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

Update several tests to use sycl/sycl.hpp header #444

Merged
merged 5 commits into from
Sep 13, 2021
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
45 changes: 22 additions & 23 deletions SYCL/Basic/buffer/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
//
//===----------------------------------------------------------------------===//

#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

#include <cassert>
#include <memory>

using namespace cl::sycl;
using namespace sycl;

int main() {
int data = 5;
Expand Down Expand Up @@ -506,7 +507,7 @@ int main() {
{
size_t size = 32;
const size_t dims = 1;
cl::sycl::range<dims> r(size);
sycl::range<dims> r(size);

std::shared_ptr<bool> bool_shrd(new bool[size],
[](bool *data) { delete[] data; });
Expand All @@ -522,18 +523,18 @@ int main() {
int_vector.reserve(size);
double_vector.reserve(size);

cl::sycl::queue Queue;
sycl::queue Queue;
std::mutex m;
{
cl::sycl::buffer<bool, dims> buf_bool_shrd(
sycl::buffer<bool, dims> buf_bool_shrd(
bool_shrd, r,
cl::sycl::property_list{cl::sycl::property::buffer::use_mutex(m)});
cl::sycl::buffer<int, dims> buf_int_shrd(
sycl::property_list{sycl::property::buffer::use_mutex(m)});
sycl::buffer<int, dims> buf_int_shrd(
int_shrd, r,
cl::sycl::property_list{cl::sycl::property::buffer::use_mutex(m)});
cl::sycl::buffer<double, dims> buf_double_shrd(
sycl::property_list{sycl::property::buffer::use_mutex(m)});
sycl::buffer<double, dims> buf_double_shrd(
double_shrd, r,
cl::sycl::property_list{cl::sycl::property::buffer::use_mutex(m)});
sycl::property_list{sycl::property::buffer::use_mutex(m)});
m.lock();
std::fill(bool_shrd.get(), (bool_shrd.get() + size), bool());
std::fill(int_shrd.get(), (int_shrd.get() + size), int());
Expand All @@ -547,14 +548,14 @@ int main() {
buf_int_shrd.set_write_back(true);
buf_double_shrd.set_write_back(true);

Queue.submit([&](cl::sycl::handler &cgh) {
Queue.submit([&](sycl::handler &cgh) {
auto Accessor_bool =
buf_bool_shrd.get_access<cl::sycl::access::mode::write>(cgh);
buf_bool_shrd.get_access<sycl::access::mode::write>(cgh);
auto Accessor_int =
buf_int_shrd.get_access<cl::sycl::access::mode::write>(cgh);
buf_int_shrd.get_access<sycl::access::mode::write>(cgh);
auto Accessor_double =
buf_double_shrd.get_access<cl::sycl::access::mode::write>(cgh);
cgh.parallel_for<class FillBuffer>(r, [=](cl::sycl::id<1> WIid) {
buf_double_shrd.get_access<sycl::access::mode::write>(cgh);
cgh.parallel_for<class FillBuffer>(r, [=](sycl::id<1> WIid) {
Accessor_bool[WIid] = true;
Accessor_int[WIid] = 3;
Accessor_double[WIid] = 7.5;
Expand Down Expand Up @@ -650,20 +651,18 @@ int main() {
{
std::allocator<float8> buf_alloc;
std::shared_ptr<float8> data(new float8[8], [](float8 *p) { delete[] p; });
cl::sycl::buffer<float8, 1, std::allocator<float8>> b(
data, cl::sycl::range<1>(8), buf_alloc);
sycl::buffer<float8, 1, std::allocator<float8>> b(data, sycl::range<1>(8),
buf_alloc);
}

{
constexpr int Size = 6;
cl::sycl::buffer<char, 1> Buf_1(Size);
cl::sycl::buffer<char, 1> Buf_2(Size / 2);
sycl::buffer<char, 1> Buf_1(Size);
sycl::buffer<char, 1> Buf_2(Size / 2);

{
auto AccA =
Buf_1.get_access<cl::sycl::access::mode::read_write>(Size / 2);
auto AccB =
Buf_2.get_access<cl::sycl::access::mode::read_write>(Size / 2);
auto AccA = Buf_1.get_access<sycl::access::mode::read_write>(Size / 2);
auto AccB = Buf_2.get_access<sycl::access::mode::read_write>(Size / 2);
assert(AccA.get_size() == AccB.get_size());
assert(AccA.get_range() == AccB.get_range());
assert(AccA.get_count() == AccB.get_count());
Expand Down
10 changes: 5 additions & 5 deletions SYCL/Basic/free_function_queries/free_function_queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===------------------------------------------------------------------------===//

#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

#include <cassert>
#include <iostream>
Expand All @@ -31,7 +31,7 @@ int main() {
sycl::buffer<int> buf(data, sycl::range<1>(n));
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
sycl::queue q;
q.submit([&](cl::sycl::handler &cgh) {
q.submit([&](sycl::handler &cgh) {
sycl::accessor<int, 1, sycl::access::mode::write,
sycl::access::target::global_buffer>
acc(buf.get_access<sycl::access::mode::write>(cgh));
Expand Down Expand Up @@ -65,7 +65,7 @@ int main() {
sycl::buffer<int> buf(data, sycl::range<1>(n));
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
sycl::queue q;
q.submit([&](cl::sycl::handler &cgh) {
q.submit([&](sycl::handler &cgh) {
sycl::accessor<int, 1, sycl::access::mode::write,
sycl::access::target::global_buffer>
acc(buf.get_access<sycl::access::mode::write>(cgh));
Expand Down Expand Up @@ -100,7 +100,7 @@ int main() {
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
sycl::queue q;
sycl::id<1> offset(1);
q.submit([&](cl::sycl::handler &cgh) {
q.submit([&](sycl::handler &cgh) {
sycl::accessor<int, 1, sycl::access::mode::write,
sycl::access::target::global_buffer>
acc(buf.get_access<sycl::access::mode::write>(cgh));
Expand Down Expand Up @@ -134,7 +134,7 @@ int main() {
sycl::buffer<int> results_buf(results, sycl::range<1>(checks_number));
sycl::queue q;
sycl::nd_range<1> NDR(sycl::range<1>{n}, sycl::range<1>{2});
q.submit([&](cl::sycl::handler &cgh) {
q.submit([&](sycl::handler &cgh) {
sycl::accessor<int, 1, sycl::access::mode::write,
sycl::access::target::global_buffer>
acc(buf.get_access<sycl::access::mode::write>(cgh));
Expand Down
4 changes: 2 additions & 2 deletions SYCL/Basic/image/srgba-read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// UNSUPPORTED: rocm_nvidia
// UNSUPPORTED: rocm_amd

#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

using namespace cl::sycl;
using namespace sycl;

using accessorPixelT = sycl::float4;
using dataPixelT = uint32_t;
Expand Down
27 changes: 15 additions & 12 deletions SYCL/ESIMD/mandelbrot/mandelbrot_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
// RUN: %GPU_RUN_PLACEHOLDER %t.out %T/output_spec.ppm %S/golden_hw.ppm 512 -2.09798 -1.19798 0.004 4.0

#include "esimd_test_utils.hpp"
#include <CL/sycl.hpp>

#include <sycl/ext/intel/experimental/esimd.hpp>
#include <sycl/sycl.hpp>

#include <array>
#include <iostream>
#include <memory>
#include <sycl/ext/intel/experimental/esimd.hpp>

using namespace cl::sycl;
using namespace sycl;
using namespace sycl::ext::intel::experimental::esimd;

#ifdef _SIM_MODE_
Expand Down Expand Up @@ -95,17 +97,17 @@ int main(int argc, char *argv[]) {
unsigned char *buf = new unsigned char[img_size];

try {
cl::sycl::image<2> imgOutput((unsigned int *)buf, image_channel_order::rgba,
image_channel_type::unsigned_int8,
range<2>{WIDTH, HEIGHT});
sycl::image<2> imgOutput((unsigned int *)buf, image_channel_order::rgba,
image_channel_type::unsigned_int8,
range<2>{WIDTH, HEIGHT});

// We need that many workitems
uint range_width = WIDTH / 8;
uint range_height = HEIGHT / 2;
cl::sycl::range<2> GlobalRange{range_width, range_height};
sycl::range<2> GlobalRange{range_width, range_height};

// Number of workitems in a workgroup
cl::sycl::range<2> LocalRange{1, 1};
sycl::range<2> LocalRange{1, 1};

queue q(esimd_test::ESIMDSelector{}, esimd_test::createExceptionHandler());

Expand All @@ -125,7 +127,7 @@ int main(int argc, char *argv[]) {
<< ", yoff = " << yoff << ", scale = " << scale
<< ", thrs = " << thrs << "\n";
}
cl::sycl::program prg(q.get_context());
sycl::program prg(q.get_context());
sycl::ext::oneapi::experimental::spec_constant<int, CrunchConst>
crunch_const = prg.set_spec_constant<CrunchConst>(crunch);
sycl::ext::oneapi::experimental::spec_constant<float, XoffConst>
Expand All @@ -136,11 +138,12 @@ int main(int argc, char *argv[]) {
scale_const = prg.set_spec_constant<ScaleConst>(scale);
sycl::ext::oneapi::experimental::spec_constant<float, ThrsConst>
thrs_const = prg.set_spec_constant<ThrsConst>(thrs);

prg.build_with_kernel_type<Test>();

auto e = q.submit([&](cl::sycl::handler &cgh) {
auto e = q.submit([&](sycl::handler &cgh) {
auto accOutput =
imgOutput.get_access<uint4, cl::sycl::access::mode::write>(cgh);
imgOutput.get_access<uint4, sycl::access::mode::write>(cgh);

cgh.parallel_for<Test>(prg.get_kernel<Test>(), GlobalRange * LocalRange,
[=](item<2> it) SYCL_ESIMD_KERNEL {
Expand All @@ -153,7 +156,7 @@ int main(int argc, char *argv[]) {
});
});
e.wait();
} catch (cl::sycl::exception const &e) {
} catch (sycl::exception const &e) {
std::cout << "SYCL exception caught: " << e.what() << '\n';
delete[] buf;
return e.get_cl_code();
Expand Down
4 changes: 2 additions & 2 deletions SYCL/GroupAlgorithm/SYCL2020/shift_left_right.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
//===----------------------------------------------------------------------===//

#include "helpers.hpp"
#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>
template <typename T, int N> class sycl_subgr;

using namespace cl::sycl;
using namespace sycl;

// TODO remove this workaround when clang will support correct generation of
// half typename in integration header
Expand Down
4 changes: 2 additions & 2 deletions SYCL/Sampler/normalized-mirror-nearest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/

#include "common.hpp"
#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

using namespace cl::sycl;
using namespace sycl;

// pixel data-type for RGBA operations (which is the minimum image type)
using pixelT = sycl::uint4;
Expand Down
6 changes: 3 additions & 3 deletions SYCL/SubGroup/reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//

#include "helper.hpp"
#include <CL/sycl.hpp>
#include <sycl/sycl.hpp>

template <typename... Ts> class sycl_subgr;

using namespace cl::sycl;
using namespace sycl;

template <typename SpecializationKernelName, typename T, class BinaryOperation>
void check_op(queue &Queue, T init, BinaryOperation op, bool skip_init = false,
Expand Down Expand Up @@ -67,7 +67,7 @@ void check_op(queue &Queue, T init, BinaryOperation op, bool skip_init = false,
template <typename SpecializationKernelName, typename T>
void check(queue &Queue, size_t G = 256, size_t L = 64) {
// limit data range for half to avoid rounding issues
if (std::is_same<T, cl::sycl::half>::value) {
if (std::is_same<T, sycl::half>::value) {
G = 64;
L = 32;
}
Expand Down