Namespace Utils
Namespace containing utility functions.
Public Functions
| Type | Name |
|---|---|
| void | check_collective_io (const HighFive::DataTransferProps & xfer_props) Check if the collective I/O is working. |
| double | generate_double (uint64_t i) Generates a deterministic double from a 64-bit integer. |
| uint64_t | get_host_hash (const char * string) Get the host hash. |
| void | get_host_name (char * hostname, int maxlen) Get the host name. |
| size_t | get_start_index (size_t glob_num_blocks, int color, int comm_size) Get the starting index for a given color (row or col). |
| int | global_to_local_size (int global_size, int color, int comm_size) Get the global size of a vector. |
| int | local_to_global_size (int local_size, int comm_size) Get the global size of a vector. |
| void | make_table (std::vector< std::string > col_names, std::vector< long double > mean, std::vector< long double > min, std::vector< long double > max) Make a table of timing data. |
| void | print_raw (long double * mean_times, long double * min_times, long double * max_times, long double * mean_times_f, long double * min_times_f, long double * max_times_f, long double * mean_times_fs, long double * min_times_fs, long double * max_times_fs, int times_len) Print the raw timing data. |
| void | print_times (int reps=1, bool table=true) Print the times for the different parts of the code. |
| void | print_vec (double * vec, int len, int block_size, std::string name="Vector") Prints the elements of a vector. |
| void | print_vec_complex (ComplexD * vec, int len, int block_size, std::string name="Vector") Prints a ComplexD vector. |
| void | print_vec_mpi (double * vec, int len, int block_size, int rank, int world_size, std::string name="Vector") Prints a vector using MPI. |
| void | sbgemv (Precision p, const void * d_mat, const void * d_vec_in, void * d_vec_out, int num_rows, int num_cols, int block_size, bool conjugate, cublasHandle_t handle, cudaStream_t s) Perform a strided batched matrix-vector multiplication. |
| void | swap_axes (Precision p, const void * d_in, void * d_out, int num_cols, int num_rows, int padded_size, cudaStream_t s=0) Computes the 3D swapaxes operation on the matrix blocks. |
| void | transpose_2d (Precision p, const void * d_in, void * d_out, int dim_ctgs, int dim_strd, cublasHandle_t handle, cudaStream_t s) Transpose a 2D matrix (usually a 1D vector thought of as a 2D matrix). |
| std::string | zero_pad (size_t num, size_t width) Zero pad a number to a given width (returns a string). |
Public Functions Documentation
function check_collective_io
Check if the collective I/O is working.
Parameters:
xfer_propsThe data transfer properties.
function generate_double
Generates a deterministic double from a 64-bit integer.
Parameters:
iThe 64-bit integer.
function get_host_hash
Get the host hash.
This function returns the hash of the host name.
Parameters:
stringThe host name.
Returns:
The hash of the host name.
function get_host_name
Get the host name.
This function gets the host name and stores it in the provided buffer.
Parameters:
hostnameThe buffer to store the host name.maxlenThe maximum length of the buffer.
Returns the hostname of the machine.
Parameters:
hostnameThe hostname to return.maxlenThe maximum length of the hostname.
function get_start_index
Get the starting index for a given color (row or col).
Parameters:
glob_num_blocksThe global number of blocks (distributed across the communicator).colorThe color of the process in the communicator.comm_sizeThe number of processes in the communicator.
function global_to_local_size
Get the global size of a vector.
Parameters:
local_sizeThe local size of the vector.colorThe color of the process in the communicator.comm_sizeThe number of processes in the communicator.
Returns:
The global size of the vector.
function local_to_global_size
Get the global size of a vector.
Parameters:
local_sizeThe local size of the vector.colorThe color of the process in the communicator.comm_sizeThe number of processes in the communicator.
Returns:
The global size of the vector (just local_size * comm_size).
function make_table
Make a table of timing data.
void Utils::make_table (
std::vector< std::string > col_names,
std::vector< long double > mean,
std::vector< long double > min,
std::vector< long double > max
)
Parameters:
col_namesThe names of the columns (first entry is the title).meanThe mean times.minThe minimum times.maxThe maximum times.
function print_raw
Print the raw timing data.
void Utils::print_raw (
long double * mean_times,
long double * min_times,
long double * max_times,
long double * mean_times_f,
long double * min_times_f,
long double * max_times_f,
long double * mean_times_fs,
long double * min_times_fs,
long double * max_times_fs,
int times_len
)
Parameters:
mean_timesThe mean times.min_timesThe minimum times.max_timesThe maximum times.mean_times_fThe mean times for the forward FFT.min_times_fThe minimum times for the forward FFT.max_times_fThe maximum times for the forward FFT.mean_times_fsThe mean times for the forward FFT in TOSI format.min_times_fsThe minimum times for the forward FFT in TOSI format.max_times_fsThe maximum times for the forward FFT in TOSI format.times_lenThe number of timing segments.
function print_times
Print the times for the different parts of the code.
Parameters:
repsThe number of repetitions of the code.tableFlag indicating whether to print the times in a table or print raw values.
function print_vec
Prints the elements of a vector.
This function prints the elements of a vector to the console.
Parameters:
vecPointer to the vector.lenThe length of the vector.block_sizeThe size of the unpadded vector.name(Optional) The name of the vector. Defaults to "Vector".
function print_vec_complex
Prints a ComplexD vector.
void Utils::print_vec_complex (
ComplexD * vec,
int len,
int block_size,
std::string name="Vector"
)
This function prints the elements of a ComplexD vector to the console.
Parameters:
vecThe ComplexD vector to be printed.lenThe length of the vector.block_sizeThe size of the unpadded vector.nameThe name of the vector (optional).
function print_vec_mpi
Prints a vector using MPI.
void Utils::print_vec_mpi (
double * vec,
int len,
int block_size,
int rank,
int world_size,
std::string name="Vector"
)
This function prints the elements of a vector using MPI. It takes the following parameters:
* vec: A pointer to the vector to be printed.
* len: The length of the vector.
* block_size: The size of the unpadded vector.
* rank: The rank of the current process.
* world_size: The total number of processes.
* name: (Optional) The name of the vector (default is "Vector").
Parameters:
vecA pointer to the vector to be printed.lenThe length of the vector.block_sizeThe size of the unpadded vector.rankThe rank of the current process.world_sizeThe total number of processes.name(Optional) The name of the vector (default is "Vector").
function sbgemv
Perform a strided batched matrix-vector multiplication.
void Utils::sbgemv (
Precision p,
const void * d_mat,
const void * d_vec_in,
void * d_vec_out,
int num_rows,
int num_cols,
int block_size,
bool conjugate,
cublasHandle_t handle,
cudaStream_t s
)
Parameters:
pThe precision of the input and output matrices.d_matPointer to the input matrix.d_vec_inPointer to the input vector.d_vec_outPointer to the output vector.num_rowsThe number of rows in the matrix.num_colsThe number of columns in the matrix.block_sizeBatch count.conjugateFlag indicating whether to conjugate transpose the matrix.handleThe cuBLAS handle to use for the operation.
function swap_axes
Computes the 3D swapaxes operation on the matrix blocks.
void Utils::swap_axes (
Precision p,
const void * d_in,
void * d_out,
int num_cols,
int num_rows,
int padded_size,
cudaStream_t s=0
)
Parameters:
pThe precision of the input and output matrices.d_inPointer to the input matrix.d_outPointer to the output matrix.num_colsThe number of block columns in the matrix.num_rowsThe number of block rows in the matrix.padded_sizeThe size of each block. Note: this is used inside the matvec setup function, so it is called with Nt + 1 and not 2 * Nt.sThe CUDA stream to use for the operation (optional).
function transpose_2d
Transpose a 2D matrix (usually a 1D vector thought of as a 2D matrix).
void Utils::transpose_2d (
Precision p,
const void * d_in,
void * d_out,
int dim_ctgs,
int dim_strd,
cublasHandle_t handle,
cudaStream_t s
)
Parameters:
pThe precision of the input and output matrices.d_inPointer to the input matrix.d_outPointer to the output matrix.dim_ctgsThe contiguous dimension of the input matrix.dim_strdThe strided dimension of the input matrix.handleThe cuBLAS handle to use for the operation.sThe CUDA stream to use for the operation (optional).
function zero_pad
Zero pad a number to a given width (returns a string).
Parameters:
numThe number to pad.widthThe width of the padding (number of digits in padded string).
Returns:
The zero-padded string.
The documentation for this class was generated from the following file src/utils.hpp