402 lines
9.1 KiB
Markdown
402 lines
9.1 KiB
Markdown
pub struct Profiler;
|
||
Calls profiler_start() in Profiler::new(), and profiler_stop() in Drop.
|
||
|
||
Implementations
|
||
Source
|
||
impl Profiler
|
||
Source
|
||
pub fn new() -> Result<Self, DriverError>
|
||
Enables profile collection by the active profiling tool for the current context. If profiling is already enabled, then Profiler::new() has no effect. More info in Cuda docs
|
||
|
||
use cudarc::driver::{Profiler};
|
||
|
||
{
|
||
let profiler = Profiler::new()?;
|
||
// Hotpath
|
||
// Profiler stops on drop
|
||
}
|
||
// Now check your results
|
||
// nsys profile -c cudaProfilerApi /path/to/bin
|
||
// And this will profile only the hotpath.
|
||
Trait Implementations
|
||
Source
|
||
impl Default for Profiler
|
||
Source
|
||
fn default() -> Profiler
|
||
Returns the “default value” for a type. Read more
|
||
Source
|
||
impl Drop for Profiler
|
||
Source
|
||
fn drop(&mut self)
|
||
Executes the destructor for this type. Read more
|
||
Auto Trait Implementations
|
||
impl Freeze for Profiler
|
||
impl RefUnwindSafe for Profiler
|
||
impl Send for Profiler
|
||
impl Sync for Profiler
|
||
impl Unpin for Profiler
|
||
impl UnwindSafe for Profiler
|
||
Blanket Implementations
|
||
Source
|
||
impl<T> Any for T
|
||
where
|
||
T: 'static + ?Sized,
|
||
Source
|
||
fn type_id(&self) -> TypeId
|
||
Gets the TypeId of self. Read more
|
||
Source
|
||
impl<T> Borrow<T> for T
|
||
where
|
||
T: ?Sized,
|
||
Source
|
||
fn borrow(&self) -> &T
|
||
Immutably borrows from an owned value. Read more
|
||
Source
|
||
impl<T> BorrowMut<T> for T
|
||
where
|
||
T: ?Sized,
|
||
Source
|
||
fn borrow_mut(&mut self) -> &mut T
|
||
Mutably borrows from an owned value. Read more
|
||
Source
|
||
impl<T> From<T> for T
|
||
Source
|
||
fn from(t: T) -> T
|
||
Returns the argument unchanged.
|
||
|
||
Source
|
||
impl<T, U> Into<U> for T
|
||
where
|
||
U: From<T>,
|
||
Source
|
||
fn into(self) -> U
|
||
Calls U::from(self).
|
||
|
||
That is, this conversion is whatever the implementation of From<T> for U chooses to do.
|
||
|
||
Source
|
||
impl<T, U> TryFrom<U> for T
|
||
where
|
||
U: Into<T>,
|
||
Source
|
||
type Error = Infallible
|
||
The type returned in the event of a conversion error.
|
||
Source
|
||
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
|
||
Performs the conversion.
|
||
Source
|
||
impl<T, U> TryInto<U> for T
|
||
where
|
||
U: TryFrom<T>,
|
||
Source
|
||
type Error = <U as TryFrom<T>>::Error
|
||
The type returned in the event of a conversion error.
|
||
Source
|
||
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
|
||
Performs the conversion.
|
||
Source
|
||
impl<V, T> VZip<V> for T
|
||
where
|
||
V: MultiLane<T>,
|
||
|
||
------------------------------------------------
|
||
|
||
Enum SyncOnDrop Copy item path
|
||
Source
|
||
Search
|
||
Settings
|
||
Help
|
||
|
||
Summary
|
||
pub enum SyncOnDrop<'a> {
|
||
Record(Option<(&'a CudaEvent, &'a CudaStream)>),
|
||
Sync(Option<&'a CudaStream>),
|
||
}
|
||
A synchronization primitive to enable stream & event synchronization. Primarily used with DevicePtr and DevicePtrMut
|
||
|
||
Variants
|
||
Record(Option<(&'a CudaEvent, &'a CudaStream)>)
|
||
Will record the stream’s workload to the event on drop.
|
||
|
||
Sync(Option<&'a CudaStream>)
|
||
Will call stream synchronize on drop.
|
||
|
||
Implementations
|
||
Source
|
||
impl<'a> SyncOnDrop<'a>
|
||
Source
|
||
pub fn record_event(
|
||
event: &'a Option<CudaEvent>,
|
||
stream: &'a CudaStream,
|
||
) -> Self
|
||
Construct a SyncOnDrop::Record variant
|
||
|
||
Source
|
||
pub fn sync_stream(stream: &'a CudaStream) -> Self
|
||
Construct a SyncOnDrop::Sync variant
|
||
|
||
Trait Implementations
|
||
Source
|
||
impl<'a> Debug for SyncOnDrop<'a>
|
||
Source
|
||
fn fmt(&self, f: &mut Formatter<'_>) -> Result
|
||
Formats the value using the given formatter. Read more
|
||
Source
|
||
impl Drop for SyncOnDrop<'_>
|
||
Source
|
||
fn drop(&mut self)
|
||
Executes the destructor for this type. Read more
|
||
Auto Trait Implementations
|
||
impl<'a> Freeze for SyncOnDrop<'a>
|
||
impl<'a> RefUnwindSafe for SyncOnDrop<'a>
|
||
impl<'a> Send for SyncOnDrop<'a>
|
||
impl<'a> Sync for SyncOnDrop<'a>
|
||
impl<'a> Unpin for SyncOnDrop<'a>
|
||
impl<'a> UnwindSafe for SyncOnDrop<'a>
|
||
Blanket Implementations
|
||
Source
|
||
impl<T> Any for T
|
||
where
|
||
T: 'static + ?Sized,
|
||
Source
|
||
impl<T> Borrow<T> for T
|
||
where
|
||
T: ?Sized,
|
||
Source
|
||
impl<T> BorrowMut<T> for T
|
||
where
|
||
T: ?Sized,
|
||
Source
|
||
impl<T> From<T> for T
|
||
Source
|
||
impl<T, U> Into<U> for T
|
||
where
|
||
U: From<T>,
|
||
Source
|
||
impl<T, U> TryFrom<U> for T
|
||
where
|
||
U: Into<T>,
|
||
Source
|
||
impl<T, U> TryInto<U> for T
|
||
where
|
||
U: TryFrom<T>,
|
||
Source
|
||
impl<V, T> VZip<V> for T
|
||
where
|
||
V: MultiLane<T>,
|
||
|
||
---------------------------------------
|
||
|
||
pub trait DevicePtr<T>: DeviceSlice<T> {
|
||
// Required method
|
||
fn device_ptr<'a>(
|
||
&'a self,
|
||
stream: &'a CudaStream,
|
||
) -> (CUdeviceptr, SyncOnDrop<'a>);
|
||
}
|
||
Abstraction over CudaSlice/CudaView
|
||
|
||
Required Methods
|
||
Source
|
||
fn device_ptr<'a>(
|
||
&'a self,
|
||
stream: &'a CudaStream,
|
||
) -> (CUdeviceptr, SyncOnDrop<'a>)
|
||
Retrieve the device pointer with the intent to read the device memory associated with it.
|
||
|
||
Implementations of this method should ensure stream waits for any previous writes of this memory before continuing (do not need to wait for any previous reads).
|
||
|
||
The SyncOnDrop item of the return tuple should be dropped after the read of the sys::CUdeviceptr is scheduled.
|
||
|
||
In most cases you can use like:
|
||
|
||
ⓘ
|
||
let (src, _record_src) = src.device_ptr(&stream);
|
||
Which will drop the SyncOnDrop at the end of the scope.
|
||
|
||
Implementors
|
||
Source
|
||
impl DevicePtr<u8> for MappedBuffer
|
||
Source
|
||
impl<T> DevicePtr<T> for CudaSlice<T>
|
||
Source
|
||
impl<T> DevicePtr<T> for CudaView<'_, T>
|
||
Source
|
||
impl<T> DevicePtr<T> for CudaViewMut<'_, T>
|
||
Source
|
||
impl<T> DevicePtr<T> for UnifiedSlice<T>
|
||
|
||
-------------------------------------------
|
||
|
||
pub trait DevicePtrMut<T>: DeviceSlice<T> {
|
||
// Required method
|
||
fn device_ptr_mut<'a>(
|
||
&'a mut self,
|
||
stream: &'a CudaStream,
|
||
) -> (CUdeviceptr, SyncOnDrop<'a>);
|
||
}
|
||
Abstraction over CudaSlice/CudaViewMut
|
||
|
||
Required Methods
|
||
Source
|
||
fn device_ptr_mut<'a>(
|
||
&'a mut self,
|
||
stream: &'a CudaStream,
|
||
) -> (CUdeviceptr, SyncOnDrop<'a>)
|
||
Retrieve the device pointer with the intent to modify the device memory associated with it.
|
||
|
||
Implementations of this method should ensure stream waits for any previous reads/writes of this memory before continuing.
|
||
|
||
The SyncOnDrop item of the return tuple should be dropped after the write of the sys::CUdeviceptr is scheduled.
|
||
|
||
In most cases you can use like:
|
||
|
||
ⓘ
|
||
let (src, _record_src) = src.device_ptr_mut(&stream);
|
||
Which will drop the SyncOnDrop at the end of the scope.
|
||
|
||
Implementors
|
||
Source
|
||
impl<T> DevicePtrMut<T> for CudaSlice<T>
|
||
Source
|
||
impl<T> DevicePtrMut<T> for CudaViewMut<'_, T>
|
||
Source§
|
||
impl<T> DevicePtrMut<T> for UnifiedSlice<T>
|
||
|
||
------------------------------------------------------
|
||
|
||
pub unsafe trait DeviceRepr { }
|
||
Something that can be copied to device memory and turned into a parameter for result::launch_kernel.
|
||
|
||
Safety
|
||
This is unsafe because a struct should likely be #[repr(C)] to be represented in cuda memory, and not all types are valid.
|
||
|
||
Implementations on Foreign Types
|
||
Source
|
||
impl DeviceRepr for bool
|
||
Source
|
||
impl DeviceRepr for f32
|
||
Source
|
||
impl DeviceRepr for f64
|
||
Source
|
||
impl DeviceRepr for i8
|
||
Source
|
||
impl DeviceRepr for i16
|
||
Source
|
||
impl DeviceRepr for i32
|
||
Source
|
||
impl DeviceRepr for i64
|
||
Source
|
||
impl DeviceRepr for i128
|
||
Source
|
||
impl DeviceRepr for isize
|
||
Source
|
||
impl DeviceRepr for u8
|
||
Source
|
||
impl DeviceRepr for u16
|
||
Source
|
||
impl DeviceRepr for u32
|
||
Source
|
||
impl DeviceRepr for u64
|
||
Source
|
||
impl DeviceRepr for u128
|
||
Source
|
||
impl DeviceRepr for usize
|
||
Source
|
||
impl DeviceRepr for bf16
|
||
Source§
|
||
impl DeviceRepr for f16
|
||
|
||
-----------------
|
||
|
||
pub trait DeviceSlice<T> {
|
||
// Required methods
|
||
fn len(&self) -> usize;
|
||
fn stream(&self) -> &Arc<CudaStream>;
|
||
|
||
// Provided methods
|
||
fn num_bytes(&self) -> usize { ... }
|
||
fn is_empty(&self) -> bool { ... }
|
||
}
|
||
Base trait for abstracting over CudaSlice/CudaView/CudaViewMut.
|
||
|
||
Don’t use this directly - use DevicePtr/DevicePtrMut.
|
||
|
||
Required Methods
|
||
Source
|
||
fn len(&self) -> usize
|
||
Source
|
||
fn stream(&self) -> &Arc<CudaStream>
|
||
Provided Methods
|
||
Source
|
||
fn num_bytes(&self) -> usize
|
||
Source
|
||
fn is_empty(&self) -> bool
|
||
Implementors
|
||
Source
|
||
impl DeviceSlice<u8> for MappedBuffer
|
||
Source
|
||
impl<T> DeviceSlice<T> for CudaSlice<T>
|
||
Source
|
||
impl<T> DeviceSlice<T> for CudaView<'_, T>
|
||
Source
|
||
impl<T> DeviceSlice<T> for CudaViewMut<'_, T>
|
||
Source
|
||
impl<T> DeviceSlice<T> for UnifiedSlice<T>
|
||
|
||
---------------------
|
||
|
||
pub trait HostSlice<T> {
|
||
// Required methods
|
||
fn len(&self) -> usize;
|
||
unsafe fn stream_synced_slice<'a>(
|
||
&'a self,
|
||
stream: &'a CudaStream,
|
||
) -> (&'a [T], SyncOnDrop<'a>);
|
||
unsafe fn stream_synced_mut_slice<'a>(
|
||
&'a mut self,
|
||
stream: &'a CudaStream,
|
||
) -> (&'a mut [T], SyncOnDrop<'a>);
|
||
|
||
// Provided method
|
||
fn is_empty(&self) -> bool { ... }
|
||
}
|
||
Abstraction over &[T], &Vec<T> and PinnedHostSlice<T>.
|
||
|
||
Required Methods
|
||
Source
|
||
fn len(&self) -> usize
|
||
Source
|
||
unsafe fn stream_synced_slice<'a>(
|
||
&'a self,
|
||
stream: &'a CudaStream,
|
||
) -> (&'a [T], SyncOnDrop<'a>)
|
||
Safety
|
||
This is only safe if the resulting slice is used with stream. Otherwise You may run into device synchronization errors
|
||
|
||
Source
|
||
unsafe fn stream_synced_mut_slice<'a>(
|
||
&'a mut self,
|
||
stream: &'a CudaStream,
|
||
) -> (&'a mut [T], SyncOnDrop<'a>)
|
||
Safety
|
||
This is only safe if the resulting slice is used with stream. Otherwise You may run into device synchronization errors
|
||
|
||
Provided Methods
|
||
Source
|
||
fn is_empty(&self) -> bool
|
||
Implementations on Foreign Types
|
||
Source
|
||
impl<T> HostSlice<T> for [T]
|
||
Source
|
||
impl<T> HostSlice<T> for Vec<T>
|
||
Source
|
||
impl<T, const N: usize> HostSlice<T> for [T; N]
|
||
Implementors
|
||
Source
|
||
impl<T> HostSlice<T> for PinnedHostSlice<T>
|
||
Source
|
||
impl<T> HostSlice<T> for UnifiedSlice<T>
|
||
|
||
---------------------------
|