Skip to main content

FileHandle

Struct FileHandle 

Source
pub struct FileHandle { /* private fields */ }
Expand description

A registered file descriptor.

Implementations§

Source§

impl FileHandle

Source

pub unsafe fn register(fd: i32) -> Result<Self>

Register an open file descriptor with cuFile. fd is typically obtained from std::fs::File::as_raw_fd() on Linux.

§Safety

fd must stay open for the lifetime of the returned handle.

Source

pub fn as_raw(&self) -> CUfileHandle_t

Source

pub unsafe fn read( &self, dev_buf: *mut c_void, size: usize, file_offset: i64, buf_offset: i64, ) -> Result<usize>

Read size bytes from file_offset into dev_buf + buf_offset. Returns the number of bytes actually read (negative on failure; we map negatives to Err).

§Safety

dev_buf must be a device pointer with at least size bytes live starting at buf_offset.

Source

pub unsafe fn write( &self, dev_buf: *const c_void, size: usize, file_offset: i64, buf_offset: i64, ) -> Result<usize>

Write size bytes from dev_buf + buf_offset into file_offset.

§Safety

Same as Self::read.

Source§

impl FileHandle

Source

pub unsafe fn read_async( &self, dev_buf: *mut c_void, size_p: *mut usize, file_offset_p: *mut i64, buf_offset_p: *mut i64, bytes_read: *mut isize, stream: *mut c_void, ) -> Result<()>

Queue a stream-ordered read. All parameters point at device / pinned-host memory that cuFile reads when the stream reaches this op (not at call time). bytes_read is written when the op completes.

§Safety

All pointers must stay live until the stream reports completion. stream must be previously registered via StreamRegistration::register.

Source

pub unsafe fn write_async( &self, dev_buf: *const c_void, size_p: *mut usize, file_offset_p: *mut i64, buf_offset_p: *mut i64, bytes_written: *mut isize, stream: *mut c_void, ) -> Result<()>

Queue a stream-ordered write.

§Safety

Same as Self::read_async.

Source

pub fn use_count(&self) -> Result<i32>

cuFile’s per-handle ref-count (non-zero = handle in use by outstanding I/O).

Trait Implementations§

Source§

impl Debug for FileHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for FileHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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.