Skip to content
Open
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
5 changes: 0 additions & 5 deletions build_tools/rocm/tsan_ignore_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ race:xla::gpu::AllocateDestinationBuffer
race:xla::LocalDeviceState::ThenRelease

# To be fixed
race:xla::LiteralBase::Piece::DeallocateBuffers
race:xla::PjRtStreamExecutorLoadedExecutable::ExecuteHelper
race:xla::PjRtStreamExecutorClient::BufferFromHostBufferInternal
race:xla::HloRunnerPjRt::TransferLiteralsFromDevice
race:xla::MutableLiteralBase::~MutableLiteralBase
race:xla::MutableLiteralBase::PopulateR1<int>
race:xla::xla::gpu::GpuCompiler::CompileSingleModule
race:xla::LiteralBase::Piece::Storage::Storage
race:xla::LocalClient::TransferFromOutfeedLocal
race:llvm::cl::opt_storage<bool, false, false>::setValue<int>
race:xla::gpu::(anonymous namespace)::RecoverExp2Pattern::initStaticsIfNeeded<std::tuple<mlir::Float32Type, mlir::FloatTF32Type, mlir::BFloat16Type>>
race:lld::lldMain
race:llvm::*
race:xla::gpu::GpuExecutable::ExecuteAsyncOnStream
6 changes: 6 additions & 0 deletions xla/literal.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.
#include <initializer_list>
#include <limits>
#include <memory>
#include <mutex>
#include <optional>
#include <ostream>
#include <string>
Expand Down Expand Up @@ -1107,6 +1108,7 @@ class LiteralBase {
Storage(Storage&& other) { *this = std::move(other); }
Storage& operator=(Storage&& other) {
rep_ = std::move(other.rep_);
std::lock_guard<std::mutex> lock(mutex_);
data_ = other.data_;

if (auto* inline_rep = GetDenseInlinedRep()) {
Expand All @@ -1127,6 +1129,7 @@ class LiteralBase {
template <typename Rep, typename... Args>
Rep& Emplace(Args... args) {
Rep& emplaced = rep_.emplace<Rep>(std::forward<Args>(args)...);
std::lock_guard<std::mutex> lock(mutex_);
if constexpr (std::is_same_v<Rep, DenseRep> ||
std::is_same_v<Rep, DenseInlinedRep>) {
data_ = emplaced.data;
Expand Down Expand Up @@ -1157,11 +1160,13 @@ class LiteralBase {
TupleRep* GetTupleRep() { return std::get_if<TupleRep>(&rep_); }

const char* data() const {
std::lock_guard<std::mutex> lock(mutex_);
DCHECK_EQ(dense_data(), data_) << "cached data pointer is stale";
return data_;
}

char* data() {
std::lock_guard<std::mutex> lock(mutex_);
DCHECK_EQ(dense_data(), data_) << "cached data pointer is stale";
return data_;
}
Expand All @@ -1174,6 +1179,7 @@ class LiteralBase {
}

std::variant<Uninitialized, TupleRep, DenseRep, DenseInlinedRep> rep_;
mutable std::mutex mutex_;
char* data_ = nullptr; // cached `rep_.data` value for dense reps
};

Expand Down