Skip to content

[SYCL][E2E] Remove subgroup supported checks from e2e tests #14313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 0 additions & 5 deletions sycl/test-e2e/Basic/linear-sub_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//
//===----------------------------------------------------------------------===//

#include "../SubGroup/helper.hpp"
#include <algorithm>
#include <cstdio>
#include <cstdlib>
Expand All @@ -20,10 +19,6 @@ using namespace sycl;

int main(int argc, char *argv[]) {
queue q;
if (!core_sg_supported(q.get_device())) {
std::cout << "Skipping test\n";
return 0;
}

// Fill output array with sub-group IDs
const uint32_t outer = 2;
Expand Down
18 changes: 13 additions & 5 deletions sycl/test-e2e/Regression/get_subgroup_sizes.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// UNSUPPORTED: accelerator
// TODO: FPGAs currently report `sub_group_sizes` as non-empty list,
// despite not having extension `cl_intel_required_subgroup_size`
// UNSUPPORTED: cuda || hip
// TODO: Similar issue to FPGAs

// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

Expand All @@ -18,13 +24,15 @@ int main() {
queue Q;
auto Dev = Q.get_device();
auto Vec = Dev.get_info<info::device::extensions>();
std::vector<size_t> SubGroupSizes =
Dev.get_info<sycl::info::device::sub_group_sizes>();
if (std::find(Vec.begin(), Vec.end(), "cl_intel_required_subgroup_size") !=
std::end(Vec)) {
std::vector<size_t> SubGroupSizes =
Dev.get_info<sycl::info::device::sub_group_sizes>();
std::vector<size_t>::const_iterator MaxIter =
std::max_element(SubGroupSizes.begin(), SubGroupSizes.end());
int MaxSubGroup_size = *MaxIter;
assert(!SubGroupSizes.empty() &&
"Required sub-group size list should not be empty");
} else {
assert(SubGroupSizes.empty() &&
"Required sub-group size list should be empty");
}
return 0;
}
22 changes: 8 additions & 14 deletions sycl/test-e2e/SubGroup/attributes.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// UNSUPPORTED: accelerator
// TODO: FPGAs currently report supported subgroups as {4,8,16,32,64}, causing
// this test to fail
// UNSUPPORTED: cuda || hip
// TODO: Device subgroup sizes reports {32}, but when we try to use it with a
// kernel attribute and check it, we get a subgroup size of 0.

// RUN: %{build} -fsycl-device-code-split=per_kernel -o %t.out
// RUN: %{run} %t.out
//==------- attributes.cpp - SYCL sub_group attributes test ----*- C++ -*---==//
Expand All @@ -13,7 +20,7 @@
#define KERNEL_FUNCTOR_WITH_SIZE(SIZE) \
class KernelFunctor##SIZE { \
public: \
[[intel::reqd_sub_group_size(SIZE)]] void \
[[sycl::reqd_sub_group_size(SIZE)]] void \
operator()(sycl::nd_item<1> Item) const { \
const auto GID = Item.get_global_id(); \
} \
Expand Down Expand Up @@ -49,19 +56,6 @@ int main() {
queue Queue;
device Device = Queue.get_device();

// According to specification, this kernel query requires `cl_khr_subgroups`
// or `cl_intel_subgroups`, and also `cl_intel_required_subgroup_size`
auto Vec = Device.get_info<info::device::extensions>();
if (std::find(Vec.begin(), Vec.end(), "cl_intel_subgroups") ==
std::end(Vec) &&
std::find(Vec.begin(), Vec.end(), "cl_khr_subgroups") ==
std::end(Vec) ||
std::find(Vec.begin(), Vec.end(), "cl_intel_required_subgroup_size") ==
std::end(Vec)) {
std::cout << "Skipping test\n";
return 0;
}

try {
const auto SGSizes = Device.get_info<info::device::sub_group_sizes>();

Expand Down
21 changes: 0 additions & 21 deletions sycl/test-e2e/SubGroup/helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,3 @@ void exit_if_not_equal_vec(vec<T, N> val, vec<T, N> ref, const char *name) {
exit(1);
}
}

bool core_sg_supported(const device &Device) {
auto Vec = Device.get_info<info::device::extensions>();
if (std::find(Vec.begin(), Vec.end(), "cl_khr_subgroups") != std::end(Vec))
return true;

if (std::find(Vec.begin(), Vec.end(), "cl_intel_subgroups") != std::end(Vec))
return true;

if (Device.get_backend() == sycl::backend::opencl) {
// Extract the numerical version from the version string, OpenCL version
// string have the format "OpenCL <major>.<minor> <vendor specific data>".
std::string ver = Device.get_info<info::device::version>().substr(7, 3);

// cl_khr_subgroups was core in OpenCL 2.1 and 2.2, but went back to
// optional in 3.0
return ver >= "2.1" && ver < "3.0";
}

return false;
}
74 changes: 34 additions & 40 deletions sycl/test-e2e/SubGroup/info.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// UNSUPPORTED: accelerator
// TODO: FPGAs currently report supported subgroups as {4,8,16,32,64}, causing
// this test to fail. Additionally, the kernel max_sub_group_size checks
// crash on FPGAs
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

Expand All @@ -17,14 +21,20 @@ int main() {
queue Queue;
device Device = Queue.get_device();

/* Basic sub-group functionality is supported as part of cl_khr_subgroups
* extension or as core OpenCL 2.1 feature. */
if (!core_sg_supported(Device)) {
std::cout << "Skipping test\n";
return 0;
bool old_opencl = false;
if (Device.get_backend() == sycl::backend::opencl) {
// Extract the numerical version from the version string, OpenCL version
// string have the format "OpenCL <major>.<minor> <vendor specific data>".
std::string ver = Device.get_info<info::device::version>().substr(7, 3);
old_opencl = (ver < "2.1");
}

/* Check info::device parameters. */
Device.get_info<info::device::sub_group_independent_forward_progress>();
if (!old_opencl) {
// Independent forward progress is missing on OpenCL backend prior to
// version 2.1
Device.get_info<info::device::sub_group_independent_forward_progress>();
}
Device.get_info<info::device::max_num_sub_groups>();

try {
Expand All @@ -49,30 +59,24 @@ int main() {
});
uint32_t Res = 0;

/* sub_group_sizes can be queried only if cl_intel_required_subgroup_size
* extension is supported by device*/
auto Vec = Device.get_info<info::device::extensions>();
if (std::find(Vec.begin(), Vec.end(), "cl_intel_required_subgroup_size") !=
std::end(Vec)) {
auto sg_sizes = Device.get_info<info::device::sub_group_sizes>();
auto sg_sizes = Device.get_info<info::device::sub_group_sizes>();

// Max sub-group size for a particular kernel might not be the max
// supported size on the device in general. Can only check that it is
// contained in list of valid sizes.
Res = Kernel.get_info<info::kernel_device_specific::max_sub_group_size>(
Device);
bool Expected =
std::find(sg_sizes.begin(), sg_sizes.end(), Res) != sg_sizes.end();
exit_if_not_equal<bool>(Expected, true, "max_sub_group_size");

// Max sub-group size for a particular kernel might not be the max
// supported size on the device in general. Can only check that it is
// contained in list of valid sizes.
for (auto r : {range<3>(3, 4, 5), range<3>(1, 1, 1), range<3>(4, 2, 1),
range<3>(32, 3, 4), range<3>(7, 9, 11)}) {
Res = Kernel.get_info<info::kernel_device_specific::max_sub_group_size>(
Device);
bool Expected =
Expected =
std::find(sg_sizes.begin(), sg_sizes.end(), Res) != sg_sizes.end();
exit_if_not_equal<bool>(Expected, true, "max_sub_group_size");

for (auto r : {range<3>(3, 4, 5), range<3>(1, 1, 1), range<3>(4, 2, 1),
range<3>(32, 3, 4), range<3>(7, 9, 11)}) {
Res = Kernel.get_info<info::kernel_device_specific::max_sub_group_size>(
Device);
Expected =
std::find(sg_sizes.begin(), sg_sizes.end(), Res) != sg_sizes.end();
exit_if_not_equal<bool>(Expected, true, "max_sub_group_size");
}
}

Res = Kernel.get_info<info::kernel_device_specific::compile_num_sub_groups>(
Expand All @@ -81,21 +85,11 @@ int main() {
/* Sub-group size is not specified in kernel or IL*/
exit_if_not_equal<uint32_t>(Res, 0, "compile_num_sub_groups");

// According to specification, this kernel query requires `cl_khr_subgroups`
// or `cl_intel_subgroups`
if ((std::find(Vec.begin(), Vec.end(), "cl_khr_subgroups") !=
std::end(Vec)) ||
std::find(Vec.begin(), Vec.end(), "cl_intel_subgroups") !=
std::end(Vec) &&
std::find(Vec.begin(), Vec.end(),
"cl_intel_required_subgroup_size") != std::end(Vec)) {
Res =
Kernel.get_info<info::kernel_device_specific::compile_sub_group_size>(
Device);

/* Required sub-group size is not specified in kernel or IL*/
exit_if_not_equal<uint32_t>(Res, 0, "compile_sub_group_size");
}
Res = Kernel.get_info<info::kernel_device_specific::compile_sub_group_size>(
Device);

/* Required sub-group size is not specified in kernel or IL*/
exit_if_not_equal<uint32_t>(Res, 0, "compile_sub_group_size");

} catch (exception e) {
std::cout << "SYCL exception caught: " << e.what();
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#include <iostream>
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class KernelName_AJprOaCZgUmsYFRTTGNw, int>(Queue);
check<class KernelName_ShKFIYTqaI, unsigned int>(Queue);
check<class KernelName_TovsKTk, long>(Queue);
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/reduce_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class KernelName_oMg, sycl::half>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/reduce_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class KernelName_alTnImqzYasRyHjYg, double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/reduce_spirv13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#include <iostream>
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}

check_mul<class MulA, int>(Queue);
check_mul<class MulB, unsigned int>(Queue);
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/reduce_spirv13_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check_mul<class MulHalf, sycl::half>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/reduce_spirv13_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
#include <iostream>
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check_mul<class MulDouble, double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class KernelName_QTbNYAsEmawQ, int>(Queue);
check<class KernelName_FQFNSdcVGrCLUbn, unsigned int>(Queue);
check<class KernelName_kWYnyHJx, long>(Queue);
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/scan_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
#include <iostream>
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class KernelName_dlpo, sycl::half>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/scan_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
#include <iostream>
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class KernelName_cYZflKkIXS, double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/scan_spirv13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check_mul<class MulA, int>(Queue);
check_mul<class MulB, unsigned int>(Queue);
check_mul<class MulC, long>(Queue);
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/scan_spirv13_fp16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check_mul<class MulHalf, sycl::half>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/scan_spirv13_fp64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check<class MulDouble, double>(Queue);
std::cout << "Test passed." << std::endl;
return 0;
Expand Down
4 changes: 0 additions & 4 deletions sycl/test-e2e/SubGroup/vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ void check(queue Queue, const int G, const int L, const int D, const int R) {
}
int main() {
queue Queue;
if (!core_sg_supported(Queue.get_device())) {
std::cout << "Skipping test\n";
return 0;
}
check(Queue, 240, 80, 3, 1);
check(Queue, 24, 12, 3, 4);
check(Queue, 1024, 256, 3, 1);
Expand Down
Loading