-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMPWide.h
126 lines (99 loc) · 5.41 KB
/
MPWide.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**************************************************************
* This file is part of the MPWide communication library
*
* Written by Derek Groen with thanks going out to Steven Rieder,
* Simon Portegies Zwart, Joris Borgdorff, Hans Blom and Tomoaki Ishiyama.
* for questions, please send an e-mail to:
* MPWide is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* MPWide is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MPWide. If not, see <http://www.gnu.org/licenses/>.
* **************************************************************/
#include <iostream>
#include <cassert>
/* Enable/disable software-based packet pacing. */
#define MPW_PacingMode 1
char* MPW_DNSResolve(char* host);
char* MPW_DNSResolve(std::string host);
/* Enable/disable autotuning. Set before initialization. */
void MPW_setAutoTuning(bool b);
bool MPW_AutoTuning();
/* Print all connections. */
void MPW_Print();
/* Print the number of available streams. */
int MPW_NumChannels();
// Return path id or negative error value.
int MPW_CreatePathWithoutConnect(std::string host, int server_side_base_port, int streams_in_path);
int MPW_ConnectPath(int path_id, bool server_wait);
int MPW_CreatePath(std::string host, int server_side_base_port, int num_streams);
// Return 0 on success (negative on failure).
int MPW_DestroyPath(int path);
extern "C" {
int MPW_Send(char* sendbuf, long long int sendsize, int path);
int MPW_Recv(char* recvbuf, long long int recvsize, int path);
int MPW_SendRecv(char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize, int path);
// returns the size of the newly received data.
int MPW_DSendRecv(char* sendbuf, long long int sendsize, char* recvbuf, long long int maxrecvsize, int path);
}
/* Initialize MPWide. */
int MPW_Init(std::string* url, int* server_side_ports, int* client_side_ports, int num_channels);
int MPW_Init(std::string* url, int* server_side_ports, int num_channels); //this call omits client-side port binding.
int MPW_Init(std::string url, int port);
/* Set tcp window size. */
void MPW_setWin(int channel, int size);
void MPW_setPathWin(int path, int size);
/* Close channels. */
void MPW_CloseChannels(int* channels , int num_channels);
/* Close all sockets and free data structures related to the library. */
int MPW_Finalize();
/* Perform this using multiple channels. */
int MPW_PSendRecv(char** sendbuf, long long int* sendsize, char** recvbuf, long long int* recvsize, int* channel, int num_channels);
int MPW_SendRecv ( char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize, int* channel, int num_channels);
/* Dynamically-sized message exchanges. */
long long int MPW_DSendRecv(char* sendbuf, long long int sendsize, char* recvbuf, long long int maxrecvsize, int* channel, int num_channels);
/* Message relaying/forwarding for communication nodes. */
void MPW_Relay(int* channels, int* channels2, int num_channels);
/* Send data, receive nothing. */
void MPW_Send(char* buf, long long int size, int* channels, int num_channels);
/* Receive data. Will not return until the data is received. */
void MPW_Recv(char* buf, long long int size, int* channels, int num_channels);
/* Recv from one set of channels. Send out through the other set. */
long long int MPW_DCycle(char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize,
int* ch_send, int num_ch_send, int* ch_recv, int num_ch_recv);
void MPW_Cycle(char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize,
int* ch_send, int num_ch_send, int* ch_recv, int num_ch_recv);
/* Simple buffer splitting function. Handy for PSendRecv calls. */
void MPW_splitBuf(char* buf, long long int bsize, int num_chunks, char** split_buf, long long int* chunk_sizes);
/* Synchronyze two processes on one stream.
* TODO: Implement collective barrier which operates on all streams simultaneously. */
void MPW_Barrier(int channel);
/* Adjust the global feeding pace. */
void MPW_setChunkSize(int sending, int receiving);
/* Non-blocking functionalities. */
int MPW_ISendRecv( char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize, int path);
bool MPW_Has_NBE_Finished(int NBE_id);
void MPW_Wait(int NBE_id);
#if MPW_PacingMode == 1
/* Get and set rates for pacing data. */
extern "C" {
double MPW_getPacingRate();
void MPW_setPacingRate(double rate);
}
#endif
extern "C" {
int MPW_CreatePath_c (char* host, int server_side_base_port, int streams_in_path);
int MPW_Init_c (char** url, int* ports, int numsockets);
int MPW_Init1_c (char* url, int port);
void MPW_SendRecv1_c (char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize, int base_channel);
void MPW_SendRecv_c (char* sendbuf, long long int sendsize, char* recvbuf, long long int recvsize, int* base_channel, int num_channels);
void MPW_PSendRecv_c(char** sendbuf, long long int* sendsize, char** recvbuf, long long int* recvsize, int* channel, int num_channels);
}