Skip to content

Commit fbe1c86

Browse files
Merge remote-tracking branch 'upstream/sycl' into sycl-mlir
2 parents ee2ca45 + 8759d07 commit fbe1c86

File tree

137 files changed

+6147
-407
lines changed

Some content is hidden

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

137 files changed

+6147
-407
lines changed

.github/workflows/sycl_post_commit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ jobs:
1919
# This job generates matrix of tests for LLVM Test Suite
2020
test_matrix:
2121
name: Generate Test Matrix
22+
if: github.repository == 'intel/llvm'
2223
uses: ./.github/workflows/sycl_gen_test_matrix.yml
2324
with:
2425
lts_config: "l0_gen9"
2526
cts_config: "cuda"
2627
linux_default:
2728
name: Linux Default
29+
if: github.repository == 'intel/llvm'
2830
needs: test_matrix
2931
uses: ./.github/workflows/sycl_linux_build_and_test.yml
3032
secrets: inherit
@@ -36,6 +38,7 @@ jobs:
3638
lts_aws_matrix: ${{ needs.test_matrix.outputs.lts_aws_matrix }}
3739
linux_no_assert:
3840
name: Linux (no assert)
41+
if: github.repository == 'intel/llvm'
3942
uses: ./.github/workflows/sycl_linux_build_and_test.yml
4043
secrets: inherit
4144
with:

.github/workflows/windows_test_comment_trigger.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ jobs:
5656
windows_test_completion:
5757
runs-on: ubuntu-latest
5858
needs: [windows_test_preparation, windows_default]
59+
if: always()
5960
steps:
6061
- name: update_pr_status_success
61-
if: always() && success()
62+
if: needs.windows_default.result == 'success'
6263
env:
6364
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6465
OWNER: ${{ github.repository_owner }}
@@ -67,7 +68,7 @@ jobs:
6768
run: |
6869
gh api --method POST -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/statuses/$SHA -f state='success' -f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' -f description='The operation completed successfully' -f context='Windows pre-commit'
6970
- name: update_pr_status_failure
70-
if: failure()
71+
if: needs.windows_default.result == 'failure'
7172
env:
7273
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7374
OWNER: ${{ github.repository_owner }}

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ the PR with:
9090
- link to existing open issue
9191
- if author cannot identify any of these, the minimal action expected is to
9292
open a new [issue](/../../issues)
93+
- list of unrelated tests failing in pre-commit CI. This would enable easy
94+
access to them via github search functionality.
9395
9496
### Merge
9597

buildbot/configure.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def do_configure(args):
2323
libclc_amd_target_names = ';amdgcn--;amdgcn--amdhsa'
2424
libclc_nvidia_target_names = ';nvptx64--;nvptx64--nvidiacl'
2525

26+
sycl_enable_fusion = "OFF"
27+
if not args.disable_fusion:
28+
llvm_external_projects += ";sycl-fusion"
29+
sycl_enable_fusion = "ON"
30+
2631
if args.llvm_external_projects:
2732
llvm_external_projects += ";" + args.llvm_external_projects.replace(",", ";")
2833

@@ -35,6 +40,7 @@ def do_configure(args):
3540
mlir_dir = os.path.join(abs_src_dir, "mlir")
3641
mlir_sycl_dir = os.path.join(abs_src_dir, "mlir-sycl")
3742
polygeist_dir = os.path.join(abs_src_dir, "polygeist")
43+
fusion_dir = os.path.join(abs_src_dir, "sycl-fusion")
3844
llvm_targets_to_build = args.host_target
3945
llvm_enable_projects = 'clang;' + llvm_external_projects
4046
libclc_targets_to_build = ''
@@ -164,6 +170,7 @@ def do_configure(args):
164170
"-DLLVM_EXTERNAL_MLIR_SOURCE_DIR={}".format(mlir_dir),
165171
"-DLLVM_EXTERNAL_MLIR_SYCL_SOURCE_DIR={}".format(mlir_sycl_dir),
166172
"-DLLVM_EXTERNAL_POLYGEIST_SOURCE_DIR={}".format(polygeist_dir),
173+
"-DLLVM_EXTERNAL_SYCL_FUSION_SOURCE_DIR={}".format(fusion_dir),
167174
"-DLLVM_ENABLE_PROJECTS={}".format(llvm_enable_projects),
168175
"-DLIBCLC_TARGETS_TO_BUILD={}".format(libclc_targets_to_build),
169176
"-DLIBCLC_GENERATE_REMANGLED_VARIANTS={}".format(libclc_gen_remangled_variants),
@@ -182,7 +189,8 @@ def do_configure(args):
182189
"-DSYCL_ENABLE_PLUGINS={}".format(';'.join(set(sycl_enabled_plugins))),
183190
"-DCMAKE_C_COMPILER={}".format(build_compiler_c),
184191
"-DCMAKE_CXX_COMPILER={}".format(build_compiler_cpp),
185-
"-DCMAKE_VERBOSE_MAKEFILE={}".format(verbose)
192+
"-DCMAKE_VERBOSE_MAKEFILE={}".format(verbose),
193+
"-DSYCL_ENABLE_KERNEL_FUSION={}".format(sycl_enable_fusion)
186194
]
187195

188196
if args.l0_headers and args.l0_loader:
@@ -262,8 +270,9 @@ def main():
262270
parser.add_argument("--ci-defaults", action="store_true", help="Enable default CI parameters")
263271
parser.add_argument("--enable-plugin", action='append', help="Enable SYCL plugin")
264272
parser.add_argument("--build-compiler-c", metavar="BUILD_COMPILER_C", help="C compiler to use to build the project")
265-
parser.add_argument("--build-compiler-cpp", metavar="BUILD_COMPILER_CPP", help="C++ compiler to use to build the project"),
266-
parser.add_argument("--verbose", default='OFF', help="Verbose build"),
273+
parser.add_argument("--build-compiler-cpp", metavar="BUILD_COMPILER_CPP", help="C++ compiler to use to build the project")
274+
parser.add_argument("--verbose", default='OFF', help="Verbose build")
275+
parser.add_argument("--disable-fusion", action="store_true", help="Disable the kernel fusion JIT compiler")
267276

268277
args = parser.parse_args()
269278

clang/include/clang/Basic/Attr.td

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,35 +3497,55 @@ def SYCLReqdWorkGroupSize : InheritableAttr, LanguageOptionsSpecificAttr {
34973497
let HasCustomParsing = 1;
34983498
}
34993499

3500-
def WorkGroupSizeHint : InheritableAttr {
3500+
def WorkGroupSizeHint : InheritableAttr, LanguageOptionsSpecificAttr {
3501+
let Spellings = [GNU<"work_group_size_hint">,
3502+
CXX11<"sycl", "work_group_size_hint">];
3503+
let Args = [UnsignedArgument<"XDim">,
3504+
UnsignedArgument<"YDim">,
3505+
UnsignedArgument<"ZDim">];
3506+
let Subjects = SubjectList<[Function], ErrorDiag>;
3507+
let Documentation = [WorkGroupSizeHintAttrDocs];
3508+
let LangOpts = [NotSYCL];
3509+
let SupportsNonconformingLambdaSyntax = 1;
3510+
let ParseKind = "WorkGroupSizeHint";
3511+
let HasCustomParsing = 1;
3512+
}
3513+
3514+
def SYCLWorkGroupSizeHint : InheritableAttr, LanguageOptionsSpecificAttr {
35013515
let Spellings = [GNU<"work_group_size_hint">,
35023516
CXX11<"sycl", "work_group_size_hint">];
35033517
let Args = [ExprArgument<"XDim">,
35043518
ExprArgument<"YDim", /*optional*/1>,
35053519
ExprArgument<"ZDim", /*optional*/1>];
35063520
let Subjects = SubjectList<[Function], ErrorDiag>;
35073521
// In OpenCL C this attribute takes no default values whereas in SYCL it does.
3508-
// To avoid confusing diagnostics, the checks are deferred to "handleWorkGroupSizeHint".
3522+
// To avoid confusing diagnostics, the checks are deferred to
3523+
// "handleWorkGroupSizeHint".
35093524
let HasCustomParsing = 1;
35103525
let AdditionalMembers = [{
35113526
Optional<llvm::APSInt> getXDimVal() const {
3527+
// X-dimension is not optional.
35123528
if (const auto *CE = dyn_cast<ConstantExpr>(getXDim()))
35133529
return CE->getResultAsAPSInt();
35143530
return std::nullopt;
35153531
}
35163532
Optional<llvm::APSInt> getYDimVal() const {
3517-
if (const auto *CE = dyn_cast<ConstantExpr>(getYDim()))
3533+
// Y-dimension is optional so a nullptr value is allowed.
3534+
if (const auto *CE = dyn_cast_or_null<ConstantExpr>(getYDim()))
35183535
return CE->getResultAsAPSInt();
35193536
return std::nullopt;
35203537
}
35213538
Optional<llvm::APSInt> getZDimVal() const {
3522-
if (const auto *CE = dyn_cast<ConstantExpr>(getZDim()))
3539+
// Z-dimension is optional so a nullptr value is allowed.
3540+
if (const auto *CE = dyn_cast_or_null<ConstantExpr>(getZDim()))
35233541
return CE->getResultAsAPSInt();
35243542
return std::nullopt;
35253543
}
35263544
}];
35273545
let Documentation = [WorkGroupSizeHintAttrDocs];
3546+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
35283547
let SupportsNonconformingLambdaSyntax = 1;
3548+
let ParseKind = "WorkGroupSizeHint";
35293549
}
35303550

35313551
def InitPriority : InheritableAttr, TargetSpecificAttr<TargetSupportsInitPriority> {

clang/include/clang/Sema/Sema.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10997,10 +10997,10 @@ class Sema final {
1099710997
bool AllWorkGroupSizesSame(const Expr *LHSXDim, const Expr *LHSYDim,
1099810998
const Expr *LHSZDim, const Expr *RHSXDim,
1099910999
const Expr *RHSYDim, const Expr *RHSZDim);
11000-
void AddWorkGroupSizeHintAttr(Decl *D, const AttributeCommonInfo &CI,
11001-
Expr *XDim, Expr *YDim, Expr *ZDim);
11002-
WorkGroupSizeHintAttr *
11003-
MergeWorkGroupSizeHintAttr(Decl *D, const WorkGroupSizeHintAttr &A);
11000+
void AddSYCLWorkGroupSizeHintAttr(Decl *D, const AttributeCommonInfo &CI,
11001+
Expr *XDim, Expr *YDim, Expr *ZDim);
11002+
SYCLWorkGroupSizeHintAttr *
11003+
MergeSYCLWorkGroupSizeHintAttr(Decl *D, const SYCLWorkGroupSizeHintAttr &A);
1100411004
void AddIntelReqdSubGroupSize(Decl *D, const AttributeCommonInfo &CI,
1100511005
Expr *E);
1100611006
IntelReqdSubGroupSizeAttr *

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
415415
assert(CanonName.startswith("gfx") && "Invalid amdgcn canonical name");
416416
Builder.defineMacro(Twine("__") + Twine(CanonName.drop_back(2).upper()) +
417417
Twine("__"));
418+
Builder.defineMacro("__CUDA_ARCH__", "0");
418419
}
419420
if (isAMDGCN(getTriple())) {
420421
Builder.defineMacro("__amdgcn_processor__",

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,33 @@ void CodeGenFunction::EmitKernelMetadata(const FunctionDecl *FD,
613613

614614
if (const WorkGroupSizeHintAttr *A = FD->getAttr<WorkGroupSizeHintAttr>()) {
615615
llvm::Metadata *AttrMDArgs[] = {
616-
llvm::ConstantAsMetadata::get(Builder.getInt(*A->getXDimVal())),
617-
llvm::ConstantAsMetadata::get(Builder.getInt(*A->getYDimVal())),
618-
llvm::ConstantAsMetadata::get(Builder.getInt(*A->getZDimVal()))};
616+
llvm::ConstantAsMetadata::get(Builder.getInt32(A->getXDim())),
617+
llvm::ConstantAsMetadata::get(Builder.getInt32(A->getYDim())),
618+
llvm::ConstantAsMetadata::get(Builder.getInt32(A->getZDim()))};
619619
Fn->setMetadata("work_group_size_hint", llvm::MDNode::get(Context, AttrMDArgs));
620620
}
621621

622+
if (const SYCLWorkGroupSizeHintAttr *A =
623+
FD->getAttr<SYCLWorkGroupSizeHintAttr>()) {
624+
llvm::Optional<llvm::APSInt> XDimVal = A->getXDimVal();
625+
llvm::Optional<llvm::APSInt> YDimVal = A->getYDimVal();
626+
llvm::Optional<llvm::APSInt> ZDimVal = A->getZDimVal();
627+
llvm::SmallVector<llvm::Metadata *, 3> AttrMDArgs;
628+
629+
// On SYCL target the dimensions are reversed if present.
630+
if (ZDimVal)
631+
AttrMDArgs.push_back(
632+
llvm::ConstantAsMetadata::get(Builder.getInt(*ZDimVal)));
633+
if (YDimVal)
634+
AttrMDArgs.push_back(
635+
llvm::ConstantAsMetadata::get(Builder.getInt(*YDimVal)));
636+
AttrMDArgs.push_back(
637+
llvm::ConstantAsMetadata::get(Builder.getInt(*XDimVal)));
638+
639+
Fn->setMetadata("work_group_size_hint",
640+
llvm::MDNode::get(Context, AttrMDArgs));
641+
}
642+
622643
if (const ReqdWorkGroupSizeAttr *A = FD->getAttr<ReqdWorkGroupSizeAttr>()) {
623644
llvm::Metadata *AttrMDArgs[] = {
624645
llvm::ConstantAsMetadata::get(Builder.getInt32(A->getXDim())),

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9021,7 +9021,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
90219021
if (isSaveTempsEnabled()) {
90229022
// If we're saving temps and the temp file conflicts with any
90239023
// input/resulting file, then avoid overwriting.
9024-
if (!AtTopLevel) {
9024+
if (!AtTopLevel && NamedOutput == BaseName) {
90259025
bool SameFile = false;
90269026
SmallString<256> Result;
90279027
llvm::sys::fs::current_path(Result);

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,8 +2971,8 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D,
29712971
NewAttr = S.MergeSYCLIntelForcePow2DepthAttr(D, *A);
29722972
else if (const auto *A = dyn_cast<SYCLIntelInitiationIntervalAttr>(Attr))
29732973
NewAttr = S.MergeSYCLIntelInitiationIntervalAttr(D, *A);
2974-
else if (const auto *A = dyn_cast<WorkGroupSizeHintAttr>(Attr))
2975-
NewAttr = S.MergeWorkGroupSizeHintAttr(D, *A);
2974+
else if (const auto *A = dyn_cast<SYCLWorkGroupSizeHintAttr>(Attr))
2975+
NewAttr = S.MergeSYCLWorkGroupSizeHintAttr(D, *A);
29762976
else if (const auto *A = dyn_cast<SYCLIntelMaxGlobalWorkDimAttr>(Attr))
29772977
NewAttr = S.MergeSYCLIntelMaxGlobalWorkDimAttr(D, *A);
29782978
else if (const auto *BTFA = dyn_cast<BTFDeclTagAttr>(Attr))

0 commit comments

Comments
 (0)