Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove StreamExecutorInterface::WaitForEventOnExternalStream and replace with a proper virtual method on Event. #68295

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions third_party/xla/xla/stream_executor/cuda/cuda_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,18 +772,6 @@ absl::Status GpuExecutor::WaitForEvent(Stream* stream, Event* event) {
}
}

absl::Status GpuExecutor::WaitForEventOnExternalStream(std::intptr_t stream,
Event* event) {
if (GpuDriver::WaitStreamOnEvent(context_,
absl::bit_cast<GpuStreamHandle>(stream),
AsGpuEvent(event)->gpu_event())) {
return absl::OkStatus();
} else {
return absl::InternalError(
"error waiting for CUDA event on external stream");
}
}

Event::Status GpuExecutor::PollForEventStatus(Event* event) {
return AsGpuEvent(event)->PollForStatus();
}
Expand Down
4 changes: 0 additions & 4 deletions third_party/xla/xla/stream_executor/event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,4 @@ Event::Status Event::PollForStatus() {
return stream_exec_->PollForEventStatus(this);
}

absl::Status Event::WaitForEventOnExternalStream(std::intptr_t stream) {
return stream_exec_->WaitForEventOnExternalStream(stream, this);
}

} // namespace stream_executor
6 changes: 4 additions & 2 deletions third_party/xla/xla/stream_executor/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Event {
kComplete,
};

Event(StreamExecutorInterface* stream_exec);
explicit Event(StreamExecutorInterface* stream_exec);

// Releases any resources held by the Event object.
virtual ~Event() = default;
Expand All @@ -51,7 +51,9 @@ class Event {

// Blocks `stream` on this event. `stream` is a raw platform-specific
// stream (e.g. GpuStreamHandle).
absl::Status WaitForEventOnExternalStream(std::intptr_t stream);
virtual absl::Status WaitForEventOnExternalStream(std::intptr_t stream) {
return absl::UnimplementedError("Not supported for this Event.");
}

Event(Event&&) = default;
Event& operator=(Event&&) = default;
Expand Down
1 change: 1 addition & 0 deletions third_party/xla/xla/stream_executor/gpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ gpu_only_cc_library(
":gpu_stream",
":gpu_types_header",
"//xla/stream_executor:stream_executor_headers",
"@com_google_absl//absl/base",
"@com_google_absl//absl/status",
],
)
Expand Down
14 changes: 14 additions & 0 deletions third_party/xla/xla/stream_executor/gpu/gpu_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ limitations under the License.

#include "xla/stream_executor/gpu/gpu_event.h"

#include <cstdint>

#include "absl/base/casts.h"
#include "absl/status/status.h"
#include "xla/stream_executor/event.h"
#include "xla/stream_executor/gpu/gpu_driver.h"
#include "xla/stream_executor/gpu/gpu_executor.h"
#include "xla/stream_executor/gpu/gpu_stream.h"
Expand Down Expand Up @@ -45,5 +49,15 @@ absl::Status GpuEvent::Record(GpuStream* stream) {

GpuEventHandle GpuEvent::gpu_event() { return gpu_event_; }

absl::Status GpuEvent::WaitForEventOnExternalStream(std::intptr_t stream) {
if (GpuDriver::WaitStreamOnEvent(parent_->gpu_context(),
absl::bit_cast<GpuStreamHandle>(stream),
gpu_event_)) {
return absl::OkStatus();
} else {
return absl::InternalError("Error waiting for event on external stream");
}
}

} // namespace gpu
} // namespace stream_executor
4 changes: 4 additions & 0 deletions third_party/xla/xla/stream_executor/gpu/gpu_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.
#ifndef XLA_STREAM_EXECUTOR_GPU_GPU_EVENT_H_
#define XLA_STREAM_EXECUTOR_GPU_GPU_EVENT_H_

#include <cstdint>

#include "absl/status/status.h"
#include "xla/stream_executor/event.h"
#include "xla/stream_executor/gpu/gpu_stream.h"
Expand Down Expand Up @@ -47,6 +49,8 @@ class GpuEvent : public Event {
// The underlying CUDA event element.
GpuEventHandle gpu_event();

absl::Status WaitForEventOnExternalStream(std::intptr_t stream) override;

private:
// The Executor used to which this object and GpuEventHandle are bound.
GpuExecutor* parent_;
Expand Down
3 changes: 0 additions & 3 deletions third_party/xla/xla/stream_executor/gpu/gpu_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ class GpuExecutor : public StreamExecutor {

absl::Status WaitForEvent(Stream* stream, Event* event) override;

absl::Status WaitForEventOnExternalStream(std::intptr_t stream,
Event* event) override;

Event::Status PollForEventStatus(Event* event) override;

absl::Status BlockHostUntilDone(Stream* stream) override;
Expand Down
2 changes: 0 additions & 2 deletions third_party/xla/xla/stream_executor/mock_stream_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ class MockStreamExecutor : public StreamExecutorInterface {
(override));
MOCK_METHOD(absl::Status, WaitForEvent, (Stream * stream, Event* event),
(override));
MOCK_METHOD(absl::Status, WaitForEventOnExternalStream,
(std::intptr_t stream, Event* event), (override));
MOCK_METHOD(Event::Status, PollForEventStatus, (Event * event), (override));
MOCK_METHOD(void, DeallocateStream, (Stream * stream), (override));
MOCK_METHOD(bool, CreateStreamDependency, (Stream * dependent, Stream* other),
Expand Down
12 changes: 0 additions & 12 deletions third_party/xla/xla/stream_executor/rocm/rocm_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,18 +676,6 @@ absl::Status GpuExecutor::WaitForEvent(Stream* stream, Event* event) {
}
}

absl::Status GpuExecutor::WaitForEventOnExternalStream(std::intptr_t stream,
Event* event) {
if (GpuDriver::WaitStreamOnEvent(context_,
absl::bit_cast<GpuStreamHandle>(stream),
AsGpuEvent(event)->gpu_event())) {
return absl::OkStatus();
} else {
return absl::InternalError(
"error waiting for ROCM event on external stream");
}
}

Event::Status GpuExecutor::PollForEventStatus(Event* event) {
return AsGpuEvent(event)->PollForStatus();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,6 @@ class StreamExecutorInterface {
// Waits for the specified event at the end of the specified stream.
virtual absl::Status WaitForEvent(Stream* stream, Event* event) = 0;

// Waits for the specified event at the end of the raw platform-specific
// stream.
virtual absl::Status WaitForEventOnExternalStream(std::intptr_t stream,
Event* event) {
return absl::UnimplementedError(
"WaitForEventOnExternalStream not supported on this executor.");
}

// Requests the current status of the event from the underlying platform.
virtual Event::Status PollForEventStatus(Event* event) = 0;

Expand Down
Loading