Skip to content

Commit

Permalink
Merge pull request oneapi-src#1414 from GeorgeWeb/georgi/hip-fences
Browse files Browse the repository at this point in the history
[HIP] Enable more ordering and scope capabilities for atomic fences
  • Loading branch information
kbenzie authored Jun 13, 2024
2 parents abe85cc + 3e011c7 commit 2c4303c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions source/adapters/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE;
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_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
Expand All @@ -795,6 +794,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
UR_MEMORY_SCOPE_CAPABILITY_FLAG_WORK_GROUP;
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
constexpr 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_DEVICE |
UR_MEMORY_SCOPE_CAPABILITY_FLAG_SYSTEM;
return ReturnValue(Capabilities);
}
case UR_DEVICE_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: {
// SYCL2020 4.6.4.2 minimum mandated capabilities for
// atomic_fence_order_capabilities.
Expand All @@ -803,6 +811,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQUIRE |
UR_MEMORY_ORDER_CAPABILITY_FLAG_RELEASE |
UR_MEMORY_ORDER_CAPABILITY_FLAG_ACQ_REL;
#ifdef __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_DEVICE_ID: {
Expand Down

0 comments on commit 2c4303c

Please sign in to comment.