Module Streamlines.Integration

Integration - Used only by trace workflow, invokes GPU to trace streamlines and count flows through ROI pixels

Copyright (C) 2017-2018,  Colin P Stark and Gavin J Stark.  All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @file   integration.ml
 * @brief  Integration using GPU for trace
 *
module ODM = Owl.Dense.Matrix.Generic
module ODN = Owl.Dense.Ndarray.Generic

pv_verbosity functions

val pv_noisy : Properties.t_props_trace ‑> (unit ‑> unit) ‑> unit

pv_noisy t

Shortcut to use Properties.t_props_trace verbosity for Properties.pv_noisy

val pv_debug : Properties.t_props_trace ‑> (unit ‑> unit) ‑> unit

pv_debug t

Shortcut to use Properties.t_props_trace verbosity for Properties.pv_debug

val pv_info : Properties.t_props_trace ‑> (unit ‑> unit) ‑> unit

pv_info t

Shortcut to use Properties.t_props_trace verbosity for Properties.pv_info

val pv_verbose : Properties.t_props_trace ‑> (unit ‑> unit) ‑> unit

pv_verbose t

Shortcut to use Properties.t_props_trace verbosity for Properties.pv_verbose

Statics

val cl_files : string list
val cl_src_path : string list

Chunks

type t_chunk = {
required : bool;
direction : string;
downup_index : int;
downup_sign : float;
chunk_index : int;
seed_offset : int;
num_seeds : int;
}

t_chunk

val chunk : Core.t_core_data ‑> bool ‑> (int * int * int) ‑> t_chunk

chunk data downstream (n, seed_start, seed_end)

Create a chunk (index n) with the given seeds, for upstream or downstream

val show_chunk : 'a ‑> unit

show_chunk t

Not yet implemented

val generate_chunks : int ‑> Core.t_core_data ‑> int ‑> int * t_chunk list

generate_chunks num_seeds data num_chunks_required

Generate a to_do_list of chunks

Memory

type t_memory = {
uv_array : Globals.t_ba_floats;
chunk_slc_array : Globals.t_ba_ints;
chunk_slt_array : Globals.t_ba_ints;
chunk_nsteps_array : Globals.t_ba_int16s;
chunk_length_array : Globals.t_ba_floats;
chunk_trajcs_array : Globals.t_ba_chars;
seeds_buffer : Pocl.t_buffer;
mask_buffer : Pocl.t_buffer;
uv_buffer : Pocl.t_buffer;
chunk_slc_buffer : Pocl.t_buffer;
chunk_slt_buffer : Pocl.t_buffer;
chunk_nsteps_buffer : Pocl.t_buffer;
chunk_length_buffer : Pocl.t_buffer;
chunk_trajcs_buffer : Pocl.t_buffer;
}

t_memory

Structure containing the memory and OpenCL buffers for interacting with the integrate_trajectories kernel.

val copy_read : Pocl.t ‑> ('a'b, Bigarray.c_layout) Bigarray.Genarray.t ‑> Owl_opencl_generated.cl_mem

copy_read pocl

Shortcut for creating an OpenCL buffer that is read-only by the kernel and copied from a big array before execution

val copy_read_write : Pocl.t ‑> ('a'b, Bigarray.c_layout) Bigarray.Genarray.t ‑> Owl_opencl_generated.cl_mem

copy_read_write pocl

Shortcut for creating an OpenCL buffer that is read-write by the kernel and copied from a big array before execution

val write_only : Pocl.t ‑> ('a'b, Bigarray.c_layout) Bigarray.Genarray.t ‑> Owl_opencl_generated.cl_mem

write_only pocl

Shortcut for creating an OpenCL buffer that is write-only by the kernel

val memory_create_buffers : Pocl.t ‑> Core.t_core_data ‑> ('a'bODM.t ‑> int ‑> t_memory

memory_create_buffers pocl data seeds chunk_size

Create a t_memory strucure with big arrays and PyOpenCL buffers to allow CPU-GPU data transfer for the integrate_trajectories kernel

val memory_clear : t_memory ‑> Pocl.t ‑> unit

memory_clear t pocl

Clear the chunk buffers and copy them to the GPU, prior to execution of the integrate_trajectories kernel

val memory_copyback : t_memory ‑> Pocl.t ‑> unit

memory_copyback t pocl

Copy back the chunk buffers from the GPU to the big arrays after execution of the integrate_trajectories kernel

Results

val results_create : Core.t_core_data ‑> ('a'bODM.t ‑> Core.t_trace_results

results_create data seeds

Create the trace results structure given the seeds

GPU functions

val gpu_integrate_chunk : Pocl.t ‑> Core.t_core_data ‑> t_memory ‑> bytes list array ‑> Core.t_trace_results ‑> string ‑> t_chunk ‑> unit

gpu_integrate_chunk pocl data memory streamline_lists results cl_kernel_source t

Integrate a chunk of seeds on the GPU - this is a set of consecutive seeds in either upstream or downstream - and aggregate the results

val gpu_integrate_trajectories : Pocl.t ‑> Core.t_core_data ‑> ('a'bODM.t ‑> int ‑> t_chunk list ‑> Core.t_trace_results

gpu_integrate_trajectories pocl data seeds chunk_size to_do_list

Carry out GPU computations in the chunks on to_do_list.

Each chunk is handled with a separate compilation, and results are aggregated.

val integrate_trajectories : Properties.t_props_trace ‑> Pocl.t ‑> Core.t_core_data ‑> ('a'bODM.t ‑> Core.t_trace_results

integrate_trajectories tprops pocl data seeds

Integrate trajectories both upstream and downstream from the seeds array of unpadded ROI coordinates.

Trace each streamline from its corresponding seed point using 2nd-order Runge-Kutta integration of the topographic gradient vector field.