Skip to content

Commit 49147d3

Browse files
committed
Merge branch 'sycl' into unified-interface
2 parents 3dbeadb + 20b1bea commit 49147d3

File tree

181 files changed

+3877
-1717
lines changed

Some content is hidden

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

181 files changed

+3877
-1717
lines changed

.github/workflows/gh_pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
if: github.repository == 'intel/llvm'
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
path: repo
2222
- name: Install deps

.github/workflows/sycl_containers.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest
2929
steps:
3030
- name: Checkout
31-
uses: actions/checkout@v2
31+
uses: actions/checkout@v3
3232
with:
3333
fetch-depth: 2
3434
- name: Build and Push Container
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ubuntu-latest
4848
steps:
4949
- name: Checkout
50-
uses: actions/checkout@v2
50+
uses: actions/checkout@v3
5151
with:
5252
fetch-depth: 2
5353
- name: Build and Push Container
@@ -70,7 +70,7 @@ jobs:
7070
needs: base_image_ubuntu2004
7171
steps:
7272
- name: Checkout
73-
uses: actions/checkout@v2
73+
uses: actions/checkout@v3
7474
with:
7575
fetch-depth: 2
7676
- name: Get dependencies configuration
@@ -108,7 +108,7 @@ jobs:
108108
needs: base_image_ubuntu2004
109109
steps:
110110
- name: Checkout
111-
uses: actions/checkout@v2
111+
uses: actions/checkout@v3
112112
with:
113113
fetch-depth: 2
114114
- name: Get dependencies configuration

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ jobs:
161161
- name: Pack LIT
162162
run: tar -cJf lit.tar.xz -C $GITHUB_WORKSPACE/src/llvm/utils/lit .
163163
- name: Upload toolchain
164-
uses: actions/upload-artifact@v2
164+
uses: actions/upload-artifact@v3
165165
with:
166166
name: sycl_linux_${{ inputs.build_artifact_suffix }}
167167
path: llvm_sycl.tar.xz
168168
- name: Upload LIT
169-
uses: actions/upload-artifact@v2
169+
uses: actions/upload-artifact@v3
170170
with:
171171
name: sycl_lit_${{ inputs.build_artifact_suffix }}
172172
path: lit.tar.xz
@@ -226,7 +226,7 @@ jobs:
226226
sudo -E /opt/install_drivers.sh --all
227227
fi
228228
# FIXME cached_checkout fails here, but works everywhere else
229-
- uses: actions/checkout@v2
229+
- uses: actions/checkout@v3
230230
with:
231231
persist-credentials: false
232232
path: llvm
@@ -277,7 +277,7 @@ jobs:
277277
fi
278278
# FIXME cached_checkout fails here, but works everywhere else
279279
# TODO: figure out if we remove this action
280-
- uses: actions/checkout@v2
280+
- uses: actions/checkout@v3
281281
with:
282282
path: llvm
283283
# TODO should this action be packed into container as well?

.github/workflows/sycl_macos_build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
- name: Pack toolchain
6767
run: tar -cJf llvm_sycl.tar.xz -C $GITHUB_WORKSPACE/build/install .
6868
- name: Upload toolchain
69-
uses: actions/upload-artifact@v2
69+
uses: actions/upload-artifact@v3
7070
with:
7171
name: sycl_macos_${{ inputs.build_artifact_suffix }}
7272
path: llvm_sycl.tar.xz

.github/workflows/sycl_nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ jobs:
4747
runs-on: ubuntu-latest
4848
needs: ubuntu2004_build_test
4949
steps:
50-
- uses: actions/checkout@v2
51-
- uses: actions/download-artifact@v2
50+
- uses: actions/checkout@v3
51+
- uses: actions/download-artifact@v3
5252
with:
5353
name: sycl_linux_default
5454
path: devops/

.github/workflows/sycl_post_commit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ jobs:
4444
runs-on: ubuntu-20.04
4545
if: github.repository == 'intel/llvm'
4646
steps:
47-
- uses: actions/checkout@v2
47+
- uses: actions/checkout@v3
4848
with:
4949
path: src
5050
- name: Install Ubuntu deps
5151
run: sudo apt install -y ninja-build ccache
5252
- name: Setup Cache
53-
uses: actions/cache@v2
53+
uses: actions/cache@v3
5454
id: cache
5555
with:
5656
path: ${{ github.workspace }}/cache
@@ -104,7 +104,7 @@ jobs:
104104
- name: Pack
105105
run: tar -czvf llvm_sycl.tar.gz -C $GITHUB_WORKSPACE/build/install .
106106
- name: Upload artifacts
107-
uses: actions/upload-artifact@v1
107+
uses: actions/upload-artifact@v3
108108
with:
109109
name: sycl_linux_${{ matrix.config }}
110110
path: llvm_sycl.tar.gz

.github/workflows/sycl_precommit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
steps:
3030
- name: 'PR commits + 1'
3131
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
32-
- uses: actions/checkout@v2
32+
- uses: actions/checkout@v3
3333
with:
3434
ref: ${{ github.event.pull_request.head.sha }}
3535
persist-credentials: false

.github/workflows/sycl_update_gpu_driver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
if: github.repository == 'intel/llvm'
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: Update dependencies file
1515
run: |
1616
version="$(python3 devops/scripts/update_drivers.py linux)"

.github/workflows/sycl_windows_build_and_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
git config --global core.autocrlf false
2424
echo "C:\Program Files\Git\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
2525
echo "SCCACHE_DIR=D:\github\_work\cache\${{ inputs.build_cache_suffix }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
26-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v3
2727
with:
2828
path: src
2929
fetch-depth: 1
@@ -78,7 +78,7 @@ jobs:
7878
shell: bash
7979
run: cmake --build build --target deploy-sycl-toolchain
8080
- name: Upload toolchain
81-
uses: actions/upload-artifact@v2
81+
uses: actions/upload-artifact@v3
8282
with:
8383
name: sycl_windows_default
8484
path: install/**/*

.github/workflows/sync-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
if: github.repository == 'intel/llvm'
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
with:
1313
# persist-credentials: false allows us to use our own credentials for
1414
# pushing to the repository. Otherwise, the default github actions token

clang/include/clang/Basic/Attr.td

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,20 @@ def SYCLAddIRAttrCommonMembers : SYCLAddIRAttrMemberCodeHolder<[{
16031603
if (ValueQType->isIntegralOrEnumerationType() ||
16041604
ValueQType->isFloatingType())
16051605
return Value.getAsString(Context, ValueQType);
1606+
if (ValueQType->isArrayType() &&
1607+
(ValueQType->getArrayElementTypeNoTypeQual()->isCharType() ||
1608+
ValueQType->getArrayElementTypeNoTypeQual()
1609+
->isIntegralOrEnumerationType())) {
1610+
SmallString<10> StrBuffer;
1611+
for (unsigned I = 0; I < Value.getArraySize(); ++I) {
1612+
const APValue &ArrayElem = Value.getArrayInitializedElt(I);
1613+
char C = static_cast<char>(ArrayElem.getInt().getExtValue());
1614+
if (C == 0)
1615+
break;
1616+
StrBuffer += C;
1617+
}
1618+
return std::string(StrBuffer);
1619+
}
16061620
return None;
16071621
}
16081622

@@ -1628,6 +1642,33 @@ def SYCLAddIRAttrCommonMembers : SYCLAddIRAttrMemberCodeHolder<[{
16281642
ValueE->getType()->isSignedIntegerType());
16291643
return std::string(IntegerStrBuffer);
16301644
}
1645+
if (const auto *InitListE = dyn_cast<InitListExpr>(ValueE)) {
1646+
if (InitListE->isStringLiteralInit()) {
1647+
const Expr *StringInitE = InitListE->getInit(0)->IgnoreParenImpCasts();
1648+
return getValidAttributeValueAsString(StringInitE, Context);
1649+
}
1650+
1651+
SmallString<10> StrBuffer;
1652+
for (const auto *InitE : InitListE->inits()) {
1653+
const Expr *InitNoImpCastE = InitE->IgnoreParenImpCasts();
1654+
char C = 0;
1655+
if (const auto *CharacterVal =
1656+
dyn_cast<CharacterLiteral>(InitNoImpCastE))
1657+
C = static_cast<char>(CharacterVal->getValue());
1658+
else if (const auto *IntegerVal =
1659+
dyn_cast<IntegerLiteral>(InitNoImpCastE))
1660+
C = static_cast<char>(IntegerVal->getValue().getSExtValue());
1661+
else
1662+
return None;
1663+
1664+
// Null terminator will end the string reading.
1665+
if (C == 0)
1666+
break;
1667+
1668+
StrBuffer += C;
1669+
}
1670+
return std::string(StrBuffer);
1671+
}
16311672

16321673
const auto *ValueCE = dyn_cast<ConstantExpr>(ValueE);
16331674
if (!ValueCE)
@@ -3427,6 +3468,7 @@ def WorkGroupSizeHint : InheritableAttr {
34273468
}
34283469
}];
34293470
let Documentation = [WorkGroupSizeHintAttrDocs];
3471+
let SupportsNonconformingLambdaSyntax = 1;
34303472
}
34313473

34323474
def InitPriority : InheritableAttr, TargetSpecificAttr<TargetSupportsInitPriority> {

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11887,6 +11887,9 @@ def err_sycl_add_ir_attribute_invalid_value : Error<
1188711887
def err_sycl_add_ir_attribute_invalid_filter : Error<
1188811888
"initializer list in the first argument of %0 must contain only string "
1188911889
"literals">;
11890+
def warn_sycl_old_and_new_kernel_attributes : Warning<
11891+
"kernel has both attribute %0 and kernel properties; conflicting properties "
11892+
"are ignored">, InGroup<IgnoredAttributes>;
1189011893

1189111894
// errors of expect.with.probability
1189211895
def err_probability_not_constant_float : Error<

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ LANGOPT(IntelFPGA , 1, 0, "Perform ahead-of-time compilation for FPGA")
279279
LANGOPT(SYCLAllowFuncPtr , 1, 0, "Allow function pointers in SYCL device code")
280280
LANGOPT(SYCLStdLayoutKernelParams, 1, 0, "Enable standard layout requirement for SYCL kernel parameters")
281281
LANGOPT(SYCLUnnamedLambda , 1, 0, "Allow unnamed lambda SYCL kernels")
282+
LANGOPT(SYCLForceInlineKernelLambda , 1, 0, "Force inline SYCL kernel lambdas in entry point")
282283
LANGOPT(SYCLESIMDForceStatelessMem, 1, 0, "Make accessors use USM memory in ESIMD kernels")
283284
ENUM_LANGOPT(SYCLVersion , SYCLMajorVersion, 2, SYCL_None, "Version of the SYCL standard used")
284285
LANGOPT(DeclareSPIRVBuiltins, 1, 0, "Declare SPIR-V builtin functions")

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,6 +2942,12 @@ defm sycl_unnamed_lambda
29422942
" >= clang::LangOptions::SYCLMajorVersion::SYCL_2020")>,
29432943
PosFlag<SetTrue, [], "Allow">, NegFlag<SetFalse, [], "Disallow">,
29442944
BothFlags<[CC1Option, CoreOption], " unnamed SYCL lambda kernels">>;
2945+
defm sycl_force_inline_kernel_lambda
2946+
: BoolFOption<
2947+
"sycl-force-inline-kernel-lambda", LangOpts<"SYCLForceInlineKernelLambda">,
2948+
DefaultTrue,
2949+
PosFlag<SetTrue, [], "Allow">, NegFlag<SetFalse, [], "Disallow">,
2950+
BothFlags<[CC1Option, CoreOption], " force inline SYCL kernels lambda in entry point">>;
29452951
def fsycl_help_EQ : Joined<["-"], "fsycl-help=">,
29462952
Flags<[NoXarchOption, CoreOption]>, HelpText<"Emit help information from the "
29472953
"related offline compilation tool. Valid values: all, fpga, gen, x86_64.">,

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10984,6 +10984,7 @@ class Sema final {
1098410984
SYCLIntelMaxWorkGroupSizeAttr *
1098510985
MergeSYCLIntelMaxWorkGroupSizeAttr(Decl *D,
1098610986
const SYCLIntelMaxWorkGroupSizeAttr &A);
10987+
void CheckSYCLAddIRAttributesFunctionAttrConflicts(Decl *D);
1098710988
SYCLAddIRAttributesFunctionAttr *MergeSYCLAddIRAttributesFunctionAttr(
1098810989
Decl *D, const SYCLAddIRAttributesFunctionAttr &A);
1098910990
void AddSYCLAddIRAttributesFunctionAttr(Decl *D,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5123,6 +5123,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51235123
CmdArgs.push_back("-sycl-std=2020");
51245124
}
51255125

5126+
if (!Args.hasFlag(options::OPT_fsycl_force_inline_kernel_lambda,
5127+
options::OPT_fno_sycl_force_inline_kernel_lambda, true))
5128+
CmdArgs.push_back("-fno-sycl-force-inline-kernel-lambda");
5129+
51265130
if (!Args.hasFlag(options::OPT_fsycl_unnamed_lambda,
51275131
options::OPT_fno_sycl_unnamed_lambda, true))
51285132
CmdArgs.push_back("-fno-sycl-unnamed-lambda");
@@ -9407,9 +9411,19 @@ void OffloadDeps::constructJob(Compilation &C, const JobAction &JA,
94079411
Targets += ',';
94089412
Targets += Action::GetOffloadKindName(Dep.DependentOffloadKind);
94099413
Targets += '-';
9410-
std::string NormalizedTriple =
9411-
Dep.DependentToolChain->getTriple().normalize();
9412-
Targets += NormalizedTriple;
9414+
// When -fsycl-force-target is used, this value overrides the expected
9415+
// output type we are creating deps for.
9416+
if (Dep.DependentOffloadKind == Action::OFK_SYCL &&
9417+
TCArgs.hasArg(options::OPT_fsycl_force_target_EQ)) {
9418+
StringRef Val(
9419+
TCArgs.getLastArg(options::OPT_fsycl_force_target_EQ)->getValue());
9420+
llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val));
9421+
Targets += TT.normalize();
9422+
} else {
9423+
std::string NormalizedTriple =
9424+
Dep.DependentToolChain->getTriple().normalize();
9425+
Targets += NormalizedTriple;
9426+
}
94139427
if ((Dep.DependentOffloadKind == Action::OFK_HIP ||
94149428
Dep.DependentOffloadKind == Action::OFK_SYCL) &&
94159429
!Dep.DependentBoundArch.empty()) {

clang/lib/Sema/SPIRVBuiltins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,12 @@ foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
840840
def : SPVBuiltin<"GenericCastToPtrExplicit", [PointerType<Char, AS>, PointerType<Char, GenericAS>], Attr.Const>;
841841
}
842842

843+
foreach Ty = [Void, ConstType<Void>, VolatileType<Void>, VolatileType<ConstType<Void>>] in {
844+
def : SPVBuiltin<"GenericCastToPtrExplicit_ToGlobal", [PointerType<Ty, GlobalAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
845+
def : SPVBuiltin<"GenericCastToPtrExplicit_ToLocal", [PointerType<Ty, LocalAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
846+
def : SPVBuiltin<"GenericCastToPtrExplicit_ToPrivate", [PointerType<Ty, PrivateAS>, PointerType<Ty, DefaultAS>, Int], Attr.Const>;
847+
}
848+
843849
foreach Type = TLFloat.List in {
844850
foreach v = [2, 3, 4, 8, 16] in {
845851
def : SPVBuiltin<"VectorTimesScalar", [VectorType<Type, v>, VectorType<Type, v>, Type], Attr.Const>;

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7808,6 +7808,22 @@ static bool checkSYCLAddIRAttributesMergeability(const AddIRAttrT &NewAttr,
78087808
return false;
78097809
}
78107810

7811+
void Sema::CheckSYCLAddIRAttributesFunctionAttrConflicts(Decl *D) {
7812+
const auto *AddIRFuncAttr = D->getAttr<SYCLAddIRAttributesFunctionAttr>();
7813+
if (!AddIRFuncAttr || AddIRFuncAttr->args_size() == 0 ||
7814+
hasDependentExpr(AddIRFuncAttr->args_begin(), AddIRFuncAttr->args_size()))
7815+
return;
7816+
7817+
// If there are potentially conflicting attributes, we issue a warning.
7818+
for (const auto *Attr : std::vector<AttributeCommonInfo *>{
7819+
D->getAttr<ReqdWorkGroupSizeAttr>(),
7820+
D->getAttr<IntelReqdSubGroupSizeAttr>(),
7821+
D->getAttr<WorkGroupSizeHintAttr>()})
7822+
if (Attr)
7823+
Diag(Attr->getLoc(), diag::warn_sycl_old_and_new_kernel_attributes)
7824+
<< Attr;
7825+
}
7826+
78117827
SYCLAddIRAttributesFunctionAttr *Sema::MergeSYCLAddIRAttributesFunctionAttr(
78127828
Decl *D, const SYCLAddIRAttributesFunctionAttr &A) {
78137829
if (const auto *ExistingAttr =

0 commit comments

Comments
 (0)