Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use address and length for GDS reads/writes [skip ci] #8301

Merged
merged 2 commits into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions java/src/main/java/ai/rapids/cudf/CuFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,25 @@ public static boolean libraryLoaded() {
* @param path The file path to copy to.
* @param file_offset The file offset from which to write the buffer.
* @param buffer The device buffer to copy from.
* @return The file offset from which the buffer was appended.
*/
public static void writeDeviceBufferToFile(File path, long file_offset,
BaseDeviceMemoryBuffer buffer) {
writeToFile(path.getAbsolutePath(), file_offset, buffer.getAddress(), buffer.getLength());
writeDeviceMemoryToFile(path, file_offset, buffer.getAddress(), buffer.getLength());
}

/**
* Write device memory to a given file path synchronously.
* <p>
* This method is NOT thread safe if the path points to the same file on disk.
*
* @param path The file path to copy to.
* @param file_offset The file offset from which to write the buffer.
* @param address The device memory address to copy from.
* @param length The length to copy.
*/
public static void writeDeviceMemoryToFile(File path, long file_offset, long address,
long length) {
writeToFile(path.getAbsolutePath(), file_offset, address, length);
}

/**
Expand All @@ -95,7 +109,21 @@ public static void writeDeviceBufferToFile(File path, long file_offset,
* @return The file offset from which the buffer was appended.
*/
public static long appendDeviceBufferToFile(File path, BaseDeviceMemoryBuffer buffer) {
return appendToFile(path.getAbsolutePath(), buffer.getAddress(), buffer.getLength());
return appendDeviceMemoryToFile(path, buffer.getAddress(), buffer.getLength());
}

/**
* Append device memory to a given file path synchronously.
* <p>
* This method is NOT thread safe if the path points to the same file on disk.
*
* @param path The file path to copy to.
* @param address The device memory address to copy from.
* @param length The length to copy.
* @return The file offset from which the buffer was appended.
*/
public static long appendDeviceMemoryToFile(File path, long address, long length) {
return appendToFile(path.getAbsolutePath(), address, length);
}

/**
Expand All @@ -109,7 +137,21 @@ public static long appendDeviceBufferToFile(File path, BaseDeviceMemoryBuffer bu
*/
public static void readFileToDeviceBuffer(BaseDeviceMemoryBuffer buffer, File path,
long fileOffset) {
readFromFile(buffer.getAddress(), buffer.getLength(), path.getAbsolutePath(), fileOffset);
readFileToDeviceMemory(buffer.getAddress(), buffer.getLength(), path, fileOffset);
}

/**
* Read a file into device memory synchronously.
* <p>
* This method is NOT thread safe if the path points to the same file on disk.
*
* @param address The device memory address to read into.
* @param length The length to read.
* @param path The file path to copy from.
* @param fileOffset The file offset from which to copy the content.
*/
public static void readFileToDeviceMemory(long address, long length, File path, long fileOffset) {
readFromFile(address, length, path.getAbsolutePath(), fileOffset);
}

private static native void writeToFile(String path, long file_offset, long address, long length);
Expand Down