FasTensor  1.0.0
Transform Supercomputing for AI
Macros | Functions
ft_array_view_access.h File Reference
#include <vector>
#include <cstdint>
#include <cstring>
#include "ft_array_iterator.h"
#include "ft_utility_macro.h"

Go to the source code of this file.

Macros

#define ARRAY_VIEW_READ   0
 
#define ARRAY_VIEW_WRITE   1
 
#define VIEW_ACCESS_HELP_V(v_bu, v_st, a_bu, a_st, count_n, rw)
 Access a subset between v_bu (view buffer) and a_bu (array buffer) More...
 
#define VIEW_ACCESS_HELP_P(v_bu, v_st, a_bu, a_st, count_n, rw, type_size)
 

Functions

template<class T >
int ArrayViewAccessV (std::vector< T > &view_v, std::vector< T > &array_v, std::vector< unsigned long long > &array_size, std::vector< unsigned long long > &start, std::vector< unsigned long long > &end, int read_write_code)
 Access an view (subset) of an array. More...
 
template<class T >
int ArrayViewAccessP (T *view_v, T *array_v, std::vector< unsigned long long > array_size, std::vector< unsigned long long > start, std::vector< unsigned long long > end, int read_write_code)
 

Macro Definition Documentation

◆ ARRAY_VIEW_READ

#define ARRAY_VIEW_READ   0

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

◆ ARRAY_VIEW_WRITE

#define ARRAY_VIEW_WRITE   1

◆ VIEW_ACCESS_HELP_P

#define VIEW_ACCESS_HELP_P (   v_bu,
  v_st,
  a_bu,
  a_st,
  count_n,
  rw,
  type_size 
)
Value:
{ \
if (rw == ARRAY_VIEW_READ) \
{ \
std::memcpy(v_bu + v_st, a_bu + a_st, count_n * type_size); \
} \
else \
{ \
std::memcpy(a_bu + a_st, v_bu + v_st, count_n * type_size); \
} \
}
#define ARRAY_VIEW_READ
Definition: ft_array_view_access.h:89

◆ VIEW_ACCESS_HELP_V

#define VIEW_ACCESS_HELP_V (   v_bu,
  v_st,
  a_bu,
  a_st,
  count_n,
  rw 
)
Value:
{ \
if (rw == ARRAY_VIEW_READ) \
{ \
std::memcpy(); \
std::copy(a_bu.begin() + a_st, a_bu.begin() + a_st + count_n, v_bu.begin() + v_st); \
} \
else \
{ \
std::copy(v_bu.begin() + v_st, v_bu.begin() + v_st + count_n, a_bu.begin() + a_st); \
} \
}

Access a subset between v_bu (view buffer) and a_bu (array buffer)

Parameters
v_buview buffer
v_ststart of view buffer
a_buarray buffer
a_ststart of array buffer
count_nelement to access
rmflag to read or write, ARRAY_VIEW_READ and ARRAY_VIEW_WRITE

Function Documentation

◆ ArrayViewAccessP()

template<class T >
int ArrayViewAccessP ( T *  view_v,
T *  array_v,
std::vector< unsigned long long >  array_size,
std::vector< unsigned long long >  start,
std::vector< unsigned long long >  end,
int  read_write_code 
)
inline

◆ ArrayViewAccessV()

template<class T >
int ArrayViewAccessV ( std::vector< T > &  view_v,
std::vector< T > &  array_v,
std::vector< unsigned long long > &  array_size,
std::vector< unsigned long long > &  start,
std::vector< unsigned long long > &  end,
int  read_write_code 
)
inline

Access an view (subset) of an array.

Parameters
view_buffer: pointer to the buffer for the view
array_buffer: pointer to the buffer for the array
array_size: the size for the array
start: the start address of the view
end: the end address of the view
read_write_code: mode to read or write, e.g., ARRAY_VIEW_READ , ARRAY_VIEW_WRITE 1
element_size: the size of each element data
Returns
int : non zero if works, otherwise failed