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

Commit f7db8ac

Browse files
committed
fix all dangling formatting, use function template to check float/double.
1 parent 4f50f12 commit f7db8ac

File tree

10 files changed

+343
-317
lines changed

10 files changed

+343
-317
lines changed

SYCL/Basic/buffer/buffer.cpp

Lines changed: 121 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include <sycl/sycl.hpp>
18+
1719
#include <cassert>
18-
#include <iostream>
1920
#include <memory>
20-
#include <sycl/sycl.hpp>
2121

2222
using namespace sycl;
2323

2424
int main() {
2525
int data = 5;
2626
bool failed = false;
2727
buffer<int, 1> buf(&data, range<1>(1));
28-
2928
{
3029
int data1[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
3130
{
@@ -509,6 +508,7 @@ int main() {
509508
size_t size = 32;
510509
const size_t dims = 1;
511510
sycl::range<dims> r(size);
511+
512512
std::shared_ptr<bool> bool_shrd(new bool[size],
513513
[](bool *data) { delete[] data; });
514514
std::shared_ptr<int> int_shrd(new int[size],
@@ -551,6 +551,7 @@ int main() {
551551
std::fill(double_shrd.get(), (double_shrd.get() + size), double());
552552
#endif
553553
m.unlock();
554+
554555
buf_bool_shrd.set_final_data(bool_vector.begin());
555556
buf_int_shrd.set_final_data(int_vector.begin());
556557
#ifdef ENABLE_FP64
@@ -591,137 +592,136 @@ int main() {
591592
#endif
592593
assert(Passed && "Data was not copied back");
593594
}
595+
}
594596

595-
// Check that data is not copied back after canceling write-back using
596-
// set_write_back
597-
{
598-
std::vector<int> data1(10, -1);
599-
{
600-
buffer<int, 1> b(range<1>(10));
601-
b.set_final_data(data1.data());
602-
b.set_write_back(false);
603-
queue myQueue;
604-
myQueue.submit([&](handler &cgh) {
605-
auto B = b.get_access<access::mode::read_write>(cgh);
606-
cgh.parallel_for<class notwb>(range<1>{10},
607-
[=](id<1> index) { B[index] = 0; });
608-
});
609-
}
610-
// Data is not copied back because write-back is canceled
611-
for (int i = 0; i < 10; i++)
612-
if (data1[i] != -1) {
613-
assert(false);
614-
failed = true;
615-
}
616-
}
617-
597+
// Check that data is not copied back after canceling write-back using
598+
// set_write_back
599+
{
600+
std::vector<int> data1(10, -1);
618601
{
619-
std::vector<int> data1(10, -1);
620-
std::vector<int> data2(10, -2);
621-
{
622-
buffer<int, 1> a(data1.data(), range<1>(10));
623-
buffer<int, 1> b(data2.data(), range<1>(10));
624-
queue myQueue;
625-
myQueue.submit([&](handler &cgh) {
626-
auto A = a.get_access<access::mode::read_write>(cgh);
627-
auto B = b.get_access<access::mode::read_write>(cgh);
628-
cgh.parallel_for<class override_lambda>(
629-
range<1>{10}, [=](id<1> index) { A[index] = 0; });
630-
});
631-
} // Data is copied back
632-
for (int i = 0; i < 10; i++)
633-
assert(data2[i] == -2);
634-
for (int i = 0; i < 10; i++)
635-
assert(data1[i] == 0);
602+
buffer<int, 1> b(range<1>(10));
603+
b.set_final_data(data1.data());
604+
b.set_write_back(false);
605+
queue myQueue;
606+
myQueue.submit([&](handler &cgh) {
607+
auto B = b.get_access<access::mode::read_write>(cgh);
608+
cgh.parallel_for<class notwb>(range<1>{10},
609+
[=](id<1> index) { B[index] = 0; });
610+
});
636611
}
612+
// Data is not copied back because write-back is canceled
613+
for (int i = 0; i < 10; i++)
614+
if (data1[i] != -1) {
615+
assert(false);
616+
failed = true;
617+
}
618+
}
637619

620+
{
621+
std::vector<int> data1(10, -1);
622+
std::vector<int> data2(10, -2);
638623
{
639-
std::vector<int> data1(10, -1);
640-
std::vector<int> data2(10, -2);
641-
{
642-
buffer<int, 1> a(data1.data(), range<1>(10));
643-
buffer<int, 1> b(data2);
644-
accessor<int, 1, access::mode::read_write, access::target::device,
645-
access::placeholder::true_t>
646-
A(a);
647-
accessor<int, 1, access::mode::read_write, access::target::device,
648-
access::placeholder::true_t>
649-
B(b);
650-
queue myQueue;
651-
myQueue.submit([&](handler &cgh) {
652-
cgh.require(A);
653-
cgh.require(B);
654-
cgh.parallel_for<class override_lambda_placeholder>(
655-
range<1>{10}, [=](id<1> index) { A[index] = 0; });
656-
});
657-
} // Data is copied back
658-
for (int i = 0; i < 10; i++)
659-
assert(data2[i] == -2);
660-
for (int i = 0; i < 10; i++)
661-
assert(data1[i] == 0);
662-
}
624+
buffer<int, 1> a(data1.data(), range<1>(10));
625+
buffer<int, 1> b(data2.data(), range<1>(10));
626+
queue myQueue;
627+
myQueue.submit([&](handler &cgh) {
628+
auto A = a.get_access<access::mode::read_write>(cgh);
629+
auto B = b.get_access<access::mode::read_write>(cgh);
630+
cgh.parallel_for<class override_lambda>(
631+
range<1>{10}, [=](id<1> index) { A[index] = 0; });
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+
}
663639

640+
{
641+
std::vector<int> data1(10, -1);
642+
std::vector<int> data2(10, -2);
664643
{
665-
int data[10];
666-
void *voidPtr = (void *)data;
667-
buffer<int, 1> b(range<1>(10));
668-
b.set_final_data(voidPtr);
669-
}
644+
buffer<int, 1> a(data1.data(), range<1>(10));
645+
buffer<int, 1> b(data2);
646+
accessor<int, 1, access::mode::read_write, access::target::device,
647+
access::placeholder::true_t>
648+
A(a);
649+
accessor<int, 1, access::mode::read_write, access::target::device,
650+
access::placeholder::true_t>
651+
B(b);
652+
queue myQueue;
653+
myQueue.submit([&](handler &cgh) {
654+
cgh.require(A);
655+
cgh.require(B);
656+
cgh.parallel_for<class override_lambda_placeholder>(
657+
range<1>{10}, [=](id<1> index) { A[index] = 0; });
658+
});
659+
} // Data is copied back
660+
for (int i = 0; i < 10; i++)
661+
assert(data2[i] == -2);
662+
for (int i = 0; i < 10; i++)
663+
assert(data1[i] == 0);
664+
}
670665

671-
{
672-
std::allocator<float8> buf_alloc;
673-
std::shared_ptr<float8> data(new float8[8],
674-
[](float8 *p) { delete[] p; });
675-
sycl::buffer<float8, 1, std::allocator<float8>> b(data, sycl::range<1>(8),
676-
buf_alloc);
677-
}
666+
{
667+
int data[10];
668+
void *voidPtr = (void *)data;
669+
buffer<int, 1> b(range<1>(10));
670+
b.set_final_data(voidPtr);
671+
}
678672

679-
{
680-
constexpr int Size = 6;
681-
sycl::buffer<char, 1> Buf_1(Size);
682-
sycl::buffer<char, 1> Buf_2(Size / 2);
683-
684-
{
685-
auto AccA = Buf_1.get_access<sycl::access::mode::read_write>(Size / 2);
686-
auto AccB = Buf_2.get_access<sycl::access::mode::read_write>(Size / 2);
687-
assert(AccA.get_size() == AccB.get_size());
688-
assert(AccA.get_range() == AccB.get_range());
689-
assert(AccA.get_count() == AccB.get_count());
690-
}
673+
{
674+
std::allocator<float8> buf_alloc;
675+
std::shared_ptr<float8> data(new float8[8], [](float8 *p) { delete[] p; });
676+
sycl::buffer<float8, 1, std::allocator<float8>> b(data, sycl::range<1>(8),
677+
buf_alloc);
678+
}
691679

692-
auto AH0 = accessor<char, 0, access::mode::read_write,
693-
access::target::host_buffer>(Buf_1);
694-
auto BH0 = accessor<char, 0, access::mode::read_write,
695-
access::target::host_buffer>(Buf_2);
696-
assert(AH0.get_size() == sizeof(char));
697-
assert(BH0.get_size() == sizeof(char));
698-
assert(AH0.get_count() == 1);
699-
assert(BH0.get_count() == 1);
700-
701-
queue Queue;
702-
Queue.submit([&](handler &CGH) {
703-
auto AK0 =
704-
accessor<char, 0, access::mode::read_write, access::target::device>(
705-
Buf_1, CGH);
706-
auto BK0 =
707-
accessor<char, 0, access::mode::read_write, access::target::device>(
708-
Buf_2, CGH);
709-
assert(AK0.get_size() == sizeof(char));
710-
assert(BK0.get_size() == sizeof(char));
711-
assert(AK0.get_count() == 1);
712-
assert(BK0.get_count() == 1);
713-
CGH.single_task<class DummyKernel>([]() {});
714-
});
715-
}
680+
{
681+
constexpr int Size = 6;
682+
sycl::buffer<char, 1> Buf_1(Size);
683+
sycl::buffer<char, 1> Buf_2(Size / 2);
716684

717685
{
718-
int data = 5;
719-
buffer<int, 1> Buffer(&data, range<1>(1));
720-
assert(Buffer.size() == 1);
721-
assert(Buffer.byte_size() == 1 * sizeof(int));
686+
auto AccA = Buf_1.get_access<sycl::access::mode::read_write>(Size / 2);
687+
auto AccB = Buf_2.get_access<sycl::access::mode::read_write>(Size / 2);
688+
assert(AccA.get_size() == AccB.get_size());
689+
assert(AccA.get_range() == AccB.get_range());
690+
assert(AccA.get_count() == AccB.get_count());
722691
}
723692

724-
// TODO tests with mutex property
725-
return failed;
693+
auto AH0 = accessor<char, 0, access::mode::read_write,
694+
access::target::host_buffer>(Buf_1);
695+
auto BH0 = accessor<char, 0, access::mode::read_write,
696+
access::target::host_buffer>(Buf_2);
697+
assert(AH0.get_size() == sizeof(char));
698+
assert(BH0.get_size() == sizeof(char));
699+
assert(AH0.get_count() == 1);
700+
assert(BH0.get_count() == 1);
701+
702+
queue Queue;
703+
Queue.submit([&](handler &CGH) {
704+
auto AK0 =
705+
accessor<char, 0, access::mode::read_write, access::target::device>(
706+
Buf_1, CGH);
707+
auto BK0 =
708+
accessor<char, 0, access::mode::read_write, access::target::device>(
709+
Buf_2, CGH);
710+
assert(AK0.get_size() == sizeof(char));
711+
assert(BK0.get_size() == sizeof(char));
712+
assert(AK0.get_count() == 1);
713+
assert(BK0.get_count() == 1);
714+
CGH.single_task<class DummyKernel>([]() {});
715+
});
716+
}
717+
718+
{
719+
int data = 5;
720+
buffer<int, 1> Buffer(&data, range<1>(1));
721+
assert(Buffer.size() == 1);
722+
assert(Buffer.byte_size() == 1 * sizeof(int));
726723
}
724+
725+
// TODO tests with mutex property
726+
return failed;
727727
}

SYCL/ESIMD/api/bin_and_cmp_ops_heavy_aspect-fp64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//==--------------- bin_un_cmp_ops_heavy_aspect-fp64.cpp - DPC++ ESIMD
2-
// on-device test -==//
1+
//==-- bin_un_cmp_ops_heavy_aspect-fp64.cpp - DPC++ ESIMD on-device test --==//
32
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54
// See https://llvm.org/LICENSE.txt for license information.

SYCL/ESIMD/api/functional/functions/functions_select_2d_core_aspect-fp64.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//==-- functions_select_2d_core_aspect-fp64.cpp - DPC++ ESIMD on-device test
2-
// ----------------------------------------------------------------==//
1+
//==- functions_select_2d_core_aspect-fp64.cpp - DPC++ ESIMD on-device test ==//
32
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54
// See https://llvm.org/LICENSE.txt for license information.

0 commit comments

Comments
 (0)