Skip to content

Commit

Permalink
Merge pull request oneapi-src#1415 from GeorgeWeb/georgi/hip-atomic-m…
Browse files Browse the repository at this point in the history
…emory-caps

[HIP] Enable more ordering and scope capabilities for atomic memory ops
  • Loading branch information
kbenzie authored Jun 13, 2024
2 parents 2c4303c + 08b19b2 commit 0e32bb5
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,19 +779,36 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
ur_memory_order_capability_flags_t Capabilities =
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELAXED |
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE |
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE;
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE |
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL;
#if __HIP_PLATFORM_NVIDIA__
// Nvidia introduced fence.sc for seq_cst only since SM 7.0.
int Major = 0;
UR_CHECK_ERROR(hipDeviceGetAttribute(
&Major, hipDeviceAttributeComputeCapabilityMajor, hDevice->get()));
if (Major >= 7)
Capabilities |= UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST;
#else
Capabilities |= UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST;
#endif
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
// SYCL2020 4.6.4.2 minimum mandated capabilities for
// atomic_fence/memory_scope_capabilities.
// Because scopes are hierarchical, wider scopes support all narrower
// scopes. At a minimum, each device must support WORK_ITEM, SUB_GROUP and
// WORK_GROUP. (https://github.com/KhronosGroup/SYCL-Docs/pull/382)
ur_memory_scope_capability_flags_t Capabilities =
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_ITEM |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SUB_GROUP |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_DEVICE;
#if __HIP_PLATFORM_NVIDIA__
// Nvidia introduced system scope atomics only since SM 6.0.
int Major = 0;
UR_CHECK_ERROR(hipDeviceGetAttribute(
&Major, hipDeviceAttributeComputeCapabilityMajor, hDevice->get()));
if (Major >= 6)
Capabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
#else
Capabilities |= UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
#endif
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
Expand Down

0 comments on commit 0e32bb5

Please sign in to comment.