Lookup copy agent when blit is selected.

Disallow passing agent 0 to avoid any API change.

Change-Id: I704fb2e04cec50500fac41a405c8a7e83a3c9fb5


[ROCm/ROCR-Runtime commit: dd671b49e5]
Este commit está contenido en:
Sean Keely
2022-05-09 17:04:37 -05:00
padre a1f04fe1ed
commit bb5bb604c5
Se han modificado 2 ficheros con 20 adiciones y 20 borrados
@@ -238,18 +238,19 @@ hsa_status_t hsa_amd_memory_async_copy(void* dst, hsa_agent_t dst_agent_handle,
uint32_t num_dep_signals, const hsa_signal_t* dep_signals,
hsa_signal_t completion_signal) {
TRY;
if (dst == NULL || src == NULL) { return HSA_STATUS_ERROR_INVALID_ARGUMENT; }
IS_BAD_PTR(dst);
IS_BAD_PTR(src);
if ((num_dep_signals == 0 && dep_signals != NULL) ||
(num_dep_signals > 0 && dep_signals == NULL)) {
if ((num_dep_signals == 0 && dep_signals != nullptr) ||
(num_dep_signals > 0 && dep_signals == nullptr)) {
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
}
core::Agent* dst_agent = core::Agent::Convert(dst_agent_handle);
IS_NULL_OR_VALID(dst_agent);
IS_VALID(dst_agent);
core::Agent* src_agent = core::Agent::Convert(src_agent_handle);
IS_NULL_OR_VALID(src_agent);
IS_VALID(src_agent);
std::vector<core::Signal*> dep_signal_list(num_dep_signals);
if (num_dep_signals > 0) {
@@ -469,25 +469,24 @@ hsa_status_t Runtime::CopyMemory(void* dst, core::Agent* dst_agent, const void*
core::Agent* src_agent, size_t size,
std::vector<core::Signal*>& dep_signals,
core::Signal& completion_signal) {
auto lookupAgent = [this](core::Agent* agent, const void* ptr) {
if (agent == nullptr || flag().discover_copy_agents()) {
hsa_amd_pointer_info_t info;
PtrInfoBlockData block;
info.size = sizeof(info);
PtrInfo(ptr, &info, nullptr, nullptr, nullptr, &block);
// Limit to IPC and GFX types for now. These are the only types for which the application may
// not posess a proper agent handle.
if ((info.type != HSA_EXT_POINTER_TYPE_IPC) && (info.type != HSA_EXT_POINTER_TYPE_GRAPHICS)) {
return agent;
}
return block.agentOwner;
hsa_amd_pointer_info_t info;
PtrInfoBlockData block;
info.size = sizeof(info);
PtrInfo(ptr, &info, nullptr, nullptr, nullptr, &block);
// Limit to IPC and GFX types for now. These are the only types for which the application may
// not posess a proper agent handle.
if ((info.type != HSA_EXT_POINTER_TYPE_IPC) && (info.type != HSA_EXT_POINTER_TYPE_GRAPHICS)) {
return agent;
}
return agent;
return block.agentOwner;
};
dst_agent = lookupAgent(dst_agent, dst);
src_agent = lookupAgent(src_agent, src);
// Lookup owning agent if blit kernel is selected or if flag override is set.
if ((dst_agent == src_agent) || flag().discover_copy_agents()) {
dst_agent = lookupAgent(dst_agent, dst);
src_agent = lookupAgent(src_agent, src);
}
if (dst_agent == nullptr || src_agent == nullptr) return HSA_STATUS_ERROR_INVALID_AGENT;
// At least one agent must be available for operation in the current process.