slm: OpenCL code base  0.1
trajectoryfns.cl
Go to the documentation of this file.
1 
14 
15 
16 #ifdef KERNEL_INTEGRATE_TRAJECTORY
45  const float dl, float *l_trajectory, const float2 vec, const float2 prev_vec,
46  uint *n_steps, uint *idx, uint *prev_idx,
47  __global char2 *trajectory_vec, __global const bool *mask_array,
48  __global uint *slt_array, __global uint *slc_array) {
49  // Step to next point along streamline, adding to trajectory length
50  // and n_steps counter.
51  // Compress step delta vector into fixed-point integer form & record in traj.
52  // Write to slt, slc arrays to record passage of this streamline.
53  *l_trajectory += dl;
54  trajectory_vec[*n_steps] = compress(vec-prev_vec);
55  *n_steps += 1u;
56  // Current pixel position in data array
57  *idx = get_array_idx(vec); \
58  check_atomic_write_sl_data(*idx, prev_idx, mask_array[*idx],
59  &slt_array[*idx], &slc_array[*idx], *l_trajectory);
60 }
61 #endif
62 
63 #ifdef KERNEL_INTEGRATE_TRAJECTORY
64 static inline void update_trajectory_write_sl_data(
89  float dl, float *l_trajectory, float2 vec, float2 prev_vec,
90  uint *n_steps, uint *idx, uint *prev_idx,
91  __global const bool *mask_array,
92  __global uint *slt_array, __global uint *slc_array) {
93  // Step to next point along streamline, adding to trajectory length
94  // and n_steps counter.
95  // Compress step delta vector into fixed-point integer form & record in traj.
96  // Write to slt, slc arrays to record passage of this streamline.
97  *l_trajectory += dl;
98  *n_steps += 1u;
99  // Current pixel position in data array
100  *idx = get_array_idx(vec);
101  check_atomic_write_sl_data(*idx, prev_idx, mask_array[*idx],
102  &slt_array[*idx], &slc_array[*idx], *l_trajectory);
103 }
104 #endif
105 
106 #ifdef KERNEL_INTEGRATE_TRAJECTORY
107 static inline void update_record_trajectory(
126  float dl, float *l_trajectory, float2 vec, float2 prev_vec,
127  uint *n_steps, __global char2 *trajectory_vec) {
128  // Step to next point along streamline, adding to trajectory length
129  // and n_steps counter.
130  // Compress step delta vector into fixed-point integer form.
131  *l_trajectory += dl;
132  trajectory_vec[*n_steps] = compress(vec-prev_vec);
133  *n_steps += 1u;
134 }
135 #endif
136 
137 #ifdef KERNEL_CONNECT_CHANNELS
138 static inline void update_record_private_trajectory(
157  float dl, float *l_trajectory, float2 vec, float2 prev_vec,
158  uint *n_steps, __private char2 *trajectory_vec) {
159  // Step to next point along streamline, adding to trajectory length
160  // and n_steps counter.
161  // Compress step delta vector into fixed-point integer form.
162  *l_trajectory += dl;
163  trajectory_vec[*n_steps] = compress(vec-prev_vec);
164  *n_steps += 1u;
165 }
166 #endif
167 
168 #ifdef KERNEL_HILLSLOPE_LENGTHS
169 static inline void update_trajectory(
183  float dl, float *l_trajectory, uint *n_steps) {
184  // Step to next point along streamline, adding to trajectory length
185  // and n_steps counter.
186  // Compress step delta vector into fixed-point integer form.
187  *l_trajectory += dl;
188  *n_steps += 1u;
189 }
190 #endif
191 
192 #ifdef KERNEL_INTEGRATE_TRAJECTORY
193 static inline void finalize_trajectory(const uint global_id, uint n_steps,
214  float l_trajectory,
215  __global ushort *traj_nsteps_array,
216  __global float *traj_length_array) {
217  // Record the total stream length in pixels and point count for rtn to CPU
218  traj_nsteps_array[global_id] = n_steps;
219  traj_length_array[global_id] = l_trajectory;
220 }
221 #endif
static void update_trajectory(float dl, float *l_trajectory, uint *n_steps)
Update variables tracking trajectory length and integration step counter.
static void update_trajectory_write_sl_data(float dl, float *l_trajectory, float2 vec, float2 prev_vec, uint *n_steps, uint *idx, uint *prev_idx, __global const bool *mask_array, __global uint *slt_array, __global uint *slc_array)
Update variables tracking trajectory length and integration step counter.
static void update_record_private_trajectory(float dl, float *l_trajectory, float2 vec, float2 prev_vec, uint *n_steps, __private char2 *trajectory_vec)
Update variables tracking trajectory length and integration step counter.
static char2 compress(float2 raw_vector)
Squish a float vector into a byte vector for O(<1 pixel) trajectory steps Achieved through scaling by...
Definition: essentials.cl:131
static void finalize_trajectory(const uint global_id, uint n_steps, float l_trajectory, __global ushort *traj_nsteps_array, __global float *traj_length_array)
Record the (final) trajectory length and count of integration steps to global arrays traj_length_arra...
static uint get_array_idx(float2 vec)
Compute the array index of the padded grid pixel pointed to by a float2 grid position vector (choice ...
Definition: essentials.cl:62
static void check_atomic_write_sl_data(const uint idx, uint *prev_idx, const bool mask_flag, __global uint *slt, __global uint *slc, const float l_trajectory)
Extended version of atomic_write_sl_data() to include testing whether the current pixel is masked...
Definition: writearray.cl:71
static void update_record_trajectory(float dl, float *l_trajectory, float2 vec, float2 prev_vec, uint *n_steps, __global char2 *trajectory_vec)
Update variables tracking trajectory length and integration step counter.
static void update_record_trajectory_write_sl_data(const float dl, float *l_trajectory, const float2 vec, const float2 prev_vec, uint *n_steps, uint *idx, uint *prev_idx, __global char2 *trajectory_vec, __global const bool *mask_array, __global uint *slt_array, __global uint *slc_array)
Update variables tracking trajectory length and integration step counter.