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

add copy methods in Java memory buffer [skip ci] #7791

Merged
merged 4 commits into from
Mar 31, 2021
Merged
Changes from 1 commit
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
33 changes: 33 additions & 0 deletions java/src/main/java/ai/rapids/cudf/MemoryBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,39 @@ public final long getAddress() {
return address;
}

/**
* Copy a subset of src to this buffer starting at destOffset using the specified CUDA stream.
* The copy has completed when this returns, but the memory copy could overlap with
* operations occurring on other streams.
* @param destOffset the offset in this to start copying from.
* @param src what to copy from
* @param srcOffset offset into src to start out
* @param length how many bytes to copy
* @param stream CUDA stream to use
*/
public final void copyFromMemoryBuffer(
long destOffset, MemoryBuffer src, long srcOffset, long length, Cuda.Stream stream) {
addressOutOfBoundsCheck(address + destOffset, length, "copy range dest");
src.addressOutOfBoundsCheck(src.address + srcOffset, length, "copy range src");
Cuda.memcpy(address + destOffset, src.address + srcOffset, length, CudaMemcpyKind.DEFAULT, stream);
rongou marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Copy a subset of src to this buffer starting at destOffset using the specified CUDA stream.
* The copy is async and may not have completed when this returns.
* @param destOffset the offset in this to start copying from.
* @param src what to copy from
* @param srcOffset offset into src to start out
* @param length how many bytes to copy
* @param stream CUDA stream to use
*/
public final void copyFromMemoryBufferAsync(
long destOffset, MemoryBuffer src, long srcOffset, long length, Cuda.Stream stream) {
addressOutOfBoundsCheck(address + destOffset, length, "copy range dest");
src.addressOutOfBoundsCheck(src.address + srcOffset, length, "copy range src");
Cuda.asyncMemcpy(address + destOffset, src.address + srcOffset, length, CudaMemcpyKind.DEFAULT, stream);
}

/**
* Slice off a part of the buffer. Note that this is a zero copy operation and all
* slices must be closed along with the original buffer before the memory is released.
Expand Down