-
Notifications
You must be signed in to change notification settings - Fork 766
/
Copy pathkernel-arg-align.cpp
52 lines (38 loc) · 1.12 KB
/
kernel-arg-align.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RUN: %clang_cc1 -fsycl-is-device -O0 -internal-isystem %S/Inputs -triple spir64 -emit-llvm -o - %s | FileCheck %s
// Test that the pointer parameters generated for the kernel do not
// have alignment on them.
#include "sycl.hpp"
using namespace sycl;
struct S;
void Test() {
struct MyIP {
char* a;
int* b;
double* c;
void operator()() const {
*((int *) a) = 1; // 1 on arg, 4 on site
*((double *) b) = 2; // 4 on arg, 8 on site
*((char *) c) = 3; // 8 on arg, 1 on site
}
};
constexpr int kN = 8;
auto host_array_A =
malloc_shared<char>(kN);
auto host_array_B =
malloc_shared<int>(kN);
auto host_array_C =
malloc_shared<double>(kN);
for (int i = 0; i < kN; i++) {
host_array_A[i] = i;
host_array_B[i] = i * 2;
}
sycl::kernel_single_task<S>(MyIP{host_array_A, host_array_B, host_array_C});
free(host_array_A);
free(host_array_B);
free(host_array_C);
}
int main() {
Test();
return 0;
}
// CHECK: define {{.*}} spir_kernel void @_ZTS1S(ptr addrspace(1) noundef %_arg_a, ptr addrspace(1) noundef %_arg_b, ptr addrspace(1) noundef %_arg_c)