Skip to content

Commit 5303368

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 fe5bc76 commit 5303368

File tree

10 files changed

+46
-1
lines changed

10 files changed

+46
-1
lines changed

include/ur.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,9 @@ class ur_device_info_v(IntEnum):
865865
## version than older devices.
866866
VIRTUAL_MEMORY_SUPPORT = 114 ## [::ur_bool_t] return true if the device supports virtual memory.
867867
ESIMD_SUPPORT = 115 ## [::ur_bool_t] return true if the device supports ESIMD.
868+
GLOBAL_VARIABLE_SUPPORT = 116 ## [::ur_bool_t] return true if the device supports the
869+
## `EnqueueDeviceGlobalVariableWrite` and
870+
## `EnqueueDeviceGlobalVariableRead` entry points.
868871
BINDLESS_IMAGES_SUPPORT_EXP = 0x2000 ## [::ur_bool_t] returns true if the device supports the creation of
869872
## bindless images
870873
BINDLESS_IMAGES_SHARED_USM_SUPPORT_EXP = 0x2001 ## [::ur_bool_t] returns true if the device supports the creation of

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
@@ -1019,6 +1019,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10191019
return ReturnValue(false);
10201020
case UR_DEVICE_INFO_ESIMD_SUPPORT:
10211021
return ReturnValue(false);
1022+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
1023+
return ReturnValue(true);
10221024
case UR_DEVICE_INFO_MAX_READ_WRITE_IMAGE_ARGS:
10231025
case UR_DEVICE_INFO_GPU_EU_COUNT:
10241026
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
@@ -819,7 +819,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
819819
return ReturnValue(false);
820820
case UR_DEVICE_INFO_ESIMD_SUPPORT:
821821
return ReturnValue(false);
822-
822+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
823+
return ReturnValue(false);
823824
// TODO: Investigate if this information is available on HIP.
824825
case UR_DEVICE_INFO_GPU_EU_COUNT:
825826
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
@@ -800,6 +800,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(
800800
return ReturnValue(result);
801801
}
802802

803+
case UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT:
804+
return ReturnValue(true);
805+
803806
default:
804807
urPrint("Unsupported ParamName in urGetDeviceInfo\n");
805808
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
@@ -1243,6 +1243,13 @@ struct urGlobalVariableTest : uur::urKernelExecutionTest {
12431243
program_name = "device_global";
12441244
global_var = {"_Z7dev_var", 0};
12451245
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());
1246+
bool global_var_support = false;
1247+
ASSERT_SUCCESS(urDeviceGetInfo(
1248+
device, UR_DEVICE_INFO_GLOBAL_VARIABLE_SUPPORT,
1249+
sizeof(global_var_support), &global_var_support, nullptr));
1250+
if (!global_var_support) {
1251+
GTEST_SKIP() << "Global variable access is not supported";
1252+
}
12461253
}
12471254

12481255
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)