86 #ifndef ARRAY_UDF_ARRAY_H
87 #define ARRAY_UDF_ARRAY_H
120 #define TRANSFORM(A_BASE_OBJECT, UDF, B, A_TYPE, UDF_OUT_TYPE) \
124 case AuEndpointDataType::AU_SHORT: \
125 static_cast<FT::Array<short> *>(A_BASE_OBJECT)->Transform<UDF_OUT_TYPE>(UDF, B); \
127 case AuEndpointDataType::AU_DOUBLE: \
128 static_cast<FT::Array<double> *>(A_BASE_OBJECT)->Transform<UDF_OUT_TYPE>(UDF, B); \
130 case AuEndpointDataType::AU_FLOAT: \
131 static_cast<FT::Array<float> *>(A_BASE_OBJECT)->Transform<UDF_OUT_TYPE>(UDF, B); \
133 case AuEndpointDataType::AU_INT: \
134 static_cast<FT::Array<int> *>(A_BASE_OBJECT)->Transform<UDF_OUT_TYPE>(UDF, B); \
137 AU_EXIT("Not supported type yet in TRANSFORM macro !"); \
157 virtual int GetTag(
const std::string &name, std::string &value) = 0;
176 std::string array_data_endpoint_info;
181 std::vector<unsigned long long> data_size;
182 std::vector<int> data_chunk_size;
183 std::vector<int> data_overlap_size;
184 std::vector<unsigned long long> data_chunked_size;
185 int data_auto_chunk_dim_index;
186 unsigned long long data_total_chunks;
188 std::vector<unsigned long long> current_chunk_start_offset;
189 std::vector<unsigned long long> current_chunk_end_offset;
190 std::vector<unsigned long long> current_chunk_size;
191 unsigned long long current_chunk_cells;
193 std::vector<unsigned long long> current_result_chunk_start_offset;
194 std::vector<unsigned long long> current_result_chunk_end_offset;
195 unsigned long long current_result_chunk_cells;
197 std::vector<unsigned long long> current_chunk_ol_start_offset;
198 std::vector<unsigned long long> current_chunk_ol_end_offset;
199 std::vector<unsigned long long> current_chunk_ol_size;
200 unsigned long long current_chunk_ol_cells;
202 unsigned long long current_chunk_id;
203 unsigned long long prev_chunk_id;
204 std::vector<int> skip_size;
205 std::vector<unsigned long long> skiped_dims_size;
206 std::vector<unsigned long long> skiped_chunks;
207 std::vector<int> skiped_chunk_size;
209 std::vector<T> current_chunk_data;
211 std::vector<long long> ol_origin_offset;
213 std::vector<unsigned long long> view_start_offset;
214 std::vector<unsigned long long> view_size;
215 std::vector<unsigned long long> view_orginal_data_dims_size;
217 std::vector<T> mirror_values;
221 std::vector<size_t> output_vector_flat_shape;
223 std::vector<std::string> attribute_array_data_endpoint_info;
225 std::vector<Endpoint *> attribute_endpoint_vector;
228 std::regex dir_input_regex, dir_output_regex;
229 std::string dir_output_replace_str;
232 size_t set_chunk_size_by_mem_max_mem_size = 1073741824;
235 bool skip_flag =
false;
236 bool view_flag =
false;
237 bool cpp_vec_flag =
false;
238 bool virtual_array_flag =
false;
239 bool save_result_flag =
true;
240 bool reverse_apply_direction_flag =
false;
241 bool mirror_value_flag =
false;
242 bool apply_replace_flag =
false;
243 bool vector_type_flag =
false;
244 bool endpoint_memory_flag =
false;
245 bool has_padding_value_flag =
false;
246 bool skip_not_aligned_w_array_flag =
false;
247 bool is_the_last_chunk =
false;
248 bool is_endpoint_created_flag =
false;
250 bool chunk_size_by_user_flag =
false;
251 bool chunk_size_by_user_by_dimension_flag =
false;
252 bool set_chunk_size_by_mem_flag =
false;
253 bool set_overlap_size_by_auto_detection_flag =
false;
255 bool set_direct_output_flag =
false;
257 bool get_stencil_tag_flag =
false;
258 std::map<std::string, std::string> stencil_metadata_map;
260 bool has_output_stencil_tag_flag =
false;
261 std::map<std::string, std::string> output_stencil_metadata_map;
263 int skip_not_aligned_w_array_index;
265 std::vector<size_t> output_vector_shape;
266 std::vector<size_t> previous_output_vector_shape;
272 AU_WTIME_TYPE t_start, time_read = 0, time_udf = 0, time_write = 0, time_create = 0, time_sync = 0, time_nonvolatile = 0;
295 array_data_endpoint_info = data_endpoint;
301 endpoint_memory_flag =
true;
313 Array(std::string data_endpoint, std::vector<int> cs)
315 array_data_endpoint_info = data_endpoint;
316 data_chunk_size = cs;
317 data_overlap_size.resize(cs.size());
318 std::fill(data_overlap_size.begin(), data_overlap_size.end(), 0);
325 chunk_size_by_user_flag =
true;
327 endpoint_memory_flag =
true;
341 Array(std::string data_endpoint, std::vector<int> cs, std::vector<int> os)
343 array_data_endpoint_info = data_endpoint;
344 data_chunk_size = cs;
345 data_overlap_size = os;
351 chunk_size_by_user_flag =
true;
353 endpoint_memory_flag =
true;
366 Array(std::string data_endpoint,
int auto_chunk_dim_index)
368 array_data_endpoint_info = data_endpoint;
369 data_auto_chunk_dim_index = auto_chunk_dim_index;
374 chunk_size_by_user_by_dimension_flag =
true;
376 endpoint_memory_flag =
true;
389 Array(std::string data_endpoint, std::vector<unsigned long long> size_p)
391 array_data_endpoint_info = data_endpoint;
399 endpoint_memory_flag =
true;
414 Array(std::vector<int> cs, std::vector<int> os)
416 data_chunk_size = cs;
417 data_overlap_size = os;
422 data_chunk_size = cs;
423 data_overlap_size.resize(cs.size());
424 std::fill(data_overlap_size.begin(), data_overlap_size.end(), 0);
431 Array(std::vector<T> &data_vector_endpoint)
442 Array(std::vector<T> &data_vector_endpoint, std::vector<int> cs, std::vector<int> os)
469 if (chunk_size_by_user_by_dimension_flag)
472 data_chunk_size.resize(data_dims);
474 for (
int i = 0; i < data_dims; i++)
476 if (data_auto_chunk_dim_index == i)
478 if (data_size[i] %
ft_size == 0)
480 data_chunk_size[i] = data_size[i] /
ft_size;
484 data_chunk_size[i] = data_size[i] /
ft_size + 1;
489 data_chunk_size[i] = data_size[i];
497 if (set_chunk_size_by_mem_flag)
499 unsigned long long total_elements = 1;
500 for (
int i = 0; i < data_dims; i++)
502 total_elements = data_size[i] * total_elements;
504 total_elements = total_elements /
ft_size;
505 if (total_elements > (set_chunk_size_by_mem_max_mem_size /
sizeof(T)))
507 total_elements = set_chunk_size_by_mem_max_mem_size /
sizeof(T);
509 std::vector<unsigned long long> chunk_size_temp =
RowMajorOrderReverse(total_elements, data_size);
510 int replace_flag = 1;
511 for (
int i = data_dims - 1; i > 0; i--)
513 if (chunk_size_temp[i] != data_size[i])
515 chunk_size_temp[i] = data_size[i];
516 if (chunk_size_temp[i - 1] != 0)
518 chunk_size_temp[i - 1] = chunk_size_temp[i - 1] - 1;
528 for (
int i = data_dims - 1; i >= 0; i--)
530 if (chunk_size_temp[i] == 0)
537 for (
int i = 0; i < data_dims; i++)
538 data_chunk_size[i] = chunk_size_temp[i];
542 AU_EXIT(
"SetChunkSizeByMem failed ! Please try specify the chunk size via SetChunkSize !");
556 data_overlap_size = os_p;
561 set_overlap_size_by_auto_detection_flag =
true;
566 os_p = data_overlap_size;
571 has_padding_value_flag =
true;
572 padding_value = padding_value_p;
578 if (endpoint != NULL)
582 std::vector<std::string> arg_v;
591 template <
class UDFOutputType>
594 if (endpoint != NULL)
598 data_overlap_size.resize(data_dims);
599 for (
int i = 0; i < data_dims; i++)
601 data_overlap_size[i] = 0;
607 if (set_overlap_size_by_auto_detection_flag)
609 std::vector<T> trail_data;
610 trail_data.resize(1);
611 Stencil<T> trail_cell(data_dims, &trail_data[0]);
619 template <
class UDFOutputType>
623 if (virtual_array_flag && attribute_endpoint_vector.size() >= 1)
626 attribute_endpoint_vector[0]->ExtractMeta();
627 data_size = attribute_endpoint_vector[0]->GetDimensions();
628 data_dims = data_size.size();
629 for (
int i = 1; i < attribute_endpoint_vector.size(); i++)
631 attribute_endpoint_vector[i]->ExtractMeta();
632 std::vector<unsigned long long> data_size_p = attribute_endpoint_vector[i]->GetDimensions();
634 if (data_size != data_size_p)
636 AU_EXIT(
"All attributes must have same size");
644 data_dims = data_size.size();
653 current_chunk_start_offset.resize(data_dims);
654 current_chunk_end_offset.resize(data_dims);
655 current_chunk_size.resize(data_dims);
657 current_result_chunk_start_offset.resize(data_dims);
658 current_result_chunk_end_offset.resize(data_dims);
660 current_chunk_ol_start_offset.resize(data_dims);
661 current_chunk_ol_end_offset.resize(data_dims);
662 current_chunk_ol_size.resize(data_dims);
664 data_chunked_size.resize(data_dims);
665 ol_origin_offset.resize(data_dims);
667 data_total_chunks = 1;
669 for (
int i = 0; i < data_dims; i++)
671 if (data_size[i] % data_chunk_size[i] == 0)
673 data_chunked_size[i] = data_size[i] / data_chunk_size[i];
677 data_chunked_size[i] = data_size[i] / data_chunk_size[i] + 1;
679 data_total_chunks = data_total_chunks * data_chunked_size[i];
684 skiped_dims_size.resize(data_dims);
685 skiped_chunks.resize(data_dims);
686 skiped_chunk_size.resize(data_dims);
688 for (
int i = 0; i < data_dims; i++)
696 if (data_chunk_size[i] % skip_size[i] != 0)
698 AU_EXIT(
"Strip size must be aligned with the size of chunk ! \n");
701 if (data_size[i] % skip_size[i] != 0)
703 skip_not_aligned_w_array_flag =
true;
704 skip_not_aligned_w_array_index = i;
705 skiped_dims_size[i] = data_size[i] / skip_size[i] + 1;
709 skiped_dims_size[i] = data_size[i] / skip_size[i];
712 skiped_chunk_size[i] = data_chunk_size[i] / skip_size[i];
713 if (skiped_dims_size[i] % skiped_chunk_size[i] != 0)
715 skiped_chunks[i] = skiped_dims_size[i] / skiped_chunk_size[i] + 1;
719 skiped_chunks[i] = skiped_dims_size[i] / skiped_chunk_size[i];
729 if (!virtual_array_flag)
734 PrintScalar(
"current chunk id:", current_chunk_id);
745 if (!virtual_array_flag)
751 for (
auto aep : attribute_endpoint_vector)
764 template <
class UDFOutputType,
class BType = UDFOutputType>
770 template <
class UDFOutputType,
class BType = UDFOutputType>
791 template <
class UDFOutputType,
class BType = UDFOutputType>
802 std::vector<UDFOutputType> current_result_chunk_data;
803 unsigned long long current_result_chunk_data_size = 1;
805 vector_type_flag = InferVectorType<UDFOutputType>();
808 int load_ret =
LoadNextChunk(current_result_chunk_data_size);
809 current_result_chunk_data.resize(current_result_chunk_data_size);
812 unsigned long long result_vector_index = 0;
814 while (load_ret == 1)
816 unsigned long long cell_target_g_location_rm;
817 result_vector_index = 0;
830 std::vector<unsigned long long> cell_coordinate(data_dims, 0), cell_coordinate_ol(data_dims, 0), global_cell_coordinate(data_dims, 0);
831 unsigned long long offset_ol;
832 Stencil<T> cell_target(0, ¤t_chunk_data[0], cell_coordinate_ol, current_chunk_ol_size, data_size);
833 if (has_padding_value_flag)
839 if (get_stencil_tag_flag)
841 cell_target.
SetTagMap(stencil_metadata_map);
844 UDFOutputType cell_return_value;
845 unsigned long long cell_target_g_location_rm;
846 int is_mirror_value = 0;
847 std::vector<unsigned long long> skip_chunk_coordinate(data_dims, 0), skip_chunk_coordinate_start(data_dims, 0);
848 int skip_flag_on_cell = 0;
851 int ithread = omp_get_thread_num();
852 int nthreads = omp_get_num_threads();
855 prefix =
new size_t[nthreads + 1];
858 std::vector<UDFOutputType> vec_private;
862 #pragma omp for schedule(static) nowait
864 for (
unsigned long long i = 0; i < current_chunk_cells; i++)
870 skip_flag_on_cell = 0;
871 for (
int id = 0;
id < data_dims;
id++)
874 skip_chunk_coordinate[id] = std::floor(cell_coordinate[
id] / skip_size[
id]);
875 skip_chunk_coordinate_start[id] = skip_chunk_coordinate[id] * skip_size[id];
876 if (skip_chunk_coordinate_start[
id] != cell_coordinate[
id])
878 skip_flag_on_cell = 1;
883 if (skip_flag_on_cell == 1)
885 assert(i < current_chunk_cells);
890 for (
int ii = 0; ii < data_dims; ii++)
892 if (cell_coordinate[ii] + ol_origin_offset[ii] < current_chunk_ol_size[ii])
894 cell_coordinate_ol[ii] = cell_coordinate[ii] + ol_origin_offset[ii];
898 cell_coordinate_ol[ii] = current_chunk_ol_size[ii] - 1;
901 global_cell_coordinate[ii] = current_chunk_start_offset[ii] + cell_coordinate[ii];
905 ROW_MAJOR_ORDER_MACRO(current_chunk_ol_size, current_chunk_ol_size.size(), cell_coordinate_ol, offset_ol);
908 ROW_MAJOR_ORDER_MACRO(data_size, data_size.size(), global_cell_coordinate, cell_target_g_location_rm)
909 cell_target.
SetLocation(offset_ol, cell_coordinate_ol, cell_coordinate, current_chunk_size, ol_origin_offset, current_chunk_ol_size, global_cell_coordinate, cell_target_g_location_rm);
913 cell_target.
SetLocation(offset_ol, cell_coordinate_ol, cell_coordinate, current_chunk_size, ol_origin_offset, current_chunk_ol_size, cell_coordinate_ol, offset_ol);
921 cell_return_stencil = UDF(cell_target);
922 cell_return_value = cell_return_stencil.
get_value();
924 if (vector_type_flag ==
true)
926 cell_return_stencil.
GetShape(output_vector_shape);
931 has_output_stencil_tag_flag =
true;
932 cell_return_stencil.
GetTagMap(output_stencil_metadata_map);
935 if (save_result_flag)
940 vec_private.push_back(cell_return_value);
942 current_result_chunk_data[result_vector_index] = cell_return_value;
943 result_vector_index = result_vector_index + 1;
953 current_result_chunk_data[i] = cell_return_value;
954 if (apply_replace_flag == 1)
956 std::memcpy(¤t_chunk_data[offset_ol], &cell_return_value,
sizeof(T));
962 prefix[ithread + 1] = vec_private.size();
966 for (
int i = 1; i < (nthreads + 1); i++)
968 prefix[i] += prefix[i - 1];
970 if (current_result_chunk_data.size() != prefix[nthreads])
972 std::cout <<
"Wrong output size ! prefix[nthreads] =" << prefix[nthreads] <<
", current.size() = " << current_result_chunk_data.size() <<
" \n ";
975 std::copy(vec_private.begin(), vec_private.end(), current_result_chunk_data.begin() + prefix[ithread]);
976 clear_vector(vec_private);
994 std::vector<unsigned long long> B_data_size;
995 std::vector<int> B_data_chunk_size, B_data_overlap_size;
999 std::vector<std::string> dir_file_list =
GetDirFile();
1000 B->SetDirFile(dir_file_list);
1002 B->SetDirChunkSize(dir_chunk_size);
1005 if (vector_type_flag)
1009 std::vector<unsigned long long> current_chunk_start_offset_v = current_result_chunk_start_offset, current_chunk_end_offset_v = current_result_chunk_end_offset;
1014 if (is_the_last_chunk && (previous_output_vector_shape.size() == 0))
1017 previous_output_vector_shape = output_vector_shape;
1018 for (
int i = 0; i < output_vector_shape.size(); i++)
1020 if (skip_not_aligned_w_array_flag && skip_not_aligned_w_array_index == i)
1022 previous_output_vector_shape[i] = data_chunk_size[i] / (current_chunk_ol_size[i] / output_vector_shape[i]);
1031 data_point =
InsertOutputVV2WriteV(current_result_chunk_data, output_vector_shape, current_chunk_start_offset_v, current_chunk_end_offset_v, is_the_last_chunk, previous_output_vector_shape);
1035 B->CreateEndpoint(B_data_size, B_data_chunk_size, B_data_overlap_size);
1038 B->WriteEndpoint(current_chunk_start_offset_v, current_chunk_end_offset_v, data_point);
1043 InferOutputSize(B_data_size, B_data_chunk_size, B_data_overlap_size, 0);
1044 B->CreateEndpoint(B_data_size, B_data_chunk_size, B_data_overlap_size);
1050 B->WriteArray(current_result_chunk_start_offset, current_chunk_end_offset, current_result_chunk_data);
1056 B->WriteArray(current_result_chunk_start_offset, current_result_chunk_end_offset, current_result_chunk_data);
1061 if (has_output_stencil_tag_flag)
1063 for (std::map<std::string, std::string>::iterator it = output_stencil_metadata_map.begin(); it != output_stencil_metadata_map.end(); ++it)
1066 B->SetTag(it->first, it->second);
1070 has_output_stencil_tag_flag =
false;
1075 if (vector_type_flag ==
true)
1077 previous_output_vector_shape = output_vector_shape;
1082 current_result_chunk_data.resize(current_result_chunk_data_size);
1088 if ((data_total_chunks %
ft_size != 0) && (current_chunk_id >= data_total_chunks) && (current_chunk_id < (data_total_chunks +
ft_size - (data_total_chunks %
ft_size))) && B !=
nullptr)
1093 std::vector<unsigned long long> null_start;
1094 std::vector<unsigned long long> null_end;
1095 void *data_point =
nullptr;
1096 null_start.resize(data_dims, 0);
1097 null_end.resize(data_dims, 0);
1098 B->WriteEndpoint(null_start, null_end, data_point);
1104 int WriteArray(
const std::vector<unsigned long long> &start_p,
const std::vector<unsigned long long> &end_p, std::vector<T> &data_p)
1106 if (!is_endpoint_created_flag)
1111 if (!virtual_array_flag)
1113 return endpoint->
Write(start_p, end_p,
static_cast<void *
>(data_p.data()));
1118 int n = attribute_endpoint_vector.size();
1119 for (
int i = 0; i < n; i++)
1122 void *current_chunk_data_void_p =
ExtractAttributeFromVirtualArrayVector(data_p, i, attribute_endpoint_vector[i]->GetDataElementType(), attribute_endpoint_vector[i]->GetDataElementTypeSize());
1123 attribute_endpoint_vector[i]->Write(start_p, end_p, current_chunk_data_void_p);
1124 free(current_chunk_data_void_p);
1140 int ReadModifyWriteArray(
const std::vector<unsigned long long> &start_p,
const std::vector<unsigned long long> &end_p, std::vector<T> &data_p,
AU_Op op)
1142 if (!is_endpoint_created_flag)
1147 if (!virtual_array_flag)
1149 std::vector<T> data_p_read;
1150 data_p_read.resize(data_p.size());
1151 endpoint->
Read(start_p, end_p,
static_cast<void *
>(data_p.data()));
1155 std::transform(data_p_read.begin(), data_p_read.end(), data_p.begin(), data_p.begin(), std::plus<T>());
1158 AU_EXIT(
"Not supported op type in ReadModifyWriteArray now\n");
1161 return endpoint->
Write(start_p, end_p,
static_cast<void *
>(data_p.data()));
1166 AU_EXIT(
"Not supported ReadModifyWriteArray on virtual array yet !\n");
1171 int WriteArray(std::vector<unsigned long long> &start_p, std::vector<unsigned long long> &end_p, std::vector<std::vector<T>> data_p)
1173 AU_EXIT(
"You should not be here !");
1177 int WriteEndpoint(std::vector<unsigned long long> &start_p, std::vector<unsigned long long> &end_p,
void *data)
1179 if (!virtual_array_flag)
1180 return endpoint->
Write(start_p, end_p, data);
1185 int ReadEndpoint(std::vector<unsigned long long> &start_p, std::vector<unsigned long long> &end_p,
void *data)
1187 return endpoint->
Read(start_p, end_p, data);
1197 void inline CalculateOutputSize(std::vector<unsigned long long> &data_size_p, std::vector<int> &data_chunk_size_p, std::vector<int> &data_overlap_size_p)
1201 data_size_p = skiped_dims_size;
1202 data_chunk_size_p = skiped_chunk_size;
1203 data_overlap_size_p = data_overlap_size;
1207 data_size_p = data_size;
1208 data_chunk_size_p = data_chunk_size;
1209 data_overlap_size_p = data_overlap_size;
1214 if (vector_type_flag)
1216 int rank = data_size_p.size();
1217 for (
int i = 0; i < output_vector_shape.size(); i++)
1221 data_size_p.push_back(output_vector_shape[i]);
1222 data_chunk_size_p.push_back(output_vector_shape[i]);
1223 data_overlap_size_p.push_back(0);
1227 if (skip_not_aligned_w_array_flag && skip_not_aligned_w_array_index == i)
1229 if (!is_the_last_chunk)
1231 data_size_p[i] = (data_size_p[i] - 1) * output_vector_shape[i];
1232 data_size_p[i] = data_size_p[i] + ((data_size[i] % skip_size[i]) * output_vector_shape[i]) / data_chunk_size[i];
1238 int normal_chunk_output_size = data_chunk_size[i] / (current_chunk_ol_size[i] / output_vector_shape[i]);
1247 data_size_p[i] = (data_size_p[i] - 1) * normal_chunk_output_size;
1248 data_size_p[i] = data_size_p[i] + ((data_size[i] % skip_size[i]) * normal_chunk_output_size) / data_chunk_size[i];
1253 data_size_p[i] = data_size_p[i] * output_vector_shape[i];
1267 void inline InferOutputSize(std::vector<unsigned long long> &data_size_p, std::vector<int> &data_chunk_size_p, std::vector<int> &data_overlap_size_p,
size_t output_vector_size)
1271 if (!vector_type_flag)
1273 data_size_p = skiped_dims_size;
1274 data_chunk_size_p = skiped_chunk_size;
1275 data_overlap_size_p = data_overlap_size;
1280 std::vector<unsigned long long> skiped_dims_size_t;
1281 std::vector<int> skiped_chunk_size_t;
1282 std::vector<int> data_overlap_size_t;
1284 if (output_vector_flat_direction_index > (data_dims - 1))
1286 data_dims_t = data_dims + 1;
1287 skiped_dims_size_t.resize(data_dims_t);
1288 skiped_chunk_size_t.resize(data_dims_t);
1289 data_overlap_size_t.resize(data_dims_t);
1290 for (
int k = 0; k < data_dims; k++)
1292 skiped_dims_size_t[k] = skiped_dims_size[k];
1293 data_overlap_size_t[k] = data_overlap_size[k];
1294 skiped_chunk_size_t[k] = skiped_chunk_size[k];
1296 skiped_dims_size_t[data_dims] = output_vector_size;
1297 data_overlap_size_t[data_dims] = 0;
1298 skiped_chunk_size_t[data_dims] = output_vector_size;
1302 data_dims_t = data_dims;
1303 skiped_dims_size_t.resize(data_dims_t);
1304 skiped_chunk_size_t.resize(data_dims_t);
1305 data_overlap_size_t.resize(data_dims_t);
1306 for (
int k = 0; k < data_dims; k++)
1308 skiped_dims_size_t[k] = skiped_dims_size[k];
1309 if (k == output_vector_flat_direction_index)
1310 skiped_dims_size_t[k] = skiped_dims_size_t[k] * output_vector_size;
1311 data_overlap_size_t[k] = data_overlap_size[k];
1312 skiped_chunk_size_t[k] = skiped_chunk_size[k];
1316 data_size_p = skiped_dims_size_t;
1317 data_chunk_size_p = skiped_chunk_size_t;
1318 data_overlap_size_p = data_overlap_size_t;
1323 if (vector_type_flag == 0)
1325 data_size_p = data_size;
1326 data_chunk_size_p = data_chunk_size;
1327 data_overlap_size_p = data_overlap_size;
1332 std::vector<unsigned long long> dims_size_t;
1333 std::vector<int> chunk_size_t;
1334 std::vector<int> data_overlap_size_t;
1336 if (output_vector_flat_direction_index > (data_dims - 1))
1338 data_dims_t = data_dims + 1;
1339 dims_size_t.resize(data_dims_t);
1340 chunk_size_t.resize(data_dims_t);
1341 data_overlap_size_t.resize(data_dims_t);
1342 for (
int k = 0; k < data_dims; k++)
1344 dims_size_t[k] = data_size[k];
1345 chunk_size_t[k] = data_chunk_size[k];
1346 data_overlap_size_t[k] = data_overlap_size[k];
1348 dims_size_t[data_dims] = output_vector_size;
1349 data_overlap_size_t[data_dims] = 0;
1350 chunk_size_t[data_dims] = output_vector_size;
1354 data_dims_t = data_dims;
1355 dims_size_t.resize(data_dims_t);
1356 chunk_size_t.resize(data_dims_t);
1357 data_overlap_size_t.resize(data_dims_t);
1358 for (
int k = 0; k < data_dims; k++)
1360 dims_size_t[k] = data_size[k];
1361 if (k == output_vector_flat_direction_index)
1362 dims_size_t[k] = dims_size_t[k] * output_vector_size;
1364 chunk_size_t[k] = data_chunk_size[k];
1365 data_overlap_size_t[k] = data_overlap_size[k];
1369 data_size_p = dims_size_t;
1370 data_chunk_size_p = chunk_size_t;
1371 data_overlap_size_p = data_overlap_size_t;
1376 int inline CreateEndpoint(std::vector<unsigned long long> data_size_p, std::vector<int> data_chunk_size_p, std::vector<int> data_overlap_size_p)
1378 if (!virtual_array_flag && endpoint->
GetOpenFlag())
1381 if (is_endpoint_created_flag)
1385 is_endpoint_created_flag =
true;
1387 data_size = data_size_p;
1388 data_chunk_size = data_chunk_size_p;
1389 data_overlap_size = data_overlap_size_p;
1391 if (virtual_array_flag)
1393 for (
int i = 0; i < attribute_endpoint_vector.size(); i++)
1395 if (attribute_endpoint_vector[i]->GetOpenFlag())
1397 attribute_endpoint_vector[i]->SetDimensions(data_size);
1398 attribute_endpoint_vector[i]->Create();
1399 attribute_endpoint_vector[i]->Close();
1408 return endpoint->
Create();
1412 int ReadArray(
const std::vector<unsigned long long> &start,
const std::vector<unsigned long long> &end, std::vector<T> &data_vector)
1415 unsigned long long data_vector_size;
1419 data_vector.resize(data_vector_size);
1420 if (!virtual_array_flag)
1422 endpoint->
Read(start, end, &data_vector[0]);
1426 int n = attribute_endpoint_vector.size();
1427 std::vector<AuEndpointDataTypeUnion> current_chunk_data_union_vector;
1428 for (
int i = 0; i < n; i++)
1430 int element_type_size = attribute_endpoint_vector[i]->GetDataElementTypeSize();
1431 void *current_chunk_data_temp = (
void *)malloc(data_vector_size * element_type_size);
1432 if (!current_chunk_data_temp)
1436 attribute_endpoint_vector[i]->Read(start, end, current_chunk_data_temp);
1437 current_chunk_data_union_vector = attribute_endpoint_vector[i]->Void2Union(current_chunk_data_temp, data_vector_size);
1439 free(current_chunk_data_temp);
1444 inline std::vector<T>
ReadArray(
const std::vector<unsigned long long> start,
const std::vector<unsigned long long> end)
1446 std::vector<T> data_vector;
1453 if (current_chunk_id >= data_total_chunks || current_chunk_id < 0)
1468 prev_chunk_id = current_chunk_id;
1470 if (!reverse_apply_direction_flag)
1472 current_chunk_id = current_chunk_id +
ft_size;
1476 current_chunk_id = current_chunk_id -
ft_size;
1496 if (current_chunk_id == (data_total_chunks - 1) && skip_not_aligned_w_array_flag)
1497 is_the_last_chunk =
true;
1499 result_vector_size = 0;
1501 current_chunk_cells = 1;
1502 current_result_chunk_cells = 1;
1503 current_chunk_ol_cells = 1;
1506 std::vector<unsigned long long> chunk_coordinate =
RowMajorOrderReverse(current_chunk_id, data_chunked_size);
1507 std::vector<unsigned long long> skiped_chunk_coordinate;
1512 for (
int i = 0; i < data_dims; i++)
1514 if (data_chunk_size[i] * chunk_coordinate[i] < data_size[i])
1516 current_chunk_start_offset[i] = data_chunk_size[i] * chunk_coordinate[i];
1520 current_chunk_start_offset[i] = data_size[i];
1523 if (current_chunk_start_offset[i] + data_chunk_size[i] - 1 < data_size[i])
1525 current_chunk_end_offset[i] = current_chunk_start_offset[i] + data_chunk_size[i] - 1;
1529 current_chunk_end_offset[i] = data_size[i] - 1;
1532 assert((current_chunk_end_offset[i] - current_chunk_start_offset[i] + 1 >= 0));
1533 current_chunk_size[i] = current_chunk_end_offset[i] - current_chunk_start_offset[i] + 1;
1534 current_chunk_cells = current_chunk_cells * current_chunk_size[i];
1539 current_result_chunk_start_offset[i] = current_chunk_start_offset[i];
1540 current_result_chunk_end_offset[i] = current_chunk_end_offset[i];
1541 current_result_chunk_cells = current_chunk_cells;
1545 if (skiped_chunk_coordinate[i] * skiped_chunk_size[i] < skiped_dims_size[i])
1547 current_result_chunk_start_offset[i] = skiped_chunk_coordinate[i] * skiped_chunk_size[i];
1551 current_result_chunk_start_offset[i] = skiped_dims_size[i];
1554 if (current_result_chunk_start_offset[i] + skiped_chunk_size[i] - 1 < skiped_dims_size[i])
1556 current_result_chunk_end_offset[i] = current_result_chunk_start_offset[i] + skiped_chunk_size[i] - 1;
1560 current_result_chunk_end_offset[i] = skiped_dims_size[i] - 1;
1562 assert((current_result_chunk_end_offset[i] - current_result_chunk_start_offset[i] + 1 >= 0));
1563 current_result_chunk_cells = current_result_chunk_cells * (current_result_chunk_end_offset[i] - current_result_chunk_start_offset[i] + 1);
1568 if (current_chunk_start_offset[i] <= data_overlap_size[i])
1570 current_chunk_ol_start_offset[i] = 0;
1574 current_chunk_ol_start_offset[i] = current_chunk_start_offset[i] - data_overlap_size[i];
1577 ol_origin_offset[i] = current_chunk_start_offset[i] - current_chunk_ol_start_offset[i];
1580 if (current_chunk_end_offset[i] + data_overlap_size[i] < data_size[i])
1582 current_chunk_ol_end_offset[i] = current_chunk_end_offset[i] + data_overlap_size[i];
1586 current_chunk_ol_end_offset[i] = data_size[i] - 1;
1588 assert((current_chunk_ol_end_offset[i] - current_chunk_ol_start_offset[i] + 1 >= 0));
1589 current_chunk_ol_size[i] = current_chunk_ol_end_offset[i] - current_chunk_ol_start_offset[i] + 1;
1590 current_chunk_ol_cells = current_chunk_ol_cells * current_chunk_ol_size[i];
1593 current_chunk_data.resize(current_chunk_ol_cells);
1594 if (save_result_flag == 1)
1598 result_vector_size = current_chunk_cells;
1602 result_vector_size = current_result_chunk_cells;
1608 for (
int i = 0; i < data_dims; i++)
1610 current_chunk_ol_start_offset[i] = current_chunk_ol_start_offset[i] + view_start_offset[i];
1611 current_chunk_ol_end_offset[i] = current_chunk_ol_end_offset[i] + view_start_offset[i];
1624 if (!virtual_array_flag)
1626 endpoint->
Read(current_chunk_ol_start_offset, current_chunk_ol_end_offset, ¤t_chunk_data[0]);
1628 if (get_stencil_tag_flag)
1630 std::vector<std::string> stencil_tag_names;
1633 std::string tag_value;
1634 for (
int i = 0; i < stencil_tag_names.size(); i++)
1636 GetTag(stencil_tag_names[i], tag_value);
1637 stencil_metadata_map[stencil_tag_names[i]] = tag_value;
1646 int n = attribute_endpoint_vector.size();
1647 std::vector<AuEndpointDataTypeUnion> current_chunk_data_union_vector;
1648 for (
int i = 0; i < n; i++)
1650 int element_type_size = attribute_endpoint_vector[i]->GetDataElementTypeSize();
1651 void *current_chunk_data_temp = (
void *)malloc(current_chunk_ol_cells * element_type_size);
1652 if (!current_chunk_data_temp)
1656 attribute_endpoint_vector[i]->Read(current_chunk_ol_start_offset, current_chunk_ol_end_offset, current_chunk_data_temp);
1657 current_chunk_data_union_vector = attribute_endpoint_vector[i]->Void2Union(current_chunk_data_temp, current_chunk_ol_cells);
1659 free(current_chunk_data_temp);
1672 skip_size = skip_size_p;
1679 output_vector_flat_direction_index = flat_direction_index;
1690 output_vector_flat_direction_index = flat_direction;
1691 output_vector_flat_shape = flat_shape;
1694 template <
typename... Is>
1697 std::vector<int> iv{{indexs...}};
1698 std::vector<unsigned long long> start;
1699 std::vector<unsigned long long> end;
1700 std::vector<T> data_v;
1702 start.resize(iv.size());
1703 end.resize(iv.size());
1704 data_v.resize(iv.size());
1706 for (
int i = 0; i < iv.size(); i++)
1712 endpoint->
Read(start, end,
static_cast<void *
>(data_v.data()));
1723 template <
typename... Is>
1726 std::vector<int> iv{{indexs...}};
1727 std::vector<unsigned long long> start;
1728 std::vector<unsigned long long> end;
1730 start.resize(iv.size());
1731 end.resize(iv.size());
1733 for (
int i = 0; i < iv.size(); i++)
1739 if (virtual_array_flag == 0)
1741 std::vector<T> data_v;
1743 endpoint->
Read(start, end,
static_cast<void *
>(data_v.data()));
1748 std::vector<T> data_v;
1754 template <
typename... Is>
1757 std::vector<int> iv{{indexs...}};
1758 std::vector<unsigned long long> start;
1759 std::vector<unsigned long long> end;
1760 std::vector<T> data_v;
1762 start.resize(iv.size());
1763 end.resize(iv.size());
1767 for (
int i = 0; i < iv.size(); i++)
1772 if (!is_endpoint_created_flag)
1777 endpoint->
Write(start, end,
static_cast<void *
>(data_v.data()));
1780 template <
class AttributeType>
1783 if (attribute_endpoint_vector.size() == 0)
1784 virtual_array_flag =
true;
1789 endpoint_memory_flag =
true;
1792 if (attribute_endpoint_vector.size() == 0)
1794 endpoint = attribute_endpoint;
1796 attribute_endpoint_vector.push_back(attribute_endpoint);
1799 template <
class AttributeType>
1802 if (attribute_endpoint_vector.size() == 0)
1803 virtual_array_flag =
true;
1808 endpoint_memory_flag =
true;
1809 attribute_endpoint_vector.push_back(attribute_endpoint);
1810 attribute_array_data_endpoint_info.push_back(data_endpoint);
1818 template <
class AttributeType>
1821 if (attribute_endpoint_vector.size() == 0)
1822 virtual_array_flag =
true;
1826 attribute_endpoint_vector.insert(attribute_endpoint_vector.begin() + index, attribute_endpoint);
1827 attribute_array_data_endpoint_info.insert(attribute_array_data_endpoint_info.begin() + index, data_endpoint);
1829 endpoint_memory_flag =
true;
1839 if (attribute_endpoint_vector[index] != NULL)
1841 delete attribute_endpoint_vector[index];
1843 attribute_endpoint_vector.erase(attribute_endpoint_vector.begin() + index);
1844 attribute_array_data_endpoint_info.erase(attribute_array_data_endpoint_info.begin() + index);
1850 if (index < attribute_array_data_endpoint_info.size())
1852 endpoint_id = attribute_array_data_endpoint_info[index];
1860 return attribute_endpoint_vector;
1865 return virtual_array_flag;
1870 virtual_array_flag =
true;
1875 dir_output_regex = regex_p;
1876 dir_output_replace_str = replace_str_p;
1881 dir_input_regex = regex_p;
1886 if (!virtual_array_flag)
1892 return attribute_endpoint_vector[0]->GetEndpointType();
1918 data_chunk_size = data_chunk_size_p;
1924 data_chunk_size_p = data_chunk_size;
1929 std::vector<int> data_chunk_size_p;
1931 return data_chunk_size_p;
1936 set_chunk_size_by_mem_flag =
true;
1937 set_chunk_size_by_mem_max_mem_size = max_mem_size;
1943 chunk_size_by_user_by_dimension_flag =
true;
1944 data_auto_chunk_dim_index = dim_rank;
1950 if (endpoint != NULL)
1968 if (endpoint != NULL)
1972 rank = data_size.size();
2007 std::string endpoint_info;
2011 if (endpoint_memory_flag ==
true && target_endpoint_type ==
EP_HDF5)
2013 std::vector<std::string> arg_v;
2014 arg_v.push_back(endpoint_info);
2015 ret = endpoint->
Control(0, arg_v);
2019 AU_EXIT(
"Nonvolatile: only support MEMORY to HDF5 now!");
2026 return Backup(data_endpoint_p);
2037 std::string target_array_data_endpoint_info = data_endpoint_p;
2042 std::vector<std::string> arg_v;
2044 ret = endpoint->
Control(1, arg_v);
2048 AU_EXIT(
"Volatile: only support HDF5 to MEMORY now!");
2066 std::vector<std::string> intial_value_str;
2067 intial_value_str.push_back(std::to_string(intial_value));
2081 std::vector<std::string> op_str;
2089 std::vector<std::string> op_str;
2090 op_str.push_back(std::to_string(Op));
2105 unsigned long long total_size = 1;
2106 std::vector<unsigned long long> start_p(data_size.size());
2107 std::vector<unsigned long long> end_p(data_size.size());
2109 for (
int i = 0; i < data_size.size(); i++)
2112 end_p[i] = data_size[i] - 1;
2113 total_size = total_size * data_size[i];
2115 std::vector<T> default_value_v(total_size, fill_value);
2116 endpoint->
Write(start_p, end_p,
static_cast<void *
>(default_value_v.data()));
2124 array_data_endpoint_info = endpoint_id;
2131 endpoint_memory_flag =
true;
2140 endpoint_id = array_data_endpoint_info;
2152 return endpoint->
Control(cmd_p, arg_v_p);
2157 std::vector<std::string> arg_v_p;
2158 return endpoint->
Control(cmd_p, arg_v_p);
2169 std::vector<double> mpi_stats_read, mpi_stats_udf, mpi_stats_write;
2176 std::cout <<
"Timing Results of All " << std::endl;
2177 std::cout <<
"Read time (s) : max = " << mpi_stats_read[0] <<
", min = " << mpi_stats_read[1] <<
", ave = " << mpi_stats_read[2] /
ft_size << std::endl;
2178 std::cout <<
"UDF time (s) : max = " << mpi_stats_udf[0] <<
", min = " << mpi_stats_udf[1] <<
", ave = " << mpi_stats_udf[2] /
ft_size << std::endl;
2179 std::cout <<
"Write time (s) : max = " << mpi_stats_write[0] <<
", min = " << mpi_stats_write[1] <<
", ave = " << mpi_stats_write[2] /
ft_size << std::endl;
2192 cost_stats[2] = cost_stats[2] /
ft_size;
2199 cost_stats[2] = cost_stats[2] /
ft_size;
2205 cost_stats[2] = cost_stats[2] /
ft_size;
2217 template <
class PType>
2218 int SetTag(
const std::string &name,
const PType value)
2222 return endpoint->
WriteAttribute(name, &value, data_element_type, 1);
2225 int SetTag(
const std::string &name,
const std::string value)
2230 template <
class PType>
2231 int SetTag(
const std::string &name,
const std::vector<PType> value)
2234 return endpoint->
WriteAttribute(name, &value[0], data_element_type, value.size());
2244 template <
class PType>
2245 int GetTag(
const std::string &name, PType &value)
2248 return endpoint->
ReadAttribute(name, &value, data_element_type);
2251 int GetTag(
const std::string &name, std::string &value)
2258 value.resize(str_len);
2262 template <
class PType>
2263 int GetTag(
const std::string &name, std::vector<PType> &value)
2267 value.resize(vec_len);
2268 return endpoint->
ReadAttribute(name, &value[0], data_element_type, value.size());
2303 std::vector<std::string> arg_v_p;
2309 AU_EXIT(
"FT only supports Create XDMF on HDF5 now !\n");
2318 std::vector<std::string> arg_v_p;
2324 AU_EXIT(
"FT only supports Create XDMF on HDF5 now !\n");
2334 set_direct_output_flag =
true;
2339 get_stencil_tag_flag =
true;
static Endpoint * NewEndpoint(std::string endpoint)
create a normal endpoint
Definition: ft_endpoint_factory.h:98
Define the class for the Endpoint used by ArrayUDF to store the data. It contains basic infomation fo...
Definition: ft_endpoint.h:106
virtual int ReadAttribute(const std::string &name, void *data, FTDataType data_type_p, const size_t &data_length_p=0)
Get the Attribute object Do not need to be pure virtual method.
Definition: ft_endpoint.cpp:474
bool GetOpenFlag()
Definition: ft_endpoint.cpp:151
virtual int Read(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data)=0
read the data from end-point
virtual int ExtractMeta()=0
extracts metadata, possbile endpoint_ranks/endpoint_dim_size/other ep_type dependents ones
virtual int Write(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data)=0
write the data to the end-point
std::string GetEndpointInfo()
Get the endpoint_info string.
Definition: ft_endpoint.cpp:345
virtual void EnableCollectiveIO()
Definition: ft_endpoint.cpp:427
virtual std::vector< int > GetDirChunkSize()
Get the Dir Chunk Size object.
Definition: ft_endpoint.cpp:387
void SetDataElementType(AuEndpointDataType data_element_type_p)
set the type of data element
Definition: ft_endpoint.cpp:104
void SetDimensions(std::vector< unsigned long long > endpoint_dim_size_p)
Set the Dimensions.
Definition: ft_endpoint.cpp:97
virtual std::vector< std::string > GetDirFileVector()
Get the Dir File Vector object.
Definition: ft_endpoint.cpp:370
virtual void SetDirChunkSize(std::vector< int > &dir_chunk_size_p)
Set the Dir Chunk Size object.
Definition: ft_endpoint.cpp:397
virtual int Control(int opt_code, std::vector< std::string > ¶meter_v)
call a special operator on endpoint such as, enable collective I/O for HDF5 dump file from MEMORY to ...
Definition: ft_endpoint.cpp:421
virtual void SetDirFileVector(std::vector< std::string > &file_list)
Set the Dir File Vector object.
Definition: ft_endpoint.cpp:377
virtual int Create()=0
create the endpoint
virtual int GetAttributeSize(const std::string &name, FTDataType data_type_p)
Definition: ft_endpoint.cpp:480
virtual int WriteAttribute(const std::string &name, const void *data, FTDataType data_type_p, const size_t &data_length_p=0)
Set the Attribute object Do not need to be pure virtual method.
Definition: ft_endpoint.cpp:461
std::vector< unsigned long long > GetDimensions()
Get the Dimensions of the data.
Definition: ft_endpoint.cpp:87
virtual int PrintInfo()=0
print information about the endpoint
virtual void DisableCollectiveIO()
Definition: ft_endpoint.cpp:431
AuEndpointType GetEndpointType()
Get the Endpoint Type object.
Definition: ft_endpoint.cpp:365
the object to the ArrayBase
Definition: ft_array.h:146
virtual int EnableApplyStride(const std::vector< int > &skip_size_p)=0
virtual int SetOverlapSize(const vector< int > os_p)=0
virtual int SetChunkSize(std::vector< int > data_chunk_size_p)=0
virtual int GetArraySize(std::vector< unsigned long long > &size_p)=0
virtual int GetTag(const std::string &name, std::string &value)=0
virtual void SetVectorDirection(OutputVectorFlatDirection flat_direction_index)=0
virtual int ControlEndpoint(int cmd_p, std::vector< std::string > &arg_v_p)=0
virtual int ControlEndpoint(int cmd_p)=0
virtual int GetStencilTag()=0
virtual void ReportCost()=0
virtual ~ArrayBase()=default
Definition: ft_array.h:163
int GetAllTagName(std::vector< string > &tag_name)
Definition: ft_array.h:2271
int SyncOverlap()
Definition: ft_array.h:576
int EndpointControl(int cmd_p, std::vector< std::string > &arg_v_p)
Definition: ft_array.h:2162
int GetChunkSize(std::vector< int > &data_chunk_size_p)
Definition: ft_array.h:1922
T operator()(Is... indexs) const
Definition: ft_array.h:1695
void Transform(Stencil< UDFOutputType >(*UDF)(const Stencil< T > &), Array< BType > &B)
Definition: ft_array.h:771
int ControlEndpoint(int cmd_p)
Definition: ft_array.h:2155
int WriteArray(const std::vector< unsigned long long > &start_p, const std::vector< unsigned long long > &end_p, std::vector< T > &data_p)
Definition: ft_array.h:1104
int ControlEndpoint(int cmd_p, std::vector< std::string > &arg_v_p)
pass command cmd to Endpoint of Array
Definition: ft_array.h:2150
int SetDirectOutput()
Definition: ft_array.h:2332
int CreateVisFile(FTVisType vis_type)
Definition: ft_array.h:2299
int SetChunkSize(std::vector< int > data_chunk_size_p)
Definition: ft_array.h:1916
Array(std::vector< T > &data_vector_endpoint, std::vector< int > cs, std::vector< int > os)
Construct a new Array object.
Definition: ft_array.h:442
int SetOverlapPadding(const T &padding_value_p)
Definition: ft_array.h:569
std::vector< std::string > GetDirFile()
Definition: ft_array.h:1896
void ReportCost()
Definition: ft_array.h:2167
int EnableApplyStride(const std::vector< int > &skip_size_p)
Definition: ft_array.h:1665
int AppendAttribute(const std::string &data_endpoint)
Definition: ft_array.h:1800
int SetTag(const std::string &name, const std::vector< PType > value)
Definition: ft_array.h:2231
int SetChunkSizeByDim(int dim_rank)
Definition: ft_array.h:1941
void SchduleChunkNext()
update current_chunk_id
Definition: ft_array.h:1466
int WriteEndpoint(std::vector< unsigned long long > &start_p, std::vector< unsigned long long > &end_p, void *data)
Definition: ft_array.h:1177
void SetVirtualArrayFlag(bool flag_p)
Definition: ft_array.h:1868
void ControlOutputVector(OutputVectorFlatDirection flat_direction, std::vector< size_t > flat_shape)
A geneic verion of function to control how to deal with output vector during the run of Apply on Arra...
Definition: ft_array.h:1688
int UpdateOverlap()
Definition: ft_array.h:2328
void DisableCollectiveIO()
merge below to EndpointControl
Definition: ft_array.h:2283
void SetDirFile(std::vector< std::string > &file_list)
Definition: ft_array.h:1901
int Clone(T intial_value)
create a local mirror (clone) of array with the inital value
Definition: ft_array.h:2064
int Volatile(std::string data_endpoint_p)
Definition: ft_array.h:2053
std::vector< int > GetChunkSize()
Definition: ft_array.h:1927
int EraseAttribute(const int &index)
Definition: ft_array.h:1837
int GetStencilTag()
Definition: ft_array.h:2337
std::vector< Endpoint * > GetAttributeEndpoint()
Definition: ft_array.h:1858
void InitializeApplyInput(Stencil< UDFOutputType >(*UDF)(const Stencil< T > &))
Definition: ft_array.h:620
int SetArraySize(const std::vector< unsigned long long > &size_p)
Definition: ft_array.h:1960
Array(std::string data_endpoint, std::vector< int > cs)
Construct a new Array object for read, as Input of Apply.
Definition: ft_array.h:313
AuEndpointType GetEndpointType()
Definition: ft_array.h:1884
void UpdateChunkSize()
Update the chunk size, given chunk_size_by_user_flag/chunk_size_by_user_by_dimension_flag.
Definition: ft_array.h:466
~Array()
Construct a new Array object from in-memory vector The data are assumed to be 1D too here.
Definition: ft_array.h:451
void SetVectorDirection(OutputVectorFlatDirection flat_direction_index)
Definition: ft_array.h:1677
void SetDirChunkSize(std::vector< int > &dir_chunk_size_p)
Definition: ft_array.h:1911
int GetReadCost(vector< double > &cost_stats)
Definition: ft_array.h:2189
Array(std::string data_endpoint, int auto_chunk_dim_index)
Construct a new Array object for read, as Input of Apply.
Definition: ft_array.h:366
int ReadModifyWriteArray(const std::vector< unsigned long long > &start_p, const std::vector< unsigned long long > &end_p, std::vector< T > &data_p, AU_Op op)
Test a new API to read modfy and write a array. It is useful for cases that you have a incremently up...
Definition: ft_array.h:1140
int SetStride(const std::vector< int > &skip_size_p)
Definition: ft_array.h:1670
void InferOutputSize(std::vector< unsigned long long > &data_size_p, std::vector< int > &data_chunk_size_p, std::vector< int > &data_overlap_size_p, size_t output_vector_size)
infer the size for output array
Definition: ft_array.h:1267
int SetTag(const std::string &name, const std::string value)
Definition: ft_array.h:2225
int CreateEndpoint(std::vector< unsigned long long > data_size_p, std::vector< int > data_chunk_size_p, std::vector< int > data_overlap_size_p)
Definition: ft_array.h:1376
int SetOverlapSize(const vector< int > os_p)
Definition: ft_array.h:554
std::vector< int > GetDirChunkSize()
Definition: ft_array.h:1906
int CreateVisFile()
Definition: ft_array.h:2313
void SetDirOutputRegexReplace(std::regex ®ex_p, std::string &replace_str_p)
Definition: ft_array.h:1873
void CalculateOutputSize(std::vector< unsigned long long > &data_size_p, std::vector< int > &data_chunk_size_p, std::vector< int > &data_overlap_size_p)
Calculate the Size of Output array (B)
Definition: ft_array.h:1197
int GetArrayRank(int &rank)
Definition: ft_array.h:1966
Array(std::vector< int > cs)
Definition: ft_array.h:420
Array(std::vector< T > &data_vector_endpoint)
Construct a new Array object from in-memory vector The data are assumed to be 1D too here.
Definition: ft_array.h:431
int GetWriteCost(vector< double > &cost_stats)
Definition: ft_array.h:2196
int WriteArray(std::vector< unsigned long long > &start_p, std::vector< unsigned long long > &end_p, std::vector< std::vector< T >> data_p)
Definition: ft_array.h:1171
int GetOverlapSize(vector< int > &os_p)
Definition: ft_array.h:564
void PushBackAttribute(std::string data_endpoint)
Definition: ft_array.h:1781
Array(std::string data_endpoint)
Construct a new Array object for either Input or Output For Input, data_endpoint is opened before App...
Definition: ft_array.h:293
int InsertAttribute(const std::string &data_endpoint, const int index)
Definition: ft_array.h:1819
void SetDirInputRegexSearch(std::regex ®ex_p)
Definition: ft_array.h:1879
Array(std::string data_endpoint, std::vector< unsigned long long > size_p)
Construct a new Array object for read, as Input of Apply.
Definition: ft_array.h:389
int Nonvolatile(std::string data_endpoint_p)
Definition: ft_array.h:2024
void EnableCollectiveIO()
Definition: ft_array.h:2291
int Merge(int Op)
Definition: ft_array.h:2087
int Fill(T fill_value)
Fill the array with value (only on rank 0)
Definition: ft_array.h:2101
void Apply(Stencil< UDFOutputType >(*UDF)(const Stencil< T > &), Array< BType > *B=nullptr)
Run a UDF on the data pointed by the array.
Definition: ft_array.h:765
int Restore(std::string data_endpoint_p)
load HDF5 array to IN_MEMORY array
Definition: ft_array.h:2035
Array()
Construct a new Array object for Write The data can be cached or dumped later.
Definition: ft_array.h:279
void PrintEndpointInfo()
print endpoint info of this array
Definition: ft_array.h:743
int GetEndpoint(string &endpoint_id)
Definition: ft_array.h:2138
int SetEndpoint(const string &endpoint_id)
Definition: ft_array.h:2122
int Clone()
create a local miroor (clone of array) without intial value so, it needs to copy the whole array
Definition: ft_array.h:2078
int GetTag(const std::string &name, PType &value)
Get the Attribute object.
Definition: ft_array.h:2245
void SetValue(T data_p, Is... indexs)
Definition: ft_array.h:1755
bool HasNextChunk()
Definition: ft_array.h:1451
int GetTag(const std::string &name, std::string &value)
Definition: ft_array.h:2251
int SetTag(const std::string &name, const PType value)
Set the Attribute object.
Definition: ft_array.h:2218
int ReadEndpoint(std::vector< unsigned long long > &start_p, std::vector< unsigned long long > &end_p, void *data)
Definition: ft_array.h:1185
void ReportTime()
Definition: ft_array.h:2184
int ReadArray(const std::vector< unsigned long long > &start, const std::vector< unsigned long long > &end, std::vector< T > &data_vector)
Definition: ft_array.h:1412
std::vector< T > ReadArray(const std::vector< unsigned long long > start, const std::vector< unsigned long long > end)
Definition: ft_array.h:1444
int GetArraySize(std::vector< unsigned long long > &size_p)
Definition: ft_array.h:1948
void Transform(Stencil< UDFOutputType >(*UDF)(const Stencil< T > &), Array< BType > *B=nullptr)
Run a UDF on the data pointed by the array.
Definition: ft_array.h:792
int GetComputingCost(vector< double > &cost_stats)
Definition: ft_array.h:2202
int GetTag(const std::string &name, std::vector< PType > &value)
Definition: ft_array.h:2263
int SetOverlapSizeByDetection()
Definition: ft_array.h:559
int GetAttribute(const int &index, std::string &endpoint_id)
Definition: ft_array.h:1848
T GetValue(Is... indexs)
Get the Value at indexs.
Definition: ft_array.h:1724
int Backup(std::string data_endpoint_p)
write data to another endpoint type, e.g., HDF5 in disk
Definition: ft_array.h:2001
int UpdateOverlapSize(Stencil< UDFOutputType >(*UDF)(const Stencil< T > &))
Definition: ft_array.h:592
bool GetVirtualArrayFlag()
Definition: ft_array.h:1863
int SetChunkSizeByMem(size_t max_mem_size)
Definition: ft_array.h:1934
Array(std::string data_endpoint, std::vector< int > cs, std::vector< int > os)
Construct a new Array object for read, as Input of Apply.
Definition: ft_array.h:341
Array(std::vector< int > cs, std::vector< int > os)
Construct a new Array object with only chunk size and overlap size Mostly, this is used for virtual a...
Definition: ft_array.h:414
int LoadNextChunk(unsigned long long &result_vector_size)
Load the next chunk.
Definition: ft_array.h:1488
Definition: ft_stencil.h:100
void SetLocation(unsigned long long my_offset, std::vector< unsigned long long > &my_coordinate, std::vector< unsigned long long > &my_location_no_ol_p, std::vector< unsigned long long > &chunk_dim_size_no_ol_p, std::vector< long long > ol_origin_offset_p, std::vector< unsigned long long > current_chunk_ol_size)
Definition: ft_stencil.h:946
int SetTagMap(std::map< std::string, std::string > &stencil_tag_map_p)
Definition: ft_stencil.h:1231
void SetChunkID(unsigned long long chunk_id_p)
Definition: ft_stencil.h:1226
void SetPadding(T padding_value_p)
Set the Padding object.
Definition: ft_stencil.h:1139
int GetShape(std::vector< size_t > &shape_p)
Get the Output Vector Shape object.
Definition: ft_stencil.h:1172
bool HasTagMap() const
Definition: ft_stencil.h:1245
T get_value()
Get the value object.
Definition: ft_stencil.h:864
int GetTagMap(std::map< std::string, std::string > &stencil_tag_map_p) const
Definition: ft_stencil.h:1239
int GetTrailRunResult(std::vector< int > &overlap_size_p)
Definition: ft_stencil.h:1051
int ft_rank
Definition: ft.cpp:86
std::vector< Endpoint * > endpoint_to_clean_vector
Definition: ft.cpp:90
int ft_size
Definition: ft.cpp:85
#define OP_CREATE_VIS_SCRIPT
Definition: ft_endpoint.h:96
#define OP_LIST_TAG
Definition: ft_endpoint.h:97
#define MEMORY_SYNC_OVERLAP
Definition: ft_endpoint_memory.h:104
#define DASH_ENABLE_LOCAL_MIRROR_CODE
Definition: ft_endpoint_memory.h:97
#define DASH_MERGE_MIRRORS_CODE
Definition: ft_endpoint_memory.h:98
double t_start
Definition: ft_example_stack.cpp:116
#define AU_SUM
Definition: ft_merge.h:92
int AU_Op
Definition: ft_merge.h:88
#define AU_WTIME_TYPE
Definition: ft_mpi.h:92
void MPIReduceStats(const T local_value, std::vector< T > &stats_vector)
get max/min/sum of local_value
Definition: ft_mpi.h:247
#define AU_WTIME
Definition: ft_mpi.h:93
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.
Definition: ft_output_vector.h:187
AuEndpointType
Definition: ft_type.h:95
@ EP_MEMORY
Definition: ft_type.h:101
@ EP_HDF5
Definition: ft_type.h:96
@ EP_DIR
Definition: ft_type.h:103
OutputVectorFlatDirection
Definition: ft_type.h:212
AuEndpointDataType
Definition: ft_type.h:118
@ AU_STRING
Definition: ft_type.h:131
int ExtractEndpointTypeInfo(std::string endpoint_type_info, AuEndpointType &endpoint_type, std::string &endpoint_info)
Split endpoint_type_info string to type and information.
Definition: ft_utility.cpp:100
void * ExtractAttributeFromVirtualArrayVector(std::vector< T2 > &virtual_array_vector, int attribute_index, AuEndpointDataType element_type, int element_type_size)
Definition: ft_utility.h:403
void PrintVector(std::string name, std::vector< T > v)
Definition: ft_utility.h:165
std::vector< unsigned long long > RowMajorOrderReverse(unsigned long long offset, std::vector< unsigned long long > dsize)
convert linearized coordinate to multidimensional one
Definition: ft_utility.h:276
void InsertAttribute2VirtualArrayVector(const std::vector< T1 > &attribute_vector, AuEndpointDataType union_index, std::vector< T2 > &virtual_array_vector, int attribute_index)
Definition: ft_utility.h:303
void PrintScalar(std::string name, T v)
Definition: ft_utility.h:237
#define ROW_MAJOR_ORDER_REVERSE_MACRO(offset, dsize, dsize_len, result_coord_v)
Definition: ft_utility_macro.h:135
#define ROW_MAJOR_ORDER_MACRO(dsize, dsize_len, coordinate, offset)
macro version of above two functions for speed
Definition: ft_utility_macro.h:124
#define AU_EXIT(info)
Definition: ft_utility_macro.h:147
#define COUNT_CELLS(start_address_p, end_address_p, cells_count_p)
help function to counts cells between start/end
Definition: ft_utility_macro.h:92
FTVisType
Definition: ft_vis.h:84
@ FT_VIS_XDMF
Definition: ft_vis.h:86
Definition: ft_array.h:113