openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
async_io.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // openCARP is an open cardiac electrophysiology simulator.
3 //
4 // Copyright (C) 2022 openCARP project
5 //
6 // This program is licensed under the openCARP Academic Public License (APL)
7 // v1.0: You can use and redistribute it and/or modify it in non-commercial
8 // academic environments under the terms of APL as published by the openCARP
9 // project v1.0, or (at your option) any later version. Commercial use requires
10 // a commercial license (info@opencarp.org).
11 //
12 // This program is distributed without any warranty; see the openCARP APL for
13 // more details.
14 //
15 // You should have received a copy of the openCARP APL along with this program
16 // and can find it online: http://www.opencarp.org/license
17 // ----------------------------------------------------------------------------
18 
27 #ifndef _ASYNC_IO_H
28 #define _ASYNC_IO_H
29 
30 namespace opencarp {
31 namespace async {
32 
33 #define ASYNC_TAG 1001
34 
35 #define ASYNC_CMD_EXIT 1
36 #define ASYNC_CMD_REGISTER_OUTPUT 2
37 #define ASYNC_CMD_OUTPUT 3
38 
41  int loc_rank = 0;
42  int loc_size = 0;
43  int rem_size = 0;
44 
46  inline void setup(MPI_Comm ic)
47  {
48  loc_rank = get_rank();
49  loc_size = get_size();
50  rem_size = get_remote_size(ic);
51  }
52 };
53 
61 
63  inline int add(IGBheader* igb,
64  const SF::vector<long int> & lt,
65  const SF::commgraph<size_t> & c,
66  const SF::vector<mesh_int_t> & pb,
67  const SF::vector<mesh_int_t> & pa)
68  {
69  int id = cg.size();
70 
71  IGBs .push_back(igb);
72  layouts.push_back(lt);
73  cg .push_back(c);
74  perm_b .push_back(pb);
75  perm_a .push_back(pa);
76 
77  return id;
78  }
79 };
80 
81 // functions used by IO nodes
82 void IO_poll_for_output(async_IO_queue & io_queue);
83 void IO_register_output(async_IO_queue & io_queue);
84 void IO_get_sender_ranks(const intercomm_layout & il, SF::vector<int> & sender);
85 void IO_prepare_sort(const SF::vector<mesh_int_t> & inp_idx,
86  SF::commgraph<size_t> & grph,
87  SF::vector<mesh_int_t> & perm_before_comm,
88  SF::vector<mesh_int_t> & perm_after_comm);
89 void IO_do_output(async_IO_queue & io_queue);
90 
91 
92 // functions used by COMPUTE nodes
94  const int dpn,
95  const char* name,
96  const char* units);
99 void COMPUTE_do_output(SF_real* data, const int lsize, const int IO_id);
100 void COMPUTE_do_output(SF_real* dat, const SF::vector<mesh_int_t> & idx, const int IO_id);
101 
102 }}
103 
104 #endif
minimal information needed for communication between MPI_Comms
Definition: async_io.h:40
int COMPUTE_get_receive_rank(const intercomm_layout &il)
get the IO node rank that will receive our data chunk
Definition: async_io.cc:304
void IO_register_output(async_IO_queue &io_queue)
Definition: async_io.cc:243
void IO_do_output(async_IO_queue &io_queue)
Definition: async_io.cc:351
void COMPUTE_send_exit_flag()
this function sends the exit flag from a compute node to an io node.
Definition: async_io.cc:94
void IO_poll_for_output(async_IO_queue &io_queue)
Definition: async_io.cc:36
T & push_back(T val)
Definition: SF_vector.h:283
SF::vector< SF::vector< mesh_int_t > > perm_a
permutation after MPI_Exchange
Definition: async_io.h:60
int loc_rank
the local rank
Definition: async_io.h:41
SF::vector< SF::vector< mesh_int_t > > perm_b
permutation before MPI_Exchange
Definition: async_io.h:59
void COMPUTE_do_output(SF_real *dat, const int lsize, const int IO_id)
Definition: async_io.cc:396
SF::vector< SF::vector< long int > > layouts
data layouts
Definition: async_io.h:57
int loc_size
the local communicator size
Definition: async_io.h:42
int COMPUTE_register_output(const SF::vector< mesh_int_t > &idx, const int dpn, const char *name, const char *units)
Definition: async_io.cc:104
int rem_size
the remote communicator size
Definition: async_io.h:43
int add(IGBheader *igb, const SF::vector< long int > &lt, const SF::commgraph< size_t > &c, const SF::vector< mesh_int_t > &pb, const SF::vector< mesh_int_t > &pa)
add one slice of IO info to the queue
Definition: async_io.h:63
SF::vector< SF::commgraph< size_t > > cg
commgraphs for MPI_Exchange
Definition: async_io.h:58
void IO_get_sender_ranks(const intercomm_layout &il, SF::vector< int > &sender)
get the compute node ranks that will send their data chunk to us
Definition: async_io.cc:320
void setup(MPI_Comm ic)
setup routine for the members
Definition: async_io.h:46
int get_remote_size(MPI_Comm intercomm)
Definition: basics.h:299
size_t size() const
The current size of the vector.
Definition: SF_vector.h:104
A vector storing arbitrary data.
Definition: SF_vector.h:42
std::map< int, std::string > units
Definition: stimulate.cc:41
double SF_real
Use the general double as real type.
Definition: SF_globals.h:38
int get_size(MPI_Comm comm=PETSC_COMM_WORLD)
Definition: basics.h:290
int get_rank(MPI_Comm comm=PETSC_COMM_WORLD)
Definition: basics.h:276
void IO_prepare_sort(const SF::vector< mesh_int_t > &inp_idx, SF::commgraph< size_t > &grph, SF::vector< mesh_int_t > &perm_before_comm, SF::vector< mesh_int_t > &perm_after_comm)
Definition: async_io.cc:149
SF::vector< IGBheader * > IGBs
IGBs with open filehandles on rank 0.
Definition: async_io.h:56
queue with the data required for performing async IO writes to IGB
Definition: async_io.h:55