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 #pragma once
0009 
0010 namespace traccc::cuda {
0011 
0012 /// Wrapper class around @c cudaStream_t
0013 ///
0014 /// It is necessary for passing around CUDA stream objects in code that should
0015 /// not be directly exposed to the CUDA header(s).
0016 ///
0017 /// Note that unlike @c vecmem::cuda::stream_wrapper, this type can not own a
0018 /// stream of its own. It can only view a stream that is owned by
0019 /// "somebody else".
0020 ///
0021 class stream_wrapper {
0022  public:
0023   /// Wrap an existing @c cudaStream_t object, without taking ownership
0024   explicit stream_wrapper(void* stream);
0025 
0026   /// Copy constructor
0027   stream_wrapper(const stream_wrapper& parent) = default;
0028   /// Move constructor
0029   stream_wrapper(stream_wrapper&& parent) = default;
0030 
0031   /// Copy assignment
0032   stream_wrapper& operator=(const stream_wrapper& rhs) = default;
0033   /// Move assignment
0034   stream_wrapper& operator=(stream_wrapper&& rhs) = default;
0035 
0036   /// Device that the stream is associated to
0037   int device() const;
0038 
0039   /// Access a typeless pointer to the managed @c cudaStream_t object
0040   void* cudaStream() const;
0041 
0042   /// Wait for all queued tasks from the stream to complete
0043   void synchronize() const;
0044 
0045  private:
0046   /// Bare pointer to the wrapped @c cudaStream_t object
0047   void* m_stream;
0048 
0049 };  // class stream_wrapper
0050 
0051 }  // namespace traccc::cuda