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
This commit is contained in:
Christophe Paquot
2020-02-13 10:44:10 -08:00
parent f456989339
commit cc63d2d7b8
3 ha cambiato i file con 12 aggiunte e 9 eliminazioni
+7 -5
Vedi File
@@ -536,7 +536,11 @@ extern "C" hipError_t hipLaunchByPtr(const void *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) {
HIP_RETURN(hipErrorNoDevice);
}
@@ -545,9 +549,6 @@ extern "C" hipError_t hipLaunchByPtr(const void *hostFunction)
HIP_RETURN(hipErrorInvalidDeviceFunction);
}
ihipExec_t exec;
PlatformState::instance().popExec(exec);
size_t size = exec.arguments_.size();
void *extra[] = {
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,
stream);
int deviceId = ihipGetDevice();
hip::Stream* s = reinterpret_cast<hip::Stream*>(stream);
int deviceId = (s != nullptr)? s->deviceId : ihipGetDevice();
if (deviceId == -1) {
HIP_RETURN(hipErrorNoDevice);
}