Skip to content

Namespace Utils

Namespace List > 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.

void Utils::check_collective_io (
    const HighFive::DataTransferProps & xfer_props
) 

Parameters:

  • xfer_props The data transfer properties.

function generate_double

Generates a deterministic double from a 64-bit integer.

double Utils::generate_double (
    uint64_t i
) 

Parameters:

  • i The 64-bit integer.

function get_host_hash

Get the host hash.

uint64_t Utils::get_host_hash (
    const char * string
) 

This function returns the hash of the host name.

Parameters:

  • string The host name.

Returns:

The hash of the host name.


function get_host_name

Get the host name.

void Utils::get_host_name (
    char * hostname,
    int maxlen
) 

This function gets the host name and stores it in the provided buffer.

Parameters:

  • hostname The buffer to store the host name.
  • maxlen The maximum length of the buffer.

Returns the hostname of the machine.

Parameters:

  • hostname The hostname to return.
  • maxlen The maximum length of the hostname.

function get_start_index

Get the starting index for a given color (row or col).

size_t Utils::get_start_index (
    size_t glob_num_blocks,
    int color,
    int comm_size
) 

Parameters:

  • glob_num_blocks The global number of blocks (distributed across the communicator).
  • color The color of the process in the communicator.
  • comm_size The number of processes in the communicator.

function global_to_local_size

Get the global size of a vector.

int Utils::global_to_local_size (
    int global_size,
    int color,
    int comm_size
) 

Parameters:

  • local_size The local size of the vector.
  • color The color of the process in the communicator.
  • comm_size The 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.

int Utils::local_to_global_size (
    int local_size,
    int comm_size
) 

Parameters:

  • local_size The local size of the vector.
  • color The color of the process in the communicator.
  • comm_size The 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_names The names of the columns (first entry is the title).
  • mean The mean times.
  • min The minimum times.
  • max The 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_times The mean times.
  • min_times The minimum times.
  • max_times The maximum times.
  • mean_times_f The mean times for the forward FFT.
  • min_times_f The minimum times for the forward FFT.
  • max_times_f The maximum times for the forward FFT.
  • mean_times_fs The mean times for the forward FFT in TOSI format.
  • min_times_fs The minimum times for the forward FFT in TOSI format.
  • max_times_fs The maximum times for the forward FFT in TOSI format.
  • times_len The number of timing segments.

function print_times

Print the times for the different parts of the code.

void Utils::print_times (
    int reps=1,
    bool table=true
) 

Parameters:

  • reps The number of repetitions of the code.
  • table Flag indicating whether to print the times in a table or print raw values.

function print_vec

Prints the elements of a vector.

void Utils::print_vec (
    double * vec,
    int len,
    int block_size,
    std::string name="Vector"
) 

This function prints the elements of a vector to the console.

Parameters:

  • vec Pointer to the vector.
  • len The length of the vector.
  • block_size The 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:

  • vec The ComplexD vector to be printed.
  • len The length of the vector.
  • block_size The size of the unpadded vector.
  • name The 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:

  • 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").

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:

  • p The precision of the input and output matrices.
  • d_mat Pointer to the input matrix.
  • d_vec_in Pointer to the input vector.
  • d_vec_out Pointer to the output vector.
  • num_rows The number of rows in the matrix.
  • num_cols The number of columns in the matrix.
  • block_size Batch count.
  • conjugate Flag indicating whether to conjugate transpose the matrix.
  • handle The 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:

  • p The precision of the input and output matrices.
  • d_in Pointer to the input matrix.
  • d_out Pointer to the output matrix.
  • num_cols The number of block columns in the matrix.
  • num_rows The number of block rows in the matrix.
  • padded_size The size of each block. Note: this is used inside the matvec setup function, so it is called with Nt + 1 and not 2 * Nt.
  • s The 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:

  • p The precision of the input and output matrices.
  • d_in Pointer to the input matrix.
  • d_out Pointer to the output matrix.
  • dim_ctgs The contiguous dimension of the input matrix.
  • dim_strd The strided dimension of the input matrix.
  • handle The cuBLAS handle to use for the operation.
  • s The CUDA stream to use for the operation (optional).

function zero_pad

Zero pad a number to a given width (returns a string).

std::string Utils::zero_pad (
    size_t num,
    size_t width
) 

Parameters:

  • num The number to pad.
  • width The 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