Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:11

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2022-2026 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 // Local include(s).
0009 #include "traccc/cuda/utils/stream_wrapper.hpp"
0010 
0011 #include "cuda_error_handling.hpp"
0012 
0013 // CUDA include(s).
0014 #include <cuda_runtime_api.h>
0015 
0016 namespace traccc::cuda {
0017 
0018 stream_wrapper::stream_wrapper(void* stream) : m_stream{stream} {}
0019 
0020 int stream_wrapper::device() const {
0021   // The device ID.
0022   int device = -1;
0023 
0024 #ifdef TRACCC_HAVE_CUDA_STREAM_GET_DEVICE
0025   // Somewhere around CUDA 12.8 this became available.
0026   TRACCC_CUDA_ERROR_CHECK(
0027       cudaStreamGetDevice(static_cast<cudaStream_t>(m_stream), &device));
0028 
0029 #else
0030   // If the CUDA version is too old to support cudaStreamGetDevice, we return
0031   // the current device instead. This is not ideal, but should be good enough.
0032   TRACCC_CUDA_ERROR_CHECK(cudaGetDevice(&device));
0033 #endif
0034 
0035   // Return the device ID.
0036   return device;
0037 }
0038 
0039 void* stream_wrapper::cudaStream() const {
0040   return m_stream;
0041 }
0042 
0043 void stream_wrapper::synchronize() const {
0044   TRACCC_CUDA_ERROR_CHECK(
0045       cudaStreamSynchronize(static_cast<cudaStream_t>(m_stream)));
0046 }
0047 
0048 }  // namespace traccc::cuda