Skip to content

Commit 56b4e34

Browse files
committed
Merge branch 'sycl' into review/yang/msan_private_mem_2
2 parents fd846cc + 7f2971a commit 56b4e34

File tree

108 files changed

+1388
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1388
-569
lines changed

.github/workflows/docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
fetch-depth: 1
6666
- name: Get subprojects that have doc changes
6767
id: docs-changed-subprojects
68-
uses: tj-actions/changed-files@v45
68+
uses: tj-actions/changed-files@v46
6969
with:
7070
files_yaml: |
7171
llvm:

.github/workflows/pr-code-format.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- name: Get changed files
3636
id: changed-files
37-
uses: tj-actions/changed-files@v45
37+
uses: tj-actions/changed-files@v46
3838
with:
3939
separator: ","
4040
skip_initial_fetch: true

.github/workflows/sycl-linux-build.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ jobs:
167167
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
168168
-DLLVM_INSTALL_UTILS=ON \
169169
-DNATIVECPU_USE_OCK=Off \
170-
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=SPIRV \
171-
--level_zero_v1_and_v2
170+
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=SPIRV
172171
- name: Compile
173172
id: build
174173
run: cmake --build $GITHUB_WORKSPACE/build --target sycl-toolchain

.github/workflows/sycl-nightly.yml

+40-5
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@ jobs:
202202
with:
203203
mode: stop
204204

205-
build-sycl-cts:
205+
build-sycl-cts-linux:
206206
needs: ubuntu2204_build
207207
if: ${{ always() && !cancelled() && needs.ubuntu2204_build.outputs.build_conclusion == 'success' }}
208208
uses: ./.github/workflows/sycl-linux-run-tests.yml
209209
with:
210-
name: Build SYCL-CTS
210+
name: Build SYCL-CTS for Linux
211211
runner: '["Linux", "build"]'
212212
cts_testing_mode: 'build-only'
213213
image_options: -u 1001 --device=/dev/dri --privileged --cap-add SYS_ADMIN
@@ -216,9 +216,10 @@ jobs:
216216
sycl_toolchain_artifact: sycl_linux_default
217217
sycl_toolchain_archive: ${{ needs.ubuntu2204_build.outputs.artifact_archive_name }}
218218
sycl_toolchain_decompress_command: ${{ needs.ubuntu2204_build.outputs.artifact_decompress_command }}
219+
sycl_cts_artifact: sycl_cts_bin_linux
219220

220-
run-sycl-cts:
221-
needs: [ubuntu2204_build, build-sycl-cts]
221+
run-sycl-cts-linux:
222+
needs: [ubuntu2204_build, build-sycl-cts-linux]
222223
if: ${{ always() && !cancelled() && needs.ubuntu2204_build.outputs.build_conclusion == 'success' }}
223224
strategy:
224225
fail-fast: false
@@ -245,7 +246,41 @@ jobs:
245246
sycl_toolchain_artifact: sycl_linux_default
246247
sycl_toolchain_archive: ${{ needs.ubuntu2204_build.outputs.artifact_archive_name }}
247248
sycl_toolchain_decompress_command: ${{ needs.ubuntu2204_build.outputs.artifact_decompress_command }}
248-
sycl_cts_artifact: sycl_cts_bin
249+
sycl_cts_artifact: sycl_cts_bin_linux
250+
251+
build-sycl-cts-win:
252+
needs: build-win
253+
if: ${{ always() && !cancelled() && needs.build-win.outputs.build_conclusion == 'success' }}
254+
uses: ./.github/workflows/sycl-windows-run-tests.yml
255+
with:
256+
name: Build SYCL-CTS for Windows
257+
runner: '["Windows", "build-e2e"]'
258+
cts_testing_mode: 'build-only'
259+
tests_selector: cts
260+
ref: ${{ github.sha }}
261+
sycl_toolchain_archive: ${{ needs.build-win.outputs.artifact_archive_name }}
262+
sycl_cts_artifact: sycl_cts_bin_win
263+
264+
run-sycl-cts-win:
265+
needs: [build-win, build-sycl-cts-win]
266+
if: ${{ always() && !cancelled() && needs.build-win.outputs.build_conclusion == 'success' }}
267+
strategy:
268+
fail-fast: false
269+
matrix:
270+
include:
271+
- name: SYCL-CTS on L0 gen12
272+
runner: '["Windows", "gen12"]'
273+
target_devices: level_zero:gpu
274+
uses: ./.github/workflows/sycl-windows-run-tests.yml
275+
with:
276+
name: ${{ matrix.name }}
277+
runner: ${{ matrix.runner }}
278+
cts_testing_mode: 'run-only'
279+
target_devices: ${{ matrix.target_devices }}
280+
tests_selector: cts
281+
ref: ${{ github.sha }}
282+
sycl_toolchain_archive: ${{ needs.build-win.outputs.artifact_archive_name }}
283+
sycl_cts_artifact: sycl_cts_bin_win
249284

250285
aggregate_benchmark_results:
251286
if: github.repository == 'intel/llvm' && !cancelled()

.github/workflows/sycl-post-commit.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ concurrency:
2929
permissions: read-all
3030

3131
jobs:
32+
detect_changes:
33+
if: ${{ github.event_name == 'pull_request' }}
34+
uses: ./.github/workflows/sycl-detect-changes.yml
35+
3236
build-lin:
3337
name: Linux (Self build + no-assertions)
3438
if: github.repository == 'intel/llvm'
@@ -40,7 +44,7 @@ jobs:
4044
build_configure_extra_args: --no-assertions --hip --cuda --native_cpu -DSYCL_ENABLE_STACK_PRINTING=ON -DSYCL_LIB_WITH_DEBUG_SYMBOL=ON
4145

4246
e2e-lin:
43-
needs: [build-lin]
47+
needs: [detect_changes, build-lin]
4448
if: ${{ always() && !cancelled() && needs.build-lin.outputs.build_conclusion == 'success' }}
4549
strategy:
4650
fail-fast: false
@@ -94,6 +98,13 @@ jobs:
9498
sycl_toolchain_archive: ${{ needs.build-lin.outputs.artifact_archive_name }}
9599
sycl_toolchain_decompress_command: ${{ needs.build-lin.outputs.artifact_decompress_command }}
96100

101+
# Do not install drivers on AMD and CUDA runners.
102+
install_igc_driver: >-
103+
${{ github.event_name == 'pull_request' }} &&
104+
${{ !contains(matrix.target_devices, 'cuda') &&
105+
!contains(matrix.target_devices, 'hip') &&
106+
contains(needs.detect_changes.outputs.filters, 'drivers') }}
107+
97108
build-win:
98109
if: |
99110
always()

.github/workflows/sycl-windows-run-tests.yml

+50-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ on:
1010
type: string
1111
required: True
1212

13+
target_devices:
14+
type: string
15+
required: False
16+
extra_cmake_args:
17+
type: string
18+
required: False
19+
tests_selector:
20+
description: |
21+
Two possible options: "e2e" and "cts".
22+
type: string
23+
default: "e2e"
24+
1325
extra_lit_opts:
1426
description: |
1527
Extra options to be added to LIT_OPTS.
@@ -28,6 +40,10 @@ on:
2840
Note: it doesn't affect ./devops/actions/run-tests/* as these actions
2941
call checkout again and therefore override the devops directory, so
3042
configs/dependecies from input.ref are used.
43+
tests_ref:
44+
type: string
45+
required: False
46+
description: Commit SHA or branch to checkout e2e/cts tests.
3147

3248
sycl_toolchain_artifact:
3349
type: string
@@ -48,6 +64,23 @@ on:
4864
required: false
4965
default: "cl"
5066

67+
cts_testing_mode:
68+
description: |
69+
Testing mode to run SYCL-CTS in, can be either `full`, `build-only`
70+
or `run-only`. In `build-only` mode an artifact of the CTS binaries
71+
will be uploaded.
72+
type: string
73+
default: 'full'
74+
75+
sycl_cts_artifact:
76+
type: string
77+
default: ''
78+
required: False
79+
artifact_retention_days:
80+
description: 'E2E/SYCL-CTS binaries artifact retention period.'
81+
type: string
82+
default: 1
83+
5184
permissions: read-all
5285

5386
jobs:
@@ -86,6 +119,7 @@ jobs:
86119
- name: Register cleanup after job is finished
87120
uses: ./devops/actions/cleanup
88121
- uses: ./devops/actions/cached_checkout
122+
if: inputs.tests_selector == 'e2e'
89123
with:
90124
path: llvm
91125
ref: ${{ inputs.ref || github.sha }}
@@ -103,16 +137,19 @@ jobs:
103137
- name: Setup SYCL toolchain
104138
run: |
105139
echo "PATH=$env:GITHUB_WORKSPACE\\install\\bin;$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
140+
echo "LIB=$env:GITHUB_WORKSPACE\\install\\lib;$env:LIB" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
106141
- run: |
107142
sycl-ls
108143
- run: |
109144
sycl-ls --verbose
110145
- name: Configure E2E with Level Zero target
146+
if: inputs.tests_selector == 'e2e'
111147
shell: cmd
112148
run: |
113149
mkdir build-e2e
114150
cmake -GNinja -B build-e2e -S.\llvm\sycl\test-e2e -DSYCL_TEST_E2E_TARGETS="level_zero:gpu" -DCMAKE_CXX_COMPILER="clang++" -DLEVEL_ZERO_LIBS_DIR="D:\\github\\level-zero_win-sdk\\lib" -DLEVEL_ZERO_INCLUDE="D:\\github\\level-zero_win-sdk\\include" -DLLVM_LIT="..\\llvm\\llvm\\utils\\lit\\lit.py"
115151
- name: Run End-to-End tests
152+
if: inputs.tests_selector == 'e2e'
116153
shell: bash
117154
run: |
118155
# Run E2E tests.
@@ -121,6 +158,18 @@ jobs:
121158
fi
122159
export LIT_OPTS="-v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests ${{ inputs.extra_lit_opts }}"
123160
cmake --build build-e2e --target check-sycl-e2e
161+
162+
- name: Run SYCL CTS Tests
163+
if: inputs.tests_selector == 'cts'
164+
uses: ./devops/actions/run-tests/windows/cts
165+
with:
166+
ref: ${{ inputs.tests_ref || 'main' }}
167+
extra_cmake_args: ${{ inputs.extra_cmake_args }}
168+
cts_testing_mode: ${{ inputs.cts_testing_mode }}
169+
sycl_cts_artifact: ${{ inputs.sycl_cts_artifact }}
170+
target_devices: ${{ inputs.target_devices }}
171+
retention-days: ${{ inputs.artifact_retention_days }}
172+
124173
- name: Detect hung tests
125174
if: always()
126175
shell: powershell
@@ -135,4 +184,4 @@ jobs:
135184
if: always()
136185
run: |
137186
rmdir /q /s install
138-
rmdir /q /s build-e2e
187+
if exist build-e2e rmdir /q /s build-e2e

buildbot/configure.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ def do_configure(args, passthrough_args):
7070
if sys.platform != "darwin":
7171
# For more info on the enablement of level_zero_v2 refer to this document:
7272
# https://github.com/intel/llvm/blob/sycl/unified-runtime/source/adapters/level_zero/v2/README.md
73-
if args.level_zero_v2:
74-
sycl_enabled_backends.append("level_zero_v2")
75-
elif args.level_zero_v1_and_v2:
73+
if args.level_zero_adapter_version == "V1":
7674
sycl_enabled_backends.append("level_zero")
75+
if args.level_zero_adapter_version == "V2":
7776
sycl_enabled_backends.append("level_zero_v2")
78-
else:
77+
if args.level_zero_adapter_version == "ALL":
7978
sycl_enabled_backends.append("level_zero")
79+
sycl_enabled_backends.append("level_zero_v2")
8080

8181
# lld is needed on Windows or for the HIP adapter on AMD
8282
if platform.system() == "Windows" or (args.hip and args.hip_platform == "AMD"):
@@ -340,12 +340,11 @@ def main():
340340
help="choose hardware platform for HIP backend",
341341
)
342342
parser.add_argument(
343-
"--level_zero_v2", action="store_true", help="Enable SYCL Level Zero V2"
344-
)
345-
parser.add_argument(
346-
"--level_zero_v1_and_v2",
347-
action="store_true",
348-
help="Enable SYCL Level Zero Legacy and V2",
343+
"--level_zero_adapter_version",
344+
type=str,
345+
choices=["V1", "V2", "ALL"],
346+
default="ALL",
347+
help="Choose version of Level Zero adapter to build",
349348
)
350349
parser.add_argument(
351350
"--host-target",

clang/lib/CodeGen/Targets/SPIR.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,20 @@ class CommonSPIRABIInfo : public DefaultABIInfo {
3838
ABIArgInfo CommonSPIRABIInfo::classifyKernelArgumentType(QualType Ty) const {
3939
Ty = useFirstFieldIfTransparentUnion(Ty);
4040

41-
if (getContext().getLangOpts().SYCLIsDevice && isAggregateTypeForABI(Ty)) {
41+
if (getContext().getLangOpts().SYCLIsDevice) {
42+
if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) {
43+
switch (BT->getKind()) {
44+
case BuiltinType::Bool:
45+
// Bool / i1 isn't a legal kernel argument in SPIR-V.
46+
// Coerce the type to follow the host representation of bool.
47+
return ABIArgInfo::getDirect(CGT.ConvertTypeForMem(Ty));
48+
default:
49+
break;
50+
}
51+
}
4252
// Pass all aggregate types allowed by Sema by value.
43-
return getNaturalAlignIndirect(Ty);
53+
if (isAggregateTypeForABI(Ty))
54+
return getNaturalAlignIndirect(Ty);
4455
}
4556

4657
return DefaultABIInfo::classifyArgumentType(Ty);

clang/lib/Sema/SPIRVBuiltins.td

+6-6
Original file line numberDiff line numberDiff line change
@@ -897,15 +897,15 @@ foreach name = ["BitCount"] in {
897897
// 3.32.20. Barrier Instructions
898898

899899
foreach name = ["ControlBarrier"] in {
900-
// TODO: Allow enum flags instead of UInt ?
901-
// TODO: We should enforce that the UInt must be a literal.
902-
def : SPVBuiltin<name, [Void, UInt, UInt, UInt], Attr.Convergent>;
900+
// TODO: Allow enum flags instead of Int ?
901+
// TODO: We should enforce that the Int must be a literal.
902+
def : SPVBuiltin<name, [Void, Int, Int, Int], Attr.Convergent>;
903903
}
904904

905905
foreach name = ["MemoryBarrier"] in {
906-
// TODO: Allow enum flags instead of UInt ?
907-
// TODO: We should enforce that the UInt must be a literal.
908-
def : SPVBuiltin<name, [Void, UInt, UInt]>;
906+
// TODO: Allow enum flags instead of Int ?
907+
// TODO: We should enforce that the Int must be a literal.
908+
def : SPVBuiltin<name, [Void, Int, Int]>;
909909
}
910910

911911
// 3.32.21. Group and Subgroup Instructions

clang/test/CodeGenSPIRV/spirv-builtin-lookup.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,19 @@ double acos(double val) {
1515
}
1616

1717
// CHECK: declare noundef double @_Z16__spirv_ocl_acosd(double noundef)
18+
19+
void control_barrier() {
20+
// CHECK-LABEL: @_Z15control_barrierv
21+
// CHECK: call void @_Z22__spirv_ControlBarrieriii
22+
__spirv_ControlBarrier(2, 2, 912);
23+
}
24+
25+
// CHECK: declare void @_Z22__spirv_ControlBarrieriii(i32 noundef, i32 noundef, i32 noundef)
26+
27+
void memory_barrier() {
28+
// CHECK-LABEL: @_Z14memory_barrierv
29+
// CHECK: call void @_Z21__spirv_MemoryBarrierii(
30+
__spirv_MemoryBarrier(0, 2);
31+
}
32+
33+
// CHECK: declare void @_Z21__spirv_MemoryBarrierii(i32 noundef, i32 noundef)

clang/test/CodeGenSYCL/Inputs/sycl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extern "C" int printf(const char* fmt, ...);
1919

2020
#ifdef __SYCL_DEVICE_ONLY__
2121
__attribute__((convergent)) extern __attribute__((sycl_device)) void
22-
__spirv_ControlBarrier(int, int, int) noexcept;
22+
__spirv_ControlBarrier(int, int, int);
2323
#endif
2424

2525
// Dummy runtime classes to model SYCL API.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
2+
3+
#include "sycl.hpp"
4+
5+
void take_bool(bool) {}
6+
7+
int main() {
8+
bool test = false;
9+
sycl::queue q;
10+
11+
// CHECK: @_ZTSZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_E11test_kernel(i8 {{.*}} [[ARG:%[A-Za-z_0-9]*]]
12+
// CHECK: %__SYCLKernel = alloca
13+
// CHECK: %test = getelementptr inbounds nuw %class.anon, ptr addrspace(4) %__SYCLKernel.ascast
14+
// CHECK: store i8 %{{.*}}, ptr addrspace(4) %test
15+
// CHECK: call spir_func void @_ZZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_ENKUlvE_clEv
16+
//
17+
// CHECK: define {{.*}} @_Z9take_boolb(i1
18+
q.submit([&](sycl::handler &h) {
19+
h.single_task<class test_kernel>([=]() {
20+
(void)test;
21+
take_bool(test);
22+
});
23+
});
24+
25+
return 0;
26+
}

0 commit comments

Comments
 (0)