public final class CudaBuffer extends Object implements AutoCloseable
CudaBuffer
class represents a region of memory on a specific
device.
Data may be transferred between the device and the Java host via the
various copyTo
or copyFrom
methods. A buffer may be filled
with a specific pattern through use of one of the fillXxx
methods.
When no longer required, a buffer must be close
d.
Constructor and Description |
---|
CudaBuffer(CudaDevice device,
long byteCount)
Allocates a new region on the specified
device of size byteCount bytes. |
Modifier and Type | Method and Description |
---|---|
CudaBuffer |
atOffset(long fromOffset)
Returns a sub-region of this buffer.
|
void |
close()
Releases the region of device memory backing this buffer.
|
void |
copyFrom(byte[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(byte[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(ByteBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyFrom(char[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(char[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(CharBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyFrom(CudaBuffer source,
long fromOffset,
long toOffset)
Copies data from the specified
source buffer (on a device)
to this buffer (on the device). |
void |
copyFrom(double[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(double[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(DoubleBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyFrom(float[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(float[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(FloatBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyFrom(int[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(int[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(IntBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyFrom(long[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(long[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(LongBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyFrom(short[] array)
Copies all data from the specified
array (on the Java host) to
this buffer (on the device). |
void |
copyFrom(short[] array,
int fromIndex,
int toIndex)
Copies data from the specified
array (on the Java host) to this
buffer (on the device). |
void |
copyFrom(ShortBuffer source)
Copies data from the specified
source buffer (on the Java host)
to this buffer (on the device). |
void |
copyTo(byte[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(byte[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(ByteBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
copyTo(char[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(char[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(CharBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
copyTo(double[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(double[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(DoubleBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
copyTo(float[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(float[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(FloatBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
copyTo(int[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(int[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(IntBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
copyTo(long[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(long[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(LongBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
copyTo(short[] array)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(short[] array,
int fromIndex,
int toIndex)
Copies data from this buffer (on the device) to the specified
array (on the Java host). |
void |
copyTo(ShortBuffer target)
Copies data from this buffer (on the device) to the specified
target buffer (on the Java host). |
void |
fillByte(byte value,
long count)
Stores
count copies of value in this buffer. |
void |
fillChar(char value,
long count)
Stores
count copies of value in this buffer. |
void |
fillFloat(float value,
long count)
Stores
count copies of value in this buffer. |
void |
fillInt(int value,
long count)
Stores
count copies of value in this buffer. |
void |
fillShort(short value,
long count)
Stores
count copies of value in this buffer. |
long |
getLength()
Returns the length in bytes of this buffer.
|
CudaBuffer |
slice(long fromOffset,
long toOffset)
Returns a sub-region of this buffer.
|
public CudaBuffer(CudaDevice device, long byteCount) throws CudaException
device
of size byteCount
bytes.device
- the device on which the region is to be allocatedbyteCount
- the allocation size in bytesCudaException
- if a CUDA exception occurspublic CudaBuffer atOffset(long fromOffset)
fromOffset
- the byte offset of the sub-region within this bufferIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the specified offset is negative or larger than the
length of this bufferpublic void close() throws CudaException
Closing a buffer created via atOffset(long)
with a
non-zero offset has no effect: the memory is still accessible via
the parent buffer which must be closed separately.
close
in interface AutoCloseable
CudaException
- if a CUDA exception occurspublic void copyFrom(byte[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(byte[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(ByteBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(char[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(char[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(CharBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(CudaBuffer source, long fromOffset, long toOffset) throws CudaException
source
buffer (on a device)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferfromOffset
- the source starting offset (inclusive)toOffset
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if either fromOffset
or toOffset
is not a legal
offset within the source buffer or the number of source bytes
is larger than the length of this bufferpublic void copyFrom(double[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(double[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(DoubleBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(float[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(float[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(FloatBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(int[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(int[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(IntBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(long[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(long[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(LongBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(short[] array) throws CudaException
array
(on the Java host) to
this buffer (on the device). Equivalent to
copyFrom(array, 0, array.length);
array
- the source arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyFrom(short[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host) to this
buffer (on the device). Elements are read from array
beginning
at fromIndex
continuing up to, but excluding, toIndex
storing them in the same order in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of source bytes is larger than the length
of this bufferpublic void copyFrom(ShortBuffer source) throws CudaException
source
buffer (on the Java host)
to this buffer (on the device). Elements are read from source
beginning at position()
continuing up to, but excluding,
limit()
storing them in the same order in this buffer.
The source
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the data
are to be copied somewhere other than the beginning of this buffer.
source
- the source bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length
of this bufferpublic void copyTo(byte[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(byte[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(ByteBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(char[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(char[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(CharBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(double[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(double[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(DoubleBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(float[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(float[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(FloatBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(int[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(int[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(IntBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(long[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(long[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(LongBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(short[] array) throws CudaException
array
(on the Java host). Equivalent to
copyTo(array, 0, array.length);
array
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void copyTo(short[] array, int fromIndex, int toIndex) throws CudaException
array
(on the Java host). Elements are read starting at the
beginning of this buffer and stored in array
beginning
at fromIndex
continuing up to, but excluding, toIndex
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)CudaException
- if a CUDA exception occursIllegalArgumentException
- if fromIndex > toIndex
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromIndex
is negative, toIndex > array.length
,
or the number of required source bytes is larger than the length
of this bufferpublic void copyTo(ShortBuffer target) throws CudaException
target
buffer (on the Java host). Elements are read starting at
the beginning of this buffer and stored in target
beginning
at position()
continuing up to, but excluding, limit()
.
The target
buffer position is set to limit()
.
A sub-buffer may be created (see atOffset(long)
) when the source
data are not located at the beginning of this buffer.
target
- the destination bufferCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length
of this bufferpublic void fillByte(byte value, long count) throws CudaException
count
copies of value
in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the values
are to be stored somewhere other than the beginning of this buffer.
value
- the destination arraycount
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the space required is larger than the length of this bufferpublic void fillChar(char value, long count) throws CudaException
count
copies of value
in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the values
are to be stored somewhere other than the beginning of this buffer.
value
- the destination arraycount
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the space required is larger than the length of this bufferpublic void fillFloat(float value, long count) throws CudaException
count
copies of value
in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the values
are to be stored somewhere other than the beginning of this buffer.
value
- the destination arraycount
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the space required is larger than the length of this bufferpublic void fillInt(int value, long count) throws CudaException
count
copies of value
in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the values
are to be stored somewhere other than the beginning of this buffer.
value
- the destination arraycount
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the space required is larger than the length of this bufferpublic void fillShort(short value, long count) throws CudaException
count
copies of value
in this buffer.
A sub-buffer may be created (see atOffset(long)
) when the values
are to be stored somewhere other than the beginning of this buffer.
value
- the destination arraycount
- the destination arrayCudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if the space required is larger than the length of this bufferpublic long getLength()
public CudaBuffer slice(long fromOffset, long toOffset)
fromOffset
- the byte offset of the start of the sub-region within this buffertoOffset
- the byte offset of the end of the sub-region within this bufferIllegalArgumentException
- if fromOffset > toOffset
IllegalStateException
- if this buffer has been closed (see close()
)IndexOutOfBoundsException
- if fromOffset
is negative, toOffset > length
,
or the number of source bytes is larger than the length
of this bufferEclipse OpenJ9 website.
To raise a bug report or suggest an improvement create an Eclipse OpenJ9 issue.
Copyright © 2013, 2025 IBM Corp. and others.