Skip to content

Commit 5a96c50

Browse files
committed
Merge remote-tracking branch 'intel_llvm/sycl' into llvmspirv_pulldown
2 parents 418a6d6 + 881724f commit 5a96c50

Some content is hidden

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

44 files changed

+784
-386
lines changed

buildbot/dependency.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ocl_cpu_rt_ver=2021.12.6.0.19
44
# https://github.com/intel/llvm/releases/download/2021-WW26/win-oclcpuexp-2021.12.6.0.19_rel.zip
55
ocl_cpu_rt_ver_win=2021.12.6.0.19
66
# Same GPU driver supports Level Zero and OpenCL
7-
# https://github.com/intel/compute-runtime/releases/tag/21.24.20098
8-
ocl_gpu_rt_ver=21.24.20098
7+
# https://github.com/intel/compute-runtime/releases/tag/21.26.20194
8+
ocl_gpu_rt_ver=21.26.20194
99
# Same GPU driver supports Level Zero and OpenCL
1010
# https://downloadmirror.intel.com/30381/a08/igfx_win10_100.9466.zip
1111
ocl_gpu_rt_ver_win=27.20.100.9466
@@ -30,7 +30,7 @@ ocloc_ver_win=27.20.100.9168
3030
[DRIVER VERSIONS]
3131
cpu_driver_lin=2021.12.6.0.19
3232
cpu_driver_win=2021.12.6.0.19
33-
gpu_driver_lin=21.24.20098
33+
gpu_driver_lin=21.26.20194
3434
gpu_driver_win=27.20.100.9466
3535
fpga_driver_lin=2021.12.6.0.19
3636
fpga_driver_win=2021.12.6.0.19

clang/include/clang/Driver/Job.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct ResponseFileSupport {
106106
class Command {
107107
public:
108108
using ErrorCodeDiagMapTy = llvm::DenseMap<int, std::string>;
109+
using ErrorCodeExitMapTy = llvm::DenseMap<int, bool>;
109110

110111
private:
111112
/// Source - The action which caused the creation of this job.
@@ -132,6 +133,11 @@ class Command {
132133
/// "invalid input" error can be ruled out
133134
ErrorCodeDiagMapTy ErrorCodeDiagMap;
134135

136+
/// Similar to the container for the diagnostic messages, this container
137+
/// is used to signify if the toolchain should error and exit right away
138+
/// or if we should continue compilation.
139+
ErrorCodeExitMapTy ErrorCodeExitMap;
140+
135141
/// The list of program arguments (not including the implicit first
136142
/// argument, which will be the executable).
137143
llvm::opt::ArgStringList Arguments;
@@ -198,11 +204,19 @@ class Command {
198204
/// returned by the command
199205
void addDiagForErrorCode(int ErrorCode, StringRef CustomDiag);
200206

207+
/// Store if the compilation should exit upon a particular error code
208+
/// returned by the command
209+
void addExitForErrorCode(int ErrorCode, bool Exit);
210+
201211
/// Get the custom driver diagnostic message for a particular error code
202212
/// if such was stored. Returns an empty string if no diagnostic message
203213
/// was found for the given error code.
204214
StringRef getDiagForErrorCode(int ErrorCode) const;
205215

216+
/// Will the tool exit when a particular error code is encountered. Returns
217+
/// true if not set (always exit)
218+
bool getWillExitForErrorCode(int ErrorCode) const;
219+
206220
/// getSource - Return the Action which caused the creation of this job.
207221
const Action &getSource() const { return Source; }
208222

clang/include/clang/Driver/Options.td

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ defvar hip = LangOpts<"HIP">;
470470
defvar gnu_mode = LangOpts<"GNUMode">;
471471
defvar asm_preprocessor = LangOpts<"AsmPreprocessor">;
472472
defvar cpp_modules = LangOpts<"CPlusPlusModules">;
473+
defvar sycl_ver = LangOpts<"SYCLVersion">;
473474

474475
defvar std = !strconcat("LangStandard::getLangStandardForKind(", lang_std.KeyPath, ")");
475476

@@ -2606,9 +2607,14 @@ def fsycl_link_EQ : Joined<["-"], "fsycl-link=">,
26062607
def fsycl_link : Flag<["-"], "fsycl-link">, Alias<fsycl_link_EQ>,
26072608
AliasArgs<["early"]>, Flags<[CC1Option, CoreOption]>,
26082609
HelpText<"Generate partially linked device object to be used with the host link">;
2609-
def fsycl_unnamed_lambda : Flag<["-"], "fsycl-unnamed-lambda">,
2610-
Flags<[CC1Option, CoreOption]>, HelpText<"Allow unnamed SYCL lambda kernels">,
2611-
MarshallingInfoFlag<LangOpts<"SYCLUnnamedLambda">>;
2610+
defm sycl_unnamed_lambda
2611+
: BoolFOption<
2612+
"sycl-unnamed-lambda", LangOpts<"SYCLUnnamedLambda">,
2613+
Default<!strconcat(
2614+
sycl_ver.KeyPath,
2615+
" >= clang::LangOptions::SYCLMajorVersion::SYCL_2020")>,
2616+
PosFlag<SetTrue, [], "Allow">, NegFlag<SetFalse, [], "Disallow">,
2617+
BothFlags<[CC1Option, CoreOption], " unnamed SYCL lambda kernels">>;
26122618
def fsycl_help_EQ : Joined<["-"], "fsycl-help=">,
26132619
Flags<[NoXarchOption, CoreOption]>, HelpText<"Emit help information from the "
26142620
"related offline compilation tool. Valid values: all, fpga, gen, x86_64.">,
@@ -5915,9 +5921,6 @@ def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>,
59155921
Flags<[CC1Option, NoArgumentUnused, CoreOption]>,
59165922
HelpText<"SYCL language standard to compile for.">,
59175923
Values<"2020,2017,121,1.2.1,sycl-1.2.1">,
5918-
NormalizedValues<["SYCL_2020", "SYCL_2017", "SYCL_2017", "SYCL_2017", "SYCL_2017"]>,
5919-
NormalizedValuesScope<"LangOptions">,
5920-
MarshallingInfoEnum<LangOpts<"SYCLVersion">, "SYCL_None">,
59215924
ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>;
59225925

59235926
def fsycl_default_sub_group_size

clang/include/clang/Sema/Sema.h

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class SYCLIntegrationHeader {
323323
};
324324

325325
public:
326-
SYCLIntegrationHeader(bool UnnamedLambdaSupport, Sema &S);
326+
SYCLIntegrationHeader(Sema &S);
327327

328328
/// Emits contents of the header into given stream.
329329
void emit(raw_ostream &Out);
@@ -335,8 +335,8 @@ class SYCLIntegrationHeader {
335335
/// Signals that subsequent parameter descriptor additions will go to
336336
/// the kernel with given name. Starts new kernel invocation descriptor.
337337
void startKernel(StringRef KernelName, QualType KernelNameType,
338-
StringRef KernelStableName, SourceLocation Loc,
339-
bool IsESIMD);
338+
StringRef KernelStableName, SourceLocation Loc, bool IsESIMD,
339+
bool IsUnnamedKernel);
340340

341341
/// Adds a kernel parameter descriptor to current kernel invocation
342342
/// descriptor.
@@ -376,10 +376,10 @@ class SYCLIntegrationHeader {
376376
// there are four free functions the kernel may call (this_id, this_item,
377377
// this_nd_item, this_group)
378378
struct KernelCallsSYCLFreeFunction {
379-
bool CallsThisId;
380-
bool CallsThisItem;
381-
bool CallsThisNDItem;
382-
bool CallsThisGroup;
379+
bool CallsThisId = false;
380+
bool CallsThisItem = false;
381+
bool CallsThisNDItem = false;
382+
bool CallsThisGroup = false;
383383
};
384384

385385
// Kernel invocation descriptor
@@ -405,7 +405,15 @@ class SYCLIntegrationHeader {
405405
// this_id(), etc)
406406
KernelCallsSYCLFreeFunction FreeFunctionCalls;
407407

408-
KernelDesc() = default;
408+
// If we are in unnamed kernel/lambda mode AND this is one that the user
409+
// hasn't provided an explicit name for.
410+
bool IsUnnamedKernel;
411+
412+
KernelDesc(StringRef Name, QualType NameType, StringRef StableName,
413+
SourceLocation KernelLoc, bool IsESIMD, bool IsUnnamedKernel)
414+
: Name(Name), NameType(NameType), StableName(StableName),
415+
KernelLocation(KernelLoc), IsESIMDKernel(IsESIMD),
416+
IsUnnamedKernel(IsUnnamedKernel) {}
409417
};
410418

411419
/// Returns the latest invocation descriptor started by
@@ -427,9 +435,6 @@ class SYCLIntegrationHeader {
427435
/// integration header emission time.
428436
llvm::SmallVector<SpecConstID, 4> SpecConsts;
429437

430-
/// Whether header is generated with unnamed lambda support
431-
bool UnnamedLambdaSupport;
432-
433438
Sema &S;
434439
};
435440

@@ -13296,8 +13301,7 @@ class Sema final {
1329613301
/// Lazily creates and returns SYCL integration header instance.
1329713302
SYCLIntegrationHeader &getSyclIntegrationHeader() {
1329813303
if (SyclIntHeader == nullptr)
13299-
SyclIntHeader = std::make_unique<SYCLIntegrationHeader>(
13300-
getLangOpts().SYCLUnnamedLambda, *this);
13304+
SyclIntHeader = std::make_unique<SYCLIntegrationHeader>(*this);
1330113305
return *SyclIntHeader.get();
1330213306
}
1330313307

clang/lib/Driver/Compilation.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ static bool ActionFailed(const Action *A,
249249
if (FailingCommands.empty())
250250
return false;
251251

252+
for (const auto &CI : FailingCommands)
253+
if (!CI.second->getWillExitForErrorCode(CI.first))
254+
return false;
255+
252256
// CUDA/HIP/SYCL can have the same input source code compiled multiple times
253257
// so do not compile again if there are already failures. It is OK to abort
254258
// the CUDA pipeline on errors.
@@ -285,7 +289,9 @@ void Compilation::ExecuteJobs(const JobList &Jobs,
285289
if (int Res = ExecuteCommand(Job, FailingCommand)) {
286290
FailingCommands.push_back(std::make_pair(Res, FailingCommand));
287291
// Bail as soon as one command fails in cl driver mode.
288-
if (TheDriver.IsCLMode())
292+
// Do not bail when the tool is setup to allow for continuation upon
293+
// failure.
294+
if (TheDriver.IsCLMode() && FailingCommand->getWillExitForErrorCode(Res))
289295
return;
290296
}
291297
}

clang/lib/Driver/Job.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,24 @@ void Command::addDiagForErrorCode(int ErrorCode, StringRef CustomDiag) {
162162
ErrorCodeDiagMap[ErrorCode] = CustomDiag.str();
163163
}
164164

165+
void Command::addExitForErrorCode(int ErrorCode, bool Exit) {
166+
ErrorCodeExitMap[ErrorCode] = Exit;
167+
}
168+
165169
StringRef Command::getDiagForErrorCode(int ErrorCode) const {
166170
auto ErrorCodeDiagIt = ErrorCodeDiagMap.find(ErrorCode);
167171
if (ErrorCodeDiagIt != ErrorCodeDiagMap.end())
168172
return ErrorCodeDiagIt->second;
169173
return StringRef();
170174
}
171175

176+
bool Command::getWillExitForErrorCode(int ErrorCode) const {
177+
auto ErrorCodeExitIt = ErrorCodeExitMap.find(ErrorCode);
178+
if (ErrorCodeExitIt != ErrorCodeExitMap.end())
179+
return ErrorCodeExitIt->second;
180+
return true;
181+
}
182+
172183
/// Rewrite relative include-like flag paths to absolute ones.
173184
static void
174185
rewriteIncludes(const llvm::ArrayRef<const char *> &Args, size_t Idx,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,8 +4675,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
46754675
// Ensure the default version in SYCL mode is 2020.
46764676
CmdArgs.push_back("-sycl-std=2020");
46774677
}
4678-
if (Args.hasArg(options::OPT_fsycl_unnamed_lambda))
4679-
CmdArgs.push_back("-fsycl-unnamed-lambda");
4678+
4679+
if (!Args.hasFlag(options::OPT_fsycl_unnamed_lambda,
4680+
options::OPT_fno_sycl_unnamed_lambda))
4681+
CmdArgs.push_back("-fno-sycl-unnamed-lambda");
46804682

46814683
// Add the Unique ID prefix
46824684
StringRef UniqueID = D.getSYCLUniqueID(Input.getBaseInput());
@@ -8679,6 +8681,9 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
86798681
// lowered to CrossWorkgroup storage class that is mapped to just
86808682
// global address space.
86818683
ExtArg += ",+SPV_INTEL_usm_storage_classes";
8684+
else
8685+
// Don't enable several freshly added extensions on FPGA H/W
8686+
ExtArg += ",+SPV_INTEL_token_type";
86828687
TranslatorArgs.push_back(TCArgs.MakeArgString(ExtArg));
86838688
}
86848689
for (auto I : Inputs) {

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ const char *SYCL::Linker::constructLLVMSpirvCommand(
8585
return OutputFileName;
8686
}
8787

88+
static void addFPGATimingDiagnostic(std::unique_ptr<Command> &Cmd,
89+
Compilation &C) {
90+
const char *Msg = C.getArgs().MakeArgString(
91+
"The FPGA image generated during this compile contains timing violations "
92+
"and may produce functional errors if used. Refer to the Intel oneAPI "
93+
"DPC++ FPGA Optimization Guide section on Timing Failures for more "
94+
"information.");
95+
Cmd->addDiagForErrorCode(/*ErrorCode*/ 42, Msg);
96+
Cmd->addExitForErrorCode(/*ErrorCode*/ 42, false);
97+
}
98+
8899
void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
89100
std::unique_ptr<Command> InputCommand,
90101
const InputInfoList &InputFiles,
@@ -122,8 +133,14 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
122133
SmallString<128> ForeachPath(C.getDriver().Dir);
123134
llvm::sys::path::append(ForeachPath, "llvm-foreach");
124135
const char *Foreach = C.getArgs().MakeArgString(ForeachPath);
125-
C.addCommand(std::make_unique<Command>(JA, *T, ResponseFileSupport::None(),
126-
Foreach, ForeachArgs, None));
136+
137+
auto Cmd = std::make_unique<Command>(JA, *T, ResponseFileSupport::None(),
138+
Foreach, ForeachArgs, None);
139+
// FIXME: Add the FPGA specific timing diagnostic to the foreach call.
140+
// The foreach call obscures the return codes from the tool it is calling
141+
// to the compiler itself.
142+
addFPGATimingDiagnostic(Cmd, C);
143+
C.addCommand(std::move(Cmd));
127144
}
128145

129146
// The list should match pre-built SYCL device library files located in
@@ -530,6 +547,7 @@ void SYCL::fpga::BackendCompiler::ConstructJob(
530547
const char *Exec = C.getArgs().MakeArgString(ExecPath);
531548
auto Cmd = std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
532549
Exec, CmdArgs, None);
550+
addFPGATimingDiagnostic(Cmd, C);
533551
if (!ForeachInputs.empty())
534552
constructLLVMForeachCommand(C, JA, std::move(Cmd), ForeachInputs, Output,
535553
this, ReportOptArg, ForeachExt);

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3546,6 +3546,20 @@ void CompilerInvocation::GenerateLangArgs(const LangOptions &Opts,
35463546
case LangOptions::SubGroupSizeType::None:
35473547
break;
35483548
}
3549+
3550+
if (Opts.isSYCL()) {
3551+
switch (Opts.SYCLVersion) {
3552+
case LangOptions::SYCL_2017:
3553+
GenerateArg(Args, OPT_sycl_std_EQ, "2017", SA);
3554+
break;
3555+
case LangOptions::SYCL_2020:
3556+
GenerateArg(Args, OPT_sycl_std_EQ, "2020", SA);
3557+
break;
3558+
case LangOptions::SYCL_None:
3559+
// Do nothing, case where we were given an invalid value.
3560+
break;
3561+
}
3562+
}
35493563
}
35503564

35513565
bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
@@ -3637,6 +3651,28 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
36373651
LangStd = OpenCLLangStd;
36383652
}
36393653

3654+
// We have to parse this manually before the marshalling, otherwise we can't
3655+
// use the marshalling to set other flags based on the SYCL version.
3656+
if (Args.hasArg(OPT_fsycl_is_device) || Args.hasArg(OPT_fsycl_is_host)) {
3657+
if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) {
3658+
Opts.setSYCLVersion(
3659+
llvm::StringSwitch<LangOptions::SYCLMajorVersion>(A->getValue())
3660+
.Case("2020", LangOptions::SYCL_2020)
3661+
.Cases("2017", "121", "1.2.1", "sycl-1.2.1",
3662+
LangOptions::SYCL_2017)
3663+
.Default(LangOptions::SYCL_None));
3664+
3665+
if (Opts.SYCLVersion == LangOptions::SYCL_None)
3666+
Diags.Report(diag::err_drv_invalid_value)
3667+
<< A->getAsString(Args) << A->getValue();
3668+
} else {
3669+
// If the user supplied -fsycl-is-device or -fsycl-is-host, but failed to
3670+
// provide -sycl-std=, we want to default it to whatever the default SYCL
3671+
// version is.
3672+
Opts.setSYCLVersion(LangOptions::SYCL_Default);
3673+
}
3674+
}
3675+
36403676
// Parse SYCL Default Sub group size.
36413677
if (const Arg *A = Args.getLastArg(OPT_fsycl_default_sub_group_size)) {
36423678
StringRef Value = A->getValue();
@@ -3687,16 +3723,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
36873723
}
36883724
}
36893725

3690-
if ((Args.hasArg(OPT_fsycl_is_device) || Args.hasArg(OPT_fsycl_is_host)) &&
3691-
!Args.hasArg(OPT_sycl_std_EQ)) {
3692-
// If the user supplied -fsycl-is-device or -fsycl-is-host, but failed to
3693-
// provide -sycl-std=, we want to default it to whatever the default SYCL
3694-
// version is. I could not find a way to express this with the options
3695-
// tablegen because we still want this value to be SYCL_None when the user
3696-
// is not in device or host mode.
3697-
Opts.setSYCLVersion(LangOptions::SYCL_Default);
3698-
}
3699-
37003726
if (Opts.ObjC) {
37013727
if (Arg *arg = Args.getLastArg(OPT_fobjc_runtime_EQ)) {
37023728
StringRef value = arg->getValue();

0 commit comments

Comments
 (0)