public class HostMemoryBuffer extends MemoryBuffer
MemoryBuffer.MemoryBufferCleaner| Modifier and Type | Method and Description |
|---|---|
static HostMemoryBuffer |
allocate(long bytes)
Allocate memory, but be sure to close the returned buffer to avoid memory leaks.
|
static HostMemoryBuffer |
allocate(long bytes,
boolean preferPinned)
Allocate memory, but be sure to close the returned buffer to avoid memory leaks.
|
ByteBuffer |
asByteBuffer()
Return a ByteBuffer that provides access to the underlying memory.
|
ByteBuffer |
asByteBuffer(long offset,
int length)
Return a ByteBuffer that provides access to the underlying memory.
|
void |
copyFromDeviceBuffer(BaseDeviceMemoryBuffer deviceMemoryBuffer)
Synchronously copy from a DeviceMemoryBuffer to a HostMemoryBuffer
|
void |
copyFromDeviceBuffer(BaseDeviceMemoryBuffer deviceMemoryBuffer,
Cuda.Stream stream)
Copy from a DeviceMemoryBuffer to a HostMemoryBuffer using the specified stream.
|
void |
copyFromDeviceBufferAsync(BaseDeviceMemoryBuffer deviceMemoryBuffer,
Cuda.Stream stream)
Copy from a DeviceMemoryBuffer to a HostMemoryBuffer using the specified stream.
|
void |
copyFromHostBuffer(long destOffset,
HostMemoryBuffer srcData,
long srcOffset,
long length)
Copy the contents of the given buffer to this buffer
|
byte |
getByte(long offset)
Returns the byte value at that offset
|
void |
getBytes(byte[] dst,
long dstOffset,
long srcOffset,
long len)
Copy a set of bytes to an array from the buffer starting at offset.
|
static HostMemoryBuffer |
mapFile(File path,
FileChannel.MapMode mode,
long offset,
long length)
Create a host buffer that is memory-mapped to a file.
|
void |
setByte(long offset,
byte value)
Sets the byte value at that offset
|
void |
setBytes(long offset,
byte[] data,
long srcOffset,
long len)
Copy a set of bytes from an array into the buffer at offset.
|
HostMemoryBuffer |
slice(long offset,
long len)
Slice off a part of the host buffer.
|
HostMemoryBuffer |
sliceWithCopy(long offset,
long len)
Slice off a part of the host buffer, actually making a copy of the data.
|
addressOutOfBoundsCheck, close, getAddress, getLength, noWarnLeakExpected, toStringpublic static HostMemoryBuffer allocate(long bytes, boolean preferPinned)
bytes - size in bytes to allocatepreferPinned - If set to true, the pinned memory pool will be used if possible with a
fallback to off-heap memory. If set to false, the allocation will always
be from off-heap memory.public static HostMemoryBuffer allocate(long bytes)
bytes - size in bytes to allocatepublic static HostMemoryBuffer mapFile(File path, FileChannel.MapMode mode, long offset, long length) throws IOException
path - path to the file to map into host memorymode - mapping typeoffset - file offset where the map will startlength - the number of bytes to mapIOExceptionpublic final ByteBuffer asByteBuffer()
public final ByteBuffer asByteBuffer(long offset, int length)
offset - the offset to start atlength - how many bytes to include.public final void copyFromHostBuffer(long destOffset,
HostMemoryBuffer srcData,
long srcOffset,
long length)
destOffset - offset in bytes in this buffer to start copying tosrcData - Buffer to be copied fromsrcOffset - offset in bytes to start copying from in srcDatalength - number of bytes to copypublic final byte getByte(long offset)
offset - - offset from the addresspublic final void setByte(long offset,
byte value)
offset - - offset from the addressvalue - - value to be setpublic final void getBytes(byte[] dst,
long dstOffset,
long srcOffset,
long len)
dstOffset - the offset from the address to start copying todst - the data to be copied.public final void setBytes(long offset,
byte[] data,
long srcOffset,
long len)
offset - the offset from the address to start copying todata - the data to be copied.public final void copyFromDeviceBuffer(BaseDeviceMemoryBuffer deviceMemoryBuffer)
deviceMemoryBuffer - buffer to copy data frompublic final void copyFromDeviceBuffer(BaseDeviceMemoryBuffer deviceMemoryBuffer, Cuda.Stream stream)
deviceMemoryBuffer - buffer to copy data fromstream - CUDA stream to usepublic final void copyFromDeviceBufferAsync(BaseDeviceMemoryBuffer deviceMemoryBuffer, Cuda.Stream stream)
deviceMemoryBuffer - buffer to copy data fromstream - CUDA stream to usepublic final HostMemoryBuffer slice(long offset, long len)
slice in class MemoryBufferoffset - where to start the slice at.len - how many bytes to slicepublic final HostMemoryBuffer sliceWithCopy(long offset, long len)
offset - where to start the slice at.len - how many bytes to sliceCopyright © 2020. All rights reserved.