Skip to content

Commit 15033c9

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 508b0f2 + 117641e commit 15033c9

Some content is hidden

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

60 files changed

+883
-289
lines changed

.github/workflows/linux_post_commit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ jobs:
2626
export ARGS=""
2727
;;
2828
SharedLibs)
29+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
30+
sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main"
31+
sudo apt-get update
32+
sudo apt-get install -y clang-12
2933
export ARGS="--shared-libs"
34+
export CC="clang-12"
35+
export CXX="clang++-12"
3036
;;
3137
NoAssertions)
3238
export ARGS="--no-assertions"

buildbot/dependency.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ocl_cpu_rt_ver=2020.11.11.0.04
44
# https://github.com/intel/llvm/releases/download/2020-WW45/win-oclcpuexp-2020.11.11.0.04_rel.zip
55
ocl_cpu_rt_ver_win=2020.11.11.0.04
66
# Same GPU driver supports Level Zero and OpenCL
7-
# https://github.com/intel/compute-runtime/releases/tag/21.01.18793
8-
ocl_gpu_rt_ver=21.01.18793
7+
# https://github.com/intel/compute-runtime/releases/tag/21.02.18820
8+
ocl_gpu_rt_ver=21.02.18820
99
# Same GPU driver supports Level Zero and OpenCL
1010
# https://downloadmirror.intel.com/30066/a08/igfx_win10_100.9030.zip
1111
ocl_gpu_rt_ver_win=27.20.100.9030
@@ -26,7 +26,7 @@ ocloc_ver_win=27.20.100.8935
2626
[DRIVER VERSIONS]
2727
cpu_driver_lin=2020.11.11.0.04
2828
cpu_driver_win=2020.11.11.0.04
29-
gpu_driver_lin=21.01.18793
29+
gpu_driver_lin=21.02.18820
3030
gpu_driver_win=27.20.100.9030
3131
fpga_driver_lin=2020.11.11.0.04
3232
fpga_driver_win=2020.11.11.0.04

clang/include/clang/Basic/Attr.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,13 +1180,17 @@ def SYCLRegisterNum : InheritableAttr {
11801180
let Documentation = [SYCLRegisterNumDocs];
11811181
}
11821182

1183-
// Used to mark ESIMD kernel pointer parameters originating from accessors.
1183+
// Used by FE to mark ESIMD kernel pointer parameters which correspond to the
1184+
// original lambda's captured accessors. FE turns the attribute to some metadata
1185+
// required by the ESIMD Back-End.
1186+
// Not supposed to be used directly in the source - SYCL device compiler FE
1187+
// automatically adds it for ESIMD kernels, hence undocumented.
11841188
def SYCLSimdAccessorPtr : InheritableAttr {
11851189
// No spelling, as this attribute can't be created in the source code.
11861190
let Spellings = [];
11871191
let Subjects = SubjectList<[ParmVar]>;
11881192
let LangOpts = [SYCLExplicitSIMD];
1189-
let Documentation = [SYCLSimdAccessorPtrDocs];
1193+
let Documentation = [Undocumented];
11901194
}
11911195

11921196
def SYCLScope : Attr {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -380,18 +380,6 @@ def SYCLRegisterNumDocs : Documentation {
380380
}];
381381
}
382382

383-
def SYCLSimdAccessorPtrDocs : Documentation {
384-
let Category = DocCatVariable;
385-
let Content = [{
386-
The ``__attribute__((esimd_acc_ptr))`` attribute is used by FE to mark ESIMD
387-
kernel pointer parameters which correspond to the original
388-
lambda's captured accessors. FE turns the attribute to some metadata
389-
required by the ESIMD Back-End.
390-
Not supposed to be used directly in the source - SYCL device compiler FE
391-
automatically adds it for ESIMD kernels.
392-
}];
393-
}
394-
395383
def C11NoReturnDocs : Documentation {
396384
let Category = DocCatFunction;
397385
let Content = [{

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ void SYCL::constructLLVMForeachCommand(Compilation &C, const JobAction &JA,
9595
Foreach, ForeachArgs, None));
9696
}
9797

98+
// The list should match pre-built SYCL device library files located in
99+
// compiler package. Once we add or remove any SYCL device library files,
100+
// the list should be updated accordingly.
101+
static llvm::SmallVector<StringRef, 10> SYCLDeviceLibList{
102+
"crt",
103+
"cmath",
104+
"cmath-fp64",
105+
"complex",
106+
"complex-fp64",
107+
"fallback-cassert",
108+
"fallback-cmath",
109+
"fallback-cmath-fp64",
110+
"fallback-complex",
111+
"fallback-complex-fp64"};
112+
98113
const char *SYCL::Linker::constructLLVMLinkCommand(
99114
Compilation &C, const JobAction &JA, const InputInfo &Output,
100115
const ArgList &Args, StringRef SubArchName, StringRef OutputFilePrefix,
@@ -116,16 +131,32 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
116131
// an actual object/archive. Take that list and pass those to the linker
117132
// instead of the original object.
118133
if (JA.isDeviceOffloading(Action::OFK_SYCL)) {
119-
auto SYCLDeviceLibIter =
120-
std::find_if(InputFiles.begin(), InputFiles.end(), [](const auto &II) {
121-
StringRef InputFilename =
122-
llvm::sys::path::filename(StringRef(II.getFilename()));
123-
if (InputFilename.startswith("libsycl-") &&
124-
InputFilename.endswith(".o"))
125-
return true;
126-
return false;
127-
});
128-
bool LinkSYCLDeviceLibs = (SYCLDeviceLibIter != InputFiles.end());
134+
auto isSYCLDeviceLib = [&C](const InputInfo &II) {
135+
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
136+
StringRef LibPostfix = ".o";
137+
if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
138+
C.getDriver().IsCLMode())
139+
LibPostfix = ".obj";
140+
StringRef InputFilename =
141+
llvm::sys::path::filename(StringRef(II.getFilename()));
142+
if (!InputFilename.startswith("libsycl-") ||
143+
!InputFilename.endswith(LibPostfix) || (InputFilename.count('-') < 2))
144+
return false;
145+
size_t PureLibNameLen = InputFilename.find_last_of('-');
146+
// Skip the prefix "libsycl-"
147+
StringRef PureLibName = InputFilename.substr(8, PureLibNameLen - 8);
148+
for (const auto &L : SYCLDeviceLibList) {
149+
if (PureLibName.compare(L) == 0)
150+
return true;
151+
}
152+
return false;
153+
};
154+
size_t InputFileNum = InputFiles.size();
155+
bool LinkSYCLDeviceLibs = (InputFileNum >= 2);
156+
LinkSYCLDeviceLibs = LinkSYCLDeviceLibs && !isSYCLDeviceLib(InputFiles[0]);
157+
for (size_t Idx = 1; Idx < InputFileNum; ++Idx)
158+
LinkSYCLDeviceLibs =
159+
LinkSYCLDeviceLibs && isSYCLDeviceLib(InputFiles[Idx]);
129160
// Go through the Inputs to the link. When a listfile is encountered, we
130161
// know it is an unbundled generated list.
131162
if (LinkSYCLDeviceLibs)

clang/test/Driver/sycl-device-lib.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,11 @@
122122
// SYCL_LLVM_LINK_NO_DEVICE_LIB: clang{{.*}} "-cc1" {{.*}} "-fsycl-is-device"
123123
// SYCL_LLVM_LINK_NO_DEVICE_LIB-NOT: llvm-link{{.*}} "-only-needed"
124124
// SYCL_LLVM_LINK_NO_DEVICE_LIB: sycl-post-link{{.*}} "-symbols" "-spec-const=rt" "-o" "{{.*}}.table" "{{.*}}.bc"
125+
126+
/// ###########################################################################
127+
/// test llvm-link behavior for special user input whose filename resembles SYCL device library
128+
// RUN: touch libsycl-crt.o
129+
// RUN: %clangxx -fsycl libsycl-crt.o -### 2>&1 \
130+
// RUN: | FileCheck %s -check-prefix=SYCL_LLVM_LINK_USER_ONLY_NEEDED
131+
// SYCL_LLVM_LINK_USER_ONLY_NEEDED: llvm-link{{.*}} "{{.*}}.o" "-o" "{{.*}}.bc" "--suppress-warnings"
132+
// SYCL_LLVM_LINK_USER_ONLY_NEEDED: llvm-link{{.*}} "-only-needed" "{{.*}}" "-o" "{{.*}}.bc" "--suppress-warnings"

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,8 +1055,6 @@ class ArchiveFileHandler final : public FileHandler {
10551055
}
10561056

10571057
// Extracted objects data for archive mode.
1058-
SmallVector<std::string, 8u> ArNames;
1059-
SmallVector<SmallVector<char, 0u>, 8u> ArData;
10601058
SmallVector<NewArchiveMember, 8u> ArMembers;
10611059

10621060
// Read all children.
@@ -1119,17 +1117,17 @@ class ArchiveFileHandler final : public FileHandler {
11191117
if (Error Err = OFH.ReadBundle(OS, *Buf))
11201118
return Err;
11211119
} else if (Mode == OutputType::Archive) {
1122-
auto &Name =
1123-
ArNames.emplace_back((TT + "." + *ChildNameOrErr).str());
1124-
auto &Data = ArData.emplace_back();
1120+
// Extract the bundle to a buffer.
1121+
SmallVector<char> Data;
11251122
raw_svector_ostream ChildOS{Data};
1126-
1127-
// Extract the bundle.
11281123
if (Error Err = OFH.ReadBundle(ChildOS, *Buf))
11291124
return Err;
11301125

1131-
ArMembers.emplace_back(
1132-
MemoryBufferRef{StringRef(Data.data(), Data.size()), Name});
1126+
// Add new archive member.
1127+
NewArchiveMember &Member = ArMembers.emplace_back();
1128+
std::string Name = (TT + "." + *ChildNameOrErr).str();
1129+
Member.Buf = MemoryBuffer::getMemBufferCopy(ChildOS.str(), Name);
1130+
Member.MemberName = Member.Buf->getBufferIdentifier();
11331131
}
11341132
if (Error Err = OFH.ReadBundleEnd(*Buf))
11351133
return Err;
@@ -1551,7 +1549,7 @@ int main(int argc, const char **argv) {
15511549
return 0;
15521550
}
15531551

1554-
if (OutputFileNames.getNumOccurrences() == 0) {
1552+
if (OutputFileNames.getNumOccurrences() == 0 && !CheckSection) {
15551553
reportError(createStringError(
15561554
errc::invalid_argument,
15571555
"for the --outputs option: must be specified at least once!"));
@@ -1662,6 +1660,15 @@ int main(int argc, const char **argv) {
16621660
++Index;
16631661
}
16641662

1663+
if (CheckSection) {
1664+
Expected<bool> Res = CheckBundledSection();
1665+
if (!Res) {
1666+
reportError(Res.takeError());
1667+
return 1;
1668+
}
1669+
return !*Res;
1670+
}
1671+
16651672
// Host triple is not really needed for unbundling operation, so do not
16661673
// treat missing host triple as error if we do unbundling.
16671674
if ((Unbundle && HostTargetNum > 1) || (!Unbundle && HostTargetNum != 1)) {

libdevice/cmake/modules/SYCLLibdevice.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ set(obj_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
22
if (WIN32)
33
set(lib-suffix obj)
44
set(spv_binary_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
5-
set(lib_crt_source msvc_wrapper.cpp)
65
else()
76
set(lib-suffix o)
87
set(spv_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
9-
set(lib_crt_source glibc_wrapper.cpp)
108
endif()
119
set(clang $<TARGET_FILE:clang>)
1210

@@ -33,9 +31,9 @@ set(devicelib-obj-file ${obj_binary_dir}/libsycl-crt.${lib-suffix})
3331
add_custom_command(OUTPUT ${devicelib-obj-file}
3432
COMMAND ${clang} -fsycl -c
3533
${compile_opts} ${sycl_targets_opt}
36-
${CMAKE_CURRENT_SOURCE_DIR}/${lib_crt_source}
34+
${CMAKE_CURRENT_SOURCE_DIR}/crt_wrapper.cpp
3735
-o ${devicelib-obj-file}
38-
MAIN_DEPENDENCY ${lib_crt_source}
36+
MAIN_DEPENDENCY crt_wrapper.cpp
3937
DEPENDS wrapper.h device.h spirv_vars.h clang clang-offload-bundler
4038
VERBATIM)
4139

libdevice/msvc_wrapper.cpp renamed to libdevice/crt_wrapper.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//==--- msvc_wrapper.cpp - wrappers for Microsoft C library functions ------==//
1+
//==------ crt_wrapper.cpp - wrappers for libc internal functions ----------==//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,6 +9,7 @@
99
#include "wrapper.h"
1010

1111
#ifdef __SPIR__
12+
#if defined(_WIN32)
1213
// Truncates a wide (16 or 32 bit) string (wstr) into an ASCII string (str).
1314
// Any non-ASCII characters are replaced by question mark '?'.
1415
static void __truncate_wchar_char_str(const wchar_t *wstr, char *str,
@@ -37,4 +38,15 @@ void _wassert(const wchar_t *wexpr, const wchar_t *wfile, unsigned line) {
3738
__spirv_LocalInvocationId_x(), __spirv_LocalInvocationId_y(),
3839
__spirv_LocalInvocationId_z());
3940
}
41+
#else
42+
DEVICE_EXTERN_C
43+
void __assert_fail(const char *expr, const char *file, unsigned int line,
44+
const char *func) {
45+
__devicelib_assert_fail(
46+
expr, file, line, func, __spirv_GlobalInvocationId_x(),
47+
__spirv_GlobalInvocationId_y(), __spirv_GlobalInvocationId_z(),
48+
__spirv_LocalInvocationId_x(), __spirv_LocalInvocationId_y(),
49+
__spirv_LocalInvocationId_z());
50+
}
51+
#endif
4052
#endif // __SPIR__

libdevice/glibc_wrapper.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

llvm-spirv/.github/workflows/check-code-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Gather list of changes
4444
id: gather-list-of-changes
4545
run: |
46-
git diff -U0 --no-color ${{ github.sha }}^ > diff-to-inspect.txt
46+
git diff -U0 --no-color ${{ github.sha }}^ -- include lib > diff-to-inspect.txt
4747
if [ -s diff-to-inspect.txt ]; then
4848
# Here we set an output of our step, which is used later to either
4949
# perform or skip further steps, i.e. there is no sense to install

llvm-spirv/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![Build Status](https://travis-ci.org/KhronosGroup/SPIRV-LLVM-Translator.svg?branch=master)](https://travis-ci.org/KhronosGroup/SPIRV-LLVM-Translator)
44

5-
![Out-of-tree build & tests](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/workflows/Out-of-tree%20build%20&%20tests/badge.svg?branch=master&event=schedule)
6-
![In-tree build & tests](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/workflows/In-tree%20build%20&%20tests/badge.svg?branch=master&event=schedule)
5+
[![Out-of-tree build & tests](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/workflows/Out-of-tree%20build%20&%20tests/badge.svg?branch=master&event=schedule)](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/actions?query=workflow%3A%22Out-of-tree+build+%26+tests%22+event%3Aschedule)
6+
[![In-tree build & tests](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/workflows/In-tree%20build%20&%20tests/badge.svg?branch=master&event=schedule)](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/actions?query=workflow%3A%22In-tree+build+%26+tests%22+event%3Aschedule)
77

88
This repository contains source code for the LLVM/SPIR-V Bi-Directional Translator, a library and tool for translation between LLVM IR and [SPIR-V](https://www.khronos.org/registry/spir-v/).
99

llvm-spirv/docs/SPIRVRepresentationInLLVM.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Overview
88
========
99

1010
As one of the goals of SPIR-V is to `"map easily to other IRs, including LLVM
11-
IR" <https://cvs.khronos.org/svn/repos/SPIRV/trunk/specs/SPIRV.html#_goals>`_,
11+
IR" <https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#_goals>`_,
1212
most of SPIR-V entities (global variables, constants, types, functions, basic
1313
blocks, instructions) have straightforward counterparts in LLVM. Therefore the
1414
focus of this document is those entities in SPIR-V which do not map to LLVM in
@@ -81,7 +81,7 @@ Some SPIR-V instructions which can be included in basic blocks do not have
8181
corresponding LLVM instructions or intrinsics. These SPIR-V instructions are
8282
represented by function calls in LLVM. The function corresponding to a SPIR-V
8383
instruction is termed SPIR-V builtin function and its name is `IA64 mangled
84-
<https://mentorembedded.github.io/cxx-abi/abi.html#mangling>`_ with extensions
84+
<https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling>`_ with extensions
8585
for SPIR-V specific types. The unmangled name of a SPIR-V builtin function
8686
follows the convention
8787

@@ -209,7 +209,7 @@ following format:
209209

210210
.. code-block:: llvm
211211
212-
!spirv.<OpCodeName> = !{!<InstructionMetadata1>, <InstructionMetadata2>, ..}
212+
!spirv.<OpCodeName> = !{!<InstructionMetadata1>, !<InstructionMetadata2>, ..}
213213
!<InstructionMetadata1> = !{<Operand1>, <Operand2>, ..}
214214
!<InstructionMetadata2> = !{<Operand1>, <Operand2>, ..}
215215

llvm-spirv/include/LLVMSPIRVLib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace SPIRV {
7474
class SPIRVModule;
7575

7676
/// \brief Check if a string contains SPIR-V binary.
77-
bool isSpirvBinary(std::string &Img);
77+
bool isSpirvBinary(const std::string &Img);
7878

7979
#ifdef _SPIRV_SUPPORT_TEXT_FMT
8080
/// \brief Convert SPIR-V between binary and internal textual formats.

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,9 +1305,11 @@ Instruction *mutateCallInstOCL(
13051305
Module *M, CallInst *CI,
13061306
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
13071307
ArgMutate,
1308-
std::function<Instruction *(CallInst *)> RetMutate, AttributeList *Attrs) {
1308+
std::function<Instruction *(CallInst *)> RetMutate, AttributeList *Attrs,
1309+
bool TakeFuncName) {
13091310
OCLBuiltinFuncMangleInfo BtnInfo(CI->getCalledFunction());
1310-
return mutateCallInst(M, CI, ArgMutate, RetMutate, &BtnInfo, Attrs);
1311+
return mutateCallInst(M, CI, ArgMutate, RetMutate, &BtnInfo, Attrs,
1312+
TakeFuncName);
13111313
}
13121314

13131315
static std::pair<StringRef, StringRef>

llvm-spirv/lib/SPIRV/OCLUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ Instruction *mutateCallInstOCL(
468468
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
469469
ArgMutate,
470470
std::function<Instruction *(CallInst *)> RetMutate,
471-
AttributeList *Attrs = nullptr);
471+
AttributeList *Attrs = nullptr, bool TakeFuncName = false);
472472

473473
/// Check if instruction is bitcast from spirv.ConstantSampler to spirv.Sampler
474474
bool isSamplerInitializer(Instruction *Inst);

0 commit comments

Comments
 (0)