Synchronous read and write API reference

Synchronous read and write API reference#

hipFileRead and hipFileWrite perform blocking transfers between a file and registered GPU memory. Both functions accept file and buffer offsets for fine-grained control over where data is read from or written to.

Before calling these functions, register the file handle with hipFileHandleRegister and the GPU buffer with hipFileBufRegister. See File handle, buffer, and RDMA API reference for registration details and Copy a file via GPU memory using hipFile for a usage walkthrough.

Offset type and functions#

The offset type used by the synchronous read and write functions, and the functions themselves.

typedef off_t hoff_t#

Platform-independent offset type.

HIPFILE_API ssize_t hipFileRead(hipFileHandle_t fh, void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset)#

Synchronously read data from a file into a GPU buffer.

Note

The maximum I/O size is determined by the Linux kernel and is currently 2^31 - the system page size

Parameters:
  • fh[in] Opaque file handle for GPU I/O operations

  • buffer_base[in] Base address of the GPU buffer

  • size[in] Number of bytes that should be read

  • file_offset[in] Offset into the file that should be read from

  • buffer_offset[in] Offset of the GPU buffer that that the data should be written to

Returns:

if >= 0: Number of bytes read

Returns:

if -1: System error (check errno for the specific error)

Returns:

else: Negative value of the related hipFileOpError_t

HIPFILE_API ssize_t hipFileWrite(hipFileHandle_t fh, const void *buffer_base, size_t size, hoff_t file_offset, hoff_t buffer_offset)#

Synchronously write data from a GPU buffer to a file.

Note

The maximum I/O size is determined by the Linux kernel and is currently 2^31 - the system page size

Parameters:
  • fh[in] Opaque file handle for GPU I/O operations

  • buffer_base[in] Base address of the GPU buffer

  • size[in] Number of bytes that should be written

  • file_offset[in] Offset into the file that should be written to

  • buffer_offset[in] Offset of the GPU buffer that the data should be read from

Returns:

if >= 0: Number of bytes written

Returns:

if -1: System error (check errno for the specific error)

Returns:

else: Negative value of the related hipFileOpError_t