tk namespace

Toolkit declarations and definitions for general purpose utilities.

Namespaces

namespace ctr
Toolkit control, general purpose user input to internal data transfer.
namespace grm
Toolkit general purpose grammar definition.
namespace mkl
Toolkit, grammar definition for Intel's Math Kernel Library.
namespace random123
Toolkit, grammar definition for the Random123 library.
namespace rngsse
Toolkit, grammar definition for the RNGSSE library.

Classes

class ChareStateCollector
template<uint8_t Layout>
class Data
Zero-runtime-cost data-layout wrappers with type-based compile-time dispatch.
class Exception
Basic exception class for producing file:func:line info + call trace.
template<typename, typename = std::void_t<>>
struct HasTypedef_alias
Detect if a type defines type 'alias'.
template<typename, typename = std::void_t<>>
struct HasTypedef_code
Detect if a type defines type 'code'.
template<typename, typename = std::void_t<>>
struct HasTypedef_i_am_tagged_tuple
Detect if a type defines type 'i_am_tagged_tuple'.
template<typename, typename = std::void_t<>>
struct HasFunction_expect_description
Detect if a type defines function 'expect::description()'.
template<typename, typename = std::void_t<>>
struct HasVar_expect_lower
Detect if a type defines variable 'expect::lower'.
template<typename, typename = std::void_t<>>
struct HasVar_expect_upper
Detect if a type defines variable 'expect::upper'.
template<typename, typename = std::void_t<>>
struct HasFunction_expect_choices
Detect if a type defines function 'expect::choices()'.
template<bool Condition, typename Then, typename Else = void>
struct if_
Type selection: if_< Condition, Then, Else >::type.
class Print
template<std::size_t N>
class Progress
class Reader
template<class List>
class TaggedTuple
Tagged tuple, allowing tag-based access.
template<class List, class Ignore = brigand::set<>>
struct DeepTuplePrinter
template<class List, class Ignore = brigand::set<>>
struct TuplePrinter
class Timer
class Writer
class FileParser
FileParser.
template<typename... T>
class cmd_keywords
template<typename... T>
class unique_codes
class StringParser
StringParser.
template<typename Enum>
class Toggle
Toggle is the base for an Option, doing generic searches.
class GmshMeshReader
class GmshMeshWriter
class H5PartWriter
class ParticleWriter
Charm++ group used to output particle data to file in parallel using H5Part and MPI-IO.
class PDFWriter
PDFWriter : Writer.
class TxtStatWriter
TxtStatWriter : tk::Writer.
class LBSwitch
class RNGPrint
RNGPrint : Print.
class MKLRNG
MKL-based random number generator used polymorphically with tk::RNG.
template<class CBRNG>
class Random123
Random123-based random number generator used polymorphically with tk::RNG.
class RNG
Random number generator.
template<class State, typename SeqNumType, unsigned int(*)(State*) Generate>
class RNGSSE
RNGSSE-based random number generator used polymorphically with tk::RNG.
class RNGStack
Random number generator stack.
class BiPDF
Joint bivariate PDF estimator.
class Statistics
Statistics estimator.
class TriPDF
Joint trivariate PDF estimator.
class UniPDF
Univariate PDF estimator.
class QuietCerr

Enums

enum ErrCode { SUCCESS = EXIT_SUCCESS, FAILURE = EXIT_FAILURE }
Error codes for the OS (or whatever calls us)
enum Style { QUIET =0, VERBOSE =1 }
Output verbosity. C-style enum as this is used for template argument.
enum GmshElemType { LIN = 1, TRI = 2, TET = 4, PNT = 15 }
Identifiers of supported Gmsh elements.
enum class GmshFileType { UNDEFINED = -1, ASCII = 0, BINARY = 1 }
Supported Gmsh mesh file types.
enum class HeaderType: uint8_t { INCITER =0, RNGTEST, UNITTEST, MESHCONV, FILECONV, WALKER }
Executable types for which an ascii logo is available in tk::Print.

Typedefs

template<class li, class lo>
using cartesian_product = brigand::reverse_fold<brigand::list<li, lo>, brigand::list<brigand::list<>>, brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::_2, brigand::defer<brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::parent<brigand::_1>, brigand::defer<brigand::bind<brigand::list, brigand::bind<brigand::push_front, brigand::_1, brigand::parent<brigand::_1>>>>>>>>>>
using ChareState = TaggedTuple<brigand::list<tag::ch, std::string, tag::id, int, tag::pe, int, tag::it, uint64_t, tag::fn, std::string, tag::time, tk::real>>
Chare state.
template<std::size_t N>
using Table = std::vector<std::array<real, N+1>>
using real = double
Real number type used throughout the whole code.
using RNGFactory = std::map<ctr::RNGType, std::function<RNG()>>
Random number generator factory: keys associated to their constructors.

Functions

template<class Container>
void unique(Container& c)
template<class Container>
auto uniquecopy(const Container& src) -> Container
template<typename Container>
auto cref_find(const Container& map, const typename Container::key_type& key) -> const typename Container::mapped_type & -> auto
Find and return a constant reference to value for key in container that provides a find() member function with error handling.
template<typename Container>
auto ref_find(const Container& map, const typename Container::key_type& key) -> typename Container::mapped_type & -> auto
Find and return a reference to value for key in a container that provides a find() member function with error handling.
template<typename T>
auto extents(const std::vector<T>& vec) -> std::array<T, 2>
Return minimum and maximum values of a vector.
template<typename Container>
auto extents(const Container& map) -> std::array< typename Container::mapped_type, 2 > -> auto
Find and return minimum and maximum values in associative container.
template<class T, std::size_t N>
auto operator+=(std::array<T, N>& dst, const std::array<T, N>& src) -> std::array<T, N>&
template<class T, class Allocator>
auto operator+=(std::vector<T, Allocator>& dst, const std::vector<T, Allocator>& src) -> std::vector<T, Allocator>&
template<class T, class Allocator>
auto operator/=(std::vector<T, Allocator>& dst, const std::vector<T, Allocator>& src) -> std::vector<T, Allocator>&
template<class C1, class C2>
auto keyEqual(const C1& a, const C2& b) -> bool
template<class Container>
auto sumsize(const Container& c) -> std::size_t
template<class Container>
auto numunique(const Container& c) -> std::size_t
template<class Map>
auto sumvalsize(const Map& c) -> std::size_t
template<class Container>
void destroy(Container& c)
template<typename Container, typename Predicate>
void erase_if(Container& items, const Predicate& predicate)
template<class T>
void concat(std::vector<T>&& src, std::vector<T>& dst)
template<class T>
void concat(std::vector<std::pair<bool, T>>&& src, std::vector<std::pair<bool, T>>& dst)
template<class Key, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
void concat(std::unordered_set<Key, Hash, Eq>&& src, std::unordered_set<Key, Hash, Eq>& dst)
template<class Key, class Value>
auto operator<<(std::ostream& os, const std::pair<const Key, Value>& v) -> std::ostream&
template<typename T>
auto parameter(const T& v) -> std::string
Convert and return value as string.
template<typename V>
auto parameters(const V& v) -> std::string
Convert and return values from container as string.
template<uint8_t Layout>
auto operator*(tk::real lhs, const Data<Layout>& rhs) -> Data<Layout>
template<uint8_t Layout>
auto min(const Data<Layout>& a, const Data<Layout>& b) -> Data<Layout>
template<uint8_t Layout>
auto max(const Data<Layout>& a, const Data<Layout>& b) -> Data<Layout>
template<uint8_t Layout>
auto operator==(const Data<Layout>& lhs, const Data<Layout>& rhs) -> bool
template<uint8_t Layout>
auto operator!=(const Data<Layout>& lhs, const Data<Layout>& rhs) -> bool
template<uint8_t Layout>
auto maxdiff(const Data<Layout>& lhs, const Data<Layout>& rhs) -> std::pair<std::size_t, tk::real>
template<class C, class Key, class Factory, typename... ConstructorArgs>
void record(Factory& f, const Key& key, ConstructorArgs&&... args)
template<class Factory, class Key, class Obj = typename std::remove_pointer< typename Factory::mapped_type::result_type>::type>
auto instantiate(const Factory& f, const Key& key) -> std::unique_ptr<Obj>
template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void recordModel(Factory& f, const Key& key, ModelConstrArgs&&... args)
template<class Host, class ModelConstructor, class Factory, class Key, typename ModelConstrArg>
void recordModelLate(Factory& f, const Key& key, ModelConstrArg)
template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void recordCharmModel(Factory& f, const Key& key, ModelConstrArgs&&... args)
template<typename A, typename B>
auto flip_pair(const std::pair<A, B>& p) -> std::pair<B, A>
template<typename A, typename B>
auto flip_map(const std::map<A, B>& src) -> std::multimap<B, A>
template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
auto serialize(const std::unordered_map<Key, T, Hash, Eq>& m) -> std::pair<int, std::unique_ptr<char[]>>
template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
auto mergeHashMap(int nmsg, CkReductionMsg** msgs) -> CkReductionMsg*
Charm++ custom reducer for merging std::unordered_maps during reduction across PEs.
auto linearLoadDistributor(real virtualization, uint64_t load, int npe, uint64_t& chunksize, uint64_t& remainder) -> uint64_t
Compute linear load distribution for given total work and virtualization.
template<typename Enum, typename Ch, typename Tr, typename std::enable_if_t<std::is_enum_v<Enum>, int> = 0>
auto operator<<(std::basic_ostream<Ch, Tr>& os, const Enum& e) -> std::basic_ostream<Ch, Tr>&
template<class T, typename Ch, typename Tr>
auto operator<<(std::basic_ostream<Ch, Tr>& os, const std::vector<T>& v) -> std::basic_ostream<Ch, Tr>&
template<typename Ch, typename Tr, class Key, class Value, class Compare = std::less<Key>>
auto operator<<(std::basic_ostream<Ch, Tr>& os, const std::map<Key, Value, Compare>& m) -> std::basic_ostream<Ch, Tr>&
template<typename T, typename Ch, typename Tr>
auto operator<<(std::basic_string<Ch, Tr>& lhs, const T& e) -> std::basic_string<Ch, Tr>
template<typename T, typename Ch, typename Tr>
auto operator<<(std::basic_string<Ch, Tr>&& lhs, const T& e) -> std::basic_string<Ch, Tr>
auto splitLines(std::string str, std::string indent, const std::string& name = "", std::size_t width = 80) -> std::string
Clean up whitespaces and format a long string into multiple lines.
auto baselogname(const std::string& executable) -> std::string
auto logname(const std::string& executable, int numrestart = 0) -> std::string
Construct log file name.
void rm(const std::string& file)
Remove file from file system.
void signalHandler(int signum)
Signal handler for multiple signals, SIGABRT, SIGSEGV, etc.
auto setSignalHandlers() -> int
Set signal handlers for multiple signals, SIGABRT, SIGSEGV, etc.
void processExceptionCharm()
Process an exception from the Charm++ runtime system.
template<typename T>
auto swap_endian(T u) -> T
template<>
auto swap_endian(double u) -> double
template<std::size_t N>
auto sample(real x, const Table<N>& table) -> std::array<real, N>
template<class Tuple>
void print(std::ostream& os, const std::string& name, const Tuple& c)
template<class List>
auto operator<<(std::ostream& os, const tk::TaggedTuple<List>& t) -> std::ostream&
template<class List, class Ignore = brigand::set<>>
void print(std::ostream& os, const tk::TaggedTuple<List>& t)
Simple (unformatted, one-line) output of a TaggedTuple to output stream with ignore.
auto hms(tk::real stamp) -> Timer::Watch
Convert existing time stamp as a real to Watch (global scope)
void flip(std::array<real, 3>& v)
void cross(real v1x, real v1y, real v1z, real v2x, real v2y, real v2z, real& rx, real& ry, real& rz)
auto cross(const std::array<real, 3>& v1, const std::array<real, 3>& v2) -> std::array<real, 3>
void crossdiv(real v1x, real v1y, real v1z, real v2x, real v2y, real v2z, real j, real& rx, real& ry, real& rz)
auto crossdiv(const std::array<real, 3>& v1, const std::array<real, 3>& v2, real j) -> std::array<real, 3>
auto dot(const std::array<real, 3>& v1, const std::array<real, 3>& v2) -> real
auto length(real x, real y, real z) -> real
auto length(const std::array<real, 3>& v) -> real
void unit(std::array<real, 3>& v)
auto triple(real v1x, real v1y, real v1z, real v2x, real v2y, real v2z, real v3x, real v3y, real v3z) -> tk::real
auto triple(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3) -> real
auto rotateX(const std::array<real, 3>& v, real angle) -> std::array<real, 3>
auto rotateY(const std::array<real, 3>& v, real angle) -> std::array<real, 3>
auto rotateZ(const std::array<real, 3>& v, real angle) -> std::array<real, 3>
auto Jacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4) -> real
Compute the determinant of the Jacobian of a coordinate transformation over a tetrahedron.
auto inverseJacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4) -> std::array<std::array<real, 3>, 3>
Compute the inverse of the Jacobian of a coordinate transformation over a tetrahedron.
auto determinant(const std::array<std::array<tk::real, 3>, 3>& a) -> tk::real
auto cramer(const std::array<std::array<tk::real, 3>, 3>& a, const std::array<tk::real, 3>& b) -> std::array<tk::real, 3>
static auto workdir() -> std::string
auto curtime() -> std::string
Wrapper for the standard C library's gettimeofday() from.
void echoHeader(const Print& print, HeaderType header)
Echo program header.
void echoBuildEnv(const Print& print, const std::string& executable)
Echo build environment.
void echoRunEnv(const Print& print, int argc, char** argv, bool verbose, bool quiescence, bool charestate, bool trace, const std::string& screen_log, const std::string& input_log)
Echo runtime environment.
template<class Driver, class CmdLine>
auto Main(int argc, char* argv[], const CmdLine& cmdline, HeaderType header, const std::string& executable, const std::string& def, int nrestart) -> Driver
Generic Main() used for all executables for code-reuse and a uniform output.
template<class MainProxy, class CmdLine>
void MainCtor(MainProxy& mp, const MainProxy& thisProxy, std::vector<tk::Timer>& timer, const CmdLine& cmdline, const CkCallback& quiescenceTarget)
template<class CmdLine>
void dumpstate(const CmdLine& cmdline, const std::string& def, int nrestart, CkReductionMsg* msg)
template<class CmdLine>
void finalize(const CmdLine& cmdline, const std::vector<tk::Timer>& timer, tk::CProxy_ChareStateCollector& state, std::vector<std::pair<std::string, tk::Timer::Watch>>& timestamp, const std::string& def, int nrestart, const CkCallback& dumpstateTarget, bool clean = true)
auto serialize(std::size_t meshid, const std::vector<tk::UniPDF>& u) -> std::pair<int, std::unique_ptr<char[]>>
Serialize univariate PDF to raw memory stream.
auto mergeUniPDFs(int nmsg, CkReductionMsg** msgs) -> CkReductionMsg*
Charm++ custom reducer for merging a univariate PDF during reduction across PEs.
auto serialize(const std::vector<tk::UniPDF>& u, const std::vector<tk::BiPDF>& b, const std::vector<tk::TriPDF>& t) -> std::pair<int, std::unique_ptr<char[]>>
Serialize vectors of PDFs to raw memory stream.
auto mergePDF(int nmsg, CkReductionMsg** msgs) -> CkReductionMsg*
Charm++ custom reducer for merging PDFs during reduction across PEs.
static auto operator<<(std::ostream& os, const tk::UniPDF& p) -> std::ostream&

Variables

const uint8_t UnkEqComp
Tags for selecting data layout policies.
static std::stringstream cerr_quiet
std::tringstream used to quiet std::cerr's stream by redirecting to it
static std::streambuf* cerr_old
std::streambuf used to store state of std::cerr before redirecting it

Enum documentation

enum tk::ErrCode

Error codes for the OS (or whatever calls us)

Enumerators
SUCCESS

Everything went fine.

FAILURE

Exceptions occurred.

Typedef documentation

template<class li, class lo>
using tk::cartesian_product = brigand::reverse_fold<brigand::list<li, lo>, brigand::list<brigand::list<>>, brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::_2, brigand::defer<brigand::bind<brigand::join, brigand::bind<brigand::transform, brigand::parent<brigand::_1>, brigand::defer<brigand::bind<brigand::list, brigand::bind<brigand::push_front, brigand::_1, brigand::parent<brigand::_1>>>>>>>>>>

Cartesian product of two brigand lists

template<std::size_t N>
using tk::Table = std::vector<std::array<real, N+1>>

Template parameters
N Number of ordinates in the table

Type alias for storing a discrete (y1,y2,...,yN) = f(x) function

Function documentation

template<class Container>
void tk::unique(Container& c)

Parameters
in/out Container

Make elements of container unique (in-place, overwriting source container)

template<class Container>
Container tk::uniquecopy(const Container& src)

Parameters
src in Container
Returns Container containing only unique elements compared to src

Make elements of container unique (on a copy, leaving the source as is)

template<typename Container>
auto tk::cref_find(const Container& map, const typename Container::key_type& key) -> const typename Container::mapped_type &

Find and return a constant reference to value for key in container that provides a find() member function with error handling.

Parameters
map in Map associating values to keys
key in Key to search for
Returns A constant reference to the value associated to the key in map

template<typename Container>
auto tk::ref_find(const Container& map, const typename Container::key_type& key) -> typename Container::mapped_type &

Find and return a reference to value for key in a container that provides a find() member function with error handling.

Parameters
map in Map associating values to keys
key in Key to search for
Returns A reference to the value associated to the key in map

template<typename T>
std::array<T, 2> tk::extents(const std::vector<T>& vec)

Return minimum and maximum values of a vector.

Parameters
vec in Vector whose extents to compute
Returns Array of two values with the minimum and maximum values

template<typename Container>
auto tk::extents(const Container& map) -> std::array< typename Container::mapped_type, 2 >

Find and return minimum and maximum values in associative container.

Parameters
map in Map whose extents of values to find
Returns Array of two values with the minimum and maximum values in the map

template<class T, std::size_t N>
std::array<T, N>& tk::operator+=(std::array<T, N>& dst, const std::array<T, N>& src)

Parameters
dst in/out Destination array, i.e., left-hand side of a1 += a2
src in Source array, i.e., righ-hand side of a1 += a2
Returns Destination containing a1[0] += a2[0], a1[1] += a2[1], ...

Add all elements of an array to those of another one

template<class T, class Allocator>
std::vector<T, Allocator>& tk::operator+=(std::vector<T, Allocator>& dst, const std::vector<T, Allocator>& src)

Parameters
dst in/out Destination vector, i.e., left-hand side of v1 += v2
src in Source vector, i.e., righ-hand side of v1 += v2
Returns Destination containing v1[0] += v2[0], v1[1] += v2[1], ...

Add all elements of a vector to those of another one If src.size() > dst.size() will grow dst to that of src.size() padding with zeros.

template<class T, class Allocator>
std::vector<T, Allocator>& tk::operator/=(std::vector<T, Allocator>& dst, const std::vector<T, Allocator>& src)

Parameters
dst in/out Destination vector, i.e., left-hand side of v1 /= v2
src in Source vector, i.e., righ-hand side of v1 /= v2
Returns Destination containing v1[0] /= v2[0], v1[1] /= v2[1], ...

Divide all elements of a vector with those of another one If src.size() > dst.size() will grow dst to that of src.size() padding with zeros.

template<class C1, class C2>
bool tk::keyEqual(const C1& a, const C2& b)

Parameters
in 1st container to compare
in 2nd container to compare
Returns True if the containers have the same size and all keys (and only the keys) of the two containers are equal

Test if all keys of two associative containers are equal

template<class Container>
std::size_t tk::sumsize(const Container& c)

Parameters
in Container of containers
Returns Sum of the sizes of the containers of the container

Compute the sum of the sizes of a container of containers

template<class Container>
std::size_t tk::numunique(const Container& c)

Parameters
in Container of containers
Returns Number of unique values in a container of containers

Compute the number of unique values in a container of containers

template<class Map>
std::size_t tk::sumvalsize(const Map& c)

Template parameters
Map Container of containers type
Parameters
in Container of containers
Returns Sum of the sizes of the values of the associative container

Compute the sum of the sizes of the values of an associative container

template<class Container>
void tk::destroy(Container& c)

Parameters
in Container defining a swap() member function

Free memory of a container See http://stackoverflow.com/a/10465032 as to why this is done with the swap() member function of the container.

template<typename Container, typename Predicate>
void tk::erase_if(Container& items, const Predicate& predicate)

Template parameters
Container Type of container to remove from
Predicate Type for functor defining the predicate
Parameters
items Container object to remove from
predicate Predicate object instance to use

Remove items from container based on predicate

template<class T>
void tk::concat(std::vector<T>&& src, std::vector<T>& dst)

Template parameters
T Vector value type
Parameters
src in/out Source vector (moved from)
dst in/out Destination vector

Concatenate vectors of T

template<class T>
void tk::concat(std::vector<std::pair<bool, T>>&& src, std::vector<std::pair<bool, T>>& dst)

Template parameters
T Vector value type
Parameters
src in/out Source vector (moved from)
dst in/out Destination vector

Overwrite vectors of pair< bool, tk::real >

template<class Key, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
void tk::concat(std::unordered_set<Key, Hash, Eq>&& src, std::unordered_set<Key, Hash, Eq>& dst)

Template parameters
Key Set key
Hash Set hasher
Eq Set equality operator
Parameters
src in/out Source set (moved from)
dst in/out Destination set

Concatenate unordered sets

template<class Key, class Value>
std::ostream& tk::operator<<(std::ostream& os, const std::pair<const Key, Value>& v)

Parameters
os in/out Output stream to write to
in value_type entry of a map
Returns Updated output stream

Operator << for writing value_type of a standard map to output streams

template<typename T>
std::string tk::parameter(const T& v)

Convert and return value as string.

Template parameters
T Value type for input
Parameters
in Value for input to return as a string
Returns String for input value

template<typename V>
std::string tk::parameters(const V& v)

Convert and return values from container as string.

Template parameters
V Container range for works on
Parameters
in Container whose components to return as a string
Returns Concatenated string of values read from a container

template<uint8_t Layout>
Data<Layout> tk::operator*(tk::real lhs, const Data<Layout>& rhs)

Parameters
lhs in Scalar to multiply with
rhs in Date object to multiply
Returns New Data object with all items multipled with lhs

Operator * multiplying all items by a scalar from the left

template<uint8_t Layout>
Data<Layout> tk::min(const Data<Layout>& a, const Data<Layout>& b)

Parameters
in 1st Data object
in 2nd Data object
Returns New Data object containing the minimum of all values for each value in a and b

Operator min between two Data objects

template<uint8_t Layout>
Data<Layout> tk::max(const Data<Layout>& a, const Data<Layout>& b)

Parameters
in 1st Data object
in 2nd Data object
Returns New Data object containing the maximum of all values for each value in a and b

Operator max between two Data objects

template<uint8_t Layout>
bool tk::operator==(const Data<Layout>& lhs, const Data<Layout>& rhs)

Parameters
lhs in Data object to compare
rhs in Data object to compare
Returns True if all entries are equal up to epsilon

Operator == between two Data objects

template<uint8_t Layout>
bool tk::operator!=(const Data<Layout>& lhs, const Data<Layout>& rhs)

Parameters
lhs in Data object to compare
rhs in Data object to compare
Returns True if all entries are unequal up to epsilon

Operator != between two Data objects

template<uint8_t Layout>
std::pair<std::size_t, tk::real> tk::maxdiff(const Data<Layout>& lhs, const Data<Layout>& rhs)

Parameters
lhs in 1st Data object
rhs in 2nd Data object
Returns The index, i.e., the raw position, of and the largest absolute value of the difference between all corresponding elements of lhs and rhs.

Compute the maximum difference between the elements of two Data objects The position returned is the position in the underlying raw data structure, independent of components, offsets, etc. If lhs == rhs with precision std::numeric_limits< tk::real >::epsilon(), a pair of (0,0.0) is returned.

template<class C, class Key, class Factory, typename... ConstructorArgs>
void tk::record(Factory& f, const Key& key, ConstructorArgs&&... args)

Parameters
in Factory to register to (std::map with value using reference semantics)
key in Key used to identify the entry in the factory
args in Variable number of arguments to pass to the constructor being registered. Note that the constructor arguments are only bound to the constructor and stored in the factory (an std::map with value using reference semantics). The object is not instantiated here, i.e., the constructor is not called here. The object can be instantiated by function instantiate.

Register class into factory with given key. This is used to register a derived-class object's constructor (deriving from some base class) to a factory. The factory itself is a std::map< key, std::function< Child*() > >, i.e., an associative container, associating some key to a std::function object holding a pointer of Child's base class constructor. The constructor and its bound arguments are stored via boost::factory, which, in this use-case, yields the correct function object of type Base constructor pointer and thus facilitates runtime polymorphism. This function works in conjunction with boost::factory, i.e., uses reference semantics (works with storing pointers of objects). For a simple example on how to use this function, see tests/unit/Base/Factory.h.

template<class Factory, class Key, class Obj = typename std::remove_pointer< typename Factory::mapped_type::result_type>::type>
std::unique_ptr<Obj> tk::instantiate(const Factory& f, const Key& key)

Parameters
in Factory to instantiate object from (std::map with value using reference semantics)
key in Key used to identify the object to instantiate from factory
Returns std::unique_ptr pointing to the object instantiated from factory

Instantiate object from factory. Factory must have a mapped_value which must have a result_type ptr, e.g., std::map< Key, std::function< Obj*() > >. This wrapper function can be used to instantiate an derived-class object from a factory, repeatedly filled with wrapper function 'record' above. The factory, as described in the documentation of 'record', stores base class pointers in an associative container, thereby facilitating runtime polymorphism and a simple lookup-and-instantiate-style object creation. The object instantiated is of type Child class. This function works in conjunction with boost::factory, i.e., uses reference semantics (works with storing pointers of objects). For a simple example on how to use this function, see tests/unit//Base/Factory.h.

template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void tk::recordModel(Factory& f, const Key& key, ModelConstrArgs&&... args)

Parameters
in Factory to register to (std::map with value using value semantics)
key in Key used to identify the entry in the factory
args in Variable number of arguments to pass to the constructor being registered. Note that the constructor arguments are only bound to the constructor and stored in the factory (an std::map with value using value semantics). The object is not instantiated here, i.e., the constructor is not called here. The object can be instantiated by simply calling the function call operator () on the mapped value. For an example, RNGStack::selected() in RNG/RNGStack.C.

Register "model" class of "host" into factory with given key. This wrapper can be used to in a similar manner to 'record', but uses boost::value_factory to bind the model object constructor to its arguments and place it in the associative container storing host class objects. The container is thus of type std::map< key, std::function< T() > >, i.e., associating a key to a function holding a constructor (and not its pointer). Runtime polymorphism here is realized entirely within the "base" class. See walker::DiffEq in DiffEq/DiffEq.h for an example and more information on runtime polymorphism without client-side inheritance. As a result, this wrapper works with factories that use value semantics, as opposed to 'record' and instantiate which work with reference semantics factories. In order to differentiate between runtime polymorphic classes using reference semantics, consistent with classes realizing runtime polymorphism without client-side inheritance, we call Host as the "Base" class and Model as the "derived" (or child) class. This wrapper function works in conjunction with boost::value_factory, i.e., uses value semantics (works with storing objects instead of object pointers). For a simple example on how to use this function, see tests/unit//Base/Factory.h.

template<class Host, class ModelConstructor, class Factory, class Key, typename ModelConstrArg>
void tk::recordModelLate(Factory& f, const Key& key, ModelConstrArg)

Parameters
in Factory to register to (std::map with value using value semantics)
key in Key used to identify the entry in the factory

Register model class of host into factory with given key using late binding. This variant of 'record' is very similar to 'recordModel', but registers a model class constructor to a factory with late binding of the constructor argument. Late binding allows specifying the constructor argument at the time when the object is instantiated instead of at the time when it is registered. This has all the benefits of using a factory and allows passing information into the model object only when it is available. The late bind is facilitated via std::bind instead of std::bind using a placeholder, _1, which stands for the first argument (bound later, i.e., not here). The value of the model constructor argument is then not used here, only its type, used to perform the late binding. The binding happens to both the model constructor via std::function (passed to the host constructor) as well as explicitly to the host constructor. Prescribing late binding to the model constructor ensures that the compiler requires the argument to the model constructor, i.e., ensures that the host constructor is required to pass the argument to the model constructor. Prescribing late binding to the host constructor puts in the actual request that an argument (with the correct type) must be passed to the host constructor at instantiate time, which then will forward it to the model constructor. See also, for example, walker::DiffEq's corresponding constructor. An example of client-side code is in walker::DiffEqStack::registerDiffEq for registration into factory, and DiffEqStack::createDiffEq for instantiation late-passing the argument.

template<class Host, class ModelConstructor, class Factory, class Key, typename... ModelConstrArgs>
void tk::recordCharmModel(Factory& f, const Key& key, ModelConstrArgs&&... args)

Parameters
in Factory to register to (std::map with value using value semantics)
key in Key used to identify the entry in the factory
args in Variable number of arguments to pass to the constructor being registered.

Register Charm++ model class of host into factory with given key. We bind a host constructor to its arguments of which the first one is a std::function holding a model constructor type (modeling, i.e., used polymorhically with host), followed by an optional number of others (possibly zero) with arbitrary types. Note that the model constructor is a nullptr (default- constructed) and only used to forward its type to the call site inside std::function. The host constructor function is then placed into the factory. This is because Charm++ chares do not explicitly invoke constructors, only call ckNew() on their proxy, which requires all constructor arguments to be present and forwarded to the actual constructor that is only called at a later point in time. This can then be used by those constructors of hosts that invoke the model constructors' proxies' ckNew() and ignore the std::function. See, e.g., rngtest::Battery() and the associated unit tests in tests/unit//Base/Factory.h.

template<typename A, typename B>
std::pair<B, A> tk::flip_pair(const std::pair<A, B>& p)

Parameters
in std::pair of arbitrary types, A and B
Returns std::pair of arbitrary types, B and A

Flip a std::pair of arbitrary types

template<typename A, typename B>
std::multimap<B, A> tk::flip_map(const std::map<A, B>& src)

Parameters
src in std::map of arbitrary key and value pairs of types A and B
Returns std::multimap of arbitrary key and value pairs of types B and A

Flip a std::map of arbitrary types, yielding a std::multimap sorted by std::map::value_type.

template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
std::pair<int, std::unique_ptr<char[]>> tk::serialize(const std::unordered_map<Key, T, Hash, Eq>& m)

Template parameters
Key Map key
T Map value
Hash Map hasher
Eq Map equality operator
Parameters
in Hash map to serialize
Returns Pair of the length and the raw stream containing the serialized map

Serialize std::unordered_map to raw memory stream

template<class Key, class T, class Hash = std::hash<Key>, class Eq = std::equal_to<Key>>
CkReductionMsg* tk::mergeHashMap(int nmsg, CkReductionMsg** msgs)

Charm++ custom reducer for merging std::unordered_maps during reduction across PEs.

Template parameters
Key Map key
T Map value
Hash Map hasher
Eq Map equality operator
Parameters
nmsg in Number of messages in msgs
msgs in Charm++ reduction message containing the serialized maps
Returns Aggregated std::unordered_maps built for further aggregation if needed

During aggregation the map keys are inserted, i.e., the keys remain unique and the mapped values, assuming containers defining begin() and end() iterators() are concatenated.

uint64_t tk::linearLoadDistributor(real virtualization, uint64_t load, int npe, uint64_t& chunksize, uint64_t& remainder)

Compute linear load distribution for given total work and virtualization.

Parameters
virtualization in Degree of virtualization [0.0...1.0]
load in Total load, e.g., number of particles, number of mesh cells
npe in Number of processing elements to distribute the load to
chunksize in/out Chunk size, see detailed description
remainder in/out Remainder, see detailed description
Returns Number of work units

Compute load distibution (number of chares and chunksize) based on total work (e.g., total number of particles) and virtualization

The virtualization parameter, specified by the user, is a real number between 0.0 and 1.0, inclusive, which controls the degree of virtualization or over-decomposition. Independent of the value of virtualization the work is approximately evenly distributed among the available processing elements, given by npe. For zero virtualization (no over-decomposition), the work is simply decomposed into total_work/numPEs, which yields the smallest number of Charm++ chares and the largest chunks of work units. The other extreme is unity virtualization, which decomposes the total work into the smallest size work units possible, yielding the largest number of Charm++ chares. Obviously, the optimum will be between 0.0 and 1.0, depending on the problem.

The formula implemented uses a linear relationship between the virtualization parameter and the number of work units with the extremes described above. The formula is given by

chunksize = (1 - n) * v + n;

where

  • v = degree of virtualization
  • n = load/npes
  • load = total work, e.g., number of particles, number of mesh cells
  • npes = number of hardware processing elements

template<typename Enum, typename Ch, typename Tr, typename std::enable_if_t<std::is_enum_v<Enum>, int> = 0>
std::basic_ostream<Ch, Tr>& tk::operator<<(std::basic_ostream<Ch, Tr>& os, const Enum& e)

Parameters
os in Output stream into to write to
in Value of enum-class type to write to stream
Returns Updated output stream for chain-use of the operator

Operator << for writing an enum class to an output stream

template<class T, typename Ch, typename Tr>
std::basic_ostream<Ch, Tr>& tk::operator<<(std::basic_ostream<Ch, Tr>& os, const std::vector<T>& v)

Parameters
os in Output stream to write to
in Vector to write to stream
Returns Updated output stream for chain-use of the operator

Operator << for writing a std::vector to an output stream

template<typename Ch, typename Tr, class Key, class Value, class Compare = std::less<Key>>
std::basic_ostream<Ch, Tr>& tk::operator<<(std::basic_ostream<Ch, Tr>& os, const std::map<Key, Value, Compare>& m)

Parameters
os in Output stream to write to
in Map to write to stream
Returns Updated output stream for chain-use of the operator

Operator << for writing an std::map to an output stream

template<typename T, typename Ch, typename Tr>
std::basic_string<Ch, Tr> tk::operator<<(std::basic_string<Ch, Tr>& lhs, const T& e)

Parameters
lhs in Output std::basic_string into which e is written
in Value of arbitrary type to write to string
Returns Updated string

Operator << for adding (concatenating) T to a std::basic_string for lvalues.

template<typename T, typename Ch, typename Tr>
std::basic_string<Ch, Tr> tk::operator<<(std::basic_string<Ch, Tr>&& lhs, const T& e)

Parameters
lhs in Output std::basic_string into which e is written
in Value of arbitrary type to write to string
Returns Updated string

Operator << for adding (concatenating) T to a std::basic_string for rvalues.

std::string tk::splitLines(std::string str, std::string indent, const std::string& name = "", std::size_t width = 80)

Clean up whitespaces and format a long string into multiple lines.

Parameters
str in String to format
indent in String to use as identation
name in String to insert before string to output
width in Width in characters to insert newlines for output

std::string tk::baselogname(const std::string& executable)

Parameters
executable in Name of the executable
Returns Base log file name

std::string tk::logname(const std::string& executable, int numrestart = 0)

Construct log file name.

Parameters
executable in Name of the executable
numrestart in Number of times restarted
Returns The name of the log file to use

void tk::rm(const std::string& file)

Remove file from file system.

Parameters
file in File name to delete (shell wildcards NOT expanded)

Since we use pstream's basic_ipstream constructor with signature ( const std::string & file, const argv_type & argv, pmode mode = pstdout ) and the file argument doesn't contain a slash, the actions of the shell are duplicated in searching for an executable in PATH. The shell will not interpret the other arguments, so wildcard expansion will not take place.

void tk::signalHandler(int signum)

Signal handler for multiple signals, SIGABRT, SIGSEGV, etc.

Parameters
signum in Signal number

Signals caught: SIGABRT is generated when the program calls the abort() function, such as when an assert() triggers SIGSEGV is generated when the program makes an illegal memory access, such as reading unaligned memory, dereferencing a null pointer, reading memory out of bounds etc. SIGILL is generated when the program tries to execute a malformed instruction. This happens when the execution pointer starts reading non-program data, or when a pointer to a function is corrupted. SIGFPE is generated when executing an illegal floating point instruction, most commonly division by zero or floating point overflow.

int tk::setSignalHandlers()

Set signal handlers for multiple signals, SIGABRT, SIGSEGV, etc.

Returns Ignore, used for calling in a constructor's initializer list

void tk::processExceptionCharm()

Process an exception from the Charm++ runtime system.

See Josuttis, The C++ Standard Library - A Tutorial and Reference, 2nd Edition, 2012.

template<typename T>
T tk::swap_endian(T u)

Parameters
in Integral type to convert
Returns Converted integer

Swap endianness of an integral type

template<>
double tk::swap_endian(double u)

Parameters
in Double to convert
Returns Converted double

Swap endianness of a double

template<std::size_t N>
std::array<real, N> tk::sample(real x, const Table<N>& table)

Template parameters
N Number of ordinates in the table
Parameters
in Abscissa to sample at
table in Table to sample
Returns Ordinates sampled

Sample a discrete (y1,y2,...,yN) = f(x) function at x

template<class Tuple>
void tk::print(std::ostream& os, const std::string& name, const Tuple& c)

Template parameters
Tuple Tuple object type
Parameters
os in/out Output stream to print to
name in Name of (root) Tuple
in Command line object to output to file

Output command line object (a TaggedTuple) to file

template<class List>
std::ostream& tk::operator<<(std::ostream& os, const tk::TaggedTuple<List>& t)

Template parameters
List brigand::list of types in the tagged tuple
Parameters
os in/out Output stream to output to
in TaggedTuple to print
Returns Output stream

Simple (unformatted, one-line) output of a TaggedTuple to output stream

template<class List, class Ignore = brigand::set<>>
void tk::print(std::ostream& os, const tk::TaggedTuple<List>& t)

Simple (unformatted, one-line) output of a TaggedTuple to output stream with ignore.

Template parameters
List brigand::list of types in the tagged tuple
Ignore brigand::list of types to not print
Parameters
os in/out Output stream to output to
in TaggedTuple to print

Timer::Watch tk::hms(tk::real stamp)

Convert existing time stamp as a real to Watch (global scope)

Parameters
stamp in Time stamp as a real number
Returns Time as hours, minutes, and seconds, as a Watch struct.

Convert existing time stamp as a real to Watch (global-scope)

void tk::flip(std::array<real, 3>& v)

Parameters
in Vector whose components to multiply by -1.0

Flip sign of vector components

void tk::cross(real v1x, real v1y, real v1z, real v2x, real v2y, real v2z, real& rx, real& ry, real& rz)

Parameters
v1x in x coordinate of the 1st vector
v1y in y coordinate of the 1st vector
v1z in z coordinate of the 1st vector
v2x in x coordinate of the 2nd vector
v2y in y coordinate of the 2nd vector
v2z in z coordinate of the 2nd vector
rx out x coordinate of the product vector
ry out y coordinate of the product vector
rz out z coordinate of the product vector

Compute the cross-product of two vectors

std::array<real, 3> tk::cross(const std::array<real, 3>& v1, const std::array<real, 3>& v2)

Parameters
v1 in 1st vector
v2 in 2nd vector
Returns Cross-product

Compute the cross-product of two vectors

void tk::crossdiv(real v1x, real v1y, real v1z, real v2x, real v2y, real v2z, real j, real& rx, real& ry, real& rz)

Parameters
v1x in x coordinate of the 1st vector
v1y in y coordinate of the 1st vector
v1z in z coordinate of the 1st vector
v2x in x coordinate of the 2nd vector
v2y in y coordinate of the 2nd vector
v2z in z coordinate of the 2nd vector
in The scalar to divide the product with
rx out x coordinate of the product vector
ry out y coordinate of the product vector
rz out z coordinate of the product vector

Compute the cross-product of two vectors divided by a scalar

std::array<real, 3> tk::crossdiv(const std::array<real, 3>& v1, const std::array<real, 3>& v2, real j)

Parameters
v1 in 1st vector
v2 in 2nd vector
in Scalar to divide each component by
Returns Cross-product divided by scalar

Compute the cross-product of two vectors divided by a scalar

real tk::dot(const std::array<real, 3>& v1, const std::array<real, 3>& v2)

Parameters
v1 in 1st vector
v2 in 2nd vector
Returns Dot-product

Compute the dot-product of two vectors

real tk::length(real x, real y, real z)

Parameters
in X coordinate of vector
in Y coordinate of vector
in Z coordinate of vector
Returns length

Compute length of a vector

real tk::length(const std::array<real, 3>& v)

Parameters
in vector
Returns length

Compute length of a vector

void tk::unit(std::array<real, 3>& v)

Parameters
in/out Vector to normalize

Scale vector to unit length

tk::real tk::triple(real v1x, real v1y, real v1z, real v2x, real v2y, real v2z, real v3x, real v3y, real v3z)

Parameters
v1x in x coordinate of the 1st vector
v1y in y coordinate of the 1st vector
v1z in z coordinate of the 1st vector
v2x in x coordinate of the 2nd vector
v2y in y coordinate of the 2nd vector
v2z in z coordinate of the 2nd vector
v3x in x coordinate of the 3rd vector
v3y in y coordinate of the 3rd vector
v3z in z coordinate of the 3rd vector
Returns Scalar value of the triple product

Compute the triple-product of three vectors

real tk::triple(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3)

Parameters
v1 in 1st vector
v2 in 2nd vector
v3 in 3rd vector
Returns Triple-product

Compute the triple-product of three vectors

std::array<real, 3> tk::rotateX(const std::array<real, 3>& v, real angle)

Parameters
in Vector to rotate
angle in Angle to use to rotate with
Returns Rotated vector

Rotate vector about X axis

std::array<real, 3> tk::rotateY(const std::array<real, 3>& v, real angle)

Parameters
in Vector to rotate
angle in Angle to use to rotate with
Returns Rotated vector

Rotate vector about Y axis

std::array<real, 3> tk::rotateZ(const std::array<real, 3>& v, real angle)

Parameters
in Vector to rotate
angle in Angle to use to rotate with
Returns Rotated vector

Rotate vector about Z axis

real tk::Jacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4)

Compute the determinant of the Jacobian of a coordinate transformation over a tetrahedron.

Parameters
v1 in (x,y,z) coordinates of 1st vertex of the tetrahedron
v2 in (x,y,z) coordinates of 2nd vertex of the tetrahedron
v3 in (x,y,z) coordinates of 3rd vertex of the tetrahedron
v4 in (x,y,z) coordinates of 4th vertex of the tetrahedron
Returns Determinant of the Jacobian of transformation of physical tetrahedron to reference (xi, eta, zeta) space

std::array<std::array<real, 3>, 3> tk::inverseJacobian(const std::array<real, 3>& v1, const std::array<real, 3>& v2, const std::array<real, 3>& v3, const std::array<real, 3>& v4)

Compute the inverse of the Jacobian of a coordinate transformation over a tetrahedron.

Parameters
v1 in (x,y,z) coordinates of 1st vertex of the tetrahedron
v2 in (x,y,z) coordinates of 2nd vertex of the tetrahedron
v3 in (x,y,z) coordinates of 3rd vertex of the tetrahedron
v4 in (x,y,z) coordinates of 4th vertex of the tetrahedron
Returns Inverse of the Jacobian of transformation of physical tetrahedron to reference (xi, eta, zeta) space

tk::real tk::determinant(const std::array<std::array<tk::real, 3>, 3>& a)

Parameters
in 3x3 matrix
Returns Determinant of the 3x3 matrix

Compute the determinant of 3x3 matrix

std::array<tk::real, 3> tk::cramer(const std::array<std::array<tk::real, 3>, 3>& a, const std::array<tk::real, 3>& b)

Parameters
in 3x3 lhs matrix
in 3x1 rhs matrix
Returns Array of solutions of the 3x3 system

Solve a 3x3 system of equations using Cramer's rule

static std::string tk::workdir()

Returns A stirng containing the current working directory

std::string tk::curtime()

Wrapper for the standard C library's gettimeofday() from.

Returns A stirng containing the current date and time

void tk::echoHeader(const Print& print, HeaderType header)

Echo program header.

Parameters
print in Pretty printer
header in Header type enum indicating which header to print

void tk::echoBuildEnv(const Print& print, const std::string& executable)

Echo build environment.

Parameters
print in Pretty printer
executable in Name of the executable

Echo information read from build_dir/Base/Config.h filled by CMake based on src/Main/Config.h.in.

void tk::echoRunEnv(const Print& print, int argc, char** argv, bool verbose, bool quiescence, bool charestate, bool trace, const std::string& screen_log, const std::string& input_log)

Echo runtime environment.

Parameters
print in Pretty printer
argc in Number of command-line arguments to executable
argv in C-style string array to command-line arguments to executable
verbose in True for verbose screen-output
quiescence in True if quiescence detection is enabled
charestate in True if chare state collection is enabled
trace in True if call and stack trace output is enabled
screen_log in Screen output log file name
input_log in Input log file name

template<class Driver, class CmdLine>
Driver tk::Main(int argc, char* argv[], const CmdLine& cmdline, HeaderType header, const std::string& executable, const std::string& def, int nrestart)

Generic Main() used for all executables for code-reuse and a uniform output.

Parameters
argc in Number of command-line arguments to executable
argv in C-style string array to command-line arguments to executable
cmdline in Command line object storing data parsed from the command line arguments
header in Header type enum indicating which executable header to print
executable in Name of the executable
def in Default log file name
nrestart in Number of times restarted
Returns Instantiated driver object which can then be used to execute() whatever it is intended to drive

The template arguments configure this Main class that is practically used instead of the usual main(). This allows code-reuse and a unfirom screen-output. The template arguments are:

  • Driver, specializaing the driver type to be created, see tk::Driver
  • Printer, specializaing the pretty printer type to use, see tk::Print
  • CmdLine, specializing the command line object storing data parsed from the command line

template<class MainProxy, class CmdLine>
void tk::MainCtor(MainProxy& mp, const MainProxy& thisProxy, std::vector<tk::Timer>& timer, const CmdLine& cmdline, const CkCallback& quiescenceTarget)

Template parameters
MainProxy Main Charm++ chare proxy for the executable
CmdLine Executable-specific tagged tuple storing the rusult of the command line parser
Parameters
mp in/out MainProxy to set for the main chare
thisProxy in 'thisProxy' to set as MainProxy
timer in/out Vector of timers, held by the main chare, in which to start the first timer, measuring the migration of global-scope data
cmdline in Command line grammar stack for the executable (assumed already parsed)
quiescenceTarget in Pre-created Charm++ callback to use as the target function to call if quiescence is detected

Generic Main Charm++ module constructor for all executables

template<class CmdLine>
void tk::dumpstate(const CmdLine& cmdline, const std::string& def, int nrestart, CkReductionMsg* msg)

Template parameters
CmdLine Executable-specific tagged tuple storing the rusult of the command line parser
Parameters
cmdline in Command line grammar stack for the executable
def in Default log file name
nrestart in Number of times restarted
msg in Charm++ reduction message containing the chare state aggregated from all PEs

Generic function to dump the Charm++ chare state (if collected)

template<class CmdLine>
void tk::finalize(const CmdLine& cmdline, const std::vector<tk::Timer>& timer, tk::CProxy_ChareStateCollector& state, std::vector<std::pair<std::string, tk::Timer::Watch>>& timestamp, const std::string& def, int nrestart, const CkCallback& dumpstateTarget, bool clean = true)

Parameters
cmdline in Command line grammar stack for the executable
timer in Vector of timers, held by the main chare
state in/out Chare state collector proxy
timestamp in/out Vector of time stamps in h:m:s with labels
def in Default log file name
nrestart in Number of times restarted
dumpstateTarget in Pre-created Charm++ callback to use as the target function for dumping chare state
clean in True if we should exit with a zero exit code, false to exit with a nonzero exit code

Generic finalize function for different executables

std::pair<int, std::unique_ptr<char[]>> tk::serialize(std::size_t meshid, const std::vector<tk::UniPDF>& u)

Serialize univariate PDF to raw memory stream.

Parameters
meshid in Mesh ID
in Univariate PDFs
Returns Pair of the length and the raw stream containing the serialized PDFs

CkReductionMsg* tk::mergeUniPDFs(int nmsg, CkReductionMsg** msgs)

Charm++ custom reducer for merging a univariate PDF during reduction across PEs.

Parameters
nmsg in Number of messages in msgs
msgs in Charm++ reduction message containing the serialized PDF
Returns Aggregated PDF built for further aggregation if needed

std::pair<int, std::unique_ptr<char[]>> tk::serialize(const std::vector<tk::UniPDF>& u, const std::vector<tk::BiPDF>& b, const std::vector<tk::TriPDF>& t)

Serialize vectors of PDFs to raw memory stream.

Parameters
in Vector of univariate PDFs
in Vector of bivariate PDFs
in Vector of trivariate PDFs
Returns Pair of the length and the raw stream containing the serialized PDFs

CkReductionMsg* tk::mergePDF(int nmsg, CkReductionMsg** msgs)

Charm++ custom reducer for merging PDFs during reduction across PEs.

Parameters
nmsg in Number of messages in msgs
msgs in Charm++ reduction message containing the serialized PDFs
Returns Aggregated PDFs built for further aggregation if needed

static std::ostream& tk::operator<<(std::ostream& os, const tk::UniPDF& p)

Parameters
os in/out Stream to output to
in PDF to output
Returns Updated stream

Output univariate PDF to output stream