-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a thunk for stream synchronization
added emitter logic fot SyncOnStreamsThunk
- Loading branch information
Showing
11 changed files
with
303 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* Copyright 2024 The OpenXLA Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#include "xla/service/gpu/runtime3/wait_for_streams_thunk.h" | ||
|
||
#include <string> | ||
#include <utility> | ||
|
||
#include "absl/status/status.h" | ||
#include "absl/strings/str_cat.h" | ||
#include "xla/service/gpu/thunk.h" | ||
#include "tsl/platform/errors.h" | ||
|
||
namespace xla::gpu { | ||
|
||
absl::Status WaitForStreamsThunk::ExecuteOnStream(const ExecuteParams& params) { | ||
TF_ASSIGN_OR_RETURN(se::Stream* source_stream, | ||
Thunk::GetStreamForExecution(source_stream_id_, params)); | ||
|
||
VLOG(5) << "Waiting for stream ids: " << | ||
absl::StrJoin(wait_on_stream_ids_, ", ", | ||
[&](std::string* s, const ExecutionStreamId& stream_id) { | ||
absl::StrAppend(s, stream_id.value()); | ||
}); | ||
for (const auto& stream_id : wait_on_stream_ids_) { | ||
TF_ASSIGN_OR_RETURN(se::Stream* wait_on_stream, | ||
Thunk::GetStreamForExecution(stream_id, params)); | ||
|
||
source_stream->ThenWaitFor(wait_on_stream); | ||
} | ||
return absl::OkStatus(); | ||
} | ||
|
||
} // namespace xla::gpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright 2024 The OpenXLA Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
==============================================================================*/ | ||
|
||
#ifndef XLA_SERVICE_GPU_RUNTIME3_WAIT_FOR_STREAMS_THUNK_H_ | ||
#define XLA_SERVICE_GPU_RUNTIME3_WAIT_FOR_STREAMS_THUNK_H_ | ||
|
||
#include <string> | ||
|
||
#include "absl/status/status.h" | ||
#include "xla/service/gpu/thunk.h" | ||
|
||
namespace xla::gpu { | ||
|
||
// This thunk | ||
class WaitForStreamsThunk : public Thunk { | ||
public: | ||
WaitForStreamsThunk(ThunkInfo thunk_info, ExecutionStreamId source_stream_id, | ||
std::vector<ExecutionStreamId> wait_on_stream_ids) | ||
: Thunk(Kind::kWaitForStreams, thunk_info), | ||
source_stream_id_(source_stream_id), | ||
wait_on_stream_ids_(wait_on_stream_ids){}; | ||
|
||
WaitForStreamsThunk(const WaitForStreamsThunk&) = delete; | ||
WaitForStreamsThunk& operator=(const WaitForStreamsThunk&) = delete; | ||
|
||
const ExecutionStreamId& source_stream_id() const { | ||
return source_stream_id_; | ||
} | ||
|
||
const std::vector<ExecutionStreamId>& wait_on_stream_ids() const { | ||
return wait_on_stream_ids_; | ||
} | ||
|
||
absl::Status ExecuteOnStream(const ExecuteParams& params) override; | ||
|
||
private: | ||
ExecutionStreamId source_stream_id_; | ||
std::vector<ExecutionStreamId> wait_on_stream_ids_; | ||
}; | ||
|
||
} // namespace xla::gpu | ||
|
||
#endif // XLA_SERVICE_GPU_RUNTIME3_WAIT_FOR_STREAMS_THUNK_H_ |
Oops, something went wrong.