Skip to content

Commit 4657e3b

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into sycl
2 parents 1b2bcc7 + 844d7b6 commit 4657e3b

File tree

58 files changed

+2017
-1172
lines changed

Some content is hidden

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

58 files changed

+2017
-1172
lines changed

clang/lib/CodeGen/CGDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ llvm::Constant *CodeGenModule::getOrCreateStaticVarDecl(
266266
// OpenCL/SYCL variables in local address space and CUDA shared
267267
// variables cannot have an initializer.
268268
llvm::Constant *Init = nullptr;
269-
if (Ty.getAddressSpace() == LangAS::opencl_local ||
270-
Ty.getAddressSpace() == LangAS::sycl_local ||
269+
if (AS == LangAS::opencl_local || AS == LangAS::sycl_local ||
271270
D.hasAttr<CUDASharedAttr>() || D.hasAttr<LoaderUninitializedAttr>())
272271
Init = llvm::UndefValue::get(LTy);
273272
else

clang/lib/Driver/Driver.cpp

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5551,6 +5551,59 @@ class OffloadingActionBuilder final {
55515551
/*BoundArch*/ nullptr, ActiveOffloadKinds);
55525552
return C.MakeAction<OffloadAction>(HDep, DDeps);
55535553
}
5554+
5555+
void unbundleStaticArchives(Compilation &C, DerivedArgList &Args,
5556+
DeviceActionBuilder::PhasesTy &PL) {
5557+
if (!Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
5558+
return;
5559+
5560+
// Go through all of the args, and create a Linker specific argument list.
5561+
// When dealing with fat static archives each archive is individually
5562+
// unbundled.
5563+
SmallVector<const char *, 16> LinkArgs(getLinkerArgs(C, Args));
5564+
const llvm::opt::OptTable &Opts = C.getDriver().getOpts();
5565+
auto unbundleStaticLib = [&](types::ID T, const StringRef &A) {
5566+
Arg *InputArg = MakeInputArg(Args, Opts, Args.MakeArgString(A));
5567+
Action *Current = C.MakeAction<InputAction>(*InputArg, T);
5568+
addHostDependenceToDeviceActions(Current, InputArg, Args);
5569+
addDeviceDependencesToHostAction(Current, InputArg, phases::Link,
5570+
PL.back(), PL);
5571+
};
5572+
for (StringRef LA : LinkArgs) {
5573+
// At this point, we will process the archives for FPGA AOCO and
5574+
// individual archive unbundling for Windows.
5575+
if (!isStaticArchiveFile(LA))
5576+
continue;
5577+
// FPGA AOCX/AOCR files are archives, but we do not want to unbundle them
5578+
// here as they have already been unbundled and processed for linking.
5579+
// TODO: The multiple binary checks for FPGA types getting a little out
5580+
// of hand. Improve this by doing a single scan of the args and holding
5581+
// that in a data structure for reference.
5582+
if (hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCX) ||
5583+
hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCR) ||
5584+
hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCR_EMU))
5585+
continue;
5586+
// For offload-static-libs we add an unbundling action for each static
5587+
// archive which produces list files with extracted objects. Device lists
5588+
// are then added to the appropriate device link actions and host list is
5589+
// ignored since we are adding offload-static-libs as normal libraries to
5590+
// the host link command.
5591+
if (hasOffloadSections(C, LA, Args)) {
5592+
// Pass along the static libraries to check if we need to add them for
5593+
// unbundling for FPGA AOT static lib usage. Uses FPGA aoco type to
5594+
// differentiate if aoco unbundling is needed. Unbundling of aoco is
5595+
// not needed for emulation, as these are treated as regular archives.
5596+
if (!C.getDriver().isFPGAEmulationMode())
5597+
unbundleStaticLib(types::TY_FPGA_AOCO, LA);
5598+
// Do not unbundle any AOCO archive as a regular archive when we are
5599+
// in FPGA Hardware/Simulation mode.
5600+
if (!C.getDriver().isFPGAEmulationMode() &&
5601+
hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCO))
5602+
continue;
5603+
unbundleStaticLib(types::TY_Archive, LA);
5604+
}
5605+
}
5606+
}
55545607
};
55555608
} // anonymous namespace.
55565609

@@ -5892,52 +5945,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
58925945
if (!LinkerInputs.empty() && C.getDriver().getOffloadStaticLibSeen())
58935946
OffloadBuilder.addDeviceLinkDependenciesFromHost(LinkerInputs);
58945947

5895-
// Go through all of the args, and create a Linker specific argument list.
5896-
// When dealing with fat static archives each archive is individually
5897-
// unbundled.
5898-
SmallVector<const char *, 16> LinkArgs(getLinkerArgs(C, Args));
5899-
const llvm::opt::OptTable &Opts = getOpts();
5900-
auto unbundleStaticLib = [&](types::ID T, const StringRef &A) {
5901-
Arg *InputArg = MakeInputArg(Args, Opts, Args.MakeArgString(A));
5902-
Action *Current = C.MakeAction<InputAction>(*InputArg, T);
5903-
OffloadBuilder.addHostDependenceToDeviceActions(Current, InputArg, Args);
5904-
OffloadBuilder.addDeviceDependencesToHostAction(
5905-
Current, InputArg, phases::Link, PL.back(), PL);
5906-
};
5907-
for (StringRef LA : LinkArgs) {
5908-
// At this point, we will process the archives for FPGA AOCO and individual
5909-
// archive unbundling for Windows.
5910-
if (!isStaticArchiveFile(LA))
5911-
continue;
5912-
// FPGA AOCX/AOCR files are archives, but we do not want to unbundle them
5913-
// here as they have already been unbundled and processed for linking.
5914-
// TODO: The multiple binary checks for FPGA types getting a little out
5915-
// of hand. Improve this by doing a single scan of the args and holding
5916-
// that in a data structure for reference.
5917-
if (hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCX) ||
5918-
hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCR) ||
5919-
hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCR_EMU))
5920-
continue;
5921-
// For offload-static-libs we add an unbundling action for each static
5922-
// archive which produces list files with extracted objects. Device lists
5923-
// are then added to the appropriate device link actions and host list is
5924-
// ignored since we are adding offload-static-libs as normal libraries to
5925-
// the host link command.
5926-
if (hasOffloadSections(C, LA, Args)) {
5927-
// Pass along the static libraries to check if we need to add them for
5928-
// unbundling for FPGA AOT static lib usage. Uses FPGA aoco type to
5929-
// differentiate if aoco unbundling is needed. Unbundling of aoco is not
5930-
// needed for emulation, as these are treated as regular archives.
5931-
if (!C.getDriver().isFPGAEmulationMode())
5932-
unbundleStaticLib(types::TY_FPGA_AOCO, LA);
5933-
// Do not unbundle any AOCO archive as a regular archive when we are
5934-
// in FPGA Hardware/Simulation mode.
5935-
if (!C.getDriver().isFPGAEmulationMode() &&
5936-
hasFPGABinary(C, LA.str(), types::TY_FPGA_AOCO))
5937-
continue;
5938-
unbundleStaticLib(types::TY_Archive, LA);
5939-
}
5940-
}
5948+
OffloadBuilder.unbundleStaticArchives(C, Args, PL);
59415949

59425950
// For an FPGA archive, we add the unbundling step above to take care of
59435951
// the device side, but also unbundle here to extract the host side
@@ -5973,7 +5981,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
59735981
if (UnbundlerInput && !PL.empty()) {
59745982
if (auto *IA = dyn_cast<InputAction>(UnbundlerInput)) {
59755983
std::string FileName = IA->getInputArg().getAsString(Args);
5976-
Arg *InputArg = MakeInputArg(Args, Opts, FileName);
5984+
Arg *InputArg = MakeInputArg(Args, getOpts(), FileName);
59775985
OffloadBuilder.addHostDependenceToDeviceActions(UnbundlerInput,
59785986
InputArg, Args);
59795987
OffloadBuilder.addDeviceDependencesToHostAction(

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,8 +1566,8 @@ void KernelObjVisitor::visitArray(const CXXRecordDecl *Owner, FieldDecl *Field,
15661566
// A type to check the validity of all of the argument types.
15671567
class SyclKernelFieldChecker : public SyclKernelFieldHandler {
15681568
bool IsInvalid = false;
1569-
bool IsSIMD = false;
15701569
DiagnosticsEngine &Diag;
1570+
bool IsSIMD = false;
15711571
// Check whether the object should be disallowed from being copied to kernel.
15721572
// Return true if not copyable, false if copyable.
15731573
bool checkNotCopyableToKernel(const FieldDecl *FD, QualType FieldTy) {

clang/test/CodeGenSYCL/wg_init.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
2+
3+
// This test checks that a local variable initialized within a
4+
// parallel_for_work_group scope is initialized as an UndefValue in addrspace(3)
5+
// in LLVM IR.
6+
7+
#include "Inputs/sycl.hpp"
8+
9+
using namespace sycl;
10+
11+
int main() {
12+
queue q;
13+
q.submit([&](handler &h) {
14+
h.parallel_for_work_group<class kernel>(
15+
range<1>{1}, range<1>{1}, [=](group<1> G) {
16+
int WG_VAR = 10;
17+
});
18+
});
19+
return 0;
20+
}
21+
22+
// CHECK: @{{.*}}WG_VAR = internal addrspace(3) global {{.*}} undef, {{.*}}

clang/test/Driver/sycl-offload.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,17 @@
132132
// RUN: %clangxx -### -Wl,-rpath,%S -fsycl -fintelfpga %t_empty.o %s 2>&1 \
133133
// RUN: | FileCheck -check-prefix NO_DIR_CHECK %s
134134
// NO_DIR_CHECK-NOT: clang-offload-bundler: error: '{{.*}}': Is a directory
135+
136+
// Device section checking only occur when offloading is enabled
137+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl %S/Inputs/SYCL/liblin64.a %s 2>&1 \
138+
// RUN: | FileCheck -check-prefix CHECK_SECTION %s
139+
// RUN: %clangxx -### -target x86_64-unknown-linux-gnu %S/Inputs/SYCL/liblin64.a %s 2>&1 \
140+
// RUN: | FileCheck -check-prefix NO_CHECK_SECTION %s
141+
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=host-x86_64-unknown-linux-gnu"{{.*}} "-check-section"
142+
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr-intel-unknown"{{.*}} "-check-section"
143+
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown"{{.*}} "-check-section"
144+
// CHECK_SECTION: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr_emu-intel-unknown"{{.*}} "-check-section"
145+
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=host-x86_64-unknown-linux-gnu"{{.*}} "-check-section"
146+
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr-intel-unknown"{{.*}} "-check-section"
147+
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown"{{.*}} "-check-section"
148+
// NO_CHECK_SECTION-NOT: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocr_emu-intel-unknown"{{.*}} "-check-section"

libclc/amdgcn-amdhsa/libspirv/group/collectives.cl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ __clc__get_group_scratch_double() __asm("__clc__get_group_scratch_double");
4242
_CLC_DECL TYPE _Z28__spirv_SubgroupShuffleINTELI##TYPE_MANGLED##ET_S0_j( \
4343
TYPE, int); \
4444
_CLC_DECL TYPE \
45-
_Z30__spirv_SubgroupShuffleUpINTELI##TYPE_MANGLED##ET_S0_S0_j(TYPE, \
46-
int);
45+
_Z30__spirv_SubgroupShuffleUpINTELI##TYPE_MANGLED##ET_S0_S0_j( \
46+
TYPE, TYPE, unsigned int);
4747

4848
__CLC_DECLARE_SHUFFLES(char, a);
4949
__CLC_DECLARE_SHUFFLES(unsigned char, h);
@@ -72,7 +72,8 @@ __CLC_DECLARE_SHUFFLES(double, d);
7272
/* Can't use XOR/butterfly shuffles; some lanes may be inactive */ \
7373
for (int o = 1; o < __spirv_SubgroupMaxSize(); o *= 2) { \
7474
TYPE contribution = \
75-
_Z28__spirv_SubgroupShuffleINTELI##TYPE_MANGLED##ET_S0_j(x, o); \
75+
_Z30__spirv_SubgroupShuffleUpINTELI##TYPE_MANGLED##ET_S0_S0_j(x, x, \
76+
o); \
7677
bool inactive = (sg_lid < o); \
7778
contribution = (inactive) ? IDENTITY : contribution; \
7879
x = OP(x, contribution); \
@@ -90,8 +91,8 @@ __CLC_DECLARE_SHUFFLES(double, d);
9091
} /* For ExclusiveScan, shift and prepend identity */ \
9192
else if (op == ExclusiveScan) { \
9293
*carry = x; \
93-
result = \
94-
_Z30__spirv_SubgroupShuffleUpINTELI##TYPE_MANGLED##ET_S0_S0_j(x, 1); \
94+
result = _Z30__spirv_SubgroupShuffleUpINTELI##TYPE_MANGLED##ET_S0_S0_j( \
95+
x, x, 1); \
9596
if (sg_lid == 0) { \
9697
result = IDENTITY; \
9798
} \

0 commit comments

Comments
 (0)