fundamental_coords_gpu

API documentation for fundamental_coords_gpu.cpp

Device methods to calculate interferometric coorindates \(u,v,w\) and \(l,m,n\).

Functions

__device__ void calc_uvw(double *d_X_diff, double *d_Y_diff, double *d_Z_diff, double sdec0, double cdec0, double sha0, double cha0, int iBaseline, int num_baselines, int num_times, int num_freqs, user_precision_t *u, user_precision_t *v, user_precision_t *w)

Use the given baseline lengths in local X,Y,Z coords, and a given phase centre, calculate u,v,w coordinates.

Performs Equation 4.1 from TMS https://link.springer.com/book/10.1007/978-3-319-44431-4. This __device__ function is called by kern_calc_uvw, which calculates u,v,w for multiple time steps. Using the index iBaseline, num_baselines, num_times, num_freqs, this function does a modulus to index d_X_diff, d_Y_diff, d_Z_diff correctly, as the diff arrays do not change with frequency (but change with time).

Parameters:
  • d_X_diff[in] Baseline length in the X direction (metres)

  • d_Y_diff[in] Baseline length in the Y direction (metres)

  • d_Z_diff[in] Baseline length in the Z direction (metres)

  • sdec0[in] Sine of the declination of the phase centre

  • cdec0[in] Cosine of the declination of the phase centre

  • sha0[in] Sine of the hour angle of the phase centre

  • cha0[in] Cosine of the hour angle of the phase centre

  • iBaseline[in] Index passed from kern_calc_uvw

  • num_baselines[in] Number of baselines for a single time step

  • num_times[in] Number of time steps

  • num_freqs[in] Number of frequency steps

  • u[inout] Output u coord (metres)

  • v[inout] Output v coord (metres)

  • w[inout] Output w coord (metres)

__global__ void kern_calc_uvw(double *d_X_diff, double *d_Y_diff, double *d_Z_diff, user_precision_t *d_u_metres, user_precision_t *d_v_metres, user_precision_t *d_w_metres, user_precision_t *d_u, user_precision_t *d_v, user_precision_t *d_w, user_precision_t *d_wavelengths, double sdec0, double cdec0, double *d_cha0s, double *d_sha0s, int num_cross, int num_baselines, int num_times, int num_freqs)

Calculate the \(u,v,w\) in metres and in wavelengths for multiple time steps and frequencies.

d_X_diff, d_Y_diff, d_Z_diff contain baseline lengths in local X,Y,Z coords, which can change with time (when precessed back to J2000), so should be of length num_baselines*num_times. To keep indexing simple, the wavelengths in d_wavelengths and hour angles in d_cha0s, d_sha0s should contain values for all baselines, all frequencies, and all time steps. .

When called with dim3 grid, threads, kernel should be called with grid.x set, where:

  • grid.x * threads.x >= num_visis

Parameters:
  • d_X_diff[in] Baseline lengths in the X direction (metres)

  • d_Y_diff[in] Baseline lengths in the Y direction (metres)

  • d_Z_diff[in] Baseline lengths in the Z direction (metres)

  • d_u_metres[inout] Output u coords (metres)

  • d_v_metres[inout] Output v coords (metres)

  • d_w_metres[inout] Output w coords (metres)

  • d_u[inout] Output u coord (wavelengths)

  • d_v[inout] Output v coord (wavelengths)

  • d_w[inout] Output w coord (wavelengths)

  • d_wavelengths[in] Wavelengths for all baselines, frequencies, and time steps (metres)

  • sdec0[in] Sine of the declination of the phase centre

  • cdec0[in] Cosine of the declination of the phase centre

  • d_cha0s[in] Cosine of the hour angle of the phase centre for all baselines, frequencies, and time steps

  • d_sha0s[in] Sine of the hour angle of the phase centre for all baselines, frequencies, and time steps

  • num_cross[in] Total number of u,v,w coords to be calculated (number of cross correlations)

  • num_baselines[in] Number of baselines for a single time step

  • num_times[in] Number of time steps

  • num_freqs[in] Number of frequency steps

void calc_uvw_gpu(double *d_X_diff, double *d_Y_diff, double *d_Z_diff, user_precision_t *d_u_metres, user_precision_t *d_v_metres, user_precision_t *d_w_metres, user_precision_t *d_us, user_precision_t *d_vs, user_precision_t *d_ws, user_precision_t *d_allsteps_wavelengths, double *d_allsteps_cha0s, double *d_allsteps_sha0s, woden_settings_t *woden_settings)

This is just a wrapper to launch kern_calc_uvw to calculate u,v,w coords on the GPU. Wrapper means we can call this function from the CPU. All arrays should be initialised and filled on the GPU before calling this function.

External GPU code linked in from fundamental_coords_gpu.cpp, see fundamental_coords_gpu.h for full details.

Parameters:
  • d_X_diff[in] Baseline lengths in the X direction (metres)

  • d_Y_diff[in] Baseline lengths in the Y direction (metres)

  • d_Z_diff[in] Baseline lengths in the Z direction (metres)

  • d_u_metres[inout] Output u coords (metres)

  • d_v_metres[inout] Output v coords (metres)

  • d_w_metres[inout] Output w coords (metres)

  • d_us[inout] Output u coord (wavelengths)

  • d_vs[inout] Output v coord (wavelengths)

  • d_ws[inout] Output w coord (wavelengths)

  • d_allsteps_wavelengths[in] Wavelengths for all baselines, frequencies, and time steps (metres)

  • d_allsteps_cha0s[in] Cosine of the hour angle of the phase centre for all baselines, frequencies, and time steps

  • d_allsteps_sha0s[in] Sine of the hour angle of the phase centre for all baselines, frequencies, and time steps

  • woden_settings[in] Struct containing simulation settings

__global__ void kern_calc_uv_shapelet(double *d_X_diff, double *d_Y_diff, double *d_Z_diff, user_precision_t *d_u_shapes, user_precision_t *d_v_shapes, double *d_lsts, double *d_ras, double *d_decs, const int num_baselines, const int num_times, const int num_shapes)

The SHAPELET visibility envelope calculation uses a u,v coordinate system where the phase centre is set to the RA/Dec of that particular SHAPELET COMPONENT. This kernel calculates multiple \(u,v\) coodinates with varying phase centres to be used later by source_components.kern_calc_visi_shapelets.

The output arrays d_u_shapes, d_v_shapes, contain coordinates for all baselines (fastest changing), all times, and all SHAPELET components (slowest changing), in units of metres.

When called with dim3 grid, threads, kernel should be called with both grid.x and grid.y set, where:

  • grid.x * threads.x >= num_baselines*num_times

  • grid.y * threads.y >= num_shapes

Parameters:
  • d_X_diff[in] Baseline lengths in the X direction (metres)

  • d_Y_diff[in] Baseline lengths in the Y direction (metres)

  • d_Z_diff[in] Baseline lengths in the Z direction (metres)

  • d_u_shapes[inout] Output u coords with various phase centres for SHAPELET components (metres)

  • d_v_shapes[inout] Output v coords with various phase centres for SHAPELET components (metres)

  • d_lsts[in] The local sidereal times of all time steps in simulation (radians)

  • d_ras[in] Array of SHAPELET Right Ascensions (radians)

  • d_decs[in] Array of SHAPELET Declinations (radians)

  • num_baselines[in] Number of baselines for a single time step

  • num_times[in] Number of time steps

  • num_shapes[in] Number of SHAPELET COMPONENTs

void calc_uv_shapelet_gpu(user_precision_t *d_u_shapes, user_precision_t *d_v_shapes, int num_shapes, double *d_X_diff, double *d_Y_diff, double *d_Z_diff, double *d_ras, double *d_decs, woden_settings_t *woden_settings)

This is just a wrapper to launch kern_calc_uv_shapelet to calculate u,v coords on the GPU. Wrapper means we can call this function from the CPU.

All d_* arrays should be initialised and filled on the GPU before calling this. The function will copy woden_settings->lsts to the GPU, use it, then free it. Must also have woden_settings->num_baselines, woden_settings->num_time_steps intialised.

External GPU code linked in from fundamental_coords_gpu.cpp, see fundamental_coords_gpu.h for full details.

Parameters:
  • d_u_shapes[inout] Output u coords with various phase centres for SHAPELET components (wavelengths)

  • d_v_shapes[inout] Output v coords with various phase centres for SHAPELET components (wavelengths)

  • num_shapes[in] Number of SHAPELET COMPONENTs

  • d_X_diff[in] Baseline lengths in the X direction (metres)

  • d_Y_diff[in] Baseline lengths in the Y direction (metres)

  • d_Z_diff[in] Baseline lengths in the Z direction (metres)

  • d_ras[in] Array of SHAPELET Right Ascensions (radians)

  • d_decs[in] Array of SHAPELET Declinations (radians)

  • woden_settings[in] Struct containing simulation settings

__device__ void calc_lmn(double ra0, double sdec0, double cdec0, double ra, double dec, double *l, double *m, double *n)

Calculate interferometric \(l,m,n\) image coords for a given RA,Dec and phase centre.

Here it is assumed the phase centre is not changing with time

Parameters:
  • ra0[in] Right Ascension of the phase centre (radians)

  • sdec0[in] Sine of Declination of the phase centre

  • cdec0[in] Cosine of Declination of the phase centre

  • ra[in] Right Ascension (radians)

  • dec[in] Declination (radians)

  • l[in] Output \(l\) coodinate

  • m[in] Output \(m\) coodinate

  • n[in] Output \(n\) coodinate

__global__ void kern_calc_lmn(double ra0, double sdec0, double cdec0, double *d_ras, double *d_decs, double *d_l, double *d_m, double *d_n, int num_components)

Calculate interferometric \(l,m,n\) image coords for a set of RA,Dec coodinates, with a single RA/Dec phase centre.

When called with dim3 grid, threads, kernel should be called with grid.x set, where:

  • grid.x * threads.x >= num_components

Parameters:
  • ra0[in] Right Ascension of the phase centre (radians)

  • sdec0[in] Sine of Declination of the phase centre

  • cdec0[in] Cosine of Declination of the phase centre

  • d_ras[in] Array of Right Ascensions (radians)

  • d_decs[in] Array of Declinations (radians)

  • d_l[inout] Output \(l\) coodinates

  • d_m[inout] Output \(m\) coodinates

  • d_n[inout] Output \(n\) coodinates

  • num_components[in] Number of RA,Dec coords

void calc_lmn_for_components_gpu(components_t *d_components, int num_components, woden_settings_t *woden_settings)

Calculates the \(l,m,n\) image coords for an intialised d_components struct. Assumes d_components->ras, d_components->decs have been allocated and set on the device.

Runs kern_calc_lmn using d_components->ras, d_components->decs and woden_settings->ra0, woden_settings->sdec0, woden_settings->cdec0 as inputs. This function allocates device memory for d_components->ls, d_components->ms, and d_components->ns, and puts the results in these arrays.

Parameters:
  • d_components[inout] Initialised components_t struct containing the ra and dec arrays

  • num_components[in] Number of RA,Dec coords in d_components

  • woden_settings[in] Woden settings struct containing the phase centre

__global__ void kern_set_auto_uvw_to_zero(int num_cross, int num_autos, user_precision_t *d_u, user_precision_t *d_v, user_precision_t *d_w)

Internally to WODEN C/GPU, all cross-correlations are stored first, then the autos after. All autos have zero length, so use this function to set all autos uvw to zero.

num_cross is the number of cross-correlations, so fill any uvw after this by adding iAuto = threadIdx.x + (blockDim.x*blockIdx.x), meaning you should run this kernel with grid.x set, where:

  • grid.x * threads.x >= num_autos

Parameters:
  • num_cross[in] Number of cross-correlations

  • num_autos[in] Number of auto-correlations

  • d_u[inout] u coords

  • d_v[inout] v coords

  • d_w[inout] w coords

void set_auto_uvw_to_zero_gpu(int num_cross, int num_autos, user_precision_t *d_u, user_precision_t *d_v, user_precision_t *d_w)

This is just a wrapper to launch kern_set_auto_uvw_to_zero to set all auto-correlations to zero. Wrapper means we can call this function from the CPU.

All d_* arrays should be initialised and filled on the GPU before calling this.

External GPU code linked in from fundamental_coords_gpu.cpp, see fundamental_coords_gpu.h for full details.

Parameters:
  • num_cross[in] Number of cross-correlations

  • num_autos[in] Number of auto-correlations

  • d_u[inout] u coords

  • d_v[inout] v coords

  • d_w[inout] w coords