Skip to content

Commit 119c163

Browse files
author
Artem Gindinson
committed
Clean up accelerator.cpp, reorder header blocks
Signed-off-by: Artem Gindinson <artem.gindinson@intel.com>
1 parent c1bf3b4 commit 119c163

File tree

4 files changed

+28
-97
lines changed

4 files changed

+28
-97
lines changed

sycl/test/aot/accelerator.cpp

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// REQUIRES: aoc, accelerator
2-
3-
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %S/Inputs/aot.cpp -o %t.out
4-
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
5-
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6-
71
//==----- accelerator.cpp - AOT compilation for fpga devices using aoc ------==//
82
//
93
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -12,71 +6,8 @@
126
//
137
//===------------------------------------------------------------------------===//
148

15-
#include <CL/sycl.hpp>
16-
17-
#include <array>
18-
#include <iostream>
19-
20-
constexpr cl::sycl::access::mode sycl_read = cl::sycl::access::mode::read;
21-
constexpr cl::sycl::access::mode sycl_write = cl::sycl::access::mode::write;
22-
23-
template <typename T>
24-
class SimpleVadd;
25-
26-
template <typename T, size_t N>
27-
void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
28-
std::array<T, N>& VC) {
29-
cl::sycl::queue deviceQueue([](cl::sycl::exception_list ExceptionList) {
30-
for (cl::sycl::exception_ptr_class ExceptionPtr : ExceptionList) {
31-
try {
32-
std::rethrow_exception(ExceptionPtr);
33-
} catch (cl::sycl::exception &E) {
34-
std::cerr << E.what();
35-
} catch (...) {
36-
std::cerr << "Unknown async exception was caught." << std::endl;
37-
}
38-
}
39-
});
40-
41-
cl::sycl::range<1> numOfItems{N};
42-
cl::sycl::buffer<T, 1> bufferA(VA.data(), numOfItems);
43-
cl::sycl::buffer<T, 1> bufferB(VB.data(), numOfItems);
44-
cl::sycl::buffer<T, 1> bufferC(VC.data(), numOfItems);
45-
46-
deviceQueue.submit([&](cl::sycl::handler& cgh) {
47-
auto accessorA = bufferA.template get_access<sycl_read>(cgh);
48-
auto accessorB = bufferB.template get_access<sycl_read>(cgh);
49-
auto accessorC = bufferC.template get_access<sycl_write>(cgh);
50-
51-
cgh.parallel_for<class SimpleVadd<T>>(numOfItems,
52-
[=](cl::sycl::id<1> wiID) {
53-
accessorC[wiID] = accessorA[wiID] + accessorB[wiID];
54-
});
55-
});
56-
57-
deviceQueue.wait_and_throw();
58-
}
9+
// REQUIRES: aoc, accelerator
5910

60-
int main() {
61-
const size_t array_size = 4;
62-
std::array<cl::sycl::cl_int, array_size> A = {{1, 2, 3, 4}},
63-
B = {{1, 2, 3, 4}}, C;
64-
std::array<cl::sycl::cl_float, array_size> D = {{1.f, 2.f, 3.f, 4.f}},
65-
E = {{1.f, 2.f, 3.f, 4.f}}, F;
66-
simple_vadd(A, B, C);
67-
simple_vadd(D, E, F);
68-
for (unsigned int i = 0; i < array_size; i++) {
69-
if (C[i] != A[i] + B[i]) {
70-
std::cout << "The results are incorrect (element " << i << " is " << C[i]
71-
<< "!\n";
72-
return 1;
73-
}
74-
if (F[i] != D[i] + E[i]) {
75-
std::cout << "The results are incorrect (element " << i << " is " << F[i]
76-
<< "!\n";
77-
return 1;
78-
}
79-
}
80-
std::cout << "The results are correct!\n";
81-
return 0;
82-
}
11+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_fpga-unknown-unknown-sycldevice %S/Inputs/aot.cpp -o %t.out
12+
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
13+
// RUN: %ACC_RUN_PLACEHOLDER %t.out

sycl/test/aot/cpu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// REQUIRES: opencl-aot, cpu
2-
3-
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/Inputs/aot.cpp -o %t.out
4-
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
5-
// RUN: %CPU_RUN_PLACEHOLDER %t.out
6-
71
//==----- cpu.cpp - AOT compilation for cpu devices using opencl-aot --------==//
82
//
93
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
104
// See https://llvm.org/LICENSE.txt for license information.
115
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
126
//
137
//===------------------------------------------------------------------------===//
8+
9+
// REQUIRES: opencl-aot, cpu
10+
11+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_x86_64-unknown-unknown-sycldevice %S/Inputs/aot.cpp -o %t.out
12+
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
13+
// RUN: %CPU_RUN_PLACEHOLDER %t.out

sycl/test/aot/gpu.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// REQUIRES: ocloc, gpu
2-
// UNSUPPORTED: cuda
3-
// CUDA is not compatible with SPIR.
4-
5-
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend=spir64_gen-unknown-unknown-sycldevice "-device skl" %S/Inputs/aot.cpp -o %t.out
6-
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
7-
// RUN: %GPU_RUN_PLACEHOLDER %t.out
8-
91
//==----- gpu.cpp - AOT compilation for gen devices using GEN compiler ------==//
102
//
113
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
124
// See https://llvm.org/LICENSE.txt for license information.
135
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
146
//
157
//===------------------------------------------------------------------------===//
8+
9+
// REQUIRES: ocloc, gpu
10+
// UNSUPPORTED: cuda
11+
// CUDA is not compatible with SPIR.
12+
13+
// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend=spir64_gen-unknown-unknown-sycldevice "-device skl" %S/Inputs/aot.cpp -o %t.out
14+
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
15+
// RUN: %GPU_RUN_PLACEHOLDER %t.out

sycl/test/aot/with-llvm-bc.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -c %S/Inputs/aot.cpp -o %t.o
2-
// RUN: %clangxx -fsycl -fsycl-link-targets=spir64-unknown-unknown-sycldevice %t.o -o %t.spv
3-
// RUN: llvm-spirv -r %t.spv -o %t.bc
4-
// RUN: %clangxx -fsycl -fsycl-add-targets=spir64:%t.bc %t.o -o %t.out
5-
//
6-
// Only CPU supports LLVM IR bitcode as a binary
7-
// RUN: %CPU_RUN_PLACEHOLDER %t.out
8-
9-
// REQUIRES: cpu
10-
111
//==----- with-llvm-bc.cpp - SYCL kernel with LLVM IR bitcode as binary ----==//
122
//
133
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
144
// See https://llvm.org/LICENSE.txt for license information.
155
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
166
//
177
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: cpu
10+
11+
// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -c %S/Inputs/aot.cpp -o %t.o
12+
// RUN: %clangxx -fsycl -fsycl-link-targets=spir64-unknown-unknown-sycldevice %t.o -o %t.spv
13+
// RUN: llvm-spirv -r %t.spv -o %t.bc
14+
// RUN: %clangxx -fsycl -fsycl-add-targets=spir64:%t.bc %t.o -o %t.out
15+
//
16+
// Only CPU supports LLVM IR bitcode as a binary
17+
// RUN: %CPU_RUN_PLACEHOLDER %t.out

0 commit comments

Comments
 (0)