Skip to content

[SYCL] Rewrite Tests Containing Deprecated Overloads #1 #16278

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 1 commit into from
Dec 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@

#include <sycl/sycl.hpp>

constexpr auto Props = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_linear_work_group_size<4>,
};
struct TestKernelLaunchBounds {
void operator()() const {}
auto get(sycl::ext::oneapi::experimental::properties_tag) { return Props; }
};

int main() {
sycl::queue Q;

constexpr auto Props = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_linear_work_group_size<4>,
};
// CHECK-IR: spir_kernel void @{{.*}}LaunchBoundsKernel(){{.*}} #[[LaunchBoundsAttrs:[0-9]+]]
Q.single_task<class LaunchBoundsKernel>(Props, []() {});
Q.submit([&](sycl::handler &h) {
h.single_task<class LaunchBoundsKernel>(TestKernelLaunchBounds{});
});

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,47 @@

#include <sycl/sycl.hpp>

constexpr auto Props1 = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_work_group_size<8>};
constexpr auto Props2 = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_work_group_size<8, 4>};
constexpr auto Props3 = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_work_group_size<8, 4, 2>};

struct TestKernel_Props1 {
void operator()() const {}
auto get(sycl::ext::oneapi::experimental::properties_tag) { return Props1; }
};

struct TestKernel_Props2 {
void operator()() const {}
auto get(sycl::ext::oneapi::experimental::properties_tag) { return Props2; }
};

struct TestKernel_Props3 {
void operator()() const {}
auto get(sycl::ext::oneapi::experimental::properties_tag) { return Props3; }
};

int main() {
sycl::queue Q;
sycl::event Ev;

constexpr auto Props1 = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_work_group_size<8>};
constexpr auto Props2 = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_work_group_size<8, 4>};
constexpr auto Props3 = sycl::ext::oneapi::experimental::properties{
sycl::ext::oneapi::experimental::max_work_group_size<8, 4, 2>};

// CHECK-IR: spir_kernel void @{{.*}}MaxWGSizeKernel0(){{.*}} #[[MaxWGSizeAttr0:[0-9]+]]
// CHECK-IR-SAME: !max_work_group_size ![[MaxWGSizeMD0:[0-9]+]]
Q.single_task<class MaxWGSizeKernel0>(Props1, []() {});
Q.single_task<class MaxWGSizeKernel0>(TestKernel_Props1{});
// CHECK-IR: spir_kernel void @{{.*}}MaxWGSizeKernel1(){{.*}} #[[MaxWGSizeAttr1:[0-9]+]]
// CHECK-IR-SAME: !max_work_group_size ![[MaxWGSizeMD1:[0-9]+]]
Q.single_task<class MaxWGSizeKernel1>(Ev, Props2, []() {});
Q.submit([&](sycl::handler &h) {
h.depends_on(Ev);
h.single_task<class MaxWGSizeKernel1>(TestKernel_Props2{});
});
// CHECK-IR: spir_kernel void @{{.*}}MaxWGSizeKernel2(){{.*}} #[[MaxWGSizeAttr2:[0-9]+]]
// CHECK-IR-SAME: !max_work_group_size ![[MaxWGSizeMD2:[0-9]+]]
Q.single_task<class MaxWGSizeKernel2>({Ev}, Props3, []() {});
Q.submit([&](sycl::handler &h) {
h.depends_on({Ev});
h.single_task<class MaxWGSizeKernel2>(TestKernel_Props3{});
});

return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,128 +54,245 @@ int funcIndirectlyUsingCPU(int a, int b) { return funcUsingCPU(a, b, 1); }
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((device_has<aspect::fp64>))
int funcUsingCPUHasFP64(int a) { return funcIndirectlyUsingCPU(a, 1); }

constexpr auto props_64 = properties{device_has<aspect::fp64>};
constexpr auto props_16 = properties{device_has<aspect::fp16>};
constexpr auto props_1664 = properties{device_has<aspect::fp16, aspect::fp64>};
constexpr auto props_6416 = properties{device_has<aspect::fp64, aspect::fp16>};
constexpr auto props_gpu = properties{device_has<aspect::gpu>};
constexpr auto props_gpu1664 =
properties{device_has<aspect::gpu, aspect::fp16, aspect::fp64>};
constexpr auto props_1664gpu =
properties{device_has<aspect::fp16, aspect::fp64, aspect::gpu>};
constexpr auto props_emp = properties{};
constexpr auto props_cpu = properties{device_has<aspect::cpu>};
constexpr auto props_cpu64 = properties{device_has<aspect::cpu, aspect::fp64>};
constexpr auto props_64cpu = properties{device_has<aspect::fp64, aspect::cpu>};
constexpr auto props_gpucpu64 =
properties{device_has<aspect::gpu, aspect::cpu, aspect::fp64>};
constexpr auto props_cpu64gpu =
properties{device_has<aspect::cpu, aspect::fp64, aspect::gpu>};

template <typename T> struct K_funcIndirectlyUsingFP16 {
T *Props;
K_funcIndirectlyUsingFP16(T Props_param) { Props = &Props_param; };
void operator()() const { int a = funcIndirectlyUsingFP16(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcIndirectlyUsingFP16_Warn16 {
T *Props;
K_funcIndirectlyUsingFP16_Warn16(T Props_param) { Props = &Props_param; };
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'fp16' not listed in its 'device_has' property}}
void operator()() const { int a = funcIndirectlyUsingFP16(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingFP16AndFP64 {
T *Props;
K_funcUsingFP16AndFP64(T Props_param) { Props = &Props_param; };
void operator()() const { int a = funcUsingFP16AndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingFP16AndFP64_Warn16 {
T *Props;
K_funcUsingFP16AndFP64_Warn16(T Props_param) { Props = &Props_param; };
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'fp16' not listed in its 'device_has' property}}
void operator()() const { int a = funcUsingFP16AndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingFP16AndFP64_Warn64 {
T *Props;
K_funcUsingFP16AndFP64_Warn64(T Props_param) { Props = &Props_param; };
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
void operator()() const { int a = funcUsingFP16AndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingFP16AndFP64_Warn1664 {
T *Props;
K_funcUsingFP16AndFP64_Warn1664(T Props_param) { Props = &Props_param; };
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp16' not listed in its 'device_has' property}}
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
void operator()() const { int a = funcUsingFP16AndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingFP16AndFP64_False {
T *Props;
K_funcUsingFP16AndFP64_False(T Props_param) { Props = &Props_param; };
void operator()() const {
if constexpr (false) {
int a = funcUsingFP16AndFP64(1, 2);
}
}
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingCPUHasFP64 {
T *Props;
K_funcUsingCPUHasFP64(T Props_param) { Props = &Props_param; };
void operator()() const { int a = funcUsingCPUHasFP64(1); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcIndirectlyUsingCPU {
T *Props;
K_funcIndirectlyUsingCPU(T Props_param) { Props = &Props_param; };
void operator()() const { int a = funcIndirectlyUsingCPU(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcIndirectlyUsingCPU_WarnCPU {
T *Props;
K_funcIndirectlyUsingCPU_WarnCPU(T Props_param) { Props = &Props_param; };
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'cpu' not listed in its 'device_has' property}}
void operator()() const { int a = funcIndirectlyUsingCPU(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingCPUAndFP64 {
T *Props;
K_funcUsingCPUAndFP64(T Props_param) { Props = &Props_param; };
void operator()() const { int a = funcUsingCPUAndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingCPUAndFP64_WarnCPU {
T *Props;
K_funcUsingCPUAndFP64_WarnCPU(T Props_param) { Props = &Props_param; };
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'cpu' not listed in its 'device_has' property}}
void operator()() const { int a = funcUsingCPUAndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingCPUAndFP64_Warn64 {
T *Props;
K_funcUsingCPUAndFP64_Warn64(T Props_param) { Props = &Props_param; };
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
void operator()() const { int a = funcUsingCPUAndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingCPUAndFP64_Warn64CPU {
T *Props;
K_funcUsingCPUAndFP64_Warn64CPU(T Props_param) { Props = &Props_param; };
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'cpu' not listed in its 'device_has' property}}
// expected-warning-re@+1 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
void operator()() const { int a = funcUsingCPUAndFP64(1, 2); }
auto get(properties_tag) { return *Props; }
};

template <typename T> struct K_funcUsingCPUAndFP64_False {
T *Props;
K_funcUsingCPUAndFP64_False(T Props_param) { Props = &Props_param; };
void operator()() const {
if constexpr (false) {
int a = funcUsingCPUAndFP64(1, 2);
}
}
auto get(properties_tag) { return *Props; }
};

int main() {
queue Q;
Q.submit([&](handler &CGH) {
CGH.single_task([=]() { int a = funcUsingFP16HasFP64(1); });
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp16' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::fp64>},
[=]() { int a = funcIndirectlyUsingFP16(1, 2); });
CGH.single_task(
K_funcIndirectlyUsingFP16_Warn16<decltype(props_64)>(props_64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp16>},
[=]() { int a = funcIndirectlyUsingFP16(1, 2); });
CGH.single_task(K_funcIndirectlyUsingFP16<decltype(props_16)>(props_16));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp16, aspect::fp64>},
[=]() { int a = funcIndirectlyUsingFP16(1, 2); });
CGH.single_task(
K_funcIndirectlyUsingFP16<decltype(props_1664)>(props_1664));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp64, aspect::fp16>},
[=]() { int a = funcIndirectlyUsingFP16(1, 2); });
CGH.single_task(
K_funcIndirectlyUsingFP16<decltype(props_6416)>(props_6416));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+3 {{function '{{.*}}' uses aspect 'fp16' not listed in its 'device_has' property}}
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::gpu>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
CGH.single_task(
K_funcUsingFP16AndFP64_Warn1664<decltype(props_gpu)>(props_gpu));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::fp16>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
CGH.single_task(
K_funcUsingFP16AndFP64_Warn64<decltype(props_16)>(props_16));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp16' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::fp64>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
CGH.single_task(
K_funcUsingFP16AndFP64_Warn16<decltype(props_64)>(props_64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::gpu>}, [=]() {
if constexpr (false) {
int a = funcUsingFP16AndFP64(1, 2);
}
});
CGH.single_task(
K_funcUsingFP16AndFP64_False<decltype(props_gpu)>(props_gpu));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp16, aspect::fp64>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
CGH.single_task(
K_funcUsingFP16AndFP64_Warn16<decltype(props_1664)>(props_1664));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp64, aspect::fp16>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
CGH.single_task(
K_funcUsingFP16AndFP64_Warn16<decltype(props_6416)>(props_6416));
});
Q.submit([&](handler &CGH) {
CGH.single_task(
properties{device_has<aspect::gpu, aspect::fp16, aspect::fp64>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
K_funcUsingFP16AndFP64_Warn16<decltype(props_gpu1664)>(props_gpu1664));
});
Q.submit([&](handler &CGH) {
CGH.single_task(
properties{device_has<aspect::fp16, aspect::fp64, aspect::gpu>},
[=]() { int a = funcUsingFP16AndFP64(1, 2); });
K_funcUsingFP16AndFP64_Warn16<decltype(props_1664gpu)>(props_1664gpu));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{}, [=]() { int a = funcUsingCPUHasFP64(1); });
CGH.single_task(K_funcUsingCPUHasFP64<decltype(props_emp)>(props_emp));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'cpu' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::fp64>},
[=]() { int a = funcIndirectlyUsingCPU(1, 2); });
CGH.single_task(
K_funcIndirectlyUsingCPU_WarnCPU<decltype(props_64)>(props_64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::cpu>},
[=]() { int a = funcIndirectlyUsingCPU(1, 2); });
CGH.single_task(K_funcIndirectlyUsingCPU<decltype(props_cpu)>(props_cpu));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::cpu, aspect::fp64>},
[=]() { int a = funcIndirectlyUsingCPU(1, 2); });
CGH.single_task(
K_funcIndirectlyUsingCPU<decltype(props_cpu64)>(props_cpu64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp64, aspect::cpu>},
[=]() { int a = funcIndirectlyUsingCPU(1, 2); });
CGH.single_task(
K_funcIndirectlyUsingCPU<decltype(props_64cpu)>(props_64cpu));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+3 {{function '{{.*}}' uses aspect 'cpu' not listed in its 'device_has' property}}
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::gpu>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
CGH.single_task(
K_funcUsingCPUAndFP64_Warn64CPU<decltype(props_gpu)>(props_gpu));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'fp64' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::cpu>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
CGH.single_task(
K_funcUsingCPUAndFP64_Warn64<decltype(props_cpu)>(props_cpu));
});
Q.submit([&](handler &CGH) {
// expected-warning-re@+2 {{function '{{.*}}' uses aspect 'cpu' not listed in its 'device_has' property}}
CGH.single_task(properties{device_has<aspect::fp64>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
CGH.single_task(
K_funcUsingCPUAndFP64_WarnCPU<decltype(props_64)>(props_64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::gpu>}, [=]() {
if constexpr (false) {
int a = funcUsingCPUAndFP64(1, 2);
}
});
CGH.single_task(
K_funcUsingCPUAndFP64_False<decltype(props_gpu)>(props_gpu));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::cpu, aspect::fp64>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
CGH.single_task(K_funcUsingCPUAndFP64<decltype(props_cpu64)>(props_cpu64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(properties{device_has<aspect::fp64, aspect::cpu>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
CGH.single_task(K_funcUsingCPUAndFP64<decltype(props_64cpu)>(props_64cpu));
});
Q.submit([&](handler &CGH) {
CGH.single_task(
properties{device_has<aspect::gpu, aspect::cpu, aspect::fp64>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
K_funcUsingCPUAndFP64<decltype(props_gpucpu64)>(props_gpucpu64));
});
Q.submit([&](handler &CGH) {
CGH.single_task(
properties{device_has<aspect::cpu, aspect::fp64, aspect::gpu>},
[=]() { int a = funcUsingCPUAndFP64(1, 2); });
K_funcUsingCPUAndFP64<decltype(props_cpu64gpu)>(props_cpu64gpu));
});
}
Loading
Loading