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

Commit 931c931

Browse files
committed
resolve latest merge conflicts
Signed-off-by: Chris Perkins <[email protected]>
2 parents aa4f185 + 4bac3b5 commit 931c931

File tree

101 files changed

+591
-567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+591
-567
lines changed

SYCL/Basic/access_to_subset.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
43
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out

SYCL/Basic/accessor/accessor.cpp

Lines changed: 147 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
2-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
43
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
@@ -141,28 +140,26 @@ int main() {
141140
// Device accessor with 2-dimensional subscript operators.
142141
{
143142
sycl::queue Queue;
144-
if (!Queue.is_host()) {
145-
int array[2][3] = {0};
146-
{
147-
sycl::range<2> Range(2, 3);
148-
sycl::buffer<int, 2> buf((int *)array, Range,
149-
{sycl::property::buffer::use_host_ptr()});
143+
int array[2][3] = {0};
144+
{
145+
sycl::range<2> Range(2, 3);
146+
sycl::buffer<int, 2> buf((int *)array, Range,
147+
{sycl::property::buffer::use_host_ptr()});
150148

151-
Queue.submit([&](sycl::handler &cgh) {
152-
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
153-
cgh.parallel_for<class dim2_subscr>(Range, [=](sycl::item<2> itemID) {
154-
acc[itemID.get_id(0)][itemID.get_id(1)] += itemID.get_linear_id();
155-
});
149+
Queue.submit([&](sycl::handler &cgh) {
150+
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
151+
cgh.parallel_for<class dim2_subscr>(Range, [=](sycl::item<2> itemID) {
152+
acc[itemID.get_id(0)][itemID.get_id(1)] += itemID.get_linear_id();
156153
});
157-
Queue.wait();
158-
}
159-
for (int i = 0; i < 2; i++) {
160-
for (int j = 0; j < 3; j++) {
161-
if (array[i][j] != i * 3 + j) {
162-
std::cerr << array[i][j] << " != " << (i * 3 + j) << std::endl;
163-
assert(0);
164-
return 1;
165-
}
154+
});
155+
Queue.wait();
156+
}
157+
for (int i = 0; i < 2; i++) {
158+
for (int j = 0; j < 3; j++) {
159+
if (array[i][j] != i * 3 + j) {
160+
std::cerr << array[i][j] << " != " << (i * 3 + j) << std::endl;
161+
assert(0);
162+
return 1;
166163
}
167164
}
168165
}
@@ -172,52 +169,48 @@ int main() {
172169
// check compile error
173170
{
174171
sycl::queue queue;
175-
if (!queue.is_host()) {
176-
sycl::range<2> range(1, 1);
177-
int Arr[] = {2};
178-
{
179-
sycl::buffer<int, 1> Buf(Arr, 1);
180-
queue.submit([&](sycl::handler &cgh) {
181-
auto acc = sycl::accessor<int, 2, sycl::access::mode::atomic,
182-
sycl::target::local>(range, cgh);
183-
cgh.parallel_for<class dim2_subscr_atomic>(
184-
sycl::nd_range<2>{range, range}, [=](sycl::nd_item<2>) {
185-
sycl::atomic<int, sycl::access::address_space::local_space>
186-
value = acc[0][0];
187-
});
188-
});
189-
}
172+
sycl::range<2> range(1, 1);
173+
int Arr[] = {2};
174+
{
175+
sycl::buffer<int, 1> Buf(Arr, 1);
176+
queue.submit([&](sycl::handler &cgh) {
177+
auto acc = sycl::accessor<int, 2, sycl::access::mode::atomic,
178+
sycl::target::local>(range, cgh);
179+
cgh.parallel_for<class dim2_subscr_atomic>(
180+
sycl::nd_range<2>{range, range}, [=](sycl::nd_item<2>) {
181+
sycl::atomic<int, sycl::access::address_space::local_space>
182+
value = acc[0][0];
183+
});
184+
});
190185
}
191186
}
192187

193188
// Device accessor with 3-dimensional subscript operators.
194189
{
195190
sycl::queue Queue;
196-
if (!Queue.is_host()) {
197-
int array[2][3][4] = {0};
198-
{
199-
sycl::range<3> Range(2, 3, 4);
200-
sycl::buffer<int, 3> buf((int *)array, Range,
201-
{sycl::property::buffer::use_host_ptr()});
191+
int array[2][3][4] = {0};
192+
{
193+
sycl::range<3> Range(2, 3, 4);
194+
sycl::buffer<int, 3> buf((int *)array, Range,
195+
{sycl::property::buffer::use_host_ptr()});
202196

203-
Queue.submit([&](sycl::handler &cgh) {
204-
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
205-
cgh.parallel_for<class dim3_subscr>(Range, [=](sycl::item<3> itemID) {
206-
acc[itemID.get_id(0)][itemID.get_id(1)][itemID.get_id(2)] +=
207-
itemID.get_linear_id();
208-
});
197+
Queue.submit([&](sycl::handler &cgh) {
198+
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
199+
cgh.parallel_for<class dim3_subscr>(Range, [=](sycl::item<3> itemID) {
200+
acc[itemID.get_id(0)][itemID.get_id(1)][itemID.get_id(2)] +=
201+
itemID.get_linear_id();
209202
});
210-
Queue.wait();
211-
}
212-
for (int i = 0; i < 2; i++) {
213-
for (int j = 0; j < 3; j++) {
214-
for (int k = 0; k < 4; k++) {
215-
int expected = k + 4 * (j + 3 * i);
216-
if (array[i][j][k] != expected) {
217-
std::cerr << array[i][j][k] << " != " << expected << std::endl;
218-
assert(0);
219-
return 1;
220-
}
203+
});
204+
Queue.wait();
205+
}
206+
for (int i = 0; i < 2; i++) {
207+
for (int j = 0; j < 3; j++) {
208+
for (int k = 0; k < 4; k++) {
209+
int expected = k + 4 * (j + 3 * i);
210+
if (array[i][j][k] != expected) {
211+
std::cerr << array[i][j][k] << " != " << expected << std::endl;
212+
assert(0);
213+
return 1;
221214
}
222215
}
223216
}
@@ -295,28 +288,26 @@ int main() {
295288
// Check that accessor is initialized when accessor is wrapped to some class.
296289
{
297290
sycl::queue queue;
298-
if (!queue.is_host()) {
299-
int array[10] = {0};
300-
{
301-
sycl::buffer<int, 1> buf((int *)array, sycl::range<1>(10),
302-
{sycl::property::buffer::use_host_ptr()});
303-
queue.submit([&](sycl::handler &cgh) {
304-
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
305-
auto acc_wrapped = AccWrapper<decltype(acc)>{acc};
306-
cgh.parallel_for<class wrapped_access1>(
307-
sycl::range<1>(buf.get_count()), [=](sycl::item<1> it) {
308-
auto idx = it.get_linear_id();
309-
acc_wrapped.accessor[idx] = 333;
310-
});
311-
});
312-
queue.wait();
313-
}
314-
for (int i = 0; i < 10; i++) {
315-
if (array[i] != 333) {
316-
std::cerr << array[i] << " != 333" << std::endl;
317-
assert(0);
318-
return 1;
319-
}
291+
int array[10] = {0};
292+
{
293+
sycl::buffer<int, 1> buf((int *)array, sycl::range<1>(10),
294+
{sycl::property::buffer::use_host_ptr()});
295+
queue.submit([&](sycl::handler &cgh) {
296+
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
297+
auto acc_wrapped = AccWrapper<decltype(acc)>{acc};
298+
cgh.parallel_for<class wrapped_access1>(
299+
sycl::range<1>(buf.get_count()), [=](sycl::item<1> it) {
300+
auto idx = it.get_linear_id();
301+
acc_wrapped.accessor[idx] = 333;
302+
});
303+
});
304+
queue.wait();
305+
}
306+
for (int i = 0; i < 10; i++) {
307+
if (array[i] != 333) {
308+
std::cerr << array[i] << " != 333" << std::endl;
309+
assert(0);
310+
return 1;
320311
}
321312
}
322313
}
@@ -325,40 +316,38 @@ int main() {
325316
// initialized in proper way and value is assigned.
326317
{
327318
sycl::queue queue;
328-
if (!queue.is_host()) {
329-
int array1[10] = {0};
330-
int array2[10] = {0};
331-
{
332-
sycl::buffer<int, 1> buf1((int *)array1, sycl::range<1>(10),
333-
{sycl::property::buffer::use_host_ptr()});
334-
sycl::buffer<int, 1> buf2((int *)array2, sycl::range<1>(10),
335-
{sycl::property::buffer::use_host_ptr()});
336-
queue.submit([&](sycl::handler &cgh) {
337-
auto acc1 = buf1.get_access<sycl::access::mode::read_write>(cgh);
338-
auto acc2 = buf2.get_access<sycl::access::mode::read_write>(cgh);
339-
auto acc_wrapped =
340-
AccsWrapper<decltype(acc1), decltype(acc2)>{10, acc1, 5, acc2};
341-
cgh.parallel_for<class wrapped_access2>(
342-
sycl::range<1>(10), [=](sycl::item<1> it) {
343-
auto idx = it.get_linear_id();
344-
acc_wrapped.accessor1[idx] = 333;
345-
acc_wrapped.accessor2[idx] = 777;
346-
});
347-
});
348-
queue.wait();
349-
}
319+
int array1[10] = {0};
320+
int array2[10] = {0};
321+
{
322+
sycl::buffer<int, 1> buf1((int *)array1, sycl::range<1>(10),
323+
{sycl::property::buffer::use_host_ptr()});
324+
sycl::buffer<int, 1> buf2((int *)array2, sycl::range<1>(10),
325+
{sycl::property::buffer::use_host_ptr()});
326+
queue.submit([&](sycl::handler &cgh) {
327+
auto acc1 = buf1.get_access<sycl::access::mode::read_write>(cgh);
328+
auto acc2 = buf2.get_access<sycl::access::mode::read_write>(cgh);
329+
auto acc_wrapped =
330+
AccsWrapper<decltype(acc1), decltype(acc2)>{10, acc1, 5, acc2};
331+
cgh.parallel_for<class wrapped_access2>(
332+
sycl::range<1>(10), [=](sycl::item<1> it) {
333+
auto idx = it.get_linear_id();
334+
acc_wrapped.accessor1[idx] = 333;
335+
acc_wrapped.accessor2[idx] = 777;
336+
});
337+
});
338+
queue.wait();
339+
}
340+
for (int i = 0; i < 10; i++) {
350341
for (int i = 0; i < 10; i++) {
351-
for (int i = 0; i < 10; i++) {
352-
if (array1[i] != 333) {
353-
std::cerr << array1[i] << " != 333" << std::endl;
354-
assert(0);
355-
return 1;
356-
}
357-
if (array2[i] != 777) {
358-
std::cerr << array2[i] << " != 777" << std::endl;
359-
assert(0);
360-
return 1;
361-
}
342+
if (array1[i] != 333) {
343+
std::cerr << array1[i] << " != 333" << std::endl;
344+
assert(0);
345+
return 1;
346+
}
347+
if (array2[i] != 777) {
348+
std::cerr << array2[i] << " != 777" << std::endl;
349+
assert(0);
350+
return 1;
362351
}
363352
}
364353
}
@@ -367,31 +356,29 @@ int main() {
367356
// Several levels of wrappers for accessor.
368357
{
369358
sycl::queue queue;
370-
if (!queue.is_host()) {
371-
int array[10] = {0};
372-
{
373-
sycl::buffer<int, 1> buf((int *)array, sycl::range<1>(10),
374-
{sycl::property::buffer::use_host_ptr()});
375-
queue.submit([&](sycl::handler &cgh) {
376-
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
377-
auto acc_wrapped = AccWrapper<decltype(acc)>{acc};
378-
Wrapper1 wr1;
379-
auto wr2 = Wrapper2<decltype(acc)>{wr1, acc_wrapped};
380-
auto wr3 = Wrapper3<decltype(acc)>{wr2};
381-
cgh.parallel_for<class wrapped_access3>(
382-
sycl::range<1>(buf.get_count()), [=](sycl::item<1> it) {
383-
auto idx = it.get_linear_id();
384-
wr3.w2.wrapped.accessor[idx] = 333;
385-
});
386-
});
387-
queue.wait();
388-
}
389-
for (int i = 0; i < 10; i++) {
390-
if (array[i] != 333) {
391-
std::cerr << array[i] << " != 333" << std::endl;
392-
assert(0);
393-
return 1;
394-
}
359+
int array[10] = {0};
360+
{
361+
sycl::buffer<int, 1> buf((int *)array, sycl::range<1>(10),
362+
{sycl::property::buffer::use_host_ptr()});
363+
queue.submit([&](sycl::handler &cgh) {
364+
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
365+
auto acc_wrapped = AccWrapper<decltype(acc)>{acc};
366+
Wrapper1 wr1;
367+
auto wr2 = Wrapper2<decltype(acc)>{wr1, acc_wrapped};
368+
auto wr3 = Wrapper3<decltype(acc)>{wr2};
369+
cgh.parallel_for<class wrapped_access3>(
370+
sycl::range<1>(buf.get_count()), [=](sycl::item<1> it) {
371+
auto idx = it.get_linear_id();
372+
wr3.w2.wrapped.accessor[idx] = 333;
373+
});
374+
});
375+
queue.wait();
376+
}
377+
for (int i = 0; i < 10; i++) {
378+
if (array[i] != 333) {
379+
std::cerr << array[i] << " != 333" << std::endl;
380+
assert(0);
381+
return 1;
395382
}
396383
}
397384
}
@@ -563,31 +550,28 @@ int main() {
563550
sycl::queue q;
564551
// host device executes kernels via a different method and there
565552
// is no good way to throw an exception at this time.
566-
if (!q.is_host()) {
567-
sycl::range<1> r(4);
568-
sycl::buffer<int, 1> b(r);
569-
try {
570-
sycl::accessor<int, 1, sycl::access::mode::read_write,
571-
sycl::access::target::device,
572-
sycl::access::placeholder::true_t>
573-
acc(b);
553+
sycl::range<1> r(4);
554+
sycl::buffer<int, 1> b(r);
555+
try {
556+
sycl::accessor<int, 1, sycl::access::mode::read_write,
557+
sycl::access::target::device,
558+
sycl::access::placeholder::true_t>
559+
acc(b);
574560

575-
q.submit([&](sycl::handler &cgh) {
576-
// we do NOT call .require(acc) without which we should throw a
577-
// synchronous exception with errc::kernel_argument
578-
cgh.parallel_for<class ph>(
579-
r, [=](sycl::id<1> index) { acc[index] = 0; });
580-
});
581-
q.wait_and_throw();
582-
assert(false && "we should not be here, missing exception");
583-
} catch (sycl::exception &e) {
584-
std::cout << "exception received: " << e.what() << std::endl;
585-
assert(e.code() == sycl::errc::kernel_argument &&
586-
"incorrect error code");
587-
} catch (...) {
588-
std::cout << "some other exception" << std::endl;
589-
return 1;
590-
}
561+
q.submit([&](sycl::handler &cgh) {
562+
// we do NOT call .require(acc) without which we should throw a
563+
// synchronous exception with errc::kernel_argument
564+
cgh.parallel_for<class ph>(r,
565+
[=](sycl::id<1> index) { acc[index] = 0; });
566+
});
567+
q.wait_and_throw();
568+
assert(false && "we should not be here, missing exception");
569+
} catch (sycl::exception &e) {
570+
std::cout << "exception received: " << e.what() << std::endl;
571+
assert(e.code() == sycl::errc::kernel_argument && "incorrect error code");
572+
} catch (...) {
573+
std::cout << "some other exception" << std::endl;
574+
return 1;
591575
}
592576
}
593577

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -Daccessor_new_api_test %S/Inputs/device_accessor.cpp -o %t.out
2-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
43
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -Dbuffer_new_api_test %S/Inputs/device_accessor.cpp -o %t.out
2-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
43
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -Dbuffer_new_api_test %S/Inputs/host_accessor.cpp -o %t.out
2-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
43
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -Dbuffer_new_api_test %S/Inputs/host_task_accessor.cpp -o %t.out
2-
// RUN: %HOST_RUN_PLACEHOLDER %t.out
32
// RUN: %CPU_RUN_PLACEHOLDER %t.out
43
// RUN: %GPU_RUN_PLACEHOLDER %t.out
54
// RUN: %ACC_RUN_PLACEHOLDER %t.out

0 commit comments

Comments
 (0)