openCARP
Doxygen code documentation for the open cardiac electrophysiology simulator openCARP
async_io.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) NumeriCor GmbH
2 // SPDX-License-Identifier: LicenseRef-APL-1.1
3 
12 #ifndef _ASYNC_IO_H
13 #define _ASYNC_IO_H
14 
15 namespace opencarp {
16 namespace async {
17 
18 #define ASYNC_TAG 1001
19 
20 #define ASYNC_CMD_EXIT 1
21 #define ASYNC_CMD_REGISTER_OUTPUT 2
22 #define ASYNC_CMD_OUTPUT 3
23 
26  int loc_rank = 0;
27  int loc_size = 0;
28  int rem_size = 0;
29 
31  inline void setup(MPI_Comm ic)
32  {
33  loc_rank = get_rank();
34  loc_size = get_size();
36  }
37 };
38 
46 
48  inline int add(IGBheader* igb,
49  const SF::vector<long int> & lt,
50  const SF::commgraph<size_t> & c,
51  const SF::vector<mesh_int_t> & pb,
52  const SF::vector<mesh_int_t> & pa)
53  {
54  int id = cg.size();
55 
56  IGBs .push_back(igb);
57  layouts.push_back(lt);
58  cg .push_back(c);
59  perm_b .push_back(pb);
60  perm_a .push_back(pa);
61 
62  return id;
63  }
64 };
65 
66 // functions used by IO nodes
67 void IO_poll_for_output(async_IO_queue & io_queue);
68 void IO_register_output(async_IO_queue & io_queue);
69 void IO_get_sender_ranks(const intercomm_layout & il, SF::vector<int> & sender);
70 void IO_prepare_sort(const SF::vector<mesh_int_t> & inp_idx,
71  SF::commgraph<size_t> & grph,
72  SF::vector<mesh_int_t> & perm_before_comm,
73  SF::vector<mesh_int_t> & perm_after_comm);
74 void IO_do_output(async_IO_queue & io_queue);
75 
76 
77 // functions used by COMPUTE nodes
79  const int dpn,
80  const char* name,
81  const char* units);
83 int COMPUTE_get_receive_rank(const intercomm_layout & il);
84 void COMPUTE_do_output(SF_real* data, const int lsize, const int IO_id);
85 void COMPUTE_do_output(SF_real* dat, const SF::vector<mesh_int_t> & idx, const int IO_id);
86 
87 }}
88 
89 #endif
opencarp::real_t SF_real
Global scalar type.
Definition: SF_globals.h:18
The class holds the communication graph for a MPI_Exchange() call.
Definition: SF_container.h:623
A vector storing arbitrary data.
Definition: SF_vector.h:28
size_t size() const
The current size of the vector.
Definition: SF_vector.h:89
T & push_back(T val)
Definition: SF_vector.h:268
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:134
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:305
void IO_do_output(async_IO_queue &io_queue)
Definition: async_io.cc:336
void COMPUTE_send_exit_flag()
this function sends the exit flag from a compute node to an io node.
Definition: async_io.cc:79
void COMPUTE_do_output(SF_real *dat, const int lsize, const int IO_id)
Definition: async_io.cc:381
int COMPUTE_get_receive_rank(const intercomm_layout &il)
get the IO node rank that will receive our data chunk
Definition: async_io.cc:289
void IO_poll_for_output(async_IO_queue &io_queue)
Definition: async_io.cc:21
int COMPUTE_register_output(const SF::vector< mesh_int_t > &idx, const int dpn, const char *name, const char *units)
Definition: async_io.cc:89
void IO_register_output(async_IO_queue &io_queue)
Definition: async_io.cc:228
std::map< int, std::string > units
Definition: stimulate.cc:26
int get_remote_size(MPI_Comm intercomm)
Definition: basics.h:292
int get_rank(MPI_Comm comm=PETSC_COMM_WORLD)
Definition: basics.h:269
int get_size(MPI_Comm comm=PETSC_COMM_WORLD)
Definition: basics.h:283
queue with the data required for performing async IO writes to IGB
Definition: async_io.h:40
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:48
SF::vector< IGBheader * > IGBs
IGBs with open filehandles on rank 0.
Definition: async_io.h:41
SF::vector< SF::vector< long int > > layouts
data layouts
Definition: async_io.h:42
SF::vector< SF::vector< mesh_int_t > > perm_b
permutation before MPI_Exchange
Definition: async_io.h:44
SF::vector< SF::vector< mesh_int_t > > perm_a
permutation after MPI_Exchange
Definition: async_io.h:45
SF::vector< SF::commgraph< size_t > > cg
commgraphs for MPI_Exchange
Definition: async_io.h:43
minimal information needed for communication between MPI_Comms
Definition: async_io.h:25
int loc_size
the local communicator size
Definition: async_io.h:27
int rem_size
the remote communicator size
Definition: async_io.h:28
void setup(MPI_Comm ic)
setup routine for the members
Definition: async_io.h:31
int loc_rank
the local rank
Definition: async_io.h:26