Skip to content

Commit ae85db7

Browse files
dyniolsgmlueckkbenzie
authored
[UR] Addition of num_compute_units query (#16538)
Co-authored-by: Greg Lueck <[email protected]> Co-authored-by: Kenneth Benzie (Benie) <[email protected]>
1 parent a8ee28a commit ae85db7

File tree

10 files changed

+85
-13
lines changed

10 files changed

+85
-13
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# commit 095e8464124a48c8ed4b995403e754254c072143
2-
# Merge: 0bb6789f 07001aa7
3-
# Author: Kenneth Benzie (Benie) <k.benzie@codeplay.com>
4-
# Date: Mon Jan 27 14:53:22 2025 +0000
5-
# Merge pull request #2574 from bratpiorka/rrudnick_fix_usm_pool_config_parse
6-
# fix parseDisjointPoolConfig and add tests
7-
set(UNIFIED_RUNTIME_TAG 095e8464124a48c8ed4b995403e754254c072143)
1+
# commit 78e1b33271d28d26845a4bfae7ae3b72c14e0e63
2+
# Merge: 902bb2e2 94b32ac2
3+
# Author: Ross Brunton <ross@codeplay.com>
4+
# Date: Tue Jan 28 11:02:44 2025 +0000
5+
# Merge pull request #2624 from RossBrunton/ross/msanfix
6+
# Assert that Device is valid for memory poisoning
7+
set(UNIFIED_RUNTIME_TAG 78e1b33271d28d26845a4bfae7ae3b72c14e0e63)

sycl/doc/extensions/proposed/sycl_ext_oneapi_num_compute_units.asciidoc renamed to sycl/doc/extensions/supported/sycl_ext_oneapi_num_compute_units.asciidoc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ SYCL specification refer to that revision.
4444

4545
== Status
4646

47-
This is a proposed extension specification, intended to gather community
48-
feedback. Interfaces defined in this specification may not be implemented yet
49-
or may be in a preliminary state. The specification itself may also change in
50-
incompatible ways before it is finalized. *Shipping software products should
51-
not rely on APIs defined in this specification.*
52-
47+
This extension is implemented and fully supported by {dpcpp}.
5348

5449
== Overview
5550

sycl/include/sycl/info/ext_oneapi_device_traits.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ __SYCL_PARAM_TRAITS_SPEC(ext::oneapi::experimental, device,
8181
composite_device, sycl::device,
8282
UR_DEVICE_INFO_COMPOSITE_DEVICE)
8383

84+
__SYCL_PARAM_TRAITS_SPEC(ext::oneapi, device,
85+
num_compute_units, size_t,
86+
UR_DEVICE_INFO_NUM_COMPUTE_UNITS)
87+
8488
#ifdef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF
8589
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC
8690
#undef __SYCL_PARAM_TRAITS_TEMPLATE_SPEC_NEEDS_UNDEF

sycl/source/feature_test.hpp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ inline namespace _V1 {
112112
#define SYCL_EXT_ONEAPI_WORK_GROUP_MEMORY 1
113113
#define SYCL_EXT_ONEAPI_WORK_GROUP_SCRATCH_MEMORY 1
114114
#define SYCL_EXT_ONEAPI_WORK_GROUP_STATIC 1
115+
#define SYCL_EXT_ONEAPI_NUM_COMPUTE_UNITS 1
115116
// In progress yet
116117
#define SYCL_EXT_ONEAPI_ATOMIC16 0
117118

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test checks whether the number of compute units in the device descriptor
2+
// returns a valid value.
3+
4+
// RUN: %{build} -o %t.out
5+
// RUN: %{run} %t.out
6+
7+
#include <cassert>
8+
#include <sycl/detail/core.hpp>
9+
10+
int main() {
11+
12+
#ifdef SYCL_EXT_ONEAPI_NUM_COMPUTE_UNITS
13+
sycl::queue Queue;
14+
sycl::device Device = Queue.get_device();
15+
16+
size_t NumberComputeUnits =
17+
Device.get_info<sycl::ext::oneapi::info::device::num_compute_units>();
18+
19+
assert(NumberComputeUnits >= 1 &&
20+
"The minimum value for number of compute units in the device is 1");
21+
22+
#else
23+
static_assert(false, "SYCL_EXT_ONEAPI_NUM_COMPUTE_UNITS not defined");
24+
#endif
25+
26+
return 0;
27+
}

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4029,3 +4029,5 @@ _ZNK4sycl3_V19kernel_id8get_nameEv
40294029
_ZNKSt4hashIN4sycl3_V15queueEEclERKS2_
40304030
__sycl_register_lib
40314031
__sycl_unregister_lib
4032+
_ZNK4sycl3_V16detail11device_impl8get_infoINS0_3ext6oneapi4info6device17num_compute_unitsEEENT_11return_typeEv
4033+
_ZNK4sycl3_V16device13get_info_implINS0_3ext6oneapi4info6device17num_compute_unitsEEENS0_6detail11ABINeutralTINS8_19is_device_info_descIT_E11return_typeEE4typeEv

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4344,3 +4344,5 @@
43444344
DllMain
43454345
__sycl_register_lib
43464346
__sycl_unregister_lib
4347+
??$get_info@Unum_compute_units@device@info@oneapi@ext@_V1@sycl@@@device_impl@detail@_V1@sycl@@QEBA_KXZ
4348+
??$get_info_impl@Unum_compute_units@device@info@oneapi@ext@_V1@sycl@@@device@_V1@sycl@@AEBA_KXZ

sycl/unittests/Extensions/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ add_sycl_unittest(ExtensionsTests OBJECT
2424
add_subdirectory(CommandGraph)
2525
add_subdirectory(VirtualFunctions)
2626
add_subdirectory(VirtualMemory)
27+
add_subdirectory(NumComputeUnits)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_sycl_unittest(NumComputeUnitsTests OBJECT
2+
ReturnedQueryValue.cpp
3+
)
4+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <sycl/sycl.hpp>
2+
3+
#include "ur_api.h"
4+
5+
#include <gtest/gtest.h>
6+
#include <helpers/UrMock.hpp>
7+
8+
template <uint32_t ExpectedValue>
9+
ur_result_t after_urDeviceGetInfo(void *pParams) {
10+
auto params = reinterpret_cast<ur_device_get_info_params_t *>(pParams);
11+
if (*params->ppropName == UR_DEVICE_INFO_NUM_COMPUTE_UNITS) {
12+
if (*params->ppPropValue)
13+
*static_cast<uint32_t *>(*params->ppPropValue) = ExpectedValue;
14+
if (*params->ppPropSizeRet)
15+
**params->ppPropSizeRet = sizeof(uint32_t);
16+
}
17+
return UR_RESULT_SUCCESS;
18+
}
19+
20+
TEST(NumComputeUnitsTests, CheckExpectedValue) {
21+
22+
constexpr uint32_t ExpectedNumComputeUnits = 111;
23+
24+
sycl::unittest::UrMock<> Mock;
25+
sycl::platform Platform = sycl::platform();
26+
sycl::queue Queue{Platform.get_devices()[0]};
27+
28+
mock::getCallbacks().set_after_callback(
29+
"urDeviceGetInfo", &after_urDeviceGetInfo<ExpectedNumComputeUnits>);
30+
31+
size_t NumberComputeUnits =
32+
Queue.get_device()
33+
.get_info<sycl::ext::oneapi::info::device::num_compute_units>();
34+
35+
EXPECT_EQ(NumberComputeUnits, ExpectedNumComputeUnits);
36+
}

0 commit comments

Comments
 (0)