Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An optimization to the function of findGlobalPool #1442

Open
wants to merge 2 commits into
base: clang_tot_upgrade
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions include/kalmar_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,18 @@ class KalmarDevice
});
return def;
#else
std::shared_ptr<KalmarQueue> result;
std::thread::id tid = std::this_thread::get_id();
tlsDefaultQueueMap_mutex.lock();
if (tlsDefaultQueueMap.find(tid) == tlsDefaultQueueMap.end()) {
tlsDefaultQueueMap[tid] = createQueue();
if (tlsDefaultQueueMap.find(tid) != tlsDefaultQueueMap.end()) {
result = tlsDefaultQueueMap[tid];
} else {
tlsDefaultQueueMap_mutex.lock();
if (tlsDefaultQueueMap.find(tid) == tlsDefaultQueueMap.end()) {
tlsDefaultQueueMap[tid] = createQueue();
}
result = tlsDefaultQueueMap[tid];
tlsDefaultQueueMap_mutex.unlock();
}
std::shared_ptr<KalmarQueue> result = tlsDefaultQueueMap[tid];
tlsDefaultQueueMap_mutex.unlock();
return result;
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions lib/hsa/unpinned_copy_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ static hsa_status_t findGlobalPool(hsa_amd_memory_pool_t pool, void* data)
if ((HSA_AMD_SEGMENT_GLOBAL == segment) &&
(flag & HSA_AMD_MEMORY_POOL_GLOBAL_FLAG_FINE_GRAINED)) {
*((hsa_amd_memory_pool_t*)data) = pool;
return HSA_STATUS_INFO_BREAK;
}
return HSA_STATUS_SUCCESS;
}
Expand Down Expand Up @@ -96,6 +97,7 @@ UnpinnedCopyEngine::UnpinnedCopyEngine(hsa_agent_t hsaAgent, hsa_agent_t cpuAgen
{
hsa_amd_memory_pool_t sys_pool;
hsa_status_t err = hsa_amd_agent_iterate_memory_pools(_cpuAgent, findGlobalPool, &sys_pool);
ErrorCheck(err);

// Generate a packed C-style array of agents, for use below with hsa_amd_agents_allow_access
// TODO - should this include the CPU agents as well?
Expand Down