RadioImagerGPU 1.0
Loading...
Searching...
No Matches
compute.cu File Reference
#include "config.hpp"
#include "compute.hpp"
#include <cufft.h>
#include <thrust/complex.h>
#include <thrust/device_vector.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cuda_runtime.h>

Macros

#define CHECK_CUFFT(call)
 Macro to check CUFFT errors and display an error message if an error occurs.
 
#define CHECK_CUDA(call)
 Macro to check CUDA errors and display an error message if an error occurs.
 

Functions

const char * cufftGetErrorString (cufftResult error)
 Get the error string for a given CUFFT error code.
 
void checkCudaError (cudaError_t err, const char *msg)
 Check CUDA error and print a message if an error occurs.
 
__global__ void fftshift_kernel (cufftDoubleComplex *data, cufftDoubleComplex *temp, int width, int height, int shiftX, int shiftY)
 Perform a 2D FFT shift operation on the given data.
 
void fftshift (thrust::device_vector< cufftDoubleComplex > &data, int width, int height)
 Perform a 2D FFT shift on a thrust::device_vector.
 
__global__ void mapVisibilitiesMultiDir (cufftDoubleComplex *grid, const cufftDoubleComplex *visibilities, const double *u, const double *v, double uv_max, double grid_res, int image_size, int num_visibilities, int num_directions)
 Map visibilities to a grid for multiple directions (batches).
 
void uniformImage (const std::vector< std::vector< std::complex< double > > > &visibilities_batch, const std::vector< std::vector< double > > &u_batch, const std::vector< std::vector< double > > &v_batch, int image_size, std::vector< std::vector< double > > &images, bool use_predefined_params)
 Generate a uniform image from visibilities using FFT.
 
__global__ void computeUVWKernel (const double *x_m, const double *y_m, const double *z_m, const double *HAs, const double *Decs, double *u, double *v, double *w, int N, int num_directions)
 CUDA kernel to compute UVW coordinates from XYZ coordinates for multiple directions.
 
void computeUVW (const std::vector< double > &x_m, const std::vector< double > &y_m, const std::vector< double > &z_m, const std::vector< double > &HAs, const std::vector< double > &Decs, std::vector< std::vector< double > > &u, std::vector< std::vector< double > > &v, std::vector< std::vector< double > > &w)
 Compute UVW coordinates from XYZ coordinates for multiple directions.
 

Macro Definition Documentation

◆ CHECK_CUDA

#define CHECK_CUDA ( call)
Value:
{ \
cudaError_t err = call; \
if (err != cudaSuccess) { \
std::cerr << "CUDA Error: " << cudaGetErrorString(err) << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(EXIT_FAILURE); \
} \
}

Macro to check CUDA errors and display an error message if an error occurs.

Parameters
callCUDA function call.

◆ CHECK_CUFFT

#define CHECK_CUFFT ( call)
Value:
{ \
cufftResult err = call; \
if (err != CUFFT_SUCCESS) { \
std::cerr << "CUFFT Error: " << cufftGetErrorString(err) << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
exit(EXIT_FAILURE); \
} \
}
const char * cufftGetErrorString(cufftResult error)
Get the error string for a given CUFFT error code.
Definition compute.cu:30

Macro to check CUFFT errors and display an error message if an error occurs.

Parameters
callCUFFT function call.

Function Documentation

◆ checkCudaError()

void checkCudaError ( cudaError_t err,
const char * msg )

Check CUDA error and print a message if an error occurs.

Parameters
errCUDA error code.
msgError message to display if an error occurs.

◆ computeUVW()

void computeUVW ( const std::vector< double > & x_m,
const std::vector< double > & y_m,
const std::vector< double > & z_m,
const std::vector< double > & HAs,
const std::vector< double > & Decs,
std::vector< std::vector< double > > & u,
std::vector< std::vector< double > > & v,
std::vector< std::vector< double > > & w )

Compute UVW coordinates from XYZ coordinates for multiple directions.

Parameters
x_mX coordinates of the antennas.
y_mY coordinates of the antennas.
z_mZ coordinates of the antennas.
HAsHour angles for multiple directions.
DecsDeclinations for multiple directions.
uOutput U coordinates for multiple directions.
vOutput V coordinates for multiple directions.
wOutput W coordinates for multiple directions.
use_predefined_paramsFlag to determine if predefined parameters should be used.

◆ computeUVWKernel()

__global__ void computeUVWKernel ( const double * x_m,
const double * y_m,
const double * z_m,
const double * HAs,
const double * Decs,
double * u,
double * v,
double * w,
int N,
int num_directions )

CUDA kernel to compute UVW coordinates from XYZ coordinates for multiple directions.

Parameters
x_mX coordinates of the antennas.
y_mY coordinates of the antennas.
z_mZ coordinates of the antennas.
HAsHour angles for multiple directions.
DecsDeclinations for multiple directions.
uOutput U coordinates.
vOutput V coordinates.
wOutput W coordinates.
NNumber of antennas.
num_directionsNumber of directions.

◆ cufftGetErrorString()

const char * cufftGetErrorString ( cufftResult error)

Get the error string for a given CUFFT error code.

Parameters
errorCUFFT error code.
Returns
const char* Corresponding error string.

◆ fftshift()

void fftshift ( thrust::device_vector< cufftDoubleComplex > & data,
int width,
int height )

Perform a 2D FFT shift on a thrust::device_vector.

Parameters
dataData to be shifted.
widthWidth of the data array.
heightHeight of the data array.

◆ fftshift_kernel()

__global__ void fftshift_kernel ( cufftDoubleComplex * data,
cufftDoubleComplex * temp,
int width,
int height,
int shiftX,
int shiftY )

Perform a 2D FFT shift operation on the given data.

Parameters
dataInput data to be shifted.
tempTemporary data storage for shifting.
widthWidth of the data array.
heightHeight of the data array.
shiftXAmount to shift in the X direction.
shiftYAmount to shift in the Y direction.

◆ mapVisibilitiesMultiDir()

__global__ void mapVisibilitiesMultiDir ( cufftDoubleComplex * grid,
const cufftDoubleComplex * visibilities,
const double * u,
const double * v,
double uv_max,
double grid_res,
int image_size,
int num_visibilities,
int num_directions )

Map visibilities to a grid for multiple directions (batches).

Parameters
gridOutput grid to store the mapped visibilities.
visibilitiesInput visibilities to map.
uU coordinates of visibilities.
vV coordinates of visibilities.
uv_maxMaximum UV coordinate value.
grid_resResolution of the grid.
image_sizeSize of the output image.
num_visibilitiesNumber of visibilities.
num_directionsNumber of directions.

◆ uniformImage()

void uniformImage ( const std::vector< std::vector< std::complex< double > > > & visibilities_batch,
const std::vector< std::vector< double > > & u_batch,
const std::vector< std::vector< double > > & v_batch,
int image_size,
std::vector< std::vector< double > > & images,
bool use_predefined_params )

Generate a uniform image from visibilities using FFT.

Parameters
visibilities_batchBatch of visibilities for multiple directions.
u_batchU coordinates for multiple directions.
v_batchV coordinates for multiple directions.
image_sizeSize of the output image.
imagesOutput images.
use_predefined_paramsFlag to determine if predefined parameters should be used.