edu.stanford.rsl.konrad.cuda
Class CUDAUtil

java.lang.Object
  extended by edu.stanford.rsl.konrad.cuda.CUDAUtil

public abstract class CUDAUtil
extends java.lang.Object


Field Summary
static int[] gridBlockSize
           
 
Constructor Summary
CUDAUtil()
           
 
Method Summary
static int align(int value, int alignment)
          Returns the given (address) value, adjusted to have the given alignment.
static jcuda.driver.CUdeviceptr allocateSpace(Volume3D vol)
          Allocates space on the CUDA device for a Volume3D
static jcuda.driver.CUdeviceptr copyFloatArrayToDevice(float[] array, jcuda.driver.CUmodule module, java.lang.String nameInCode)
           
static jcuda.driver.CUdeviceptr copyToDeviceMemory(float[] data)
          copies a float array to the device and returns a pointer to the memory.
static jcuda.driver.CUdeviceptr copyToDeviceMemory(int[] data)
          copies an int array to the device and returns a pointer to the memory.
static long correctMemoryValue(int memory)
           
static void fetchFromDevice(Volume3D vol, jcuda.driver.CUdeviceptr deviceX)
          Fetches the volume from the device
static void fetchFromDeviceMemory(float[] data, jcuda.driver.CUdeviceptr deviceX)
          fetches a float data array from the device and frees the memory on the device.
static jcuda.driver.CUdevice getBestDevice()
           
static jcuda.driver.CUdevice getSmallestDevice()
           
static int iDivUp(int a, int b)
          Integral division, rounding the result to the next highest integer.
static void moveToDevice(Volume3D vol, jcuda.driver.CUdeviceptr deviceX)
          Moves the volume to the device.
static void updateFloatArrayOnDevice(jcuda.driver.CUdeviceptr devptr, float[] array, jcuda.driver.CUmodule module)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gridBlockSize

public static int[] gridBlockSize
Constructor Detail

CUDAUtil

public CUDAUtil()
Method Detail

align

public static int align(int value,
                        int alignment)
Returns the given (address) value, adjusted to have the given alignment. In newer versions of JCuda, this function is also available as JCudaDriver#align

Parameters:
value - The address value
alignment - The desired alignment
Returns:
The aligned address value

copyToDeviceMemory

public static jcuda.driver.CUdeviceptr copyToDeviceMemory(int[] data)
copies an int array to the device and returns a pointer to the memory.

Parameters:
data - the int array
Returns:
the pointer to the device memory

copyToDeviceMemory

public static jcuda.driver.CUdeviceptr copyToDeviceMemory(float[] data)
copies a float array to the device and returns a pointer to the memory.

Parameters:
data - the float array
Returns:
the pointer to the device memory

fetchFromDeviceMemory

public static void fetchFromDeviceMemory(float[] data,
                                         jcuda.driver.CUdeviceptr deviceX)
fetches a float data array from the device and frees the memory on the device.

Parameters:
data - the float array to write to
deviceX - the pointer to the device memory

allocateSpace

public static jcuda.driver.CUdeviceptr allocateSpace(Volume3D vol)
Allocates space on the CUDA device for a Volume3D

Parameters:
vol - the volume
Returns:
the pointer to the memory

moveToDevice

public static void moveToDevice(Volume3D vol,
                                jcuda.driver.CUdeviceptr deviceX)
Moves the volume to the device.

Parameters:
vol - the volume
deviceX - the memory pointer

fetchFromDevice

public static void fetchFromDevice(Volume3D vol,
                                   jcuda.driver.CUdeviceptr deviceX)
Fetches the volume from the device

Parameters:
vol - the volume object
deviceX - the pointer to the memory on the deivce.

iDivUp

public static int iDivUp(int a,
                         int b)
Integral division, rounding the result to the next highest integer.

Parameters:
a - Dividend
b - Divisor
Returns:
a/b rounded to the next highest integer.

copyFloatArrayToDevice

public static jcuda.driver.CUdeviceptr copyFloatArrayToDevice(float[] array,
                                                              jcuda.driver.CUmodule module,
                                                              java.lang.String nameInCode)

updateFloatArrayOnDevice

public static void updateFloatArrayOnDevice(jcuda.driver.CUdeviceptr devptr,
                                            float[] array,
                                            jcuda.driver.CUmodule module)

correctMemoryValue

public static long correctMemoryValue(int memory)

getBestDevice

public static jcuda.driver.CUdevice getBestDevice()

getSmallestDevice

public static jcuda.driver.CUdevice getSmallestDevice()