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:
ActionListener,WindowListener,Runnable,EventListener
- Direct Known Subclasses:
OpenCLAlgorithmDeconvolution,OpenCLAlgorithmFFT,OpenCLAlgorithmGaussianBlur,OpenCLAlgorithmGradientMagnitude,OpenCLAlgorithmLaplacian,OpenCLAlgorithmMarchingCubes,OpenCLAlgorithmVolumeCrop,OpenCLAlgorithmVolumeNormals
Abstract base class for implementing Algorithms in OpenCL.
Extends AlgorithmBase.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected int[]Color flags.protected intprotected booleanFlag, if true, indicates that the whole image should be processed.protected intprivate static booleanprivate static booleanprivate static booleanprotected longprotected com.jogamp.opengl.GL3private static final intprotected intprivate static booleanprotected intFields inherited from class gov.nih.mipav.model.algorithms.AlgorithmBase
destFlag, destImage, image25D, mask, maxProgressValue, minProgressValue, multiThreadingEnabled, nthreads, progress, progressModulus, progressStep, runningInSeparateThread, separable, srcImage, threadStoppedFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionOpenCLAlgorithmBase(ModelImage destImg, ModelImage srcImg, boolean entireImage, long type) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfillBuffer(FloatBuffer buffer, float[] img) static voidfillBuffer(FloatBuffer buffer, ModelImage img) static voidfillBuffer(FloatBuffer buffer, ModelImage img, int offset) static voidfillBuffer(IntBuffer buffer, int[] img) voidfinalize()Prepare this class for destruction.protected longgetMaxMemoryUsed(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 voidinitCL(long iType, com.jogamp.opengl.GL3 gl) static booleanstatic voidreadBuffer(FloatBuffer buffer, ModelImage img) static voidreadBuffer(FloatBuffer buffer, ModelImage img, int offset) static StringreadKernelFile(String fileName) Helper function which reads the file with the given name and returns the contents of this file as a String.static introundUp(int groupSize, int globalSize) protected static longroundUp(long groupSize, long globalSize) voidsaveImage(float[] data, int time, boolean calcMinMax) voidsaveImage(float[] data, int time, int zSlice, boolean calcMinMax) voidsetBlue(boolean flag) Sets the flag for the blue channel.voidsetGreen(boolean flag) Sets the flag for the green channel.voidsetRed(boolean flag) Sets the flag for the red channel.voidsetTime(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, windowOpenedMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
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:
-
width
protected int width -
height
protected int height -
depth
protected int depth -
time
protected int time -
color
protected int color -
colorMask
protected int[] colorMaskColor flags. -
m_iDeviceType
protected long m_iDeviceType -
m_kGL
protected com.jogamp.opengl.GL3 m_kGL -
entireImage
protected boolean entireImageFlag, if true, indicates that the whole image should be processed. If false only process the image over the mask areas.
-
-
Constructor Details
-
OpenCLAlgorithmBase
public OpenCLAlgorithmBase() -
OpenCLAlgorithmBase
-
-
Method Details
-
initCL
protected void initCL(long iType, com.jogamp.opengl.GL3 gl) -
finalize
public void finalize()Prepare this class for destruction.- Overrides:
finalizein 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
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
-
fillBuffer
-
fillBuffer
-
fillBuffer
-
readBuffer
-
readBuffer
-
roundUp
public static int roundUp(int groupSize, int globalSize)
-