Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes | Enumerations | Functions | Variables
shamcomm Namespace Reference

namespace for communication related stuff More...

Classes

class  CommunicationBuffer
 Shamrock communication buffers. More...
 

Enumerations

enum  CommunicationProtocol { CopyToHost , DirectGPU }
 
enum  StateMPI_Aware {
  Unknown , Yes , No , ForcedYes ,
  ForcedNo
}
 Enum to describe the MPI capabilities. More...
 

Functions

void validate_comm (std::shared_ptr< sham::DeviceScheduler > &sched)
 
CommunicationProtocol get_protocol (sham::Device &device)
 
bool validate_comm_internal (std::shared_ptr< sham::DeviceScheduler > &device_sched)
 
void open_reset_file (MPI_File &fh, const std::string &fname)
 Open a MPI file and remove its content.
 
void open_read_only_file (MPI_File &fh, const std::string &fname)
 Open a mpi file in read only mode.
 
std::optional< u32node_local_rank ()
 
bool is_main_node_rank (u32 main_local_rank_id=0)
 
void check_mpi_return (int ret, const char *log)
 Check a MPI return code.
 
bool is_direct_comm_aware (const StateMPI_Aware &v)
 
StateMPI_Aware get_mpi_cuda_aware_status ()
 Get the MPI CUDA aware capability.
 
StateMPI_Aware get_mpi_rocm_aware_status ()
 Get the MPI ROCM aware capability.
 
std::optional< StateMPI_Awareshould_force_dgpu_state ()
 Should DGPU should be forced.
 
void fetch_mpi_capabilities (std::optional< StateMPI_Aware > forced_state)
 Fetch the MPI capabilities.
 
void print_mpi_capabilities ()
 Print the MPI capabilities.
 
void print_mpi_comm_info ()
 Print the MPI communicator infos.
 
std::string get_process_name ()
 Get the process name.
 
i32 world_rank ()
 Gives the rank of the current process in the MPI communicator.
 
i32 world_size ()
 Gives the size of the MPI communicator.
 
i32 mpi_max_tag_value ()
 Gets the maximum value of the MPI tag.
 
std::string mpi_process_name ()
 Gets the name of the MPI process.
 
void fetch_world_info ()
 Gets the information about the MPI communicator.
 
bool is_mpi_initialized ()
 Check if MPI is initialized.
 
 __attribute__ ((no_sanitize_address)) void fetch_mpi_process_name()
 
void set_callstack_process_identifier ()
 

Variables

const std::optional< std::string > MV2_COMM_WORLD_LOCAL_RANK = shamcmdopt::getenv_str("MV2_COMM_WORLD_LOCAL_RANK")
 
const std::optional< std::string > OMPI_COMM_WORLD_LOCAL_RANK = shamcmdopt::getenv_str("OMPI_COMM_WORLD_LOCAL_RANK")
 
const std::optional< std::string > MPI_LOCALRANKID = shamcmdopt::getenv_str("MPI_LOCALRANKID")
 
const std::optional< std::string > SLURM_PROCID = shamcmdopt::getenv_str("SLURM_PROCID")
 
const std::optional< std::string > LOCAL_RANK = shamcmdopt::getenv_str("LOCAL_RANK")
 
const std::optional< std::string > PALS_LOCAL_RANKID = shamcmdopt::getenv_str("PALS_LOCAL_RANKID")
 
const std::optional< std::string > PSM2_CUDA = shamcmdopt::getenv_str("PSM2_CUDA")
 
StateMPI_Aware mpi_cuda_aware = StateMPI_Aware::Unknown
 MPI CUDA aware capability.
 
StateMPI_Aware mpi_rocm_aware = StateMPI_Aware::Unknown
 MPI ROCm aware capability.
 
bool fetched = false
 Has the MPI capabilities been fetched?
 
std::optional< StateMPI_Aware_forced_state
 
i32 _world_rank
 
i32 _world_size
 
std::optional< i32_max_tag = std::nullopt
 
std::string _mpi_process_name
 

Detailed Description

namespace for communication related stuff

Enumeration Type Documentation

◆ CommunicationProtocol

Enumerator
CopyToHost 

copy data to the host and then perform the call

DirectGPU 

copy data straight from the GPU

Definition at line 28 of file CommunicationBufferImpl.hpp.

◆ StateMPI_Aware

Enum to describe the MPI capabilities.

Enumerator
Unknown 

The MPI implementation does not if the feature is supported.

Yes 

The MPI implementation supports the feature.

No 

The MPI implementation does not support the feature.

ForcedYes 

Feature forced on by the user.

ForcedNo 

Feature forced off by the user.

Definition at line 28 of file mpiInfo.hpp.

Function Documentation

◆ __attribute__()

shamcomm::__attribute__ ( (no_sanitize_address)  )

Definition at line 44 of file worldInfo.cpp.

◆ check_mpi_return()

void shamcomm::check_mpi_return ( int  ret,
const char *  log 
)

Check a MPI return code.

This function checks the return code of an MPI call and aborts the program if an error occured. The function prints an error message indicating where the error occured (using the provided log string)

Parameters
retThe MPI return code to check
logA string indicating where the error occured

Definition at line 21 of file mpiErrorCheck.cpp.

◆ fetch_mpi_capabilities()

void shamcomm::fetch_mpi_capabilities ( std::optional< StateMPI_Aware forced_state)

Fetch the MPI capabilities.

This function fetches the MPI capabilities of the current process.

Parameters
forced_stateForce the MPI CUDA & ROCM aware capability to be reported as ForcedOn

Definition at line 70 of file mpiInfo.cpp.

◆ fetch_world_info()

void shamcomm::fetch_world_info ( )

Gets the information about the MPI communicator.

This function queries the MPI communicator size and rank. It should be called once in the program.

Definition at line 64 of file worldInfo.cpp.

+ Here is the call graph for this function:

◆ get_mpi_cuda_aware_status()

StateMPI_Aware shamcomm::get_mpi_cuda_aware_status ( )

Get the MPI CUDA aware capability.

This function returns the MPI CUDA aware capability of the current process. If the capability has not been fetched yet, it raises a std::runtime_error

Returns
The MPI CUDA aware capability

Definition at line 52 of file mpiInfo.cpp.

+ Here is the call graph for this function:

◆ get_mpi_rocm_aware_status()

StateMPI_Aware shamcomm::get_mpi_rocm_aware_status ( )

Get the MPI ROCM aware capability.

This function returns the MPI ROCM aware capability of the current process. If the capability has not been fetched yet, it raises a std::runtime_error

Returns
The MPI ROCM aware capability

Definition at line 60 of file mpiInfo.cpp.

+ Here is the call graph for this function:

◆ get_process_name()

std::string shamcomm::get_process_name ( )

Get the process name.

Returns
std::string the process name

Definition at line 147 of file mpiInfo.cpp.

+ Here is the call graph for this function:

◆ get_protocol()

CommunicationProtocol shamcomm::get_protocol ( sham::Device device)
inline

Definition at line 41 of file CommunicationBufferImpl.hpp.

◆ is_direct_comm_aware()

bool shamcomm::is_direct_comm_aware ( const StateMPI_Aware v)
inline

Definition at line 51 of file mpiInfo.hpp.

◆ is_main_node_rank()

bool shamcomm::is_main_node_rank ( u32  main_local_rank_id = 0)

Definition at line 51 of file local_rank.cpp.

◆ is_mpi_initialized()

bool shamcomm::is_mpi_initialized ( )

Check if MPI is initialized.

This function returns true if MPI has been initialized, false otherwise.

Returns
true if MPI is initialized, false otherwise

Definition at line 89 of file worldInfo.cpp.

◆ mpi_max_tag_value()

i32 shamcomm::mpi_max_tag_value ( )

Gets the maximum value of the MPI tag.

Returns
the maximum value of the MPI tag

Definition at line 36 of file worldInfo.cpp.

+ Here is the call graph for this function:

◆ mpi_process_name()

std::string shamcomm::mpi_process_name ( )

Gets the name of the MPI process.

Returns
the name of the MPI process

Definition at line 42 of file worldInfo.cpp.

◆ node_local_rank()

std::optional< u32 > shamcomm::node_local_rank ( )

Definition at line 22 of file local_rank.cpp.

◆ open_read_only_file()

void shamcomm::open_read_only_file ( MPI_File &  fh,
const std::string &  fname 
)

Open a mpi file in read only mode.

Definition at line 52 of file io.cpp.

◆ open_reset_file()

void shamcomm::open_reset_file ( MPI_File &  fh,
const std::string &  fname 
)

Open a MPI file and remove its content.

This function opens the MPI file fname with write-exclusive permission and remove its content if the file already exists.

Parameters
[out]fhThe MPI file handle to open
fnameThe name of the file to open

Definition at line 24 of file io.cpp.

+ Here is the call graph for this function:

◆ print_mpi_capabilities()

void shamcomm::print_mpi_capabilities ( )

Print the MPI capabilities.

Definition at line 115 of file mpiInfo.cpp.

+ Here is the call graph for this function:

◆ print_mpi_comm_info()

void shamcomm::print_mpi_comm_info ( )

Print the MPI communicator infos.

Definition at line 142 of file mpiInfo.cpp.

+ Here is the call graph for this function:

◆ set_callstack_process_identifier()

void shamcomm::set_callstack_process_identifier ( )

Definition at line 53 of file worldInfo.cpp.

◆ should_force_dgpu_state()

std::optional< StateMPI_Aware > shamcomm::should_force_dgpu_state ( )

Should DGPU should be forced.

Definition at line 113 of file mpiInfo.cpp.

◆ validate_comm()

void shamcomm::validate_comm ( std::shared_ptr< sham::DeviceScheduler > &  sched)

Definition at line 91 of file CommunicationBuffer.cpp.

◆ validate_comm_internal()

bool shamcomm::validate_comm_internal ( std::shared_ptr< sham::DeviceScheduler > &  device_sched)

Definition at line 26 of file CommunicationBuffer.cpp.

◆ world_rank()

i32 shamcomm::world_rank ( )

Gives the rank of the current process in the MPI communicator.

Returns
the rank of the current process in the MPI communicator

Definition at line 40 of file worldInfo.cpp.

◆ world_size()

i32 shamcomm::world_size ( )

Gives the size of the MPI communicator.

Returns
the size of the MPI communicator

Definition at line 38 of file worldInfo.cpp.

Variable Documentation

◆ _forced_state

std::optional<StateMPI_Aware> shamcomm::_forced_state

Definition at line 68 of file mpiInfo.cpp.

◆ _max_tag

std::optional<i32> shamcomm::_max_tag = std::nullopt

Definition at line 32 of file worldInfo.cpp.

◆ _mpi_process_name

std::string shamcomm::_mpi_process_name

Definition at line 34 of file worldInfo.cpp.

◆ _world_rank

i32 shamcomm::_world_rank

Definition at line 28 of file worldInfo.cpp.

◆ _world_size

i32 shamcomm::_world_size

Definition at line 30 of file worldInfo.cpp.

◆ fetched

bool shamcomm::fetched = false

Has the MPI capabilities been fetched?

This variable is set to true once the fetch_mpi_capabilities function has been called.

Definition at line 50 of file mpiInfo.cpp.

◆ LOCAL_RANK

const std::optional<std::string> shamcomm::LOCAL_RANK = shamcmdopt::getenv_str("LOCAL_RANK")

Definition at line 31 of file env_variables.hpp.

◆ mpi_cuda_aware

StateMPI_Aware shamcomm::mpi_cuda_aware = StateMPI_Aware::Unknown

MPI CUDA aware capability.

This variable contains the MPI CUDA aware capability of the current process. It is set to Unknown at the beginning and is updated by the fetch_mpi_capabilities function.

Definition at line 33 of file mpiInfo.cpp.

◆ MPI_LOCALRANKID

const std::optional<std::string> shamcomm::MPI_LOCALRANKID = shamcmdopt::getenv_str("MPI_LOCALRANKID")

Definition at line 29 of file env_variables.hpp.

◆ mpi_rocm_aware

StateMPI_Aware shamcomm::mpi_rocm_aware = StateMPI_Aware::Unknown

MPI ROCm aware capability.

This variable contains the MPI ROCm aware capability of the current process. It is set to Unknown at the beginning and is updated by the fetch_mpi_capabilities function.

Definition at line 42 of file mpiInfo.cpp.

◆ MV2_COMM_WORLD_LOCAL_RANK

const std::optional<std::string> shamcomm::MV2_COMM_WORLD_LOCAL_RANK = shamcmdopt::getenv_str("MV2_COMM_WORLD_LOCAL_RANK")

Definition at line 25 of file env_variables.hpp.

◆ OMPI_COMM_WORLD_LOCAL_RANK

const std::optional<std::string> shamcomm::OMPI_COMM_WORLD_LOCAL_RANK = shamcmdopt::getenv_str("OMPI_COMM_WORLD_LOCAL_RANK")

Definition at line 27 of file env_variables.hpp.

◆ PALS_LOCAL_RANKID

const std::optional<std::string> shamcomm::PALS_LOCAL_RANKID = shamcmdopt::getenv_str("PALS_LOCAL_RANKID")

Definition at line 32 of file env_variables.hpp.

◆ PSM2_CUDA

const std::optional<std::string> shamcomm::PSM2_CUDA = shamcmdopt::getenv_str("PSM2_CUDA")

Definition at line 35 of file env_variables.hpp.

◆ SLURM_PROCID

const std::optional<std::string> shamcomm::SLURM_PROCID = shamcmdopt::getenv_str("SLURM_PROCID")

Definition at line 30 of file env_variables.hpp.