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