Remove a map lookup whenever we were getting the default stream

Change-Id: I64b6d1deea41d81e94a58a83de287e78923656b3
This commit is contained in:
Christophe Paquot
2020-04-09 12:44:21 -07:00
parent f03a1ef371
commit 4d9c540f4f
3 ha cambiato i file con 21 aggiunte e 22 eliminazioni
+4 -20
Vedi File
@@ -34,8 +34,6 @@ thread_local hipError_t g_lastError = hipSuccess;
std::once_flag g_ihipInitialized;
Device* host_device = nullptr;
std::map<Device*, amd::HostQueue*> g_nullStreams;
void init() {
if (!amd::Runtime::initialized()) {
amd::IS_HIP = true;
@@ -93,24 +91,10 @@ amd::HostQueue* getQueue(hipStream_t stream) {
}
}
amd::HostQueue* getNullStream(Device& dev) {
auto stream = g_nullStreams.find(&dev);
if (stream == g_nullStreams.end()) {
amd::Device* device = dev.devices()[0];
cl_command_queue_properties properties = CL_QUEUE_PROFILING_ENABLE;
amd::HostQueue* queue = new amd::HostQueue(*dev.asContext(), *device, properties,
amd::CommandQueue::RealTimeDisabled,
amd::CommandQueue::Priority::Normal);
g_nullStreams[&dev] = queue;
return queue;
}
return stream->second;
}
amd::HostQueue* getNullStream(amd::Context& ctx) {
for (auto& it : g_nullStreams) {
if (it.first->asContext() == &ctx) {
return it.second;
for (auto& it : g_devices) {
if (it->asContext() == &ctx) {
return it->defaultStream();
}
}
return nullptr;
@@ -118,7 +102,7 @@ amd::HostQueue* getNullStream(amd::Context& ctx) {
amd::HostQueue* getNullStream() {
Device* device = getCurrentDevice();
return device ? getNullStream(*device) : nullptr;
return device ? device->defaultStream() : nullptr;
}
};