Skip to content

Commit 1842fa3

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents c7c8f87 + 1192a4c commit 1842fa3

File tree

6 files changed

+64
-14
lines changed

6 files changed

+64
-14
lines changed

.github/workflows/sycl_nightly.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616
with:
1717
build_cache_root: "/__w/"
1818
build_artifact_suffix: default
19-
lts_config: "ocl_gen9;ocl_x64;hip_amdgpu"
19+
build_configure_extra_args: ''
20+
lts_config: "ocl_gen9;ocl_x64"
2021

2122
windows_default:
2223
name: Windows

devops/actions/llvm_test_suite/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ runs:
9393
echo "::endgroup::"
9494
echo "::group::SYCL_PI_TRACE=-1 sycl-ls"
9595
echo $LD_LIBRARY_PATH
96-
ldd $PWD/toolchain/lib/libpi_hip.so
9796
SYCL_PI_TRACE=-1 sycl-ls
9897
echo "::endgroup::"
9998
cd build

sycl/doc/design/DeviceGlobal.md

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,37 @@ instance of a device global variable in a `pi_program`. This functionality is
563563
exposed as two new PI interfaces:
564564

565565
```
566-
pi_result piextCopyToDeviceVariable(pi_device Device, pi_program Program,
567-
const char *name, const void *src, size_t count, size_t offset);
568-
569-
pi_result piextCopyFromDeviceVariable(pi_device Device, pi_program Program,
570-
const char *name, void *dst, size_t count, size_t offset);
566+
pi_result piextEnqueueDeviceVariableRead(pi_queue Queue, pi_program Program,
567+
const char *Name, pi_bool BlockingRead,
568+
size_t Count, size_t Offset, void *Dst,
569+
pi_uint32 NumEventsInWaitList,
570+
const pi_event *EventsWaitList,
571+
pi_event *Event);
572+
573+
pi_result piextEnqueueDeviceVariableWrite(pi_queue Queue, pi_program Program,
574+
const char *Name,
575+
pi_bool BlockingWrite, size_t Count,
576+
size_t Offset, const void *Src,
577+
pi_uint32 NumEventsInWaitList,
578+
const pi_event *EventsWaitList,
579+
pi_event *Event);
571580
```
572581

573-
In both cases the `name` parameter is the same as the `sycl-unique-id` string
574-
that is associated with the device global variable.
582+
The `piextEnqueueDeviceVariableRead` function reads `Count` bytes at byte-offset
583+
`Offset` from a device global variable in `Program` identified by the name
584+
`Name`. The read data is stored in `Dst`. Likewise, the
585+
`piextEnqueueDeviceVariableWrite` function reads `Count` bytes from `Dst` and
586+
stores them at byte-offset `Offset` in the device global variable in `Program`
587+
identified by the name `Name`.
588+
589+
Both functions will enqueue the associated memory command on `Queue` where it
590+
will first wait for `NumEventsInWaitList` events in `EventsWaitList` to finish.
591+
`Event` will be populated with the event associated with resulting enqueued
592+
command. If either `BlockingRead` or `BlockingWrite` is `true` the call will
593+
block on the host until the enqueued command finishes execution.
594+
595+
For `device_global` variables the `Name` parameter in calls to these functions
596+
is the same as the associated `sycl-unique-id` string.
575597

576598
The Level Zero backend has existing APIs that can implement these PI
577599
interfaces. The plugin first calls [`zeModuleGetGlobalPointer()`][8] to get a
@@ -616,8 +638,8 @@ depends upon implementation of that OpenCL extension.
616638

617639
[10]: <opencl-extensions/cl_intel_global_variable_access.asciidoc>
618640

619-
The CUDA backend has existing APIs `cudaMemcpyToSymbol()` and
620-
`cudaMemcpyFromSymbol()` which can be used to implement these PI interfaces.
641+
The CUDA backend has existing APIs `cuModuleGetGlobal()` and `cuMemcpyAsync()`
642+
which can be used to implement these PI interfaces.
621643

622644

623645
## Design choices

sycl/plugins/level_zero/pi_level_zero.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,8 @@ struct _pi_buffer final : _pi_mem {
976976
_pi_buffer(pi_context Ctx, char *Mem, char *HostPtr, bool OwnZeMemHandle,
977977
_pi_mem *Parent = nullptr, size_t Origin = 0, size_t Size = 0,
978978
bool MemOnHost = false, bool ImportedHostPtr = false)
979-
: _pi_mem(Ctx, HostPtr, OwnZeMemHandle, MemOnHost), ZeMem{Mem},
980-
SubBuffer{Parent, Origin, Size} {}
979+
: _pi_mem(Ctx, HostPtr, OwnZeMemHandle, MemOnHost, ImportedHostPtr),
980+
ZeMem{Mem}, SubBuffer{Parent, Origin, Size} {}
981981

982982
void *getZeHandle() override { return ZeMem; }
983983

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,31 @@ bool handleInvalidWorkItemSize(const device_impl &DeviceImpl,
268268
return 0;
269269
}
270270

271+
bool handleInvalidValue(const device_impl &DeviceImpl,
272+
const NDRDescT &NDRDesc) {
273+
const plugin &Plugin = DeviceImpl.getPlugin();
274+
RT::PiDevice Device = DeviceImpl.getHandleRef();
275+
276+
size_t MaxNWGs[] = {0, 0, 0};
277+
Plugin.call<PiApiKind::piDeviceGetInfo>(
278+
Device, PI_EXT_ONEAPI_DEVICE_INFO_MAX_WORK_GROUPS_3D, sizeof(MaxNWGs),
279+
&MaxNWGs, nullptr);
280+
for (unsigned int I = 0; I < NDRDesc.Dims; I++) {
281+
size_t NWgs = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I];
282+
if (NWgs > MaxNWGs[I])
283+
throw sycl::nd_range_error(
284+
"Number of work-groups exceed limit for dimension " +
285+
std::to_string(I) + " : " + std::to_string(NWgs) + " > " +
286+
std::to_string(MaxNWGs[I]),
287+
PI_INVALID_VALUE);
288+
}
289+
290+
// fallback
291+
constexpr pi_result Error = PI_INVALID_VALUE;
292+
throw runtime_error(
293+
"Native API failed. Native API returns: " + codeToString(Error), Error);
294+
}
295+
271296
bool handleError(pi_result Error, const device_impl &DeviceImpl,
272297
pi_kernel Kernel, const NDRDescT &NDRDesc) {
273298
assert(Error != PI_SUCCESS &&
@@ -315,6 +340,9 @@ bool handleError(pi_result Error, const device_impl &DeviceImpl,
315340
"slice pitch) are not supported by device associated with queue",
316341
PI_INVALID_IMAGE_SIZE);
317342

343+
case PI_INVALID_VALUE:
344+
return handleInvalidValue(DeviceImpl, NDRDesc);
345+
318346
// TODO: Handle other error codes
319347

320348
default:

sycl/source/detail/sycl_mem_obj_t.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SYCLMemObjT::SYCLMemObjT(cl_mem MemObject, const context &SyclContext,
2323
SizeInBytes, AvailableEvent, std::move(Allocator)) {}
2424

2525
SYCLMemObjT::SYCLMemObjT(pi_native_handle MemObject, const context &SyclContext,
26-
const size_t SizeInBytes, event AvailableEvent,
26+
const size_t, event AvailableEvent,
2727
std::unique_ptr<SYCLMemObjAllocator> Allocator)
2828
: SYCLMemObjT(MemObject, SyclContext, true, AvailableEvent,
2929
std::move(Allocator)) {}

0 commit comments

Comments
 (0)