FasTensor  1.0.0
Transform Supercomputing for AI
Macros | Functions | Variables
ft_utility.h File Reference
#include <vector>
#include <type_traits>
#include <cstring>
#include <cmath>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <tuple>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <iostream>
#include <utility>
#include <variant>
#include <dirent.h>
#include "ft_type.h"
#include "ft_utility_macro.h"
#include <iomanip>

Go to the source code of this file.

Macros

#define V2VOIDP(vv)   static_cast<void *>(vv.data())
 
#define ExtractAttributeFromVirtualArrayVector_HELPER(ELEMENT_TYPE)
 

Functions

std::string realpathEx (std::string path)
 expand the path to full directory https://www.dreamincode.net/forums/topic/218601-realpath-and-tilde/ More...
 
std::vector< std::string > GetDirFileList (std::string dir_str_p)
 Get file list of a direction. More...
 
int ExtractEndpointTypeInfo (std::string endpoint_type_info, AuEndpointType &endpoint_type, std::string &endpoint_info)
 Split endpoint_type_info string to type and information. More...
 
int file_exist (const char *filename)
 Check wether the file exists. More...
 
std::string ExtractFileName (const std::string &fullPath)
 
std::string ExtractPath (const std::string &fullPath)
 
template<typename T >
void PrintVector (std::string name, std::vector< T > v)
 
template<typename T >
void PrintVV (std::string name, std::vector< std::vector< T >> v)
 
template<typename T >
void PrintScalar (std::string name, T v)
 
template<typename T >
void PrintString (std::string name)
 
unsigned long long RowMajorOrder (std::vector< unsigned long long > dsize, std::vector< unsigned long long > coordinate)
 convert coordinate to linearized one More...
 
std::vector< unsigned long long > RowMajorOrderReverse (unsigned long long offset, std::vector< unsigned long long > dsize)
 convert linearized coordinate to multidimensional one More...
 
template<class T1 , class T2 >
void InsertAttribute2VirtualArrayVector (const std::vector< T1 > &attribute_vector, AuEndpointDataType union_index, std::vector< T2 > &virtual_array_vector, int attribute_index)
 
template<>
void InsertAttribute2VirtualArrayVector< AuEndpointDataTypeUnion, std::complex< double > > (const std::vector< AuEndpointDataTypeUnion > &attribute_vector, AuEndpointDataType union_index, std::vector< std::complex< double >> &virtual_array_vector, int attribute_index)
 
template<class T2 >
void * ExtractAttributeFromVirtualArrayVector (std::vector< T2 > &virtual_array_vector, int attribute_index, AuEndpointDataType element_type, int element_type_size)
 
template<>
void * ExtractAttributeFromVirtualArrayVector< std::complex< double > > (std::vector< std::complex< double >> &virtual_array_vector, int attribute_index, AuEndpointDataType element_type, int element_type_size)
 
template<typename T >
std::string Vector2String (const std::vector< T > &vec)
 
template<typename T >
void String2Vector (const std::string &str, std::vector< T > &vec_new)
 

Variables

int ft_rank
 

Macro Definition Documentation

◆ ExtractAttributeFromVirtualArrayVector_HELPER

#define ExtractAttributeFromVirtualArrayVector_HELPER (   ELEMENT_TYPE)
Value:
{ \
ELEMENT_TYPE *attribute_data_typed = (ELEMENT_TYPE *)attribute_data_void_pointer; \
for (size_t i = 0; i < n; i++) \
{ \
int m_index = 0; \
ELEMENT_TYPE temp_attribute_value; \
cista::for_each_field(virtual_array_vector[i], [&m_index, attribute_index, &temp_attribute_value](auto &&m) { \
if (m_index == attribute_index) \
{ \
temp_attribute_value = m; \
} \
m_index++; \
}); \
attribute_data_typed[i] = temp_attribute_value; \
} \
}

◆ V2VOIDP

#define V2VOIDP (   vv)    static_cast<void *>(vv.data())

Author: Bin Dong dbin@.nosp@m.lbl..nosp@m.gov Web: https://crd.lbl.gov/bin-dong Scientific Data Management Research Group Lawrence Berkeley National Laboratory

Function Documentation

◆ ExtractAttributeFromVirtualArrayVector()

template<class T2 >
void* ExtractAttributeFromVirtualArrayVector ( std::vector< T2 > &  virtual_array_vector,
int  attribute_index,
AuEndpointDataType  element_type,
int  element_type_size 
)
inline

◆ ExtractAttributeFromVirtualArrayVector< std::complex< double > >()

template<>
void* ExtractAttributeFromVirtualArrayVector< std::complex< double > > ( std::vector< std::complex< double >> &  virtual_array_vector,
int  attribute_index,
AuEndpointDataType  element_type,
int  element_type_size 
)
inline

◆ ExtractEndpointTypeInfo()

int ExtractEndpointTypeInfo ( std::string  endpoint_type_info,
AuEndpointType endpoint_type,
std::string &  endpoint_info 
)

Split endpoint_type_info string to type and information.

Parameters
endpoint_type_info,informationstring for the endpoint
endpoint_type,outputvalue containing the type
endpoint_info,outputvalue containging all other parts
Returns
int

◆ ExtractFileName()

std::string ExtractFileName ( const std::string &  fullPath)
Parameters
fullPath
Returns
std::string

◆ ExtractPath()

std::string ExtractPath ( const std::string &  fullPath)
Parameters
fullPath
Returns
std::string

◆ file_exist()

int file_exist ( const char *  filename)

Check wether the file exists.

Parameters
filename
Returns
int

◆ GetDirFileList()

std::vector<std::string> GetDirFileList ( std::string  dir_str_p)

Get file list of a direction.

Parameters
dir_str_p
Returns
std::vector<std::string>

◆ InsertAttribute2VirtualArrayVector()

template<class T1 , class T2 >
void InsertAttribute2VirtualArrayVector ( const std::vector< T1 > &  attribute_vector,
AuEndpointDataType  union_index,
std::vector< T2 > &  virtual_array_vector,
int  attribute_index 
)
inline
Template Parameters
T1
T2
Parameters
attribute_vectorit is type of AuEndpointDataTypeUnion
virtual_array_vector
index

◆ InsertAttribute2VirtualArrayVector< AuEndpointDataTypeUnion, std::complex< double > >()

template<>
void InsertAttribute2VirtualArrayVector< AuEndpointDataTypeUnion, std::complex< double > > ( const std::vector< AuEndpointDataTypeUnion > &  attribute_vector,
AuEndpointDataType  union_index,
std::vector< std::complex< double >> &  virtual_array_vector,
int  attribute_index 
)
inline

◆ PrintScalar()

template<typename T >
void PrintScalar ( std::string  name,
v 
)
inline

◆ PrintString()

template<typename T >
void PrintString ( std::string  name)
inline

◆ PrintVector()

template<typename T >
void PrintVector ( std::string  name,
std::vector< T >  v 
)
inline

◆ PrintVV()

template<typename T >
void PrintVV ( std::string  name,
std::vector< std::vector< T >>  v 
)
inline

◆ realpathEx()

std::string realpathEx ( std::string  path)

expand the path to full directory https://www.dreamincode.net/forums/topic/218601-realpath-and-tilde/

Parameters
path
buff
Returns
char*

Author: Bin Dong dbin@.nosp@m.lbl..nosp@m.gov Web: https://crd.lbl.gov/bin-dong Scientific Data Management Research Group Lawrence Berkeley National Laboratory

◆ RowMajorOrder()

unsigned long long RowMajorOrder ( std::vector< unsigned long long >  dsize,
std::vector< unsigned long long >  coordinate 
)
inline

convert coordinate to linearized one

Parameters
dsize: size of all dimensions of the data
coordinate: multidimensional coordinate
Returns
unsigned long long : linearized one

◆ RowMajorOrderReverse()

std::vector<unsigned long long> RowMajorOrderReverse ( unsigned long long  offset,
std::vector< unsigned long long >  dsize 
)
inline

convert linearized coordinate to multidimensional one

Parameters
offset: linearized coordinate
dsize: data size
Returns
std::vector<unsigned long long> :multidimensional coordinate

◆ String2Vector()

template<typename T >
void String2Vector ( const std::string &  str,
std::vector< T > &  vec_new 
)

◆ Vector2String()

template<typename T >
std::string Vector2String ( const std::vector< T > &  vec)

Variable Documentation

◆ ft_rank

int ft_rank
extern