Package org.cytoscape.opencl.cycl
Class CyCLBuffer
- java.lang.Object
-
- org.cytoscape.opencl.cycl.CyCLBuffer
-
public class CyCLBuffer extends Object
Provides functionality associated with an OpenCL memory object.- Author:
- Dimitry Tegunov
-
-
Constructor Summary
Constructors Constructor Description CyCLBuffer(CyCLContext context, byte[] data)Allocates device memory to fit all elements in data, and copies its contentsCyCLBuffer(CyCLContext context, double[] data)Allocates device memory to fit all elements in data, and copies its contentsCyCLBuffer(CyCLContext context, float[] data)Allocates device memory to fit all elements in data, and copies its contentsCyCLBuffer(CyCLContext context, int[] data)Allocates device memory to fit all elements in data, and copies its contentsCyCLBuffer(CyCLContext context, long[] data)Allocates device memory to fit all elements in data, and copies its contentsCyCLBuffer(CyCLContext context, short[] data)Allocates device memory to fit all elements in data, and copies its contentsCyCLBuffer(CyCLContext context, Class<?> type, int elements)Allocates [sizeof(type) * elements] bytes in device memory without copying any host data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intelementSize()Returns the number of bytes associated with the CyCLBuffer's element type.protected voidfinalize()Frees all device memory associated with the buffer.voidfree()Frees all device memory associated with the buffer.voidgetFromDevice(byte[] data)Copies data from device to host memory.voidgetFromDevice(byte[] data, int length, int offset)Copies data from device to host memory.voidgetFromDevice(double[] data)Copies data from device to host memory.voidgetFromDevice(double[] data, int length, int offset)Copies data from device to host memory.voidgetFromDevice(float[] data)Copies data from device to host memory.voidgetFromDevice(float[] data, int length, int offset)Copies data from device to host memory.voidgetFromDevice(int[] data)Copies data from device to host memory.voidgetFromDevice(int[] data, int length, int offset)Copies data from device to host memory.voidgetFromDevice(long[] data)Copies data from device to host memory.voidgetFromDevice(long[] data, int length, int offset)Copies data from device to host memory.voidgetFromDevice(short[] data)Copies data from device to host memory.voidgetFromDevice(short[] data, int length, int offset)Copies data from device to host memory.org.lwjgl.opencl.CLMemgetMemObject()Gets the underlying memory object.voidsetFromDevice(CyCLBuffer src)Copies data from another device buffer to this one.voidsetFromDevice(CyCLBuffer src, long bytes, long offsetSrc, long offsetDst)Copies data from another device buffer to this one.voidsetFromHost(byte[] data)Copies data from host to device memory.voidsetFromHost(byte[] data, int length, int offset)Copies data from host to device memory.voidsetFromHost(double[] data)Copies data from host to device memory.voidsetFromHost(double[] data, int length, int offset)Copies data from host to device memory.voidsetFromHost(float[] data)Copies data from host to device memory.voidsetFromHost(float[] data, int length, int offset)Copies data from host to device memory.voidsetFromHost(int[] data)Copies data from host to device memory.voidsetFromHost(int[] data, int length, int offset)Copies data from host to device memory.voidsetFromHost(long[] data)Copies data from host to device memory.voidsetFromHost(long[] data, int length, int offset)Copies data from host to device memory.voidsetFromHost(short[] data)Copies data from host to device memory.voidsetFromHost(short[] data, int length, int offset)Copies data from host to device memory.intsizeInBytes()Returns the overall buffer size in bytes.
-
-
-
Constructor Detail
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, Class<?> type, int elements)
Allocates [sizeof(type) * elements] bytes in device memory without copying any host data- Parameters:
context- The context of the device where the memory should be allocatedtype- Element typeelements- Number of elements
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, byte[] data)
Allocates device memory to fit all elements in data, and copies its contents- Parameters:
context- The context of the device where the memory should be allocateddata- Data to be copied into device memory
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, short[] data)
Allocates device memory to fit all elements in data, and copies its contents- Parameters:
context- The context of the device where the memory should be allocateddata- Data to be copied into device memory
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, int[] data)
Allocates device memory to fit all elements in data, and copies its contents- Parameters:
context- The context of the device where the memory should be allocateddata- Data to be copied into device memory
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, long[] data)
Allocates device memory to fit all elements in data, and copies its contents- Parameters:
context- The context of the device where the memory should be allocateddata- Data to be copied into device memory
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, float[] data)
Allocates device memory to fit all elements in data, and copies its contents- Parameters:
context- The context of the device where the memory should be allocateddata- Data to be copied into device memory
-
CyCLBuffer
public CyCLBuffer(CyCLContext context, double[] data)
Allocates device memory to fit all elements in data, and copies its contents- Parameters:
context- The context of the device where the memory should be allocateddata- Data to be copied into device memory
-
-
Method Detail
-
elementSize
public int elementSize()
Returns the number of bytes associated with the CyCLBuffer's element type.- Returns:
- sizeof(type)
-
sizeInBytes
public int sizeInBytes()
Returns the overall buffer size in bytes.- Returns:
- sizeof(type) * elements
-
setFromHost
public void setFromHost(byte[] data, int length, int offset)Copies data from host to device memory.- Parameters:
data- Data to be copiedlength- Number of elements to be copiedoffset- Offset in bytes from the device memory's start
-
setFromHost
public void setFromHost(short[] data, int length, int offset)Copies data from host to device memory.- Parameters:
data- Data to be copiedlength- Number of elements to be copiedoffset- Offset in bytes from the device memory's start
-
setFromHost
public void setFromHost(int[] data, int length, int offset)Copies data from host to device memory.- Parameters:
data- Data to be copiedlength- Number of elements to be copiedoffset- Offset in bytes from the device memory's start
-
setFromHost
public void setFromHost(long[] data, int length, int offset)Copies data from host to device memory.- Parameters:
data- Data to be copiedlength- Number of elements to be copiedoffset- Offset in bytes from the device memory's start
-
setFromHost
public void setFromHost(float[] data, int length, int offset)Copies data from host to device memory.- Parameters:
data- Data to be copiedlength- Number of elements to be copiedoffset- Offset in bytes from the device memory's start
-
setFromHost
public void setFromHost(double[] data, int length, int offset)Copies data from host to device memory.- Parameters:
data- Data to be copiedlength- Number of elements to be copiedoffset- Offset in bytes from the device memory's start
-
setFromHost
public void setFromHost(byte[] data)
Copies data from host to device memory.- Parameters:
data- Data to be copied
-
setFromHost
public void setFromHost(short[] data)
Copies data from host to device memory.- Parameters:
data- Data to be copied
-
setFromHost
public void setFromHost(int[] data)
Copies data from host to device memory.- Parameters:
data- Data to be copied
-
setFromHost
public void setFromHost(long[] data)
Copies data from host to device memory.- Parameters:
data- Data to be copied
-
setFromHost
public void setFromHost(float[] data)
Copies data from host to device memory.- Parameters:
data- Data to be copied
-
setFromHost
public void setFromHost(double[] data)
Copies data from host to device memory.- Parameters:
data- Data to be copied
-
setFromDevice
public void setFromDevice(CyCLBuffer src, long bytes, long offsetSrc, long offsetDst)
Copies data from another device buffer to this one.- Parameters:
src- Device buffer with the source databytes- Amount of bytes to be copiedoffsetSrc- Offset in bytes from the start of the source bufferoffsetDst- Offset in bytes from the start of the destination buffer
-
setFromDevice
public void setFromDevice(CyCLBuffer src)
Copies data from another device buffer to this one.- Parameters:
src- Device buffer with the source data
-
getFromDevice
public void getFromDevice(byte[] data, int length, int offset)Copies data from device to host memory.- Parameters:
data- Array that the data will be copied tolength- Number of elementsoffset- Offset in bytes from the start of the device buffer
-
getFromDevice
public void getFromDevice(short[] data, int length, int offset)Copies data from device to host memory.- Parameters:
data- Array that the data will be copied tolength- Number of elementsoffset- Offset in bytes from the start of the device buffer
-
getFromDevice
public void getFromDevice(int[] data, int length, int offset)Copies data from device to host memory.- Parameters:
data- Array that the data will be copied tolength- Number of elementsoffset- Offset in bytes from the start of the device buffer
-
getFromDevice
public void getFromDevice(long[] data, int length, int offset)Copies data from device to host memory.- Parameters:
data- Array that the data will be copied tolength- Number of elementsoffset- Offset in bytes from the start of the device buffer
-
getFromDevice
public void getFromDevice(float[] data, int length, int offset)Copies data from device to host memory.- Parameters:
data- Array that the data will be copied tolength- Number of elementsoffset- Offset in bytes from the start of the device buffer
-
getFromDevice
public void getFromDevice(double[] data, int length, int offset)Copies data from device to host memory.- Parameters:
data- Array that the data will be copied tolength- Number of elementsoffset- Offset in bytes from the start of the device buffer
-
getFromDevice
public void getFromDevice(byte[] data)
Copies data from device to host memory.- Parameters:
data- Array that the data will be copied to
-
getFromDevice
public void getFromDevice(short[] data)
Copies data from device to host memory.- Parameters:
data- Array that the data will be copied to
-
getFromDevice
public void getFromDevice(int[] data)
Copies data from device to host memory.- Parameters:
data- Array that the data will be copied to
-
getFromDevice
public void getFromDevice(long[] data)
Copies data from device to host memory.- Parameters:
data- Array that the data will be copied to
-
getFromDevice
public void getFromDevice(float[] data)
Copies data from device to host memory.- Parameters:
data- Array that the data will be copied to
-
getFromDevice
public void getFromDevice(double[] data)
Copies data from device to host memory.- Parameters:
data- Array that the data will be copied to
-
getMemObject
public org.lwjgl.opencl.CLMem getMemObject()
Gets the underlying memory object.- Returns:
- LWJGL memory object
-
free
public void free()
Frees all device memory associated with the buffer. CyCLBuffer cannot be used anymore once this method has been executed.
-
-