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

Commit 18b3729

Browse files
authored
[ESIMD] Add tests for ESIMDOptimizeVecArgCallConv pass. (#1289)
* [ESIMD] Add tests for ESIMDOptimizeVecArgCallConv pass. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
1 parent be408a8 commit 18b3729

File tree

3 files changed

+161
-0
lines changed

3 files changed

+161
-0
lines changed

SYCL/ESIMD/vadd_usm_opqptr.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//==---------------- vadd_usm_opqptr.cpp - DPC++ ESIMD on-device test -----==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// REQUIRES: gpu
9+
// UNSUPPORTED: cuda || hip
10+
// RUN: %clangxx -fsycl -Xclang -opaque-pointers %s -o %t.out
11+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
12+
13+
// TODO Running existing tests in opaque pointer mode should be supported by the
14+
// CI.
15+
16+
// The test checks if vadd_usm.cpp works in opaque pointer mode.
17+
18+
#include "vadd_usm.cpp"

SYCL/ESIMD/vec_arg_call_conv_ext.cpp

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//==-------------- vec_arg_call_conv_ext.cpp - DPC++ ESIMD feature test ---==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// Intel GPU is not really required, but the test does not make sense for
9+
// others.
10+
// REQUIRES: gpu
11+
// UNSUPPORTED: cuda || hip
12+
// RUN: %clangxx -fsycl -Xclang -opaque-pointers -fsycl-device-only -Xclang -emit-llvm -o %t.comp.ll %s
13+
// RUN: sycl-post-link -ir-output-only -lower-esimd -S %t.comp.ll -o %t.out.ll
14+
// RUN: FileCheck --input-file=%t.out.ll %s
15+
16+
// Checks that ESIMDOptimizeVecArgCallConv does the right job as
17+
// a part of sycl-post-link.
18+
19+
#include <sycl/ext/intel/esimd.hpp>
20+
21+
using namespace sycl::ext::intel::esimd;
22+
23+
// clang-format off
24+
25+
//------------------------
26+
// Test1: Optimized parameter interleaves non - optimizeable ones.
27+
28+
__attribute__((noinline))
29+
SYCL_EXTERNAL simd<int, 8> callee__sret__x_param_x(int i, simd<int, 8> x, int j) SYCL_ESIMD_FUNCTION {
30+
// CHECK: define dso_local spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 noundef %{{.*}}, <8 x i32> %{{.*}}, i32 noundef %{{.*}})
31+
return x + (i + j);
32+
}
33+
34+
__attribute__((noinline))
35+
SYCL_EXTERNAL simd<int, 8> test__sret__x_param_x(simd<int, 8> x) SYCL_ESIMD_FUNCTION {
36+
// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__x_param_x{{.*}}(<8 x i32> %{{.*}})
37+
return callee__sret__x_param_x(2, x, 1);
38+
// CHECK: %{{.*}} = call spir_func <8 x i32> @_Z23callee__sret__x_param_x{{.*}}(i32 2, <8 x i32> %{{.*}}, i32 1)
39+
}
40+
41+
//------------------------
42+
// Test2: "2-level fall through"
43+
44+
__attribute__((noinline))
45+
SYCL_EXTERNAL simd<double, 32> callee__all_fall_through0(simd<double, 32> x) SYCL_ESIMD_FUNCTION {
46+
// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}})
47+
return x;
48+
}
49+
50+
__attribute__((noinline))
51+
SYCL_EXTERNAL simd<double, 32> callee__all_fall_through1(simd<double, 32> x) SYCL_ESIMD_FUNCTION {
52+
// CHECK: define dso_local spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}})
53+
return callee__all_fall_through0(x);
54+
// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through0{{.*}}(<32 x double> %{{.*}})
55+
}
56+
57+
__attribute__((noinline))
58+
SYCL_EXTERNAL simd<double, 32> test__all_fall_through(simd<double, 32> x) SYCL_ESIMD_FUNCTION {
59+
// CHECK: define dso_local spir_func <32 x double> @_Z22test__all_fall_through{{.*}}(<32 x double> %{{.*}})
60+
return callee__all_fall_through1(x);
61+
// CHECK: %{{.*}} = call spir_func <32 x double> @_Z25callee__all_fall_through1{{.*}}(<32 x double> %{{.*}})
62+
}
63+
64+
//------------------------
65+
// Test3. First argument is passed by reference and updated in the callee,
66+
// must not be optimized.
67+
68+
__attribute__((noinline))
69+
SYCL_EXTERNAL void callee_void__noopt_opt(simd<int, 8>& x, simd<int, 8> y) SYCL_ESIMD_FUNCTION {
70+
// CHECK: define dso_local spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr {{.*}} %{{.*}}, <8 x i32> %{{.*}})
71+
x = x + y;
72+
}
73+
74+
__attribute__((noinline))
75+
SYCL_EXTERNAL simd<int, 8> test__sret__noopt_opt(simd<int, 8> x) SYCL_ESIMD_FUNCTION {
76+
// CHECK: define dso_local spir_func <8 x i32> @_Z21test__sret__noopt_opt{{.*}}(ptr noundef %{{.*}})
77+
callee_void__noopt_opt(x, x);
78+
// CHECK: call spir_func void @_Z22callee_void__noopt_opt{{.*}}(ptr addrspace(4) %{{.*}}, <8 x i32> %{{.*}})
79+
return x;
80+
}
81+
82+
//------------------------
83+
84+
// Dummy main to satisfy linker.
85+
int main() {
86+
return 0;
87+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//==------------ vec_arg_call_conv_smoke.cpp - DPC++ ESIMD feature test ---==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// Intel GPU is not really required, but the test does not make sense for
9+
// others.
10+
// REQUIRES: gpu
11+
// UNSUPPORTED: cuda || hip
12+
// RUN: %clangxx -fsycl -Xclang -opaque-pointers -fsycl-device-only -Xclang -emit-llvm -o %t.comp.ll %s
13+
// RUN: sycl-post-link -ir-output-only -lower-esimd -S %t.comp.ll -o %t.out.ll
14+
// RUN: FileCheck --input-file=%t.out.ll %s
15+
16+
// Performs a basic check that ESIMDOptimizeVecArgCallConv does the right job as
17+
// a part of sycl-post-link.
18+
19+
#include <sycl/ext/intel/esimd.hpp>
20+
21+
using namespace sycl::ext::intel::esimd;
22+
23+
ESIMD_PRIVATE simd<float, 3 * 32 * 4> GRF;
24+
#define V(x, w, i) (x).template select<w, 1>(i)
25+
26+
// clang-format off
27+
28+
// "Fall-through case", incoming optimizeable parameter is just returned
29+
30+
__attribute__((noinline))
31+
SYCL_EXTERNAL simd<float, 16> callee__sret__param(simd<float, 16> x) SYCL_ESIMD_FUNCTION {
32+
// CHECK: define dso_local spir_func <16 x float> @_Z19callee__sret__param{{.*}}(<16 x float> %[[PARAM:.+]])
33+
return x;
34+
}
35+
36+
// * Caller 1: simd object is read from array
37+
38+
__attribute__((noinline))
39+
SYCL_EXTERNAL simd<float, 16> test__sret__fall_through__arr(simd<float, 16> *x, int i) SYCL_ESIMD_FUNCTION {
40+
// CHECK: define dso_local spir_func <16 x float> @_Z29test__sret__fall_through__arr{{.*}}(ptr addrspace(4) noundef %[[PARAM0:.+]], i32 noundef %{{.*}})
41+
return callee__sret__param(x[i]);
42+
// CHECK: %{{.*}} = call spir_func <16 x float> @_Z19callee__sret__param{{.*}}(<16 x float> %{{.*}})
43+
}
44+
45+
// * Caller 2 : simd object is read from a global
46+
47+
__attribute__((noinline))
48+
SYCL_EXTERNAL simd<float, 16> test__sret__fall_through__glob() SYCL_ESIMD_FUNCTION {
49+
return callee__sret__param(V(GRF, 16, 0));
50+
// CHECK: %{{.*}} = call spir_func <16 x float> @_Z19callee__sret__param{{.*}}(<16 x float> %{{.*}})
51+
}
52+
53+
// Dummy main to satisfy linker.
54+
int main() {
55+
return 0;
56+
}

0 commit comments

Comments
 (0)