Skip to content

Commit 0b3637c

Browse files
LuFinchmayuyuace
andauthored
Fix cross device synchronization (#2693)
Co-authored-by: mayuyuace <[email protected]>
1 parent 6bbfe9a commit 0b3637c

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

WORKSPACE

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ load(
3232
# curl -L https://github.com/openxla/xla/archive/<git hash>.tar.gz | sha256sum
3333
# and update XLA_SHA256 with the result.
3434

35-
XLA_COMMIT = "98bf412acc77c515ed7b40cff26ac1f1decf8f5b"
35+
XLA_COMMIT = "da290b48daafac8cf9db1d9431ed1e4bd5fccdfa"
3636

3737
new_git_repository(
3838
name = "intel_extension_for_openxla",

itex/core/devices/gpu/gpu_device_plugin.cc

+15-19
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,28 @@ void gpu_destroy_event(const SP_Device* device, SP_Event event) {
166166

167167
// Requests the current status of the event from the underlying platform.
168168
SE_EventStatus gpu_get_event_status(const SP_Device* device, SP_Event event) {
169-
if (IsMultipleStreamEnabled()) {
170-
ITEX_GPUEvent event_handle = static_cast<SP_Event_st*>(event)->event_handle;
171-
auto event_status =
172-
event_handle.get_info<sycl::info::event::command_execution_status>();
173-
switch (event_status) {
174-
case sycl::info::event_command_status::submitted:
175-
case sycl::info::event_command_status::running:
176-
return SE_EVENT_PENDING;
177-
case sycl::info::event_command_status::complete:
178-
return SE_EVENT_COMPLETE;
179-
default:
180-
return SE_EVENT_UNKNOWN;
181-
}
169+
ITEX_GPUEvent event_handle = static_cast<SP_Event_st*>(event)->event_handle;
170+
auto event_status =
171+
event_handle.get_info<sycl::info::event::command_execution_status>();
172+
switch (event_status) {
173+
case sycl::info::event_command_status::submitted:
174+
case sycl::info::event_command_status::running:
175+
return SE_EVENT_PENDING;
176+
case sycl::info::event_command_status::complete:
177+
return SE_EVENT_COMPLETE;
178+
default:
179+
return SE_EVENT_UNKNOWN;
182180
}
183181
return SE_EVENT_COMPLETE;
184182
}
185183

186184
// Inserts the specified event at the end of the specified stream.
187185
void gpu_record_event(const SP_Device* device, SP_Stream stream, SP_Event event,
188186
TF_Status* status) {
189-
if (IsMultipleStreamEnabled()) {
190-
ITEX_GPUStream* stream_handle =
191-
static_cast<SP_Stream_st*>(stream)->stream_handle;
192-
ITEX_GPUEvent recorded_event = stream_handle->ext_oneapi_submit_barrier();
193-
event->event_handle = recorded_event;
194-
}
187+
ITEX_GPUStream* stream_handle =
188+
static_cast<SP_Stream_st*>(stream)->stream_handle;
189+
ITEX_GPUEvent recorded_event = stream_handle->ext_oneapi_submit_barrier();
190+
event->event_handle = recorded_event;
195191
}
196192

197193
// Wait for the specified event at the end of the specified stream.

itex/core/devices/gpu/itex_gpu_runtime.cc

+5-14
Original file line numberDiff line numberDiff line change
@@ -365,25 +365,16 @@ ITEX_GPUError_t ITEX_GPUDestroyEvent(ITEX_GPUDevice* device_handle,
365365

366366
ITEX_GPUError_t ITEX_GPUStreamWaitEvent(ITEX_GPUStream* stream,
367367
ITEX_GPUEvent event) {
368-
if (IsMultipleStreamEnabled()) {
369-
const std::vector<ITEX_GPUEvent> event_list{event};
370-
stream->ext_oneapi_submit_barrier(event_list);
371-
} else {
372-
stream->wait();
373-
}
368+
const std::vector<ITEX_GPUEvent> event_list{event};
369+
stream->ext_oneapi_submit_barrier(event_list);
374370
return ITEX_GPU_SUCCESS;
375371
}
376372

377373
ITEX_GPUError_t ITEX_GPUStreamWaitStream(ITEX_GPUStream* dependent,
378374
ITEX_GPUStream* other) {
379-
if (IsMultipleStreamEnabled()) {
380-
ITEX_GPUEvent event = other->ext_oneapi_submit_barrier();
381-
const std::vector<ITEX_GPUEvent> event_list{event};
382-
dependent->ext_oneapi_submit_barrier(event_list);
383-
} else {
384-
dependent->wait();
385-
other->wait();
386-
}
375+
ITEX_GPUEvent event = other->ext_oneapi_submit_barrier();
376+
const std::vector<ITEX_GPUEvent> event_list{event};
377+
dependent->ext_oneapi_submit_barrier(event_list);
387378
return ITEX_GPU_SUCCESS;
388379
}
389380

0 commit comments

Comments
 (0)