Agora  1.2.0
Agora project
utils.h File Reference

Utility functions for file and text processing. More...

#include <complex>
#include <cstddef>
#include <cstdint>
#include <fstream>
#include <random>
#include <string>
#include <vector>
#include "armadillo"
#include "symbols.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EventHandlerContext< T >
 
class  Utils
 
struct  Range
 A range type with an inclusive start bound and an exclusive end bound. More...
 
class  SlowRand
 
class  FastRand
 

Macros

#define UNUSED   __attribute__((unused))
 
#define unused(x)   ((void)(x))
 
#define likely(x)   __builtin_expect(!!(x), 1)
 
#define unlikely(x)   __builtin_expect(!!(x), 0)
 

Functions

void SetCpuLayoutOnNumaNodes (bool verbose=false, const std::vector< size_t > &cores_to_exclude=std::vector< size_t >(1, 0))
 
size_t GetPhysicalCoreId (size_t core_id)
 
int PinToCore (size_t core_id)
 
void PinToCoreWithOffset (ThreadType thread, size_t base_core_offset, size_t thread_id, bool allow_reuse=false, bool verbose=false)
 
void PrintCoreAssignmentSummary ()
 
template<uint64_t PowerOfTwoNumber, typename T >
static constexpr T Roundup (T x)
 
static void RtAssert (bool condition, const char *throw_str)
 
static void RtAssert (bool condition)
 
static void RtAssert (bool condition, const std::string &throw_str)
 Check a condition at runtime. If the condition is false, throw exception. More...
 
static void RtAssert (bool condition, const std::string &throw_str, char *s)
 Check a condition at runtime. If the condition is false, throw exception. More...
 
size_t Gcd (size_t a, size_t b)
 Returns the greatest common divisor of a and b. More...
 
size_t Lcm (size_t a, size_t b)
 Returns the least common multiple of a and b. More...
 

Detailed Description

Utility functions for file and text processing.

Author
Rahman Doost-Mohamamdy: doost.nosp@m.@ric.nosp@m.e.edu

Macro Definition Documentation

◆ likely

#define likely (   x)    __builtin_expect(!!(x), 1)

◆ unlikely

#define unlikely (   x)    __builtin_expect(!!(x), 0)

◆ UNUSED

#define UNUSED   __attribute__((unused))

◆ unused

#define unused (   x)    ((void)(x))

Function Documentation

◆ Gcd()

size_t Gcd ( size_t  a,
size_t  b 
)
inline

Returns the greatest common divisor of a and b.

Here is the caller graph for this function:

◆ GetPhysicalCoreId()

size_t GetPhysicalCoreId ( size_t  core_id)

◆ Lcm()

size_t Lcm ( size_t  a,
size_t  b 
)
inline

Returns the least common multiple of a and b.

Here is the call graph for this function:

◆ PinToCore()

int PinToCore ( size_t  core_id)
Here is the caller graph for this function:

◆ PinToCoreWithOffset()

void PinToCoreWithOffset ( ThreadType  thread,
size_t  base_core_offset,
size_t  thread_id,
bool  allow_reuse = false,
bool  verbose = false 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintCoreAssignmentSummary()

void PrintCoreAssignmentSummary ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Roundup()

template<uint64_t PowerOfTwoNumber, typename T >
static constexpr T Roundup ( T  x)
staticconstexpr

roundup<N>(x) returns x rounded up to the next multiple of N. N must be a power of two.

Here is the call graph for this function:

◆ RtAssert() [1/4]

static void RtAssert ( bool  condition)
inlinestatic

Check a condition at runtime. If the condition is false, throw exception. This is faster than rt_assert(cond, std::string) as it avoids string construction.

◆ RtAssert() [2/4]

static void RtAssert ( bool  condition,
const char *  throw_str 
)
inlinestatic

Check a condition at runtime. If the condition is false, throw exception. This is faster than rt_assert(cond, std::string) as it avoids string construction.

◆ RtAssert() [3/4]

static void RtAssert ( bool  condition,
const std::string &  throw_str 
)
inlinestatic

Check a condition at runtime. If the condition is false, throw exception.

◆ RtAssert() [4/4]

static void RtAssert ( bool  condition,
const std::string &  throw_str,
char *  s 
)
inlinestatic

Check a condition at runtime. If the condition is false, throw exception.

◆ SetCpuLayoutOnNumaNodes()

void SetCpuLayoutOnNumaNodes ( bool  verbose = false,
const std::vector< size_t > &  cores_to_exclude = std::vector< size_t >(1, 0) 
)
Here is the call graph for this function:
Here is the caller graph for this function: