Skip to content

Commit b340233

Browse files
committed
Add preview-breaking-changes macro to ABI breaks
1 parent 704f87c commit b340233

14 files changed

+91
-10
lines changed

sycl/include/sycl/interop_handle.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,25 @@ class interop_handle {
208208
friend class detail::DispatchHostTask;
209209
using ReqToMem = std::pair<detail::AccessorImplHost *, ur_mem_handle_t>;
210210

211+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
212+
// MGraph should become a member of this class on the next ABI breaking
213+
// window
214+
// TODO create and link GitHub Issue
211215
interop_handle(std::vector<ReqToMem> MemObjs,
212216
const std::shared_ptr<detail::queue_impl> &Queue,
213217
const std::shared_ptr<detail::device_impl> &Device,
214218
const std::shared_ptr<detail::context_impl> &Context,
215-
const ur_exp_command_buffer_handle_t &Graph)
219+
ur_exp_command_buffer_handle_t Graph = nullptr)
216220
: MQueue(Queue), MDevice(Device), MContext(Context), MGraph(Graph),
217221
MMemObjs(std::move(MemObjs)) {}
222+
#else
223+
interop_handle(std::vector<ReqToMem> MemObjs,
224+
const std::shared_ptr<detail::queue_impl> &Queue,
225+
const std::shared_ptr<detail::device_impl> &Device,
226+
const std::shared_ptr<detail::context_impl> &Context)
227+
: MQueue(Queue), MDevice(Device), MContext(Context),
228+
MMemObjs(std::move(MemObjs)) {}
229+
#endif
218230

219231
template <backend Backend, typename DataT, int Dims>
220232
backend_return_t<Backend, buffer<DataT, Dims>>
@@ -242,7 +254,12 @@ class interop_handle {
242254
std::shared_ptr<detail::queue_impl> MQueue;
243255
std::shared_ptr<detail::device_impl> MDevice;
244256
std::shared_ptr<detail::context_impl> MContext;
257+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
258+
// MGraph should become a member of this class on the next ABI breaking
259+
// window
260+
// TODO link github issue
245261
ur_exp_command_buffer_handle_t MGraph;
262+
#endif
246263

247264
std::vector<ReqToMem> MMemObjs;
248265
};

sycl/source/detail/queue_impl.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,19 @@ class queue_impl {
753753
return ResEvent;
754754
}
755755

756+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
757+
// These methods are for accessing a member that should live in the
758+
// sycl::interop_handle class and will be moved on next ABI breaking window.
759+
// TODO create and link github issue
760+
ur_exp_command_buffer_handle_t getInteropGraph() const {
761+
return MInteropGraph;
762+
}
763+
764+
void setInteropGraph(ur_exp_command_buffer_handle_t Graph) {
765+
MInteropGraph = Graph;
766+
}
767+
#endif
768+
756769
protected:
757770
event discard_or_return(const event &Event);
758771

@@ -1000,6 +1013,14 @@ class queue_impl {
10001013
// recording commands to it.
10011014
std::weak_ptr<ext::oneapi::experimental::detail::graph_impl> MGraph{};
10021015

1016+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
1017+
// This member should be part of the sycl::interop_handle class, but it
1018+
// in an API breaking change. So member lives here temporarily where it can
1019+
// be accessed through the queue member of the interop_handle
1020+
// TODO create and link github issue
1021+
ur_exp_command_buffer_handle_t MInteropGraph{};
1022+
#endif
1023+
10031024
unsigned long long MQueueID;
10041025
static std::atomic<unsigned long long> MNextAvailableQueueID;
10051026

sycl/source/detail/scheduler/commands.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ class DispatchHostTask {
420420
"Host task submissions should have an associated queue");
421421
interop_handle IH{MReqToMem, HostTask.MQueue,
422422
HostTask.MQueue->getDeviceImplPtr(),
423-
HostTask.MQueue->getContextImplPtr(), nullptr};
423+
HostTask.MQueue->getContextImplPtr()};
424424
// TODO: should all the backends that support this entry point use this
425425
// for host task?
426426
auto &Queue = HostTask.MQueue;
@@ -3087,8 +3087,19 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() {
30873087
};
30883088
std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv);
30893089

3090+
ur_exp_command_buffer_handle_t InteropCommandBuffer =
3091+
ChildCommandBuffer ? ChildCommandBuffer : MCommandBuffer;
3092+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
3093+
// The native command-buffer should be a member of the sycl::interop_handle
3094+
// class, but it is in an API breaking change to add it. So member lives in
3095+
// the queue as a intermediate workaround.
3096+
// TODO create and link github issue
30903097
interop_handle IH{ReqToMem, MQueue, DeviceImpl, ContextImpl,
3091-
ChildCommandBuffer ? ChildCommandBuffer : MCommandBuffer};
3098+
InteropCommandBuffer};
3099+
#else
3100+
MQueue->setInteropGraph(InteropCommandBuffer);
3101+
interop_handle IH{ReqToMem, MQueue, DeviceImpl, ContextImpl};
3102+
#endif
30923103
CommandBufferNativeCommandData CustomOpData{
30933104
IH, HostTask->MHostTask->MInteropTask};
30943105

@@ -3480,7 +3491,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
34803491
EnqueueNativeCommandData CustomOpData{
34813492
interop_handle{ReqToMem, HostTask->MQueue,
34823493
HostTask->MQueue->getDeviceImplPtr(),
3483-
HostTask->MQueue->getContextImplPtr(), nullptr},
3494+
HostTask->MQueue->getContextImplPtr()},
34843495
HostTask->MHostTask->MInteropTask};
34853496

34863497
ur_bool_t NativeCommandSupport = false;

sycl/source/interop_handle.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ backend interop_handle::get_backend() const noexcept {
2424
}
2525

2626
bool interop_handle::ext_codeplay_has_graph() const noexcept {
27+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
28+
// TODO create and link GitHub
2729
return MGraph != nullptr;
30+
#else
31+
return MQueue->getInteropGraph() != nullptr;
32+
#endif
2833
}
2934

3035
ur_native_handle_t
@@ -58,15 +63,22 @@ interop_handle::getNativeQueue(int32_t &NativeHandleDesc) const {
5863
}
5964

6065
ur_native_handle_t interop_handle::getNativeGraph() const {
61-
if (!MGraph) {
66+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
67+
// TODO create and link github issue
68+
auto Graph = MGraph;
69+
#else
70+
auto Graph = MQueue->getInteropGraph();
71+
#endif
72+
73+
if (!Graph) {
6274
throw exception(
6375
make_error_code(errc::invalid),
6476
"No backend graph object is available for the command-group");
6577
}
6678

6779
auto Adapter = MQueue->getAdapter();
6880
ur_native_handle_t Handle;
69-
Adapter->call<detail::UrApiKind::urCommandBufferGetNativeHandleExp>(MGraph,
81+
Adapter->call<detail::UrApiKind::urCommandBufferGetNativeHandleExp>(Graph,
7082
&Handle);
7183
return Handle;
7284
}

sycl/test-e2e/EnqueueNativeCommand/Graph/invalid.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %{build} -o %t.out
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -o %t2.out %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: cuda
46

57
// Test that interop_handle::ext_codeplay_get_native_graph() throws if no

sycl/test-e2e/EnqueueNativeCommand/Graph/native_cuda_explicit_usm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out %cuda_options
1+
// RUN: %{build} -o %t.out %cuda_options
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -o %t2.out %cuda_options %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: cuda, cuda_dev_kit
46

57
#include <cuda.h>

sycl/test-e2e/EnqueueNativeCommand/Graph/native_cuda_record_buffer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out %cuda_options
1+
// RUN: %{build} -o %t.out %cuda_options
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -o %t2.out %cuda_options %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: cuda, cuda_dev_kit
46

57
#include <cuda.h>

sycl/test-e2e/EnqueueNativeCommand/Graph/native_cuda_record_usm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out %cuda_options
1+
// RUN: %{build} -o %t.out %cuda_options
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -o %t2.out %cuda_options %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: cuda, cuda_dev_kit
46

57
#include <cuda.h>

sycl/test-e2e/EnqueueNativeCommand/Graph/native_hip_explicit_usm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// RUN: %{run-aux} %{build} -Wno-error=deprecated-pragma -o %t.out -I%rocm_path/include -L%rocm_path/lib -lamdhip64
66
// RUN: %{run} %t.out
7+
// RUN: %if preview-breaking-changes-supported %{ %{run-aux} %{build} -Wno-error=deprecated-pragma -fpreview-breaking-changes -o %t2.out -I%rocm_path/include -L%rocm_path/lib -lamdhip64 %}
8+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
79
// REQUIRES: target-amd
810

911
#define __HIP_PLATFORM_AMD__

sycl/test-e2e/EnqueueNativeCommand/Graph/native_hip_record_buffer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// RUN: %{run-aux} %{build} -Wno-error=deprecated-pragma -o %t.out -I%rocm_path/include -L%rocm_path/lib -lamdhip64
66
// RUN: %{run} %t.out
7+
// RUN: %if preview-breaking-changes-supported %{ %{run-aux} %{build} -Wno-error=deprecated-pragma -fpreview-breaking-changes -o %t2.out -I%rocm_path/include -L%rocm_path/lib -lamdhip64 %}
8+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
79
// REQUIRES: target-amd
810

911
#define __HIP_PLATFORM_AMD__

sycl/test-e2e/EnqueueNativeCommand/Graph/native_hip_record_usm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
// RUN: %{run-aux} %{build} -Wno-error=deprecated-pragma -o %t.out -I%rocm_path/include -L%rocm_path/lib -lamdhip64
66
// RUN: %{run} %t.out
7+
// RUN: %if preview-breaking-changes-supported %{ %{run-aux} %{build} -Wno-error=deprecated-pragma -fpreview-breaking-changes -o %t2.out -I%rocm_path/include -L%rocm_path/lib -lamdhip64 %}
8+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
79
// REQUIRES: target-amd
810

911
#define __HIP_PLATFORM_AMD__

sycl/test-e2e/EnqueueNativeCommand/Graph/native_level-zero_usm.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %{build} %level_zero_options -o %t.out
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} %level_zero_options -fpreview-breaking-changes -o %t2.out %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: level_zero, level_zero_dev_kit
46

57
#include <level_zero/ze_api.h>

sycl/test-e2e/EnqueueNativeCommand/Graph/native_level-zero_usm_D2H_copy_deps.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %{build} %level_zero_options -o %t.out
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} %level_zero_options -fpreview-breaking-changes -o %t2.out %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: level_zero, level_zero_dev_kit
46

57
// Tests that the optimization to use the L0 Copy Engine for memory commands

sycl/test-e2e/EnqueueNativeCommand/Graph/native_opencl_buffer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// RUN: %{build} -Wno-error=deprecated-declarations -o %t.out %threads_lib %opencl_lib
1+
// RUN: %{build} -o %t.out %threads_lib %opencl_lib
22
// RUN: %{run} %t.out
3+
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -o %t2.out %threads_lib %opencl_lib %}
4+
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
35
// REQUIRES: opencl
46

57
#include <sycl/backend.hpp>

0 commit comments

Comments
 (0)