Skip to content

Commit

Permalink
Remove CONTEXT_INFO_ATOMIC queries.
Browse files Browse the repository at this point in the history
These were used as dummy values in the sycl runtime to implement
meta-queries for each device in the given context. The affiliated LLVM
change for this PR updates that to use __SYCL_TRAIT_HANDLED_IN_RT
instead.

Fixes #2119
  • Loading branch information
aarongreig committed Feb 4, 2025
1 parent 7d864b6 commit f3fdd84
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 254 deletions.
16 changes: 1 addition & 15 deletions include/ur_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2941,20 +2941,6 @@ typedef enum ur_context_info_t {
/// [::ur_bool_t] to indicate if the ::urEnqueueUSMFill2D entrypoint is
/// supported.
UR_CONTEXT_INFO_USM_FILL2D_SUPPORT = 4,
/// [::ur_memory_order_capability_flags_t][optional-query] return a
/// bit-field of atomic memory order capabilities.
UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 5,
/// [::ur_memory_scope_capability_flags_t][optional-query] return a
/// bit-field of atomic memory scope capabilities.
UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 6,
/// [::ur_memory_order_capability_flags_t][optional-query] return a
/// bit-field of atomic memory fence order capabilities.
/// Zero is returned if the backend does not support context-level fences.
UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES = 7,
/// [::ur_memory_scope_capability_flags_t][optional-query] return a
/// bit-field of atomic memory fence scope capabilities.
/// Zero is returned if the backend does not support context-level fences.
UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES = 8,
/// @cond
UR_CONTEXT_INFO_FORCE_UINT32 = 0x7fffffff
/// @endcond
Expand Down Expand Up @@ -3003,7 +2989,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextRelease(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES < propName`
/// + `::UR_CONTEXT_INFO_USM_FILL2D_SUPPORT < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
72 changes: 0 additions & 72 deletions include/ur_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5881,18 +5881,6 @@ inline std::ostream &operator<<(std::ostream &os,
case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT:
os << "UR_CONTEXT_INFO_USM_FILL2D_SUPPORT";
break;
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
os << "UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES";
break;
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
os << "UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES";
break;
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
os << "UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES";
break;
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES:
os << "UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES";
break;
default:
os << "unknown enumerator";
break;
Expand Down Expand Up @@ -5976,66 +5964,6 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr,

os << ")";
} break;
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: {
const ur_memory_order_capability_flags_t *tptr =
(const ur_memory_order_capability_flags_t *)ptr;
if (sizeof(ur_memory_order_capability_flags_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_memory_order_capability_flags_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

ur::details::printFlag<ur_memory_order_capability_flag_t>(os, *tptr);

os << ")";
} break;
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
const ur_memory_scope_capability_flags_t *tptr =
(const ur_memory_scope_capability_flags_t *)ptr;
if (sizeof(ur_memory_scope_capability_flags_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

ur::details::printFlag<ur_memory_scope_capability_flag_t>(os, *tptr);

os << ")";
} break;
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES: {
const ur_memory_order_capability_flags_t *tptr =
(const ur_memory_order_capability_flags_t *)ptr;
if (sizeof(ur_memory_order_capability_flags_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_memory_order_capability_flags_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

ur::details::printFlag<ur_memory_order_capability_flag_t>(os, *tptr);

os << ")";
} break;
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
const ur_memory_scope_capability_flags_t *tptr =
(const ur_memory_scope_capability_flags_t *)ptr;
if (sizeof(ur_memory_scope_capability_flags_t) > size) {
os << "invalid size (is: " << size
<< ", expected: >=" << sizeof(ur_memory_scope_capability_flags_t)
<< ")";
return UR_RESULT_ERROR_INVALID_SIZE;
}
os << (const void *)(tptr) << " (";

ur::details::printFlag<ur_memory_scope_capability_flag_t>(os, *tptr);

os << ")";
} break;
default:
os << "unknown enumerator";
return UR_RESULT_ERROR_INVALID_ENUMERATION;
Expand Down
12 changes: 0 additions & 12 deletions scripts/core/context.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,6 @@ etors:
desc: "[$x_bool_t] to indicate if the $xEnqueueUSMMemcpy2D entrypoint is supported."
- name: USM_FILL2D_SUPPORT
desc: "[$x_bool_t] to indicate if the $xEnqueueUSMFill2D entrypoint is supported."
- name: ATOMIC_MEMORY_ORDER_CAPABILITIES
desc: "[$x_memory_order_capability_flags_t][optional-query] return a bit-field of atomic memory order capabilities."
- name: ATOMIC_MEMORY_SCOPE_CAPABILITIES
desc: "[$x_memory_scope_capability_flags_t][optional-query] return a bit-field of atomic memory scope capabilities."
- name: ATOMIC_FENCE_ORDER_CAPABILITIES
desc: |
[$x_memory_order_capability_flags_t][optional-query] return a bit-field of atomic memory fence order capabilities.
Zero is returned if the backend does not support context-level fences.
- name: ATOMIC_FENCE_SCOPE_CAPABILITIES
desc: |
[$x_memory_scope_capability_flags_t][optional-query] return a bit-field of atomic memory fence scope capabilities.
Zero is returned if the backend does not support context-level fences.
--- #--------------------------------------------------------------------------
type: function
desc: "Releases the context handle reference indicating end of its usage"
Expand Down
28 changes: 0 additions & 28 deletions source/adapters/cuda/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,34 +74,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextGetInfo(
hContext->getDevices().size());
case UR_CONTEXT_INFO_REFERENCE_COUNT:
return ReturnValue(hContext->getReferenceCount());
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: {
uint32_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_ACQ_REL;
return ReturnValue(Capabilities);
}
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: {
int Major = 0;
UR_CHECK_ERROR(cuDeviceGetAttribute(
&Major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
hContext->getDevices()[0]->get()));
uint32_t Capabilities =
(Major >= 7) ? 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
: 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;
return ReturnValue(Capabilities);
}
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT:
// 2D USM memcpy is supported.
return ReturnValue(true);
Expand Down
8 changes: 0 additions & 8 deletions source/adapters/hip/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
hContext->getDevices().size());
case UR_CONTEXT_INFO_REFERENCE_COUNT:
return ReturnValue(hContext->getReferenceCount());
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
// These queries should be dealt with in context_impl.cpp by calling the
// queries of each device separately and building the intersection set.
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT:
// 2D USM memcpy is supported.
return ReturnValue(true);
Expand Down
15 changes: 0 additions & 15 deletions source/adapters/level_zero/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,6 @@ ur_result_t urContextGetInfo(
case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT:
// 2D USM fill is not supported.
return ReturnValue(uint8_t{false});
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: {

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_ACQ_REL |
UR_MEMORY_ORDER_CAPABILITY_FLAG_SEQ_CST;
return ReturnValue(Capabilities);
}
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}

default:
// TODO: implement other parameters
Expand Down
6 changes: 0 additions & 6 deletions source/adapters/level_zero/v2/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,6 @@ ur_result_t urContextGetInfo(ur_context_handle_t hContext,
case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT:
// 2D USM fill is not supported.
return ReturnValue(uint8_t{false});
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
6 changes: 0 additions & 6 deletions source/adapters/native_cpu/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
// case UR_CONTEXT_INFO_USM_MEMSET2D_SUPPORT:
// 2D USM operations currently not supported.
return returnValue(false);
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
default:
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}
Expand Down
8 changes: 0 additions & 8 deletions source/adapters/opencl/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: {
return ReturnValue(false);
}
case UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES:
case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: {
/* These queries should be dealt with in context_impl.cpp by calling the
* queries of each device separately and building the intersection set. */
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
case UR_CONTEXT_INFO_NUM_DEVICES:
case UR_CONTEXT_INFO_DEVICES:
case UR_CONTEXT_INFO_REFERENCE_COUNT: {
Expand Down
2 changes: 1 addition & 1 deletion source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ __urdlllocal ur_result_t UR_APICALL urContextGetInfo(
if (pPropValue == NULL && pPropSizeRet == NULL)
return UR_RESULT_ERROR_INVALID_NULL_POINTER;

if (UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES < propName)
if (UR_CONTEXT_INFO_USM_FILL2D_SUPPORT < propName)
return UR_RESULT_ERROR_INVALID_ENUMERATION;

if (propSize == 0 && pPropValue != NULL)
Expand Down
2 changes: 1 addition & 1 deletion source/loader/ur_libapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ ur_result_t UR_APICALL urContextRelease(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES < propName`
/// + `::UR_CONTEXT_INFO_USM_FILL2D_SUPPORT < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
2 changes: 1 addition & 1 deletion source/ur_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ ur_result_t UR_APICALL urContextRelease(
/// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE
/// + `NULL == hContext`
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
/// + `::UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES < propName`
/// + `::UR_CONTEXT_INFO_USM_FILL2D_SUPPORT < propName`
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
/// + If `propName` is not supported by the adapter.
/// - ::UR_RESULT_ERROR_INVALID_SIZE
Expand Down
68 changes: 0 additions & 68 deletions test/conformance/context/urContextGetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,74 +77,6 @@ TEST_P(urContextGetInfoTest, SuccessReferenceCount) {
ASSERT_GT(reference_count, 0U);
}

TEST_P(urContextGetInfoTest, SuccessAtomicMemoryOrderCapabilities) {
ur_context_info_t property_name =
UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES;
size_t property_size = 0;

ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
urContextGetInfo(context, property_name, 0, nullptr, &property_size),
property_name);
ASSERT_EQ(property_size, sizeof(ur_memory_order_capability_flags_t));

ur_memory_order_capability_flags_t flags = 0;
ASSERT_SUCCESS(
urContextGetInfo(context, property_name, property_size, &flags, nullptr));

ASSERT_EQ(flags & UR_MEMORY_ORDER_CAPABILITY_FLAGS_MASK, 0);
}

TEST_P(urContextGetInfoTest, SuccessAtomicMemoryScopeCapabilities) {
ur_context_info_t property_name =
UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES;
size_t property_size = 0;

ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
urContextGetInfo(context, property_name, 0, nullptr, &property_size),
property_name);
ASSERT_EQ(property_size, sizeof(ur_memory_scope_capability_flags_t));

ur_memory_scope_capability_flags_t flags = 0;
ASSERT_SUCCESS(
urContextGetInfo(context, property_name, property_size, &flags, nullptr));

ASSERT_EQ(flags & UR_MEMORY_SCOPE_CAPABILITY_FLAGS_MASK, 0);
}

TEST_P(urContextGetInfoTest, SuccessAtomicFenceOrderCapabilities) {
ur_context_info_t property_name =
UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES;
size_t property_size = 0;

ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
urContextGetInfo(context, property_name, 0, nullptr, &property_size),
property_name);
ASSERT_EQ(property_size, sizeof(ur_memory_order_capability_flags_t));

ur_memory_order_capability_flags_t flags = 0;
ASSERT_SUCCESS(
urContextGetInfo(context, property_name, property_size, &flags, nullptr));

ASSERT_EQ(flags & UR_MEMORY_ORDER_CAPABILITY_FLAGS_MASK, 0);
}

TEST_P(urContextGetInfoTest, SuccessAtomicFenceScopeCapabilities) {
ur_context_info_t property_name =
UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES;
size_t property_size = 0;

ASSERT_SUCCESS_OR_OPTIONAL_QUERY(
urContextGetInfo(context, property_name, 0, nullptr, &property_size),
property_name);
ASSERT_EQ(property_size, sizeof(ur_memory_scope_capability_flags_t));

ur_memory_scope_capability_flags_t flags = 0;
ASSERT_SUCCESS(
urContextGetInfo(context, property_name, property_size, &flags, nullptr));

ASSERT_EQ(flags & UR_MEMORY_SCOPE_CAPABILITY_FLAGS_MASK, 0);
}

TEST_P(urContextGetInfoTest, InvalidNullHandleContext) {
uint32_t nDevices = 0;
ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_NULL_HANDLE,
Expand Down
13 changes: 0 additions & 13 deletions test/conformance/testing/include/uur/optional_queries.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ template <> inline bool isQueryOptional(ur_device_info_t query) {
query) != optional_ur_device_info_t.end();
}

constexpr std::array optional_ur_context_info_t = {
UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES,
UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES,
UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES,
UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES,
};

template <> inline bool isQueryOptional(ur_context_info_t query) {
return std::find(optional_ur_context_info_t.begin(),
optional_ur_context_info_t.end(),
query) != optional_ur_context_info_t.end();
}

constexpr std::array optional_ur_usm_alloc_info_t = {
UR_USM_ALLOC_INFO_POOL,
};
Expand Down

0 comments on commit f3fdd84

Please sign in to comment.