Skip to content

Commit

Permalink
Improve use of map
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcrimsontianyu committed Oct 9, 2024
1 parent dc536af commit f68743f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cpp/include/kvikio/posix_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ class StreamsByThread {
auto key = std::make_pair(ctx, thd_id);

// Create a new stream if `ctx` doesn't have one.
if (_instance._streams.find(key) == _instance._streams.end()) {
if (auto search = _instance._streams.find(key); search == _instance._streams.end()) {
CUstream stream{};
CUDA_DRIVER_TRY(cudaAPI::instance().StreamCreate(&stream, CU_STREAM_DEFAULT));
_instance._streams[key] = stream;
return stream;
} else {
return search->second;
}
return _instance._streams.at(key);
}

static CUstream get()
Expand Down

0 comments on commit f68743f

Please sign in to comment.