This source file includes following definitions.
- send_callback
- main
1 #include "orte_config.h"
2
3 #include <stdio.h>
4 #include <signal.h>
5 #include <math.h>
6 #include <sys/time.h>
7
8 #include "opal/runtime/opal_progress.h"
9
10 #include "orte/util/proc_info.h"
11 #include "orte/util/name_fns.h"
12 #include "orte/runtime/orte_globals.h"
13 #include "orte/mca/rml/rml.h"
14 #include "orte/mca/errmgr/errmgr.h"
15
16 #include "orte/runtime/runtime.h"
17 #include "orte/runtime/orte_wait.h"
18
19 #define MY_TAG 12345
20 #define MAX_COUNT 3
21
22 static bool msg_recvd;
23 static volatile bool msg_active;
24
25 static void send_callback(int status, orte_process_name_t *peer,
26 opal_buffer_t* buffer, orte_rml_tag_t tag,
27 void* cbdata)
28
29 {
30 OBJ_RELEASE(buffer);
31 if (ORTE_SUCCESS != status) {
32 exit(1);
33 }
34 msg_active = false;
35 }
36
37
38 int
39 main(int argc, char *argv[]){
40 int count;
41 int msgsize;
42 uint8_t *msg;
43 int i, j, rc;
44 orte_process_name_t peer;
45 double maxpower;
46 opal_buffer_t *buf;
47 orte_rml_recv_cb_t blob;
48 struct timeval start, end;
49
50
51
52 orte_init(&argc, &argv, ORTE_PROC_NON_MPI);
53
54 if (argc > 1) {
55 count = atoi(argv[1]);
56 if (count < 0) {
57 count = INT_MAX-1;
58 }
59 } else {
60 count = MAX_COUNT;
61 }
62
63 peer.jobid = ORTE_PROC_MY_NAME->jobid;
64 peer.vpid = ORTE_PROC_MY_NAME->vpid + 1;
65 if (peer.vpid == orte_process_info.num_procs) {
66 peer.vpid = 0;
67 }
68
69 gettimeofday(&start,NULL);
70 for (j=1; j < count+1; j++) {
71
72 if (ORTE_PROC_MY_NAME->vpid == 0) {
73
74 buf = OBJ_NEW(opal_buffer_t);
75
76 maxpower = (double)(j%7);
77 msgsize = (int)pow(10.0, maxpower);
78 opal_output(0, "Ring %d message size %d bytes", j, msgsize);
79 msg = (uint8_t*)malloc(msgsize);
80 opal_dss.pack(buf, msg, msgsize, OPAL_BYTE);
81 free(msg);
82 orte_rml.send_buffer_nb(&peer, buf, MY_TAG, orte_rml_send_callback, NULL);
83
84
85 OBJ_CONSTRUCT(&blob, orte_rml_recv_cb_t);
86 blob.active = true;
87 orte_rml.recv_buffer_nb(ORTE_NAME_WILDCARD, MY_TAG,
88 ORTE_RML_NON_PERSISTENT,
89 orte_rml_recv_callback, &blob);
90 ORTE_WAIT_FOR_COMPLETION(blob.active);
91 OBJ_DESTRUCT(&blob);
92
93 opal_output(0, "%s Ring %d completed", ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), j);
94 } else {
95
96 OBJ_CONSTRUCT(&blob, orte_rml_recv_cb_t);
97 blob.active = true;
98 orte_rml.recv_buffer_nb(ORTE_NAME_WILDCARD, MY_TAG,
99 ORTE_RML_NON_PERSISTENT,
100 orte_rml_recv_callback, &blob);
101 ORTE_WAIT_FOR_COMPLETION(blob.active);
102
103
104 buf = OBJ_NEW(opal_buffer_t);
105 opal_dss.copy_payload(buf, &blob.data);
106 OBJ_DESTRUCT(&blob);
107 msg_active = true;
108 orte_rml.send_buffer_nb(&peer, buf, MY_TAG, send_callback, NULL);
109 ORTE_WAIT_FOR_COMPLETION(msg_active);
110 }
111 }
112 gettimeofday(&end,NULL);
113 printf("Total minutes = %d, Total seconds = %d\n",(end.tv_sec - start.tv_sec)/60,(end.tv_sec - start.tv_sec));
114
115 orte_finalize();
116
117 return 0;
118 }