Skip to content

Commit 1610f63

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents db46420 + bdeb3ce commit 1610f63

File tree

84 files changed

+1488
-2885
lines changed

Some content is hidden

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

84 files changed

+1488
-2885
lines changed

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void SPIRVDecorate::encode(spv_ostream &O) const {
126126
break;
127127
case internal::DecorationFuncParamDescINTEL:
128128
SPIRVDecorateFuncParamDescAttr::encodeLiterals(Encoder, Literals);
129+
break;
129130
case internal::DecorationHostAccessINTEL:
130131
SPIRVDecorateHostAccessINTELLegacy::encodeLiterals(Encoder, Literals);
131132
break;
@@ -163,6 +164,7 @@ void SPIRVDecorate::decode(std::istream &I) {
163164
break;
164165
case internal::DecorationFuncParamDescINTEL:
165166
SPIRVDecorateFuncParamDescAttr::decodeLiterals(Decoder, Literals);
167+
break;
166168
case internal::DecorationHostAccessINTEL:
167169
SPIRVDecorateHostAccessINTELLegacy::decodeLiterals(Decoder, Literals);
168170
break;

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,8 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
12801280
static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM) {
12811281
SmallVector<Function *> SpirFixupFuncs;
12821282
for (Function &F : M) {
1283-
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
1283+
if (F.getCallingConv() == CallingConv::SPIR_KERNEL &&
1284+
F.hasFnAttribute(Attribute::SanitizeAddress)) {
12841285
SpirFixupFuncs.emplace_back(&F);
12851286
}
12861287
}
@@ -1296,9 +1297,7 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM) {
12961297
Types.push_back(I->getType());
12971298
}
12981299

1299-
// New argument type: uintptr_t as(1)*, as it's allocated in USM buffer, and
1300-
// it can also be treated as a pointer point to the base address of private
1301-
// shadow memory
1300+
// New argument: uintptr_t as(1)*, which is allocated in shared USM buffer
13021301
Types.push_back(IntptrTy->getPointerTo(kSpirOffloadGlobalAS));
13031302

13041303
FunctionType *NewFTy = FunctionType::get(F->getReturnType(), Types, false);
@@ -1413,6 +1412,21 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M,
14131412
ClUseStackSafety ? &MAM.getResult<StackSafetyGlobalAnalysis>(M) : nullptr;
14141413

14151414
if (Triple(M.getTargetTriple()).isSPIR()) {
1415+
bool HasESIMDKernel = false;
1416+
1417+
// ESIMD kernel doesn't support noinline functions, so we can't
1418+
// support sanitizer for it
1419+
for (Function &F : M)
1420+
if (F.hasMetadata("sycl_explicit_simd")) {
1421+
F.removeFnAttr(Attribute::SanitizeAddress);
1422+
HasESIMDKernel = true;
1423+
}
1424+
1425+
// FIXME: we can't check if the kernel is ESIMD kernel at UR, so we
1426+
// have to disable ASan completely in this case
1427+
if (HasESIMDKernel)
1428+
return PreservedAnalyses::all();
1429+
14161430
ExtendSpirKernelArgs(M, FAM);
14171431
}
14181432

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 -asan-stack=0 -asan-globals=0 -S | FileCheck %s
2+
3+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
4+
target triple = "spir64-unknown-unknown"
5+
6+
@__spirv_BuiltInGlobalInvocationId = external addrspace(1) constant <3 x i64>
7+
8+
; Function Attrs: sanitize_address
9+
define spir_kernel void @esimd_kernel() #0 !sycl_explicit_simd !1 {
10+
entry:
11+
%0 = load i64, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) @__spirv_BuiltInGlobalInvocationId, i64 8), align 8
12+
ret void
13+
}
14+
; CHECK-NOT: {{ sanitize_address }}
15+
16+
attributes #0 = { sanitize_address }
17+
!1 = !{}

sycl/doc/extensions/experimental/sycl_ext_oneapi_graph.asciidoc

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,15 +1736,23 @@ passed an invalid event.
17361736
The new handler methods, and queue shortcuts, defined by
17371737
link:../supported/sycl_ext_oneapi_enqueue_barrier.asciidoc[sycl_ext_oneapi_enqueue_barrier]
17381738
can only be used in graph nodes created using the Record & Replay API, as
1739-
barriers rely on events to enforce dependencies. For barriers with an empty
1740-
wait list parameter, the semantics are that the barrier node being added to
1741-
will depend on all the existing graph leaf nodes, not only the leaf nodes
1742-
that were added from the queue being recorded.
1739+
barriers rely on events to enforce dependencies.
17431740

17441741
A synchronous exception will be thrown with error code `invalid` if a user
1745-
tries to add them to a graph using the Explicit API. Empty nodes created with
1746-
the `node::depends_on_all_leaves` property can be used instead of barriers when
1747-
a user is building a graph with the explicit API.
1742+
tries to add a barrier command to a graph using the explicit API. Empty nodes
1743+
created with the `node::depends_on_all_leaves` property can be used instead of
1744+
barriers when a user is building a graph with the explicit API.
1745+
1746+
The semantics of barriers are defined in `sycl_ext_oneapi_enqueue_barrier` for
1747+
a single command-queue, and correlate as follows to a graph that may contain
1748+
nodes that are recorded from multiple queues and/or added by the explicit API:
1749+
1750+
* Barriers with an empty wait list parameter will only depend on the leaf nodes
1751+
that were added to the graph from the queue the barrier command is being
1752+
recorded from.
1753+
1754+
* The only commands which have an implicit dependency on the barrier command
1755+
are those recorded from the same queue the barrier command was submitted to.
17481756

17491757
==== sycl_ext_oneapi_memcpy2d
17501758

sycl/doc/syclcompat/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,24 @@ those to learn to use the library.
7878

7979
SYCLcompat provides a `dim3` class akin to that of CUDA or HIP programming
8080
models. `dim3` encapsulates other languages iteration spaces that are
81-
represented with coordinate letters (x, y, z).
81+
represented with coordinate letters (x, y, z). In SYCL, the fastest-moving
82+
dimension is the one with the highest index, e.g. in a SYCL 2D range iteration
83+
space, there are two dimensions, 0 and 1, and 1 will be the one that "moves
84+
faster". For CUDA/HIP, the convention is reversed: `x` is the dimension which
85+
moves fastest. `syclcompat::dim3` follows this convention, so that
86+
`syclcompat::dim3(32, 4)` is equivalent to `sycl::range<2>(4, 32)`, and
87+
`syclcompat::dim3(32, 4, 2)` is equivalent to `sycl::range<3>(2, 4, 32)`.
8288

8389
```cpp
8490
namespace syclcompat {
8591

8692
class dim3 {
8793
public:
88-
const size_t x, y, z;
94+
unsigned int x, y, z;
8995
dim3(const sycl::range<3> &r);
9096
dim3(const sycl::range<2> &r);
9197
dim3(const sycl::range<1> &r);
92-
constexpr dim3(size_t x, size_t y = 1, size_t z = 1);
98+
constexpr dim3(unsigned int x = 1, unsigned int y = 1, unsigned int z = 1);
9399

94100
constexpr size_t size();
95101

@@ -106,12 +112,10 @@ inline dim3 operator-(const dim3 &a, const dim3 &b);
106112
} // syclcompat
107113
```
108114
109-
In SYCL, the fastest-moving dimension is the one with the highest index, e.g. in
110-
a SYCL 2D range iteration space, there are two dimensions, 0 and 1, and 1 will
111-
be the one that "moves faster". The compatibility headers for SYCL offer a
112-
number of convenience functions that help the mapping between xyz-based
113-
coordinates to SYCL iteration spaces in the different scopes available. In
114-
addition to the global range, the following helper functions are also provided:
115+
The compatibility headers for SYCL offer a number of convenience functions that
116+
help the mapping between xyz-based coordinates to SYCL iteration spaces in the
117+
different scopes available. In addition to the global range, the following
118+
helper functions are also provided:
115119
116120
``` c++
117121
namespace syclcompat {

sycl/include/sycl/handler.hpp

Lines changed: 23 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class __SYCL_EXPORT handler {
466466
/// \param Queue is a SYCL queue.
467467
/// \param IsHost indicates if this handler is created for SYCL host device.
468468
/// TODO: Unused. Remove with ABI break.
469-
handler(std::shared_ptr<detail::queue_impl> Queue, bool IsHost);
469+
handler(std::shared_ptr<detail::queue_impl> Queue, bool /*Unused*/);
470470

471471
/// Constructs SYCL handler from the associated queue and the submission's
472472
/// primary and secondary queue.
@@ -476,20 +476,20 @@ class __SYCL_EXPORT handler {
476476
/// \param PrimaryQueue is the primary SYCL queue of the submission.
477477
/// \param SecondaryQueue is the secondary SYCL queue of the submission. This
478478
/// is null if no secondary queue is associated with the submission.
479-
/// \param IsHost indicates if this handler is created for SYCL host device.
480479
/// TODO: Unused. Remove with ABI break.
481480
handler(std::shared_ptr<detail::queue_impl> Queue,
482481
std::shared_ptr<detail::queue_impl> PrimaryQueue,
483-
std::shared_ptr<detail::queue_impl> SecondaryQueue, bool IsHost);
482+
std::shared_ptr<detail::queue_impl> SecondaryQueue,
483+
bool /* Unused */);
484484

485485
/// Constructs SYCL handler from queue.
486486
///
487487
/// \param Queue is a SYCL queue.
488488
/// \param IsHost indicates if this handler is created for SYCL host device.
489489
/// \param CallerNeedsEvent indicates if the event resulting from this handler
490490
/// is needed by the caller.
491-
handler(std::shared_ptr<detail::queue_impl> Queue, bool IsHost,
492-
bool CallerNeedsEvent);
491+
handler(std::shared_ptr<detail::queue_impl> Queue,
492+
bool /* ABI break: remove */, bool CallerNeedsEvent);
493493

494494
/// Constructs SYCL handler from the associated queue and the submission's
495495
/// primary and secondary queue.
@@ -504,8 +504,8 @@ class __SYCL_EXPORT handler {
504504
/// is needed by the caller.
505505
handler(std::shared_ptr<detail::queue_impl> Queue,
506506
std::shared_ptr<detail::queue_impl> PrimaryQueue,
507-
std::shared_ptr<detail::queue_impl> SecondaryQueue, bool IsHost,
508-
bool CallerNeedsEvent);
507+
std::shared_ptr<detail::queue_impl> SecondaryQueue,
508+
bool /* ABI break: remove */, bool CallerNeedsEvent);
509509

510510
/// Constructs SYCL handler from Graph.
511511
///
@@ -644,7 +644,7 @@ class __SYCL_EXPORT handler {
644644
~handler() = default;
645645

646646
// TODO: Private and unusued. Remove when ABI break is allowed.
647-
bool is_host() { return MIsHost; }
647+
bool is_host() { return false; }
648648

649649
#ifdef __SYCL_DEVICE_ONLY__
650650
// In device compilation accessor isn't inherited from host base classes, so
@@ -923,12 +923,6 @@ class __SYCL_EXPORT handler {
923923
detail::KernelLambdaHasKernelHandlerArgT<KernelType,
924924
LambdaArgType>::value;
925925

926-
if (IsCallableWithKernelHandler && MIsHost) {
927-
throw sycl::feature_not_supported(
928-
"kernel_handler is not yet supported by host device.",
929-
PI_ERROR_INVALID_OPERATION);
930-
}
931-
932926
KernelType *KernelPtr =
933927
ResetHostKernel<KernelType, LambdaArgType, Dims>(KernelFunc);
934928

@@ -1077,8 +1071,7 @@ class __SYCL_EXPORT handler {
10771071
std::enable_if_t<(DimSrc > 0) && (DimDst > 0), bool>
10781072
copyAccToAccHelper(accessor<TSrc, DimSrc, ModeSrc, TargetSrc, IsPHSrc> Src,
10791073
accessor<TDst, DimDst, ModeDst, TargetDst, IsPHDst> Dst) {
1080-
if (!MIsHost &&
1081-
IsCopyingRectRegionAvailable(Src.get_range(), Dst.get_range()))
1074+
if (IsCopyingRectRegionAvailable(Src.get_range(), Dst.get_range()))
10821075
return false;
10831076

10841077
range<1> LinearizedRange(Src.size());
@@ -1100,23 +1093,19 @@ class __SYCL_EXPORT handler {
11001093
///
11011094
/// \param Src is a source SYCL accessor.
11021095
/// \param Dst is a destination SYCL accessor.
1096+
// ABI break: to remove whole method
11031097
template <typename TSrc, int DimSrc, access::mode ModeSrc,
11041098
access::target TargetSrc, typename TDst, int DimDst,
11051099
access::mode ModeDst, access::target TargetDst,
11061100
access::placeholder IsPHSrc, access::placeholder IsPHDst>
11071101
std::enable_if_t<DimSrc == 0 || DimDst == 0, bool>
1108-
copyAccToAccHelper(accessor<TSrc, DimSrc, ModeSrc, TargetSrc, IsPHSrc> Src,
1109-
accessor<TDst, DimDst, ModeDst, TargetDst, IsPHDst> Dst) {
1110-
if (!MIsHost)
1111-
return false;
1112-
1113-
single_task<__copyAcc2Acc<TSrc, DimSrc, ModeSrc, TargetSrc, TDst, DimDst,
1114-
ModeDst, TargetDst, IsPHSrc, IsPHDst>>(
1115-
[=]() { *(Dst.get_pointer()) = *(Src.get_pointer()); });
1116-
return true;
1102+
copyAccToAccHelper(accessor<TSrc, DimSrc, ModeSrc, TargetSrc, IsPHSrc>,
1103+
accessor<TDst, DimDst, ModeDst, TargetDst, IsPHDst>) {
1104+
return false;
11171105
}
11181106

11191107
#ifndef __SYCL_DEVICE_ONLY__
1108+
// ABI break: to remove whole method
11201109
/// Copies the content of memory object accessed by Src into the memory
11211110
/// pointed by Dst.
11221111
///
@@ -1136,6 +1125,7 @@ class __SYCL_EXPORT handler {
11361125
});
11371126
}
11381127

1128+
// ABI break: to remove whole method
11391129
/// Copies 1 element accessed by 0-dimensional accessor Src into the memory
11401130
/// pointed by Dst.
11411131
///
@@ -1153,6 +1143,7 @@ class __SYCL_EXPORT handler {
11531143
});
11541144
}
11551145

1146+
// ABI break: to remove whole method
11561147
/// Copies the memory pointed by Src into the memory accessed by Dst.
11571148
///
11581149
/// \param Src is a pointer to source memory.
@@ -1170,6 +1161,7 @@ class __SYCL_EXPORT handler {
11701161
});
11711162
}
11721163

1164+
// ABI break: to remove whole method
11731165
/// Copies 1 element pointed by Src to memory accessed by 0-dimensional
11741166
/// accessor Dst.
11751167
///
@@ -2282,7 +2274,7 @@ class __SYCL_EXPORT handler {
22822274
MNDRDesc.set(range<1>{1});
22832275
MKernel = detail::getSyclObjImpl(std::move(Kernel));
22842276
setType(detail::CG::Kernel);
2285-
if (!MIsHost && !lambdaAndKernelHaveEqualName<NameT>()) {
2277+
if (!lambdaAndKernelHaveEqualName<NameT>()) {
22862278
extractArgsAndReqs();
22872279
MKernelName = getKernelName();
22882280
} else
@@ -2319,7 +2311,7 @@ class __SYCL_EXPORT handler {
23192311
MKernel = detail::getSyclObjImpl(std::move(Kernel));
23202312
setType(detail::CG::Kernel);
23212313
setNDRangeUsed(false);
2322-
if (!MIsHost && !lambdaAndKernelHaveEqualName<NameT>()) {
2314+
if (!lambdaAndKernelHaveEqualName<NameT>()) {
23232315
extractArgsAndReqs();
23242316
MKernelName = getKernelName();
23252317
} else
@@ -2359,7 +2351,7 @@ class __SYCL_EXPORT handler {
23592351
MKernel = detail::getSyclObjImpl(std::move(Kernel));
23602352
setType(detail::CG::Kernel);
23612353
setNDRangeUsed(false);
2362-
if (!MIsHost && !lambdaAndKernelHaveEqualName<NameT>()) {
2354+
if (!lambdaAndKernelHaveEqualName<NameT>()) {
23632355
extractArgsAndReqs();
23642356
MKernelName = getKernelName();
23652357
} else
@@ -2398,7 +2390,7 @@ class __SYCL_EXPORT handler {
23982390
MKernel = detail::getSyclObjImpl(std::move(Kernel));
23992391
setType(detail::CG::Kernel);
24002392
setNDRangeUsed(true);
2401-
if (!MIsHost && !lambdaAndKernelHaveEqualName<NameT>()) {
2393+
if (!lambdaAndKernelHaveEqualName<NameT>()) {
24022394
extractArgsAndReqs();
24032395
MKernelName = getKernelName();
24042396
} else
@@ -2725,14 +2717,6 @@ class __SYCL_EXPORT handler {
27252717
"Invalid accessor target for the copy method.");
27262718
static_assert(isValidModeForSourceAccessor(AccessMode),
27272719
"Invalid accessor mode for the copy method.");
2728-
#ifndef __SYCL_DEVICE_ONLY__
2729-
if (MIsHost) {
2730-
// TODO: Temporary implementation for host. Should be handled by memory
2731-
// manager.
2732-
copyAccToPtrHost(Src, Dst);
2733-
return;
2734-
}
2735-
#endif
27362720
setType(detail::CG::CopyAccToPtr);
27372721

27382722
detail::AccessorBaseHost *AccBase = (detail::AccessorBaseHost *)&Src;
@@ -2769,14 +2753,7 @@ class __SYCL_EXPORT handler {
27692753
"Invalid accessor mode for the copy method.");
27702754
// TODO: Add static_assert with is_device_copyable when vec is
27712755
// device-copyable.
2772-
#ifndef __SYCL_DEVICE_ONLY__
2773-
if (MIsHost) {
2774-
// TODO: Temporary implementation for host. Should be handled by memory
2775-
// manager.
2776-
copyPtrToAccHost(Src, Dst);
2777-
return;
2778-
}
2779-
#endif
2756+
27802757
setType(detail::CG::CopyPtrToAcc);
27812758

27822759
detail::AccessorBaseHost *AccBase = (detail::AccessorBaseHost *)&Dst;
@@ -2890,8 +2867,6 @@ class __SYCL_EXPORT handler {
28902867
fill(accessor<T, Dims, AccessMode, AccessTarget, IsPlaceholder, PropertyListT>
28912868
Dst,
28922869
const T &Pattern) {
2893-
assert(!MIsHost && "fill() should no longer be callable on a host device.");
2894-
28952870
if (Dst.is_placeholder())
28962871
checkIfPlaceholderIsBoundToHandler(Dst);
28972872

@@ -3429,7 +3404,7 @@ class __SYCL_EXPORT handler {
34293404
/// Storage for the CG created when handling graph nodes added explicitly.
34303405
std::unique_ptr<detail::CG> MGraphNodeCG;
34313406

3432-
bool MIsHost = false;
3407+
bool MIsHost = false; // ABI break: to remove
34333408

34343409
detail::code_location MCodeLoc = {};
34353410
bool MIsFinalized = false;

sycl/include/syclcompat/dims.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ namespace syclcompat {
3030

3131
class dim3 {
3232
public:
33-
const size_t x, y, z;
33+
unsigned int x, y, z;
3434

3535
dim3(const sycl::range<3> &r) : x(r[2]), y(r[1]), z(r[0]) {}
3636

3737
dim3(const sycl::range<2> &r) : x(r[1]), y(r[0]), z(1) {}
3838

3939
dim3(const sycl::range<1> &r) : x(r[0]), y(1), z(1) {}
4040

41-
constexpr dim3(size_t x, size_t y = 1, size_t z = 1) : x(x), y(y), z(z) {}
41+
constexpr dim3(unsigned int x = 1, unsigned int y = 1, unsigned int z = 1)
42+
: x(x), y(y), z(z) {}
4243

4344
constexpr size_t size() const { return x * y * z; }
4445

0 commit comments

Comments
 (0)