- java.lang.Object
-
- com.ibm.cuda.CudaBuffer
-
- All Implemented Interfaces:
AutoCloseable
public final class CudaBuffer extends Object implements AutoCloseable
TheCudaBufferclass represents a region of memory on a specific device.Data may be transferred between the device and the Java host via the various
copyToorcopyFrommethods. A buffer may be filled with a specific pattern through use of one of thefillXxxmethods.When no longer required, a buffer must be
closed.
-
-
Constructor Summary
Constructors Constructor Description CudaBuffer(CudaDevice device, long byteCount)Allocates a new region on the specifieddeviceof sizebyteCountbytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CudaBufferatOffset(long fromOffset)Returns a sub-region of this buffer.voidclose()Releases the region of device memory backing this buffer.voidcopyFrom(byte[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(byte[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(char[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(char[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(double[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(double[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(float[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(float[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(int[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(int[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(long[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(long[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(short[] array)Copies all data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(short[] array, int fromIndex, int toIndex)Copies data from the specifiedarray(on the Java host) to this buffer (on the device).voidcopyFrom(CudaBuffer source, long fromOffset, long toOffset)Copies data from the specifiedsourcebuffer (on a device) to this buffer (on the device).voidcopyFrom(ByteBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyFrom(CharBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyFrom(DoubleBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyFrom(FloatBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyFrom(IntBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyFrom(LongBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyFrom(ShortBuffer source)Copies data from the specifiedsourcebuffer (on the Java host) to this buffer (on the device).voidcopyTo(byte[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(byte[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(char[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(char[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(double[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(double[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(float[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(float[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(int[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(int[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(long[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(long[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(short[] array)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(short[] array, int fromIndex, int toIndex)Copies data from this buffer (on the device) to the specifiedarray(on the Java host).voidcopyTo(ByteBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidcopyTo(CharBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidcopyTo(DoubleBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidcopyTo(FloatBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidcopyTo(IntBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidcopyTo(LongBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidcopyTo(ShortBuffer target)Copies data from this buffer (on the device) to the specifiedtargetbuffer (on the Java host).voidfillByte(byte value, long count)Storescountcopies ofvaluein this buffer.voidfillChar(char value, long count)Storescountcopies ofvaluein this buffer.voidfillFloat(float value, long count)Storescountcopies ofvaluein this buffer.voidfillInt(int value, long count)Storescountcopies ofvaluein this buffer.voidfillShort(short value, long count)Storescountcopies ofvaluein this buffer.longgetLength()Returns the length in bytes of this buffer.CudaBufferslice(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 specifieddeviceof sizebyteCountbytes.- 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 CudaExceptionReleases 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:
closein interfaceAutoCloseable- Throws:
CudaException- if a CUDA exception occurs
-
copyFrom
public void copyFrom(byte[] array) throws CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 specifiedsourcebuffer (on a device) to this buffer (on the device). Elements are read fromsourcebeginning 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 eitherfromOffsetortoOffsetis 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 CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 CudaExceptionCopies 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 CudaExceptionCopies data from the specifiedarray(on the Java host) to this buffer (on the device). Elements are read fromarraybeginning atfromIndexcontinuing up to, but excluding,toIndexstoring 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedsourcebuffer (on the Java host) to this buffer (on the device). Elements are read fromsourcebeginning atposition()continuing up to, but excluding,limit()storing them in the same order in this buffer. Thesourcebuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionCopies 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 CudaExceptionCopies 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 inarraybeginning atfromIndexcontinuing 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 > toIndexIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromIndexis 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 specifiedtargetbuffer (on the Java host). Elements are read starting at the beginning of this buffer and stored intargetbeginning atposition()continuing up to, but excluding,limit(). Thetargetbuffer 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 CudaExceptionStorescountcopies ofvaluein 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 CudaExceptionStorescountcopies ofvaluein 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 CudaExceptionStorescountcopies ofvaluein 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 CudaExceptionStorescountcopies ofvaluein 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 CudaExceptionStorescountcopies ofvaluein 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 > toOffsetIllegalStateException- if this buffer has been closed (seeclose())IndexOutOfBoundsException- iffromOffsetis negative,toOffset > length, or the number of source bytes is larger than the length of this buffer
-
-