SpECTRE  v2024.09.29
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
sys Namespace Reference

Utilities for hardware and system interop. More...

Enumerations

enum class  PrefetchTo : int {
  L1Cache = 3 , L2Cache = 2 , L3Cache = 1 , NonTemporal = 0 ,
  WriteL1Cache = 7 , WriteL2Cache = 6
}
 The cache location to prefetch data to. More...
 

Functions

void abort (const std::string &message)
 Abort the program with an error message. More...
 
void attach_debugger ()
 Provide an infinite loop to attach a debugger during startup. Useful for debugging MPI runs. More...
 
void exit (int exit_code=0)
 Exit the program normally. This should only be called once over all processors.
 
int number_of_procs ()
 Number of processing elements.
 
int my_proc ()
 Index of my processing element.
 
int number_of_nodes ()
 Number of nodes.
 
int my_node ()
 Index of my node.
 
int procs_on_node (int node_index)
 Number of processing elements on the given node.
 
int my_local_rank ()
 The local index of my processing element on my node. This is in the interval 0, ..., procs_on_node(my_node()) - 1.
 
int first_proc_on_node (int node_index)
 Index of first processing element on the given node.
 
int node_of (int proc_index)
 Index of the node for the given processing element.
 
int local_rank_of (int proc_index)
 The local index for the given processing element on its node.
 
double wall_time ()
 The elapsed wall time in seconds.
 
template<PrefetchTo CacheLocation>
void prefetch (const void *address_to_prefetch)
 Prefetch data into a specific level of data cache.
 
std::ostreamoperator<< (std::ostream &os, PrefetchTo cache_location)
 
std::string pretty_wall_time (double total_seconds)
 Format the wall time in DD-HH:MM:SS format. More...
 
std::string pretty_wall_time ()
 Format the wall time in DD-HH:MM:SS format. More...
 

Detailed Description

Utilities for hardware and system interop.

Enumeration Type Documentation

◆ PrefetchTo

enum class sys::PrefetchTo : int
strong

The cache location to prefetch data to.

Enumerator
L1Cache 

Prefetch into L1 data cache.

Typically the fastest CPU cache, about 32 KB in size.

L2Cache 

Prefetch into L2 data cache.

Typically the second fastest CPU cache, about 128 or 256 KB in size.

L3Cache 

Prefetch into L3 data cache.

Typically the slowest CPU cache and is shared among multiple cores with sizes varying by factors of several.

NonTemporal 

Non-temporal is an element that is unlikely to be re-used. E.g., read once, written but never read.

WriteL1Cache 

Prefetch to L1 data cache for writing.

WriteL2Cache 

Prefetch to L2 data cache for writing.

Function Documentation

◆ attach_debugger()

void sys::attach_debugger ( )

Provide an infinite loop to attach a debugger during startup. Useful for debugging MPI runs.

Each MPI rank writes a file name spectre_pid_#_host_NAME to the working directory. This allows you to attach GDB to the running process using gdb --pid=PID, once for each MPI rank. You must then halt the program using C-c and then call set var i = 7 inside GDB. Once you've done this on each MPI rank, you can have each MPI rank continue.

To add support for attaching to a debugger in an executable, you must add sys::attach_debugger to the Parallel::charmxx::register_init_node_and_proc init node functions. Then, when you launch the executable launch it as

SPECTRE_ATTACH_DEBUGGER=1 mpirun -np N ...

The environment variable SPECTRE_ATTACH_DEBUGGER being set tells the code to allow attaching from a debugger.