summaryrefslogtreecommitdiff
path: root/modules/remote-sycl/tests/data_ref.cpp
blob: e92c693b7b9c91ccd65a5417cd274e601c99f36f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <forstio/test/suite.hpp>

#include "../c++/data.hpp"

namespace {
namespace sch {
using namespace saw::schema;
}

SAW_TEST("Data Ref Basics"){
	using namespace saw;

	acpp::sycl::queue sycl_q;

	constexpr uint64_t dat_size = 1000u;

	data<sch::Array<sch::UInt64>, encode::Sycl<encode::Native>> dat{{{dat_size}},sycl_q};

	data<sch::Ref<sch::Array<sch::UInt64>>, encode::Sycl<encode::Native>> dat_ref{dat};
	auto dat_ptr = dat_ref.get_internal_data();

	sycl_q.parallel_for(dat_size, [=](acpp::sycl::id<1> idx){
		size_t i = idx[0];

		dat_ptr[i] = {i};
	}).wait();

	for(uint64_t i = 0u; i < dat_size; ++i){
		SAW_EXPECT(dat_ptr[i].get() == i, std::string{"Unexpected value: "} + std::to_string(i));
	}
}
}