- java.lang.Object
-
- com.ibm.cuda.CudaBuffer
-
- All Implemented Interfaces:
AutoCloseable
public final class CudaBuffer extends Object implements AutoCloseable
TheCudaBuffer
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
orcopyFrom
methods. A buffer may be filled with a specific pattern through use of one of thefillXxx
methods.When no longer required, a buffer must be
close
d.
-
-
Constructor Summary
Constructors Constructor Description CudaBuffer(CudaDevice device, long byteCount)
Allocates a new region on the specifieddevice
of sizebyteCount
bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 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
copyFrom(IntBuffer source)
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
copyTo(IntBuffer target)
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
getLength()
Returns the length in bytes of this buffer.CudaBuffer
slice(long fromOffset, long toOffset)
Returns a sub-region of this buffer.
-
-
-
Constructor Detail
-
CudaBuffer
public CudaBuffer(CudaDevice device, long byteCount) throws CudaException
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 Detail
-
atOffset
public CudaBuffer atOffset(long fromOffset)
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
public void close() throws CudaException
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
public void copyFrom(byte[] array) throws CudaException
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
public void copyFrom(byte[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(ByteBuffer source) throws CudaException
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
public void copyFrom(char[] array) throws CudaException
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
public void copyFrom(char[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(CharBuffer source) throws CudaException
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
public void copyFrom(CudaBuffer source, long fromOffset, long toOffset) throws CudaException
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
public void copyFrom(double[] array) throws CudaException
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
public void copyFrom(double[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(DoubleBuffer source) throws CudaException
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
public void copyFrom(float[] array) throws CudaException
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
public void copyFrom(float[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(FloatBuffer source) throws CudaException
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
public void copyFrom(int[] array) throws CudaException
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
public void copyFrom(int[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(IntBuffer source) throws CudaException
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
public void copyFrom(long[] array) throws CudaException
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
public void copyFrom(long[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(LongBuffer source) throws CudaException
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
public void copyFrom(short[] array) throws CudaException
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
public void copyFrom(short[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyFrom(ShortBuffer source) throws CudaException
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
public void copyTo(byte[] array) throws CudaException
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
public void copyTo(byte[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(ByteBuffer target) throws CudaException
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
public void copyTo(char[] array) throws CudaException
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
public void copyTo(char[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(CharBuffer target) throws CudaException
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
public void copyTo(double[] array) throws CudaException
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
public void copyTo(double[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(DoubleBuffer target) throws CudaException
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
public void copyTo(float[] array) throws CudaException
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
public void copyTo(float[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(FloatBuffer target) throws CudaException
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
public void copyTo(int[] array) throws CudaException
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
public void copyTo(int[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(IntBuffer target) throws CudaException
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
public void copyTo(long[] array) throws CudaException
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
public void copyTo(long[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(LongBuffer target) throws CudaException
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
public void copyTo(short[] array) throws CudaException
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
public void copyTo(short[] array, int fromIndex, int toIndex) throws CudaException
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
public void copyTo(ShortBuffer target) throws CudaException
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
public void fillByte(byte value, long count) throws CudaException
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
public void fillChar(char value, long count) throws CudaException
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
public void fillFloat(float value, long count) throws CudaException
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
public void fillInt(int value, long count) throws CudaException
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
public void fillShort(short value, long count) throws CudaException
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
public CudaBuffer slice(long fromOffset, long toOffset)
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
-
-