Skip to content

Commit 998656f

Browse files
[SYCL][NFC] Move ESIMD tests in-tree (#7417)
Tests were added to intel/llvm-test-suite repo (intel/llvm-test-suite#1289), but they are too low-level to be located in there. Moved them in-tree.
1 parent f26eb3c commit 998656f

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// RUN: %clangxx -fsycl -Xclang -opaque-pointers -fsycl-device-only -Xclang -emit-llvm -o %t.comp.ll %s
2+
// RUN: sycl-post-link -ir-output-only -lower-esimd -S %t.comp.ll -o %t.out.ll
3+
// RUN: FileCheck --input-file=%t.out.ll %s
4+
5+
// Checks that ESIMDOptimizeVecArgCallConv does the right job as
6+
// a part of sycl-post-link.
7+
8+
#include <sycl/ext/intel/esimd.hpp>
9+
10+
using namespace sycl::ext::intel::esimd;
11+
12+
// clang-format off
13+
14+
//------------------------
15+
// Test1: Optimized parameter interleaves non - optimizeable ones.
16+
17+
__attribute__((noinline))
18+
SYCL_EXTERNAL simd<int, 8> callee__sret__x_param_x(int i, simd<int, 8> x, int j) SYCL_ESIMD_FUNCTION {
19+
// CHECK: define dso_local spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 noundef %{{.*}}, <8 x i32> %{{.*}}, i32 noundef %{{.*}})
20+
return x + (i + j);
21+
}
22+
23+
__attribute__((noinline))
24+
SYCL_EXTERNAL simd<int, 8> test__sret__x_param_x(simd<int, 8> x) SYCL_ESIMD_FUNCTION {
25+
// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__x_param_x{{.*}}(<8 x i32> %{{.*}})
26+
return callee__sret__x_param_x(2, x, 1);
27+
// CHECK: %{{.*}} = call spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 2, <8 x i32> %{{.*}}, i32 1)
28+
}
29+
30+
//------------------------
31+
// Test2: "2-level fall through"
32+
33+
__attribute__((noinline))
34+
SYCL_EXTERNAL simd<double, 32> callee__all_fall_through0(simd<double, 32> x) SYCL_ESIMD_FUNCTION {
35+
// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}})
36+
return x;
37+
}
38+
39+
__attribute__((noinline))
40+
SYCL_EXTERNAL simd<double, 32> callee__all_fall_through1(simd<double, 32> x) SYCL_ESIMD_FUNCTION {
41+
// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}})
42+
return callee__all_fall_through0(x);
43+
// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}})
44+
}
45+
46+
__attribute__((noinline))
47+
SYCL_EXTERNAL simd<double, 32> test__all_fall_through(simd<double, 32> x) SYCL_ESIMD_FUNCTION {
48+
// CHECK: define dso_local spir_func <32 x double> @_Z22test__all_fall_through{{.*}}(<32 x double> %{{.*}})
49+
return callee__all_fall_through1(x);
50+
// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}})
51+
}
52+
53+
//------------------------
54+
// Test3. First argument is passed by reference and updated in the callee,
55+
// must not be optimized.
56+
57+
__attribute__((noinline))
58+
SYCL_EXTERNAL void callee_void__noopt_opt(simd<int, 8>& x, simd<int, 8> y) SYCL_ESIMD_FUNCTION {
59+
// CHECK: define dso_local spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr {{.*}} %{{.*}}, <8 x i32> %{{.*}})
60+
x = x + y;
61+
}
62+
63+
__attribute__((noinline))
64+
SYCL_EXTERNAL simd<int, 8> test__sret__noopt_opt(simd<int, 8> x) SYCL_ESIMD_FUNCTION {
65+
// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__noopt_opt{{.*}}(ptr noundef %{{.*}})
66+
callee_void__noopt_opt(x, x);
67+
// CHECK: call spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr addrspace(4) %{{.*}}, <8 x i32> %{{.*}})
68+
return x;
69+
}
70+
71+
//------------------------
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %clangxx -fsycl -Xclang -opaque-pointers -fsycl-device-only -Xclang -emit-llvm -o %t.comp.ll %s
2+
// RUN: sycl-post-link -ir-output-only -lower-esimd -S %t.comp.ll -o %t.out.ll
3+
// RUN: FileCheck --input-file=%t.out.ll %s
4+
5+
// Performs a basic check that ESIMDOptimizeVecArgCallConv does the right job as
6+
// a part of sycl-post-link.
7+
8+
#include <sycl/ext/intel/esimd.hpp>
9+
10+
using namespace sycl::ext::intel::esimd;
11+
12+
ESIMD_PRIVATE simd<float, 3 * 32 * 4> GRF;
13+
#define V(x, w, i) (x).template select<w, 1>(i)
14+
15+
// clang-format off
16+
17+
// "Fall-through case", incoming optimizeable parameter is just returned
18+
19+
__attribute__((noinline))
20+
SYCL_EXTERNAL simd<float, 16> callee__sret__param(simd<float, 16> x) SYCL_ESIMD_FUNCTION {
21+
// CHECK: define dso_local spir_func <16 x float> @_Z19callee__sret__param{{.*}}(<16 x float> %[[PARAM:.+]])
22+
return x;
23+
}
24+
25+
// * Caller 1: simd object is read from array
26+
27+
__attribute__((noinline))
28+
SYCL_EXTERNAL simd<float, 16> test__sret__fall_through__arr(simd<float, 16> *x, int i) SYCL_ESIMD_FUNCTION {
29+
// CHECK: define dso_local spir_func <16 x float> @_Z29test__sret__fall_through__arr{{.*}}(ptr addrspace(4) noundef %[[PARAM0:.+]], i32 noundef %{{.*}})
30+
return callee__sret__param(x[i]);
31+
// CHECK: %{{.*}} = call spir_func <16 x float> @_Z19callee__sret__param{{.*}}(<16 x float> %{{.*}})
32+
}
33+
34+
// * Caller 2 : simd object is read from a global
35+
36+
__attribute__((noinline))
37+
SYCL_EXTERNAL simd<float, 16> test__sret__fall_through__glob() SYCL_ESIMD_FUNCTION {
38+
return callee__sret__param(V(GRF, 16, 0));
39+
// CHECK: %{{.*}} = call spir_func <16 x float> @_Z19callee__sret__param{{.*}}(<16 x float> %{{.*}})
40+
}

0 commit comments

Comments
 (0)