Skip to content

Commit 6dc1a1d

Browse files
author
haesleinhuepf
committed
moved over documentation from clij1
1 parent c157074 commit 6dc1a1d

30 files changed

+747
-210
lines changed

api_design_priciples.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# API design principles
2+
3+
In order to simplify image processing using CLIJ from an application programming interface (API) as well as usability point of view, some general rules have been established:
4+
5+
* All numeric spatial parameters in CLIJ such as radius and sigma are always entered in pixels. There is no operation in CLIJ which makes use of any physical units.
6+
* Pixel coordinates in X, Y and Z are zero-based indiced.
7+
* Only two- and three-dimensional images are supported.
8+
* There are no in-place operations supported in CLIJ. No operation overwrites its input images.
9+
* The currently active image window in ImageJ plays no role in CLIJ. Input and output images must be specified in macros by name explicitly.
10+
* If a specified output image does not exist in GPU memory, it will be generated automatically with a size defined by the executed operation with respect to input image and given parameters.
11+
* If a specified output image exists already in GPU memory, it will be overwritten.
12+
* CLIJ operations called from ImageJ macro have no return values. They either process pixels and save results to images or they save their results to ImageJs results table.
13+
* Binary output images are filled with pixel values 0 and 1. Any input image can serve as binary image and will be interpreted by differentiating 0 and non-zero values.
14+
15+
[Back to CLIJ documentation](https://clij.github.io/)
16+
17+
[Imprint](https://clij.github.io/imprint)
18+
19+

dependingViaMaven.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
### Depending on CLIJ
3+
4+
If you want to access CLIJ from your Java code, it is recommended to depend on CLIJ via Maven dependencies. Add this dependency to the pom.xml file of your project:
5+
6+
```xml
7+
<dependency>
8+
<groupId>net.haesleinhuepf</groupId>
9+
<artifactId>clij2_</artifactId>
10+
<version>0.27.2</version>
11+
</dependency>
12+
```
13+
14+
To allow maven finding this artifact, add a repository to your pom.xml file:
15+
16+
```xml
17+
<repository>
18+
<id>clij</id>
19+
<url>http://dl.bintray.com/haesleinhuepf/clij</url>
20+
</repository>
21+
```
22+
23+
[Back to CLIJ documentation](https://clij.github.io/)
24+
25+
[Imprint](https://clij.github.io/imprint)
26+

faq.md

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Frequently asked questions
2+
3+
<a name="supported_gpus"></a>
4+
## Which GPUs are supported by CLIJ?
5+
CLIJ was successfully tested on a variety of Intel, Nvidia and AMD GPUs. See the
6+
[full list of tested systems](https://clij.github.io/clij-docs/testedsystems)
7+
8+
<a name="buy_gpus"></a>
9+
## Do I have to buy a dedicated GPU in order to benefit from GPU-acceleration using CLIJ?
10+
No. Common Intel Core and AMD Ryzen processors contain built-in GPUs which are compatible with CLIJ.
11+
However, as dedicated graphics cards come with their own GDDR-memory, additional speed-up can be gained by utilizing dedicated GPUs though.
12+
13+
<a name="supported_os"></a>
14+
## With which operating systems is CLIJ compatible?
15+
CLIJ was successfully tested on Windows, MacOS, Fedora linux and Ubuntu linux.
16+
Current GPU and OpenCL drivers must be installed.
17+
18+
<a name="optimal_performance"></a>
19+
## How can I achieve optimal performance using CLIJ?
20+
In order to exploit GPU-accelerated image processing, one should
21+
* Run as many operations as possible in a block without back and forth pulling/pushing image data to/from GPU memory.
22+
* Process images larger than 10 MB (rule of thumb, depends on actual CPU/GPU hardware). Background: Image processing on the CPU can be pretty fast if the accessed memory is smaller than the cache of the CPU. When processing exceeds this cache size, using GPU might become beneficial.
23+
* Process many images of the same size and type subsequently, because in that way compiled GPU-code can be reused.
24+
* Reuse memory. Releasing and allocating memory takes time. Try to reuse memory if possible.
25+
* Use a dedicated graphics card. When deciding for the right GPU, check the memory bandwidth. Image processing is usually memory-bound. The faster the memory access, the faster images can be processed. The computing power / clock rate of the GPU and number of compute cores is of secondary interest.
26+
* Some CLIJ marked with "Box" in their name filters are implemented separable (Gaussian blur, minimum, maximum, mean filters). Separable filters are faster than others (e.g. marked with "Sphere").
27+
* Further speedup can be achieved by combining filters on OpenCL kernel level. This means implementing OpenCL kernels containing whole workflows. This custom OpenCL code can be distributed as custom CLIJ plugin. A plugin template can be found here: https://github.com/clij/clij-plugin-template/
28+
29+
<a name="how_to_measure_speedup"></a>
30+
## How can I measure the speedup of my workflows?
31+
The simplest way for measuring the speedup of workflows is using time measurements before and after execution, e.g. in ImageJ macro:
32+
33+
```
34+
time = getTime(); // gives current time in milliseconds
35+
// ...
36+
// my workflow
37+
// ...
38+
print("Processing the workflow took " + (getTime() - time) + " msec"));
39+
```
40+
41+
However, in order to make these measurements reliable, some hints shall be given:
42+
* Measure the timing of execution in a loop several times. The first execution(s) may be slower than subsequent executions because of so called _warmup_ effects.
43+
* Exclude file input/output from the time measurements to exclude hard drive read/write speed from the performance benchmarking of your workflow.
44+
* Also measure the similarity of the ImageJ and CLIJ workflows results. For example: Some CLIJ_*Box filters are potentially much faster than CLIJ_*Sphere filters, which are more similar to ImageJs filters. In this case, performance can be gained by paying with reduced workflow result similarity.
45+
46+
ImageJ macros benchmarking CPU/GPU performance can be found
47+
[here](https://github.com/clij/clij-docs/blob/master/src/main/macro/benchmarking.ijm)
48+
and
49+
[here](https://github.com/clij/clij-benchmarking/tree/master/src/main/macro_benchmarking_workflow)
50+
51+
For more professional benchmarking, we recommend the OpenJDK Java Microbenchmark Harness (JMH). As the name suggests, this involves Java programming. You find more details
52+
[here](https://openjdk.java.net/projects/code-tools/jmh/)
53+
54+
To give an overview, some of CLIJs operations have been
55+
[benchmarked with JMH](https://github.com/clij/clij-benchmarking-jmh)
56+
57+
58+
<a name="compatibility_imagej"></a>
59+
## Is CLIJ compatible with ImageJ without Fiji?
60+
With some limitations, yes. You find details and installation instructions
61+
[here](https://github.com/clij/clij-legacy/)
62+
63+
<a name="thread_safe"></a>
64+
## Is CLIJ thread safe?
65+
If you use CLIJ from ImageJ macro, you cannot execute it in parallel from several threads.
66+
If you use CLIJ from any other programming language, please use one CLIJ instance per thread.
67+
By using multiple threads in combination with multiple CLIJ instances, you can also [execute operations on multiple graphics cards](https://github.com/clij/clij-docs/blob/master/src/main/jython/multi_GPU_demo.py) at a time.
68+
69+
<a name="memory_reuse"></a>
70+
## Does reusing memory bring additional speed-up?
71+
Yes. When processing images of the same size and type, it is recommended to reuse memory instead of releasing memory and reallocating memory in every iteration. An example macro demonstrating this can be found
72+
[here](https://github.com/clij/clij-docs/blob/master/src/main/macro/memory_reuse_versus_reallocation.ijm)
73+
74+
<a name="result_comparibility_imagej"></a>
75+
## Are results of CLIJ filters expected to be exactly the same as when using ImageJ?
76+
No. While algorithms on the CPU can make use of double-precision, common GPUs only support single precision for floating point numbers. Furthermore, following priorities were set while developing CLIJs filters:
77+
* Mathematical correctness
78+
* Consistency, e.g. results in 2D and 3D should be reasonably similar
79+
* Simplicity of code to ease maintenance
80+
* Performance
81+
* Similarity of results generated with ImageJ
82+
83+
For example, the minimum filter of ImageJ takes different neighborhoods into account when being applied in 2D and 3D. CLIJs filters are consistent in 2D and 3D. Thus, results may differ between ImageJ and CLIJ as shown in Figure 1.
84+
![Image](images/mean_filter_comparison_r1.png)
85+
Figure 1: Comparing CLIJs mean filter (center) and ImageJs mean filter (right) in 2D (top) and 3D (bottom). The result can be reproduced by running the
86+
[this example macro](https://github.com/clij/clij-docs/blob/master/src/main/macro/mean_detailed_comparison_IJ_CLIJ.ijm)
87+
with radius = 1:
88+
89+
<a name="image_edge_handling"></a>
90+
## Which pixel values does CLIJ take into account when processing edge pixels of the image?
91+
CLIJ in general uses the strategy `clamp to edge` assuming pixels outside the image have the same pixel value as the closest border pixel of the image. For transforms such as rotation, translation, scaling, and affine transforms, 'zero-padding' is applied assuming pixels having value 0 out of the image.
92+
93+
<a name="physical_units"></a>
94+
## Does CLIJ take physical pixel units into account?
95+
No. All numeric spatial parameters in CLIJ such as radius and sigma are always entered in pixels. There is no operation in CLIJ which makes use of any physical units.
96+
97+
<a name="pixel_indexing"></a>
98+
## Are pixel positions 0- or 1-indiced?
99+
Pixel coordinates in X, Y and Z are zero-based indiced.
100+
101+
<a name="multi)_channels"></a>
102+
## Are multi-channel images and timelapse data supported by CLIJ?
103+
In general no. CLIJ supports two and three dimensional images. If the third dimension represents channels or frames, these images can be processed using CLIJs 3D filters. When processing 4D or 5D images, it is recommended to split them into 3D blocks.
104+
105+
<a name="inplace_operations"></a>
106+
## Are in-place operations supported?
107+
No. There are no in-place operations implemented in CLIJ. No built-in operation overwrites its input images. However, when implementing your own custom OpenCL-code and wrapping it into CLIJ plugins, in-place operations may be supported depending on used hardware, driver version and supported OpenCL version.
108+
109+
<a name="active_imagej_window"></a>
110+
## Does it matter which is the currently active image window in ImageJ?
111+
No. The currently active image window in ImageJ plays no role in CLIJ. Input and output images must be specified in macros by name explicitly.
112+
113+
<a name="output_not_existing_macro"></a>
114+
## What happens in ImageJ macro if a specified output image doesn't exist?
115+
If a specified output image does not exist in GPU memory, it will be generated automatically with a size defined by the executed operation with respect to input image and given parameters.
116+
117+
<a name="output_existing_macro"></a>
118+
## What happens in ImageJ macro if a specified output image exists already?
119+
If a specified output image exists already in GPU memory, it will be overwritten. If the output image has the wrong size, it will not be changed.
120+
121+
<a name="return_values_macro"></a>
122+
## What is the return value of Ext.CLIJ_... methods in ImageJ macro?
123+
CLIJ operations called from ImageJ macro have no return values. They either process pixels and save results to images or they save their results to ImageJs results table.
124+
125+
<a name="binary_image_characteristics"></a>
126+
## How are binary images characterized in CLIJ?
127+
Binary output images are filled with pixel values 0 and 1. Any input image can serve as binary image and will be interpreted by differentiating 0 and non-zero values. In order to pull a binary image back to ImageJ which is compatible, use `pullBinary()`. This delivers a binary 8-bit image with 0 and 255 as pixel values.
128+
129+
<a name="clearcl_vs_clij_performance_benefits"></a>
130+
## Are there performance benefits expected when calling OpenCL kernels directly via ClearCL instead of CLIJ?
131+
Yes. CLIJ brings OpenCL-kernel caching and the possibility of image/pixel-type-independent OpenCL. These benefits come with small performance loss. Calling an OpenCL kernel via ClearCL directly may be about _a millisecond_ faster than calling it via CLIJ. Example code demonstrating this is available
132+
[here](https://github.com/clij/clij-benchmarking/blob/master/src/main/java/net/haesleinhuepf/clij/benchmark/clearclclijcomparison/ClearCLVersusCLIJComparison.java)
133+
134+
<a name="buffers_vs_images"></a>
135+
## The CLIJ Java API offers methods for processing ClearCLBuffers and ClearCLImages. What's the difference?
136+
Images and buffers are defined in the OpenCL standard. We tried to have as many operations as possible compatible to both, images and buffers. Differences are:
137+
* When applying affine transforms and warping to images, linear interpolation is used. When using buffers, the nearest neighbor pixel delivers the resulting intensity.
138+
* Images are not generally supported by GPU devices running OpenCL 1.1.
139+
* For filters which access the local neighborhood of pixels, using images brings performance gain.
140+
141+
We recommend using buffers in general for maximum device compatibility.
142+
143+
<a name="headless"></a>
144+
## Does CLIJ run in Fijis headless mode?
145+
Yes. As operations executed on the GPU anyway don't make use of user interface elements, CLIJs operations in general run headless and need no user interaction. Furthermore, it can be run from the
146+
[command line](https://github.com/clij/clij-executable-example)
147+
and in
148+
[cloud systems using docker](https://github.com/clij/clij-apeer-template).
149+
150+
[Back to CLIJ documentation](https://clij.github.io/)
151+
152+
[Imprint](https://clij.github.io/imprint)
153+
154+
155+

images/clij_bridge.gif

8.54 MB
Loading

installationInFiji.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
## Installation
3+
[Download and install Fiji](https://fiji.sc/Downloads). Afterwards, click the menu `Help > Update...` and activate the [CLIJ update site](installationInFiji.
4+
5+
![Image](images/updatesite.png)
6+
7+
After restarting Fiji, CLIJ is successfully installed, if you find a menu entry _Plugins > ImageJ on GPU (CLIJ)_.
8+
9+
## Testing the installation
10+
You can execute [this macro](https://github.com/clij/clij-docs/blob/master/src/main/macro/benchmarking.ijm) to see if CLIJ and graphics card drivers are installed correctly. In case of issues, consult the [troubleshooting section](https://clij.github.io/clij-docs/troubleshooting) or contact us via [image.sc](https://image.sc).
11+
12+
## Windows and MacOS
13+
On Windows and MacOS the installation should work right away in case the computer has a built-in Intel HD or AMD Ryzen GPU. In case dedicated AMD or NVidia GPUs are used, special drivers might have to be installed. Search for more information about drivers on the websites of the GPU vendors.
14+
15+
## Windows: AMD and NVidia graphics cards
16+
In case of processing large images and/or working with large kernels, errors may pop up when using NVidia or AMD graphics cards on Windows. The issue is related to a timeout of the operating system interrupting processing on the GPU. Add the following entries keys to the windows registry and restart the computer:
17+
```
18+
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers]
19+
"TdrDelay"=dword:0000003c
20+
"TdrDdiDelay"=dword:0000003c
21+
```
22+
Be really careful when doing this. Don't do it, if you're not aware what that means. Ask you IT department for support. [Read the BSD3 license file](license.txt) for details on why we're not responsible for your actions on your computer. More technical background information:
23+
24+
[https://docs.microsoft.com/en-us/windows-hardware/drivers/display/tdr-registry-keys](https://docs.microsoft.com/en-us/windows-hardware/drivers/display/tdr-registry-keys)
25+
26+
[https://community.amd.com/thread/180166](https://community.amd.com/thread/180166)
27+
28+
[https://support.microsoft.com/en-us/help/2665946/display-driver-stopped-responding-and-has-recovered-error-in-windows-7](https://support.microsoft.com/en-us/help/2665946/display-driver-stopped-responding-and-has-recovered-error-in-windows-7)
29+
30+
## Linux
31+
Linux users need to install drivers for OpenCL, even on Intel HD GPUs. It is recommended to install the packages [beignet](https://github.com/intel/beignet) and [ocl-icd-devel](https://github.com/OCL-dev/ocl-icd).
32+
33+
[Back to CLIJ documentation](https://clij.github.io/)
34+
35+
[Imprint](https://clij.github.io/imprint)
36+

installation_linux.md

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Installation on linux
2+
3+
* Ubuntu
4+
* Fedora
5+
6+
## Installation Ubuntu 18.04 LTS
7+
8+
Fresh OS:
9+
10+
```
11+
(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_172 [64-bit]; Linux 5.0.0-23-generic; 93MB of 10833MB (<1%)
12+
java.lang.NoClassDefFoundError: Could not initialize class net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL
13+
at net.haesleinhuepf.clij.clearcl.backend.ClearCLBackends.getBestBackend(ClearCLBackends.java:126)
14+
at net.haesleinhuepf.clij.CLIJ.getAvailableDeviceNames(CLIJ.java:199)
15+
at net.haesleinhuepf.clij.macro.AbstractCLIJPlugin.run(AbstractCLIJPlugin.java:218)
16+
at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:266)
17+
at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
18+
at ij.IJ.runUserPlugIn(IJ.java:232)
19+
at ij.IJ.runPlugIn(IJ.java:193)
20+
at ij.Executer.runCommand(Executer.java:137)
21+
at ij.Executer.run(Executer.java:66)
22+
at java.lang.Thread.run(Thread.java:748
23+
```
24+
25+
```
26+
sudo apt-get update
27+
sudo apt-get install ocl-icd-opencl-dev
28+
```
29+
30+
Restart Fiji
31+
32+
```
33+
(Fiji Is Just) ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_172 [64-bit]; Linux 5.0.0-23-generic; 63MB of 10763MB (<1%)
34+
35+
net.haesleinhuepf.clij.clearcl.exceptions.OpenCLException: OpenCL error: -1001 -> Unknown OpenCL error:-1001
36+
at net.haesleinhuepf.clij.clearcl.backend.BackendUtils.checkOpenCLError(BackendUtils.java:346)
37+
at net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL.lambda$getNumberOfPlatforms$0(ClearCLBackendJOCL.java:83)
38+
at net.haesleinhuepf.clij.clearcl.backend.BackendUtils.checkExceptions(BackendUtils.java:156)
39+
at net.haesleinhuepf.clij.clearcl.backend.jocl.ClearCLBackendJOCL.getNumberOfPlatforms(ClearCLBackendJOCL.java:81)
40+
at net.haesleinhuepf.clij.clearcl.ClearCL.getNumberOfPlatforms(ClearCL.java:44)
41+
at net.haesleinhuepf.clij.clearcl.ClearCL.getAllDevices(ClearCL.java:232)
42+
at net.haesleinhuepf.clij.CLIJ.getAvailableDeviceNames(CLIJ.java:201)
43+
at net.haesleinhuepf.clij.macro.AbstractCLIJPlugin.run(AbstractCLIJPlugin.java:218)
44+
at ij.plugin.filter.PlugInFilterRunner.processOneImage(PlugInFilterRunner.java:266)
45+
at ij.plugin.filter.PlugInFilterRunner.<init>(PlugInFilterRunner.java:114)
46+
at ij.IJ.runUserPlugIn(IJ.java:232)
47+
at ij.IJ.runPlugIn(IJ.java:193)
48+
at ij.Executer.runCommand(Executer.java:137)
49+
at ij.Executer.run(Executer.java:66)
50+
at java.lang.Thread.run(Thread.java:748)
51+
```
52+
53+
```
54+
sudo apt-get install beignet clinfo
55+
```
56+
57+
Error on command line output:
58+
```
59+
ASSERTION FAILED: Not implemented
60+
at file /build/beignet-Bevceu/beignet-1.3.2/backend/src/llvm/llvm_scalarize.cpp, function bool gbe::Scalarize::scalarizeInsert(llvm::InsertElementInst*), line 838
61+
```
62+
63+
```
64+
sudo apt-get install build-essential
65+
sudo apt-get install cmake
66+
sudo apt-get install llvm
67+
sudo apt-get install llvm-dev
68+
sudo apt-get install pkg-config
69+
sudo apt-get install libclang-dev
70+
sudo apt-get install lib32z1-dev
71+
72+
git clone https://github.com/intel/beignet.git
73+
cd beignet/
74+
mkdir build
75+
cd build
76+
77+
cmake ../
78+
sudo make install
79+
80+
81+
```
82+
83+
[Back to CLIJ documentation](https://clij.github.io/)
84+
85+
[Imprint](https://clij.github.io/imprint)
-79.9 KB
Binary file not shown.
79.9 KB
Loading

0 commit comments

Comments
 (0)