Skip to content

Commit 9befa55

Browse files
committed
Merge remote-tracking branch 'origin/sycl' into duncan/sub-copy
2 parents 7700111 + a4f74a9 commit 9befa55

File tree

180 files changed

+2868
-1561
lines changed

Some content is hidden

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

180 files changed

+2868
-1561
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ jobs:
117117
env: ${{ matrix.env || '{}' }}
118118

119119
# Do not install drivers on AMD and CUDA runners.
120-
install_igc_driver: |
120+
install_igc_driver: >-
121121
${{ !contains(matrix.target_devices, 'ext_oneapi_cuda') &&
122122
!contains(matrix.target_devices, 'ext_oneapi_hip') &&
123123
contains(needs.detect_changes.outputs.filters, 'drivers') }}
124-
install_dev_igc_driver: |
124+
install_dev_igc_driver: >-
125125
${{ !contains(matrix.target_devices, 'ext_oneapi_cuda') &&
126126
!contains(matrix.target_devices, 'ext_oneapi_hip') &&
127127
matrix.use_igc_dev && contains(needs.detect_changes.outputs.filters, 'devigccfg') ||

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ jobs:
8686
# Run E2E tests.
8787
export LIT_OPTS="-v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests ${{ inputs.extra_lit_opts }}"
8888
cmake --build build-e2e --target check-sycl-e2e
89+
- name: Detect hung tests
90+
shell: powershell
91+
run: |
92+
$exitCode = 0
93+
$hungTests = Get-Process | Where-Object { ($_.Path -match "llvm\\install") -or ($_.Path -match "llvm\\build-e2e") }
94+
$hungTests | Foreach-Object {
95+
$exitCode = 1
96+
echo "Test $($_.Path) hung!"
97+
Stop-Process -Force $_
98+
}
99+
exit $exitCode
89100
- name: Cleanup
90101
shell: cmd
91102
if: always()

clang/include/clang/Basic/LangOptions.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ LANGOPT(SYCLAllowFuncPtr , 1, 0, "Allow function pointers in SYCL device code")
307307
LANGOPT(SYCLStdLayoutKernelParams, 1, 0, "Enable standard layout requirement for SYCL kernel parameters")
308308
LANGOPT(SYCLUnnamedLambda , 1, 0, "Allow unnamed lambda SYCL kernels")
309309
LANGOPT(SYCLForceInlineKernelLambda , 1, 0, "Force inline SYCL kernel lambdas in entry point")
310-
LANGOPT(SYCLAllowAllFeaturesInConstexpr, 1, 0, "Allow all C++ features in SYCL device code in manifestly constant-evaluated expressions")
311310
LANGOPT(SYCLESIMDForceStatelessMem, 1, 0, "Make accessors use USM memory in ESIMD kernels")
312311
LANGOPT(SYCLESIMDBuildHostCode, 1, 1, "Build the host implementation of ESIMD functions")
313312
ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 2, SYCL_None, "Version of the SYCL standard used")

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8628,11 +8628,6 @@ def fsycl_is_native_cpu : Flag<["-"], "fsycl-is-native-cpu">,
86288628
HelpText<"Perform device compilation for Native CPU.">,
86298629
Visibility<[CC1Option]>,
86308630
MarshallingInfoFlag<LangOpts<"SYCLIsNativeCPU">>;
8631-
defm sycl_allow_all_features_in_constexpr
8632-
: BoolFOption<
8633-
"sycl-allow-all-features-in-constexpr", LangOpts<"SYCLAllowAllFeaturesInConstexpr">,
8634-
DefaultFalse,
8635-
PosFlag<SetTrue, [], [CC1Option], "Allow all C++ features in SYCL device code in manifestly constant-evaluated expressions">, NegFlag<SetFalse>>;
86368631

86378632
} // let Visibility = [CC1Option]
86388633

clang/lib/Sema/Sema.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ class DeferredDiagnosticsEmitter
18291829
}
18301830

18311831
void VisitDeclStmt(DeclStmt *DS) {
1832-
if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr) {
1832+
if (S.getLangOpts().SYCLIsDevice) {
18331833
if (DS->isSingleDecl()) {
18341834
Decl *D = DS->getSingleDecl();
18351835
if (auto *VD = dyn_cast<VarDecl>(D))
@@ -1850,7 +1850,7 @@ class DeferredDiagnosticsEmitter
18501850
}
18511851

18521852
void VisitConstantExpr(ConstantExpr *E) {
1853-
if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr)
1853+
if (S.getLangOpts().SYCLIsDevice)
18541854
return;
18551855
this->VisitStmt(E);
18561856
}
@@ -2264,7 +2264,7 @@ void Sema::checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D) {
22642264

22652265
CheckType(Ty);
22662266
if (const auto *FD = dyn_cast_if_present<FunctionDecl>(D)) {
2267-
if (LangOpts.SYCLAllowAllFeaturesInConstexpr && FD->isConsteval())
2267+
if (LangOpts.SYCLIsDevice && FD->isConsteval())
22682268
return;
22692269
if (const auto *FPTy = dyn_cast<FunctionProtoType>(Ty)) {
22702270
for (const auto &ParamTy : FPTy->param_types())

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18418,7 +18418,7 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl *D) {
1841818418

1841918419
if (auto *VD = dyn_cast<VarDecl>(D);
1842018420
VD && (VD->mightBeUsableInConstantExpressions(Context)))
18421-
InConstexprVarInit = LangOpts.SYCLAllowAllFeaturesInConstexpr;
18421+
InConstexprVarInit = true;
1842218422
PushExpressionEvaluationContext(
1842318423
ExpressionEvaluationContext::PotentiallyEvaluated, D);
1842418424
}

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,7 @@ class DeviceFunctionTracker {
782782

783783
public:
784784
DeviceFunctionTracker(SemaSYCL &S) : SemaSYCLRef(S) {
785-
if (S.getLangOpts().SYCLAllowAllFeaturesInConstexpr)
786-
CG.setSkipConstantExpressions(S.getASTContext());
785+
CG.setSkipConstantExpressions(S.getASTContext());
787786
CG.addToCallGraph(S.getASTContext().getTranslationUnitDecl());
788787
CollectSyclExternalFuncs();
789788
}
@@ -5594,14 +5593,12 @@ SemaSYCL::DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID,
55945593
return SemaDiagnosticBuilder::K_ImmediateWithCallStack;
55955594
if (!FD)
55965595
return SemaDiagnosticBuilder::K_Nop;
5597-
if (SemaRef.getLangOpts().SYCLAllowAllFeaturesInConstexpr &&
5598-
(SemaRef.isConstantEvaluatedContext() ||
5599-
SemaRef.currentEvaluationContext().isDiscardedStatementContext()))
5596+
if (SemaRef.isConstantEvaluatedContext() ||
5597+
SemaRef.currentEvaluationContext().isDiscardedStatementContext())
56005598
return SemaDiagnosticBuilder::K_Nop;
56015599
// Defer until we know that the variable's intializer is actually a
56025600
// manifestly constant-evaluated expression.
5603-
if (SemaRef.getLangOpts().SYCLAllowAllFeaturesInConstexpr &&
5604-
SemaRef.InConstexprVarInit)
5601+
if (SemaRef.InConstexprVarInit)
56055602
return SemaDiagnosticBuilder::K_Deferred;
56065603
if (SemaRef.getEmissionStatus(FD) ==
56075604
Sema::FunctionEmissionStatus::Emitted) {

clang/test/CodeGenSYCL/free_function_int_header.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ __attribute__((sycl_device))
7676

7777
template void ff_6(Agg S1, Derived S2, int);
7878

79+
constexpr int TestArrSize = 3;
80+
81+
template <int ArrSize>
82+
struct KArgWithPtrArray {
83+
int *data[ArrSize];
84+
int start[ArrSize];
85+
int end[ArrSize];
86+
constexpr int getArrSize() { return ArrSize; }
87+
};
88+
89+
template <int ArrSize>
90+
[[__sycl_detail__::add_ir_attributes_function("sycl-single-task-kernel", 0)]]
91+
void ff_7(KArgWithPtrArray<ArrSize> KArg) {
92+
for (int j = 0; j < ArrSize; j++)
93+
for (int i = KArg.start[j]; i <= KArg.end[j]; i++)
94+
KArg.data[j][i] = KArg.start[j] + KArg.end[j];
95+
}
96+
97+
template void ff_7(KArgWithPtrArray<TestArrSize> KArg);
98+
7999
// CHECK: const char* const kernel_names[] = {
80100
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_2Piii
81101
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_2Piiii
@@ -84,6 +104,7 @@ template void ff_6(Agg S1, Derived S2, int);
84104
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_3IdEvPT_S0_S0_
85105
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_410NoPointers8Pointers3Agg
86106
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_6I3Agg7DerivedEvT_T0_i
107+
// CHECK-NEXT: {{.*}}__sycl_kernel_ff_7ILi3EEv16KArgWithPtrArrayIXT_EE
87108
// CHECK-NEXT: ""
88109
// CHECK-NEXT: };
89110

@@ -124,6 +145,9 @@ template void ff_6(Agg S1, Derived S2, int);
124145
// CHECK-NEXT: { kernel_param_kind_t::kind_std_layout, 40, 32 },
125146
// CHECK-NEXT: { kernel_param_kind_t::kind_std_layout, 4, 72 },
126147

148+
// CHECK: //--- _Z18__sycl_kernel_ff_7ILi3EEv16KArgWithPtrArrayIXT_EE
149+
// CHECK-NEXT: { kernel_param_kind_t::kind_std_layout, 48, 0 },
150+
127151
// CHECK: { kernel_param_kind_t::kind_invalid, -987654321, -987654321 },
128152
// CHECK-NEXT: };
129153

@@ -249,6 +273,26 @@ template void ff_6(Agg S1, Derived S2, int);
249273
// CHECK-NEXT: static constexpr bool value = true;
250274
// CHECK-NEXT: };
251275
// CHECK-NEXT: }
276+
//
277+
// CHECK: Definition of _Z18__sycl_kernel_ff_7ILi3EEv16KArgWithPtrArrayIXT_EE as a free function kernel
278+
279+
// CHECK: Forward declarations of kernel and its argument types:
280+
// CHECK: template <int ArrSize> struct KArgWithPtrArray;
281+
//
282+
// CHECK: template <int ArrSize> void ff_7(KArgWithPtrArray<ArrSize> KArg);
283+
// CHECK-NEXT: static constexpr auto __sycl_shim8() {
284+
// CHECK-NEXT: return (void (*)(struct KArgWithPtrArray<3>))ff_7<3>;
285+
// CHECK-NEXT: }
286+
// CHECK-NEXT: namespace sycl {
287+
// CHECK-NEXT: template <>
288+
// CHECK-NEXT: struct ext::oneapi::experimental::is_kernel<__sycl_shim8()> {
289+
// CHECK-NEXT: static constexpr bool value = true;
290+
// CHECK-NEXT: };
291+
// CHECK-NEXT: template <>
292+
// CHECK-NEXT: struct ext::oneapi::experimental::is_single_task_kernel<__sycl_shim8()> {
293+
// CHECK-NEXT: static constexpr bool value = true;
294+
// CHECK-NEXT: };
295+
// CHECK-NEXT: }
252296

253297
// CHECK: #include <sycl/kernel_bundle.hpp>
254298

@@ -307,3 +351,11 @@ template void ff_6(Agg S1, Derived S2, int);
307351
// CHECK-NEXT: return sycl::detail::get_kernel_id_impl(std::string_view{"_Z18__sycl_kernel_ff_6I3Agg7DerivedEvT_T0_i"});
308352
// CHECK-NEXT: }
309353
// CHECK-NEXT: }
354+
355+
// CHECK: Definition of kernel_id of _Z18__sycl_kernel_ff_7ILi3EEv16KArgWithPtrArrayIXT_EE
356+
// CHECK-NEXT: namespace sycl {
357+
// CHECK-NEXT: template <>
358+
// CHECK-NEXT: kernel_id ext::oneapi::experimental::get_kernel_id<__sycl_shim8()>() {
359+
// CHECK-NEXT: return sycl::detail::get_kernel_id_impl(std::string_view{"_Z18__sycl_kernel_ff_7ILi3EEv16KArgWithPtrArrayIXT_EE"});
360+
// CHECK-NEXT: }
361+
// CHECK-NEXT: }

clang/test/CodeGenSYCL/free_function_kernel_params.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,33 @@ __attribute__((sycl_device))
2626
void ff_4(NoPointers S1, Pointers S2, Agg S3) {
2727
}
2828

29+
constexpr int TestArrSize = 3;
30+
31+
template <int ArrSize>
32+
struct KArgWithPtrArray {
33+
int *data[ArrSize];
34+
int start[ArrSize];
35+
int end[ArrSize];
36+
constexpr int getArrSize() { return ArrSize; }
37+
};
38+
39+
template <int ArrSize>
40+
[[__sycl_detail__::add_ir_attributes_function("sycl-single-task-kernel", 0)]]
41+
void ff_6(KArgWithPtrArray<ArrSize> KArg) {
42+
for (int j = 0; j < ArrSize; j++)
43+
for (int i = KArg.start[j]; i <= KArg.end[j]; i++)
44+
KArg.data[j][i] = KArg.start[j] + KArg.end[j];
45+
}
46+
47+
template void ff_6(KArgWithPtrArray<TestArrSize> KArg);
48+
2949
// CHECK: %struct.NoPointers = type { i32 }
3050
// CHECK: %struct.Pointers = type { ptr addrspace(4), ptr addrspace(4) }
3151
// CHECK: %struct.Agg = type { %struct.NoPointers, i32, ptr addrspace(4), %struct.Pointers }
3252
// CHECK: %struct.__generated_Pointers = type { ptr addrspace(1), ptr addrspace(1) }
3353
// CHECK: %struct.__generated_Agg = type { %struct.NoPointers, i32, ptr addrspace(1), %struct.__generated_Pointers.0 }
3454
// CHECK: %struct.__generated_Pointers.0 = type { ptr addrspace(1), ptr addrspace(1) }
55+
// CHECK: %struct.__generated_KArgWithPtrArray = type { [3 x ptr addrspace(1)], [3 x i32], [3 x i32] }
56+
// CHECK: %struct.KArgWithPtrArray = type { [3 x ptr addrspace(4)], [3 x i32], [3 x i32] }
3557
// CHECK: define dso_local spir_kernel void @{{.*}}__sycl_kernel{{.*}}(ptr noundef byval(%struct.NoPointers) align 4 %__arg_S1, ptr noundef byval(%struct.__generated_Pointers) align 8 %__arg_S2, ptr noundef byval(%struct.__generated_Agg) align 8 %__arg_S3)
58+
// CHECK: define dso_local spir_kernel void @{{.*}}__sycl_kernel_ff_6{{.*}}(ptr noundef byval(%struct.__generated_KArgWithPtrArray) align 8 %__arg_KArg)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Verify the __CUDA_ARCH__ macro has not been defined when offloading SYCL on NVPTX
2+
// RUN: %clangxx -E -dM -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -nocudalib -fno-sycl-libspirv %s 2>&1 \
3+
// RUN: | FileCheck --check-prefix=CHECK-CUDA-ARCH-MACRO %s
4+
// CHECK-CUDA-ARCH-MACRO-NOT: #define __CUDA_ARCH__ {{[0-9]+}}
5+
6+
// Verify that '-fcuda-is-device' is not supplied when offloading SYCL on NVPTX
7+
// RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -nocudalib -fno-sycl-libspirv %s 2>&1 \
8+
// RUN: | FileCheck --check-prefix=CHECK-CUDA-IS-DEVICE %s
9+
// CHECK-CUDA-IS-DEVICE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
10+
// CHECK-CUDA-IS-DEVICE-NOT: "-fcuda-is-device"
11+
// CHECK-CUDA-IS-DEVICE-SAME: "-fsycl-is-device"

0 commit comments

Comments
 (0)