4
4
#include <string.h>
5
5
6
6
#include <sesstype/st_node.h>
7
+ #include <sesstype/st_node_print.h>
7
8
#include <scribble/print.h>
8
9
9
10
#include "scribble/mpi_print.h"
@@ -14,6 +15,13 @@ extern unsigned int mpi_primitive_count;
14
15
15
16
void mpi_fprint_allgather (FILE * pre_stream , FILE * stream , FILE * post_stream , st_tree * tree , st_node * node , int indent )
16
17
{
18
+ #ifdef __DEBUG__
19
+ fprintf (stderr , "INFO/%s:%d %s entry\nINFO/" , __FILE__ , __LINE__ , __FUNCTION__ );
20
+ st_node_fprint (stderr , node , indent );
21
+ #endif
22
+
23
+ assert (node != NULL );
24
+
17
25
// Variable declarations
18
26
mpi_fprintf (pre_stream , " int count%u = 1 /* CHANGE ME */;\n" , mpi_primitive_count );
19
27
@@ -53,8 +61,12 @@ void mpi_fprint_allgather(FILE *pre_stream, FILE *stream, FILE *post_stream, st_
53
61
54
62
void mpi_fprint_allreduce (FILE * pre_stream , FILE * stream , FILE * post_stream , st_tree * tree , st_node * node , int indent )
55
63
{
56
- assert (node != NULL && node -> type == ST_NODE_ALLREDUCE );
64
+ #ifdef __DEBUG__
65
+ fprintf (stderr , "INFO/%s:%d %s entry\nINFO/" , __FILE__ , __LINE__ , __FUNCTION__ );
66
+ st_node_fprint (stderr , node , indent );
67
+ #endif
57
68
69
+ assert (node != NULL && node -> type == ST_NODE_ALLREDUCE );
58
70
59
71
// Variable declarations
60
72
mpi_fprintf (pre_stream , " int count%u = 1 /* CHANGE ME */;\n" , mpi_primitive_count );
@@ -85,8 +97,12 @@ void mpi_fprint_allreduce(FILE *pre_stream, FILE *stream, FILE *post_stream, st_
85
97
86
98
void mpi_fprint_scatter (FILE * pre_stream , FILE * stream , FILE * post_stream , st_tree * tree , st_node * node , int indent )
87
99
{
88
- assert (node != NULL && node -> type == ST_NODE_RECV );
100
+ #ifdef __DEBUG__
101
+ fprintf (stderr , "INFO/%s:%d %s entry\nINFO/" , __FILE__ , __LINE__ , __FUNCTION__ );
102
+ st_node_fprint (stderr , node , indent );
103
+ #endif
89
104
105
+ assert (node != NULL && node -> type == ST_NODE_RECV );
90
106
91
107
// Variable declarations
92
108
mpi_fprintf (pre_stream , " int count%u = 1 /* CHANGE ME */;\n" , mpi_primitive_count );
@@ -114,7 +130,15 @@ void mpi_fprint_scatter(FILE *pre_stream, FILE *stream, FILE *post_stream, st_tr
114
130
if (param != 0 ) mpi_fprintf (stream , "," );
115
131
mpi_fprint_const_or_var (stream , tree , node -> interaction -> from -> param [param ]);
116
132
}
117
- mpi_fprintf (stream , "), MPI_COMM_WORLD);\n" );
133
+ if (is_role_in_group (node -> interaction -> msg_cond -> name , tree )) {
134
+ mpi_fprintf (stream , "), %s_comm);\n" , node -> interaction -> msg_cond -> name );
135
+ } else if (strcmp (node -> interaction -> msg_cond -> name , ST_ROLE_ALL ) == 0 ) {
136
+ mpi_fprintf (stream , "), MPI_COMM_WORLD);\n" );
137
+ } else {
138
+ fprintf (stderr , "ERROR/%s:%d %s Cannot determine communicator (inline group?), defaulting to MPI_COMM_WORLD\n" , __FILE__ , __LINE__ , __FUNCTION__ );
139
+ // TODO Inline group not given name
140
+ mpi_fprintf (stream , "), MPI_COMM_WORLD);\n" );
141
+ }
118
142
mpi_fprintf (stream , "#pragma pabble compute%u (buf%u, count%u)\n" , mpi_primitive_count , mpi_primitive_count , mpi_primitive_count );
119
143
120
144
mpi_fprintf (post_stream , " free(sbuf%u);\n" , mpi_primitive_count );
@@ -125,8 +149,12 @@ void mpi_fprint_scatter(FILE *pre_stream, FILE *stream, FILE *post_stream, st_tr
125
149
126
150
void mpi_fprint_gather (FILE * pre_stream , FILE * stream , FILE * post_stream , st_tree * tree , st_node * node , int indent )
127
151
{
128
- assert (node != NULL && node -> type == ST_NODE_SEND );
152
+ #ifdef __DEBUG__
153
+ fprintf (stderr , "INFO/%s:%d %s entry\nINFO/" , __FILE__ , __LINE__ , __FUNCTION__ );
154
+ st_node_fprint (stderr , node , indent );
155
+ #endif
129
156
157
+ assert (node != NULL && node -> type == ST_NODE_SEND );
130
158
131
159
// Variable declarations
132
160
mpi_fprintf (pre_stream , " int count%u = 1 /* CHANGE ME */;\n" , mpi_primitive_count );
@@ -162,7 +190,15 @@ void mpi_fprint_gather(FILE *pre_stream, FILE *stream, FILE *post_stream, st_tre
162
190
if (param != 0 ) mpi_fprintf (stream , "," );
163
191
mpi_fprint_const_or_var (stream , tree , node -> interaction -> to [0 ]-> param [param ]);
164
192
}
165
- mpi_fprintf (stream , "), MPI_COMM_WORLD);\n" );
193
+ if (is_role_in_group (node -> interaction -> msg_cond -> name , tree )) {
194
+ mpi_fprintf (stream , "), %s_comm);\n" , node -> interaction -> msg_cond -> name );
195
+ } else if (strcmp (node -> interaction -> msg_cond -> name , ST_ROLE_ALL ) == 0 ) {
196
+ mpi_fprintf (stream , "), MPI_COMM_WORLD);\n" );
197
+ } else {
198
+ fprintf (stderr , "ERROR/%s:%d %s Cannot determine communicator (inline group?), defaulting to MPI_COMM_WORLD\n" , __FILE__ , __LINE__ , __FUNCTION__ );
199
+ // TODO Inline group not given name
200
+ mpi_fprintf (stream , "), MPI_COMM_WORLD);\n" );
201
+ }
166
202
mpi_fprintf (stream , "#pragma pabble compute%u (buf%u, count%u)\n" , mpi_primitive_count , mpi_primitive_count , mpi_primitive_count );
167
203
168
204
mpi_fprintf (post_stream , " free(sbuf%u);\n" , mpi_primitive_count );
0 commit comments