-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathpcu_msg.h
70 lines (59 loc) · 2.21 KB
/
pcu_msg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/******************************************************************************
Copyright 2011 Scientific Computation Research Center,
Rensselaer Polytechnic Institute. All rights reserved.
This work is open source software, licensed under the terms of the
BSD license as described in the LICENSE file in the top-level directory.
*******************************************************************************/
#ifndef PCU_MSG_H
#define PCU_MSG_H
#include "pcu_coll.h"
#include "pcu_aa.h"
#include "pcu_io.h"
#ifdef __cplusplus
extern "C" {
#endif
/* the PCU Messenger (pcu_msg for short) system implements
a non-blocking Bulk Synchronous Parallel communication model
it is based on PCU non-blocking Collectives and pcu_mpi,
so it also works in hybrid mode */
/* a structure containing all data to be sent to a peer during
this communication phase. */
typedef struct
{
pcu_aa_node node; //binary tree node for lookup
pcu_message message; //send buffer and peer id
} pcu_msg_peer;
struct pcu_order_struct;
struct pcu_msg_struct
{
pcu_aa_tree peers; //binary tree of send buffers
pcu_message received; //current received buffer
pcu_coll coll; //collective operation object
int state; //state within a communication phase
/* below this point are variables that just need
to be thread-specific but have been tacked onto
pcu_msg. if this gets out of hand, create a
pcu_thread struct to or something */
FILE* file; //messenger-unique input or output file
struct pcu_order_struct* order;
};
typedef struct pcu_msg_struct pcu_msg;
void pcu_make_msg(pcu_msg* m);
void pcu_msg_start(pcu_mpi_t*, pcu_msg* b);
void* pcu_msg_pack(pcu_msg* m, int id, size_t size);
#define PCU_MSG_PACK(m,id,o) \
memcpy(pcu_msg_pack(m,id,sizeof(o)),&(o),sizeof(o))
size_t pcu_msg_packed(pcu_msg* m, int id);
void pcu_msg_send(pcu_mpi_t *mpi, pcu_msg* m);
bool pcu_msg_receive(pcu_mpi_t* mpi, pcu_msg* m);
void* pcu_msg_unpack(pcu_msg* m, size_t size);
#define PCU_MSG_UNPACK(m,o) \
memcpy(&(o),pcu_msg_unpack(m,sizeof(o)),sizeof(o))
bool pcu_msg_unpacked(pcu_msg* m);
int pcu_msg_received_from(pcu_msg* m);
size_t pcu_msg_received_size(pcu_msg* m);
void pcu_free_msg(pcu_msg* m);
#ifdef __cplusplus
}
#endif
#endif //PCU_MSG_H