P4 to Git Change 1550486 by cpaquot@cpaquot-ocl-lc-lnx on 2018/05/04 14:00:33
SWDEV-145570 - [HIP] Fix multithread init
Make the g_ihipInitialized variable per thread
And make sure to assign a default g_context
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_context.cpp#10 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#9 edit
[ROCm/hip commit: 9129aa17f6]
This commit is contained in:
@@ -28,12 +28,12 @@ THE SOFTWARE.
|
||||
#include <thread>
|
||||
|
||||
std::vector<amd::Context*> g_devices;
|
||||
std::once_flag g_ihipInitialized;
|
||||
|
||||
namespace hip {
|
||||
|
||||
thread_local amd::Context* g_context = nullptr;
|
||||
thread_local std::stack<amd::Context*> g_ctxtStack;
|
||||
std::once_flag g_ihipInitialized;
|
||||
|
||||
std::map<amd::Context*,amd::HostQueue*> g_nullStreams;
|
||||
|
||||
@@ -53,7 +53,6 @@ void init() {
|
||||
context->release();
|
||||
} else {
|
||||
g_devices.push_back(context);
|
||||
g_context = context;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,26 +28,29 @@ THE SOFTWARE.
|
||||
#include <thread>
|
||||
|
||||
#define HIP_INIT() \
|
||||
std::call_once(g_ihipInitialized, hip::init);
|
||||
|
||||
std::call_once(hip::g_ihipInitialized, hip::init); \
|
||||
assert(g_devices.size() > 0); \
|
||||
if (hip::g_context == nullptr) { \
|
||||
hip::g_context = g_devices[0]; \
|
||||
}
|
||||
|
||||
// This macro should be called at the beginning of every HIP API.
|
||||
#define HIP_INIT_API(...) \
|
||||
HIP_INIT(); \
|
||||
\
|
||||
amd::Thread* thread = amd::Thread::current(); \
|
||||
if (!CL_CHECK_THREAD(thread)) { \
|
||||
return hipErrorOutOfMemory; \
|
||||
}
|
||||
} \
|
||||
HIP_INIT();
|
||||
|
||||
namespace hc {
|
||||
class accelerator;
|
||||
class accelerator_view;
|
||||
};
|
||||
|
||||
extern std::once_flag g_ihipInitialized;
|
||||
|
||||
namespace hip {
|
||||
extern std::once_flag g_ihipInitialized;
|
||||
extern thread_local amd::Context* g_context;
|
||||
|
||||
extern void init();
|
||||
|
||||
extern amd::Context* getCurrentContext();
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user