Struct caffe2_context::ThreadLocalCUDAObjects
source · pub struct ThreadLocalCUDAObjects { /* private fields */ }
Expand description
| A struct to host thread-local cuda objects. | | In Caffe2, each thread has its own non-default | cuda stream as well as related objects | such as cublas and curand handles. | | This is achieved by having the ThreadLocalCUDAObjects | wrapper that takes care of allocating | and deallocating these objects at the | thread scope. | | This class is solely used inside CUDAContext | and should not be used externally. | | This class manages the mapping from | logical stream ID (int stream_id passed | around in Caffe2) and CudaStream objects. | | We intend to eventually deprecate the | logical stream ID interface, but not | for now. |
Implementations§
source§impl ThreadLocalCUDAObjects
impl ThreadLocalCUDAObjects
sourcepub fn set_current_stream_id(&mut self, gpu: DeviceIndex, stream_id: StreamId)
pub fn set_current_stream_id(&mut self, gpu: DeviceIndex, stream_id: StreamId)
| Record current stream id for the current | thread. | | This is the new API we’re trying to | migrate use cases to and get rid of | explicit stream id passing. | | For now it’s invoked in | CUDAContext::SwitchToDevice
sourcepub fn get_stream(&mut self, gpu: DeviceIndex) -> CudaStream
pub fn get_stream(&mut self, gpu: DeviceIndex) -> CudaStream
| Uses the logical stream id from the thread | local to pick the stream | | We’re going to migrate all usages to this | case API instead of passing the stream id | directly
pub fn get_stream_with_stream_id( &mut self, gpu: DeviceIndex, stream_id: StreamId ) -> CudaStream
sourcepub fn get_handle_with_device_index(&mut self, gpu: DeviceIndex) -> CublasHandle
pub fn get_handle_with_device_index(&mut self, gpu: DeviceIndex) -> CublasHandle
| Uses the logical stream id from the thread | local to pick the stream | | We’re going to migrate all usages to this | case API instead of passing the stream id | directly
sourcepub fn get_cudastream(
&mut self,
gpu: DeviceIndex,
stream_id: StreamId
) -> CudaStream
pub fn get_cudastream( &mut self, gpu: DeviceIndex, stream_id: StreamId ) -> CudaStream
| Retrieves the CudaStream corresponding to | a logical stream ID, ensuring that it | exists in cuda_streams_ if it has not been | allocated yet.
pub fn get_handle_with_cuda_stream( &mut self, cuda_stream: CudaStream ) -> CublasHandle
sourcepub fn get_cudnn_handle(&mut self, gpu: DeviceIndex)
pub fn get_cudnn_handle(&mut self, gpu: DeviceIndex)
| Uses the logical stream id from the thread | local to pick the stream | | We’re going to migrate all usages to this | case API instead of passing the stream id | directly
Trait Implementations§
source§impl Default for ThreadLocalCUDAObjects
impl Default for ThreadLocalCUDAObjects
Auto Trait Implementations§
impl RefUnwindSafe for ThreadLocalCUDAObjects
impl Send for ThreadLocalCUDAObjects
impl Sync for ThreadLocalCUDAObjects
impl Unpin for ThreadLocalCUDAObjects
impl UnwindSafe for ThreadLocalCUDAObjects
Blanket Implementations§
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.