FasTensor  1.0.0
Transform Supercomputing for AI
ft_endpoint_memory.h
Go to the documentation of this file.
1 
2 
3 /*
4 ****************************
5 
6 FasTensor (FT) Copyright (c) 2021, The Regents of the University of
7 California, through Lawrence Berkeley National Laboratory (subject to
8 receipt of any required approvals from the U.S. Dept. of Energy).
9 All rights reserved.
10 
11 If you have questions about your rights to use or distribute this software,
12 please contact Berkeley Lab's Intellectual Property Office at
14 
15 NOTICE. This Software was developed under funding from the U.S. Department
16 of Energy and the U.S. Government consequently retains certain rights. As
17 such, the U.S. Government has been granted for itself and others acting on
18 its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
19 Software to reproduce, distribute copies to the public, prepare derivative
20 works, and perform publicly and display publicly, and to permit others to do so.
21 
22 
23 ****************************
24 
25 
26 *** License Agreement ***
27 
28 FasTensor (FT) Copyright (c) 2021, The Regents of the University of
29 California, through Lawrence Berkeley National Laboratory (subject to
30 receipt of any required approvals from the U.S. Dept. of Energy).
31 All rights reserved.
32 
33 Redistribution and use in source and binary forms, with or without
34 modification, are permitted provided that the following conditions are met:
35 
36 (1) Redistributions of source code must retain the above copyright notice,
37 this list of conditions and the following disclaimer.
38 
39 (2) Redistributions in binary form must reproduce the above copyright
40 notice, this list of conditions and the following disclaimer in the
41 documentation and/or other materials provided with the distribution.
42 
43 (3) Neither the name of the University of California, Lawrence Berkeley
44 National Laboratory, U.S. Dept. of Energy nor the names of its contributors
45 may be used to endorse or promote products derived from this software
46 without specific prior written permission.
47 
48 
49 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
50 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
52 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
53 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
54 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
55 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
56 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
57 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
58 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59 POSSIBILITY OF SUCH DAMAGE.
60 
61 You are under no obligation whatsoever to provide any bug fixes, patches,
62 or upgrades to the features, functionality or performance of the source
63 code ("Enhancements") to anyone; however, if you choose to make your
64 Enhancements available either publicly, or directly to Lawrence Berkeley
65 National Laboratory, without imposing a separate written license agreement
66 for such Enhancements, then you hereby grant the following license: a
67 non-exclusive, royalty-free perpetual license to install, use, modify,
68 prepare derivative works, incorporate into other computer software,
69 distribute, and sublicense such enhancements or derivative works thereof,
70 in binary and source code form.
71 */
72 
82 #ifndef END_POINT_MEMORY_H
83 #define END_POINT_MEMORY_H
84 #include <string>
85 #include <iostream>
86 #include <vector>
87 #include "ft_type.h"
88 #include "ft_endpoint.h"
89 #include "ft_local_mirror.h"
90 #include "ft_endpoint_hdf5.h"
91 
92 #define DASH_READ_FLAG 0
93 #define DASH_WRITE_FLAG 1
94 
95 #define DASH_NONVOLATILE_CODE 0
96 #define DASH_VOLATILE_CODE 1
97 #define DASH_ENABLE_LOCAL_MIRROR_CODE 2
98 #define DASH_MERGE_MIRRORS_CODE 3
99 
100 #define MEMORY_BACKUP 0
101 #define MEMORY_RESTORE 1
102 #define MEMORY_CLONE 2
103 #define MEMORY_MERGE 3
104 #define MEMORY_SYNC_OVERLAP 4
105 
106 #ifdef HAS_DASH_ENDPOINT
107 
108 #include <unistd.h>
109 #include <iostream>
110 #include <cstddef>
111 #include <iomanip>
112 #include <libdash.h>
113 
114 using dash::io::hdf5::hdf5_options;
115 using dash::io::hdf5::StoreHDF;
116 
117 class EndpointMEMORY : public Endpoint
118 {
119 private:
120  void *dash_array_p;
121 
122  //For local mirror
123  void *local_mirror_buffer;
124  bool local_mirror_flag = false;
125  unsigned long long local_mirror_size;
126 
127 public:
133  EndpointMEMORY(std::string endpoint_info_p)
134  {
135  endpoint_info = endpoint_info_p;
137  SetOpenFlag(false);
139  SetCreateFlag(false);
140  }
146  {
147  SetOpenFlag(false);
149  SetCreateFlag(false);
150  }
151 
153  {
154  Close();
155  }
161  int ExtractMeta() override;
167  int PrintInfo() override;
168 
174  int Create() override;
175 
181  int Open() override;
182 
191  int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override;
192 
201  int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data) override;
202 
208  int Close() override;
209 
210  void Map2MyType() override;
211 
212  void EnableCollectiveIO() override;
213 
214  void DisableCollectiveIO() override;
215 
221  int ParseEndpointInfo() override;
222 
229  int Control(int opt_code, std::vector<std::string> &parameter_v) override;
230 
237  int Nonvolatile(std::string parameter);
238 
245  int Volatile(std::string parameter);
246 
252  int MergeMirrors(std::string op_str);
253 
259  int CreateLocalMirror(std::string init_value_str);
260 };
261 
262 #define CreateDashMatrix(dash_matrix_p_p, rank_const_p, element_type_code_p, array_size) \
263  { \
264  dash::SizeSpec<rank_const_p, unsigned long> dash_size_spec = dash::SizeSpec<rank_const_p, unsigned long>(); \
265  size_t num_units = dash::Team::All().size(); \
266  dash::TeamSpec<rank_const_p, unsigned long> teamspec; \
267  teamspec.balance_extents(); \
268  dash::DistributionSpec<rank_const_p> distspec; \
269  for (int i = 0; i < rank_const_p; i++) \
270  { \
271  dash_size_spec.resize(i, array_size[i]); \
272  } \
273  switch (element_type_code_p) \
274  { \
275  case AU_SHORT: \
276  { \
277  dash_matrix_p_p = new dash::Matrix<short, rank_const_p, unsigned long>(dash_size_spec); \
278  break; \
279  } \
280  case AU_INT: \
281  { \
282  dash_matrix_p_p = new dash::Matrix<int, rank_const_p, unsigned long>(dash_size_spec); \
283  break; \
284  } \
285  case AU_LONG: \
286  { \
287  dash_matrix_p_p = new dash::Matrix<long, rank_const_p, unsigned long>(dash_size_spec); \
288  break; \
289  } \
290  case AU_LONG_LONG: \
291  { \
292  dash_matrix_p_p = new dash::Matrix<long long, rank_const_p, unsigned long>(dash_size_spec); \
293  break; \
294  } \
295  case AU_USHORT: \
296  { \
297  dash_matrix_p_p = new dash::Matrix<unsigned short, rank_const_p, unsigned long>(dash_size_spec); \
298  break; \
299  } \
300  case AU_UINT: \
301  { \
302  dash_matrix_p_p = new dash::Matrix<unsigned int, rank_const_p, unsigned long>(dash_size_spec); \
303  break; \
304  } \
305  case AU_ULONG: \
306  { \
307  dash_matrix_p_p = new dash::Matrix<unsigned long, rank_const_p, unsigned long>(dash_size_spec); \
308  break; \
309  } \
310  case AU_ULLONG: \
311  { \
312  dash_matrix_p_p = new dash::Matrix<unsigned long long, rank_const_p, unsigned long>(dash_size_spec); \
313  break; \
314  } \
315  case AU_FLOAT: \
316  { \
317  dash_matrix_p_p = new dash::Matrix<float, rank_const_p, unsigned long>(dash_size_spec); \
318  break; \
319  } \
320  case AU_DOUBLE: \
321  { \
322  dash_matrix_p_p = new dash::Matrix<double, rank_const_p, unsigned long>(dash_size_spec); \
323  break; \
324  } \
325  case AU_DOUBLE_COMPLEX: \
326  { \
327  dash_matrix_p_p = new dash::Matrix<std::complex<double>, rank_const_p, unsigned long>(dash_size_spec); \
328  break; \
329  } \
330  default: \
331  AU_EXIT("Unsupported datatype in CreateDashMatrix !"); \
332  } \
333  }
334 
335 #define AccessDashData1D(dash_array_p_p, start_p, end_p, data_p, element_type_code_p, RW_flag) \
336  { \
337  switch (element_type_code_p) \
338  { \
339  case AU_SHORT: \
340  { \
341  dash::Matrix<short, 1, unsigned long> *dash_array_typed = (dash::Matrix<short, 1, unsigned long> *)dash_array_p_p; \
342  short *typed_data_p = (short *)data_p; \
343  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
344  { \
345  if (RW_flag == DASH_READ_FLAG) \
346  { \
347  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
348  } \
349  else \
350  { \
351  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
352  } \
353  } \
354  break; \
355  } \
356  case AU_INT: \
357  { \
358  dash::Matrix<int, 1, unsigned long> *dash_array_typed = (dash::Matrix<int, 1, unsigned long> *)dash_array_p_p; \
359  int *typed_data_p = (int *)data_p; \
360  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
361  { \
362  if (RW_flag == DASH_READ_FLAG) \
363  { \
364  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
365  } \
366  else \
367  { \
368  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
369  } \
370  } \
371  break; \
372  } \
373  case AU_LONG: \
374  { \
375  dash::Matrix<long, 1, unsigned long> *dash_array_typed = (dash::Matrix<long, 1, unsigned long> *)dash_array_p_p; \
376  long *typed_data_p = (long *)data_p; \
377  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
378  { \
379  if (RW_flag == DASH_READ_FLAG) \
380  { \
381  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
382  } \
383  else \
384  { \
385  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
386  } \
387  } \
388  break; \
389  } \
390  case AU_LONG_LONG: \
391  { \
392  dash::Matrix<long long, 1, unsigned long> *dash_array_typed = (dash::Matrix<long long, 1, unsigned long> *)dash_array_p_p; \
393  long long *typed_data_p = (long long *)data_p; \
394  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
395  { \
396  if (RW_flag == DASH_READ_FLAG) \
397  { \
398  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
399  } \
400  else \
401  { \
402  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
403  } \
404  } \
405  break; \
406  } \
407  case AU_USHORT: \
408  { \
409  dash::Matrix<unsigned short, 1, unsigned long> *dash_array_typed = (dash::Matrix<unsigned short, 1, unsigned long> *)dash_array_p_p; \
410  unsigned short *typed_data_p = (unsigned short *)data_p; \
411  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
412  { \
413  if (RW_flag == DASH_READ_FLAG) \
414  { \
415  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
416  } \
417  else \
418  { \
419  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
420  } \
421  } \
422  break; \
423  } \
424  case AU_UINT: \
425  { \
426  dash::Matrix<unsigned int, 1, unsigned long> *dash_array_typed = (dash::Matrix<unsigned int, 1, unsigned long> *)dash_array_p_p; \
427  unsigned int *typed_data_p = (unsigned int *)data_p; \
428  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
429  { \
430  if (RW_flag == DASH_READ_FLAG) \
431  { \
432  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
433  } \
434  else \
435  { \
436  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
437  } \
438  } \
439  break; \
440  } \
441  case AU_ULONG: \
442  { \
443  dash::Matrix<unsigned long, 1, unsigned long> *dash_array_typed = (dash::Matrix<unsigned long, 1, unsigned long> *)dash_array_p_p; \
444  unsigned long *typed_data_p = (unsigned long *)data_p; \
445  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
446  { \
447  if (RW_flag == DASH_READ_FLAG) \
448  { \
449  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
450  } \
451  else \
452  { \
453  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
454  } \
455  } \
456  break; \
457  } \
458  case AU_ULLONG: \
459  { \
460  dash::Matrix<unsigned long long, 1, unsigned long> *dash_array_typed = (dash::Matrix<unsigned long long, 1, unsigned long> *)dash_array_p_p; \
461  unsigned long long *typed_data_p = (unsigned long long *)data_p; \
462  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
463  { \
464  if (RW_flag == DASH_READ_FLAG) \
465  { \
466  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
467  } \
468  else \
469  { \
470  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
471  } \
472  } \
473  break; \
474  } \
475  case AU_FLOAT: \
476  { \
477  dash::Matrix<float, 1, unsigned long> *dash_array_typed = (dash::Matrix<float, 1, unsigned long> *)dash_array_p_p; \
478  float *typed_data_p = (float *)data_p; \
479  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
480  { \
481  if (RW_flag == DASH_READ_FLAG) \
482  { \
483  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
484  } \
485  else \
486  { \
487  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
488  } \
489  } \
490  break; \
491  } \
492  case AU_DOUBLE: \
493  { \
494  dash::Matrix<double, 1, unsigned long> *dash_array_typed = (dash::Matrix<double, 1, unsigned long> *)dash_array_p_p; \
495  double *typed_data_p = (double *)data_p; \
496  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
497  { \
498  if (RW_flag == DASH_READ_FLAG) \
499  { \
500  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
501  } \
502  else \
503  { \
504  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
505  } \
506  } \
507  break; \
508  } \
509  case AU_DOUBLE_COMPLEX: \
510  { \
511  dash::Matrix<std::complex<double>, 1, unsigned long> *dash_array_typed = (dash::Matrix<std::complex<double>, 1, unsigned long> *)dash_array_p_p; \
512  std::complex<double> *typed_data_p = (std::complex<double> *)data_p; \
513  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
514  { \
515  if (RW_flag == DASH_READ_FLAG) \
516  { \
517  typed_data_p[i - start_p[0]] = dash_array_typed->at(i); \
518  } \
519  else \
520  { \
521  dash_array_typed->at(i) = typed_data_p[i - start_p[0]]; \
522  } \
523  } \
524  break; \
525  } \
526  default: \
527  AU_EXIT("Unsupported datatype in AccessDashData !"); \
528  } \
529  }
530 
531 #define AccessDashData2D(dash_array_p_p, start_p, end_p, data_p, element_type_code_p, RW_flag) \
532  { \
533  unsigned long offset = 0; \
534  switch (element_type_code_p) \
535  { \
536  case AU_SHORT: \
537  { \
538  dash::Matrix<short, 2, unsigned long> *dash_array_typed = (dash::Matrix<short, 2, unsigned long> *)dash_array_p_p; \
539  short *typed_data_p = (short *)data_p; \
540  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
541  { \
542  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
543  { \
544  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
545  if (RW_flag == DASH_READ_FLAG) \
546  { \
547  typed_data_p[offset] = dash_array_typed->at(i, j); \
548  } \
549  else \
550  { \
551  dash_array_typed->at(i, j) = typed_data_p[offset]; \
552  } \
553  } \
554  } \
555  break; \
556  } \
557  case AU_INT: \
558  { \
559  dash::Matrix<int, 2, unsigned long> *dash_array_typed = (dash::Matrix<int, 2, unsigned long> *)dash_array_p_p; \
560  int *typed_data_p = (int *)data_p; \
561  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
562  { \
563  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
564  { \
565  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
566  if (RW_flag == DASH_READ_FLAG) \
567  { \
568  typed_data_p[offset] = dash_array_typed->at(i, j); \
569  } \
570  else \
571  { \
572  dash_array_typed->at(i, j) = typed_data_p[offset]; \
573  } \
574  } \
575  } \
576  break; \
577  } \
578  case AU_LONG: \
579  { \
580  dash::Matrix<long, 2, unsigned long> *dash_array_typed = (dash::Matrix<long, 2, unsigned long> *)dash_array_p_p; \
581  long *typed_data_p = (long *)data_p; \
582  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
583  { \
584  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
585  { \
586  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
587  if (RW_flag == DASH_READ_FLAG) \
588  { \
589  typed_data_p[offset] = dash_array_typed->at(i, j); \
590  } \
591  else \
592  { \
593  dash_array_typed->at(i, j) = typed_data_p[offset]; \
594  } \
595  } \
596  } \
597  break; \
598  } \
599  case AU_LONG_LONG: \
600  { \
601  dash::Matrix<long long, 2, unsigned long> *dash_array_typed = (dash::Matrix<long long, 2, unsigned long> *)dash_array_p_p; \
602  long long *typed_data_p = (long long *)data_p; \
603  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
604  { \
605  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
606  { \
607  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
608  if (RW_flag == DASH_READ_FLAG) \
609  { \
610  typed_data_p[offset] = dash_array_typed->at(i, j); \
611  } \
612  else \
613  { \
614  dash_array_typed->at(i, j) = typed_data_p[offset]; \
615  } \
616  } \
617  } \
618  break; \
619  } \
620  case AU_USHORT: \
621  { \
622  dash::Matrix<unsigned short, 2, unsigned long> *dash_array_typed = (dash::Matrix<unsigned short, 2, unsigned long> *)dash_array_p_p; \
623  unsigned short *typed_data_p = (unsigned short *)data_p; \
624  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
625  { \
626  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
627  { \
628  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
629  if (RW_flag == DASH_READ_FLAG) \
630  { \
631  typed_data_p[offset] = dash_array_typed->at(i, j); \
632  } \
633  else \
634  { \
635  dash_array_typed->at(i, j) = typed_data_p[offset]; \
636  } \
637  } \
638  } \
639  break; \
640  } \
641  case AU_UINT: \
642  { \
643  dash::Matrix<unsigned int, 2, unsigned long> *dash_array_typed = (dash::Matrix<unsigned int, 2, unsigned long> *)dash_array_p_p; \
644  unsigned int *typed_data_p = (unsigned int *)data_p; \
645  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
646  { \
647  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
648  { \
649  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
650  if (RW_flag == DASH_READ_FLAG) \
651  { \
652  typed_data_p[offset] = dash_array_typed->at(i, j); \
653  } \
654  else \
655  { \
656  dash_array_typed->at(i, j) = typed_data_p[offset]; \
657  } \
658  } \
659  } \
660  break; \
661  } \
662  case AU_ULONG: \
663  { \
664  dash::Matrix<unsigned long, 2, unsigned long> *dash_array_typed = (dash::Matrix<unsigned long, 2, unsigned long> *)dash_array_p_p; \
665  unsigned long *typed_data_p = (unsigned long *)data_p; \
666  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
667  { \
668  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
669  { \
670  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
671  if (RW_flag == DASH_READ_FLAG) \
672  { \
673  typed_data_p[offset] = dash_array_typed->at(i, j); \
674  } \
675  else \
676  { \
677  dash_array_typed->at(i, j) = typed_data_p[offset]; \
678  } \
679  } \
680  } \
681  break; \
682  } \
683  case AU_ULLONG: \
684  { \
685  dash::Matrix<unsigned long long, 2, unsigned long> *dash_array_typed = (dash::Matrix<unsigned long long, 2, unsigned long> *)dash_array_p_p; \
686  unsigned long long *typed_data_p = (unsigned long long *)data_p; \
687  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
688  { \
689  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
690  { \
691  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
692  if (RW_flag == DASH_READ_FLAG) \
693  { \
694  typed_data_p[offset] = dash_array_typed->at(i, j); \
695  } \
696  else \
697  { \
698  dash_array_typed->at(i, j) = typed_data_p[offset]; \
699  } \
700  } \
701  } \
702  break; \
703  } \
704  case AU_FLOAT: \
705  { \
706  dash::Matrix<float, 2, unsigned long> *dash_array_typed = (dash::Matrix<float, 2, unsigned long> *)dash_array_p_p; \
707  float *typed_data_p = static_cast<float *>(data_p); \
708  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
709  { \
710  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
711  { \
712  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
713  if (RW_flag == DASH_READ_FLAG) \
714  { \
715  typed_data_p[offset] = dash_array_typed->at(i, j); \
716  } \
717  else \
718  { \
719  dash_array_typed->at(i, j) = typed_data_p[offset]; \
720  } \
721  } \
722  } \
723  break; \
724  } \
725  case AU_DOUBLE: \
726  { \
727  dash::Matrix<double, 2, unsigned long> *dash_array_typed = (dash::Matrix<double, 2, unsigned long> *)dash_array_p_p; \
728  double *typed_data_p = (double *)data_p; \
729  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
730  { \
731  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
732  { \
733  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
734  if (RW_flag == DASH_READ_FLAG) \
735  { \
736  typed_data_p[offset] = dash_array_typed->at(i, j); \
737  } \
738  else \
739  { \
740  dash_array_typed->at(i, j) = typed_data_p[offset]; \
741  } \
742  } \
743  } \
744  break; \
745  } \
746  case AU_DOUBLE_COMPLEX: \
747  { \
748  dash::Matrix<std::complex<double>, 2, unsigned long> *dash_array_typed = (dash::Matrix<std::complex<double>, 2, unsigned long> *)dash_array_p_p; \
749  std::complex<double> *typed_data_p = (std::complex<double> *)data_p; \
750  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
751  { \
752  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
753  { \
754  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
755  if (RW_flag == DASH_READ_FLAG) \
756  { \
757  typed_data_p[offset] = dash_array_typed->at(i, j); \
758  } \
759  else \
760  { \
761  dash_array_typed->at(i, j) = typed_data_p[offset]; \
762  } \
763  } \
764  } \
765  break; \
766  } \
767  default: \
768  AU_EXIT("Unsupported datatype in AccessDashData !"); \
769  } \
770  }
771 
772 #define AccessDashData3D(dash_array_p_p, start_p, end_p, data_p, element_type_code_p, RW_flag) \
773  { \
774  unsigned long offset = 0; \
775  switch (element_type_code_p) \
776  { \
777  case AU_SHORT: \
778  { \
779  dash::Matrix<short, 3, unsigned long> *dash_array_typed = (dash::Matrix<short, 3, unsigned long> *)dash_array_p_p; \
780  short *typed_data_p = (short *)data_p; \
781  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
782  { \
783  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
784  { \
785  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
786  { \
787  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
788  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
789  if (RW_flag == DASH_READ_FLAG) \
790  { \
791  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
792  } \
793  else \
794  { \
795  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
796  } \
797  } \
798  } \
799  } \
800  break; \
801  } \
802  case AU_INT: \
803  { \
804  dash::Matrix<int, 3, unsigned long> *dash_array_typed = (dash::Matrix<int, 3, unsigned long> *)dash_array_p_p; \
805  int *typed_data_p = (int *)data_p; \
806  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
807  { \
808  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
809  { \
810  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
811  { \
812  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
813  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
814  if (RW_flag == DASH_READ_FLAG) \
815  { \
816  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
817  } \
818  else \
819  { \
820  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
821  } \
822  } \
823  } \
824  } \
825  break; \
826  } \
827  case AU_LONG: \
828  { \
829  dash::Matrix<long, 3, unsigned long> *dash_array_typed = (dash::Matrix<long, 3, unsigned long> *)dash_array_p_p; \
830  long *typed_data_p = (long *)data_p; \
831  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
832  { \
833  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
834  { \
835  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
836  { \
837  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
838  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
839  if (RW_flag == DASH_READ_FLAG) \
840  { \
841  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
842  } \
843  else \
844  { \
845  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
846  } \
847  } \
848  } \
849  } \
850  break; \
851  } \
852  case AU_LONG_LONG: \
853  { \
854  dash::Matrix<long long, 3, unsigned long> *dash_array_typed = (dash::Matrix<long long, 3, unsigned long> *)dash_array_p_p; \
855  long long *typed_data_p = (long long *)data_p; \
856  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
857  { \
858  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
859  { \
860  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
861  { \
862  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
863  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
864  if (RW_flag == DASH_READ_FLAG) \
865  { \
866  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
867  } \
868  else \
869  { \
870  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
871  } \
872  } \
873  } \
874  } \
875  break; \
876  } \
877  case AU_USHORT: \
878  { \
879  dash::Matrix<unsigned short, 3, unsigned long> *dash_array_typed = (dash::Matrix<unsigned short, 3, unsigned long> *)dash_array_p_p; \
880  unsigned short *typed_data_p = (unsigned short *)data_p; \
881  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
882  { \
883  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
884  { \
885  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
886  { \
887  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
888  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
889  if (RW_flag == DASH_READ_FLAG) \
890  { \
891  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
892  } \
893  else \
894  { \
895  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
896  } \
897  } \
898  } \
899  } \
900  break; \
901  } \
902  case AU_UINT: \
903  { \
904  dash::Matrix<unsigned int, 3, unsigned long> *dash_array_typed = (dash::Matrix<unsigned int, 3, unsigned long> *)dash_array_p_p; \
905  unsigned int *typed_data_p = (unsigned int *)data_p; \
906  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
907  { \
908  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
909  { \
910  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
911  { \
912  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
913  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
914  if (RW_flag == DASH_READ_FLAG) \
915  { \
916  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
917  } \
918  else \
919  { \
920  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
921  } \
922  } \
923  } \
924  } \
925  break; \
926  } \
927  case AU_ULONG: \
928  { \
929  dash::Matrix<unsigned long, 3, unsigned long> *dash_array_typed = (dash::Matrix<unsigned long, 3, unsigned long> *)dash_array_p_p; \
930  unsigned long *typed_data_p = (unsigned long *)data_p; \
931  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
932  { \
933  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
934  { \
935  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
936  { \
937  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
938  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
939  if (RW_flag == DASH_READ_FLAG) \
940  { \
941  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
942  } \
943  else \
944  { \
945  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
946  } \
947  } \
948  } \
949  } \
950  break; \
951  } \
952  case AU_ULLONG: \
953  { \
954  dash::Matrix<unsigned long long, 3, unsigned long> *dash_array_typed = (dash::Matrix<unsigned long long, 3, unsigned long> *)dash_array_p_p; \
955  unsigned long long *typed_data_p = (unsigned long long *)data_p; \
956  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
957  { \
958  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
959  { \
960  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
961  { \
962  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
963  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
964  if (RW_flag == DASH_READ_FLAG) \
965  { \
966  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
967  } \
968  else \
969  { \
970  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
971  } \
972  } \
973  } \
974  } \
975  break; \
976  } \
977  case AU_FLOAT: \
978  { \
979  dash::Matrix<float, 3, unsigned long> *dash_array_typed = (dash::Matrix<float, 3, unsigned long> *)dash_array_p_p; \
980  float *typed_data_p = (float *)data_p; \
981  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
982  { \
983  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
984  { \
985  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
986  { \
987  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
988  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
989  if (RW_flag == DASH_READ_FLAG) \
990  { \
991  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
992  } \
993  else \
994  { \
995  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
996  } \
997  } \
998  } \
999  } \
1000  break; \
1001  } \
1002  case AU_DOUBLE: \
1003  { \
1004  dash::Matrix<double, 3, unsigned long> *dash_array_typed = (dash::Matrix<double, 3, unsigned long> *)dash_array_p_p; \
1005  double *typed_data_p = (double *)data_p; \
1006  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
1007  { \
1008  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
1009  { \
1010  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
1011  { \
1012  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
1013  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
1014  if (RW_flag == DASH_READ_FLAG) \
1015  { \
1016  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
1017  } \
1018  else \
1019  { \
1020  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
1021  } \
1022  } \
1023  } \
1024  } \
1025  break; \
1026  } \
1027  case AU_DOUBLE_COMPLEX: \
1028  { \
1029  dash::Matrix<std::complex<double>, 3, unsigned long> *dash_array_typed = (dash::Matrix<std::complex<double>, 3, unsigned long> *)dash_array_p_p; \
1030  std::complex<double> *typed_data_p = (std::complex<double> *)data_p; \
1031  for (unsigned long i = start_p[0]; i <= end_p[0]; i++) \
1032  { \
1033  for (unsigned long j = start_p[1]; j <= end_p[1]; j++) \
1034  { \
1035  for (unsigned long k = start_p[2]; k <= end_p[2]; k++) \
1036  { \
1037  offset = (i - start_p[0]) * (end_p[1] - start_p[1] + 1) + (j - start_p[1]); \
1038  offset = offset * (end_p[2] - start_p[2] + 1) + (k - start_p[2]); \
1039  if (RW_flag == DASH_READ_FLAG) \
1040  { \
1041  typed_data_p[offset] = dash_array_typed->at(i, j, k); \
1042  } \
1043  else \
1044  { \
1045  dash_array_typed->at(i, j, k) = typed_data_p[offset]; \
1046  } \
1047  } \
1048  } \
1049  } \
1050  break; \
1051  } \
1052  default: \
1053  AU_EXIT("Unsupported datatype in AccessDashData !"); \
1054  } \
1055  }
1056 
1057 #else
1058 class EndpointMEMORY : public Endpoint
1059 {
1060 private:
1061 public:
1067  EndpointMEMORY(std::string endpoint_info_p)
1068  {
1069  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1070  AU_EXIT(-1);
1071  }
1077  {
1078  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1079  AU_EXIT(-1);
1080  }
1081 
1083  {
1084  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1085  AU_EXIT(-1);
1086  }
1093  {
1094  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1095  AU_EXIT(-1);
1096  }
1103  {
1104  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1105  AU_EXIT(-1);
1106  }
1107 
1113  int Create()
1114  {
1115  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1116  AU_EXIT(-1);
1117  }
1118 
1124  int Open()
1125  {
1126  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1127  AU_EXIT(-1);
1128  }
1129 
1138  int Read(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data)
1139  {
1140  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1141  AU_EXIT(-1);
1142  }
1151  int Write(std::vector<unsigned long long> start, std::vector<unsigned long long> end, void *data)
1152  {
1153  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1154  AU_EXIT(-1);
1155  }
1156 
1162  int Close()
1163  {
1164  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1165  AU_EXIT(-1);
1166  }
1167 
1168  void Map2MyType()
1169  {
1170  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1171  AU_EXIT(-1);
1172  }
1173 
1175  {
1176  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1177  AU_EXIT(-1);
1178  }
1179 
1181  {
1182  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1183  AU_EXIT(-1);
1184  }
1185 
1192  {
1193  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1194  AU_EXIT(-1);
1195  }
1196 
1203  int SpecialOperator(int opt_code, std::vector<std::string> parameter_v)
1204  {
1205  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1206  AU_EXIT(-1);
1207  }
1208 
1215  int Nonvolatile(std::string parameter)
1216  {
1217  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1218  AU_EXIT(-1);
1219  }
1220 
1227  int Volatile(std::string parameter)
1228  {
1229  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1230  AU_EXIT(-1);
1231  }
1232 
1238  int MergeMirrors(std::string op_str)
1239  {
1240  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1241  AU_EXIT(-1);
1242  }
1243 
1249  int CreateLocalMirror(std::string init_value_str)
1250  {
1251  std::cout << "EP_MEMORY is not configured and compiled ! \n";
1252  AU_EXIT(-1);
1253  }
1254 };
1255 
1256 #endif
1257 #endif
Define the class for the Endpoint used by ArrayUDF to store the data. It contains basic infomation fo...
Definition: ft_endpoint.h:106
void SetCreateFlag(bool open_flag_p)
Definition: ft_endpoint.cpp:166
void SetEndpointType(AuEndpointType endpoint_type_p)
Set the Endpoint Type object.
Definition: ft_endpoint.cpp:355
void SetOpenFlag(bool open_flag_p)
Definition: ft_endpoint.cpp:156
std::string endpoint_info
Definition: ft_endpoint.h:109
virtual int Control(int opt_code, std::vector< std::string > &parameter_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
Definition: ft_endpoint_memory.h:1059
int Write(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data)
write the data to the end-point
Definition: ft_endpoint_memory.h:1151
int Read(std::vector< unsigned long long > start, std::vector< unsigned long long > end, void *data)
read the data from end-point
Definition: ft_endpoint_memory.h:1138
int Create()
create the endpoint
Definition: ft_endpoint_memory.h:1113
EndpointMEMORY(std::string endpoint_info_p)
Construct a new EndpointMEMORY object.
Definition: ft_endpoint_memory.h:1067
int PrintInfo()
print information about the endpoint
Definition: ft_endpoint_memory.h:1102
void EnableCollectiveIO()
Definition: ft_endpoint_memory.h:1174
~EndpointMEMORY()
Definition: ft_endpoint_memory.h:1082
int SpecialOperator(int opt_code, std::vector< std::string > parameter_v)
call a special operator on endpoint to dump file from MEMORY to HDF5, or in verse
Definition: ft_endpoint_memory.h:1203
void Map2MyType()
call the finalize to close everything (like call Destractor)
Definition: ft_endpoint_memory.h:1168
int ParseEndpointInfo()
parse endpoint_info to my own info In MEMORY, it map endpoint_info to filename, group name and datase...
Definition: ft_endpoint_memory.h:1191
void DisableCollectiveIO()
Definition: ft_endpoint_memory.h:1180
EndpointMEMORY()
Construct a new Endpoint in MEMORY Nothing to do there, can be used as sub-endpoint of directory.
Definition: ft_endpoint_memory.h:1076
int MergeMirrors(std::string op_str)
Merger mirrors on all processes.
Definition: ft_endpoint_memory.h:1238
int Volatile(std::string parameter)
Volatile the data from HDF5 to MEMORY.
Definition: ft_endpoint_memory.h:1227
int ExtractMeta()
extracts metadata, possbile endpoint_ranks/endpoint_dim_size/data_element_type
Definition: ft_endpoint_memory.h:1092
int Nonvolatile(std::string parameter)
Nonvolatile the data in MEMORY to HDF5.
Definition: ft_endpoint_memory.h:1215
int Close()
close the end-point
Definition: ft_endpoint_memory.h:1162
int CreateLocalMirror(std::string init_value_str)
Create a Local Mirror object.
Definition: ft_endpoint_memory.h:1249
int Open()
open the endpoint
Definition: ft_endpoint_memory.h:1124
@ EP_MEMORY
Definition: ft_type.h:101
#define AU_EXIT(info)
Definition: ft_utility_macro.h:147