Skip to content

Commit 4d6d070

Browse files
author
Georgi Mirazchiyski
committed
Merge remote-tracking branch 'upstream/sycl' into georgi/update-device-config-file-amd
2 parents ac8c1c2 + fb2fcc2 commit 4d6d070

File tree

158 files changed

+3003
-1277
lines changed

Some content is hidden

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

158 files changed

+3003
-1277
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,13 @@ jobs:
8686
image_options: -u 1001 --device=/dev/dri --privileged --cap-add SYS_ADMIN
8787
target_devices: level_zero:gpu;opencl:gpu;opencl:cpu
8888
reset_intel_gpu: true
89-
install_drivers: ${{ contains(needs.detect_changes.outputs.filters, 'drivers') }}
9089
extra_lit_opts: --param gpu-intel-gen12=True
9190
- name: E2E tests on Intel Arc A-Series Graphics
9291
runner: '["Linux", "arc"]'
9392
image: ghcr.io/intel/llvm/ubuntu2204_intel_drivers:latest
9493
image_options: -u 1001 --device=/dev/dri --privileged --cap-add SYS_ADMIN
9594
target_devices: level_zero:gpu;opencl:gpu
9695
reset_intel_gpu: true
97-
install_drivers: ${{ contains(needs.detect_changes.outputs.filters, 'drivers') }}
9896
extra_lit_opts: --param matrix-xmx8=True --param gpu-intel-dg2=True
9997
env: '{"LIT_FILTER":${{ needs.determine_arc_tests.outputs.arc_tests }} }'
10098
- name: E2E tests with dev igc on Intel Arc A-Series Graphics
@@ -103,14 +101,9 @@ jobs:
103101
image_options: -u 1001 --device=/dev/dri --privileged --cap-add SYS_ADMIN
104102
target_devices: level_zero:gpu;opencl:gpu
105103
reset_intel_gpu: true
106-
install_drivers: >-
107-
${{ contains(needs.detect_changes.outputs.filters, 'drivers') ||
108-
contains(needs.detect_changes.outputs.filters, 'devigccfg') }}
109-
use_dev_igc: ${{ contains(needs.detect_changes.outputs.filters, 'devigccfg') }}
110104
extra_lit_opts: --param matrix-xmx8=True --param gpu-intel-dg2=True
111105
env: '{"LIT_FILTER":${{ needs.determine_arc_tests.outputs.arc_tests }} }'
112-
# Run only if the PR does not have the 'ci-no-devigc' label.
113-
skip_run: ${{ contains(github.event.pull_request.labels.*.name, 'ci-no-devigc') }}
106+
use_igc_dev: true
114107

115108
uses: ./.github/workflows/sycl-linux-run-tests.yml
116109
with:
@@ -120,11 +113,13 @@ jobs:
120113
image_options: ${{ matrix.image_options }}
121114
target_devices: ${{ matrix.target_devices }}
122115
reset_intel_gpu: ${{ matrix.reset_intel_gpu }}
123-
install_drivers: ${{ matrix.install_drivers }}
124-
use_dev_igc: ${{ matrix.use_dev_igc }}
125116
extra_lit_opts: ${{ matrix.extra_lit_opts }}
126117
env: ${{ matrix.env || '{}' }}
127-
skip_run: ${{ matrix.skip_run || 'false' }}
118+
119+
install_igc_driver: ${{ contains(needs.detect_changes.outputs.filters, 'drivers') }}
120+
install_dev_igc_driver: ${{ matrix.use_igc_dev && contains(needs.detect_changes.outputs.filters, 'devigccfg') || 'false' }}
121+
# Run only if the PR does not have the 'ci-no-devigc' label.
122+
skip_run: ${{matrix.use_igc_dev && contains(github.event.pull_request.labels.*.name, 'ci-no-devigc') || 'false'}}
128123

129124
ref: ${{ github.sha }}
130125
merge_ref: ''

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ on:
6565
reset_intel_gpu:
6666
type: string
6767
required: False
68-
install_drivers:
68+
install_igc_driver:
6969
type: string
7070
required: False
71-
use_dev_igc:
71+
install_dev_igc_driver:
7272
type: string
7373
required: False
7474
env:
@@ -134,13 +134,13 @@ on:
134134
Extra options to be added to LIT_OPTS.
135135
default: ''
136136

137-
install_drivers:
137+
install_igc_driver:
138138
type: choice
139139
options:
140140
- false
141141
- true
142142

143-
use_dev_igc:
143+
install_dev_igc_driver:
144144
type: choice
145145
options:
146146
- false
@@ -193,15 +193,15 @@ jobs:
193193
run: |
194194
git -C khronos_sycl_cts submodule update --init
195195
- name: Install drivers
196-
if: inputs.install_drivers == 'true'
196+
if: inputs.install_igc_driver == 'true' || inputs.install_dev_igc_driver == 'true'
197197
env:
198198
GITHUB_TOKEN: ${{ github.token }}
199199
run: |
200-
if [ "${{ inputs.use_dev_igc }}" = "true" ]; then
200+
if [ "${{ inputs.install_dev_igc_driver }}" = "true" ]; then
201201
# If libllvm14 is already installed (dev igc docker), still return true.
202202
sudo apt-get install -yqq libllvm14 || true;
203203
fi
204-
sudo -E bash devops/scripts/install_drivers.sh llvm/devops/dependencies.json ${{ inputs.use_dev_igc == 'true' && 'llvm/devops/dependencies-igc-dev.json --use-dev-igc' || '' }} --all
204+
sudo -E bash devops/scripts/install_drivers.sh llvm/devops/dependencies.json ${{ inputs.install_dev_igc_driver == 'true' && 'llvm/devops/dependencies-igc-dev.json --use-dev-igc' || '' }} --all
205205
- name: Source OneAPI TBB vars.sh
206206
shell: bash
207207
run: |

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12358,6 +12358,8 @@ def err_bit_cast_type_size_mismatch : Error<
1235812358
"__builtin_bit_cast source size does not equal destination size (%0 vs %1)">;
1235912359

1236012360
// SYCL-specific diagnostics
12361+
def warn_sycl_incorrect_use_attribute_non_kernel_function : Warning<
12362+
"%0 attribute can only be applied to a SYCL kernel function">, InGroup<SyclStrict>;
1236112363
def warn_sycl_kernel_num_of_template_params : Warning<
1236212364
"'sycl_kernel' attribute only applies to a function template with at least"
1236312365
" two template parameters">, InGroup<IgnoredAttributes>;

clang/include/clang/Sema/SemaSYCL.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ class SemaSYCL : public SemaBase {
259259
// useful notes that shows where the kernel was called.
260260
bool DiagnosingSYCLKernel = false;
261261

262+
llvm::DenseSet<const FunctionDecl *> SYCLKernelFunctions;
263+
262264
public:
263265
SemaSYCL(Sema &S);
264266

@@ -300,6 +302,10 @@ class SemaSYCL : public SemaBase {
300302
void addSyclDeviceDecl(Decl *d) { SyclDeviceDecls.insert(d); }
301303
llvm::SetVector<Decl *> &syclDeviceDecls() { return SyclDeviceDecls; }
302304

305+
void addSYCLKernelFunction(const FunctionDecl *FD) {
306+
SYCLKernelFunctions.insert(FD);
307+
}
308+
303309
/// Lazily creates and returns SYCL integration header instance.
304310
SYCLIntegrationHeader &getSyclIntegrationHeader() {
305311
if (SyclIntHeader == nullptr)
@@ -375,6 +381,8 @@ class SemaSYCL : public SemaBase {
375381
SourceLocation Loc,
376382
DeviceDiagnosticReason Reason);
377383

384+
void performSYCLDelayedAttributesAnalaysis(const FunctionDecl *FD);
385+
378386
/// Tells whether given variable is a SYCL explicit SIMD extension's "private
379387
/// global" variable - global variable in the private address space.
380388
bool isSYCLEsimdPrivateGlobal(VarDecl *VDecl) {

clang/lib/Driver/Driver.cpp

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5564,7 +5564,7 @@ class OffloadingActionBuilder final {
55645564
SYCLDeviceLibLinked = addSYCLDeviceLibs(
55655565
TC, SYCLDeviceLibs, UseAOTLink,
55665566
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment(),
5567-
IsSYCLNativeCPU, NativeCPULib);
5567+
IsSYCLNativeCPU, NativeCPULib, BoundArch);
55685568
}
55695569
JobAction *LinkSYCLLibs =
55705570
C.MakeAction<LinkJobAction>(SYCLDeviceLibs, types::TY_LLVM_BC);
@@ -5842,7 +5842,7 @@ class OffloadingActionBuilder final {
58425842

58435843
bool addSYCLDeviceLibs(const ToolChain *TC, ActionList &DeviceLinkObjects,
58445844
bool isSpirvAOT, bool isMSVCEnv, bool isNativeCPU,
5845-
Action *&NativeCPULib) {
5845+
Action *&NativeCPULib, const char *BoundArch) {
58465846
int NumOfDeviceLibLinked = 0;
58475847
SmallVector<SmallString<128>, 4> LibLocCandidates;
58485848
SYCLInstallation.getSYCLDeviceLibPath(LibLocCandidates);
@@ -5852,14 +5852,10 @@ class OffloadingActionBuilder final {
58525852
tools::SYCL::getDeviceLibraries(C, TC->getTriple(), isSpirvAOT);
58535853

58545854
for (const auto &DeviceLib : DeviceLibraries) {
5855-
bool LibLocSelected = false;
58565855
for (const auto &LLCandidate : LibLocCandidates) {
5857-
if (LibLocSelected)
5858-
break;
58595856
SmallString<128> LibName(LLCandidate);
58605857
llvm::sys::path::append(LibName, DeviceLib);
58615858
if (llvm::sys::fs::exists(LibName)) {
5862-
58635859
// NativeCPU currently only needs libsycl-nativecpu_utils and
58645860
// libclc, so temporarily skip other device libs in invocation.
58655861
// Todo: remove once NativeCPU tests the other libraries.
@@ -5897,8 +5893,6 @@ class OffloadingActionBuilder final {
58975893
C.MakeAction<InputAction>(*InputArg, types::TY_LLVM_BC);
58985894
DeviceLinkObjects.push_back(SYCLDeviceLibsInputAction);
58995895
}
5900-
if (!LibLocSelected)
5901-
LibLocSelected = !LibLocSelected;
59025896

59035897
// The device link stage may remove symbols not referenced in the
59045898
// source code. Since libsycl-nativecpu_utils contains such symbols
@@ -5909,22 +5903,26 @@ class OffloadingActionBuilder final {
59095903
NativeCPULib = DeviceLinkObjects.back();
59105904
DeviceLinkObjects.pop_back();
59115905
}
5906+
5907+
break;
59125908
}
59135909
}
59145910
}
59155911

5916-
// For NVPTX backend we need to also link libclc and CUDA libdevice
5917-
// at the same stage that we link all of the unbundled SYCL libdevice
5918-
// objects together.
5919-
if ((TC->getTriple().isNVPTX() || isNativeCPU) && NumOfDeviceLibLinked) {
5912+
if (!NumOfDeviceLibLinked)
5913+
return false;
5914+
5915+
// For NVPTX and NativeCPU we need to also link libclc at the same stage
5916+
// that we link all of the unbundled SYCL libdevice objects together.
5917+
if (TC->getTriple().isNVPTX() || isNativeCPU) {
59205918
std::string LibSpirvFile;
59215919
if (Args.hasArg(options::OPT_fsycl_libspirv_path_EQ)) {
59225920
auto ProvidedPath =
59235921
Args.getLastArgValue(options::OPT_fsycl_libspirv_path_EQ).str();
59245922
if (llvm::sys::fs::exists(ProvidedPath))
59255923
LibSpirvFile = ProvidedPath;
59265924
} else {
5927-
SmallVector<StringRef, 8> LibraryPaths;
5925+
SmallVector<StringRef, 2> LibraryPaths;
59285926

59295927
// Expected path w/out install.
59305928
SmallString<256> WithoutInstallPath(C.getDriver().ResourceDir);
@@ -5936,22 +5934,17 @@ class OffloadingActionBuilder final {
59365934
llvm::sys::path::append(WithInstallPath, Twine("../../../share/clc"));
59375935
LibraryPaths.emplace_back(WithInstallPath.c_str());
59385936

5939-
// TODO: check if the isNVPTX() path can also use
5940-
// TC->getTripleString() so that the conditional could be removed
5941-
const std::string TrStr =
5942-
isNativeCPU ? TC->getTripleString() : "nvptx64-nvidia-cuda";
5943-
59445937
// Select remangled libclc variant
59455938
StringRef LibSpirvTargetNamePref =
59465939
TC->getAuxTriple()->isOSWindows()
59475940
? "remangled-l32-signed_char.libspirv-"
59485941
: "remangled-l64-signed_char.libspirv-";
5949-
llvm::Twine LibSpirvTargetNameTemp = LibSpirvTargetNamePref + TrStr;
5950-
llvm::Twine LibSpirvTargetName = LibSpirvTargetNameTemp + ".bc";
59515942

59525943
for (StringRef LibraryPath : LibraryPaths) {
59535944
SmallString<128> LibSpirvTargetFile(LibraryPath);
5954-
llvm::sys::path::append(LibSpirvTargetFile, LibSpirvTargetName);
5945+
llvm::sys::path::append(LibSpirvTargetFile,
5946+
LibSpirvTargetNamePref +
5947+
TC->getTripleString() + ".bc");
59555948
if (llvm::sys::fs::exists(LibSpirvTargetFile) ||
59565949
Args.hasArg(options::OPT__HASH_HASH_HASH)) {
59575950
LibSpirvFile = std::string(LibSpirvTargetFile.str());
@@ -5966,30 +5959,24 @@ class OffloadingActionBuilder final {
59665959
C.MakeAction<InputAction>(*LibClcInputArg, types::TY_LLVM_BC);
59675960
DeviceLinkObjects.push_back(SYCLLibClcInputAction);
59685961
}
5962+
}
59695963

5970-
if (isNativeCPU) {
5971-
// return here to not generate cuda actions
5972-
return NumOfDeviceLibLinked != 0;
5973-
}
5974-
5964+
// For NVPTX we also need to link with the CUDA libdevice
5965+
if (TC->getTriple().isNVPTX() && !Args.hasArg(options::OPT_nogpulib)) {
59755966
const toolchains::CudaToolChain *CudaTC =
59765967
static_cast<const toolchains::CudaToolChain *>(TC);
5977-
for (const auto &LinkInputEnum : enumerate(DeviceLinkerInputs)) {
5978-
const char *BoundArch =
5979-
SYCLTargetInfoList[LinkInputEnum.index()].BoundArch;
5980-
std::string LibDeviceFile =
5981-
CudaTC->CudaInstallation.getLibDeviceFile(BoundArch);
5982-
if (!LibDeviceFile.empty()) {
5983-
Arg *CudaDeviceLibInputArg =
5984-
MakeInputArg(Args, C.getDriver().getOpts(),
5985-
Args.MakeArgString(LibDeviceFile));
5986-
auto *SYCLDeviceLibInputAction = C.MakeAction<InputAction>(
5987-
*CudaDeviceLibInputArg, types::TY_LLVM_BC);
5988-
DeviceLinkObjects.push_back(SYCLDeviceLibInputAction);
5989-
}
5968+
std::string LibDeviceFile =
5969+
CudaTC->CudaInstallation.getLibDeviceFile(BoundArch);
5970+
if (!LibDeviceFile.empty()) {
5971+
Arg *CudaDeviceLibInputArg = MakeInputArg(
5972+
Args, C.getDriver().getOpts(), Args.MakeArgString(LibDeviceFile));
5973+
auto *SYCLDeviceLibInputAction = C.MakeAction<InputAction>(
5974+
*CudaDeviceLibInputArg, types::TY_LLVM_BC);
5975+
DeviceLinkObjects.push_back(SYCLDeviceLibInputAction);
59905976
}
59915977
}
5992-
return NumOfDeviceLibLinked != 0;
5978+
5979+
return true;
59935980
}
59945981

59955982
void appendLinkDependences(OffloadAction::DeviceDependences &DA) override {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10115,12 +10115,12 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1011510115
ArgStringList WrapperArgs;
1011610116

1011710117
const auto &WrapperJob = *llvm::dyn_cast<OffloadWrapperJobAction>(&JA);
10118-
bool LlcCompileEnabled = WrapperJob.getCompileStep();
10118+
bool WrapperCompileEnabled = WrapperJob.getCompileStep();
1011910119
SmallString<128> OutOpt("-o=");
1012010120
std::string OutTmpName = C.getDriver().GetTemporaryPath("wrapper", "bc");
1012110121
const char *WrapperFileName =
1012210122
C.addTempFile(C.getArgs().MakeArgString(OutTmpName));
10123-
OutOpt += LlcCompileEnabled ? WrapperFileName : Output.getFilename();
10123+
OutOpt += WrapperCompileEnabled ? WrapperFileName : Output.getFilename();
1012410124
WrapperArgs.push_back(C.getArgs().MakeArgString(OutOpt));
1012510125

1012610126
SmallString<128> HostTripleOpt("-host=");
@@ -10218,28 +10218,30 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1021810218
WrapperArgs, std::nullopt);
1021910219
C.addCommand(std::move(Cmd));
1022010220

10221-
if (LlcCompileEnabled) {
10222-
// Construct llc command.
10223-
// The output is an object file
10224-
ArgStringList LlcArgs{"-filetype=obj", "-o", Output.getFilename(),
10225-
WrapperFileName};
10221+
if (WrapperCompileEnabled) {
10222+
// TODO Use TC.SelectTool().
10223+
ArgStringList ClangArgs{
10224+
TCArgs.MakeArgString("--target=" + TC.getAuxTriple()->str()), "-c",
10225+
"-o", Output.getFilename(), WrapperFileName};
1022610226
llvm::Reloc::Model RelocationModel;
1022710227
unsigned PICLevel;
1022810228
bool IsPIE;
1022910229
std::tie(RelocationModel, PICLevel, IsPIE) =
1023010230
ParsePICArgs(getToolChain(), TCArgs);
1023110231
if (PICLevel > 0 || TCArgs.hasArg(options::OPT_shared)) {
10232-
LlcArgs.push_back("-relocation-model=pic");
10232+
if (!TC.getAuxTriple()->isOSWindows())
10233+
ClangArgs.push_back("-fPIC");
1023310234
}
1023410235
if (Arg *A = C.getArgs().getLastArg(options::OPT_mcmodel_EQ))
10235-
LlcArgs.push_back(
10236-
TCArgs.MakeArgString(Twine("--code-model=") + A->getValue()));
10237-
10238-
SmallString<128> LlcPath(C.getDriver().Dir);
10239-
llvm::sys::path::append(LlcPath, "llc");
10240-
const char *Llc = C.getArgs().MakeArgString(LlcPath);
10241-
C.addCommand(std::make_unique<Command>(
10242-
JA, *this, ResponseFileSupport::None(), Llc, LlcArgs, std::nullopt));
10236+
ClangArgs.push_back(
10237+
TCArgs.MakeArgString(Twine("-mcmodel=") + A->getValue()));
10238+
10239+
SmallString<128> ClangPath(C.getDriver().Dir);
10240+
llvm::sys::path::append(ClangPath, "clang");
10241+
const char *Clang = C.getArgs().MakeArgString(ClangPath);
10242+
C.addCommand(std::make_unique<Command>(JA, *this,
10243+
ResponseFileSupport::None(), Clang,
10244+
ClangArgs, std::nullopt));
1024310245
}
1024410246
return;
1024510247
} // end of SYCL flavor of offload wrapper command creation

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -713,21 +713,6 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
713713
return OutputFileName;
714714
}
715715

716-
void SYCL::Linker::constructLlcCommand(Compilation &C, const JobAction &JA,
717-
const InputInfo &Output,
718-
const char *InputFileName) const {
719-
// Construct llc command.
720-
// The output is an object file.
721-
ArgStringList LlcArgs{"-filetype=obj", "-o", Output.getFilename(),
722-
InputFileName};
723-
SmallString<128> LlcPath(C.getDriver().Dir);
724-
llvm::sys::path::append(LlcPath, "llc");
725-
const char *Llc = C.getArgs().MakeArgString(LlcPath);
726-
C.addCommand(std::make_unique<Command>(JA, *this,
727-
ResponseFileSupport::AtFileUTF8(), Llc,
728-
LlcArgs, std::nullopt));
729-
}
730-
731716
// For SYCL the inputs of the linker job are SPIR-V binaries and output is
732717
// a single SPIR-V binary. Input can also be bitcode when specified by
733718
// the user.

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
7474
llvm::StringRef SubArchName,
7575
llvm::StringRef OutputFilePrefix,
7676
const InputInfoList &InputFiles) const;
77-
void constructLlcCommand(Compilation &C, const JobAction &JA,
78-
const InputInfo &Output,
79-
const char *InputFile) const;
8077
};
8178

8279
/// Directly call FPGA Compiler and Linker

clang/lib/Sema/Sema.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,6 +1909,10 @@ class DeferredDiagnosticsEmitter
19091909
void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
19101910
auto &Done = DoneMap[InOMPDeviceContext > 0 ? 1 : 0];
19111911
FunctionDecl *Caller = UsePath.empty() ? nullptr : UsePath.back();
1912+
1913+
if (!Caller && S.LangOpts.SYCLIsDevice)
1914+
S.SYCL().performSYCLDelayedAttributesAnalaysis(FD);
1915+
19121916
if ((!ShouldEmitRootNode && !S.getLangOpts().OpenMP && !Caller) ||
19131917
S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD))
19141918
return;

0 commit comments

Comments
 (0)