Skip to content

Commit 450b238

Browse files
committed
Merge remote-tracking branch 'origin/sycl' into llvmspirv_pulldown
2 parents ff9ee8c + e06e482 commit 450b238

File tree

428 files changed

+10599
-13797
lines changed

Some content is hidden

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

428 files changed

+10599
-13797
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ jobs:
300300
testing_mode: build-only
301301
target_devices: all
302302
binaries_artifact: ${{ inputs.e2e_binaries_artifact }}
303-
cxx_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
303+
sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
304304
extra_lit_opts: --param sycl_build_targets="spir;nvidia;amd"
305305

306306
- name: Remove E2E tests before spirv-backend run
@@ -315,5 +315,5 @@ jobs:
315315
testing_mode: build-only
316316
target_devices: all
317317
binaries_artifact: ${{ inputs.e2e_binaries_artifact }}_spirv_backend
318-
cxx_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
318+
sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
319319
extra_lit_opts: --param spirv-backend=True

.github/workflows/sycl-nightly.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ jobs:
163163
with:
164164
name: Intel GEN12 Graphics with Level Zero
165165
runner: '["Windows","gen12"]'
166+
target_devices: level_zero:gpu
166167
sycl_toolchain_archive: ${{ needs.build-win.outputs.artifact_archive_name }}
167168

168169
cuda-aws-start:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
&& github.repository == 'intel/llvm'
103103
uses: ./.github/workflows/sycl-windows-build.yml
104104
with:
105-
compiler: icx
105+
cxx: icx
106106
build_configure_extra_args: -DCMAKE_C_FLAGS="/fp:precise /clang:-Wno-nonportable-include-path /clang:-Wno-cast-function-type-mismatch" -DCMAKE_CXX_FLAGS="/fp:precise /clang:-Wno-nonportable-include-path /clang:-Wno-cast-function-type-mismatch" -DCMAKE_EXE_LINKER_FLAGS=/manifest:no -DCMAKE_MODULE_LINKER_FLAGS=/manifest:no -DCMAKE_SHARED_LINKER_FLAGS=/manifest:no
107107
build_cache_suffix: icx
108108

@@ -119,7 +119,7 @@ jobs:
119119
runner: '["Windows","gen12"]'
120120
target_devices: "level_zero:gpu"
121121
sycl_toolchain_archive: ${{ needs.build-win.outputs.artifact_archive_name }}
122-
compiler: icx
122+
cxx: icx
123123

124124
macos_default:
125125
name: macOS

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ on:
2828
e2e_binaries_artifact:
2929
type: string
3030
required: false
31-
compiler:
31+
cxx:
3232
type: string
3333
required: false
3434
default: "cl"
@@ -67,7 +67,7 @@ on:
6767
type: choice
6868
options:
6969
- 3
70-
compiler:
70+
cxx:
7171
type: choice
7272
options:
7373
- cl
@@ -104,7 +104,7 @@ jobs:
104104
arch: amd64
105105
- name: Setup oneAPI env
106106
uses: ./devops/actions/setup_windows_oneapi_env
107-
if: ${{ always() && !cancelled() && inputs.compiler == 'icx' }}
107+
if: ${{ always() && !cancelled() && inputs.cxx == 'icx' }}
108108
- name: Set env
109109
run: |
110110
git config --system core.longpaths true
@@ -132,8 +132,8 @@ jobs:
132132
IF NOT EXIST D:\github\_work\cache\${{inputs.build_cache_suffix}} MKDIR D:\github\_work\cache\${{inputs.build_cache_suffix}}
133133
python.exe src/buildbot/configure.py -o build ^
134134
--ci-defaults %ARGS% ^
135-
"-DCMAKE_C_COMPILER=${{inputs.compiler}}" ^
136-
"-DCMAKE_CXX_COMPILER=${{inputs.compiler}}" ^
135+
"-DCMAKE_C_COMPILER=${{inputs.cxx}}" ^
136+
"-DCMAKE_CXX_COMPILER=${{inputs.cxx}}" ^
137137
"-DCMAKE_INSTALL_PREFIX=%GITHUB_WORKSPACE%\install" ^
138138
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^
139139
-DCMAKE_C_COMPILER_LAUNCHER=ccache ^
@@ -244,6 +244,7 @@ jobs:
244244
target_devices: all
245245
binaries_artifact: ${{ inputs.e2e_binaries_artifact }}
246246
extra_lit_opts: --param sycl_build_targets="spir"
247+
cxx: ${{ inputs.cxx }}
247248

248249
- name: Detect hung tests
249250
if: always()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ on:
5858
default: '{}'
5959
required: False
6060

61-
compiler:
61+
cxx:
6262
type: string
6363
required: false
6464
default: "cl"
@@ -117,7 +117,7 @@ jobs:
117117
arch: amd64
118118
- name: Setup oneAPI env
119119
uses: ./devops/actions/setup_windows_oneapi_env
120-
if: ${{ always() && !cancelled() && inputs.compiler == 'icx' }}
120+
if: ${{ always() && !cancelled() && inputs.cxx == 'icx' }}
121121
- name: Set env
122122
run: |
123123
git config --system core.longpaths true
@@ -164,7 +164,7 @@ jobs:
164164
target_devices: ${{ inputs.target_devices }}
165165
extra_lit_opts: ${{ inputs.extra_lit_opts }}
166166
retention-days: ${{ inputs.artifact_retention_days }}
167-
compiler: ${{ inputs.compiler }}
167+
cxx: ${{ inputs.cxx }}
168168

169169
- name: Run SYCL CTS Tests
170170
if: inputs.tests_selector == 'cts'

.github/workflows/ur-build-hw.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ on:
1313
runner_name:
1414
required: true
1515
type: string
16-
platform:
17-
description: "Platform string, `UR_CTS_ADAPTER_PLATFORM` will be set to this."
18-
required: false
19-
type: string
20-
default: ""
2116
static_loader:
2217
required: false
2318
type: string
@@ -46,11 +41,6 @@ on:
4641
runner_name:
4742
required: true
4843
type: string
49-
platform:
50-
description: "Platform string, `UR_CTS_ADAPTER_PLATFORM` will be set to this."
51-
required: false
52-
type: string
53-
default: ""
5444
static_loader:
5545
required: false
5646
type: string
@@ -89,7 +79,6 @@ jobs:
8979
{
9080
name: "${{inputs.adapter_name}}",
9181
other_name: "${{inputs.other_adapter_name}}",
92-
platform: "${{inputs.platform}}",
9382
static_Loader: "${{inputs.static_loader}}",
9483
static_adapter: "${{inputs.static_loader}}"
9584
}
@@ -105,7 +94,6 @@ jobs:
10594
steps:
10695
# TODO:
10796
# - investigate if DUR_CONFORMANCE_AMD_ARCH could be removed
108-
# - find better way to handle platform param (e.g. "Intel(R) OpenCL" -> "opencl")
10997
# - switch to Ninja generator in CMake
11098
# - downloading DPC++ should be integrated somehow; most likely use nightly release.
11199
#
@@ -184,7 +172,7 @@ jobs:
184172
- name: Test adapters
185173
env:
186174
ZE_ENABLE_LOADER_DEBUG_TRACE: 1
187-
run: env UR_CTS_ADAPTER_PLATFORM="${{matrix.adapter.platform}}" ctest -C ${{matrix.build_type}} --test-dir build --output-on-failure -L "conformance" --timeout 600 -VV
175+
run: ctest -C ${{matrix.build_type}} --test-dir build --output-on-failure -L "conformance" --timeout 600 -VV
188176

189177
- name: Get information about platform
190178
if: ${{ always() }}

.github/workflows/ur-precommit.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,10 @@ jobs:
7777
image_options: -u 1001 --privileged --cap-add SYS_ADMIN --gpus all
7878
- name: OPENCL
7979
runner: UR_OPENCL
80-
platform: "Intel(R) OpenCL"
8180
docker_image: "ghcr.io/intel/llvm/ubuntu2204_build:latest"
8281
image_options: -u 1001 --device=/dev/dri --device=/dev/kfd --privileged --cap-add SYS_ADMIN
8382
- name: OPENCL
8483
runner: UR_OPENCL
85-
platform: "OPENCL:Intel(R) OpenCL"
8684
other_adapter: NATIVE_CPU
8785
docker_image: "ghcr.io/intel/llvm/ubuntu2204_build:latest"
8886
image_options: -u 1001 --device=/dev/dri --device=/dev/kfd --privileged --cap-add SYS_ADMIN
@@ -96,7 +94,6 @@ jobs:
9694
runner_name: ${{ matrix.runner }}
9795
static_loader: ${{ matrix.static || 'OFF' }}
9896
static_adapter: ${{ matrix.static || 'OFF' }}
99-
platform: ${{ matrix.platform || '' }}
10097
other_adapter_name: ${{ matrix.other_adapter || '' }}
10198
docker_image: ${{ matrix.docker_image || 'ghcr.io/intel/llvm/ubuntu2404_intel_drivers:alldeps'}}
10299
image_options: ${{ matrix.image_options || '' }}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12865,8 +12865,13 @@ def err_registered_kernels_name_already_registered : Error<
1286512865
"free function kernel has already been registered with '%0'; cannot register with '%1'">;
1286612866
def err_not_sycl_free_function : Error<
1286712867
"attempting to register a function that is not a SYCL free function as '%0'">;
12868-
def err_free_function_variadic_args: Error<
12868+
def err_free_function_with_default_arg : Error<
12869+
"a function with a default argument value cannot be used to define SYCL free function kernel">;
12870+
def err_free_function_variadic_args : Error<
1286912871
"free function kernel cannot be a variadic function">;
12872+
def err_free_function_return_type : Error<
12873+
"SYCL free function kernel should have return type 'void'">;
12874+
1287012875

1287112876
// SYCL kernel entry point diagnostics
1287212877
def err_sycl_entry_point_invalid : Error<

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7300,6 +7300,8 @@ defm sycl_allow_device_image_dependencies: BoolOptionWithoutMarshalling<"f", "sy
73007300
def fsycl_dump_device_code_EQ : Joined<["-"], "fsycl-dump-device-code=">,
73017301
Flags<[NoXarchOption]>,
73027302
HelpText<"Dump device code into the user provided directory.">;
7303+
def fsyclbin : Flag<["-"], "fsyclbin">,
7304+
HelpText<"Create a SYCLBIN file">;
73037305
} // let Group = sycl_Group
73047306

73057307
// FIXME: -fsycl-explicit-simd is deprecated. remove it when support is dropped.

clang/lib/Driver/Driver.cpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,9 +1226,11 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
12261226
// We need to generate a SYCL toolchain if the user specified -fsycl.
12271227
// If -fsycl is supplied without any of these we will assume SPIR-V.
12281228
// Use of -fsycl-device-only overrides -fsycl.
1229+
// Use of -fsyclbin enables SYCL device compilation.
12291230
bool IsSYCL = C.getInputArgs().hasFlag(options::OPT_fsycl,
12301231
options::OPT_fno_sycl, false) ||
1231-
C.getInputArgs().hasArg(options::OPT_fsycl_device_only);
1232+
C.getInputArgs().hasArgNoClaim(options::OPT_fsycl_device_only,
1233+
options::OPT_fsyclbin);
12321234

12331235
auto argSYCLIncompatible = [&](OptSpecifier OptId) {
12341236
if (!IsSYCL)
@@ -3468,7 +3470,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
34683470
Arg *InputTypeArg = nullptr;
34693471
bool IsSYCL =
34703472
Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false) ||
3471-
Args.hasArg(options::OPT_fsycl_device_only);
3473+
Args.hasArgNoClaim(options::OPT_fsycl_device_only, options::OPT_fsyclbin);
34723474

34733475
// The last /TC or /TP option sets the input type to C or C++ globally.
34743476
if (Arg *TCTP = Args.getLastArgNoClaim(options::OPT__SLASH_TC,
@@ -7955,6 +7957,19 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
79557957
C.MakeAction<LinkJobAction>(OffloadActions, types::TY_HIP_FATBIN);
79567958
DDep.add(*FatbinAction, *C.getSingleOffloadToolChain<Action::OFK_HIP>(),
79577959
nullptr, Action::OFK_HIP);
7960+
} else if (C.isOffloadingHostKind(Action::OFK_SYCL) &&
7961+
Args.hasArg(options::OPT_fsyclbin)) {
7962+
// With '-fsyclbin', package all the offloading actions into a single output
7963+
// that is sent to the clang-linker-wrapper.
7964+
Action *PackagerAction =
7965+
C.MakeAction<OffloadPackagerJobAction>(OffloadActions, types::TY_Image);
7966+
ActionList PackagerActions;
7967+
PackagerActions.push_back(PackagerAction);
7968+
Action *LinkAction =
7969+
C.MakeAction<LinkerWrapperJobAction>(PackagerActions, types::TY_Image);
7970+
DDep.add(*LinkAction, *C.getSingleOffloadToolChain<Action::OFK_Host>(),
7971+
nullptr, C.getActiveOffloadKinds());
7972+
return C.MakeAction<OffloadAction>(DDep, types::TY_Nothing);
79587973
} else {
79597974
// Package all the offloading actions into a single output that can be
79607975
// embedded in the host and linked.
@@ -9365,8 +9380,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
93659380
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
93669381
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
93679382
return C.addResultFile(FinalOutput->getValue(), &JA);
9368-
// Output to destination for -fsycl-device-only and Windows -o
9369-
if (offloadDeviceOnly() && JA.getOffloadingDeviceKind() == Action::OFK_SYCL)
9383+
// Output to destination for -fsycl-device-only/-fsyclbin and Windows -o
9384+
if ((offloadDeviceOnly() ||
9385+
C.getArgs().hasArgNoClaim(options::OPT_fsyclbin)) &&
9386+
JA.getOffloadingDeviceKind() == Action::OFK_SYCL)
93709387
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_o))
93719388
return C.addResultFile(FinalOutput->getValue(), &JA);
93729389
}
@@ -9535,6 +9552,20 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
95359552
else
95369553
BaseName = llvm::sys::path::filename(BasePath);
95379554

9555+
// When compiling with -fsyclbin, maintain a simple output file name for the
9556+
// resulting image. A '.syclbin' extension is used to represent the resulting
9557+
// output file.
9558+
if (JA.getOffloadingDeviceKind() == Action::OFK_SYCL &&
9559+
C.getArgs().hasArgNoClaim(options::OPT_fsyclbin) &&
9560+
JA.getType() == types::TY_Image) {
9561+
SmallString<128> SYCLBinOutput(getDefaultImageName());
9562+
if (IsCLMode())
9563+
// Use BaseName for the syclbin output name.
9564+
SYCLBinOutput = BaseName;
9565+
llvm::sys::path::replace_extension(SYCLBinOutput, ".syclbin");
9566+
return C.addResultFile(C.getArgs().MakeArgString(SYCLBinOutput), &JA);
9567+
}
9568+
95389569
// Determine what the derived output name should be.
95399570
const char *NamedOutput;
95409571

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11499,6 +11499,9 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1149911499
CmdArgs.push_back(
1150011500
Args.MakeArgString("--sycl-target-link-options=" + LinkOptString));
1150111501
}
11502+
// Add option to enable creating of the .syclbin file.
11503+
if (Args.hasArg(options::OPT_fsyclbin))
11504+
CmdArgs.push_back(Args.MakeArgString("--syclbin"));
1150211505
}
1150311506

1150411507
// Construct the link job so we can wrap around it.

clang/lib/Sema/SPIRVBuiltins.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
850850
def : SPVBuiltin<"GenericCastToPtrExplicit", [PointerType<Char, AS>, PointerType<Char, GenericAS>], Attr.Const>;
851851
}
852852

853-
foreach Ty = [Void, ConstType<Void>, VolatileType<Void>, VolatileType<ConstType<Void>>] in {
853+
foreach Ty = [Void, ConstType<Void>] in {
854854
def : SPVBuiltin<"GenericCastToPtrExplicit_ToGlobal", [PointerType<Ty, GlobalAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
855855
def : SPVBuiltin<"GenericCastToPtrExplicit_ToLocal", [PointerType<Ty, LocalAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
856856
def : SPVBuiltin<"GenericCastToPtrExplicit_ToPrivate", [PointerType<Ty, PrivateAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,21 +1159,13 @@ static target getAccessTarget(QualType FieldTy,
11591159
AccTy->getTemplateArgs()[3].getAsIntegral().getExtValue());
11601160
}
11611161

1162-
// FIXME: Free functions must have void return type and be declared at file
1163-
// scope, outside any namespaces.
11641162
bool SemaSYCL::isFreeFunction(const FunctionDecl *FD) {
11651163
for (auto *IRAttr : FD->specific_attrs<SYCLAddIRAttributesFunctionAttr>()) {
11661164
SmallVector<std::pair<std::string, std::string>, 4> NameValuePairs =
11671165
IRAttr->getAttributeNameValuePairs(getASTContext());
11681166
for (const auto &NameValuePair : NameValuePairs) {
11691167
if (NameValuePair.first == "sycl-nd-range-kernel" ||
11701168
NameValuePair.first == "sycl-single-task-kernel") {
1171-
if (!FD->getReturnType()->isVoidType()) {
1172-
llvm::report_fatal_error(
1173-
"Only functions at file scope with void return "
1174-
"type are permitted as free functions");
1175-
return false;
1176-
}
11771169
return true;
11781170
}
11791171
}
@@ -5791,12 +5783,29 @@ void SemaSYCL::MarkDevices() {
57915783
}
57925784
}
57935785

5786+
static bool CheckFreeFunctionDiagnostics(Sema &S, FunctionDecl *FD) {
5787+
if (FD->isVariadic()) {
5788+
return S.Diag(FD->getLocation(), diag::err_free_function_variadic_args);
5789+
}
5790+
5791+
if (!FD->getReturnType()->isVoidType()) {
5792+
return S.Diag(FD->getLocation(), diag::err_free_function_return_type);
5793+
}
5794+
5795+
for (ParmVarDecl *Param : FD->parameters()) {
5796+
if (Param->hasDefaultArg()) {
5797+
return S.Diag(Param->getLocation(),
5798+
diag::err_free_function_with_default_arg)
5799+
<< Param->getSourceRange();
5800+
}
5801+
}
5802+
return false;
5803+
}
5804+
57945805
void SemaSYCL::ProcessFreeFunction(FunctionDecl *FD) {
57955806
if (isFreeFunction(FD)) {
5796-
if (FD->isVariadic()) {
5797-
Diag(FD->getLocation(), diag::err_free_function_variadic_args);
5807+
if (CheckFreeFunctionDiagnostics(SemaRef, FD))
57985808
return;
5799-
}
58005809
SyclKernelDecompMarker DecompMarker(*this);
58015810
SyclKernelFieldChecker FieldChecker(*this);
58025811
SyclKernelUnionChecker UnionChecker(*this);

0 commit comments

Comments
 (0)