Package gov.nih.mipav.model.algorithms
Class OpenCLAlgorithmBase
- java.lang.Object
-
- java.lang.Thread
-
- gov.nih.mipav.model.algorithms.AlgorithmBase
-
- gov.nih.mipav.model.algorithms.OpenCLAlgorithmBase
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.event.WindowListener
,java.lang.Runnable
,java.util.EventListener
- Direct Known Subclasses:
OpenCLAlgorithmDeconvolution
,OpenCLAlgorithmFFT
,OpenCLAlgorithmGaussianBlur
,OpenCLAlgorithmGradientMagnitude
,OpenCLAlgorithmLaplacian
,OpenCLAlgorithmMarchingCubes
,OpenCLAlgorithmVolumeCrop
,OpenCLAlgorithmVolumeNormals
public abstract class OpenCLAlgorithmBase extends AlgorithmBase
Abstract base class for implementing Algorithms in OpenCL. Extends AlgorithmBase.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
color
protected int[]
colorMask
Color flags.protected int
depth
protected boolean
entireImage
Flag, if true, indicates that the whole image should be processed.protected int
height
private static boolean
isOCL_CPU_Available
private static boolean
isOCL_GPU_Available
private static boolean
isOCLAvailable
protected long
m_iDeviceType
protected com.jogamp.opengl.GL3
m_kGL
private static int
platformIndex
protected int
time
private static boolean
wasOCLChecked
protected int
width
-
Fields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStopped
-
-
Constructor Summary
Constructors Constructor Description OpenCLAlgorithmBase()
OpenCLAlgorithmBase(ModelImage destImg, ModelImage srcImg, boolean entireImage, long type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
fillBuffer(java.nio.FloatBuffer buffer, float[] img)
static void
fillBuffer(java.nio.FloatBuffer buffer, ModelImage img)
static void
fillBuffer(java.nio.FloatBuffer buffer, ModelImage img, int offset)
static void
fillBuffer(java.nio.IntBuffer buffer, int[] img)
void
finalize()
Prepare this class for destruction.protected long
getMaxMemoryUsed(int nBuffers, int elementCount, float[] sigmas)
Determines the amount of memory used for the OpenCL buffers required for the gaussian kernels for the given sigmas.protected void
initCL(long iType, com.jogamp.opengl.GL3 gl)
static boolean
isOCLAvailable()
static void
readBuffer(java.nio.FloatBuffer buffer, ModelImage img)
static void
readBuffer(java.nio.FloatBuffer buffer, ModelImage img, int offset)
static java.lang.String
readKernelFile(java.lang.String fileName)
Helper function which reads the file with the given name and returns the contents of this file as a String.static int
roundUp(int groupSize, int globalSize)
protected static long
roundUp(long groupSize, long globalSize)
void
saveImage(float[] data, int time, boolean calcMinMax)
void
saveImage(float[] data, int time, int zSlice, boolean calcMinMax)
void
setBlue(boolean flag)
Sets the flag for the blue channel.void
setGreen(boolean flag)
Sets the flag for the green channel.void
setRed(boolean flag)
Sets the flag for the red channel.void
setTime(int timeSlice)
-
Methods inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
actionPerformed, addListener, addProgressChangeListener, calculateImageSize, calculatePrincipleAxis, computeElapsedTime, computeElapsedTime, convertIntoFloat, delinkProgressToAlgorithm, delinkProgressToAlgorithmMulti, displayError, errorCleanUp, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, generateProgressValues, getDestImage, getElapsedTime, getMask, getMaxProgressValue, getMinProgressValue, getNumberOfThreads, getProgress, getProgressChangeListener, getProgressChangeListeners, getProgressModulus, getProgressStep, getProgressValues, getSrcImage, isCompleted, isImage25D, isMultiThreadingEnabled, isRunningInSeparateThread, isThreadStopped, linkProgressToAlgorithm, linkProgressToAlgorithm, makeProgress, notifyListeners, removeListener, removeProgressChangeListener, run, runAlgorithm, setCompleted, setImage25D, setMask, setMaxProgressValue, setMinProgressValue, setMultiThreadingEnabled, setNumberOfThreads, setProgress, setProgressModulus, setProgressStep, setProgressValues, setProgressValues, setRunningInSeparateThread, setSrcImage, setStartTime, setThreadStopped, startMethod, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
isOCLAvailable
private static boolean isOCLAvailable
-
isOCL_CPU_Available
private static boolean isOCL_CPU_Available
-
isOCL_GPU_Available
private static boolean isOCL_GPU_Available
-
wasOCLChecked
private static boolean wasOCLChecked
-
platformIndex
private static final int platformIndex
- See Also:
- Constant Field Values
-
width
protected int width
-
height
protected int height
-
depth
protected int depth
-
time
protected int time
-
color
protected int color
-
colorMask
protected int[] colorMask
Color flags.
-
m_iDeviceType
protected long m_iDeviceType
-
m_kGL
protected com.jogamp.opengl.GL3 m_kGL
-
entireImage
protected boolean entireImage
Flag, if true, indicates that the whole image should be processed. If false only process the image over the mask areas.
-
-
Constructor Detail
-
OpenCLAlgorithmBase
public OpenCLAlgorithmBase()
-
OpenCLAlgorithmBase
public OpenCLAlgorithmBase(ModelImage destImg, ModelImage srcImg, boolean entireImage, long type)
-
-
Method Detail
-
initCL
protected void initCL(long iType, com.jogamp.opengl.GL3 gl)
-
finalize
public void finalize()
Prepare this class for destruction.- Overrides:
finalize
in classAlgorithmBase
-
saveImage
public void saveImage(float[] data, int time, int zSlice, boolean calcMinMax)
-
saveImage
public void saveImage(float[] data, int time, boolean calcMinMax)
-
isOCLAvailable
public static boolean isOCLAvailable()
-
roundUp
protected static long roundUp(long groupSize, long globalSize)
-
setBlue
public void setBlue(boolean flag)
Sets the flag for the blue channel.- Parameters:
flag
- if set to true then the blue channel is processed.
-
setGreen
public void setGreen(boolean flag)
Sets the flag for the green channel.- Parameters:
flag
- if set to true then the green channel is processed.
-
setRed
public void setRed(boolean flag)
Sets the flag for the red channel.- Parameters:
flag
- if set to true then the red channel is processed.
-
setTime
public void setTime(int timeSlice)
-
readKernelFile
public static java.lang.String readKernelFile(java.lang.String fileName)
Helper function which reads the file with the given name and returns the contents of this file as a String. Will exit the application if the file can not be read.- Parameters:
fileName
- The name of the file to read.- Returns:
- The contents of the file
-
getMaxMemoryUsed
protected long getMaxMemoryUsed(int nBuffers, int elementCount, float[] sigmas)
Determines the amount of memory used for the OpenCL buffers required for the gaussian kernels for the given sigmas. Plus the memory used for the nBuffers OpenCL buffers, each elementCount in size.- Parameters:
nBuffers
- number of bufferselementCount
- buffer sizesigmas
-- Returns:
-
fillBuffer
public static void fillBuffer(java.nio.FloatBuffer buffer, ModelImage img)
-
fillBuffer
public static void fillBuffer(java.nio.IntBuffer buffer, int[] img)
-
fillBuffer
public static void fillBuffer(java.nio.FloatBuffer buffer, ModelImage img, int offset)
-
fillBuffer
public static void fillBuffer(java.nio.FloatBuffer buffer, float[] img)
-
readBuffer
public static void readBuffer(java.nio.FloatBuffer buffer, ModelImage img)
-
readBuffer
public static void readBuffer(java.nio.FloatBuffer buffer, ModelImage img, int offset)
-
roundUp
public static int roundUp(int groupSize, int globalSize)
-
-