Skip to content

Commit 3d4583b

Browse files
aarongreigcallumfare
authored andcommitted
[SYCL][CUDA] Implement UR_DEVICE_INFO_IL_VERSION query for cuda.
1 parent e86f38d commit 3d4583b

File tree

1 file changed

+26
-0
lines changed
  • sycl/plugins/unified_runtime/ur/adapters/cuda

1 file changed

+26
-0
lines changed

sycl/plugins/unified_runtime/ur/adapters/cuda/device.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,32 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t device,
924924

925925
return ReturnValue(memory_bandwidth);
926926
}
927+
case UR_DEVICE_INFO_IL_VERSION: {
928+
std::string il_version = "nvptx-";
929+
930+
int driver_version = 0;
931+
cuDriverGetVersion(&driver_version);
932+
int major = driver_version / 1000;
933+
int minor = driver_version % 1000 / 10;
934+
935+
// We can work out which ptx ISA version we support based on the versioning
936+
// table published here
937+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#release-notes
938+
// Major versions that we support are consistent in how they line up, so we
939+
// can derive that easily. The minor versions for version 10 don't line up
940+
// the same so it needs a special case. This is not ideal but it does seem
941+
// to be the best bet to avoid a maintenance burden here.
942+
il_version += std::to_string(major - 4) + ".";
943+
if (major == 10) {
944+
il_version += std::to_string(minor + 3);
945+
} else if (major >= 11) {
946+
il_version += std::to_string(minor);
947+
} else {
948+
return UR_RESULT_ERROR_INVALID_VALUE;
949+
}
950+
951+
return ReturnValue(il_version.data(), il_version.size());
952+
}
927953
case UR_EXT_DEVICE_INFO_MAX_REGISTERS_PER_WORK_GROUP: {
928954
// Maximum number of 32-bit registers available to a thread block.
929955
// Note: This number is shared by all thread blocks simultaneously resident

0 commit comments

Comments
 (0)