- All Implemented Interfaces:
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 Summary
ConstructorDescriptionCudaBuffer
(CudaDevice device, long byteCount) Allocates a new region on the specifieddevice
of sizebyteCount
bytes. -
Method Summary
Modifier and TypeMethodDescriptionatOffset
(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 specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(byte[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(char[] array) Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(char[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(double[] array) Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(double[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(float[] array) Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(float[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(int[] array) Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(int[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(long[] array) Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(long[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(short[] array) Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(short[] array, int fromIndex, int toIndex) Copies data from the specifiedarray
(on the Java host) to this buffer (on the device).void
copyFrom
(CudaBuffer source, long fromOffset, long toOffset) Copies data from the specifiedsource
buffer (on a device) to this buffer (on the device).void
copyFrom
(ByteBuffer source) Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device).void
copyFrom
(CharBuffer source) Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device).void
copyFrom
(DoubleBuffer source) Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device).void
copyFrom
(FloatBuffer source) Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device).void
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device).void
copyFrom
(LongBuffer source) Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device).void
copyFrom
(ShortBuffer source) Copies data from the specifiedsource
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 specifiedarray
(on the Java host).void
copyTo
(byte[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(char[] array) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(char[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(double[] array) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(double[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(float[] array) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(float[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(int[] array) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(int[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(long[] array) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(long[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(short[] array) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(short[] array, int fromIndex, int toIndex) Copies data from this buffer (on the device) to the specifiedarray
(on the Java host).void
copyTo
(ByteBuffer target) Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
copyTo
(CharBuffer target) Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
copyTo
(DoubleBuffer target) Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
copyTo
(FloatBuffer target) Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
copyTo
(LongBuffer target) Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
copyTo
(ShortBuffer target) Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host).void
fillByte
(byte value, long count) Storescount
copies ofvalue
in this buffer.void
fillChar
(char value, long count) Storescount
copies ofvalue
in this buffer.void
fillFloat
(float value, long count) Storescount
copies ofvalue
in this buffer.void
fillInt
(int value, long count) Storescount
copies ofvalue
in this buffer.void
fillShort
(short value, long count) Storescount
copies ofvalue
in this buffer.long
Returns the length in bytes of this buffer.slice
(long fromOffset, long toOffset) Returns a sub-region of this buffer.
-
Constructor Details
-
CudaBuffer
Allocates a new region on the specifieddevice
of sizebyteCount
bytes.- Parameters:
device
- the device on which the region is to be allocatedbyteCount
- the allocation size in bytes- Throws:
CudaException
- if a CUDA exception occurs
-
-
Method Details
-
atOffset
Returns a sub-region of this buffer. The new buffer begins at the specified offset and extends to the end of this buffer.- Parameters:
fromOffset
- the byte offset of the sub-region within this buffer- Returns:
- the specified sub-region
- Throws:
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the specified offset is negative or larger than the length of this buffer
-
close
Releases the region of device memory backing this buffer.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.- Specified by:
close
in interfaceAutoCloseable
- Throws:
CudaException
- if a CUDA exception occurs
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on a device) to this buffer (on the device). Elements are read fromsource
beginning atposition()
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.- Parameters:
source
- the source bufferfromOffset
- the source starting offset (inclusive)toOffset
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if eitherfromOffset
ortoOffset
is not a legal offset within the source buffer or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies all data from the specifiedarray
(on the Java host) to this buffer (on the device). Equivalent tocopyFrom(array, 0, array.length);
- Parameters:
array
- the source array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedarray
(on the Java host) to this buffer (on the device). Elements are read fromarray
beginning atfromIndex
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.- Parameters:
array
- the source arrayfromIndex
- the source starting offset (inclusive)toIndex
- the source ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of source bytes is larger than the length of this buffer
-
copyFrom
Copies data from the specifiedsource
buffer (on the Java host) to this buffer (on the device). Elements are read fromsource
beginning atposition()
continuing up to, but excluding,limit()
storing them in the same order in this buffer. Thesource
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the data are to be copied somewhere other than the beginning of this buffer.- Parameters:
source
- the source buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Equivalent tocopyTo(array, 0, array.length);
- Parameters:
array
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedarray
(on the Java host). Elements are read starting at the beginning of this buffer and stored inarray
beginning atfromIndex
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.- Parameters:
array
- the destination arrayfromIndex
- the destination starting offset (inclusive)toIndex
- the destination ending offset (exclusive)- Throws:
CudaException
- if a CUDA exception occursIllegalArgumentException
- iffromIndex > toIndex
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromIndex
is negative,toIndex > array.length
, or the number of required source bytes is larger than the length of this buffer
-
copyTo
Copies data from this buffer (on the device) to the specifiedtarget
buffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intarget
beginning atposition()
continuing up to, but excluding,limit()
. Thetarget
buffer position is set tolimit()
.A sub-buffer may be created (see
atOffset(long)
) when the source data are not located at the beginning of this buffer.- Parameters:
target
- the destination buffer- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the number of required source bytes is larger than the length of this buffer
-
fillByte
Storescount
copies ofvalue
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.- Parameters:
value
- the destination arraycount
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the space required is larger than the length of this buffer
-
fillChar
Storescount
copies ofvalue
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.- Parameters:
value
- the destination arraycount
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the space required is larger than the length of this buffer
-
fillFloat
Storescount
copies ofvalue
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.- Parameters:
value
- the destination arraycount
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the space required is larger than the length of this buffer
-
fillInt
Storescount
copies ofvalue
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.- Parameters:
value
- the destination arraycount
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the space required is larger than the length of this buffer
-
fillShort
Storescount
copies ofvalue
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.- Parameters:
value
- the destination arraycount
- the destination array- Throws:
CudaException
- if a CUDA exception occursIllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- if the space required is larger than the length of this buffer
-
getLength
public long getLength()Returns the length in bytes of this buffer.- Returns:
- the length in bytes of this buffer
-
slice
Returns a sub-region of this buffer. The new buffer begins at the specified fromOffset and extends to the specified toOffset (exclusive).- Parameters:
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 buffer- Returns:
- the specified sub-region
- Throws:
IllegalArgumentException
- iffromOffset > toOffset
IllegalStateException
- if this buffer has been closed (seeclose()
)IndexOutOfBoundsException
- iffromOffset
is negative,toOffset > length
, or the number of source bytes is larger than the length of this buffer
-