Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9366babcae4de4d2986a30854a1b89d2fa82f4c7
[simgrid.git] / examples / c / app-chainsend / chainsend.h
1 /* Copyright (c) 2012-2022. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef CHAINSEND_H
8 #define CHAINSEND_H
9
10 #include "simgrid/actor.h"
11 #include "simgrid/comm.h"
12 #include "simgrid/engine.h"
13 #include "simgrid/host.h"
14 #include "simgrid/instr.h"
15 #include "simgrid/mailbox.h"
16
17 #include "xbt/log.h"
18 #include "xbt/str.h"
19 #include "xbt/sysdep.h"
20
21 /* Connection parameters */
22 #define MAX_PENDING_COMMS 256
23 #define PIECE_SIZE 65536
24 #define MESSAGE_BUILD_CHAIN_SIZE 40
25 #define MESSAGE_SEND_DATA_HEADER_SIZE 1
26
27 /* Broadcaster struct */
28 typedef struct s_broadcaster {
29   unsigned int host_count;
30   unsigned int piece_count;
31   sg_mailbox_t first;
32   sg_mailbox_t* mailboxes;
33   sg_comm_t* pending_sends;
34 } s_broadcaster_t;
35
36 typedef s_broadcaster_t* broadcaster_t;
37 typedef const s_broadcaster_t* const_broadcaster_t;
38 void broadcaster(int argc, char* argv[]);
39
40 /* Message struct */
41 typedef struct s_chain_message {
42   sg_mailbox_t prev_;
43   sg_mailbox_t next_;
44   unsigned int num_pieces;
45 } s_chain_message_t;
46
47 typedef s_chain_message_t* chain_message_t;
48
49 /* Peer struct */
50 typedef struct s_peer {
51   sg_mailbox_t prev;
52   sg_mailbox_t next;
53   sg_mailbox_t me;
54   unsigned long long received_bytes;
55   unsigned int received_pieces;
56   unsigned int total_pieces;
57   sg_comm_t* pending_recvs;
58   sg_comm_t* pending_sends;
59 } s_peer_t;
60
61 typedef s_peer_t* peer_t;
62 void peer(int argc, char* argv[]);
63
64 #endif /* CHAINSEND_H */