AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
Aqua Namespace Reference

Main AQUAgpusph namespace. More...

Namespaces

namespace  CalcServer
 Calculation server name space.
namespace  InputOutput
 Input/Output data interfaces.
namespace  MPI

Data Structures

class  Tokenizer_exprtk
class  Tokenizer_muparser

Typedefs

typedef Tokenizer_exprtk Tokenizer
typedef long double tokenizer_t

Enumerations

enum  TLogLevel {
  L_DEBUG , L_INFO , L_WARNING , L_ERROR ,
  L_NONE
}

Functions

bool hasPrefix (const std::string &str, const std::string &prefix)
 Check if a string starts with an specific prefix.
bool hasSuffix (const std::string &str, const std::string &suffix)
 Check if a string ends with an specific suffix.
void replaceAll (std::string &str, const std::string &search, const std::string &replace)
 Replace all substring occurrences by another substring.
std::string replaceAllCopy (std::string str, std::string search, std::string replace)
 Replace all substring occurrences by another substring.
void ltrim (std::string &s)
 Remove all the blank spaces (including line breaks, tabulators...) string prefix.
void rtrim (std::string &s)
 Remove all the blank spaces (including line breaks, tabulators...) string suffix.
void trim (std::string &s)
 Remove all the blank spaces (including line breaks, tabulators...) string prefix and suffix.
std::string ltrimCopy (std::string s)
 Remove all the blank spaces (including line breaks, tabulators...) string suffix.
std::string rtrimCopy (std::string s)
 Remove all the blank spaces (including line breaks, tabulators...) string suffix.
std::string trimCopy (std::string s)
 Remove all the blank spaces (including line breaks, tabulators...) string prefix and suffix.
std::string xxd2string (unsigned char *arr, unsigned int len)
 Transform a xxd exported file into a C++ string.
void toLower (std::string &str)
 Convert a string to lower case.
std::string toLowerCopy (std::string str)
 Convert a string to lower case.
void setStrConstants (std::string &str)
 Set several constants into a string.
std::string setStrConstantsCopy (std::string str)
 Set several constants into a string.
std::vector< std::string > split (std::string str, char chr)
 Split a string by a character.
std::vector< std::string > split_formulae (std::string str)
 Split a list of split_formulae.
std::string newFilePath (const std::string &basename, unsigned int &i, unsigned int digits=5)
 Look for a file path which is not already taken.
unsigned int nextPowerOf2 (unsigned int n)
unsigned int isPowerOf2 (unsigned int n)
const std::string getExePath ()
 Get the executable path.
const std::string getRootPath ()
 Get the root path.
const std::string getFolderFromFilePath (const std::string file_path)
 Gets the folder path which contains the file <strong class=.
const std::string getFileNameFromFilePath (const std::string file_path)
 Gets the file name of the path <strong class=.
const std::string getExtensionFromFilePath (const std::string file_path)
 Gets the file extension.
bool isFile (const std::string file_name)
 Check if the file <strong class= exist on the system.
bool isRelativePath (const std::string path)
 Check if the path <strong class= is a relative or an absolute one.
size_t getLocalWorkSize (cl_command_queue queue)
 Compute the maximum local work size allowed by a device.
size_t getGlobalWorkSize (size_t n, size_t local_work_size)
 Compute the global work size needed to compute <strong class= threads.
unsigned int numberOfDigits (unsigned int number)
 Get the number of digits of an integer decimal text representation.
bool startswith (const std::string &str, const std::string &prefix)
 Alias for hasPrefix()
bool endswith (const std::string &str, const std::string &prefix)
 Alias for hasSuffix()
std::vector< std::string > split (const std::string &s)
 Split a string in a list of substrings.
template<typename T>
bool isPowerOf2 (T x)
 Check if a number is power of 2.
template<typename T>
T nextPowerOf2 (T n)
 Next number which is power of 2.
template<typename T = unsigned int>
T roundUp (T x, T divisor)
 Rounded up value which is divisible by <strong class=.
template<typename Tout = int, typename Tin>
Tout round (Tin n)
 Round an float value to an integer one.
float clamp (float x, float a, float b)
 Clamps a value between the bounds.
template<class Tdst, class Torg>
Tdst narrow_cast (Torg v)
 Cast a value, checking that it is not overflowing.
double mod_operator (double v, double w)
double not_operator (double v)

Detailed Description

Main AQUAgpusph namespace.

Typedef Documentation

◆ Tokenizer

◆ tokenizer_t

typedef long double Aqua::tokenizer_t

Enumeration Type Documentation

◆ TLogLevel

Enumerator
L_DEBUG 
L_INFO 
L_WARNING 
L_ERROR 
L_NONE 

Function Documentation

◆ clamp()

float Aqua::clamp ( float x,
float a,
float b )
inline

Clamps a value between the bounds.

Parameters
xValue to adjust into the bounds.
aMinimum value.
bMaximum value.
Returns
Clamped value.

◆ endswith()

bool Aqua::endswith ( const std::string & str,
const std::string & prefix )
inline

Alias for hasSuffix()

Here is the call graph for this function:

◆ getExePath()

const std::string Aqua::getExePath ( )

Get the executable path.

Returns
The executable path, not necessarily a canonical one
Here is the call graph for this function:

◆ getExtensionFromFilePath()

const std::string Aqua::getExtensionFromFilePath ( const std::string file_path)

Gets the file extension.

Get the file extension from the full file path <strong class=.

Parameters
file_pathThe file path.
Returns
Extension of the file.

◆ getFileNameFromFilePath()

const std::string Aqua::getFileNameFromFilePath ( const std::string file_path)

Gets the file name of the path <strong class=.

Parameters
file_pathThe file path.
Returns
The file name.

◆ getFolderFromFilePath()

const std::string Aqua::getFolderFromFilePath ( const std::string file_path)

Gets the folder path which contains the file <strong class=.

Parameters
file_pathThe file path.
Returns
The folder.

◆ getGlobalWorkSize()

size_t Aqua::getGlobalWorkSize ( size_t n,
size_t local_work_size )

Compute the global work size needed to compute <strong class= threads.

Parameters
nAmount of data to operate in kernel (aiming threads to launch).
local_work_sizeThe local work size which will be applied.
Returns
The required global work size.
See also
roundUp()
Here is the call graph for this function:

◆ getLocalWorkSize()

size_t Aqua::getLocalWorkSize ( cl_command_queue queue)

Compute the maximum local work size allowed by a device.

Parameters
nAmount of data to operate in kernel (aiming threads to launch).
queueCommand queue.
Returns
The local work size, 0 if it is not possible to find a valid value.

◆ getRootPath()

const std::string Aqua::getRootPath ( )

Get the root path.

The root path is actually the data path, where the resources folder can be found. The root path is either Aqua::getExePath() / "../" or Aqua::getExePath() / "../share/aquagpusph"

Returns
The executable path, not necessarily a canonical one
Exceptions
std::filesystem::filesystem_errorif none of the path candidates exists
Here is the call graph for this function:

◆ hasPrefix()

bool Aqua::hasPrefix ( const std::string & str,
const std::string & prefix )

Check if a string starts with an specific prefix.

Parameters
strString to be checked
prefixPrefix to be looked for
Returns
true if #str starts with #prefix, false otherwise.

◆ hasSuffix()

bool Aqua::hasSuffix ( const std::string & str,
const std::string & suffix )

Check if a string ends with an specific suffix.

Parameters
strString to be checked
suffixSuffix to be looked for
Returns
true if #str ends with #suffix, false otherwise.

◆ isFile()

bool Aqua::isFile ( const std::string file_name)

Check if the file <strong class= exist on the system.

Parameters
file_nameThe file path.
Returns
false if the file can not be found in the system, true otherwise.

◆ isPowerOf2() [1/2]

template<typename T>
bool Aqua::isPowerOf2 ( T x)
inline

Check if a number is power of 2.

Compute if a value is power of 2.

Parameters
nValue to test.
Returns
1 if it is a power of two, 0 otherwise.

◆ isPowerOf2() [2/2]

unsigned int Aqua::isPowerOf2 ( unsigned int n)

◆ isRelativePath()

bool Aqua::isRelativePath ( const std::string path)

Check if the path <strong class= is a relative or an absolute one.

Parameters
pathThe path.
Returns
true if it is a relative path, false otherwise.
Here is the call graph for this function:

◆ ltrim()

void Aqua::ltrim ( std::string & s)

Remove all the blank spaces (including line breaks, tabulators...) string prefix.

Parameters
sString to become trimmed

◆ ltrimCopy()

std::string Aqua::ltrimCopy ( std::string s)

Remove all the blank spaces (including line breaks, tabulators...) string suffix.

Parameters
sString to become trimmed
Returns
Trimmed string
Here is the call graph for this function:

◆ mod_operator()

double Aqua::mod_operator ( double v,
double w )

◆ narrow_cast()

template<class Tdst, class Torg>
Tdst Aqua::narrow_cast ( Torg v)
inline

Cast a value, checking that it is not overflowing.

This is just a wrapper around boost::numeric_cast<>()

Parameters
valValue to cast
Returns
Casted value
Exceptions
std::out_of_rangeIf the casting would overflow the variable

◆ newFilePath()

std::string Aqua::newFilePath ( const std::string & basename,
unsigned int & i,
unsigned int digits = 5 )

Look for a file path which is not already taken.

Several scape strings can be used, that will be replaced as follows:

  • "%d"/"{index}" will be replaced by the first integer which results in a non-existing file path
  • "{mpi_rank}" will be replaced by the process identifier index
  • "{version}" will be replaced by the AQUAgpusph package version

In case a file path cannot be obtained, a std::invalid_argument exception will be raised.

Parameters
basenameThe base name of the file
iFirst index that will be checked. Also, the resulting file index is stored in this variable.
Returns
The available file path
Note
In case overwriting files is allowed, you can call this method with a try, catching std::invalid_argument exception. If exception std::invalid_argument is eventually raised, you can call setStrConstantsCopy()
Here is the call graph for this function:

◆ nextPowerOf2() [1/2]

template<typename T>
T Aqua::nextPowerOf2 ( T n)
inline

Next number which is power of 2.

Compute a value which, being power of two, is greater or equal than n.

Parameters
nNumber to round up to a power of two.
Returns
Next value which is power of two (it can be the same input value n).
Here is the call graph for this function:

◆ nextPowerOf2() [2/2]

unsigned int Aqua::nextPowerOf2 ( unsigned int n)

◆ not_operator()

double Aqua::not_operator ( double v)

◆ numberOfDigits()

unsigned int Aqua::numberOfDigits ( unsigned int number)

Get the number of digits of an integer decimal text representation.

Parameters
numberNumber from which the number of digits should be computed.
Returns
Number of digits.

◆ replaceAll()

void Aqua::replaceAll ( std::string & str,
const std::string & search,
const std::string & replace )

Replace all substring occurrences by another substring.

Parameters
strString to be modified
searchSubstring to be replaced
replaceReplacement substring

◆ replaceAllCopy()

std::string Aqua::replaceAllCopy ( std::string str,
std::string search,
std::string replace )

Replace all substring occurrences by another substring.

Parameters
strString to be modified
searchSubstring to be replaced
replaceReplacement substring
Returns
Modified string
Here is the call graph for this function:

◆ round()

template<typename Tout = int, typename Tin>
Tout Aqua::round ( Tin n)
inline

Round an float value to an integer one.

Parameters
nNumber to round.
Returns
The closest integer to <strong class=.

◆ roundUp()

template<typename T = unsigned int>
T Aqua::roundUp ( T x,
T divisor )

Rounded up value which is divisible by <strong class=.

Compute a value, which being divisible by <strong class=, is greater or equal than <strong class=.

Parameters
xNumber to round up.
divisorDivisor.
Returns
Rounded up number.

◆ rtrim()

void Aqua::rtrim ( std::string & s)

Remove all the blank spaces (including line breaks, tabulators...) string suffix.

Parameters
sString to become trimmed

◆ rtrimCopy()

std::string Aqua::rtrimCopy ( std::string s)

Remove all the blank spaces (including line breaks, tabulators...) string suffix.

Parameters
sString to become trimmed
Returns
Trimmed string
Here is the call graph for this function:

◆ setStrConstants()

void Aqua::setStrConstants ( std::string & str)

Set several constants into a string.

Following scape strings can be used, that will be replaced as follows:

  • "{mpi_rank}" will be replaced by the process identifier index
  • "{version}" will be replaced by the AQUAgpusph package version
Parameters
strThe string where constants shall be set
Here is the call graph for this function:

◆ setStrConstantsCopy()

std::string Aqua::setStrConstantsCopy ( std::string str)

Set several constants into a string.

Following scape strings can be used, that will be replaced as follows:

  • "{mpi_rank}" will be replaced by the process identifier index
  • "{version}" will be replaced by the AQUAgpusph package version
Parameters
strThe string where constants shall be set
Returns
The modified string
Here is the call graph for this function:

◆ split() [1/2]

std::vector< std::string > Aqua::split ( const std::string & s)
inline

Split a string in a list of substrings.

The space is used as separator

Parameters
sString to split
Returns
The list of substrings
Here is the call graph for this function:

◆ split() [2/2]

std::vector< std::string > Aqua::split ( std::string str,
char chr )

Split a string by a character.

Parameters
strString to be split
chrSplitting cahracter
Returns
List of substrings

◆ split_formulae()

std::vector< std::string > Aqua::split_formulae ( std::string str)

Split a list of split_formulae.

Formulae can be separated either by semicolon, ';', or by simple comma, ','. This function already takes care of parentheses, but it is not checking for syntax errors

Parameters
strString within formulae
Returns
List of formulae string
Here is the call graph for this function:

◆ startswith()

bool Aqua::startswith ( const std::string & str,
const std::string & prefix )
inline

Alias for hasPrefix()

Here is the call graph for this function:

◆ toLower()

void Aqua::toLower ( std::string & str)

Convert a string to lower case.

◆ toLowerCopy()

std::string Aqua::toLowerCopy ( std::string str)

Convert a string to lower case.

Returns
Modified string
Here is the call graph for this function:

◆ trim()

void Aqua::trim ( std::string & s)

Remove all the blank spaces (including line breaks, tabulators...) string prefix and suffix.

Parameters
sString to become trimmed
Here is the call graph for this function:

◆ trimCopy()

std::string Aqua::trimCopy ( std::string s)

Remove all the blank spaces (including line breaks, tabulators...) string prefix and suffix.

Parameters
sString to become trimmed
Returns
Trimmed string
Here is the call graph for this function:

◆ xxd2string()

std::string Aqua::xxd2string ( unsigned char * arr,
unsigned int len )

Transform a xxd exported file into a C++ string.

xdd can be used to embed external files into the program source code, by means of an include statement. However, the data is exported as a non-null terminated char array and its length. This method is appending the null character, and building a C++ string

Parameters
arrC-Like chars array
lenC-Like chars array length
Returns
C++ string