HILA
|
Implement hila::swap for gauge fields. More...
Namespaces | |
namespace | linalg |
Inversed diagnal + const. matrix using Sherman-Morrison formula. | |
Classes | |
struct | base_type_struct |
struct | contains_type |
class | global |
Global variable class within hila namespace. More... | |
class | has_assign_zero |
hila::has_assign_zero<T>::value returns true if '= 0 is defined for T More... | |
class | has_unary_minus |
Conditionally reture bool type false if type T does't have unary - operator. More... | |
struct | inner_type_struct |
class | input |
hila::input - Class for parsing runtime parameter files. More... | |
struct | is_arithmetic |
struct | is_avx_vector |
struct | is_complex_or_arithmetic |
hila::is_complex_or_arithmetic<T>::value More... | |
struct | is_field_class_type |
struct | is_field_type |
struct | is_std_array |
struct | is_vectorizable_type |
is_vectorizable_type<T>::value is always false if the target is not vectorizable More... | |
class | k_binning |
class | timer |
struct | timer_value |
This file defines timer class and other timing related utilities. More... | |
struct | vector_info |
Typedefs | |
template<typename A , typename B > | |
using | type_plus = decltype(std::declval< A >()+std::declval< B >()) |
Enumerations | |
enum class | bc |
list of field boundary conditions - used only if SPECIAL_BOUNDARY_CONDITIONS defined | |
Functions | |
template<int n, int m, typename T > | |
std::string | to_string (const Array< n, m, T > &A, int prec=8, char separator=' ') |
Converts Array object to string. | |
template<typename T > | |
std::string | to_string (const Complex< T > &A, int prec=8, char separator=' ') |
Return Complex number as std::string. | |
template<typename T > | |
std::string | prettyprint (const Complex< T > &A, int prec=8) |
Return well formatted Complex number as std::string. | |
template<int n, int m, typename T , typename MT > | |
std::string | to_string (const Matrix_t< n, m, T, MT > &A, int prec=8, char separator=' ') |
Converts Matrix_t object to string. | |
template<int n, int m, typename T , typename MT > | |
std::string | prettyprint (const Matrix_t< n, m, T, MT > &A, int prec=8) |
Formats Matrix_t object in a human readable way. | |
void | free_device_rng () |
Free GPU RNG state, does nothing on non-GPU archs. | |
template<typename T > | |
T | broadcast (T &var, int rank=0) |
Broadcast the value of var to all MPI ranks from rank (default=0). | |
template<typename T > | |
T | broadcast (const T &var, int rank=0) |
Version of broadcast with non-modifiable var. | |
template<typename T > | |
void | broadcast (std::vector< T > &list, int rank=0) |
Broadcast for std::vector. | |
template<typename T , int n> | |
void | broadcast (std::array< T, n > &arr, int rank=0) |
And broadcast for std::array. | |
template<typename T > | |
void | broadcast (T *var, int rank=0) |
Bare pointers cannot be broadcast. | |
template<typename T > | |
void | broadcast_array (T *var, int n, int rank=0) |
Broadcast for arrays where size must be known and same for all nodes. | |
template<typename T , typename U > | |
void | broadcast2 (T &t, U &u, int rank=0) |
and broadcast with two values | |
template<typename T > | |
void | reduce_node_sum (T *value, int send_count, bool allreduce=true) |
Reduce an array across nodes. | |
template<typename T > | |
T | reduce_node_sum (T &var, bool allreduce=true) |
void | set_allreduce (bool on=true) |
set allreduce on (default) or off on the next reduction | |
void | initialize (int argc, char **argv) |
Read in command line arguments. Initialise default stream and MPI communication. | |
void | finishrun () |
Normal, controlled exit - all nodes must call this. Prints timing information and information about communications. | |
void | terminate (int status) |
void | error (const char *msg) |
Print message and force quit. | |
int | myrank () |
rank of this node | |
int | number_of_nodes () |
how many nodes there are | |
void | synchronize () |
synchronize mpi | |
template<typename T > | |
void | swap (Field< T > &A, Field< T > &B) |
Implement hila::swap() for Fields too, equivalent to std::swap() | |
bool | bc_need_communication (hila::bc bc) |
False if we have b.c. which does not require communication. | |
uint64_t | shuffle_rng_seed (uint64_t seed) |
Random shuffling of rng seed for MPI nodes. | |
void | initialize_host_rng (uint64_t seed) |
Initialize host (CPU) random number generator separately, done implicitly by seed_random() | |
void | seed_random (uint64_t seed, bool device_rng=true) |
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ranks are seeded with different values. | |
bool | is_rng_seeded () |
Check if RNG is seeded already. | |
void | initialize_device_rng (uint64_t seed) |
Initialize device random number generator on GPUs, if application run on GPU platform. No effect on other archs. | |
bool | is_device_rng_on () |
Check if the RNG on GPU is allocated and ready to use. | |
double | random () |
Real valued uniform random number generator. | |
double | gaussrand () |
Gaussian random generation routine. | |
double | gaussrand2 (double &out2) |
hila::gaussrand2 returns 2 Gaussian distributed random numbers with variance \(1.0\). | |
void | check_that_rng_is_initialized () |
Check if RNG is initialized, do what the name says. | |
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0> | |
T | random (out_only T &val) |
Template function const T & hila::random(T & var) sets the argument to a random value, and return a constant reference to it. | |
template<typename T > | |
T | random () |
Template function T hila::random<T>() without argument. | |
template<typename T , std::enable_if_t< std::is_arithmetic< T >::value, int > = 0> | |
T | gaussian_random (out_only T &val, double w=1.0) |
Template function const T & hila::gaussian_random(T & variable,double width=1) | |
template<typename T > | |
T | gaussian_random () |
Template function T hila::gaussian_random<T>() ,generates gaussian random value of type T , with variance \(1\). | |
template<typename T , std::enable_if_t< hila::is_arithmetic< T >::value, int > = 0> | |
std::string | to_string (const T v, int prec=8, char separator=' ') |
convert to string: separator does nothing, but for compatibility w. other to_strings | |
template<typename T , std::enable_if_t< hila::is_std_array< T >::value||hila::is_std_vector< T >::value, int > = 0> | |
void | shuffle (T &arr) |
auto | shuffle_directions_and_parities () |
auto | shuffle_directions () |
double | gettime () |
template<typename T > | |
hila::arithmetic_type< T > | get_number_in_var (const T &var, int i) |
Variables | |
std::ostream | out |
this is our default output file stream | |
std::ostream | out0 |
This writes output only from main process (node 0) | |
std::ofstream | output_file |
this is just a hook to store output file, if it is in use | |
logger_class | log |
Now declare the logger. | |
std::vector< timer * > | timer_list = {} |
Timer routines - for high-resolution event timing. | |
Implement hila::swap for gauge fields.
Namespace hila
contains most of class templates
and function templates
, which are necessary to run lattice filed simulations on distributed memory system as well as on GPU nodes concurrently.
using hila::type_plus = typedef decltype(std::declval<A>() + std::declval<B>()) |
Helper operations to make generic templates for arithmetic operators e.g. hila::type_plus<A,B> gives the type of the operator a + b, where a is of type A and b type B.
Definition at line 103 of file type_tools.h.
T hila::broadcast | ( | T & | var, |
int | rank = 0 |
||
) |
Broadcast the value of var to all MPI ranks from rank (default=0).
NOTE: the function must be called by all MPI ranks, otherwise the program will deadlock.
The type of the variable var can be any standard plain datatype (trivial type), std::string, std::vector or std::array
For trivial types, the input var can be non-modifiable value. In this case the broadcast value is obtained from the broadcast return value.
Example:
var | variable to be synchronized across the full |
rank | MPI rank from which the |
void hila::check_that_rng_is_initialized | ( | ) |
Check if RNG is initialized, do what the name says.
program quits with error message if RNG is not initialized. It also quit with error messages if the device RNG is not initialized.
Definition at line 256 of file random.cpp.
T hila::gaussian_random | ( | ) |
Template function T hila::gaussian_random<T>()
,generates gaussian random value of type T
, with variance \(1\).
For example,
calculates the norm of a gaussian random complex value.
hila::gaussian_random(value)
T hila::gaussian_random | ( | out_only T & | val, |
double | w = 1.0 |
||
) |
Template function const T & hila::gaussian_random(T & variable,double width=1)
Sets the argument to a gaussian random value, and return a constant reference to it. Optional second argument width sets the \(variance=width^{2}\) ( \(default==1\))
For example:
sets the variable c
to complex gaussian random value and stores its square in n
.
This function is for hila classes relies on the existence of method T::gaussian_random()
. The advantage for this function over class function T::random()
is that the argument can be of elementary arithmetic type.
double hila::gaussrand2 | ( | double & | out2 | ) |
hila::gaussrand2
returns 2 Gaussian distributed random numbers with variance \(1.0\).
Useful because Box-Muller algorithm computes 2 values at the same time.
Definition at line 181 of file random.cpp.
|
inline |
Access variables as if arrays of scalar_type numbers
Definition at line 118 of file type_tools.h.
double hila::gettime | ( | ) |
Use clock_gettime() to get the accurate time (alternative: use gettimeofday() or MPI_Wtime()) gettime returns the time in secs since program start
Definition at line 163 of file timing.cpp.
void hila::initialize | ( | int | argc, |
char ** | argv | ||
) |
Read in command line arguments. Initialise default stream and MPI communication.
argc | Number of command line arguments |
argv | List of command line arguments |
Definition at line 66 of file initialize.cpp.
void hila::initialize_host_rng | ( | uint64_t | seed | ) |
Initialize host (CPU) random number generator separately, done implicitly by seed_random()
seed | unsigned int_64 |
Definition at line 61 of file random.cpp.
bool hila::is_rng_seeded | ( | ) |
int hila::myrank | ( | ) |
rank of this node
Return my node number - take care to return the previous node number if mpi is being torn down (used in destructors)
Definition at line 234 of file com_mpi.cpp.
int hila::number_of_nodes | ( | ) |
how many nodes there are
Return number of nodes or "pseudo-nodes".
Definition at line 245 of file com_mpi.cpp.
std::string hila::prettyprint | ( | const Complex< T > & | A, |
int | prec = 8 |
||
) |
std::string hila::prettyprint | ( | const Matrix_t< n, m, T, MT > & | A, |
int | prec = 8 |
||
) |
Formats Matrix_t object in a human readable way.
Example 2 x 3 matrix is the following
__device__ __host__ double hila::random | ( | ) |
Real valued uniform random number generator.
Returns an uniform double precision random number in interval \([0,1)\).
This function can be called from outside or inside site loops (on GPU if the device rng is initialized).
Uses std::uniform_real_distribution
Definition at line 121 of file hila_gpu.cpp.
T hila::random | ( | ) |
Template function T hila::random<T>()
without argument.
This is used to generate random value for type T
without defined variable. Example:
calculates the norm of a random complex value. hila::random<double>()
is functionally equivalent to hila::random()
T hila::random | ( | out_only T & | val | ) |
Template function const T & hila::random(T & var)
sets the argument to a random value, and return a constant reference to it.
For example
sets the variable c
to complex random value and calculates its absolute value. c.real()
and c.imag()
will be \(\in [0,1)\).
For hila classes relies on the existence of method T::random()
(i.e. var.random()
), this function typically sets the argument real numbers to interval \([0,1)\) if type T
is arithmatic. if T is more commplicated classes such as SU<N,T>
-matrix, this function sets the argument to valid random SU<N,T>
.
Advantage of this function over class function T::random()
is that the argument can be of elementary arithmetic type.
T hila::reduce_node_sum | ( | T & | var, |
bool | allreduce = true |
||
) |
void hila::seed_random | ( | uint64_t | seed, |
bool | device_init = true |
||
) |
Seed random generators with 64-bit unsigned value. On MPI shuffles the seed so that different MPI ranks are seeded with different values.
The optional 2nd argument indicates whether to initialize the RNG on GPU device: hila::device_rng_on
(default) or hila::device_rng_off
. This argument does nothing if no GPU platform. If hila::device_rng_off
is used, onsites()
-loops cannot contain random number calls (Runtime error will be flagged and program exits).
Seed is shuffled so that different nodes get different rng seeds. If seed == 0
, seed is generated through using the time()
-function.
Definition at line 86 of file random.cpp.
void hila::shuffle | ( | T & | arr | ) |
|
inline |
Shuffling directions and parities separately with functions
std::array<Direction,NDIM> hila::shuffle_directions() std::array<Parity,2> hila::shuffle_parities()
Thus, (almost) the same operation as above with shuffle_directions_and_parities() can be done with
for (const Direction d : hila::shuffle_directions()) { for (const Parity p : hila::shuffle_parities()) { update_parity_dir(U, p, d); } }
This does more MPI synchronization than the shuffle_directions_and_parities()
|
inline |
Function returning all directions and parities as shuffled to random order. Return type is std::array<dir_and_parity,2*NDIM>,
Use case is in Gauge heatbath/overrelax updates, to randomize order. Synchronizes with all MPI nodes, i.e. all ranks will have the same content. Function marked inline in order to avoid ODR
Typical use: no need to declare std::array
for (const auto & s : hila::shuffle_directions_and_parities()) { update_parity_dir(U, s.parity, s.direction); }
Can also be assigned, i.e. auto shuffled = hila::shuffle_directions_and_parities();
uint64_t hila::shuffle_rng_seed | ( | uint64_t | seed | ) |
Random shuffling of rng seed for MPI nodes.
Do it in a manner makes it difficult to give the same seed by mistake and also avoids giving the same seed for 2 nodes For single MPI node seed remains unchanged
Definition at line 47 of file random.cpp.
void hila::terminate | ( | int | status | ) |
Force quit for multinode processes – kill all nodes No synchronisation done
Definition at line 293 of file initialize.cpp.
std::string hila::to_string | ( | const Array< n, m, T > & | A, |
int | prec = 8 , |
||
char | separator = ' ' |
||
) |
std::string hila::to_string | ( | const Complex< T > & | A, |
int | prec = 8 , |
||
char | separator = ' ' |
||
) |
std::string hila::to_string | ( | const Matrix_t< n, m, T, MT > & | A, |
int | prec = 8 , |
||
char | separator = ' ' |
||
) |