Guard against IPC signal use of when profiling copy APIs.

Also update IPC signal API text to allow single process profiling with IPC signals.

Change-Id: I90b246623129d57183acb4ba1789beec360547c3
Αυτή η υποβολή περιλαμβάνεται σε:
Sean Keely
2018-01-30 18:59:44 -06:00
γονέας 91f559802d
υποβολή f59b001c75
3 αρχεία άλλαξαν με 15 προσθήκες και 3 διαγραφές
@@ -643,7 +643,7 @@ hsa_status_t GpuAgent::DmaCopy(void* dst, core::Agent& dst_agent,
if (profiling_enabled()) {
// Track the agent so we could translate the resulting timestamp to system
// domain correctly.
out_signal.async_copy_agent(this);
out_signal.async_copy_agent(core::Agent::Convert(this->public_handle()));
}
hsa_status_t stat = blit->SubmitLinearCopyCommand(dst, src, size, dep_signals, out_signal);
@@ -333,6 +333,16 @@ hsa_status_t hsa_amd_profiling_get_async_copy_time(
return HSA_STATUS_ERROR;
}
// Validate the embedded agent pointer if the signal is IPC.
if (signal->isIPC()) {
for (auto it : core::Runtime::runtime_singleton_->gpu_agents()) {
if (it == agent) break;
}
// If the agent isn't a GPU then it is from a different process or it's a CPU.
// Assume it's a CPU and illegal uses will generate garbage data same as kernel completion.
agent = core::Runtime::runtime_singleton_->cpu_agents()[0];
}
if (agent->device_type() == core::Agent::DeviceType::kAmdGpuDevice) {
// Translate timestamp from GPU to system domain.
static_cast<amd::GpuAgentInt*>(agent)->TranslateTime(signal, *time);
@@ -387,8 +387,10 @@ typedef enum {
HSA_AMD_SIGNAL_AMD_GPU_ONLY = 1,
/**
* Signal may be used for interprocess communication.
* This signal may not be used with profiling APIs. Errors or inaccurate
* timing data may result from such use.
* IPC signals can be read, written, and waited on from any process.
* Profiling using an IPC enabled signal is only supported in a single process
* at a time. Producing profiling data in one process and consuming it in
* another process is undefined.
*/
HSA_AMD_SIGNAL_IPC = 2,
} hsa_amd_signal_attribute_t;