Skip to content

Commit 08b19b2

Browse files
author
Georgi Mirazchiyski
committed
[HIP] Enable device and system memory scope for atomics on HIP
1 parent b11b346 commit 08b19b2

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

source/adapters/hip/device.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,15 +794,21 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
794794
return ReturnValue(Capabilities);
795795
}
796796
case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
797-
// SYCL2020 4.6.4.2 minimum mandated capabilities for
798-
// atomic_fence/memory_scope_capabilities.
799-
// Because scopes are hierarchical, wider scopes support all narrower
800-
// scopes. At a minimum, each device must support WORK_ITEM, SUB_GROUP and
801-
// WORK_GROUP. (https://github.com/KhronosGroup/SYCL-Docs/pull/382)
802797
ur_memory_scope_capability_flags_t Capabilities =
803798
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
804799
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
805-
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
800+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP |
801+
UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE;
802+
#if __HIP_PLATFORM_NVIDIA__
803+
// Nvidia introduced system scope atomics only since SM 6.0.
804+
int Major = 0;
805+
UR_CHECK_ERROR(hipDeviceGetAttribute(
806+
&Major, hipDeviceAttributeComputeCapabilityMajor, hDevice->get()));
807+
if (Major >= 6)
808+
Capabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
809+
#else
810+
Capabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
811+
#endif
806812
return ReturnValue(Capabilities);
807813
}
808814
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {

0 commit comments

Comments
 (0)