cufile.h(3)
okay bestie, welcome to cufile.h(3) from the Library Functions Manual โ the cuFile C APIs page, and it is a lot in the best way. ๐
โจ NAME โจ
cufile.h โ cuFile C APIs. That's the whole vibe. ๐ซถ
โจ SYNOPSIS โจ
Data Structures ๐
struct CUfileDescr_tstruct CUfileDrvPropsstruct CUfileErrorโ note:cufileop status stringstruct CUfileFSOpsstruct CUfileIOEventsstruct CUfileIOParamsstruct cufileRDMAInfo
Macros ๐ง
CU_FILE_CUDA_ERR(status)โ pulls out the CUDA error:
#define CU_FILE_CUDA_ERR(status) ((status).cu_err)
CU_FILE_RDMA_REGISTERโ the value is1:
#define CU_FILE_RDMA_REGISTER 1
CU_FILE_RDMA_RELAXED_ORDERINGโ the value is(1<<1):
#define CU_FILE_RDMA_RELAXED_ORDERING (1<<1)
CU_FILE_STREAM_FIXED_BUF_OFFSETโ the value is1:
#define CU_FILE_STREAM_FIXED_BUF_OFFSET 1
CU_FILE_STREAM_FIXED_FILE_OFFSETโ the value is2:
#define CU_FILE_STREAM_FIXED_FILE_OFFSET 2
CU_FILE_STREAM_FIXED_FILE_SIZEโ the value is4:
#define CU_FILE_STREAM_FIXED_FILE_SIZE 4
CU_FILE_STREAM_PAGE_ALIGNED_INPUTSโ the value is8:
#define CU_FILE_STREAM_PAGE_ALIGNED_INPUTS 8
CUFILE_ERRSTR(err)โ this one is giving error-string realness:
#define CUFILE_ERRSTR(err)
cufileop_status_error((CUfileOpError)abs((err)))
cuFileDriverCloseโ aliases straight tocuFileDriverClose_v2:
#define cuFileDriverClose cuFileDriverClose_v2
IS_CUDA_ERR(status)โ checks forCU_FILE_CUDA_DRIVER_ERROR:
#define IS_CUDA_ERR(status) ((status).err ==
CU_FILE_CUDA_DRIVER_ERROR)
IS_CUFILE_ERR(err)โ checks(abs((err)) > CUFILEOP_BASE_ERR):
#define IS_CUFILE_ERR(err) (abs((err)) > CUFILEOP_BASE_ERR)
- and these are the error macros to inspect error status of type
CUfileOpErrorโ yes, that whole little note is part of the package, bestie.
Typedefs ๐ฆ
typedef void * CUfileBatchHandle_ttypedef enum cufileBatchMode CUfileBatchMode_ttypedef struct CUfileDescr_t CUfileDescr_ttypedef enum CUfileDriverControlFlags CUfileDriverControlFlags_ttypedef enum CUfileDriverStatusFlags CUfileDriverStatusFlags_ttypedef struct CUfileDrvProps CUfileDrvProps_ttypedef struct CUfileError CUfileError_tโ note:cufileop status stringtypedef enum CUfileFeatureFlags CUfileFeatureFlags_ttypedef struct CUfileFSOps CUfileFSOps_ttypedef void * CUfileHandle_tโ note:File handle type.typedef struct CUfileIOEvents CUfileIOEvents_ttypedef struct CUfileIOParams CUfileIOParams_ttypedef enum CUfileOpcode CUfileOpcode_ttypedef struct cufileRDMAInfo cufileRDMAInfo_ttypedef enum CUFILEStatus_enum CUfileStatus_ttypedef struct sockaddr sockaddr_t
Enumerations ๐ฅ
enum cufileBatchMode:
enum cufileBatchMode { CUFILE_BATCH = 1 }
enum CUfileDriverControlFlags:
enum CUfileDriverControlFlags { CU_FILE_USE_POLL_MODE = 0,
CU_FILE_ALLOW_COMPAT_MODE = 1 }
enum CUfileDriverStatusFlags:
enum CUfileDriverStatusFlags { CU_FILE_LUSTRE_SUPPORTED = 0,
CU_FILE_WEKAFS_SUPPORTED = 1, CU_FILE_NFS_SUPPORTED = 2,
CU_FILE_GPFS_SUPPORTED = 3, CU_FILE_NVME_SUPPORTED = 4,
CU_FILE_NVMEOF_SUPPORTED = 5, CU_FILE_SCSI_SUPPORTED = 6,
CU_FILE_SCALEFLUX_CSD_SUPPORTED = 7, CU_FILE_NVMESH_SUPPORTED = 8,
CU_FILE_BEEGFS_SUPPORTED = 9 }
enum CUfileFeatureFlags:
enum CUfileFeatureFlags { CU_FILE_DYN_ROUTING_SUPPORTED = 0,
CU_FILE_BATCH_IO_SUPPORTED = 1, CU_FILE_STREAMS_SUPPORTED = 2,
CU_FILE_PARALLEL_IO_SUPPORTED = 3 }
enum CUfileFileHandleType:
enum CUfileFileHandleType { CU_FILE_HANDLE_TYPE_OPAQUE_FD = 1,
CU_FILE_HANDLE_TYPE_OPAQUE_WIN32 = 2,
CU_FILE_HANDLE_TYPE_USERSPACE_FS = 3 }
enum CUfileOpcode:
enum CUfileOpcode { CUFILE_READ = 0, CUFILE_WRITE }
enum CUFILEStatus_enum:
enum CUFILEStatus_enum { CUFILE_WAITING = 0x000001, CUFILE_PENDING =
0x000002, CUFILE_INVALID = 0x000004, CUFILE_CANCELED = 0x000008,
CUFILE_COMPLETE = 0x0000010, CUFILE_TIMEOUT = 0x0000020,
CUFILE_FAILED = 0x0000040 }
Functions ๐
CUfileError_t cuFileBatchIOCancel (CUfileBatchHandle_t batch_idp)void cuFileBatchIODestroy (CUfileBatchHandle_t batch_idp)CUfileError_t cuFileBatchIOGetStatus (CUfileBatchHandle_t batch_idp, unsigned min_nr, unsigned *nr, CUfileIOEvents_t *iocbp, struct timespec *timeout)CUfileError_t cuFileBatchIOSetUp (CUfileBatchHandle_t *batch_idp, unsigned nr)CUfileError_t cuFileBatchIOSubmit (CUfileBatchHandle_t batch_idp, unsigned nr, CUfileIOParams_t *iocbp, unsigned int flags)CUfileError_t cuFileBufDeregister (const void *bufPtr_base)โ deregister an already registered device or host memory from cuFileCUfileError_t cuFileBufRegister (const void *bufPtr_base, size_t length, int flags)โ register an existing cudaMalloced memory with cuFile to pin for GPUDirect Storage access, or register host allocated memory with cuFile.CUfileError_t cuFileDriverClose (void)CUfileError_t cuFileDriverClose_v2 (void)โ reset the cuFile library and release the nvidia-fs driverCUfileError_t cuFileDriverGetProperties (CUfileDrvProps_t *props)โ gets the Driver session properties.CUfileError_t cuFileDriverOpen (void)โ initialize the cuFile library and open the nvidia-fs driver.CUfileError_t cuFileDriverSetMaxCacheSize (size_t max_cache_size)โ control parameter to set maximum GPU memory reserved per device by the library for internal buffering.CUfileError_t cuFileDriverSetMaxDirectIOSize (size_t max_direct_io_size)โ control parameter to set max IO size(KB) used by the library to talk to nvidia-fs driver.CUfileError_t cuFileDriverSetMaxPinnedMemSize (size_t max_pinned_size)โ sets maximum buffer space that is pinned in KB for use bycuFileBufRegister.CUfileError_t cuFileDriverSetPollMode (bool poll, size_t poll_threshold_size)โ sets whether the Read/Write APIs use polling to do IO operations.CUfileError_t cuFileGetVersion (int *version)void cuFileHandleDeregister (CUfileHandle_t fh)โ releases a registered filehandle from cuFileCUfileError_t cuFileHandleRegister (CUfileHandle_t *fh, CUfileDescr_t *descr)โcuFileHandleRegisteris required, and performs extra checking that is memoized to provide increased performance on later cuFile operations.ssize_t cuFileRead (CUfileHandle_t fh, void *bufPtr_base, size_t size, off_t file_offset, off_t bufPtr_offset)โ read data from a registered file handle to a specified device or host memoryCUfileError_t cuFileReadAsync (CUfileHandle_t fh, void *bufPtr_base, size_t *size_p, off_t *file_offset_p, off_t *bufPtr_offset_p, ssize_t *bytes_read_p, CUstream stream)CUfileError_t cuFileStreamDeregister (CUstream stream)CUfileError_t cuFileStreamRegister (CUstream stream, unsigned flags)long cuFileUseCount (void)โ returns use count of cufile drivers at that moment by the process.ssize_t cuFileWrite (CUfileHandle_t fh, const void *bufPtr_base, size_t size, off_t file_offset, off_t bufPtr_offset)โ write data from a specified device or host memory to a registered file handleCUfileError_t cuFileWriteAsync (CUfileHandle_t fh, void *bufPtr_base, size_t *size_p, off_t *file_offset_p, off_t *bufPtr_offset_p, ssize_t *bytes_written_p, CUstream stream)
Variables ๐
CUfileOpError
๐ธ DETAILED DESCRIPTION ๐ธ
cuFile C APIs.
This file contains all the C APIs to perform GPUDirect Storage supported IO operations. Like, all of them. ๐
๐ง MACRO DEFINITION DOCUMENTATION ๐ง
Yep, same macro squad, now in documentation form:
CU_FILE_CUDA_ERR(status):
#define CU_FILE_CUDA_ERR(status) ((status).cu_err)
CU_FILE_RDMA_REGISTER:
#define CU_FILE_RDMA_REGISTER 1
CU_FILE_RDMA_RELAXED_ORDERING:
#define CU_FILE_RDMA_RELAXED_ORDERING (1<<1)
CU_FILE_STREAM_FIXED_BUF_OFFSET:
#define CU_FILE_STREAM_FIXED_BUF_OFFSET 1
CU_FILE_STREAM_FIXED_FILE_OFFSET:
#define CU_FILE_STREAM_FIXED_FILE_OFFSET 2
CU_FILE_STREAM_FIXED_FILE_SIZE:
#define CU_FILE_STREAM_FIXED_FILE_SIZE 4
CU_FILE_STREAM_PAGE_ALIGNED_INPUTS:
#define CU_FILE_STREAM_PAGE_ALIGNED_INPUTS 8
CUFILE_ERRSTR(err):
#define CUFILE_ERRSTR(err)
cufileop_status_error((CUfileOpError)abs((err)))
cuFileDriverClose:
#define cuFileDriverClose cuFileDriverClose_v2
IS_CUDA_ERR(status):
#define IS_CUDA_ERR(status) ((status).err == CU_FILE_CUDA_DRIVER_ERROR)
IS_CUFILE_ERR(err):
#define IS_CUFILE_ERR(err) (abs((err)) > CUFILEOP_BASE_ERR)
- and again, these are the error macros to inspect error status of type
CUfileOpError. Iconic. โจ
๐ TYPEDEF DOCUMENTATION ๐
typedef void* CUfileBatchHandle_ttypedef enum cufileBatchMode CUfileBatchMode_ttypedef struct CUfileDescr_t CUfileDescr_ttypedef enum CUfileDriverControlFlags CUfileDriverControlFlags_ttypedef enum CUfileDriverStatusFlags CUfileDriverStatusFlags_ttypedef struct CUfileDrvProps CUfileDrvProps_ttypedef struct CUfileError CUfileError_tโ note:cufileop status stringtypedef enum CUfileFeatureFlags CUfileFeatureFlags_ttypedef struct CUfileFSOps CUfileFSOps_ttypedef void* CUfileHandle_tโ note:File handle type.typedef struct CUfileIOEvents CUfileIOEvents_ttypedef struct CUfileIOParams CUfileIOParams_ttypedef enum CUfileOpcode CUfileOpcode_ttypedef struct cufileRDMAInfo cufileRDMAInfo_ttypedef enum CUFILEStatus_enum CUfileStatus_ttypedef struct sockaddr sockaddr_t
๐ฅ ENUMERATION TYPE DOCUMENTATION ๐ฅ
enum cufileBatchMode
Enumerator โจ
CUFILE_BATCHโ no extra description on the page, just the name.
enum CUfileDriverControlFlags
Enumerator โจ
CU_FILE_USE_POLL_MODEโ use POLL mode.properties.use_poll_modeCU_FILE_ALLOW_COMPAT_MODEโ allow COMPATIBILITY mode.properties.allow_compat_mode
enum CUfileDriverStatusFlags
Enumerator โจ
CU_FILE_LUSTRE_SUPPORTEDโ Support for DDN LUSTRECU_FILE_WEKAFS_SUPPORTEDโ Support for WEKAFSCU_FILE_NFS_SUPPORTEDโ Support for NFSCU_FILE_GPFS_SUPPORTEDโ no description on the page, bestieCU_FILE_NVME_SUPPORTEDโ< Support for GPFS Support for NVMeCU_FILE_NVMEOF_SUPPORTEDโ Support for NVMeOFCU_FILE_SCSI_SUPPORTEDโ Support for SCSICU_FILE_SCALEFLUX_CSD_SUPPORTEDโ Support for Scaleflux CSDCU_FILE_NVMESH_SUPPORTEDโ Support for NVMesh Block DevCU_FILE_BEEGFS_SUPPORTEDโ Support for BeeGFS
enum CUfileFeatureFlags
Enumerator โจ
CU_FILE_DYN_ROUTING_SUPPORTEDโ Support for Dynamic routing to handle devices across the PCIe bridgesCU_FILE_BATCH_IO_SUPPORTEDโ UnsupportedCU_FILE_STREAMS_SUPPORTEDโ UnsupportedCU_FILE_PARALLEL_IO_SUPPORTEDโ Unsupported
enum CUfileFileHandleType
Enumerator โจ
CU_FILE_HANDLE_TYPE_OPAQUE_FDโ Linux based fdCU_FILE_HANDLE_TYPE_OPAQUE_WIN32โ Windows based handle (unsupported)CU_FILE_HANDLE_TYPE_USERSPACE_FSโ no description on the page
enum CUfileOpcode
Enumerator โจ
CUFILE_READโ no extra description on the pageCUFILE_WRITEโ no extra description on the page
enum CUFILEStatus_enum
Enumerator โจ
CUFILE_WAITINGCUFILE_PENDINGCUFILE_INVALIDCUFILE_CANCELEDCUFILE_COMPLETECUFILE_TIMEOUTCUFILE_FAILED
๐ FUNCTION DOCUMENTATION ๐
CUfileError_t cuFileBatchIOCancel (CUfileBatchHandle_t batch_idp)
No extra description on the page for this one โ it's just the signature and main-character energy.
void cuFileBatchIODestroy (CUfileBatchHandle_t batch_idp)
Also just the signature here.
CUfileError_t cuFileBatchIOGetStatus (CUfileBatchHandle_t batch_idp, unsigned min_nr, unsigned * nr, CUfileIOEvents_t * iocbp, struct timespec * timeout)
Signature only, bestie.
CUfileError_t cuFileBatchIOSetUp (CUfileBatchHandle_t * batch_idp, unsigned nr)
Signature only. Slay.
CUfileError_t cuFileBatchIOSubmit (CUfileBatchHandle_t batch_idp, unsigned nr, CUfileIOParams_t * iocbp, unsigned int flags)
Signature only.
CUfileError_t cuFileBufDeregister (const void * bufPtr_base)
deregister an already registered device or host memory from cuFile
Parameters
bufPtr_baseโ buffer pointer to deregister
Returns
CU_FILE_SUCCESSon successCU_FILE_INVALID_VALUEon invalid memory pointer or unregistered memory pointer
See also
cuFileBufRegistercuFileReadcuFileWrite
CUfileError_t cuFileBufRegister (const void * bufPtr_base, size_t length, int flags)
register an existing cudaMalloced memory with cuFile to pin for GPUDirect Storage access or register host allocated memory with cuFile.
Parameters:
bufPtr_baseโ the buffer pointer you allocated ๐ซถlengthโ the size of the memory region, counting from thatbufPtr_basewe just mentionedflagsโCU_FILE_RDMA_REGISTER
Returns:
CU_FILE_SUCCESSwhen it goes through โจCU_FILE_NVFS_DRIVER_ERRORCU_FILE_INVALID_VALUECU_FILE_CUDA_ERRORโ for unsupported memory typeCU_FILE_MEMORY_ALREADY_REGISTEREDโ on errorCU_FILE_GPU_MEMORY_PINNING_FAILEDโ if there's not enough pinned memory available
Note: this memory is gonna be used to perform GPU direct DMA from the supported storage.
Warning: this API is intended for usecases where the memory is used as a streaming buffer that gets reused across multiple cuFile IO operations before you call cuFileBufDeregister. iykyk ๐ฅ
See also: cuFileBufDeregister, cuFileRead, cuFileWrite
cuFileDriverClose / cuFileDriverClose_v2
CUfileError_t cuFileDriverClose (void)
CUfileError_t cuFileDriverClose_v2 (void)
okay so these two literally reset the cuFile library and release the nvidia-fs driver ๐
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_CLOSINGโ if there are any active IO operations usingcuFileReadorcuFileWrite
See also: cuFileDriverOpen
cuFileDriverGetProperties
CUfileError_t cuFileDriverGetProperties (CUfileDrvProps_t * props)
Gets the Driver session properties ๐
Returns:
CU_FILE_SUCCESSon success
See also: cuFileDriverSetPollMode, cuFileDriverSetMaxDirectIOSize, cuFileDriverSetMaxCacheSize, cuFileDriverSetMaxPinnedMemSize
cuFileDriverOpen
CUfileError_t cuFileDriverOpen (void)
Initialize the cuFile library and open the nvidia-fs driver ๐ this is like the main character entrance of the whole API ngl
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_NOT_INITIALIZEDCU_FILE_DRIVER_VERSION_MISMATCHโ on driver version mismatch error
See also: cuFileDriverClose
cuFileDriverSetMaxCacheSize
CUfileError_t cuFileDriverSetMaxCacheSize (size_t max_cache_size)
Control parameter to set the maximum GPU memory reserved per device by the library for its internal buffering ๐
Parameters:
max_cache_sizeโ the maximum GPU buffer space per device used for internal use, in KB
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_NOT_INITIALIZEDโ if the driver is not initializedCU_FILE_DRIVER_VERSION_MISMATCH,CU_FILE_DRIVER_UNSUPPORTED_LIMITโ on error
Warning: this is an advanced command and should be tuned based on supported GPU memory. no cap, don't just yeet a number in there ๐
See also: cuFileDriverGetProperties
cuFileDriverSetMaxDirectIOSize
CUfileError_t cuFileDriverSetMaxDirectIOSize (size_t max_direct_io_size)
Control parameter to set the max IO size (KB) that the library uses to talk to the nvidia-fs driver ๐
Parameters:
max_direct_io_sizeโ maximum allowed direct io size in KB
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_NOT_INITIALIZEDโ if the driver is not initializedCU_FILE_DRIVER_VERSION_MISMATCH,CU_FILE_DRIVER_UNSUPPORTED_LIMITโ on error
Warning: this is an advanced command and should be tuned based on available system memory ๐ซถ
See also: cuFileDriverGetProperties
cuFileDriverSetMaxPinnedMemSize
CUfileError_t cuFileDriverSetMaxPinnedMemSize (size_t max_pinned_size)
Sets the maximum buffer space that is pinned, in KB, for use by cuFileBufRegister ๐ง
Parameters:
max_pinned_sizeโ maximum buffer space that is pinned, in KB
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_NOT_INITIALIZEDโ if the driver is not initializedCU_FILE_DRIVER_VERSION_MISMATCH,CU_FILE_DRIVER_UNSUPPORTED_LIMITโ on error
Warning: this is an advanced command and should be tuned based on supported GPU memory ๐
See also: cuFileDriverGetProperties
cuFileDriverSetPollMode
CUfileError_t cuFileDriverSetPollMode (bool poll, size_t poll_threshold_size)
Sets whether the Read/Write APIs use polling to do IO operations โญ like, do we spin or do we not spin, that is the question
Parameters:
pollโ boolean to indicate whether to use poll mode or notpoll_threshold_sizeโ max IO size to use for POLLING mode, in KB
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_NOT_INITIALIZEDโ if the driver is not initializedCU_FILE_DRIVER_VERSION_MISMATCH,CU_FILE_DRIVER_UNSUPPORTED_LIMITโ on error
Warning: this is an advanced command and should be tuned based on available system memory ๐ธ
See also: cuFileDriverGetProperties
cuFileGetVersion
CUfileError_t cuFileGetVersion (int * version)
Returns: the cufile library version ๐
version comes back as (1000 major + 10 minor). example: CUFILE 1.7.0 would be represented by 1070. math ate, honestly ๐งฎโจ
Note: this is useful for applications that need to inquire the library.
Returns:
CU_FILE_SUCCESSon successCU_FILE_INVALID_VALUEโ if the input parameter is nullCU_FILE_DRIVER_VERSION_READ_ERRORโ if the version is not available
cuFileHandleDeregister
void cuFileHandleDeregister (CUfileHandle_t fh)
releases a registered filehandle from cuFile ๐ฆ bye bestie
Parameters:
fhโCUfileHandle_tfile handle
Returns: void
See also: cuFileHandleRegister
cuFileHandleRegister
CUfileError_t cuFileHandleRegister (CUfileHandle_t * fh, CUfileDescr_t * descr)
cuFileHandleRegister is required, and it performs extra checking that's memoized so that later cuFile operations go faster ๐ฅ (memoized!! we love a caching king)
Parameters:
fhโCUfileHandle_topaque file handle for IO operationsdescrโCUfileDescr_tfile descriptor (OS agnostic)
Returns:
CU_FILE_SUCCESSon successful completion.fhwill be updated for use incuFileRead,cuFileWrite,cuFileHandleDeregisterCU_FILE_DRIVER_NOT_INITIALIZEDโ on failure to load driverCU_FILE_IO_NOT_SUPPORTEDโ if filesystem is not supportedCU_FILE_INVALID_VALUEโ if null or bad api argumentsCU_FILE_INVALID_FILE_OPEN_FLAGโ if file is opened with unsupported modes like noO_DIRECTCU_FILE_INVALID_FILE_TYPEโ if filepath is not valid or is not a regular fileCU_FILE_HANDLE_ALREADY_REGISTEREDโ if file handle/descriptor is already registered
Description: cuFileHandleRegister registers the open file descriptor for use with cuFile IO operations ๐
This API will ensure that the file's descriptor is checked for GPUDirect Storage support and returns a valid file handle on CU_FILE_SUCCESS.
Note: the file needs to be opened in O_DIRECT mode to support GPUDirect Storage. do not skip this one, fr fr ๐ญ
See also: cuFileRead, cuFileWrite, cuFileHandleDeregister
cuFileRead
ssize_t cuFileRead (CUfileHandle_t fh, void * bufPtr_base, size_t size, off_t file_offset, off_t bufPtr_offset)
read data from a registered file handle into a specified device or host memory ๐โจ
Parameters:
fhโCUfileHandle_topaque file handlebufPtr_baseโ base address of buffer in device or host memorysizeโ size bytes to readfile_offsetโ file-offset from beginning of the filebufPtr_offsetโ offset relative to thebufPtr_basepointer to read into.
Returns:
- size of bytes successfully read
-1on error, in which caseerrnois set to indicate filesystem errors.- all other errors will return a negative integer value of
CUfileOpErrorenum value.
Note: if the bufPtr is not registered with cuFileBufRegister, the data will be buffered through preallocated pinned buffers if needed ๐ซถ
This is useful for applications that need to perform IO to unaligned file offsets and/or size. This is also recommended for cases where the BAR1 memory size is smaller than the size of the allocated memory ๐
See also: cuFileBufRegister, cuFileHandleRegister, cuFileWrite
cuFileReadAsync
CUfileError_t cuFileReadAsync (CUfileHandle_t fh, void * bufPtr_base, size_t * size_p, off_t * file_offset_p, off_t * bufPtr_offset_p, ssize_t * bytes_read_p, CUstream stream)
Parameters:
fhโ The cuFile handle for the file.bufPtr_baseโ base address of buffer in device or host memorysize_pโ pointer to size bytes to read
Note: *size_p โ if the size is not known at the time of submission, then you must provide the max possible size for the I/O request. plan ahead bestie ๐
Parameters:
file_offset_pโ pointer to file-offset from beginning of the filebufPtr_offset_pโ pointer to offset relative to thebufPtr_basepointer to read into.bytes_read_pโ pointer to the number of bytes that were successfully read.CUstream streamโ cuda stream for the operation.
Returns:
- size of bytes successfully read in
*bytes_read_p -1on error, in which caseerrnois set to indicate filesystem errors.- all other errors will return a negative integer value of
CUfileOpErrorenum value.
Note: if the bufPtr_base is not registered with cuFileBufRegister, the data will be buffered through preallocated pinned buffers.
This is useful for applications that need to perform IO to unaligned file offsets and/or size. This is also recommended for cases where the BAR1 memory size is smaller than the size of the allocated memory ๐
If the stream is registered with cuFileStreamRegister, the IO setup and teardown overhead will be reduced โจ (less overhead = more slay).
on cuda stream errors, the user must call cuFileStreamDeregister to release any outstanding cuFile resources for the stream โ ๏ธ like, actually must.
See also: cuFileBufRegister, cuFileHandleRegister, cuFileRead, cuFileStreamRegister, cuFileStreamDeregister
cuFileStreamDeregister
CUfileError_t cuFileStreamDeregister (CUstream stream)
Parameters:
CUstream streamโ cuda stream for the operation.
Note:
- deallocates resources used by previous cuFile asynchronous operations for the cuda stream ๐งน
- highly recommend to call after cuda stream errors to release any outstanding cuFile resources for this stream
- must be called before
cuStreamDestroycall for the specified stream. ๐ this one's non-negotiable - This is useful for applications that need to perform IO to unaligned file offsets and/or size. This is also recommended for cases where the BAR1 memory size is smaller than the size of the allocated memory.
Returns:
CU_FILE_SUCCESSon successCU_FILE_DRIVER_NOT_INITIALIZEDโ if the driver is not initializedCU_FILE_INVALID_VALUEโ if the stream is invalid
See also: cuFileReadAsync, cuFileWriteAsync, cuFileStreamRegister
cuFileStreamRegister
CUfileError_t cuFileStreamRegister (CUstream stream, unsigned flags)
Parameters:
CUstream streamโ cuda stream for the operation.flagsโ for the stream to improve the stream execution of IO based on input parameters.
Note: supported FLAGS are ๐ฉ
CU_FILE_STREAM_FIXED_BUF_OFFSETโ buffer pointer offset is set at submission timeCU_FILE_STREAM_FIXED_FILE_OFFSETโ file offset is set at submission timeCU_FILE_STREAM_FIXED_FILE_SIZEโ the file size is locked in at submission time, no take-backs ๐CU_FILE_STREAM_PAGE_ALIGNED_INPUTSโ size, offset and buffer offset are all 4k aligned, iconic behavior tbh โจ
...and bestie, that call is what allocates resources needed to support cuFile operations asynchronously for the cuda stream ๐ฆ
This is genuinely useful for applications that need to perform IO to unaligned file offsets and/or size. It's also the recommended move for cases where the BAR1 memory size is smaller than the size of the allocated memory โ yeah, that scenario, we love a practical queen ๐
Returns:
CU_FILE_SUCCESSon success ๐CU_FILE_DRIVER_NOT_INITIALIZEDif the driver is not initializedCU_FILE_INVALID_VALUEif the stream is invalid
See also:
cuFileReadAsynccuFileWriteAsynccuFileStreamDeregister
๐ธ long cuFileUseCount (void)
Okay so this one is literally just: returns use count of cufile drivers at that moment by the process. That's it. Snapshot of the vibe check on how many cufile drivers are in use by your process right this second ๐ฅ
๐ฆ ssize_t cuFileWrite (CUfileHandle_t fh, const void * bufPtr_base, size_t size, off_t file_offset, off_t bufPtr_offset)
Write data from a specified device or host memory to a registered file handle. Get it, girl, write it out ๐
Parameters:
fhโ CUfileHandle_t opaque file handlebufPtr_baseโ base address of buffer in device or host memorysizeโ size bytes to writefile_offsetโ file-offset from beginning of the filebufPtr_offsetโ offset relative to thebufPtr_basepointer to write from.
Returns:
- size of bytes successfully written โ
-1on error, in which caseerrnois set to indicate filesystem errors. ๐ญ- all other errors will return a negative integer value of
CUfileOpErrorenum value.
Note: If thebufPtris not registered withcuFileBufRegister, the data will be buffered through preallocated pinned buffers if needed.
This is useful for applications that need to perform IO to unaligned file offsets and/or size. It's also recommended for cases where the BAR1 memory size is smaller than the size of the allocated memory โ same energy as before, no cap ๐
See also:
cuFileBufRegistercuFileHandleRegistercuFileRead
โญ CUfileError_t cuFileWriteAsync (CUfileHandle_t fh, void * bufPtr_base, size_t * size_p, off_t * file_offset_p, off_t * bufPtr_offset_p, ssize_t * bytes_written_p, CUstream stream)
Parameters:
fhโ The cuFile handle for the file.bufPtr_baseโ base address of buffer in device or host memorysize_pโ pointer to size bytes to write.
Note: *size_p โ if the size is not known at the time of submission, then must provide the max possible size for I/O request. So like, guess big, bestie ๐
Parameters: (yes we're back to parameters, the doc did the split thing, we respect it)
file_offset_pโ pointer to file-offset from beginning of the filebufPtr_offset_pโ pointer to offset relative to thebufPtr_basepointer to write from.bytes_written_pโ pointer to the number of bytes that were successfully written.CUstreamโ cuda stream for the operation.
Returns:
- size of bytes successfully written in
*bytes_written_p -1on error, in which caseerrnois set to indicate filesystem errors. ๐- all other errors will return a negative integer value of
CUfileOpErrorenum value.
Note: If thebufPtr_baseis not registered withcuFileBufRegister, the data will be buffered through preallocated pinned buffers.
This is useful for applications that need to perform IO to unaligned file offsets and/or size. This is also recommended for cases where the BAR1 memory size is smaller than the size of the allocated memory ๐ซถ
If the stream is registered with cuFileStreamRegister prior to this call, the IO setup and teardown overhead will be reduced โ free performance, we ate ๐
on cuda stream errors, the user must call cuFileStreamDeregister to release any outstanding cuFile resources for the stream. Don't skip this one, fr fr, it's giving leak if you ignore it ๐ญ
See also:
cuFileBufRegistercuFileHandleRegistercuFileWritecuFileStreamRegistercuFileStreamDeregister
๐ Variable Documentation ๐
CUfileOpError
That's the one variable doc, and honestly? She speaks for herself ๐
๐ Author ๐
Generated automatically by Doxygen for GPUDirect Storage from the source code. A whole bot wrote this and we're out here annotating it like it's a group chat, love that for us ๐
And that's a wrap on cufile.h(3)! ๐ This lil beauty came to you from GPUDirect Storage, dated Wed Mar 13 2024, page cufile.h(3) โ go forth and async your IO, bestie, you're literally the main character now ๐ง๐
๐ฆ where this page comes from
- debian trixie: libcufile-dev 1.9.1.3~12.4.1-2 ยท GPL-3.0-or-later
- ubuntu questing: libcufile-dev 1.9.1.3~12.4.1-4build1
- ubuntu resolute: libcufile-dev 1.9.1.3~12.4.1-8 ยท GPL-3.0-or-later
- ubuntu stonking: libcufile-dev 1.9.1.3~12.4.1-8.2ubuntu2 ยท GPL-3.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms