diff --git a/source/adapters/cuda/context.cpp b/source/adapters/cuda/context.cpp index 69796cf79d..82f8d69440 100644 --- a/source/adapters/cuda/context.cpp +++ b/source/adapters/cuda/context.cpp @@ -98,13 +98,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextGetInfo( 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: case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: - // 2D USM memcpy is supported. - return ReturnValue(true); - case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: - // 2D USM operations currently not supported. - return ReturnValue(false); - + case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: { + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; + } default: break; } diff --git a/source/adapters/hip/context.cpp b/source/adapters/hip/context.cpp index 761eab954d..f3fe718e21 100644 --- a/source/adapters/hip/context.cpp +++ b/source/adapters/hip/context.cpp @@ -72,18 +72,13 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName, 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: { + case UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES: + case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: + case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: { // 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_INVALID_ENUMERATION; + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } - case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: - // 2D USM memcpy is supported. - return ReturnValue(true); - case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: - // 2D USM operations currently not supported. - return ReturnValue(false); - default: break; } diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index 296e3e98d5..212a903edc 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -126,10 +126,13 @@ ur_result_t urContextGetInfo( 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 - die("urGetContextInfo: unsuppported ParamName."); + return UR_RESULT_ERROR_INVALID_ENUMERATION; } return UR_RESULT_SUCCESS; diff --git a/source/adapters/level_zero/v2/context.cpp b/source/adapters/level_zero/v2/context.cpp index abb8a13538..422323fe76 100644 --- a/source/adapters/level_zero/v2/context.cpp +++ b/source/adapters/level_zero/v2/context.cpp @@ -104,13 +104,10 @@ ur_result_t urContextGetInfo(ur_context_handle_t hContext, case UR_CONTEXT_INFO_REFERENCE_COUNT: return ReturnValue(uint32_t{hContext->RefCount.load()}); case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: - // TODO: this is currently not implemented - return ReturnValue(uint8_t{false}); case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: - // 2D USM fill is not supported. - return ReturnValue(uint8_t{false}); + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; default: - return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; + return UR_RESULT_ERROR_INVALID_ENUMERATION; } } } // namespace ur::level_zero diff --git a/source/adapters/native_cpu/context.cpp b/source/adapters/native_cpu/context.cpp index 8efc61a024..681c34eea3 100644 --- a/source/adapters/native_cpu/context.cpp +++ b/source/adapters/native_cpu/context.cpp @@ -57,14 +57,11 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName, case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: return returnValue(true); case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: - // 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_ADAPTER_SPECIFIC; + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } default: return UR_RESULT_ERROR_INVALID_ENUMERATION; diff --git a/source/adapters/opencl/context.cpp b/source/adapters/opencl/context.cpp index 38202bbf58..f30d7ef2f4 100644 --- a/source/adapters/opencl/context.cpp +++ b/source/adapters/opencl/context.cpp @@ -79,16 +79,14 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName, switch (static_cast(propName)) { /* 2D USM memops are not supported. */ case UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT: - case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: { - return ReturnValue(false); - } + case UR_CONTEXT_INFO_USM_FILL2D_SUPPORT: 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_INVALID_ARGUMENT; + return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } case UR_CONTEXT_INFO_NUM_DEVICES: case UR_CONTEXT_INFO_DEVICES: diff --git a/test/conformance/context/urContextCreate.cpp b/test/conformance/context/urContextCreate.cpp index 0f268a3992..0dc4341bd0 100644 --- a/test/conformance/context/urContextCreate.cpp +++ b/test/conformance/context/urContextCreate.cpp @@ -36,6 +36,17 @@ TEST_P(urContextCreateTest, InvalidNullPointerContext) { urContextCreate(1, &device, nullptr, nullptr)); } +TEST_P(urContextCreateTest, InvalidEnumeration) { + auto device = GetParam(); + + ur_context_properties_t properties{UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES, + nullptr, UR_CONTEXT_FLAGS_MASK}; + uur::raii::Context context = nullptr; + + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_ENUMERATION, + urContextCreate(1, &device, &properties, context.ptr())); +} + using urContextCreateMultiDeviceTest = uur::urAllDevicesTest; TEST_F(urContextCreateMultiDeviceTest, Success) { if (devices.size() < 2) { diff --git a/test/conformance/context/urContextGetInfo.cpp b/test/conformance/context/urContextGetInfo.cpp index f9f699d511..d44797d650 100644 --- a/test/conformance/context/urContextGetInfo.cpp +++ b/test/conformance/context/urContextGetInfo.cpp @@ -17,6 +17,24 @@ struct urContextGetInfoTestWithInfoParam {UR_CONTEXT_INFO_REFERENCE_COUNT, sizeof(uint32_t)}, {UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, sizeof(bool)}, {UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, sizeof(bool)}, + {UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, + sizeof(ur_memory_order_capability_flags_t)}, + {UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, + sizeof(ur_memory_order_capability_flags_t)}, + {UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, + sizeof(ur_memory_order_capability_flags_t)}, + {UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES, + sizeof(ur_memory_order_capability_flags_t)}}; + + ctx_info_mem_flags_map = { + {UR_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES, + UR_MEMORY_ORDER_CAPABILITY_FLAGS_MASK}, + {UR_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES, + UR_MEMORY_SCOPE_CAPABILITY_FLAGS_MASK}, + {UR_CONTEXT_INFO_ATOMIC_FENCE_ORDER_CAPABILITIES, + UR_MEMORY_ORDER_CAPABILITY_FLAGS_MASK}, + {UR_CONTEXT_INFO_ATOMIC_FENCE_SCOPE_CAPABILITIES, + UR_MEMORY_SCOPE_CAPABILITY_FLAGS_MASK}, }; } @@ -26,24 +44,34 @@ struct urContextGetInfoTestWithInfoParam } std::unordered_map ctx_info_size_map; + std::unordered_map + ctx_info_mem_flags_map; }; UUR_TEST_SUITE_P(urContextGetInfoTestWithInfoParam, ::testing::Values( - UR_CONTEXT_INFO_NUM_DEVICES, // - UR_CONTEXT_INFO_DEVICES, // - UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, // - UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, // - UR_CONTEXT_INFO_REFERENCE_COUNT // - + UR_CONTEXT_INFO_NUM_DEVICES, // + UR_CONTEXT_INFO_DEVICES, // + UR_CONTEXT_INFO_USM_MEMCPY2D_SUPPORT, // + UR_CONTEXT_INFO_USM_FILL2D_SUPPORT, // + UR_CONTEXT_INFO_REFERENCE_COUNT, // + 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 // ), uur::deviceTestWithParamPrinter); TEST_P(urContextGetInfoTestWithInfoParam, Success) { ur_context_info_t info = getParam(); size_t info_size = 0; - ASSERT_SUCCESS(urContextGetInfo(context, info, 0, nullptr, &info_size)); + ur_result_t result = + urContextGetInfo(context, info, 0, nullptr, &info_size); + if (result != UR_RESULT_SUCCESS) { + ASSERT_EQ(result, UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION); + return; // exit before further checks fail because this type is unsupported + } ASSERT_NE(info_size, 0); if (const auto expected_size = ctx_info_size_map.find(info); @@ -83,6 +111,17 @@ TEST_P(urContextGetInfoTestWithInfoParam, Success) { ASSERT_GT(*returned_reference_count, 0U); break; } + 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: { + if (const auto flags = ctx_info_mem_flags_map.find(info); + flags != ctx_info_mem_flags_map.end()) { + auto value = reinterpret_cast(info_data.data()); + ASSERT_EQ(*value & flags->second, 0); + } + break; + } default: break; }