"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "c570fb57d4732725b9147e645f51d709bd64ce5a"
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)
return result;
}
void gpu_sync()
{
hipDeviceSynchronize();
}
} // namespace gpu
} // namespace migraph
......@@ -13,6 +13,8 @@ migraph::argument to_gpu(migraph::argument arg, bool host = false);
migraph::argument from_gpu(migraph::argument arg);
void gpu_sync();
struct hip_allocate
{
std::string tag{};
......@@ -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
{
std::string name() const { return "hip::write"; }
......
......@@ -330,6 +330,7 @@ struct miopen_apply
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 = "")
......
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