Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL] Adjust tests to info descriptor changes #1107

Merged
merged 4 commits into from
Aug 5, 2022
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
31 changes: 22 additions & 9 deletions SYCL/Basic/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <sycl/sycl.hpp>

#include <cassert>
#include <cstdint>
#include <iostream>
#include <string>
#include <strstream>
#include <sycl/sycl.hpp>
#include <type_traits>

using namespace sycl;

Expand Down Expand Up @@ -175,9 +178,9 @@ template <> std::string info_to_string(device info) {
return "SYCL OpenCL device";
}

template <> std::string info_to_string(id<3> info) {
template <int Dim> std::string info_to_string(id<Dim> info) {
std::string str;
for (size_t i = 0; i < 3; ++i) {
for (size_t i = 0; i < Dim; ++i) {
str += info_to_string(info[i]) + " ";
}
return str;
Expand All @@ -194,15 +197,21 @@ template <typename T> std::string info_to_string(std::vector<T> info) {
return str;
}

template <info::device param, typename T>
template <typename Param, typename ExpectedReturnT>
void print_info(const device &dev, const std::string &name) {
T result(dev.get_info<param>());
static_assert(
std::is_same<typename Param::return_type, ExpectedReturnT>::value,
"Unexpected info query return type");
ExpectedReturnT result = dev.get_info<Param>();
std::cout << name << ": " << info_to_string(result) << std::endl;
}

template <info::platform param, typename T>
template <typename Param, typename ExpectedReturnT>
void print_info(const platform &plt, const std::string &name) {
T result(plt.get_info<param>());
static_assert(
std::is_same<typename Param::return_type, ExpectedReturnT>::value,
"Unexpected info query return type");
ExpectedReturnT result(plt.get_info<Param>());
std::cout << name << ": " << info_to_string(result) << std::endl;
}

Expand All @@ -218,8 +227,12 @@ int main() {
dev, "Max compute units");
print_info<info::device::max_work_item_dimensions, sycl::cl_uint>(
dev, "Max work item dimensions");
print_info<info::device::max_work_item_sizes, id<3>>(dev,
"Max work item sizes");
print_info<info::device::max_work_item_sizes<1>, id<1>>(
dev, "Max work item sizes 1D");
print_info<info::device::max_work_item_sizes<2>, id<2>>(
dev, "Max work item sizes 2D");
print_info<info::device::max_work_item_sizes<3>, id<3>>(
dev, "Max work item sizes 3D");
print_info<info::device::max_work_group_size, size_t>(dev,
"Max work group size");
print_info<info::device::preferred_vector_width_char, sycl::cl_uint>(
Expand Down
8 changes: 0 additions & 8 deletions SYCL/Basic/kernel_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ int main() {
const size_t wgSize =
krn.get_info<info::kernel_device_specific::work_group_size>(dev);
assert(wgSize > 0);
const size_t wgSizeNew =
krn.get_info<info::kernel_device_specific::work_group_size>(dev);
assert(wgSizeNew > 0);
assert(wgSize == wgSizeNew);
const size_t prefWGSizeMult = krn.get_info<
info::kernel_device_specific::preferred_work_group_size_multiple>(dev);
assert(prefWGSizeMult > 0);
const size_t prefWGSizeMultNew = krn.get_info<
info::kernel_device_specific::preferred_work_group_size_multiple>(dev);
assert(prefWGSizeMultNew > 0);
assert(prefWGSizeMult == prefWGSizeMultNew);
}
8 changes: 0 additions & 8 deletions SYCL/DeprecatedFeatures/kernel_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ int main() {
const size_t wgSize =
krn.get_info<info::kernel_device_specific::work_group_size>(dev);
assert(wgSize > 0);
const size_t wgSizeNew =
krn.get_info<info::kernel_device_specific::work_group_size>(dev);
assert(wgSizeNew > 0);
assert(wgSize == wgSizeNew);
const size_t prefWGSizeMult = krn.get_info<
info::kernel_device_specific::preferred_work_group_size_multiple>(dev);
assert(prefWGSizeMult > 0);
const size_t prefWGSizeMultNew = krn.get_info<
info::kernel_device_specific::preferred_work_group_size_multiple>(dev);
assert(prefWGSizeMultNew > 0);
assert(prefWGSizeMult == prefWGSizeMultNew);
}
4 changes: 2 additions & 2 deletions SYCL/SubGroup/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ int main() {

auto Kernel = TheKernel[0];

auto Res = Kernel.get_sub_group_info<
sycl::info::kernel_sub_group::compile_sub_group_size>(Device);
auto Res = Kernel.get_info<
sycl::info::kernel_device_specific::compile_sub_group_size>(Device);

exit_if_not_equal<size_t>(Res, ReqdSize, "compile_sub_group_size");
}
Expand Down
24 changes: 1 addition & 23 deletions SYCL/SubGroup/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,14 @@ int main() {
auto sg_sizes = Device.get_info<info::device::sub_group_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_sub_group_info<info::kernel_sub_group::max_sub_group_size>(
Device, r);
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");

Res = Kernel.get_info<info::kernel_device_specific::max_sub_group_size>(
Device, r);
Expected =
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");
}
}

Res =
Kernel
.get_sub_group_info<info::kernel_sub_group::compile_num_sub_groups>(
Device);

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

Res = Kernel.get_info<info::kernel_device_specific::compile_num_sub_groups>(
Device);

Expand All @@ -100,12 +84,6 @@ int main() {
std::end(Vec) &&
std::find(Vec.begin(), Vec.end(),
"cl_intel_required_subgroup_size") != std::end(Vec)) {
Res = Kernel.get_sub_group_info<
info::kernel_sub_group::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);
Expand Down