Skip to content

Commit

Permalink
Merge branch 'sycl' into private/s-kanaev/assert-abort
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Kanaev committed Apr 15, 2021
2 parents 5078fcc + 347e41c commit 4dc7b1f
Show file tree
Hide file tree
Showing 117 changed files with 4,949 additions and 1,438 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Get clang-format first
run: sudo apt-get install -yqq clang-format-9
run: sudo apt-get install -yqq clang-format

- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sync-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: automatic sync main branch from llvm-project to llvm

on:
schedule:
- cron: '*/10 * * * *'
- cron: '0 */1 * * *'
jobs:
sync:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions buildbot/dependency.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ ocl_cpu_rt_ver=2021.11.3.0.09
# https://github.com/intel/llvm/releases/download/2021-WW11/win-oclcpuexp-2021.11.3.0.09_rel.zip
ocl_cpu_rt_ver_win=2021.11.3.0.09
# Same GPU driver supports Level Zero and OpenCL
# https://github.com/intel/compute-runtime/releases/tag/21.09.19150
ocl_gpu_rt_ver=21.09.19150
# https://github.com/intel/compute-runtime/releases/tag/21.12.19358
ocl_gpu_rt_ver=21.12.19358
# Same GPU driver supports Level Zero and OpenCL
# https://downloadmirror.intel.com/30266/a08/igfx_win10_100.9316.zip
ocl_gpu_rt_ver_win=27.20.100.9316
Expand All @@ -30,7 +30,7 @@ ocloc_ver_win=27.20.100.9168
[DRIVER VERSIONS]
cpu_driver_lin=2021.11.3.0.09
cpu_driver_win=2021.11.3.0.09
gpu_driver_lin=21.09.19150
gpu_driver_lin=21.12.19358
gpu_driver_win=27.20.100.9316
fpga_driver_lin=2021.11.3.0.09
fpga_driver_win=2021.11.3.0.09
Expand Down
33 changes: 31 additions & 2 deletions clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,7 @@ def SYCLSimd : InheritableAttr {
let Subjects = SubjectList<[Function, GlobalVar]>;
let Documentation = [SYCLSimdDocs];
let SupportsNonconformingLambdaSyntax = 1;
let SimpleHandler = 1;
}

// Available in SYCL explicit SIMD extension. Binds a file scope private
Expand Down Expand Up @@ -1431,15 +1432,32 @@ def LoopUnrollHint : StmtAttr {
}

def IntelReqdSubGroupSize: InheritableAttr {
let Spellings = [GNU<"intel_reqd_sub_group_size">,
CXX11<"intel", "reqd_sub_group_size">];
let Spellings = [
GNU<"intel_reqd_sub_group_size">, CXX11<"intel", "reqd_sub_group_size">,
CXX11<"intel", "sub_group_size"> // SYCL2020 spelling.
];
let Args = [ExprArgument<"Value">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [IntelReqdSubGroupSizeDocs];
let LangOpts = [OpenCL, SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
let SupportsNonconformingLambdaSyntax = 1;
let Accessors =
[Accessor<"isSYCL2020Spelling", [CXX11<"intel", "sub_group_size">]>];
}

def IntelNamedSubGroupSize : InheritableAttr {
let Spellings = [CXX11<"intel", "named_sub_group_size">];
let Args = [EnumArgument<"Type", "SubGroupSizeType", ["automatic", "primary"],
["Automatic", "Primary"]>];
let Subjects = SubjectList<[Function], ErrorDiag>;
let Documentation = [IntelNamedSubGroupSizeDocs];
let LangOpts = [OpenCL, SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
let SupportsNonconformingLambdaSyntax = 1;
}

def :
MutualExclusions<[IntelReqdSubGroupSize, IntelNamedSubGroupSize, SYCLSimd]>;

// This attribute is both a type attribute, and a declaration attribute (for
// parameter variables).
def OpenCLAccess : Attr {
Expand Down Expand Up @@ -1952,6 +1970,13 @@ def SYCLIntelFPGADisableLoopPipelining : DeclOrStmtAttr {
}
def : MutualExclusions<[SYCLIntelFPGAInitiationInterval,
SYCLIntelFPGADisableLoopPipelining]>;
def : MutualExclusions<[SYCLIntelFPGAIVDep,
SYCLIntelFPGADisableLoopPipelining]>;
def : MutualExclusions<[SYCLIntelFPGAMaxConcurrency,
SYCLIntelFPGADisableLoopPipelining]>;

def : MutualExclusions<[SYCLIntelFPGAMaxConcurrency,
SYCLIntelFPGADisableLoopPipelining]>;

def SYCLIntelFPGAMaxInterleaving : StmtAttr {
let Spellings = [CXX11<"intelfpga","max_interleaving">,
Expand All @@ -1963,6 +1988,8 @@ def SYCLIntelFPGAMaxInterleaving : StmtAttr {
let HasCustomTypeTransform = 1;
let Documentation = [SYCLIntelFPGAMaxInterleavingAttrDocs];
}
def : MutualExclusions<[SYCLIntelFPGADisableLoopPipelining,
SYCLIntelFPGAMaxInterleaving]>;

def SYCLIntelFPGASpeculatedIterations : StmtAttr {
let Spellings = [CXX11<"intelfpga","speculated_iterations">,
Expand All @@ -1974,6 +2001,8 @@ def SYCLIntelFPGASpeculatedIterations : StmtAttr {
let HasCustomTypeTransform = 1;
let Documentation = [SYCLIntelFPGASpeculatedIterationsAttrDocs];
}
def : MutualExclusions<[SYCLIntelFPGADisableLoopPipelining,
SYCLIntelFPGASpeculatedIterations]>;

def SYCLIntelFPGANofusion : StmtAttr {
let Spellings = [CXX11<"intel","nofusion">];
Expand Down
63 changes: 56 additions & 7 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -2869,7 +2869,7 @@ This attribute applies to a loop or a function. It indicates that the
loop/function should allow no more than N threads or iterations to execute it
simultaneously. N must be a non negative integer. '0' indicates the
max_concurrency case to be unbounded. Cannot be applied multiple times to the
same loop.
same loop or function, or in conjunction with ``disable_loop_pipelining``.

.. code-block:: c++

Expand Down Expand Up @@ -2935,17 +2935,18 @@ def SYCLIntelFPGADisableLoopPipeliningAttrDocs : Documentation {
This attribute applies to a loop or a function. Takes no arguments and
disables pipelining of the loop or function data path, causing the loop
or function to be executed serially. Cannot be used on the same loop or
function in conjunction with max_interleaving, speculated_iterations,
max_concurrency, initiation_interval, or ivdep.
function, or in conjunction with ``max_interleaving``,
``speculated_iterations``, ``max_concurrency``, ``initiation_interval``,
or ``ivdep``.

.. code-block:: c++

void foo() {
int var = 0;
[[intel::disable_loop_pipelining] for (int i = 0; i < 10; ++i) var++;
[[intel::disable_loop_pipelining]] for (int i = 0; i < 10; ++i) var++;
}

[[intel::disable_loop_pipelining] void foo1() { }
[[intel::disable_loop_pipelining]] void foo1() { }

}];
}
Expand Down Expand Up @@ -4353,9 +4354,9 @@ This attribute can be used in both OpenCL and SYCL.

OpenCL documentation:
The optional attribute intel_reqd_sub_group_size can be used to indicate that
the kernel must be compiled and executed with the specified subgroup size. When
the kernel must be compiled and executed with the specified sub group size. When
this attribute is present, get_max_sub_group_size() is guaranteed to return the
specified integer value. This is important for the correctness of many subgroup
specified integer value. This is important for the correctness of many sub group
algorithms, and in some cases may be used by the compiler to generate more optimal
code. See `cl_intel_required_subgroup_size
<https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_required_subgroup_size.txt>`
Expand All @@ -4366,6 +4367,13 @@ 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.

The ``[[intel::sub_group_size(n)]]`` attribute has the same effect as the other
attribute spellings, except that it follows the SYCL 2020 Attribute Rules. See
the ``[[intel::named_sub_group_size(NAME)]]`` documentation for clarification.

This attribute is mutually exclusive with ``[[intel::named_sub_group_size(NAME)]]``
and ``[[intel::sycl_explicit_simd]]``.

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:
Expand All @@ -4389,6 +4397,47 @@ See Sub-groups for NDRange Parallelism proposal in sycl/doc/extensions/sub_group
}];
}

def IntelNamedSubGroupSizeDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
The ``[[intel::named_sub_group_size(NAME)]]`` attribute works similar to
``[[intel::sub_group_size(N)]]`` attribute in that it defines the specific
sub group size for the kernel. The ``[[intel::named_sub_group_size(NAME)]]``
form accepts a required parameter of either ``automatic`` or ``primary``.

``automatic`` specifies that the implementation is free to select any of the
valid sub-group sizes associated with the device to which the kernel is
submitted. ``primary`` specifies that the implementation should select the
device's primary sub-group size as reported by
``info::device::primary_sub_group_size``.

This attribute may not be combined with ``[[intel::sub_group_size(N)]]``, as
the two attributes have different meanings. It is also mutually exclusive with
``[[intel::sycl_explicit_simd]]``.

In addition to the attributes, a default sub-group size strategy may be
specified by the ``-fsycl-default-sub-group-size`` command line option, which
accepts either ``automatic``, ``primary``, or a default size as an integer.
These values match and have the same behavior as the ``automatic``, ``primary``,
and ``[[intel::sub_group_size(N)]]`` values respectively.

SYCL 2020 Attribute Rules:
SYCL 2020 specifies that kernel-type attributes should only be specified on the
kernel or a ``SYCL_EXTERNAL`` function. This implementation permits these
attributes to appear on all function declarations for the purposes of
self-documenting declarations. However, these attributes must match the kernel's
sub-group size as configured by the command line, or via an attribute
specifically.

In addition to the SYCL 2020 Attribute Rules, this attribute and the
``[[intel::sub_group_size(N)]]`` attribute also require that any
``SYCL_EXTERNAL`` functions defined in a different translation unit must have a
matching sub-group size specification, so ``SYCL_EXTERNAL`` functions not
defined in this translation unit must also have a matching sub-group
specification to the kernel function that calls it.
}];
}

def OpenCLAccessDocs : Documentation {
let Category = DocCatStmt;
let Heading = "__read_only, __write_only, __read_write (read_only, write_only, read_write)";
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ def err_drv_invalid_Xsycl_frontend_with_args : Error<
"invalid -Xsycl-target-frontend argument: '%0', options requiring arguments are unsupported">;
def err_drv_bad_fpga_device_count : Error<
"More than one FPGA specific device binary found in input objects">;
def warn_drv_mismatch_fpga_archive : Warning<
"FPGA archive '%0' does not contain matching emulation/hardware expectancy">,
InGroup<SyclFPGAMismatch>;
def err_drv_unsupported_opt_dpcpp : Error<"option '%0' unsupported with DPC++">;
def err_drv_argument_only_allowed_with : Error<
"invalid argument '%0' only allowed with '%1'">;
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ def Sycl2017Compat : DiagGroup<"sycl-2017-compat">;
def Sycl2020Compat : DiagGroup<"sycl-2020-compat">;
def SyclStrict : DiagGroup<"sycl-strict", [ Sycl2017Compat, Sycl2020Compat]>;
def SyclTarget : DiagGroup<"sycl-target">;
def SyclFPGAMismatch : DiagGroup<"sycl-fpga-mismatch">;

// Backend warnings.
def BackendInlineAsm : DiagGroup<"inline-asm">;
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -11317,6 +11317,11 @@ def note_spelling_suggestion : Note<
"did you mean to use %0 instead?">;
def warn_attribute_requires_non_negative_integer_argument :
Warning<warn_impcast_integer_sign.Text>, InGroup<AcceptedAttributes>;
def err_sycl_mismatch_group_size
: Error<"%select{kernel-called|undefined 'SYCL_EXTERNAL'}0 function must "
"have a sub group size that matches the size specified for the "
"kernel">;
def note_sycl_kernel_declared_here : Note<"kernel declared here">;

// errors of expect.with.probability
def err_probability_not_constant_float : Error<
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ LANGOPT(RelativeCXXABIVTables, 1, 0,

LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits")

ENUM_LANGOPT(DefaultSubGroupSizeType, SubGroupSizeType, 2,
SubGroupSizeType::None,
"Strategy via which sub group is assigned for SYCL kernel "
"types if not overridden via attributes")

VALUE_LANGOPT(DefaultSubGroupSize, 32, 0,
"If DefaultSubGroupSizeType is Integer contains the value")

#undef LANGOPT
#undef COMPATIBLE_LANGOPT
#undef BENIGN_LANGOPT
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ class LangOptions : public LangOptionsBase {
Single
};

enum class SubGroupSizeType { None, Auto, Primary, Integer };

public:
/// The used language standard.
LangStandard::Kind LangStd;
Expand Down Expand Up @@ -354,6 +356,12 @@ class LangOptions : public LangOptionsBase {
/// SYCL integration footer to be generated by the device compiler
std::string SYCLIntFooter;

/// A driver-provided unique string for this translation unit that is used to
/// generate unique names for SYCL names. This is provided by the driver so
/// that the case of multiple-offload can have each device compilation share a
/// name.
std::string SYCLUniquePrefix;

LangOptions();

// Define accessors/mutators for language options of enumeration type.
Expand Down
11 changes: 11 additions & 0 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,13 @@ class Driver {

void setOffloadStaticLibSeen() { OffloadStaticLibSeen = true; }

/// FPGA Emulation Mode. By default, this is true due to the fact that
/// an external option setting is required to target hardware.
bool FPGAEmulationMode = true;
void setFPGAEmulationMode(bool IsEmulation) {
FPGAEmulationMode = IsEmulation;
}

/// Returns true if an offload static library is found.
bool checkForOffloadStaticLib(Compilation &C,
llvm::opt::DerivedArgList &Args) const;
Expand Down Expand Up @@ -690,6 +697,10 @@ class Driver {
return FPGATempDepFiles[FileName];
}

/// isFPGAEmulationMode - Compilation mode is determined to be used for
/// FPGA Emulation. This is only used for SYCL offloading to FPGA device.
bool isFPGAEmulationMode() const { return FPGAEmulationMode; };

/// addIntegrationFiles - Add the integration files that will be populated
/// by the device compilation and used by the host compile.
void addIntegrationFiles(StringRef IntHeaderName, StringRef FileName) const {
Expand Down
19 changes: 17 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -5559,8 +5559,10 @@ def finclude_default_header : Flag<["-"], "finclude-default-header">,
HelpText<"Include default header file for OpenCL">;
def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
HelpText<"Add OpenCL builtin function declarations (experimental)">;
def fdeclare_spirv_builtins : Flag<["-"], "fdeclare-spirv-builtins">,
HelpText<"Add SPIR-V builtin function declarations (experimental)">;
def fdeclare_spirv_builtins
: Flag<["-"], "fdeclare-spirv-builtins">,
HelpText<"Add SPIR-V builtin function declarations (experimental)">,
MarshallingInfoFlag<LangOpts<"DeclareSPIRVBuiltins">>;

def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
HelpText<"Preserve 3-component vector type">,
Expand Down Expand Up @@ -5698,6 +5700,11 @@ def fsycl_int_footer : Separate<["-"], "fsycl-int-footer">,
MarshallingInfoString<LangOpts<"SYCLIntFooter">>;
def fsycl_int_footer_EQ : Joined<["-"], "fsycl-int-footer=">,
Alias<fsycl_int_footer>;
def fsycl_unique_prefix_EQ
: Joined<["-"], "fsycl-unique-prefix=">,
HelpText<"A unique prefix for this translation unit across devices, used "
"to generate a unique name for local variables.">,
MarshallingInfoString<LangOpts<"SYCLUniquePrefix">>;
def fsycl_std_layout_kernel_params: Flag<["-"], "fsycl-std-layout-kernel-params">,
HelpText<"Enable standard layout requirement for SYCL kernel parameters.">,
MarshallingInfoFlag<LangOpts<"SYCLStdLayoutKernelParams">>;
Expand All @@ -5721,6 +5728,14 @@ def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group<sycl_Group>,
MarshallingInfoEnum<LangOpts<"SYCLVersion">, "SYCL_None">,
ShouldParseIf<!strconcat(fsycl_is_device.KeyPath, "||", fsycl_is_host.KeyPath)>;

def fsycl_default_sub_group_size
: Separate<["-"], "fsycl-default-sub-group-size">,
HelpText<"Set the default sub group size for SYCL kernels">,
Flags<[CC1Option]>;
def fsycl_default_sub_group_size_EQ
: Joined<["-"], "fsycl-default-sub-group-size=">,
Alias<fsycl_default_sub_group_size>, Flags<[CC1Option]>;

defm cuda_approx_transcendentals : BoolFOption<"cuda-approx-transcendentals",
LangOpts<"CUDADeviceApproxTranscendentals">, DefaultFalse,
PosFlag<SetTrue, [CC1Option], "Use">, NegFlag<SetFalse, [], "Don't use">,
Expand Down
6 changes: 4 additions & 2 deletions clang/include/clang/Driver/Types.def
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@ TYPE("tempAOCOfilelist", TempAOCOfilelist, INVALID, "txt", phases
TYPE("archive", Archive, INVALID, "a", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("wholearchive", WholeArchive, INVALID, "a", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_aocx", FPGA_AOCX, INVALID, "aocx", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_aocx_emu", FPGA_AOCX_EMU, INVALID, "aocx", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_aocr", FPGA_AOCR, INVALID, "aocr", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_aocr_emu", FPGA_AOCR_EMU, INVALID, "aocr", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_aoco", FPGA_AOCO, INVALID, "aoco", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_dependencies", FPGA_Dependencies, INVALID, "d", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_dependencies_list", FPGA_Dependencies_List, INVALID, "txt", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_dep", FPGA_Dependencies, INVALID, "d", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("fpga_dep_list", FPGA_Dependencies_List, INVALID, "txt", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
TYPE("none", Nothing, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)
13 changes: 6 additions & 7 deletions clang/include/clang/Sema/ParsedAttr.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ struct ParsedAttrInfo {
const Decl *D) const {
return true;
}
/// Check if the given attribute is mutually exclusive with other attributes
/// already applied to the given statement.
virtual bool diagMutualExclusion(Sema &S, const ParsedAttr &A,
const Stmt *St) const {
return true;
}
/// Check if this attribute is allowed by the language we are compiling, and
/// issue a diagnostic if not.
virtual bool diagLangOpts(Sema &S, const ParsedAttr &Attr) const {
Expand Down Expand Up @@ -615,7 +609,12 @@ class ParsedAttr final
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const;
bool diagnoseAppertainsTo(class Sema &S, const Stmt *St) const;
bool diagnoseMutualExclusion(class Sema &S, const Decl *D) const;
bool diagnoseMutualExclusion(class Sema &S, const Stmt *St) const;
// This function stub exists for parity with the declaration checking code so
// that checkCommonAttributeFeatures() can work generically on declarations
// or statements.
bool diagnoseMutualExclusion(class Sema &S, const Stmt *St) const {
return true;
}
bool appliesToDecl(const Decl *D, attr::SubjectMatchRule MatchRule) const;
void getMatchRules(const LangOptions &LangOpts,
SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>>
Expand Down
Loading

0 comments on commit 4dc7b1f

Please sign in to comment.