-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #876 from AlexeySachkov/private/asachkov/tests-for…
…-oneapi-composite-device Add tests for `sycl_ext_oneapi_composite_device` extension
- Loading branch information
Showing
7 changed files
with
783 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
if(SYCL_CTS_ENABLE_EXT_ONEAPI_COMPOSITE_DEVICE_TESTS) | ||
set(test_cases_list | ||
aspects.cpp | ||
descendent_device.cpp | ||
device_info_descriptors.cpp | ||
enumerating_composite_devices.cpp | ||
more_complex_test_cases.cpp | ||
) | ||
|
||
add_cts_test(${test_cases_list}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/******************************************************************************* | ||
// | ||
// SYCL 2020 Conformance Test Suite | ||
// | ||
// Copyright (c) 2024 The Khronos Group Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
*******************************************************************************/ | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
|
||
#include "../../common/get_cts_object.h" | ||
|
||
#include <algorithm> | ||
#include <type_traits> | ||
#include <vector> | ||
|
||
namespace composite_device::tests { | ||
|
||
TEST_CASE("Test for aspects of composite devices", | ||
"[oneapi_composite_device]") { | ||
#ifndef SYCL_EXT_ONEAPI_COMPOSITE_DEVICE | ||
SKIP( | ||
"The sycl_ext_oneapi_composite device extension is not supported by an " | ||
"implementation"); | ||
#else | ||
auto platform = sycl_cts::util::get_cts_object::platform(); | ||
auto platform_composite_devices = platform.ext_oneapi_get_composite_devices(); | ||
auto all_composite_devices = | ||
sycl::ext::oneapi::experimental::get_composite_devices(); | ||
|
||
INFO( | ||
"Checking that all devices returned by platform::get_composite_devices() " | ||
"and by sycl::ext::oneapi::experimental::get_composite_devices() have " | ||
"sycl_ext_oneapi_is_composite aspect"); | ||
REQUIRE(std::all_of( | ||
platform_composite_devices.begin(), platform_composite_devices.end(), | ||
[&](sycl::device composite_device) { | ||
return composite_device.has(sycl::aspect::ext_oneapi_is_composite); | ||
})); | ||
REQUIRE(std::all_of( | ||
all_composite_devices.begin(), all_composite_devices.end(), | ||
[&](sycl::device composite_device) { | ||
return composite_device.has(sycl::aspect::ext_oneapi_is_composite); | ||
})); | ||
|
||
INFO( | ||
"Checking that none of devices returned by " | ||
"platform::get_composite_devices() " | ||
"and by sycl::ext::oneapi::experimental::get_composite_devices() have " | ||
"sycl_ext_oneapi_is_component aspect"); | ||
REQUIRE(std::none_of( | ||
platform_composite_devices.begin(), platform_composite_devices.end(), | ||
[&](sycl::device composite_device) { | ||
return composite_device.has(sycl::aspect::ext_oneapi_is_component); | ||
})); | ||
REQUIRE(std::none_of( | ||
all_composite_devices.begin(), all_composite_devices.end(), | ||
[&](sycl::device composite_device) { | ||
return composite_device.has(sycl::aspect::ext_oneapi_is_component); | ||
})); | ||
|
||
#endif | ||
} | ||
|
||
TEST_CASE("Test for ext_oneapi_is_component aspect", | ||
"[oneapi_composite_device]") { | ||
#ifndef SYCL_EXT_ONEAPI_COMPOSITE_DEVICE | ||
SKIP( | ||
"The sycl_ext_oneapi_composite device extension is not supported by an " | ||
"implementation"); | ||
#else | ||
|
||
auto device = sycl_cts::util::get_cts_object::device(); | ||
|
||
if (!device.has(sycl::aspect::ext_oneapi_is_component)) | ||
SKIP( | ||
"The selected device doesn't have ext_oneapi_is_component aspect, this " | ||
"test has nothing to check"); | ||
|
||
INFO( | ||
"Checking that a component device is not considered a composite device " | ||
"at the same time"); | ||
REQUIRE(!device.has(sycl::aspect::ext_oneapi_is_composite)); | ||
|
||
std::vector<sycl::info::partition_property> supported_partitions = | ||
device.get_info<sycl::info::device::partition_properties>(); | ||
INFO( | ||
"Checking that sub-devices of a component device are not considered to " | ||
"be component devices"); | ||
for (auto selected_partition : supported_partitions) { | ||
switch (selected_partition) { | ||
case sycl::info::partition_property::partition_equally: { | ||
constexpr size_t count = 2; // Guaranteed to work by SYCL 2020 spec. | ||
auto sub_devices = device.create_sub_devices< | ||
sycl::info::partition_property::partition_equally>(count); | ||
REQUIRE(std::none_of(sub_devices.begin(), sub_devices.end(), | ||
[&](sycl::device sub_device) { | ||
return sub_device.has( | ||
sycl::aspect::ext_oneapi_is_component); | ||
})); | ||
|
||
} break; | ||
case sycl::info::partition_property::partition_by_counts: { | ||
const std::vector<size_t> counts = {1, 1}; | ||
auto sub_devices = device.create_sub_devices< | ||
sycl::info::partition_property::partition_by_counts>(counts); | ||
REQUIRE(std::none_of(sub_devices.begin(), sub_devices.end(), | ||
[&](sycl::device sub_device) { | ||
return sub_device.has( | ||
sycl::aspect::ext_oneapi_is_component); | ||
})); | ||
} break; | ||
case sycl::info::partition_property::partition_by_affinity_domain: { | ||
auto supported_domains = | ||
device.get_info<sycl::info::device::partition_affinity_domains>(); | ||
for (auto domain : supported_domains) { | ||
auto sub_devices = device.create_sub_devices< | ||
sycl::info::partition_property::partition_by_affinity_domain>( | ||
domain); | ||
REQUIRE(std::none_of(sub_devices.begin(), sub_devices.end(), | ||
[&](sycl::device sub_device) { | ||
return sub_device.has( | ||
sycl::aspect::ext_oneapi_is_component); | ||
})); | ||
} | ||
} break; | ||
default: | ||
// Unknown partition type, do nothing | ||
; | ||
} | ||
} | ||
|
||
#endif | ||
} | ||
|
||
} // namespace composite_device::tests |
88 changes: 88 additions & 0 deletions
88
tests/extension/oneapi_composite_device/descendent_device.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/******************************************************************************* | ||
// | ||
// SYCL 2020 Conformance Test Suite | ||
// | ||
// Copyright (c) 2024 The Khronos Group Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
*******************************************************************************/ | ||
|
||
#include <sycl/sycl.hpp> | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
|
||
#include "../../common/get_cts_object.h" | ||
|
||
#include <algorithm> | ||
#include <vector> | ||
|
||
namespace composite_device::tests { | ||
|
||
TEST_CASE("Test for impact on descendent device", "[oneapi_composite_device]") { | ||
#ifndef SYCL_EXT_ONEAPI_COMPOSITE_DEVICE | ||
SKIP( | ||
"The sycl_ext_oneapi_composite device extension is not supported by an " | ||
"implementation"); | ||
#else | ||
|
||
auto component_device = sycl_cts::util::get_cts_object::device(); | ||
if (!component_device.has(sycl::aspect::ext_oneapi_is_component)) { | ||
SKIP( | ||
"Selected device is not a component device, this test has nothing to " | ||
"do"); | ||
} | ||
|
||
auto composite_device = component_device.get_info< | ||
sycl::ext::oneapi::experimental::info::device::composite_device>(); | ||
|
||
INFO( | ||
"Checking that a queue for a component device can be created using " | ||
"context of the corresponding composite device"); | ||
|
||
sycl::context composite_context(composite_device); | ||
sycl::queue q(composite_context, component_device); | ||
|
||
INFO( | ||
"Checking that a queue for a component device created using context of " | ||
"the corresponding composite device can be used to perform simple " | ||
"operations"); | ||
|
||
constexpr size_t count = 100; | ||
std::vector<int> a(count), b(count); | ||
std::iota(a.begin(), a.end(), 0); | ||
std::iota(b.begin(), b.end(), 42); | ||
|
||
sycl::buffer bufA(a); | ||
sycl::buffer bufB(b); | ||
sycl::buffer<int> bufC(sycl::range{count}); | ||
|
||
q.submit([&](sycl::handler& cgh) { | ||
sycl::accessor accA(bufA, cgh, sycl::read_only); | ||
sycl::accessor accB(bufB, cgh, sycl::read_only); | ||
sycl::accessor accC(bufC, cgh, sycl::write_only); | ||
|
||
cgh.parallel_for(sycl::range{count}, | ||
[=](sycl::id<1> it) { accC[it] = accA[it] + accB[it]; }); | ||
}); | ||
|
||
auto hostAcc = bufC.get_host_access(); | ||
INFO("Verifying kernel (vector add) results"); | ||
for (size_t i = 0; i < count; ++i) { | ||
REQUIRE(a[i] + b[i] == hostAcc[i]); | ||
} | ||
|
||
#endif | ||
} | ||
|
||
} // namespace composite_device::tests |
Oops, something went wrong.