Skip to content

Commit dd7c935

Browse files
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. Signed-off-by: Luke Robison <[email protected]>
1 parent 4861b94 commit dd7c935

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

ompi/mca/coll/tuned/coll_tuned_component.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2019 Mellanox Technologies. All rights reserved.
2020
* Copyright (c) 2024 NVIDIA Corporation. All rights reserved.
21+
* Copyright (c) 2025 Amazon.com, Inc. or its affiliates. All rights
22+
* reserved.
23+
2124
* $COPYRIGHT$
2225
*
2326
* Additional copyrights may follow
@@ -230,7 +233,7 @@ static int tuned_open(void)
230233
OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:component_open Reading collective rules file [%s]",
231234
ompi_coll_tuned_dynamic_rules_filename));
232235
rc = ompi_coll_tuned_read_rules_config_file( ompi_coll_tuned_dynamic_rules_filename,
233-
&(mca_coll_tuned_component.all_base_rules), COLLCOUNT);
236+
&(mca_coll_tuned_component.all_base_rules));
234237
if( rc >= 0 ) {
235238
OPAL_OUTPUT((ompi_coll_tuned_stream,"coll:tuned:module_open Read %d valid rules\n", rc));
236239
} else {
@@ -257,7 +260,7 @@ static int tuned_close(void)
257260
OPAL_OUTPUT((ompi_coll_tuned_stream, "coll:tuned:component_close: done!"));
258261

259262
if( NULL != mca_coll_tuned_component.all_base_rules ) {
260-
ompi_coll_tuned_free_all_rules(mca_coll_tuned_component.all_base_rules, COLLCOUNT);
263+
ompi_coll_tuned_free_all_rules(mca_coll_tuned_component.all_base_rules);
261264
mca_coll_tuned_component.all_base_rules = NULL;
262265
}
263266

ompi/mca/coll/tuned/coll_tuned_dynamic_file.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* and Technology (RIST). All rights reserved.
1414
* Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved.
1515
* Copyright (c) 2024 NVIDIA CORPORATION. All rights reserved.
16+
* Copyright (c) 2025 Amazon.com, Inc. or its affiliates. All rights
17+
* reserved.
1618
* $COPYRIGHT$
1719
*
1820
* Additional copyrights may follow
@@ -27,6 +29,7 @@
2729
#include "mpi.h"
2830
#include "ompi/mca/mca.h"
2931
#include "coll_tuned.h"
32+
#include "ompi/mca/coll/base/coll_base_functions.h"
3033

3134
/* need to include our own topo prototypes so we can malloc data on the comm correctly */
3235
#include "ompi/mca/coll/base/coll_base_topo.h"
@@ -67,7 +70,7 @@ static int fileline=0; /* used for verbose error messages */
6770
*
6871
*/
6972

70-
int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** rules, int n_collectives)
73+
int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t** rules)
7174
{
7275
long NCOL = 0, /* number of collectives for which rules are provided */
7376
COLID = 0, /* identifies the collective type to associate the rules with */
@@ -106,19 +109,14 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
106109
return (-2);
107110
}
108111

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-
114112
fptr = fopen (fname, "r");
115113
if (!fptr) {
116114
OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot read rules file [%s]\n", fname));
117115
goto on_file_error;
118116
}
119117

120118
/* 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);
119+
alg_rules = ompi_coll_tuned_mk_alg_rules(COLLCOUNT);
122120
if (NULL == alg_rules) {
123121
OPAL_OUTPUT((ompi_coll_tuned_stream,"Cannot allocate rules for file [%s]\n", fname));
124122
goto on_file_error;
@@ -134,8 +132,8 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
134132
OPAL_OUTPUT((ompi_coll_tuned_stream,"Could not read number of collectives in configuration file around line %d\n", fileline));
135133
goto on_file_error;
136134
}
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));
135+
if (NCOL>COLLCOUNT) {
136+
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));
139137
goto on_file_error;
140138
}
141139

@@ -146,8 +144,8 @@ int ompi_coll_tuned_read_rules_config_file (char *fname, ompi_coll_alg_rule_t**
146144
OPAL_OUTPUT((ompi_coll_tuned_stream,"Could not read next Collective id in configuration file around line %d\n", fileline));
147145
goto on_file_error;
148146
}
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));
147+
if (COLID>=COLLCOUNT) {
148+
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));
151149
goto on_file_error;
152150
}
153151

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

298296
/* deallocate memory if allocated */
299-
if (alg_rules) ompi_coll_tuned_free_all_rules (alg_rules, n_collectives);
297+
if (alg_rules) ompi_coll_tuned_free_all_rules (alg_rules);
300298

301299
/* close file */
302300
if (fptr) fclose (fptr);

ompi/mca/coll/tuned/coll_tuned_dynamic_file.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* University of Stuttgart. All rights reserved.
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
12+
* Copyright (c) 2025 Amazon.com, Inc. or its affiliates. All rights
13+
* reserved.
1214
* $COPYRIGHT$
1315
*
1416
* Additional copyrights may follow
@@ -27,7 +29,7 @@
2729

2830
BEGIN_C_DECLS
2931

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

3234

3335
END_C_DECLS

ompi/mca/coll/tuned/coll_tuned_dynamic_rules.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* Copyright (c) 2011-2012 FUJITSU LIMITED. All rights reserved.
1313
* Copyright (c) 2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
15+
* Copyright (c) 2025 Amazon.com, Inc. or its affiliates. All rights
16+
* reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -256,12 +258,12 @@ int ompi_coll_tuned_free_coms_in_alg_rule (ompi_coll_alg_rule_t* alg_p)
256258
}
257259

258260

259-
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p, int n_algs)
261+
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p)
260262
{
261263
int i;
262264
int rc = 0;
263265

264-
for( i = 0; i < n_algs; i++ ) {
266+
for( i = 0; i < COLLCOUNT; i++ ) {
265267
rc += ompi_coll_tuned_free_coms_in_alg_rule (&(alg_p[i]));
266268
}
267269

ompi/mca/coll/tuned/coll_tuned_dynamic_rules.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2011-2012 FUJITSU LIMITED. All rights reserved.
14+
* Copyright (c) 2025 Amazon.com, Inc. or its affiliates. All rights
15+
* reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -87,7 +89,7 @@ int ompi_coll_tuned_dump_all_rules (ompi_coll_alg_rule_t* alg_p, int n_rules);
8789
/* free alloced memory routines, used by file and tuned component/module */
8890
int ompi_coll_tuned_free_msg_rules_in_com_rule (ompi_coll_com_rule_t* com_p);
8991
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);
92+
int ompi_coll_tuned_free_all_rules (ompi_coll_alg_rule_t* alg_p);
9193

9294

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

0 commit comments

Comments
 (0)