PyPO User Manual
KernelsRTf.cu File Reference

Kernel for CUDA RT calculations. More...

#include "InterfaceCUDA.h"

Functions

__device__ __inline__ float common1 (float t, float xr, float yr, float dxr, float dyr)
 
__device__ __inline__ float common2 (float t, float xr, float yr, float dxr, float dyr)
 
__device__ __inline__ float gp (float t, float xr, float yr, float zr, float dxr, float dyr, float dzr)
 
__device__ __inline__ float gh (float t, float xr, float yr, float zr, float dxr, float dyr, float dzr)
 
__device__ __inline__ float ge (float t, float xr, float yr, float zr, float dxr, float dyr, float dzr)
 
__device__ __inline__ float gpl (float t, float xr, float yr, float zr, float dxr, float dyr, float dzr)
 
__device__ __inline__ void np (float xr, float yr, float zr, float(&out)[3])
 
__device__ __inline__ void nh (float xr, float yr, float zr, float(&out)[3])
 
__device__ __inline__ void ne (float xr, float yr, float zr, float(&out)[3])
 
__device__ __inline__ void npl (float xr, float yr, float zr, float(&out)[3])
 
__device__ __inline__ void transfRays (float *x, float *y, float *z, float *dx, float *dy, float *dz, int i, bool inv=false)
 
__host__ std::array< dim3, 2 > _initCUDA (reflparamsf ctp, float epsilon, float t0, int _nTot, int nBlocks, int nThreads)
 
__global__ void propagateRaysToTarget (float *xs, float *ys, float *zs, float *dxs, float *dys, float *dzs, float *xt, float *yt, float *zt, float *dxt, float *dyt, float *dzt)
 
void callRTKernel (reflparamsf ctp, cframef *fr_in, cframef *fr_out, float epsilon, float t0, int nBlocks, int nThreads)
 

Variables

__constant__ float conrt [CSIZERT]
 
__constant__ float mat [16]
 
__constant__ int nTot
 
__constant__ int cflip
 
__constant__ int ctype
 

Detailed Description

Kernel for CUDA RT calculations.

Contains kernel for RT calculations.

Function Documentation

◆ _initCUDA()

__host__ std::array<dim3, 2> _initCUDA ( reflparamsf  ctp,
float  epsilon,
float  t0,
int  _nTot,
int  nBlocks,
int  nThreads 
)

Initialize CUDA.

Instantiate program and populate constant memory.

Parameters
ctpreflparamsf object containing target surface parameters.
epsilonPrecision of NR method.
t0Starting guess for NR method.
_nTotTotal number of rays in beam.
nBlocksNumber of blocks per grid.
nThreadsNumber of threads per block.
Returns
BT Array of two dim3 objects.

◆ callRTKernel()

void callRTKernel ( reflparamsf  ctp,
cframef fr_in,
cframef fr_out,
float  epsilon,
float  t0,
int  nBlocks,
int  nThreads 
)

Call ray-trace Kernel.

Calculate a new frame of rays on a target, given an input frame of rays.

Parameters
ctpreflparamsf object containing target surface parameters.
fr_inPointer to input cframef object.
fr_outPointer to output cframef object.
epsilonPrecision for NR method.
t0Starting guess for NR method.
nBlocksNumber of blocks in GPU grid.
nThreadsNumber of threads in block.
See also
reflparamsf
cframef

◆ common1()

__device__ __inline__ float common1 ( float  t,
float  xr,
float  yr,
float  dxr,
float  dyr 
)

Calculate common factor 1.

Parameters
tScaling factor.
xrx co-ordinate of ray.
yry co-ordinate of ray.
dxrx co-ordinate of ray direction
dyry co-ordinate of ray direction

◆ common2()

__device__ __inline__ float common2 ( float  t,
float  xr,
float  yr,
float  dxr,
float  dyr 
)

Calculate common factor 2.

Parameters
tScaling factor.
xrx co-ordinate of ray.
yry co-ordinate of ray.
dxrx co-ordinate of ray direction
dyry co-ordinate of ray direction

◆ ge()

__device__ __inline__ float ge ( float  t,
float  xr,
float  yr,
float  zr,
float  dxr,
float  dyr,
float  dzr 
)

Calculate ray-ellipsoid intersection.

Parameters
tScaling factor.
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
dxrx co-ordinate of ray direction
dyry co-ordinate of ray direction
dzrz co-ordinate of ray direction

◆ gh()

__device__ __inline__ float gh ( float  t,
float  xr,
float  yr,
float  zr,
float  dxr,
float  dyr,
float  dzr 
)

Calculate ray-hyperboloid intersection.

Parameters
tScaling factor.
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
dxrx co-ordinate of ray direction
dyry co-ordinate of ray direction
dzrz co-ordinate of ray direction

◆ gp()

__device__ __inline__ float gp ( float  t,
float  xr,
float  yr,
float  zr,
float  dxr,
float  dyr,
float  dzr 
)

Calculate ray-paraboloid intersection.

Parameters
tScaling factor.
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
dxrx co-ordinate of ray direction
dyry co-ordinate of ray direction
dzrz co-ordinate of ray direction

◆ gpl()

__device__ __inline__ float gpl ( float  t,
float  xr,
float  yr,
float  zr,
float  dxr,
float  dyr,
float  dzr 
)

Calculate ray-plane intersection.

Parameters
tScaling factor.
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
dxrx co-ordinate of ray direction
dyry co-ordinate of ray direction
dzrz co-ordinate of ray direction

◆ ne()

__device__ __inline__ void ne ( float  xr,
float  yr,
float  zr,
float(&)  out[3] 
)

Calculate ellipsoid normals.

Parameters
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
outArray of 3 float.

◆ nh()

__device__ __inline__ void nh ( float  xr,
float  yr,
float  zr,
float(&)  out[3] 
)

Calculate hyperboloid normals.

Parameters
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
outArray of 3 float.

◆ np()

__device__ __inline__ void np ( float  xr,
float  yr,
float  zr,
float(&)  out[3] 
)

Calculate paraboloid normals.

Parameters
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
outArray of 3 float.

◆ npl()

__device__ __inline__ void npl ( float  xr,
float  yr,
float  zr,
float(&)  out[3] 
)

Calculate plane normals.

Parameters
xrx co-ordinate of ray.
yry co-ordinate of ray.
zrz co-ordinate of ray.
outArray of 3 float.

◆ propagateRaysToTarget()

__global__ void propagateRaysToTarget ( float *  xs,
float *  ys,
float *  zs,
float *  dxs,
float *  dys,
float *  dzs,
float *  xt,
float *  yt,
float *  zt,
float *  dxt,
float *  dyt,
float *  dzt 
)

Optimize ray-target distance.

Uses a Newton Rhapson (NR) method to find the point of ray-surface intersection.

Parameters
xsArray of ray x co-ordinates.
ysArray of ray y co-ordinates.
zsArray of ray z co-ordinates.
dxsArray of ray x directions.
dysArray of ray y directions.
dzsArray of ray z directions.
xtArray of ray x co-ordinates, to be filled.
ytArray of ray y co-ordinates, to be filled.
ztArray of ray z co-ordinates, to be filled.
dxtArray of ray x directions, to be filled.
dytArray of ray y directions, to be filled.
dztArray of ray z directions, to be filled.

◆ transfRays()

__device__ __inline__ void transfRays ( float *  x,
float *  y,
float *  z,
float *  dx,
float *  dy,
float *  dz,
int  i,
bool  inv = false 
)

Transform rays to surface restframe.

Parameters
xArray of ray x co-ordinates.
yArray of ray y co-ordinates.
zArray of ray z co-ordinates.
dxArray of ray x directions.
dyArray of ray y directions.
dzArray of ray z directions.
iIndex of co-ordinate.
invWhether to apply inverse transformation.