Skip to content

Commit 8a5332d

Browse files
kluckecopybara-github
authored andcommitted
Remove GpuStream::platform_specific_stream method in favor of the more widely-used ::gpu_stream method.
PiperOrigin-RevId: 658127980
1 parent 102003e commit 8a5332d

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

xla/stream_executor/cuda/cuda_executor.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,13 @@ void GpuExecutor::DeallocateStream(Stream* stream) {
665665
dnn_->NotifyStreamDestroyed(stream);
666666
}
667667
}
668-
GpuStream* cuda_stream = AsGpuStream(stream);
668+
GpuStream* gpu_stream = AsGpuStream(stream);
669669
absl::MutexLock l(&alive_gpu_streams_mu_);
670-
alive_gpu_streams_.erase(cuda_stream->platform_specific_stream());
671-
if (!cuda_stream->IsIdle()) {
670+
alive_gpu_streams_.erase(gpu_stream->gpu_stream());
671+
if (!gpu_stream->IsIdle()) {
672672
LOG(ERROR) << "Deallocating stream with pending work";
673673
}
674-
cuda_stream->Destroy();
674+
gpu_stream->Destroy();
675675
}
676676

677677
absl::Status GpuExecutor::BlockHostUntilDone(Stream* stream) {
@@ -805,20 +805,20 @@ absl::StatusOr<std::unique_ptr<Event>> GpuExecutor::CreateEvent() {
805805

806806
absl::StatusOr<std::unique_ptr<Stream>> GpuExecutor::CreateStream(
807807
std::optional<std::variant<StreamPriority, int>> priority) {
808-
auto gpu_stream = std::make_unique<GpuStream>(this);
808+
auto stream = std::make_unique<GpuStream>(this);
809809
if (priority.has_value()) {
810810
if (std::holds_alternative<StreamPriority>(*priority)) {
811-
gpu_stream->SetPriority(std::get<StreamPriority>(*priority));
811+
stream->SetPriority(std::get<StreamPriority>(*priority));
812812
} else {
813-
gpu_stream->SetPriority(std::get<int>(*priority));
813+
stream->SetPriority(std::get<int>(*priority));
814814
}
815815
}
816816
absl::MutexLock l(&alive_gpu_streams_mu_);
817-
bool init_worked = gpu_stream->Init();
817+
bool init_worked = stream->Init();
818818
if (init_worked) {
819-
auto platform_specific_stream = gpu_stream->platform_specific_stream();
820-
alive_gpu_streams_[platform_specific_stream] = gpu_stream.get();
821-
return std::move(gpu_stream);
819+
auto gpu_stream = stream->gpu_stream();
820+
alive_gpu_streams_[gpu_stream] = stream.get();
821+
return std::move(stream);
822822
} else {
823823
return absl::InvalidArgumentError("Failed to initialize gpu stream");
824824
}

xla/stream_executor/gpu/gpu_stream.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ class GpuStream : public StreamCommon {
5858
parent()->DeallocateStream(this);
5959
}
6060

61-
// Returns a pointer to a platform specific stream associated with this object
62-
// if it exists, or nullptr otherwise. This is available via Stream public API
63-
// as Stream::PlatformSpecificHandle, and should not be accessed directly
64-
// outside of a StreamExecutor package.
65-
void* platform_specific_stream() const { return gpu_stream_; }
66-
6761
// Explicitly initialize the CUDA resources associated with this stream.
6862
bool Init();
6963

xla/stream_executor/rocm/rocm_executor.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ void GpuExecutor::DeallocateStream(Stream* stream) {
499499
}
500500
GpuStream* rocm_stream = AsGpuStream(stream);
501501
absl::MutexLock l(&alive_gpu_streams_mu_);
502-
alive_gpu_streams_.erase(rocm_stream->platform_specific_stream());
502+
alive_gpu_streams_.erase(rocm_stream->gpu_stream());
503503
if (!rocm_stream->IsIdle()) {
504504
LOG(ERROR) << "Deallocating stream with pending work";
505505
}
@@ -642,20 +642,20 @@ absl::StatusOr<std::unique_ptr<Event>> GpuExecutor::CreateEvent() {
642642

643643
absl::StatusOr<std::unique_ptr<Stream>> GpuExecutor::CreateStream(
644644
std::optional<std::variant<StreamPriority, int>> priority) {
645-
auto gpu_stream = std::make_unique<GpuStream>(this);
645+
auto stream = std::make_unique<GpuStream>(this);
646646
if (priority.has_value()) {
647647
if (std::holds_alternative<StreamPriority>(*priority)) {
648-
gpu_stream->SetPriority(std::get<StreamPriority>(*priority));
648+
stream->SetPriority(std::get<StreamPriority>(*priority));
649649
} else {
650-
gpu_stream->SetPriority(std::get<int>(*priority));
650+
stream->SetPriority(std::get<int>(*priority));
651651
}
652652
}
653653
absl::MutexLock l(&alive_gpu_streams_mu_);
654-
bool init_worked = gpu_stream->Init();
654+
bool init_worked = stream->Init();
655655
if (init_worked) {
656-
auto platform_specific_stream = gpu_stream->platform_specific_stream();
657-
alive_gpu_streams_[platform_specific_stream] = gpu_stream.get();
658-
return std::move(gpu_stream);
656+
auto gpu_stream = stream->gpu_stream();
657+
alive_gpu_streams_[gpu_stream] = stream.get();
658+
return std::move(stream);
659659
} else {
660660
return absl::InvalidArgumentError("Failed to initialize GPU stream");
661661
}

0 commit comments

Comments
 (0)