Skip to content

Commit 4eaefed

Browse files
committed
mca/base: add priority output to mca_base_select
The mca_base_select function uses returned priorities to select the best component/module. This priority may be of use to the caller so pass that information back in an optional argument. If the priority is not needed pass NULL. This is a modification of open-mpi/ompi@8b5810f . The primary difference is we left the original mca_base_select in place for compatibility. Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 901f7aa commit 4eaefed

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

ompi/mca/mtl/base/mtl_base_frame.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
34
* University Research and Technology
@@ -52,14 +53,16 @@ ompi_mtl_base_select(bool enable_progress_threads,
5253
int ret = OMPI_ERR_NOT_FOUND;
5354
mca_mtl_base_component_t *best_component = NULL;
5455
mca_mtl_base_module_t *best_module = NULL;
56+
int best_priority;
5557

5658
/*
5759
* Select the best component
5860
*/
59-
if( OPAL_SUCCESS != mca_base_select("mtl", ompi_mtl_base_framework.framework_output,
60-
&ompi_mtl_base_framework.framework_components,
61-
(mca_base_module_t **) &best_module,
62-
(mca_base_component_t **) &best_component) ) {
61+
if( OPAL_SUCCESS != mca_base_select_new ("mtl", ompi_mtl_base_framework.framework_output,
62+
&ompi_mtl_base_framework.framework_components,
63+
(mca_base_module_t **) &best_module,
64+
(mca_base_component_t **) &best_component,
65+
&best_priority) ) {
6366
/* notify caller that no available component found */
6467
return ret;
6568
}

opal/mca/base/base.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
14+
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* $COPYRIGHT$
1717
*
@@ -108,11 +108,20 @@ OPAL_DECLSPEC int mca_base_close(void);
108108
/**
109109
* A generic select function
110110
*
111+
* The _new version is a 1.10.x only function. It is the version available
112+
* 2.0.0 and beyond. The old version calls the new version with NULL for
113+
* priority_out.
111114
*/
112-
OPAL_DECLSPEC int mca_base_select(const char *type_name, int output_id,
113-
opal_list_t *components_available,
114-
mca_base_module_t **best_module,
115-
mca_base_component_t **best_component);
115+
OPAL_DECLSPEC int mca_base_select_new (const char *type_name, int output_id,
116+
opal_list_t *components_available,
117+
mca_base_module_t **best_module,
118+
mca_base_component_t **best_component,
119+
int *priority_out);
120+
121+
OPAL_DECLSPEC int mca_base_select (const char *type_name, int output_id,
122+
opal_list_t *components_available,
123+
mca_base_module_t **best_module,
124+
mca_base_component_t **best_component);
116125

117126
/**
118127
* A function for component query functions to discover if they have

opal/mca/base/mca_base_components_select.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12
/*
23
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
34
* University Research and Technology
45
* Corporation. All rights reserved.
6+
* Copyright (c) 2014 Los Alamos National Security, LLC. All rights
7+
* reserved.
58
* $COPYRIGHT$
69
*
710
* Additional copyrights may follow
@@ -26,11 +29,21 @@
2629
#include "opal/mca/base/mca_base_component_repository.h"
2730
#include "opal/constants.h"
2831

32+
int mca_base_select (const char *type_name, int output_id,
33+
opal_list_t *components_available,
34+
mca_base_module_t **best_module,
35+
mca_base_component_t **best_component)
36+
{
37+
return mca_base_select_new (type_name, output_id, components_available,
38+
best_module, best_component, NULL);
39+
}
2940

30-
int mca_base_select(const char *type_name, int output_id,
31-
opal_list_t *components_available,
32-
mca_base_module_t **best_module,
33-
mca_base_component_t **best_component)
41+
42+
int mca_base_select_new (const char *type_name, int output_id,
43+
opal_list_t *components_available,
44+
mca_base_module_t **best_module,
45+
mca_base_component_t **best_component,
46+
int *priority_out)
3447
{
3548
mca_base_component_list_item_t *cli = NULL;
3649
mca_base_component_t *component = NULL;
@@ -93,6 +106,9 @@ int mca_base_select(const char *type_name, int output_id,
93106
}
94107
}
95108

109+
if (priority_out) {
110+
*priority_out = best_priority;
111+
}
96112

97113
/*
98114
* Finished querying all components.

0 commit comments

Comments
 (0)