Skip to content

Commit 54fbd56

Browse files
author
Luke Robison
committed
coll/tuned: simplify arguments to dynamic file create/destroy
Previously we passed n_collectives which we hard-coded to COLLCOUNT. Now we just include coll_base_functions.h and use COLLCOUNT directly.
1 parent 81f8c38 commit 54fbd56

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

ompi/mca/coll/tuned/coll_tuned_component.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int tuned_open(void)
230230
OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:component_open Reading collective rules file [%s]",
231231
ompi_coll_tuned_dynamic_rules_filename));
232232
rc = ompi_coll_tuned_read_rules_config_file( ompi_coll_tuned_dynamic_rules_filename,
233-
&(mca_coll_tuned_component.all_base_rules), COLLCOUNT);
233+
&(mca_coll_tuned_component.all_base_rules));
234234
if( rc >= 0 ) {
235235
OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:module_open Read %d valid rules\n", rc));
236236
} else {
@@ -257,7 +257,7 @@ static int tuned_close(void)
257257
OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:component_close: done!"));
258258

259259
if( NULL != mca_coll_tuned_component.all_base_rules ) {
260-
ompi_coll_tuned_free_all_rules(mca_coll_tuned_component.all_base_rules, COLLCOUNT);
260+
ompi_coll_tuned_free_all_rules(mca_coll_tuned_component.all_base_rules);
261261
mca_coll_tuned_component.all_base_rules = NULL;
262262
}
263263

ompi/mca/coll/tuned/coll_tuned_dynamic_file.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "mpi.h"
2828
#include "ompi/mca/mca.h"
2929
#include "coll_tuned.h"
30+
#include "ompi/mca/coll/base/coll_base_functions.h"
3031

3132
/* need to include our own topo prototypes so we can malloc data on the comm correctly */
3233
#include "ompi/mca/coll/base/coll_base_topo.h"
@@ -67,7 +68,7 @@ static int fileline=0; /* used for verbose error messages */
6768
*
6869
*/
6970

70-
int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** rules, int n_collectives)
71+
int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** rules)
7172
{
7273
long NCOL = 0, /* number of collectives for which rules are provided */
7374
COLID = 0, /* identifies the collective type to associate the rules with */
@@ -106,19 +107,14 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
106107
return (-2);
107108
}
108109

109-
if (n_collectives<1) {
110-
OPAL_OUTPUT((ompi_coll_tuned_stream,"Gave %d as max number of collectives in the rule table configuration file for tuned collectives!... ignoring!\n", n_collectives));
111-
return (-3);
112-
}
113-
114110
fptr = fopen (fname, "r");
115111
if (!fptr) {
116112
OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot read rules file [%s]\n", fname));
117113
goto on_file_error;
118114
}
119115

120116
/* make space and init the algorithm rules for each of the n_collectives MPI collectives */
121-
alg_rules = ompi_coll_tuned_mk_alg_rules (n_collectives);
117+
alg_rules = ompi_coll_tuned_mk_alg_rules(COLLCOUNT);
122118
if (NULL == alg_rules) {
123119
OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot allocate rules for file [%s]\n", fname));
124120
goto on_file_error;
@@ -134,8 +130,8 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
134130
OPAL_OUTPUT((ompi_coll_tuned_stream,"Could not read number of collectives in configuration file around line %d\n", fileline));
135131
goto on_file_error;
136132
}
137-
if (NCOL>n_collectives) {
138-
OPAL_OUTPUT((ompi_coll_tuned_stream,"Number of collectives in configuration file %ld is greater than number of MPI collectives possible %d ??? error around line %d\n", NCOL, n_collectives, fileline));
133+
if (NCOL>COLLCOUNT) {
134+
OPAL_OUTPUT((ompi_coll_tuned_stream,"Number of collectives in configuration file %ld is greater than number of MPI collectives possible %d ??? error around line %d\n", NCOL, COLLCOUNT, fileline));
139135
goto on_file_error;
140136
}
141137

@@ -146,8 +142,8 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
146142
OPAL_OUTPUT((ompi_coll_tuned_stream,"Could not read next Collective id in configuration file around line %d\n", fileline));
147143
goto on_file_error;
148144
}
149-
if (COLID>=n_collectives) {
150-
OPAL_OUTPUT((ompi_coll_tuned_stream,"Collective id in configuration file %ld is greater than MPI collectives possible %d. Error around line %d\n", COLID, n_collectives, fileline));
145+
if (COLID>=COLLCOUNT) {
146+
OPAL_OUTPUT((ompi_coll_tuned_stream,"Collective id in configuration file %ld is greater than MPI collectives possible %d. Error around line %d\n", COLID, COLLCOUNT, fileline));
151147
goto on_file_error;
152148
}
153149

@@ -296,7 +292,7 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
296292
OPAL_OUTPUT((ompi_coll_tuned_stream,"Fix errors as listed above and try again.\n"));
297293

298294
/* deallocate memory if allocated */
299-
if (alg_rules) ompi_coll_tuned_free_all_rules (alg_rules, n_collectives);
295+
if (alg_rules) ompi_coll_tuned_free_all_rules (alg_rules);
300296

301297
/* close file */
302298
if (fptr) fclose (fptr);

ompi/mca/coll/tuned/coll_tuned_dynamic_file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
BEGIN_C_DECLS
2929

30-
int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** rules, int n_collectives);
30+
int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** rules);
3131

3232

3333
END_C_DECLS

ompi/mca/coll/tuned/coll_tuned_dynamic_rules.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,12 @@ int ompi_coll_tuned_free_coms_in_alg_rule (ompi_coll_alg_rule_t* alg_p)
256256
}
257257

258258

259-
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p, int n_algs)
259+
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p)
260260
{
261261
int i;
262262
int rc = 0;
263263

264-
for( i = 0; i < n_algs; i++ ) {
264+
for( i = 0; i < COLLCOUNT; i++ ) {
265265
rc += ompi_coll_tuned_free_coms_in_alg_rule (&(alg_p[i]));
266266
}
267267

ompi/mca/coll/tuned/coll_tuned_dynamic_rules.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int ompi_coll_tuned_dump_all_rules (ompi_coll_alg_rule_t* alg_p, int n_rules);
8787
/* free alloced memory routines, used by file and tuned component/module */
8888
int ompi_coll_tuned_free_msg_rules_in_com_rule (ompi_coll_com_rule_t* com_p);
8989
int ompi_coll_tuned_free_coms_in_alg_rule (ompi_coll_alg_rule_t* alg_p);
90-
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p, int n_algs);
90+
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p);
9191

9292

9393
/* the IMPORTANT routines, i.e. the ones that do stuff for everyday communicators and collective calls */

0 commit comments

Comments
 (0)