CuFile#

public class CuFile#

JNI wrapper for accessing the cuFile API.

Using this wrapper requires GPUDirect Storage (GDS)/cuFile to be installed in the target environment, and the jar to be built with USE_GDS=ON. Otherwise it will throw an exception when loading.

The Java APIs are experimental and subject to change.

Method Summary

appendDeviceBufferToFile(File path, BaseDeviceMemoryBuffer buffer)

Append a device buffer to a given file path synchronously.

appendDeviceMemoryToFile(File path, long address, long length)

Append device memory to a given file path synchronously.

libraryLoaded()

Check if the libcufilejni library is loaded.

readFileToDeviceBuffer(BaseDeviceMemoryBuffer buffer, File path, long fileOffset)

Read a file into a device buffer synchronously.

readFileToDeviceMemory(long address, long length, File path, long fileOffset)

Read a file into device memory synchronously.

writeDeviceBufferToFile(File path, long file_offset, BaseDeviceMemoryBuffer buffer)

Write a device buffer to a given file path synchronously.

writeDeviceMemoryToFile(File path, long file_offset, long address, long length)

Write device memory to a given file path synchronously.

Static Methods

public static boolean libraryLoaded()#

Check if the libcufilejni library is loaded.

Returns:

true if the libcufilejni library has been successfully loaded.

public static void writeDeviceBufferToFile(
File path,
long file_offset,
BaseDeviceMemoryBuffer buffer
)#

Write a device buffer to a given file path synchronously.

This method is NOT thread safe if the path points to the same file on disk.

Parameters:
  • path – The file path to copy to.

  • file_offset – The file offset from which to write the buffer.

  • buffer – The device buffer to copy from.

public static void writeDeviceMemoryToFile(
File path,
long file_offset,
long address,
long length
)#

Write device memory to a given file path synchronously.

This method is NOT thread safe if the path points to the same file on disk.

Parameters:
  • path – The file path to copy to.

  • file_offset – The file offset from which to write the buffer.

  • address – The device memory address to copy from.

  • length – The length to copy.

public static long appendDeviceBufferToFile(
File path,
BaseDeviceMemoryBuffer buffer
)#

Append a device buffer to a given file path synchronously.

This method is NOT thread safe if the path points to the same file on disk.

Parameters:
  • path – The file path to copy to.

  • buffer – The device buffer to copy from.

Returns:

The file offset from which the buffer was appended.

public static long appendDeviceMemoryToFile(
File path,
long address,
long length
)#

Append device memory to a given file path synchronously.

This method is NOT thread safe if the path points to the same file on disk.

Parameters:
  • path – The file path to copy to.

  • address – The device memory address to copy from.

  • length – The length to copy.

Returns:

The file offset from which the buffer was appended.

public static void readFileToDeviceBuffer(
BaseDeviceMemoryBuffer buffer,
File path,
long fileOffset
)#

Read a file into a device buffer synchronously.

This method is NOT thread safe if the path points to the same file on disk.

Parameters:
  • buffer – The device buffer to copy into.

  • path – The file path to copy from.

  • fileOffset – The file offset from which to copy the content.

public static void readFileToDeviceMemory(
long address,
long length,
File path,
long fileOffset
)#

Read a file into device memory synchronously.

This method is NOT thread safe if the path points to the same file on disk.

Parameters:
  • address – The device memory address to read into.

  • length – The length to read.

  • path – The file path to copy from.

  • fileOffset – The file offset from which to copy the content.