Commit 52223d46 authored by Paul's avatar Paul
Browse files

Move time_op to migraphx_gpu

parent da29ed61
......@@ -122,6 +122,7 @@ add_library(migraphx_gpu
schedule_model.cpp
sync_device.cpp
target.cpp
time_op.cpp
topk.cpp
write_literals.cpp
${JIT_GPU_SRCS}
......
......@@ -81,20 +81,17 @@ struct compile_plan
context* ctx;
operation preop;
instruction_ref ins;
optional<tuning_config> config = nullopt;
optional<tuning_config> config = nullopt;
std::vector<compiled_result> results = {};
void update_config()
{
config = get_tuning_config(*ctx, ins, preop);
}
template<class Vector>
void update_config() { config = get_tuning_config(*ctx, ins, preop); }
template <class Vector>
void add_compiles(Vector& compiles)
{
if (config.has_value())
if(config.has_value())
{
const auto& solutions = config.value().solutions;
results.resize(solutions.size());
for(auto i:range(solutions.size()))
for(auto i : range(solutions.size()))
{
auto solution = solutions[i];
compiles.emplace_back([=] {
......@@ -143,19 +140,17 @@ void compile_ops::apply(module& m) const
cps.push_back({ctx, preop, ins});
}
// Get the tuning configs for all ops
par_compile(cps.size(), [&](auto i) {
cps[i].update_config();
});
par_compile(cps.size(), [&](auto i) { cps[i].update_config(); });
// Compile everything in parallel
std::vector<std::function<void()>> compiles;
for(auto& cp:cps)
for(auto& cp : cps)
{
cp.add_compiles(compiles);
}
par_compile(compiles.size(), [&](auto i) { compiles[i](); });
// Replace and/or benchmark
for(const auto& cp:cps)
for(const auto& cp : cps)
{
cp.replace(m);
}
......
......@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <migraphx/gpu/driver/action.hpp>
#include <migraphx/gpu/driver/perf.hpp>
#include <migraphx/gpu/time_op.hpp>
#include <migraphx/gpu/compiler.hpp>
#include <migraphx/gpu/context.hpp>
......
......@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <migraphx/gpu/driver/action.hpp>
#include <migraphx/gpu/driver/perf.hpp>
#include <migraphx/gpu/time_op.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/make_op.hpp>
......
......@@ -31,12 +31,10 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace driver {
std::pair<double, double>
time_op(context& ictx, operation op, const std::vector<shape>& inputs, int n = 100);
} // namespace driver
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <migraphx/gpu/driver/perf.hpp>
#include <migraphx/gpu/time_op.hpp>
#include <migraphx/context.hpp>
#include <migraphx/generate.hpp>
#include <migraphx/time.hpp>
......@@ -30,7 +30,6 @@
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace driver {
std::vector<argument> generate_arguments(const std::vector<shape>& shapes, unsigned long seed = 0)
{
......@@ -69,7 +68,6 @@ time_op(context& ictx, operation op, const std::vector<shape>& inputs, int n)
return std::make_pair(host_time / n, device_time / n);
}
} // namespace driver
} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment