Skip to content

Commit 04ba6a5

Browse files
committed
fix cuda plugin UID
1 parent 34dd9dd commit 04ba6a5

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2091,7 +2091,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
20912091
//
20922092
// Agents that do not support UUID will return the string "GPU-XX" or
20932093
// "CPU-XX" or "DSP-XX" depending on their device type.
2094-
char Uuid[24];
2094+
char Uuid[24] = {0};
20952095
if (auto Err = getDeviceAttr(HSA_AMD_AGENT_INFO_UUID, Uuid))
20962096
return Err;
20972097
if (strcmp(Uuid + 3, "-XX") != 0)

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
12161216
/// between different plugins.
12171217
std::string DeviceUid;
12181218
/// Construct the device UID from the vendor (U)UID.
1219-
void setDeviceUidFromVendorUid(const char *VendorUid);
1219+
void setDeviceUidFromVendorUid(StringRef VendorUid);
12201220

12211221
/// The default grid values used for this device.
12221222
llvm::omp::GV GridValues;

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ Expected<bool> GenericDeviceTy::isAccessiblePtr(const void *Ptr, size_t Size) {
16131613
return isAccessiblePtrImpl(Ptr, Size);
16141614
}
16151615

1616-
void GenericDeviceTy::setDeviceUidFromVendorUid(const char *VendorUid) {
1616+
void GenericDeviceTy::setDeviceUidFromVendorUid(StringRef VendorUid) {
16171617
DeviceUid = std::string(Plugin.getName()) + "-" + std::string(VendorUid);
16181618
}
16191619

offload/plugins-nextgen/cuda/dynamic_cuda/cuda.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ typedef struct CUfunc_st *CUfunction;
3333
typedef void (*CUhostFn)(void *userData);
3434
typedef struct CUstream_st *CUstream;
3535
typedef struct CUevent_st *CUevent;
36-
typedef struct CUuuid_st *CUuuid;
36+
typedef struct CUuuid_st {
37+
char bytes[16];
38+
} CUuuid;
3739

3840
#define CU_DEVICE_INVALID ((CUdevice)(-2))
3941

offload/plugins-nextgen/cuda/src/rtl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "PluginInterface.h"
2626
#include "Utils/ELF.h"
2727

28+
#include "llvm/ADT/StringExtras.h"
2829
#include "llvm/BinaryFormat/ELF.h"
2930
#include "llvm/Frontend/OpenMP/OMPConstants.h"
3031
#include "llvm/Frontend/OpenMP/OMPGridValues.h"
@@ -293,11 +294,11 @@ struct CUDADeviceTy : public GenericDeviceTy {
293294
if (auto Err = Plugin::check(Res, "error in cuDeviceGet: %s"))
294295
return Err;
295296

296-
char Uuid[16];
297-
Res = cuDeviceGetUuid(Uuid, Device);
297+
CUuuid Uuid = {0};
298+
Res = cuDeviceGetUuid(&Uuid, Device);
298299
if (auto Err = Plugin::check(Res, "error in cuDeviceGetUuid: %s"))
299300
return Err;
300-
setDeviceUidFromVendorUid(Uuid);
301+
setDeviceUidFromVendorUid(toHex(Uuid.bytes, true));
301302

302303
// Query the current flags of the primary context and set its flags if
303304
// it is inactive.

0 commit comments

Comments
 (0)