forked from efficient/rdma_bench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.c
60 lines (48 loc) · 1.77 KB
/
master.c
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
#include "hrd.h"
#include "main.h"
/* Random local_hids for master */
#define MASTER_P0_ID -22
#define MASTER_P1_ID -23
void* run_master(void* arg) {
int i;
struct thread_params params = *(struct thread_params*)arg;
struct hrd_ctrl_blk* cb[2]; /* 1 control block per port */
for (i = 0; i < 2; i++) {
cb[i] = hrd_ctrl_blk_init(MASTER_P0_ID, (params.dual_port == 0 ? 0 : i % 2),
0, /* port index, numa node*/
NUM_CLIENTS / 2, USE_UC, /* conn qps, uc */
NULL, RR_SIZE,
MASTER_SHM_KEY + i, /* prealloc buf, size, key */
0, 0, -1); /* #dgram qps, buf size, shm key */
/* Zero out the request buffers */
memset((void*)cb[i]->conn_buf, 0, RR_SIZE);
}
for (i = 0; i < NUM_CLIENTS; i++) {
char mstr_qp_name[HRD_QP_NAME_SIZE];
sprintf(mstr_qp_name, "master-%d", i);
hrd_publish_conn_qp(cb[i % 2], i / 2, mstr_qp_name);
}
for (i = 0; i < NUM_CLIENTS; i++) {
char clt_conn_qp_name[HRD_QP_NAME_SIZE];
sprintf(clt_conn_qp_name, "client-conn-%d", i);
struct hrd_qp_attr* clt_qp = NULL;
while (clt_qp == NULL) {
clt_qp = hrd_get_published_qp(clt_conn_qp_name);
if (clt_qp == NULL) {
usleep(200000);
}
}
printf("main: Master found client %s! Connecting..\n", clt_conn_qp_name);
hrd_connect_qp(cb[i % 2], i / 2, clt_qp);
char mstr_qp_name[HRD_QP_NAME_SIZE];
sprintf(mstr_qp_name, "master-%d", i);
hrd_publish_ready(mstr_qp_name);
}
/*
* Wait until the sun rises in the west and sets in the east. Until the
* rivers run dry, and the mountains blow in the wind like leaves...
*/
printf("main: Master sleeping\n");
sleep(1000000);
return NULL;
}