Skip to content

Commit 74c1b6e

Browse files
committed
Add DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT device info query.
This gates support for the EnqueueDeviceGlobalVariableRead and Write operations. The CTS tests for these now check for support before running, and all adapters report their support correctly.
1 parent 5d5c810 commit 74c1b6e

File tree

9 files changed

+43
-1
lines changed

9 files changed

+43
-1
lines changed

include/ur_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,9 @@ typedef enum ur_device_info_t {
15301530
///< version than older devices.
15311531
UR_DEVICE_INFO_VIRTUAL_MEMORY_SUPPORT = 114, ///< [::ur_bool_t] return true if the device supports virtual memory.
15321532
UR_DEVICE_INFO_ESIMD_SUPPORT = 115, ///< [::ur_bool_t] return true if the device supports ESIMD.
1533+
UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT = 116, ///< [::ur_bool_t] return true if the device supports the
1534+
///< `EnqueueDeviceGlobalVariableWrite` and
1535+
///< `EnqueueDeviceGlobalVariableRead` entry points.
15331536
UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP = 0x2000, ///< [::ur_bool_t] returns true if the device supports the creation of
15341537
///< bindless images
15351538
UR_DEVICE_INFO_BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001, ///< [::ur_bool_t] returns true if the device supports the creation of

include/ur_print.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,9 @@ inline std::ostream &operator<<(std::ostream &os, ur_device_info_t value) {
24012401
case UR_DEVICE_INFO_ESIMD_SUPPORT:
24022402
os << "UR_DEVICE_INFO_ESIMD_SUPPORT";
24032403
break;
2404+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
2405+
os << "UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT";
2406+
break;
24042407
case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP:
24052408
os << "UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP";
24062409
break;
@@ -3809,6 +3812,18 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info
38093812

38103813
os << ")";
38113814
} break;
3815+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
3816+
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
3817+
if (sizeof(ur_bool_t) > size) {
3818+
os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")";
3819+
return UR_RESULT_ERROR_INVALID_SIZE;
3820+
}
3821+
os << (const void *)(tptr) << " (";
3822+
3823+
os << *tptr;
3824+
3825+
os << ")";
3826+
} break;
38123827
case UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP: {
38133828
const ur_bool_t *tptr = (const ur_bool_t *)ptr;
38143829
if (sizeof(ur_bool_t) > size) {

scripts/core/device.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ etors:
396396
desc: "[$x_bool_t] return true if the device supports virtual memory."
397397
- name: ESIMD_SUPPORT
398398
desc: "[$x_bool_t] return true if the device supports ESIMD."
399+
- name: GLOBAL_VARIABLE_SUPPORT
400+
desc: "[$x_bool_t] return true if the device supports the `EnqueueDeviceGlobalVariableWrite` and `EnqueueDeviceGlobalVariableRead` entry points."
399401
--- #--------------------------------------------------------------------------
400402
type: function
401403
desc: "Retrieves various information about device"

source/adapters/cuda/device.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10221022
return ReturnValue(true);
10231023
case UR_DEVICE_INFO_ESIMD_SUPPORT:
10241024
return ReturnValue(false);
1025+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1026+
return ReturnValue(true);
10251027
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10261028
case UR_DEVICE_INFO_GPU_EU_COUNT:
10271029
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/adapters/hip/device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
823823
return ReturnValue(false);
824824
case UR_DEVICE_INFO_ESIMD_SUPPORT:
825825
return ReturnValue(false);
826-
826+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
827+
return ReturnValue(false);
827828
// TODO: Investigate if this information is available on HIP.
828829
case UR_DEVICE_INFO_GPU_EU_COUNT:
829830
case UR_DEVICE_INFO_GPU_EU_SIMD_WIDTH:

source/adapters/level_zero/device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
825825
return ReturnValue(result);
826826
}
827827

828+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
829+
return ReturnValue(true);
830+
828831
default:
829832
urPrint("Unsupported ParamName in urGetDeviceInfo\n");
830833
urPrint("ParamName=%d(0x%x)\n", ParamName, ParamName);

source/adapters/opencl/device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
787787
{"cl_intel_program_scope_host_pipe"}, Supported));
788788
return ReturnValue(Supported);
789789
}
790+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT: {
791+
bool Supported = false;
792+
CL_RETURN_ON_FAILURE(cl_adapter::checkDeviceExtensions(
793+
cl_adapter::cast<cl_device_id>(hDevice),
794+
{"cl_intel_global_variable_access"}, Supported));
795+
return ReturnValue(Supported);
796+
}
790797
case UR_DEVICE_INFO_QUEUE_PROPERTIES:
791798
case UR_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES:
792799
case UR_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES:

test/conformance/testing/include/uur/fixtures.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,13 @@ struct urGlobalVariableTest : uur::urKernelExecutionTest {
12711271
program_name = "device_global";
12721272
global_var = {"_Z7dev_var", 0};
12731273
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());
1274+
bool global_var_support = false;
1275+
ASSERT_SUCCESS(urDeviceGetInfo(
1276+
device, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT,
1277+
sizeof(global_var_support), &global_var_support, nullptr));
1278+
if (!global_var_support) {
1279+
GTEST_SKIP() << "Global variable access is not supported";
1280+
}
12741281
}
12751282

12761283
GlobalVar<int> global_var;

tools/urinfo/urinfo.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ inline void printDeviceInfos(ur_device_handle_t hDevice,
323323
std::cout << prefix;
324324
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_ESIMD_SUPPORT);
325325
std::cout << prefix;
326+
printDeviceInfo<ur_bool_t>(hDevice, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT);
327+
std::cout << prefix;
326328
printDeviceInfo<ur_bool_t>(hDevice,
327329
UR_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP);
328330
std::cout << prefix;

0 commit comments

Comments
 (0)