Skip to content

[SYCL][CUDA] Use context mutex in refcount inc/dec #6577

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

Merged
merged 1 commit into from
Aug 16, 2022
Merged
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
10 changes: 8 additions & 2 deletions sycl/plugins/cuda/pi_cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,15 @@ struct _pi_context {

bool is_primary() const noexcept { return kind_ == kind::primary; }

pi_uint32 increment_reference_count() noexcept { return ++refCount_; }
pi_uint32 increment_reference_count() noexcept {
std::lock_guard<std::mutex> guard(mutex_);
return ++refCount_;
}

pi_uint32 decrement_reference_count() noexcept { return --refCount_; }
pi_uint32 decrement_reference_count() noexcept {
std::lock_guard<std::mutex> guard(mutex_);
return --refCount_;
}

pi_uint32 get_reference_count() const noexcept { return refCount_; }

Expand Down