"vscode:/vscode.git/clone" did not exist on "f1b8cd2cf627edefeeb0f316a6b9e47236557530"
Commit a4bb0fdb authored by Paul's avatar Paul
Browse files

Add a device sync at the end

parent 8f08e754
...@@ -88,6 +88,11 @@ argument from_gpu(argument arg) ...@@ -88,6 +88,11 @@ argument from_gpu(argument arg)
return result; return result;
} }
void gpu_sync()
{
hipDeviceSynchronize();
}
} // namespace gpu } // namespace gpu
} // namespace migraph } // namespace migraph
...@@ -13,6 +13,8 @@ migraph::argument to_gpu(migraph::argument arg, bool host = false); ...@@ -13,6 +13,8 @@ migraph::argument to_gpu(migraph::argument arg, bool host = false);
migraph::argument from_gpu(migraph::argument arg); migraph::argument from_gpu(migraph::argument arg);
void gpu_sync();
struct hip_allocate struct hip_allocate
{ {
std::string tag{}; std::string tag{};
...@@ -44,6 +46,23 @@ struct hip_load ...@@ -44,6 +46,23 @@ struct hip_load
} }
}; };
struct hip_sync
{
std::string tag{};
std::string name() const { return "hip::sync"; }
shape compute_shape(const std::vector<shape>& inputs) const
{
if(inputs.empty()) return {};
else return inputs.front();
}
argument compute(context&, const shape&, const std::vector<argument>& args) const
{
gpu_sync();
if(args.empty()) return {};
else return args.front();
}
};
struct hip_write struct hip_write
{ {
std::string name() const { return "hip::write"; } std::string name() const { return "hip::write"; }
......
...@@ -330,6 +330,7 @@ struct miopen_apply ...@@ -330,6 +330,7 @@ struct miopen_apply
check_shape(s, apply_batch_norm_inference(it)); check_shape(s, apply_batch_norm_inference(it));
} }
} }
prog->insert_instruction(prog->end(), hip_sync{}, std::prev(prog->end()));
} }
instruction_ref insert_allocation(instruction_ref ins, const shape& s, std::string tag = "") instruction_ref insert_allocation(instruction_ref ins, const shape& s, std::string tag = "")
......
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