1
- // REQUIRES: opencl
2
-
3
1
// RUN: %clangxx %s -o %t1.out -lsycl -I %sycl_include
4
2
// RUN: env SYCL_DEVICE_TYPE=HOST %t1.out
5
3
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t2.out
8
6
// RUN: %GPU_RUN_PLACEHOLDER %t2.out
9
7
// RUN: %ACC_RUN_PLACEHOLDER %t2.out
10
8
11
- // TODO: Unexpected result and following assertion
12
- // XFAIL: cuda
13
-
14
9
// ==------------------- buffer.cpp - SYCL buffer basic test ----------------==//
15
10
//
16
11
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -397,8 +392,8 @@ int main() {
397
392
398
393
myQueue.submit ([&](handler &cgh) {
399
394
accessor<int , 2 , access::mode::write, access::target::global_buffer,
400
- access::placeholder::false_t >
401
- B (Buffer, cgh, range<2 >(20 ,20 ), id<2 >(10 ,10 ));
395
+ access::placeholder::false_t >
396
+ B (Buffer, cgh, range<2 >(20 , 20 ), id<2 >(10 , 10 ));
402
397
cgh.parallel_for <class bufferByRangeOffset >(
403
398
range<2 >{10 , 5 }, [=](id<2 > index) { B[index] = 1 ; });
404
399
});
@@ -494,9 +489,8 @@ int main() {
494
489
myQueue.submit ([&](handler &cgh) {
495
490
auto B = b.get_access <access::mode::read_write>(cgh);
496
491
cgh.parallel_for <class wb >(range<1 >{10 },
497
- [=](id<1 > index) { B[index] = 0 ; });
492
+ [=](id<1 > index) { B[index] = 0 ; });
498
493
});
499
-
500
494
}
501
495
// Data is copied back because there is a user side ptr and write-back is
502
496
// enabled
@@ -519,9 +513,8 @@ int main() {
519
513
myQueue.submit ([&](handler &cgh) {
520
514
auto B = b.get_access <access::mode::read_write>(cgh);
521
515
cgh.parallel_for <class notwb >(range<1 >{10 },
522
- [=](id<1 > index) { B[index] = 0 ; });
516
+ [=](id<1 > index) { B[index] = 0 ; });
523
517
});
524
-
525
518
}
526
519
// Data is not copied back because write-back is canceled
527
520
for (int i = 0 ; i < 10 ; i++)
@@ -551,33 +544,6 @@ int main() {
551
544
assert (data1[i] == 0 );
552
545
}
553
546
554
- {
555
- queue myQueue;
556
- if (!myQueue.is_host ()) {
557
- std::vector<int > data1 (10 , -1 );
558
- std::vector<int > data2 (10 , -2 );
559
- {
560
- buffer<int , 1 > a (data1.data (), range<1 >(10 ));
561
- buffer<int , 1 > b (data2);
562
-
563
- program prog (myQueue.get_context ());
564
- prog.build_with_source (" kernel void override_source(global int* Acc) "
565
- " {Acc[get_global_id(0)] = 0; }\n " );
566
- cl::sycl::kernel krn = prog.get_kernel (" override_source" );
567
- myQueue.submit ([&](handler &cgh) {
568
- auto A = a.get_access <access::mode::read_write>(cgh);
569
- cgh.set_arg (0 , A);
570
- auto B = b.get_access <access::mode::read_write>(cgh);
571
- cgh.parallel_for (cl::sycl::range<1 >(10 ), krn);
572
- });
573
- } // Data is copied back
574
- for (int i = 0 ; i < 10 ; i++)
575
- assert (data2[i] == -2 );
576
- for (int i = 0 ; i < 10 ; i++)
577
- assert (data1[i] == 0 );
578
- }
579
- }
580
-
581
547
{
582
548
std::vector<int > data1 (10 , -1 );
583
549
std::vector<int > data2 (10 , -2 );
@@ -604,40 +570,6 @@ int main() {
604
570
assert (data1[i] == 0 );
605
571
}
606
572
607
- {
608
- queue myQueue;
609
- if (!myQueue.is_host ()) {
610
- std::vector<int > data1 (10 , -1 );
611
- std::vector<int > data2 (10 , -2 );
612
- {
613
- buffer<int , 1 > a (data1.data (), range<1 >(10 ));
614
- buffer<int , 1 > b (data2);
615
- accessor<int , 1 , access::mode::read_write,
616
- access::target::global_buffer, access::placeholder::true_t >
617
- A (a);
618
- accessor<int , 1 , access::mode::read_write,
619
- access::target::global_buffer, access::placeholder::true_t >
620
- B (b);
621
-
622
- program prog (myQueue.get_context ());
623
- prog.build_with_source (" kernel void override_source_placeholder(global "
624
- " int* Acc) {Acc[get_global_id(0)] = 0; }\n " );
625
- cl::sycl::kernel krn = prog.get_kernel (" override_source_placeholder" );
626
-
627
- myQueue.submit ([&](handler &cgh) {
628
- cgh.require (A);
629
- cgh.set_arg (0 , A);
630
- cgh.require (B);
631
- cgh.parallel_for (cl::sycl::range<1 >(10 ), krn);
632
- });
633
- } // Data is copied back
634
- for (int i = 0 ; i < 10 ; i++)
635
- assert (data2[i] == -2 );
636
- for (int i = 0 ; i < 10 ; i++)
637
- assert (data1[i] == 0 );
638
- }
639
- }
640
-
641
573
{
642
574
int data[10 ];
643
575
void *voidPtr = (void *)data;
0 commit comments