xref: /petsc/src/dm/impls/swarm/data_ex.h (revision d2ebda5dc63913b1e21b49d168148e9df5e6b3bc)
1095059a4SDave May 
2095059a4SDave May #ifndef __DATA_EXCHANGER_H__
3095059a4SDave May #define __DATA_EXCHANGER_H__
4095059a4SDave May 
5095059a4SDave May 
6095059a4SDave May #include <petsc.h>
7095059a4SDave May #include <petscvec.h>
8095059a4SDave May #include <petscmat.h>
9095059a4SDave May 
10095059a4SDave May typedef enum { DEOBJECT_INITIALIZED=0, DEOBJECT_FINALIZED, DEOBJECT_STATE_UNKNOWN } DEObjectState;
11095059a4SDave May 
12095059a4SDave May typedef struct _p_DataEx* DataEx;
13095059a4SDave May struct  _p_DataEx {
14095059a4SDave May 	PetscInt    instance;
15095059a4SDave May 	MPI_Comm    comm;
16095059a4SDave May 	PetscMPIInt rank;
17095059a4SDave May 
18095059a4SDave May 	PetscMPIInt  n_neighbour_procs;
19095059a4SDave May 	PetscMPIInt *neighbour_procs; /* [n_neighbour_procs] */
20095059a4SDave May 	PetscInt    *messages_to_be_sent; /* [n_neighbour_procs] */
21095059a4SDave May 	PetscInt    *message_offsets; /* [n_neighbour_procs] */
22095059a4SDave May 	PetscInt    *messages_to_be_recvieved; /* [n_neighbour_procs] */
23095059a4SDave May 	size_t       unit_message_size;
24095059a4SDave May 	void        *send_message;
25095059a4SDave May 	PetscInt     send_message_length;
26095059a4SDave May 	void        *recv_message;
27095059a4SDave May 	PetscInt     recv_message_length;
28095059a4SDave May 	int         *send_tags, *recv_tags;
29095059a4SDave May 	PetscInt     total_pack_cnt;
30095059a4SDave May 	PetscInt    *pack_cnt; /* [n_neighbour_procs] */
31095059a4SDave May 	DEObjectState     topology_status;
32095059a4SDave May 	DEObjectState     message_lengths_status;
33095059a4SDave May 	DEObjectState     packer_status;
34095059a4SDave May 	DEObjectState     communication_status;
35095059a4SDave May 
36095059a4SDave May 	MPI_Status  *_stats;
37095059a4SDave May 	MPI_Request *_requests;
38095059a4SDave May };
39095059a4SDave May 
40095059a4SDave May 
41095059a4SDave May /* OBJECT_STATUS */
42*d2ebda5dSSatish Balay /* #define OBJECT_INITIALIZED    0 */
43*d2ebda5dSSatish Balay /* #define OBJECT_FINALIZED      1 */
44*d2ebda5dSSatish Balay /* #define OBJECT_STATE_UNKNOWN  2 */
45095059a4SDave May 
46095059a4SDave May extern const char *status_names[];
47095059a4SDave May 
48521f74f9SMatthew G. Knepley PetscErrorCode DataExCreate(MPI_Comm comm,const PetscInt count, DataEx *);
49095059a4SDave May PetscErrorCode DataExView(DataEx d);
50095059a4SDave May PetscErrorCode DataExDestroy(DataEx d);
51095059a4SDave May PetscErrorCode DataExTopologyInitialize(DataEx d);
52095059a4SDave May PetscErrorCode DataExTopologyAddNeighbour(DataEx d,const PetscMPIInt proc_id);
53095059a4SDave May PetscErrorCode DataExTopologyFinalize(DataEx d);
54095059a4SDave May PetscErrorCode DataExInitializeSendCount(DataEx de);
55095059a4SDave May PetscErrorCode DataExAddToSendCount(DataEx de,const PetscMPIInt proc_id,const PetscInt count);
56095059a4SDave May PetscErrorCode DataExFinalizeSendCount(DataEx de);
57095059a4SDave May PetscErrorCode DataExPackInitialize(DataEx de,size_t unit_message_size);
58095059a4SDave May PetscErrorCode DataExPackData(DataEx de,PetscMPIInt proc_id,PetscInt n,void *data);
59095059a4SDave May PetscErrorCode DataExPackFinalize(DataEx de);
60095059a4SDave May PetscErrorCode DataExBegin(DataEx de);
61095059a4SDave May PetscErrorCode DataExEnd(DataEx de);
62095059a4SDave May PetscErrorCode DataExGetSendData(DataEx de,PetscInt *length,void **send);
63095059a4SDave May PetscErrorCode DataExGetRecvData(DataEx de,PetscInt *length,void **recv);
64095059a4SDave May PetscErrorCode DataExTopologyGetNeighbours(DataEx de,PetscMPIInt *n,PetscMPIInt *neigh[]);
65095059a4SDave May 
66095059a4SDave May 
67095059a4SDave May #endif
68095059a4SDave May 
69