VCSBeam
Functions
metadata.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <mwalib.h>
#include "vcsbeam.h"
#include "gpu_macros.h"
Include dependency graph for metadata.c:

Functions

vcsbeam_context * vmInit (bool use_mpi)
 Initialises a VCSBeam context struct. More...
 
void vmBindObsData (vcsbeam_context *vm, char *first_coarse_chan_str, int num_coarse_chans_to_process, int coarse_chan_idx_offset, char *first_gps_second_str, int num_gps_seconds_to_process, int gps_second_offset, char *datadir)
 Binds a set of observation files to the VCSBeam context. More...
 
void vmBindCalibrationData (vcsbeam_context *vm, char *caldir, int cal_type, bool use_bandpass, char *flags_file)
 Binds a calibration solution to the VCSBeam context. More...
 
void vmReadCalibration (vcsbeam_context *vm)
 Reads in a calibration solution. More...
 
Antenna * find_antenna_by_name (MetafitsMetadata *obs_metadata, char *tile_name)
 Finds an antenna in an observation with a given name. More...
 
void destroy_vcsbeam_context (vcsbeam_context *vm)
 Frees the memory associated with the VCSBeam context. More...
 
void vmSetOutputChannelisation (vcsbeam_context *vm, bool out_fine, bool out_coarse)
 Sets flags governing whether the PFB and inverse PFB routines are run depending on the input and output channelisations. More...
 
void vmMallocVHost (vcsbeam_context *vm)
 Allocates memory for the input voltages on the CPU. More...
 
void vmMallocJVHost (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf J}{\bf v}\) on the CPU. More...
 
void vmMallocEHost (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf e}\) on the CPU. More...
 
void vmMallocSHost (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf S}\) on the CPU. More...
 
void vmMallocJHost (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf J}\) on the CPU. More...
 
void vmMallocDHost (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf D}\) on the CPU. More...
 
void vmMallocPQIdxsHost (vcsbeam_context *vm)
 Allocates memory for the polarisation indexes on the CPU. More...
 
void vmFreeVHost (vcsbeam_context *vm)
 Frees memory allocated for the input voltages on the CPU. More...
 
void vmFreeJVHost (vcsbeam_context *vm)
 Frees memory allocated with vmMallocJVHost(). More...
 
void vmFreeEHost (vcsbeam_context *vm)
 Frees memory allocated with vmMallocEHost(). More...
 
void vmFreeSHost (vcsbeam_context *vm)
 Frees memory allocated with vmMallocSHost(). More...
 
void vmFreeJHost (vcsbeam_context *vm)
 Frees memory allocated with vmMallocJHost(). More...
 
void vmFreeDHost (vcsbeam_context *vm)
 Frees memory allocated with vmMallocDHost(). More...
 
void vmFreePQIdxsHost (vcsbeam_context *vm)
 Frees memory allocated with vmMallocPQIdxsHost(). More...
 
void vmMallocVDevice (vcsbeam_context *vm)
 Allocates memory for the input voltages on the GPU. More...
 
void vmMallocJVDevice (vcsbeam_context *vm)
 Allocates memory for the quantities \({\bf J}{\bf v}\) on the GPU. More...
 
void vmMallocEDevice (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf e}\) on the GPU. More...
 
void vmMallocSDevice (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf S}\) on the GPU. More...
 
void vmMallocJDevice (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf J}\) on the GPU. More...
 
void vmMallocDDevice (vcsbeam_context *vm)
 Allocates memory for the quantity \({\bf D}\) on the GPU. More...
 
void vmMallocPQIdxsDevice (vcsbeam_context *vm)
 Allocates memory for the polarisation indexes on the GPU. More...
 
void vmFreeVDevice (vcsbeam_context *vm)
 Frees the GPU memory allocated with vmMallocVDevice(). More...
 
void vmFreeJVDevice (vcsbeam_context *vm)
 Frees memory allocated with vmMallocJVDevice(). More...
 
void vmFreeEDevice (vcsbeam_context *vm)
 Frees memory allocated with vmMallocEDevice(). More...
 
void vmFreeSDevice (vcsbeam_context *vm)
 Frees memory allocated with vmMallocSDevice(). More...
 
void vmFreeJDevice (vcsbeam_context *vm)
 Frees memory allocated with vmMallocJDevice(). More...
 
void vmFreeDDevice (vcsbeam_context *vm)
 Frees memory allocated with vmMallocDDevice(). More...
 
void vmFreePQIdxsDevice (vcsbeam_context *vm)
 Frees memory allocated with vmMallocPQIdxsDevice(). More...
 
void vmSetMaxGPUMem (vcsbeam_context *vm, int nchunks)
 Tries to cleverly figure out how many chunks are needed to fit everything on the GPU. More...
 
void vmPushChunk (vcsbeam_context *vm)
 Loads a "chunk" of input data onto the GPU. More...
 
vm_error vmReadNextSecond (vcsbeam_context *vm)
 Reads a second's worth of input data from the observation files. More...
 
void vmPushJ (vcsbeam_context *vm)
 Loads the Jones matrices onto the GPU. More...
 
void vmCreateCudaStreams (vcsbeam_context *vm)
 Sets up CUDA streams for multi-pixel beamforming. More...
 
void vmDestroyCudaStreams (vcsbeam_context *vm)
 Destroys the CUDA streams that were set up for multi-pixel beamforming. More...
 
void vmCreateStatistics (vcsbeam_context *vm, mpi_psrfits *mpfs)
 Allocates both CPU and GPU memory for the scales, offsets, and data for PSRFITS output. More...
 
void vmDestroyStatistics (vcsbeam_context *vm)
 Frees both the CPU and GPU memory for the scales, offsets, and data for PSRFITS output. More...
 
void vmSetNumPointings (vcsbeam_context *vm, unsigned int npointings)
 Sets the number of pointings. More...
 
void vmCreateFilenames (vcsbeam_context *vm)
 Creates a list of file names for the input data. More...
 
void vmGetVoltFilename (vcsbeam_context *vm, unsigned int coarse_chan_idx, uint64_t gps_second, char *filename)
 Gets the input file name for the given channel index and GPS second. More...
 
void vmGetLegacyVoltFilename (vcsbeam_context *vm, unsigned int coarse_chan_idx, uint64_t gps_second, char *filename)
 Gets the file name for the given channel index and GPS, as if the observation were a Legacy VCS observation. More...
 
void vmDestroyFilenames (vcsbeam_context *vm)
 Destroys the list of input file names. More...
 
void vmLoadObsMetafits (vcsbeam_context *vm, char *filename)
 Loads an observation's metadata from its metafits file. More...
 
void vmLoadCalMetafits (vcsbeam_context *vm, char *filename)
 Loads a calibration observation's metadata from its metafits file. More...
 
void vmGetVoltageMetadata (vcsbeam_context *vm)
 Creates the voltage metadata structs using mwalib's API. More...
 
long unsigned int get_relative_gps (MetafitsMetadata *obs_metadata, long int relative_begin)
 Gets the GPS second for an observation from a relative offset value. More...
 
long unsigned int parse_begin_string (MetafitsMetadata *obs_metadata, char *begin_str)
 Gets the GPS second from a string representation of either a relative or absolute value. More...
 
uintptr_t parse_coarse_chan_string (MetafitsMetadata *obs_metadata, char *begin_coarse_chan_str)
 Gets the coarse channel index from a string representation of either a relative or absolute value. More...
 
void vmSetNumNotFlaggedRFInputs (vcsbeam_context *vm)
 Counts the number of tiles that are not flagged. More...
 
Rfinput * find_matching_rf_input (MetafitsMetadata *metadata, Rfinput *rfinput)
 Finds a matching RF input in the given metadata. More...
 
Antenna * find_matching_antenna (MetafitsMetadata *metadata, Rfinput *rfinput)
 Finds a matching Antenna in the given metadata. More...
 
void get_mwalib_version (char *version_str)
 Gets the mwalib version. More...
 
void vmParsePointingFile (vcsbeam_context *vm, const char *filename)
 Parses RA/Dec pointings from a file. More...
 
void vmReportPerformanceStats (vcsbeam_context *vm)
 Reports all performance statistics. More...
 
void vmPrintTitle (vcsbeam_context *vm, const char *title)
 Prints a title to the specified log output stream. More...
 
void vmCheckError (vm_error err)
 

Function Documentation

◆ destroy_vcsbeam_context()

void destroy_vcsbeam_context ( vcsbeam_context *  vm)

Frees the memory associated with the VCSBeam context.

Parameters
vmThe VCSBeam context struct

After freeing the memory associated with the VCSBeam context's member variables, this function frees the VCSBeam context itself.

Todo:
Rename this function to a vm... name

◆ find_antenna_by_name()

Antenna* find_antenna_by_name ( MetafitsMetadata *  obs_metadata,
char *  tile_name 
)

Finds an antenna in an observation with a given name.

Parameters
obs_metadataThe observation metadata to be searched
tile_nameThe name of the tile being sought
Returns
A pointer to an mwalib Antenna struct with a matching tile name

If no tile with the given name is found in the observation, NULL is returned.

◆ find_matching_antenna()

Antenna* find_matching_antenna ( MetafitsMetadata *  metadata,
Rfinput *  rfinput 
)

Finds a matching Antenna in the given metadata.

Parameters
metadataThe metadata to be searched
rfinputThe RF input being sought
Returns
A pointer to the matching struct in metadata

This function goes through the antennas in metadata, searching for one that matches rfinput. A "match" is an RF input that has the same tile_id. If no match is found, NULL is returned.

◆ find_matching_rf_input()

Rfinput* find_matching_rf_input ( MetafitsMetadata *  metadata,
Rfinput *  rfinput 
)

Finds a matching RF input in the given metadata.

Parameters
metadataThe metadata to be searched
rfinputThe RF input being sought
Returns
A pointer to the matching struct in metadata

This function goes through the RF inputs in metadata, searching for one that matches rfinput. A "match" is an RF input that has the same tile_id and pol. If no match is found, NULL is returned.

◆ get_mwalib_version()

void get_mwalib_version ( char *  version_str)

Gets the mwalib version.

Parameters
[out]version_strA buffer to hold the version string

This function assumes that version_str is already allocated, and is big enough

◆ get_relative_gps()

long unsigned int get_relative_gps ( MetafitsMetadata *  obs_metadata,
long int  relative_begin 
)

Gets the GPS second for an observation from a relative offset value.

Parameters
obs_metadataThe observation's metadata
relative_beginAn offset number of seconds
Returns
An absolute GPS second

If relative_begin >= 0, then return the GPS second relative to the "good time" (i.e. from the beginning of the observation). If relative_begin < 0, then return the GPS second relative to the end of the observation.

relative_begin GPS second
0 1st "good" second
1 2nd "good" second
2 3rd "good" second
... ...
-2 2nd last second
-1 Last second

◆ parse_begin_string()

long unsigned int parse_begin_string ( MetafitsMetadata *  obs_metadata,
char *  begin_str 
)

Gets the GPS second from a string representation of either a relative or absolute value.

Parameters
obs_metadataThe observation's metadata
begin_strA string representation of either a relative or absolute GPS second
Returns
An absolute GPS second

If the first character of begin_str is '+' or '-', then return a relative GPS second according to get_relative_gps(). Otherwise, parse it as a GPS second in its own right.

See also
parse_coarse_chan_string()
get_relative_gps()

◆ parse_coarse_chan_string()

uintptr_t parse_coarse_chan_string ( MetafitsMetadata *  obs_metadata,
char *  begin_coarse_chan_str 
)

Gets the coarse channel index from a string representation of either a relative or absolute value.

Parameters
obs_metadataThe observation's metadata
begin_coarse_chan_strA string representation of either a relative or absolute coarse channel index
Returns
An absolute coarse channel index

If the first character of begin_coarse_chan_str is '+' or '-', then return the coarse channel index relative to the lowest or highest coarse channel, respectively (with "-1" representing the highest channel, "-2" the second highest, etc.). Otherwise, parse it as a coarse channel index in its own right.

See also
parse_begin_string()

◆ vmBindCalibrationData()

void vmBindCalibrationData ( vcsbeam_context *  vm,
char *  caldir,
int  cal_type,
bool  use_bandpass,
char *  flags_file 
)

Binds a calibration solution to the VCSBeam context.

Parameters
vmThe VCSBeam context struct
caldirThe directory containing RTS solution files, OR the path of an Offringa-style calibration solution file
cal_typeEither CAL_RTS or CAL_OFFRINGA
use_bandpassWhether to include the Bandpass information (relevant for RTS solutions only)
flags_fileA file containing names of (extra) tiles to be flagged, or NULL

◆ vmBindObsData()

void vmBindObsData ( vcsbeam_context *  vm,
char *  first_coarse_chan_str,
int  num_coarse_chans_to_process,
int  coarse_chan_idx_offset,
char *  first_gps_second_str,
int  num_gps_seconds_to_process,
int  gps_second_offset,
char *  datadir 
)

Binds a set of observation files to the VCSBeam context.

Parameters
vmThe VCSBeam context struct
first_coarse_chan_strA string representation of the lowest coarse channel to be processed
num_coarse_chans_to_processThe number of coarse channels to be processed
coarse_chan_idx_offsetThe first coarse channel (relative to first_coarse_chan_str) to be processed by this MPI process
first_gps_second_strA string representation of the first GPS second to be processed
num_gps_seconds_to_processThe number of GPS seconds to be processed
gps_second_offsetThe first GPS second (relative to first_gps_second_str) to be processed by this MPI process
datadirThe directory containing the observation data files

◆ vmCheckError()

void vmCheckError ( vm_error  err)

◆ vmCreateCudaStreams()

void vmCreateCudaStreams ( vcsbeam_context *  vm)

Sets up CUDA streams for multi-pixel beamforming.

Parameters
vmThe VCSBeam context struct
See also
vmDestroyCudaStreams()

◆ vmCreateFilenames()

void vmCreateFilenames ( vcsbeam_context *  vm)

Creates a list of file names for the input data.

Parameters
vmThe VCSBeam context struct

This function creates an array of file names that are passed to mwalib to manage the reading in of the data.

See also
vmDestroyFilenames()

◆ vmCreateStatistics()

void vmCreateStatistics ( vcsbeam_context *  vm,
mpi_psrfits *  mpfs 
)

Allocates both CPU and GPU memory for the scales, offsets, and data for PSRFITS output.

Parameters
vmThe VCSBeam context struct
mpfsA pointer to a MPI PSRFITS struct
See also
vmDestroyStatistics()

◆ vmDestroyCudaStreams()

void vmDestroyCudaStreams ( vcsbeam_context *  vm)

Destroys the CUDA streams that were set up for multi-pixel beamforming.

Parameters
vmThe VCSBeam context struct
See also
vmCreateCudaStreams()

◆ vmDestroyFilenames()

void vmDestroyFilenames ( vcsbeam_context *  vm)

Destroys the list of input file names.

Parameters
vmThe VCSBeam context struct
See also
vmCreateFilenames()

◆ vmDestroyStatistics()

void vmDestroyStatistics ( vcsbeam_context *  vm)

Frees both the CPU and GPU memory for the scales, offsets, and data for PSRFITS output.

Parameters
vmThe VCSBeam context struct
See also
vmCreateStatistics()

◆ vmFreeDDevice()

void vmFreeDDevice ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocDDevice().

Parameters
vmThe VCSBeam context struct

◆ vmFreeDHost()

void vmFreeDHost ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocDHost().

Parameters
vmThe VCSBeam context struct

◆ vmFreeEDevice()

void vmFreeEDevice ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocEDevice().

Parameters
vmThe VCSBeam context struct

◆ vmFreeEHost()

void vmFreeEHost ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocEHost().

Parameters
vmThe VCSBeam context struct

◆ vmFreeJDevice()

void vmFreeJDevice ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocJDevice().

Parameters
vmThe VCSBeam context struct

◆ vmFreeJHost()

void vmFreeJHost ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocJHost().

Parameters
vmThe VCSBeam context struct

◆ vmFreeJVDevice()

void vmFreeJVDevice ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocJVDevice().

Parameters
vmThe VCSBeam context struct

◆ vmFreeJVHost()

void vmFreeJVHost ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocJVHost().

Parameters
vmThe VCSBeam context struct

◆ vmFreePQIdxsDevice()

void vmFreePQIdxsDevice ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocPQIdxsDevice().

Parameters
vmThe VCSBeam context struct

◆ vmFreePQIdxsHost()

void vmFreePQIdxsHost ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocPQIdxsHost().

Parameters
vmThe VCSBeam context struct

◆ vmFreeSDevice()

void vmFreeSDevice ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocSDevice().

Parameters
vmThe VCSBeam context struct

◆ vmFreeSHost()

void vmFreeSHost ( vcsbeam_context *  vm)

Frees memory allocated with vmMallocSHost().

Parameters
vmThe VCSBeam context struct

◆ vmFreeVDevice()

void vmFreeVDevice ( vcsbeam_context *  vm)

Frees the GPU memory allocated with vmMallocVDevice().

Parameters
vmThe VCSBeam context struct

If the observation is Legacy, then free the memory.

If the observation is MWAX, then do nothing; the memory should be freed via a call to vmFreeForwardPFB().

◆ vmFreeVHost()

void vmFreeVHost ( vcsbeam_context *  vm)

Frees memory allocated for the input voltages on the CPU.

Parameters
vmThe VCSBeam context struct

◆ vmGetLegacyVoltFilename()

void vmGetLegacyVoltFilename ( vcsbeam_context *  vm,
unsigned int  coarse_chan_idx,
uint64_t  gps_second,
char *  filename 
)

Gets the file name for the given channel index and GPS, as if the observation were a Legacy VCS observation.

Parameters
vmThe VCSBeam context struct
[in]coarse_chan_idxThe index of a coarse channel
[in]gps_secondA GPS second
[out]filenameA buffer for the filename

This function returns the filename for the observation referred to in vm→obs_context_legacy.

filename must point to already-allocated memory.

See also
vmGetVoltFilename()

◆ vmGetVoltageMetadata()

void vmGetVoltageMetadata ( vcsbeam_context *  vm)

Creates the voltage metadata structs using mwalib's API.

Parameters
vmThe VCSBeam context struct

This function should only be called after vmLoadObsMetafits().

◆ vmGetVoltFilename()

void vmGetVoltFilename ( vcsbeam_context *  vm,
unsigned int  coarse_chan_idx,
uint64_t  gps_second,
char *  filename 
)

Gets the input file name for the given channel index and GPS second.

Parameters
vmThe VCSBeam context struct
[in]coarse_chan_idxThe index of a coarse channel
[in]gps_secondA GPS second
[out]filenameA buffer for the filename

This function returns the filename for the observation referred to in vm→obs_context.

The variable vm→seconds_per_file must be set to the relevant value depending on whether the observation is Legacy (1) or MWAX (8), which is done via vmLoadObsMetafits().

filename must point to already-allocated memory.

See also
vmGetLegacyVoltFilename()

◆ vmInit()

vcsbeam_context* vmInit ( bool  use_mpi)

Initialises a VCSBeam context struct.

Parameters
use_mpiSet up the struct for using MPI
Returns
A pointer to a newly allocated vcsbeam_context struct

Once the VCSBeam context is finished with, it should be freed with a call to destroy_vcsbeam_context().

◆ vmLoadCalMetafits()

void vmLoadCalMetafits ( vcsbeam_context *  vm,
char *  filename 
)

Loads a calibration observation's metadata from its metafits file.

Parameters
vmThe VCSBeam context struct
filenameThe name of the metafits file to be loaded.

This function loads the metadata into vm→cal_context and vm→cal_metadata, using mwalib's API. The observation to be loaded should be the calibration observation, i.e. the observation for which a calibration solution has been obtained.

◆ vmLoadObsMetafits()

void vmLoadObsMetafits ( vcsbeam_context *  vm,
char *  filename 
)

Loads an observation's metadata from its metafits file.

Parameters
vmThe VCSBeam context struct
filenameThe name of the metafits file to be loaded.

This function loads the metadata into vm→obs_context and vm→obs_metadata, using mwalib's API. It also loads a "Legacy" version of the context and metafits into vm→obs_context_legacy and vm→obs_metafits_legacy. The observation to be loaded should be the "target" observation, i.e. the observation whose VCS data is to be processed.

◆ vmMallocDDevice()

void vmMallocDDevice ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf D}\) on the GPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→d_D.

◆ vmMallocDHost()

void vmMallocDHost ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf D}\) on the CPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→D.

◆ vmMallocEDevice()

void vmMallocEDevice ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf e}\) on the GPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→d_e.

◆ vmMallocEHost()

void vmMallocEHost ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf e}\) on the CPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→e.

◆ vmMallocJDevice()

void vmMallocJDevice ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf J}\) on the GPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→d_J.

◆ vmMallocJHost()

void vmMallocJHost ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf J}\) on the CPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→J.

◆ vmMallocJVDevice()

void vmMallocJVDevice ( vcsbeam_context *  vm)

Allocates memory for the quantities \({\bf J}{\bf v}\) on the GPU.

Parameters
vmThe VCSBeam context struct

Pointers to the newly allocated memory are given in vm→d_Jv_P and vm→d_Jv_Q.

Only one "chunk" of memory is allocated (where each second of input data is divided up into one or more chunks, depending on the amount of memory available on the GPU).

◆ vmMallocJVHost()

void vmMallocJVHost ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf J}{\bf v}\) on the CPU.

Parameters
vmThe VCSBeam context struct

Pointers to the newly allocated memory are given in vm→Jv_P and vm→Jv_Q.

◆ vmMallocPQIdxsDevice()

void vmMallocPQIdxsDevice ( vcsbeam_context *  vm)

Allocates memory for the polarisation indexes on the GPU.

Parameters
vmThe VCSBeam context struct

Pointers to the newly allocated memory are given in vm→d_polP_idxs and vm→d_polQ_idxs.

◆ vmMallocPQIdxsHost()

void vmMallocPQIdxsHost ( vcsbeam_context *  vm)

Allocates memory for the polarisation indexes on the CPU.

Parameters
vmThe VCSBeam context struct

Pointers to the newly allocated memory are given in vm→polP_idxs and vm→polQ_idxs.

◆ vmMallocSDevice()

void vmMallocSDevice ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf S}\) on the GPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→d_S.

◆ vmMallocSHost()

void vmMallocSHost ( vcsbeam_context *  vm)

Allocates memory for the quantity \({\bf S}\) on the CPU.

Parameters
vmThe VCSBeam context struct

A pointer to the newly allocated memory is given in vm→S.

◆ vmMallocVDevice()

void vmMallocVDevice ( vcsbeam_context *  vm)

Allocates memory for the input voltages on the GPU.

Parameters
vmThe VCSBeam context struct

If the observation is Legacy, then this function allocates new memory and sets vm→d_v_size_bytes to the address of the new memory block.

If the observation is MWAX, then this function only copies the value of vm→fpfb→d_vcs_data to vm→d_v_size_bytes, (without checking whether it points to valid GPU memory).

Only one "chunk" of memory is allocated (where each second of input data is divided up into one or more chunks, depending on the amount of memory available on the GPU).

◆ vmMallocVHost()

void vmMallocVHost ( vcsbeam_context *  vm)

Allocates memory for the input voltages on the CPU.

Parameters
vmThe VCSBeam context struct

The memory is allocated as a host_buffer struct (see vmInitReadBuffer() for a full description). The amount of memory allocated depends on whether the observation is Legacy or MWAX.

If the input is legacy, the read buffer can be just enough for one second's worth of data.

However, for MWAX, the read buffer must be slightly bigger to accommodate the PFB's extra taps. (For now, this is fixed to one voltage block. Changing this will break the gpu kernels that do the fine PFB, for which the offset into the data is currently hard-coded.)

◆ vmParsePointingFile()

void vmParsePointingFile ( vcsbeam_context *  vm,
const char *  filename 
)

Parses RA/Dec pointings from a file.

Parameters
vmThe VCSBeam context struct
filenameThe name of the file to be parsed.

The file must contain whitespace-separated RAs and Decs in the format HH:MM:SS.S DD:MM:SS.S.

This function allocates memory for ras_hours and decs_degs arrays, which will be destroyed during destroy_vcsbeam_context().

◆ vmPrintTitle()

void vmPrintTitle ( vcsbeam_context *  vm,
const char *  title 
)

Prints a title to the specified log output stream.

Parameters
vmThe VCSBeam context struct
titleThe text to be printed

The text is printed in the format

------- VCSBeam (VERSION): TITLE -------

with VERSION and TITLE being replaced with the VCSBeam version string and the specified title respectively.

◆ vmPushChunk()

void vmPushChunk ( vcsbeam_context *  vm)

Loads a "chunk" of input data onto the GPU.

Parameters
vmThe VCSBeam context struct

◆ vmPushJ()

void vmPushJ ( vcsbeam_context *  vm)

Loads the Jones matrices onto the GPU.

Parameters
vmThe VCSBeam context struct

◆ vmReadCalibration()

void vmReadCalibration ( vcsbeam_context *  vm)

Reads in a calibration solution.

Parameters
vmThe VCSBeam context struct

Calls either vmLoadRTSSolution() or vmLoadOffringaSolution() depending on whether vm→cal.cal_type is set to CAL_RTS or CAL_OFFRINGA. Afterwards, vmSetCustomTileFlags() is called.

◆ vmReadNextSecond()

vm_error vmReadNextSecond ( vcsbeam_context *  vm)

Reads a second's worth of input data from the observation files.

Parameters
vmThe VCSBeam context struct

◆ vmReportPerformanceStats()

void vmReportPerformanceStats ( vcsbeam_context *  vm)

Reports all performance statistics.

Parameters
vmThe VCSBeam context struct

◆ vmSetMaxGPUMem()

void vmSetMaxGPUMem ( vcsbeam_context *  vm,
int  nchunks 
)

Tries to cleverly figure out how many chunks are needed to fit everything on the GPU.

Parameters
vmThe VCSBeam context struct
max_gpu_mem_bytesThe maximum amount of GPU memory (in bytes) to use

LOGIC IS CURRENTLY FAULTY AND INCOMPLETE. DO NOT USE!

◆ vmSetNumNotFlaggedRFInputs()

void vmSetNumNotFlaggedRFInputs ( vcsbeam_context *  vm)

Counts the number of tiles that are not flagged.

Parameters
vmThe VCSBeam context struct

The result is stored in vm→num_not_flagged.

◆ vmSetNumPointings()

void vmSetNumPointings ( vcsbeam_context *  vm,
unsigned int  npointings 
)

Sets the number of pointings.

Parameters
vmThe VCSBeam context struct
[in]npointingsThe number of pointings
Todo:
Investigate whether this function is really needed

◆ vmSetOutputChannelisation()

void vmSetOutputChannelisation ( vcsbeam_context *  vm,
bool  out_fine,
bool  out_coarse 
)

Sets flags governing whether the PFB and inverse PFB routines are run depending on the input and output channelisations.

Parameters
vmThe VCSBeam context struct
out_fineSets the flag for fine channelised output
out_coarseSets the flag for coarse_channelised output

Whether the (forward) PFB or the inverse PFB needs to be run depends on the input channelisation (fine = Legacy, or coarse = MWAX), and what channelisations are desired in output (fine or coarse). The vm→do_forward_pfb and vm→do_inverse_pfb are set accordingly.

The following table describes all possible scenarios:

Input mode Output fine? Output coarse? Do forward PFB? Do inverse PFB?
Legacy no no no no
Legacy no yes no yes
Legacy yes no no no
Legacy yes yes no yes
MWAX no no no no
MWAX no yes yes yes
MWAX yes no yes no
MWAX yes yes yes yes

Note that both forward and inverse PFBs are required for MWAX data even when fine-channelised output is not requested. This is because the beamforming operation requires sufficiently fine channels in order to avoid decoherence across the channels.