FasTensor  1.0.0
Transform Supercomputing for AI
Functions
ft_output_vector.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 "ft_array_view_access.h"

Go to the source code of this file.

Functions

void GetChunkAddress (const unsigned long long chunk_id, const std::vector< unsigned long long > array_size, const std::vector< size_t > chunk_size, std::vector< unsigned long long > &chunk_start_address, std::vector< unsigned long long > &chunk_end_address)
 Get the Chunk Address object. More...
 
template<typename T >
void * InsertOutputVV2WriteV (std::vector< std::vector< T >> &v, std::vector< size_t > &v_shape, std::vector< unsigned long long > &write_start_address, std::vector< unsigned long long > &write_end_address, bool last_chunk_flag, std::vector< size_t > &prev_v_shape)
 Insert output (vector of vector) into a buffer (vector) to write. More...
 
template<typename T >
void * InsertOutputVV2WriteV (std::vector< T > &v, std::vector< size_t > &v_shape, std::vector< unsigned long long > &write_start_address, std::vector< unsigned long long > &write_end_address, bool last_chunk_flag, std::vector< size_t > &prev_v_shape)
 
template<typename T >
void * InsertOutputVV2WriteV (T &v, std::vector< size_t > &v_shape, std::vector< unsigned long long > &write_start_address, std::vector< unsigned long long > &write_end_address, bool last_chunk_flag, std::vector< size_t > &prev_v_shape)
 
template<typename T >
void * FlatVector (std::vector< std::vector< T >> &v, OutputVectorFlatDirection direction, std::vector< unsigned long long > &start_address, std::vector< unsigned long long > &end_address, size_t &v_size)
 flat vector of vector to 1D vector direction specify row-major or colum major AU_FLAT_OUTPUT_ROW (0): row major, e.g., for a 2 by 2 vector of vector v[0][0] v[0][1] v[1][0] v[1][1] AU_FLAT_OUTPUT_COL (1): column major, e.g., for a 2 by 2 vector of vector v[0][0] v[1][0] v[0][1] v[1][1] More...
 
template<typename T >
void * FlatVector (std::vector< T > &v, OutputVectorFlatDirection direction, std::vector< unsigned long long > &start_address, std::vector< unsigned long long > &end_address, size_t &v_size)
 
template<typename T >
void * FlatVector (T &v, OutputVectorFlatDirection direction, std::vector< unsigned long long > &start_address, std::vector< unsigned long long > &end_address, size_t &v_size)
 

Function Documentation

◆ FlatVector() [1/3]

template<typename T >
void* FlatVector ( std::vector< std::vector< T >> &  v,
OutputVectorFlatDirection  direction,
std::vector< unsigned long long > &  start_address,
std::vector< unsigned long long > &  end_address,
size_t &  v_size 
)

flat vector of vector to 1D vector direction specify row-major or colum major AU_FLAT_OUTPUT_ROW (0): row major, e.g., for a 2 by 2 vector of vector v[0][0] v[0][1] v[1][0] v[1][1] AU_FLAT_OUTPUT_COL (1): column major, e.g., for a 2 by 2 vector of vector v[0][0] v[1][0] v[0][1] v[1][1]

AU_FLAT_OUTPUT_RC: both row and column major, e.g. for a 2 by 2 vector of vector v[0][0] v[0][1] v[1][0] v[1][1] Then, linearized as v[0][0] v[0][1] v[1][0] v[1][1] It looks like AU_FLAT_OUTPUT_ROW, but the start_address and end_address are handled differently start_address is adjusted by v.size() end_address is adjusted by v[0].size()
AU_FLAT_OUTPUT_CR: both row and column major, e.g. for a 2 by 2 vector of vector

Since this is the support function to WriteEndpoint, It also convert the address associated with it.

Template Parameters
Ttype of data element
Parameters
vthe vector of vector
directionhow to flat the data
start_addressthe start address before/after flat, it may chage the # of dimensions
end_addressthe end address before/after flat, it may chage the # of dimensions
v_size,thesize of each element vector
Returns
void* the flat data

◆ FlatVector() [2/3]

template<typename T >
void* FlatVector ( std::vector< T > &  v,
OutputVectorFlatDirection  direction,
std::vector< unsigned long long > &  start_address,
std::vector< unsigned long long > &  end_address,
size_t &  v_size 
)

◆ FlatVector() [3/3]

template<typename T >
void* FlatVector ( T &  v,
OutputVectorFlatDirection  direction,
std::vector< unsigned long long > &  start_address,
std::vector< unsigned long long > &  end_address,
size_t &  v_size 
)

◆ GetChunkAddress()

void GetChunkAddress ( const unsigned long long  chunk_id,
const std::vector< unsigned long long >  array_size,
const std::vector< size_t >  chunk_size,
std::vector< unsigned long long > &  chunk_start_address,
std::vector< unsigned long long > &  chunk_end_address 
)
inline

Get the Chunk Address object.

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

Parameters
chunk_id
array_size
chunk_size
chunk_start_address
chunk_end_address
Returns
int

◆ InsertOutputVV2WriteV() [1/3]

template<typename T >
void* InsertOutputVV2WriteV ( std::vector< std::vector< T >> &  v,
std::vector< size_t > &  v_shape,
std::vector< unsigned long long > &  write_start_address,
std::vector< unsigned long long > &  write_end_address,
bool  last_chunk_flag,
std::vector< size_t > &  prev_v_shape 
)

Insert output (vector of vector) into a buffer (vector) to write.

Template Parameters
T,elementtype
Parameters
v,theoutput vector of vector
v_shape,theshape of the output in array space
write_start_address,thestart address to write (get updated by the function too)
write_end_address,theend address to write (get updated by the function too)
Returns
void* the buffer containing the vector to write

◆ InsertOutputVV2WriteV() [2/3]

template<typename T >
void* InsertOutputVV2WriteV ( std::vector< T > &  v,
std::vector< size_t > &  v_shape,
std::vector< unsigned long long > &  write_start_address,
std::vector< unsigned long long > &  write_end_address,
bool  last_chunk_flag,
std::vector< size_t > &  prev_v_shape 
)

◆ InsertOutputVV2WriteV() [3/3]

template<typename T >
void* InsertOutputVV2WriteV ( T &  v,
std::vector< size_t > &  v_shape,
std::vector< unsigned long long > &  write_start_address,
std::vector< unsigned long long > &  write_end_address,
bool  last_chunk_flag,
std::vector< size_t > &  prev_v_shape 
)