Skip to content

Commit 162703f

Browse files
authored
Merge branch 'sycl' into buildbot
2 parents 97a7858 + 5d0d034 commit 162703f

File tree

15 files changed

+100
-893
lines changed

15 files changed

+100
-893
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
255255
"The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.">;
256256
def err_drv_expecting_fsycl_with_sycl_opt : Error<
257257
"The option %0 must be used in conjunction with -fsycl to enable offloading.">;
258+
def err_drv_fsycl_with_c_type : Error<
259+
"The option %0%1 must not be used in conjunction with -fsycl which expects C++ source.">;
258260
def warn_drv_omp_offload_target_duplicate : Warning<
259261
"The OpenMP offloading target '%0' is similar to target '%1' already specified - will be ignored.">,
260262
InGroup<OpenMPTarget>;

clang/lib/Driver/Driver.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,15 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
769769
}
770770
return SYCLArg;
771771
};
772+
773+
// Emit an error if c-compilation is forced in -fsycl mode
774+
if (HasValidSYCLRuntime)
775+
for (StringRef XValue : C.getInputArgs().getAllArgValues(options::OPT_x)) {
776+
if (XValue == "c" || XValue == "c-header")
777+
C.getDriver().Diag(clang::diag::err_drv_fsycl_with_c_type)
778+
<< "-x " << XValue;
779+
}
780+
772781
Arg *SYCLTargets = getArgRequiringSYCLRuntime(options::OPT_fsycl_targets_EQ);
773782
Arg *SYCLLinkTargets =
774783
getArgRequiringSYCLRuntime(options::OPT_fsycl_link_targets_EQ);

clang/test/Driver/sycl-offload.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,5 +795,10 @@
795795
// LIB-NODEVICE: 1: linker, {0}, image, (host-sycl)
796796
// LIB-NODEVICE-NOT: linker, {{.*}}, spirv, (device-sycl)
797797

798+
// Checking for an error if c-compilation is forced
799+
// RUN: %clangxx -### -c -fsycl -xc %s 2>&1 | FileCheck -check-prefixes=CHECK_XC_FSYCL %s
800+
// RUN: %clangxx -### -c -fsycl -xc-header %s 2>&1 | FileCheck -check-prefixes=CHECK_XC_FSYCL %s
801+
// CHECK_XC_FSYCL: The option -x c{{.*}} must not be used in conjunction with -fsycl{{.*}}
802+
798803
// TODO: SYCL specific fail - analyze and enable
799804
// XFAIL: windows-msvc

libclc/generic/libspirv/async/async_work_group_strided_copy.inc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#define STRIDED_COPY(DST_AS, SRC_AS, DST_STRIDE, SRC_STRIDE) \
10-
size_t size = __spirv_LocalInvocationId_x() * \
11-
__spirv_LocalInvocationId_y() * \
12-
__spirv_LocalInvocationId_z(); \
13-
size_t id = (__spirv_WorkgroupSize_y() * __spirv_WorkgroupSize_z() * \
14-
__spirv_LocalInvocationId_x()) + \
15-
(__spirv_WorkgroupSize_z() * \
16-
__spirv_LocalInvocationId_y()) + \
17-
__spirv_LocalInvocationId_z(); \
18-
size_t i; \
19-
\
20-
for (i = id; i < num_gentypes; i += size) { \
21-
dst[i * DST_STRIDE] = src[i * SRC_STRIDE]; \
9+
#define STRIDED_COPY(DST_AS, SRC_AS, DST_STRIDE, SRC_STRIDE) \
10+
size_t size = __spirv_WorkgroupSize_x() * __spirv_WorkgroupSize_y() * \
11+
__spirv_WorkgroupSize_z(); \
12+
size_t id = (__spirv_WorkgroupSize_y() * __spirv_WorkgroupSize_x() * \
13+
__spirv_LocalInvocationId_z()) + \
14+
(__spirv_WorkgroupSize_x() * __spirv_LocalInvocationId_y()) + \
15+
__spirv_LocalInvocationId_x(); \
16+
size_t i; \
17+
\
18+
for (i = id; i < num_gentypes; i += size) { \
19+
dst[i * DST_STRIDE] = src[i * SRC_STRIDE]; \
2220
}
2321

2422
_CLC_OVERLOAD _CLC_DEF event_t
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; This test checks that the post-link tool produces a correct resulting file
2+
; table and a symbol file for an input module with two kernels when no code
3+
; splitting is requested.
4+
;
5+
; RUN: sycl-post-link -symbols -spec-const=rt -S %s -o %t.files.table
6+
; RUN: FileCheck %s -input-file=%t.files.table --check-prefixes CHECK-TABLE
7+
; RUN: FileCheck %s -input-file=%t.files_0.sym --match-full-lines --check-prefixes CHECK-SYM
8+
9+
define dso_local spir_kernel void @KERNEL_AAA() {
10+
; CHECK-SYM-NOT: {{[a-zA-Z0-9._@]+}}
11+
; CHECK-SYM: KERNEL_AAA
12+
entry:
13+
ret void
14+
}
15+
16+
define dso_local spir_kernel void @KERNEL_BBB() {
17+
; CHECK-SYM-NEXT: KERNEL_BBB
18+
; CHECK-SYM-EMPTY:
19+
entry:
20+
ret void
21+
}
22+
23+
; CHECK-TABLE: [Code|Properties|Symbols]
24+
; CHECK-TABLE-NEXT: {{.*}}files_0.sym
25+
; CHECK-TABLE-EMPTY:

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,51 @@ static void writeToFile(std::string Filename, std::string Content) {
121121
OS.close();
122122
}
123123

124-
// Output parameter ResKernelModuleMap is a map containing groups of kernels
125-
// with same values of the sycl-module-id attribute.
126-
// The function fills ResKernelModuleMap using input module M.
124+
// Describes scope covered by each entry in the module-kernel map populated by
125+
// the collectKernelModuleMap function.
126+
enum KernelMapEntryScope {
127+
Scope_PerKernel, // one entry per kernel
128+
Scope_PerModule, // one entry per module
129+
Scope_Global // single entry in the map for all kernels
130+
};
131+
132+
// This function decides how kernels of the input module M will be distributed
133+
// ("split") into multiple modules based on the command options and IR
134+
// attributes. The decision is recorded in the output map parameter
135+
// ResKernelModuleMap which maps some key to a group of kernels. Each such group
136+
// along with IR it depends on (globals, functions from its call graph,...) will
137+
// constitute a separate module.
127138
static void collectKernelModuleMap(
128139
Module &M, std::map<StringRef, std::vector<Function *>> &ResKernelModuleMap,
129-
bool OneKernelPerModule) {
130-
131-
constexpr char ATTR_SYCL_MODULE_ID[] = "sycl-module-id";
140+
KernelMapEntryScope EntryScope) {
132141

133142
for (auto &F : M.functions()) {
134143
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
135-
if (OneKernelPerModule) {
144+
switch (EntryScope) {
145+
case Scope_PerKernel:
136146
ResKernelModuleMap[F.getName()].push_back(&F);
137-
} else if (F.hasFnAttribute(ATTR_SYCL_MODULE_ID)) {
147+
break;
148+
case Scope_PerModule: {
149+
constexpr char ATTR_SYCL_MODULE_ID[] = "sycl-module-id";
150+
151+
// TODO It may make sense to group all kernels w/o the attribute into
152+
// a separate module rather than issuing an error. Should probably be
153+
// controlled by an option.
154+
if (!F.hasFnAttribute(ATTR_SYCL_MODULE_ID))
155+
error("no '" + Twine(ATTR_SYCL_MODULE_ID) +
156+
"' attribute in kernel '" + F.getName() +
157+
"', per-module split not possible");
138158
Attribute Id = F.getFnAttribute(ATTR_SYCL_MODULE_ID);
139159
StringRef Val = Id.getValueAsString();
140160
ResKernelModuleMap[Val].push_back(&F);
161+
break;
162+
}
163+
case Scope_Global:
164+
// the map key is not significant here
165+
ResKernelModuleMap["<GLOBAL>"].push_back(&F);
166+
break;
167+
default:
168+
llvm_unreachable("unknown scope");
141169
}
142170
}
143171
}
@@ -375,8 +403,12 @@ int main(int argc, char **argv) {
375403

376404
std::map<StringRef, std::vector<Function *>> GlobalsSet;
377405

378-
if (DoSplit || DoSymGen)
379-
collectKernelModuleMap(*MPtr, GlobalsSet, SplitMode == SPLIT_PER_KERNEL);
406+
if (DoSplit || DoSymGen) {
407+
KernelMapEntryScope Scope = Scope_Global;
408+
if (DoSplit)
409+
Scope = SplitMode == SPLIT_PER_KERNEL ? Scope_PerKernel : Scope_PerModule;
410+
collectKernelModuleMap(*MPtr, GlobalsSet, Scope);
411+
}
380412

381413
std::vector<std::unique_ptr<Module>> ResultModules;
382414
std::vector<SpecIDMapTy> ResultSpecIDMaps;

sycl/doc/GetStartedGuide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ and a wide range of compute accelerators such as GPU and FPGA.
2424
* `git` - https://git-scm.com/downloads
2525
* `cmake` version 3.2 or later - http://www.cmake.org/download/
2626
* `python` - https://www.python.org/downloads/release/python-2716/
27+
* `ninja` - https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
2728
* C++ compiler
2829
* Linux: `GCC` version 5.1.0 or later (including libstdc++) -
2930
https://gcc.gnu.org/install/

sycl/source/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ set(SYCL_SOURCES
105105
"detail/scheduler/graph_builder.cpp"
106106
"detail/spec_constant_impl.cpp"
107107
"detail/sycl_mem_obj_t.cpp"
108-
"detail/usm/clusm.cpp"
109-
"detail/usm/usm_dispatch.cpp"
110108
"detail/usm/usm_impl.cpp"
111109
"detail/util.cpp"
112110
"accessor.cpp"

sycl/source/detail/context_impl.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <detail/kernel_program_cache.hpp>
1818
#include <detail/platform_impl.hpp>
1919
#include <detail/program_manager/program_manager.hpp>
20-
#include <detail/usm/usm_dispatch.hpp>
2120

2221
#include <map>
2322
#include <memory>
@@ -152,7 +151,6 @@ class context_impl {
152151
bool MPluginInterop;
153152
bool MHostContext;
154153
bool MUseCUDAPrimaryContext;
155-
std::shared_ptr<usm::USMDispatcher> MUSMDispatch;
156154
std::map<DeviceLibExt, RT::PiProgram> MCachedLibPrograms;
157155
mutable KernelProgramCache MKernelProgramCache;
158156
};

sycl/source/detail/memory_manager.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <detail/context_impl.hpp>
1111
#include <detail/event_impl.hpp>
1212
#include <detail/queue_impl.hpp>
13-
#include <detail/usm/usm_dispatch.hpp>
1413

1514
#include <algorithm>
1615
#include <cassert>

sycl/source/detail/queue_impl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <CL/sycl/detail/pi.hpp>
1313
#include <CL/sycl/device.hpp>
1414
#include <detail/queue_impl.hpp>
15-
#include <detail/usm/usm_dispatch.hpp>
1615

1716
#include <cstring>
1817

0 commit comments

Comments
 (0)