Skip to content

Commit

Permalink
Merge from 'sycl' to 'sycl-web' (intel#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
iclsrc committed Sep 8, 2020
2 parents cee7f3b + f90614c commit c107c05
Show file tree
Hide file tree
Showing 240 changed files with 6,946 additions and 2,055 deletions.
12 changes: 6 additions & 6 deletions buildbot/dependency.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ ocl_cpu_rt_ver=2020.11.8.0.27
# https://github.com/intel/llvm/releases/download/2020-WW36/win-oclcpuexp-2020.11.8.0.27_rel.zip
ocl_cpu_rt_ver_win=2020.11.8.0.27
# Same GPU driver supports Level Zero and OpenCL:
# https://github.com/intel/compute-runtime/releases/tag/20.29.17408
ocl_gpu_rt_ver=20.29.17408
# https://github.com/intel/compute-runtime/releases/tag/20.35.17767
ocl_gpu_rt_ver=20.35.17767
# Same GPU driver supports Level Zero and OpenCL:
# https://downloadmirror.intel.com/29674/a08/igfx_win10_100.8336.zip
ocl_gpu_rt_ver_win=27.20.100.8336
# https://downloadmirror.intel.com/29817/a08/igfx_win10_100.8673.zip
ocl_gpu_rt_ver_win=27.20.100.8673
intel_sycl_ver=build
# https://github.com/oneapi-src/oneTBB/releases/download/v2021.1-beta08/oneapi-tbb-2021.1-beta08-lin.tgz
tbb_ver=2021.1.9.636
Expand All @@ -24,8 +24,8 @@ fpga_ver_win=20200811_000006
[DRIVER VERSIONS]
cpu_driver_lin=2020.11.8.0.27
cpu_driver_win=2020.11.8.0.27
gpu_driver_lin=20.29.17408
gpu_driver_win=27.20.100.8336
gpu_driver_lin=20.35.17767
gpu_driver_win=27.20.100.8673
fpga_driver_lin=2020.11.8.0.27
fpga_driver_win=2020.11.8.0.27
# NVidia CUDA driver
Expand Down
1 change: 0 additions & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,6 @@ def LoopUnrollHint : InheritableAttr {

def IntelReqdSubGroupSize: InheritableAttr {
let Spellings = [GNU<"intel_reqd_sub_group_size">,
CXX11<"cl", "intel_reqd_sub_group_size">,
CXX11<"intel", "reqd_sub_group_size">];
let Args = [ExprArgument<"SubGroupSize">];
let Subjects = SubjectList<[Function, CXXMethod], ErrorDiag>;
Expand Down
20 changes: 3 additions & 17 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -3476,30 +3476,16 @@ code. See `cl_intel_required_subgroup_size
for details.

SYCL documentation:
The [[cl::intel_reqd_sub_group_size(n)]] and [[intel::reqd_sub_group_size(n)]]
attribute indicates that the kernel must be compiled and executed with a
sub-group of size n. The value of n must be set to a sub-group size supported
by the device, or device compilation will fail.
The [[intel::reqd_sub_group_size(n)]] attribute indicates that the kernel must
be compiled and executed with a sub-group of size n. The value of n must be set
to a sub-group size supported by the device, or device compilation will fail.

In addition to device functions, the required sub-group size attribute may also
be specified in the definition of a named functor object and lambda functions,
as in the examples below:

.. code-block:: c++

class Functor
{
void operator()(item<1> item) [[cl::intel_reqd_sub_group_size(16)]]
{
/* kernel code */
}
}

kernel<class kernel_name>(
[]() [[cl::intel_reqd_sub_group_size(n)]] {
/* kernel code */
});

class Functor
{
[[intel::reqd_sub_group_size(16)]] void operator()(item<1> item)
Expand Down
13 changes: 3 additions & 10 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -11002,11 +11002,9 @@ def err_sycl_restrict : Error<
"|use a const static or global variable that is neither zero-initialized "
"nor constant-initialized"
"}0">;
def warn_sycl_kernel_too_many_args : Warning<
"kernel argument count (%0) exceeds supported maximum of %1 on GPU">,
InGroup<SyclStrict>;
def note_sycl_kernel_args_count : Note<"array elements and fields of a "
"class/struct may be counted separately">;
def warn_sycl_kernel_too_big_args : Warning<
"size of kernel arguments (%0 bytes) exceeds supported maximum of %1 bytes "
"on GPU">, InGroup<SyclStrict>;
def err_sycl_virtual_types : Error<
"No class with a vtable can be used in a SYCL kernel or any code included in the kernel">;
def note_sycl_recursive_function_declared_here: Note<"function implemented using recursion declared here">;
Expand Down Expand Up @@ -11073,11 +11071,6 @@ def err_ivdep_declrefexpr_arg : Error<
def warn_ivdep_redundant : Warning <"ignoring redundant Intel FPGA loop "
"attribute 'ivdep': safelen %select{INF|%1}0 >= safelen %select{INF|%3}2">,
InGroup<IgnoredAttributes>;
def warn_attribute_spelling_deprecated : Warning<
"attribute %0 is deprecated">,
InGroup<DeprecatedAttributes>;
def note_spelling_suggestion : Note<
"did you mean to use %0 instead?">;

// errors of expect.with.probability
def err_probability_not_constant_float : Error<
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6119,8 +6119,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
}

// For /P, preprocess to file named after BaseInput.
if (C.getArgs().hasArg(options::OPT__SLASH_P)) {
assert(AtTopLevel && isa<PreprocessJobAction>(JA));
if (C.getArgs().hasArg(options::OPT__SLASH_P) &&
((AtTopLevel && isa<PreprocessJobAction>(JA)) ||
isa<OffloadBundlingJobAction>(JA))) {
StringRef BaseName = llvm::sys::path::filename(BaseInput);
StringRef NameArg;
if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi))
Expand Down
14 changes: 12 additions & 2 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4201,8 +4201,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
SYCLStdArg->render(Args, CmdArgs);
CmdArgs.push_back("-fsycl-std-layout-kernel-params");
} else {
// Ensure the default version in SYCL mode is 1.2.1 (aka 2017)
CmdArgs.push_back("-sycl-std=2017");
// Ensure the default version in SYCL mode is 2020
CmdArgs.push_back("-sycl-std=2020");
}
}

Expand Down Expand Up @@ -5996,10 +5996,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
options::OPT_fno_gnu_inline_asm, true))
CmdArgs.push_back("-fno-gnu-inline-asm");

bool EnableSYCLEarlyOptimizations =
Args.hasFlag(options::OPT_fsycl_early_optimizations,
options::OPT_fno_sycl_early_optimizations,
Triple.getSubArch() != llvm::Triple::SPIRSubArch_fpga);

// Enable vectorization per default according to the optimization level
// selected. For optimization levels that want vectorization we use the alias
// option to simplify the hasFlag logic.
bool EnableVec = shouldEnableVectorizerAtOLevel(Args, false);
if (UseSYCLTriple && EnableSYCLEarlyOptimizations)
EnableVec = false; // But disable vectorization for SYCL device code
OptSpecifier VectorizeAliasOption =
EnableVec ? options::OPT_O_Group : options::OPT_fvectorize;
if (Args.hasFlag(options::OPT_fvectorize, VectorizeAliasOption,
Expand All @@ -6008,6 +6015,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,

// -fslp-vectorize is enabled based on the optimization level selected.
bool EnableSLPVec = shouldEnableVectorizerAtOLevel(Args, true);
if (UseSYCLTriple && EnableSYCLEarlyOptimizations)
EnableSLPVec = false; // But disable vectorization for SYCL device code
OptSpecifier SLPVectAliasOption =
EnableSLPVec ? options::OPT_O_Group : options::OPT_fslp_vectorize;
if (Args.hasFlag(options::OPT_fslp_vectorize, SLPVectAliasOption,
Expand Down Expand Up @@ -7710,6 +7719,7 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
TranslatorArgs.push_back(Output.getFilename());
if (getToolChain().getTriple().isSYCLDeviceEnvironment()) {
TranslatorArgs.push_back("-spirv-max-version=1.1");
TranslatorArgs.push_back("-spirv-debug-info-version=legacy");
if (C.getArgs().hasArg(options::OPT_fsycl_esimd))
TranslatorArgs.push_back("-spirv-allow-unknown-intrinsics");

Expand Down
17 changes: 14 additions & 3 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const char *SYCL::Linker::constructLLVMSpirvCommand(Compilation &C,
} else {
CmdArgs.push_back("-spirv-max-version=1.1");
CmdArgs.push_back("-spirv-ext=+all");
CmdArgs.push_back("-spirv-debug-info-version=legacy");
if (C.getArgs().hasArg(options::OPT_fsycl_esimd))
CmdArgs.push_back("-spirv-allow-unknown-intrinsics");
CmdArgs.push_back("-o");
Expand Down Expand Up @@ -204,6 +205,13 @@ void SYCL::Linker::ConstructJob(Compilation &C, const JobAction &JA,
SpirvInputs);
}

static const char *makeExeName(Compilation &C, StringRef Name) {
llvm::SmallString<8> ExeName(Name);
if (C.getDriver().IsCLMode())
ExeName.append(".exe");
return C.getArgs().MakeArgString(ExeName);
}

void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
const JobAction &JA,
const InputInfo &Output,
Expand Down Expand Up @@ -312,7 +320,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
CmdArgs.push_back(Args.MakeArgString(A->getAsString(Args)));
}

SmallString<128> ExecPath(getToolChain().GetProgramPath("aoc"));
SmallString<128> ExecPath(
getToolChain().GetProgramPath(makeExeName(C, "aoc")));
const char *Exec = C.getArgs().MakeArgString(ExecPath);
auto Cmd = std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, None);
Expand Down Expand Up @@ -349,7 +358,8 @@ void SYCL::gen::BackendCompiler::ConstructJob(Compilation &C,
static_cast<const toolchains::SYCLToolChain &>(getToolChain());
TC.TranslateBackendTargetArgs(Args, CmdArgs);
TC.TranslateLinkerTargetArgs(Args, CmdArgs);
SmallString<128> ExecPath(getToolChain().GetProgramPath("ocloc"));
SmallString<128> ExecPath(
getToolChain().GetProgramPath(makeExeName(C, "ocloc")));
const char *Exec = C.getArgs().MakeArgString(ExecPath);
auto Cmd = std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, None);
Expand Down Expand Up @@ -382,7 +392,8 @@ void SYCL::x86_64::BackendCompiler::ConstructJob(Compilation &C,

TC.TranslateBackendTargetArgs(Args, CmdArgs);
TC.TranslateLinkerTargetArgs(Args, CmdArgs);
SmallString<128> ExecPath(getToolChain().GetProgramPath("opencl-aot"));
SmallString<128> ExecPath(
getToolChain().GetProgramPath(makeExeName(C, "opencl-aot")));
const char *Exec = C.getArgs().MakeArgString(ExecPath);
auto Cmd = std::make_unique<Command>(
JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, None);
Expand Down
25 changes: 25 additions & 0 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3212,6 +3212,22 @@ static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD,
FixSemaDC(VD->getDescribedVarTemplate());
}

template <typename AttributeType>
static void checkDimensionsAndSetDiagnostics(Sema &S, FunctionDecl *New,
FunctionDecl *Old) {
AttributeType *NewDeclAttr = New->getAttr<AttributeType>();
AttributeType *OldDeclAttr = Old->getAttr<AttributeType>();
if ((NewDeclAttr->getXDim() != OldDeclAttr->getXDim()) ||
(NewDeclAttr->getYDim() != OldDeclAttr->getYDim()) ||
(NewDeclAttr->getZDim() != OldDeclAttr->getZDim())) {
S.Diag(New->getLocation(), diag::err_conflicting_sycl_function_attributes)
<< OldDeclAttr << NewDeclAttr;
S.Diag(New->getLocation(), diag::warn_duplicate_attribute) << OldDeclAttr;
S.Diag(OldDeclAttr->getLocation(), diag::note_conflicting_attribute);
S.Diag(NewDeclAttr->getLocation(), diag::note_conflicting_attribute);
}
}

/// MergeFunctionDecl - We just parsed a function 'New' from
/// declarator D which has the same name and scope as a previous
/// declaration 'Old'. Figure out how to resolve this situation,
Expand Down Expand Up @@ -3286,6 +3302,15 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
}
}

if (New->hasAttr<ReqdWorkGroupSizeAttr>() &&
Old->hasAttr<ReqdWorkGroupSizeAttr>())
checkDimensionsAndSetDiagnostics<ReqdWorkGroupSizeAttr>(*this, New, Old);

if (New->hasAttr<SYCLIntelMaxWorkGroupSizeAttr>() &&
Old->hasAttr<SYCLIntelMaxWorkGroupSizeAttr>())
checkDimensionsAndSetDiagnostics<SYCLIntelMaxWorkGroupSizeAttr>(*this, New,
Old);

if (New->hasAttr<InternalLinkageAttr>() &&
!Old->hasAttr<InternalLinkageAttr>()) {
Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
Expand Down
7 changes: 0 additions & 7 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3013,13 +3013,6 @@ static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
if (D->getAttr<IntelReqdSubGroupSizeAttr>())
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;

if (AL.getAttributeSpellingListIndex() ==
IntelReqdSubGroupSizeAttr::CXX11_cl_intel_reqd_sub_group_size) {
S.Diag(AL.getLoc(), diag::warn_attribute_spelling_deprecated) << AL;
S.Diag(AL.getLoc(), diag::note_spelling_suggestion)
<< "'intel::reqd_sub_group_size'";
}

S.addIntelReqdSubGroupSizeAttr(D, AL, E);
}

Expand Down
Loading

0 comments on commit c107c05

Please sign in to comment.