Skip to content

Commit 27bf506

Browse files
committed
Merge branch 'sycl' into llvmspirv_pulldown
2 parents 3f8d7ed + e143dcc commit 27bf506

File tree

259 files changed

+5878
-993
lines changed

Some content is hidden

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

259 files changed

+5878
-993
lines changed

.github/workflows/sycl_linux_precommit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727

2828
lint:
2929
runs-on: [Linux, build]
30+
if: ${{ always() && !contains(github.event.pull_request.labels.*.name, 'disable-lint') }}
3031
container:
3132
image: ghcr.io/intel/llvm/sycl_ubuntu2204_nightly:no-drivers
3233
options: -u 1001:1001
@@ -57,7 +58,7 @@ jobs:
5758
needs: [lint, detect_changes]
5859
if: |
5960
always()
60-
&& (success() || contains(github.event.pull_request.labels.*.name, 'ignore-lint'))
61+
&& (success() || needs.lint.result == 'skipped')
6162
uses: ./.github/workflows/sycl_linux_build.yml
6263
with:
6364
build_ref: ${{ github.sha }}

.github/workflows/sycl_post_commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
build-win:
6767
if: |
6868
always()
69-
&& (success() || contains(github.event.pull_request.labels.*.name, 'ignore-lint'))
69+
&& success()
7070
&& github.repository == 'intel/llvm'
7171
uses: ./.github/workflows/sycl_windows_build.yml
7272

.github/workflows/sycl_windows_precommit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929

3030
lint:
3131
runs-on: [Linux, build]
32+
if: ${{ always() && !contains(github.event.pull_request.labels.*.name, 'disable-lint') }}
3233
container:
3334
image: ghcr.io/intel/llvm/sycl_ubuntu2204_nightly:no-drivers
3435
options: -u 1001:1001
@@ -60,7 +61,7 @@ jobs:
6061
needs: [lint, detect_changes]
6162
if: |
6263
always()
63-
&& (success() || contains(github.event.pull_request.labels.*.name, 'ignore-lint'))
64+
&& (success() || needs.lint.result == 'skipped')
6465
&& github.repository == 'intel/llvm'
6566
uses: ./.github/workflows/sycl_windows_build.yml
6667
with:

clang/test/SemaSYCL/lb_sm_90.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -internal-isystem %S/Inputs %s -triple nvptx64-nvidia-cuda -target-cpu sm_90 -fsycl-is-device -fsyntax-only -Wno-c++23-extensions -verify -S
1+
// RUN: %clang_cc1 -internal-isystem %S/Inputs %s -triple nvptx64-nvidia-cuda -target-cpu sm_90 -fsycl-is-device -fsyntax-only -Wno-c++23-extensions -verify -S -o %t
22

33
// Maximum work groups per multi-processor, mapped to maxclusterrank PTX
44
// directive, is an SM_90 feature. Attributes need to be used in sequence:

llvm/lib/SYCLLowerIR/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ endif()
1313
if (NOT TARGET LLVMGenXIntrinsics)
1414
if (NOT DEFINED LLVMGenXIntrinsics_SOURCE_DIR)
1515
set(LLVMGenXIntrinsics_GIT_REPO https://github.com/intel/vc-intrinsics.git)
16-
# Author: Jinsong Ji <[email protected]>
17-
# Date: Thu Aug 10 14:41:52 2023 +0000
18-
# Guard removed typed pointer enum within version macro
19-
set(LLVMGenXIntrinsics_GIT_TAG 17a53f4304463b8e7e639d57ef17479040a8a2ad)
16+
# Author: Artur Gainullin <[email protected]>
17+
# Date: Thu Nov 9 00:37:24 2023 +0000
18+
19+
# Replace old kernel with rewritten kernel in metadata only since LLVM 17
20+
set(LLVMGenXIntrinsics_GIT_TAG a8403355ada112b72d1fc7db29fd04325eecee60)
2021

2122
message(STATUS "vc-intrinsics repo is missing. Will try to download it from ${LLVMGenXIntrinsics_GIT_REPO}")
2223
include(FetchContent)

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,36 @@ const StringMap<Decor> SpirvDecorMap = {
6565
};
6666
#undef SYCL_COMPILE_TIME_PROPERTY
6767

68+
// Masks defined here must be in sync with the SYCL header with fp control
69+
// kernel property.
70+
enum FloatControl {
71+
RTE = 1, // Round to nearest or even
72+
RTP = 1 << 1, // Round towards +ve inf
73+
RTN = 1 << 2, // Round towards -ve inf
74+
RTZ = 1 << 3, // Round towards zero
75+
76+
DENORM_FTZ = 1 << 4, // Denorm mode flush to zero
77+
DENORM_D_ALLOW = 1 << 5, // Denorm mode double allow
78+
DENORM_F_ALLOW = 1 << 6, // Denorm mode float allow
79+
DENORM_HF_ALLOW = 1 << 7 // Denorm mode half allow
80+
};
81+
82+
enum FloatControlMask {
83+
ROUND_MASK = (RTE | RTP | RTN | RTZ),
84+
DENORM_MASK = (DENORM_D_ALLOW | DENORM_F_ALLOW | DENORM_HF_ALLOW)
85+
};
86+
87+
// SPIRV execution modes for FP control.
88+
// These opcodes are specified in SPIRV specification (SPV_KHR_float_controls
89+
// and SPV_INTEL_float_controls2 extensions):
90+
// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf
91+
constexpr uint32_t SPIRV_ROUNDING_MODE_RTE = 4462; // RoundingModeRTE
92+
constexpr uint32_t SPIRV_ROUNDING_MODE_RTZ = 4463; // RoundingModeRTZ
93+
constexpr uint32_t SPIRV_ROUNDING_MODE_RTP_INTEL = 5620; // RoundingModeRTPINTEL
94+
constexpr uint32_t SPIRV_ROUNDING_MODE_RTN_INTEL = 5621; // RoundingModeRTNINTEL
95+
constexpr uint32_t SPIRV_DENORM_FLUSH_TO_ZERO = 4460; // DenormFlushToZero
96+
constexpr uint32_t SPIRV_DENORM_PRESERVE = 4459; // DenormPreserve
97+
6898
/// Builds a metadata node for a SPIR-V decoration (decoration code is
6999
/// \c uint32_t integers) with no value.
70100
///
@@ -282,6 +312,55 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
282312
if (!AttrKindStr.startswith("sycl-"))
283313
return std::nullopt;
284314

315+
auto AddFPControlMetadataForWidth = [&](int32_t SPIRVFPControl,
316+
int32_t Width) {
317+
auto NamedMD = M.getOrInsertNamedMetadata("spirv.ExecutionMode");
318+
SmallVector<Metadata *, 4> ValueVec;
319+
ValueVec.push_back(ConstantAsMetadata::get(&F));
320+
ValueVec.push_back(ConstantAsMetadata::get(
321+
ConstantInt::get(Type::getInt32Ty(Ctx), SPIRVFPControl)));
322+
ValueVec.push_back(ConstantAsMetadata::get(
323+
ConstantInt::get(Type::getInt32Ty(Ctx), Width)));
324+
NamedMD->addOperand(MDNode::get(Ctx, ValueVec));
325+
};
326+
327+
auto AddFPControlMetadata = [&](int32_t SPIRVFPControl) {
328+
for (int32_t Width : {64, 32, 16}) {
329+
AddFPControlMetadataForWidth(SPIRVFPControl, Width);
330+
}
331+
};
332+
333+
if (AttrKindStr == "sycl-floating-point-control") {
334+
uint32_t FPControl = getAttributeAsInteger<uint32_t>(Attr);
335+
auto IsFPModeSet = [FPControl](FloatControl Flag) -> bool {
336+
return (FPControl & Flag) == Flag;
337+
};
338+
339+
if (IsFPModeSet(RTE))
340+
AddFPControlMetadata(SPIRV_ROUNDING_MODE_RTE);
341+
342+
if (IsFPModeSet(RTP))
343+
AddFPControlMetadata(SPIRV_ROUNDING_MODE_RTP_INTEL);
344+
345+
if (IsFPModeSet(RTN))
346+
AddFPControlMetadata(SPIRV_ROUNDING_MODE_RTN_INTEL);
347+
348+
if (IsFPModeSet(RTZ))
349+
AddFPControlMetadata(SPIRV_ROUNDING_MODE_RTZ);
350+
351+
if (IsFPModeSet(DENORM_FTZ))
352+
AddFPControlMetadata(SPIRV_DENORM_FLUSH_TO_ZERO);
353+
354+
if (IsFPModeSet(DENORM_HF_ALLOW))
355+
AddFPControlMetadataForWidth(SPIRV_DENORM_PRESERVE, 16);
356+
357+
if (IsFPModeSet(DENORM_F_ALLOW))
358+
AddFPControlMetadataForWidth(SPIRV_DENORM_PRESERVE, 32);
359+
360+
if (IsFPModeSet(DENORM_D_ALLOW))
361+
AddFPControlMetadataForWidth(SPIRV_DENORM_PRESERVE, 64);
362+
}
363+
285364
if (AttrKindStr == "sycl-work-group-size" ||
286365
AttrKindStr == "sycl-work-group-size-hint") {
287366
// Split values in the comma-separated list integers.

llvm/lib/Target/ARM/ARMFastISel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,7 @@ unsigned ARMFastISel::ARMSelectCallOp(bool UseReg) {
21802180

21812181
unsigned ARMFastISel::getLibcallReg(const Twine &Name) {
21822182
// Manually compute the global's type to avoid building it when unnecessary.
2183-
Type *GVTy = Type::getInt32PtrTy(*Context, /*AS=*/0);
2183+
Type *GVTy = PointerType::get(*Context, /*AS=*/0);
21842184
EVT LCREVT = TLI.getValueType(DL, GVTy);
21852185
if (!LCREVT.isSimple()) return 0;
21862186

@@ -2964,7 +2964,7 @@ unsigned ARMFastISel::ARMLowerPICELF(const GlobalValue *GV, MVT VT) {
29642964
/*AddCurrentAddress=*/UseGOT_PREL);
29652965

29662966
Align ConstAlign =
2967-
MF->getDataLayout().getPrefTypeAlign(Type::getInt32PtrTy(*Context));
2967+
MF->getDataLayout().getPrefTypeAlign(PointerType::get(*Context, 0));
29682968
unsigned Idx = MF->getConstantPool()->getConstantPoolIndex(CPV, ConstAlign);
29692969
MachineMemOperand *CPMMO =
29702970
MF->getMachineMemOperand(MachinePointerInfo::getConstantPool(*MF),
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
; RUN: opt -passes=compile-time-properties %s -S | FileCheck %s
2+
3+
4+
define spir_kernel void @"Kernel0"() #0 {
5+
entry:
6+
ret void
7+
}
8+
9+
define spir_kernel void @"Kernel1"() #1 {
10+
entry:
11+
ret void
12+
}
13+
14+
define spir_kernel void @"Kernel2"() #2 {
15+
entry:
16+
ret void
17+
}
18+
19+
define spir_kernel void @"Kernel3"() #3 {
20+
entry:
21+
ret void
22+
}
23+
24+
define spir_kernel void @"Kernel4"() #4 {
25+
entry:
26+
ret void
27+
}
28+
29+
define spir_kernel void @"Kernel5"() #5 {
30+
entry:
31+
ret void
32+
}
33+
34+
define spir_kernel void @"Kernel6"() #6 {
35+
entry:
36+
ret void
37+
}
38+
39+
define spir_kernel void @"Kernel7"() #7 {
40+
entry:
41+
ret void
42+
}
43+
44+
define spir_kernel void @"Kernel8"() #8 {
45+
entry:
46+
ret void
47+
}
48+
49+
define spir_kernel void @"Kernel9"() #9 {
50+
entry:
51+
ret void
52+
}
53+
54+
define spir_kernel void @"Kernel10"() #10 {
55+
entry:
56+
ret void
57+
}
58+
59+
; SPIRV execution modes for FP control. | BitMask
60+
; ROUNDING_MODE_RTE = 4462; | 00000001
61+
; ROUNDING_MODE_RTP_INTEL = 5620; | 00000010
62+
; ROUNDING_MODE_RTN_INTEL = 5621; | 00000100
63+
; ROUNDING_MODE_RTZ = 4463; | 00001000
64+
; DEMORM_FLUSH_TO_ZERO = 4460; | 00010000
65+
; DENORM_PRESERVE (double) = 4459; | 00100000
66+
; DENORM_PRESERVE (float) = 4459; | 01000000
67+
; DENORM_PRESERVE (half) = 4459; | 10000000
68+
69+
; rte + ftz (Default)
70+
; CHECK: !0 = !{ptr @Kernel0, i32 [[RTE:4462]], i32 64}
71+
; CHECK: !1 = !{ptr @Kernel0, i32 [[RTE]], i32 32}
72+
; CHECK: !2 = !{ptr @Kernel0, i32 [[RTE]], i32 16}
73+
; CHECK: !3 = !{ptr @Kernel0, i32 [[FTZ:4460]], i32 64}
74+
; CHECK: !4 = !{ptr @Kernel0, i32 [[FTZ]], i32 32}
75+
; CHECK: !5 = !{ptr @Kernel0, i32 [[FTZ]], i32 16}
76+
attributes #0 = { "sycl-floating-point-control"="17" }
77+
78+
; rtp + ftz
79+
; CHECK: !6 = !{ptr @Kernel1, i32 [[RTP:5620]], i32 64}
80+
; CHECK: !7 = !{ptr @Kernel1, i32 [[RTP]], i32 32}
81+
; CHECK: !8 = !{ptr @Kernel1, i32 [[RTP]], i32 16}
82+
; CHECK: !9 = !{ptr @Kernel1, i32 [[FTZ]], i32 64}
83+
; CHECK: !10 = !{ptr @Kernel1, i32 [[FTZ]], i32 32}
84+
; CHECK: !11 = !{ptr @Kernel1, i32 [[FTZ]], i32 16}
85+
attributes #1 = { "sycl-floating-point-control"="18" }
86+
87+
; rtn + ftz
88+
; CHECK: !12 = !{ptr @Kernel2, i32 [[RTN:5621]], i32 64}
89+
; CHECK: !13 = !{ptr @Kernel2, i32 [[RTN]], i32 32}
90+
; CHECK: !14 = !{ptr @Kernel2, i32 [[RTN]], i32 16}
91+
; CHECK: !15 = !{ptr @Kernel2, i32 [[FTZ]], i32 64}
92+
; CHECK: !16 = !{ptr @Kernel2, i32 [[FTZ]], i32 32}
93+
; CHECK: !17 = !{ptr @Kernel2, i32 [[FTZ]], i32 16}
94+
attributes #2 = { "sycl-floating-point-control"="20" }
95+
96+
; rtz + ftz
97+
; CHECK: !18 = !{ptr @Kernel3, i32 [[RTZ:4463]], i32 64}
98+
; CHECK: !19 = !{ptr @Kernel3, i32 [[RTZ]], i32 32}
99+
; CHECK: !20 = !{ptr @Kernel3, i32 [[RTZ]], i32 16}
100+
; CHECK: !21 = !{ptr @Kernel3, i32 [[FTZ]], i32 64}
101+
; CHECK: !22 = !{ptr @Kernel3, i32 [[FTZ]], i32 32}
102+
; CHECK: !23 = !{ptr @Kernel3, i32 [[FTZ]], i32 16}
103+
attributes #3 = { "sycl-floating-point-control"="24" }
104+
105+
; rte + denorm_preserve(double)
106+
; CHECK: !24 = !{ptr @Kernel4, i32 [[RTE]], i32 64}
107+
; CHECK: !25 = !{ptr @Kernel4, i32 [[RTE]], i32 32}
108+
; CHECK: !26 = !{ptr @Kernel4, i32 [[RTE]], i32 16}
109+
; CHECK: !27 = !{ptr @Kernel4, i32 [[DENORM_PRESERVE:4459]], i32 64}
110+
attributes #4 = { "sycl-floating-point-control"="33" }
111+
112+
; rte + denorm_preserve(float)
113+
; CHECK: !28 = !{ptr @Kernel5, i32 [[RTE]], i32 64}
114+
; CHECK: !29 = !{ptr @Kernel5, i32 [[RTE]], i32 32}
115+
; CHECK: !30 = !{ptr @Kernel5, i32 [[RTE]], i32 16}
116+
; CHECK: !31 = !{ptr @Kernel5, i32 [[DENORM_PRESERVE]], i32 32}
117+
attributes #5 = { "sycl-floating-point-control"="65" }
118+
119+
; rte + denorm_preserve(half)
120+
; CHECK: !32 = !{ptr @Kernel6, i32 [[RTE]], i32 64}
121+
; CHECK: !33 = !{ptr @Kernel6, i32 [[RTE]], i32 32}
122+
; CHECK: !34 = !{ptr @Kernel6, i32 [[RTE]], i32 16}
123+
; CHECK: !35 = !{ptr @Kernel6, i32 [[DENORM_PRESERVE]], i32 16}
124+
attributes #6 = { "sycl-floating-point-control"="129" }
125+
126+
; rte + denorm_allow
127+
; CHECK: !36 = !{ptr @Kernel7, i32 [[RTE]], i32 64}
128+
; CHECK: !37 = !{ptr @Kernel7, i32 [[RTE]], i32 32}
129+
; CHECK: !38 = !{ptr @Kernel7, i32 [[RTE]], i32 16}
130+
; CHECK: !39 = !{ptr @Kernel7, i32 [[DENORM_PRESERVE]], i32 16}
131+
; CHECK: !40 = !{ptr @Kernel7, i32 [[DENORM_PRESERVE]], i32 32}
132+
; CHECK: !41 = !{ptr @Kernel7, i32 [[DENORM_PRESERVE]], i32 64}
133+
attributes #7 = { "sycl-floating-point-control"="225" }
134+
135+
; rtz + denorm_preserve(double)
136+
; CHECK: !42 = !{ptr @Kernel8, i32 [[RTZ]], i32 64}
137+
; CHECK: !43 = !{ptr @Kernel8, i32 [[RTZ]], i32 32}
138+
; CHECK: !44 = !{ptr @Kernel8, i32 [[RTZ]], i32 16}
139+
; CHECK: !45 = !{ptr @Kernel8, i32 [[DENORM_PRESERVE]], i32 64}
140+
attributes #8 = { "sycl-floating-point-control"="40" }
141+
142+
; rtp + denorm_preserve(float)
143+
; CHECK: !46 = !{ptr @Kernel9, i32 [[RTP]], i32 64}
144+
; CHECK: !47 = !{ptr @Kernel9, i32 [[RTP]], i32 32}
145+
; CHECK: !48 = !{ptr @Kernel9, i32 [[RTP]], i32 16}
146+
; CHECK: !49 = !{ptr @Kernel9, i32 [[DENORM_PRESERVE]], i32 32}
147+
attributes #9 = { "sycl-floating-point-control"="66" }
148+
149+
; rtz + denorm_allow
150+
; CHECK: !50 = !{ptr @Kernel10, i32 [[RTZ]], i32 64}
151+
; CHECK: !51 = !{ptr @Kernel10, i32 [[RTZ]], i32 32}
152+
; CHECK: !52 = !{ptr @Kernel10, i32 [[RTZ]], i32 16}
153+
; CHECK: !53 = !{ptr @Kernel10, i32 [[DENORM_PRESERVE]], i32 16}
154+
; CHECK: !54 = !{ptr @Kernel10, i32 [[DENORM_PRESERVE]], i32 32}
155+
; CHECK: !55 = !{ptr @Kernel10, i32 [[DENORM_PRESERVE]], i32 64}
156+
attributes #10 = { "sycl-floating-point-control"="232" }

0 commit comments

Comments
 (0)