dpivsoft.Cl_DPIV

dpivsoft.Cl_DPIV.select_Platform(idx)[source]

Select the OpenCL platform/device where the calculations run.

Parameters:

idx (int or str) – Index of the platform on this computer. If the string “selection” is passed, the terminal shows a list of all available platforms to choose from interactively.

Returns:

thr – Thread on the selected device, to be passed to compile_Kernels, initialization and processing.

Return type:

reikna.cluda Thread

dpivsoft.Cl_DPIV.compile_Kernels(thr)[source]

Compile all kernels needed for GPU calculation. Only needs to be called once per device.

Kernel sources live in the package folder “GPU_Kernels”. SubMean and find_peak are compiled later, in initialization(), because their local-memory sizes depend on the box geometry.

Parameters:

thr (reikna.cluda Thread) – Device thread returned by select_Platform.

dpivsoft.Cl_DPIV.initialization(width, height, thr)[source]

Allocate all GPU buffers and compile the geometry-dependent kernels (SubMean, find_peak). Call once after setting Parameters and before processing(); call again if the image size or the PIV parameters change.

Parameters:
  • width (int) – Image size in pixels.

  • height (int) – Image size in pixels.

  • thr (reikna.cluda Thread) – Device thread returned by select_Platform.

dpivsoft.Cl_DPIV.processing(img1_name, img2_name, thr)[source]

Perform the parallelized two-pass PIV algorithm with window deformation on the GPU (OpenCL).

Developed by Jorge Aguilar-Cabello

The image pair to process must already be in GPU memory (GPU.img1, GPU.img2). While the GPU queue is running, the next image pair is loaded from disk and uploaded, so file I/O overlaps with the computation.

Parameters:
  • img1_name (str) – Paths to the image pair of the next iteration, loaded asynchronously during runtime.

  • img2_name (str) – Paths to the image pair of the next iteration, loaded asynchronously during runtime.

  • thr (reikna.cluda Thread) – Device thread returned by select_Platform.

Notes

Processing options are taken from the Parameters class in “Classes.py”; they can be set manually or loaded from a file with the classmethod “readParameters”.

Results are left in GPU memory, as attributes of the GPU class in “Classes.py” (retrieve them with .get()):

GPU.x1, GPU.y1, GPU.u1, GPU.v1GPU 2d arrays

Grid and velocity field of the first pass.

GPU.x2, GPU.y2, GPU.u2_f, GPU.v2_fGPU 2d arrays

Grid and median-filtered velocity field of the second pass (the final result).