hipLaunchByPtr and hipLaunchKernel deviceId potential issue
Those APIs should look at the device associated with the stream first.
If that stream is null then get the current device ID.
Change-Id: Iedde1d1644818ba64f128b988f0bd9674f5b8ad6
[ROCm/hip commit: cc63d2d7b8]
This commit is contained in:
1 parent
9a5205cd50
commit
df7fd4fb53
3 files changed
+12
-9
No files matched your search
@@ -102,8 +102,9 @@ namespace hip {
|
|||||||
amd::Context* context;
|
amd::Context* context;
|
||||||
amd::CommandQueue::Priority priority;
|
amd::CommandQueue::Priority priority;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
|
int deviceId;
|
||||||
|
|
||||||
Stream(amd::Device* dev, amd::Context* ctx, amd::CommandQueue::Priority p, unsigned int f);
|
Stream(amd::Device* dev, amd::Context* ctx, amd::CommandQueue::Priority p, unsigned int f, int d);
|
||||||
void create();
|
void create();
|
||||||
amd::HostQueue* asHostQueue();
|
amd::HostQueue* asHostQueue();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|||||||
@@ -536,7 +536,11 @@ extern "C" hipError_t hipLaunchByPtr(const void *hostFunction)
|
|||||||
{
|
{
|
||||||
HIP_INIT_API(NONE, hostFunction);
|
HIP_INIT_API(NONE, hostFunction);
|
||||||
|
|
||||||
int deviceId = ihipGetDevice();
|
ihipExec_t exec;
|
||||||
|
PlatformState::instance().popExec(exec);
|
||||||
|
|
||||||
|
hip::Stream* stream = reinterpret_cast<hip::Stream*>(exec.hStream_);
|
||||||
|
int deviceId = (stream != nullptr)? stream->deviceId : ihipGetDevice();
|
||||||
if (deviceId == -1) {
|
if (deviceId == -1) {
|
||||||
HIP_RETURN(hipErrorNoDevice);
|
HIP_RETURN(hipErrorNoDevice);
|
||||||
}
|
}
|
||||||
@@ -545,9 +549,6 @@ extern "C" hipError_t hipLaunchByPtr(const void *hostFunction)
|
|||||||
HIP_RETURN(hipErrorInvalidDeviceFunction);
|
HIP_RETURN(hipErrorInvalidDeviceFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
ihipExec_t exec;
|
|
||||||
PlatformState::instance().popExec(exec);
|
|
||||||
|
|
||||||
size_t size = exec.arguments_.size();
|
size_t size = exec.arguments_.size();
|
||||||
void *extra[] = {
|
void *extra[] = {
|
||||||
HIP_LAUNCH_PARAM_BUFFER_POINTER, &exec.arguments_[0],
|
HIP_LAUNCH_PARAM_BUFFER_POINTER, &exec.arguments_[0],
|
||||||
@@ -940,7 +941,8 @@ extern "C" hipError_t hipLaunchKernel(const void *hostFunction,
|
|||||||
HIP_INIT_API(NONE, hostFunction, gridDim, blockDim, args, sharedMemBytes,
|
HIP_INIT_API(NONE, hostFunction, gridDim, blockDim, args, sharedMemBytes,
|
||||||
stream);
|
stream);
|
||||||
|
|
||||||
int deviceId = ihipGetDevice();
|
hip::Stream* s = reinterpret_cast<hip::Stream*>(stream);
|
||||||
|
int deviceId = (s != nullptr)? s->deviceId : ihipGetDevice();
|
||||||
if (deviceId == -1) {
|
if (deviceId == -1) {
|
||||||
HIP_RETURN(hipErrorNoDevice);
|
HIP_RETURN(hipErrorNoDevice);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ void syncStreams() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream::Stream(amd::Device* dev, amd::Context* ctx, amd::CommandQueue::Priority p, unsigned int f) :
|
Stream::Stream(amd::Device* dev, amd::Context* ctx, amd::CommandQueue::Priority p, unsigned int f, int d) :
|
||||||
queue(nullptr), device(dev), context(ctx), priority(p), flags(f) {}
|
queue(nullptr), device(dev), context(ctx), priority(p), flags(f), deviceId(d) {}
|
||||||
|
|
||||||
void Stream::create() {
|
void Stream::create() {
|
||||||
cl_command_queue_properties properties = CL_QUEUE_PROFILING_ENABLE;
|
cl_command_queue_properties properties = CL_QUEUE_PROFILING_ENABLE;
|
||||||
@@ -95,7 +95,7 @@ void CL_CALLBACK ihipStreamCallback(cl_event event, cl_int command_exec_status,
|
|||||||
static hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags, amd::CommandQueue::Priority priority) {
|
static hipError_t ihipStreamCreate(hipStream_t *stream, unsigned int flags, amd::CommandQueue::Priority priority) {
|
||||||
amd::Device* device = hip::getCurrentContext()->devices()[0];
|
amd::Device* device = hip::getCurrentContext()->devices()[0];
|
||||||
|
|
||||||
hip::Stream* hStream = new hip::Stream(device, hip::getCurrentContext(), priority, flags);
|
hip::Stream* hStream = new hip::Stream(device, hip::getCurrentContext(), priority, flags, ihipGetDevice());
|
||||||
|
|
||||||
if (hStream == nullptr) {
|
if (hStream == nullptr) {
|
||||||
return hipErrorOutOfMemory;
|
return hipErrorOutOfMemory;
|
||||||
|
|||||||
Reference in new issue
Block a user