Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/extension/khr_max_num_work_groups/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(SYCL_CTS_ENABLE_MAX_NUM_WORK_GROUPS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused. Should it be SYCL_CTS_ENABLE_KHR_MAX_NUM_WORK_GROUPS instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a bug vs line 130

file(GLOB test_cases_list *.cpp)

add_cts_test(${test_cases_list})
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2025 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 "../../common/common.h"

namespace max_num_work_groups_macro::tests {
TEST_CASE(
"the max_num_work_groups extension defines the "
"SYCL_KHR_MAX_NUM_WORK_GROUPS macro",
"[khr_max_num_work_groups]") {
#ifndef SYCL_KHR_MAX_NUM_WORK_GROUPS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/how is this macro set?

Copy link
Contributor Author

@Aympab Aympab Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This macro is set by the SYCL implementation
It's a requirement when the extension is implemented, the macro should be defined
(See https://github.com/Aympab/SYCL-Docs/blob/khr-max-num-wg/adoc/extensions/sycl_khr_max_num_work_groups.adoc#L15 )

static_assert(false, "SYCL_KHR_MAX_NUM_WORK_GROUPS is not defined");
#endif
}
} // namespace max_num_work_groups_macro::tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2025 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 "../../common/common.h"

namespace max_num_work_groups::tests {

template <int DIMENSION>
void check_min_size() {
auto queue = sycl_cts::util::get_cts_object::queue();
auto dev = queue.get_device();

check_get_info_param<khr::info::device::max_num_work_groups<DIMENSION>,
sycl::range<DIMENSION>>(dev);

if (dev.get_info<sycl::info::device::device_type>() ==
sycl::info::device_type::custom) {
return;
} else {
auto max_work_groups =
dev.get_info<khr::info::device::max_num_work_groups<DIMENSION>>();

for (int i = 0; i < DIMENSION; i++) {
CHECK(max_work_groups[i] >= 1);
}
}
}

TEST_CASE("if the device is not info::device_type::custom, the minimal",
"size in each dimension is (1,1,1)", "[khr_max_num_work_groups]") {
check_min_size<1>();
check_min_size<2>();
check_min_size<3>();
}

} // namespace max_num_work_groups::tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*******************************************************************************
//
// SYCL 2020 Conformance Test Suite
//
// Copyright (c) 2025 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 "../../common/common.h"

namespace max_num_work_groups::tests {

template <int DIMENSION>
void check_submit() {
auto queue = sycl_cts::util::get_cts_object::queue();
auto dev = queue.get_device();

auto max_work_groups_nd =
dev.get_info<sycl::info::device::max_num_work_groups<DIMENSION>>();
auto local = sycl::range<DIMENSION>();
for (int i = 0; i < DIMENSION; i++) {
local[i] = 1;
// to avoid running too long
max_work_groups_nd[i] = std::min(
max_work_groups_nd[i],
static_cast<size_t>(std::numeric_limits<unsigned int>::max() + 1));
}

int* a = sycl::malloc_shared<int>(1, queue);
a[0] = 0;
queue
.parallel_for(sycl::nd_range(max_work_groups_nd, local),
[=](auto i) {
if (i.get_global_id(0) == 0) a[0] = 1;
})
.wait_and_throw();

CHECK(a[0] == 1);

sycl::free(a, queue);
}

TEST_CASE("max_num_work_groups nd_range submission [khr_max_num_work_groups]") {
check_submit<1>();
check_submit<2>();
check_submit<3>();
}

} // namespace max_num_work_groups::tests