Skip to content

Commit 00a5108

Browse files
committed
ofi: Cruft Cleanup in common code
Remove cruft from common_ofi, including unnecessary includes, declarations, and OPAL_DECLSPEC annotations on function definitions (they are only needed on declarations). Also move one function back into the C_DECLS block and properly OPAL_DECLSPEC the function. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 4828663 commit 00a5108

File tree

2 files changed

+23
-42
lines changed

2 files changed

+23
-42
lines changed

opal/mca/common/ofi/common_ofi.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,30 @@
1515
* $HEADER$
1616
*/
1717

18+
19+
#include "opal_config.h"
20+
1821
#include <errno.h>
1922
#include <unistd.h>
23+
#include <rdma/fabric.h>
24+
#if OPAL_OFI_IMPORT_MONITOR_SUPPORT
25+
#include <rdma/fi_ext.h>
26+
#endif
2027

21-
#include "opal_config.h"
2228
#include "common_ofi.h"
2329
#include "opal/constants.h"
2430
#include "opal/mca/base/mca_base_framework.h"
2531
#include "opal/mca/base/mca_base_var.h"
2632
#include "opal/mca/hwloc/base/base.h"
33+
#include "opal/mca/memory/base/base.h"
2734
#include "opal/mca/pmix/base/base.h"
2835
#include "opal/util/argv.h"
2936
#include "opal/util/show_help.h"
3037

31-
OPAL_DECLSPEC opal_common_ofi_module_t opal_common_ofi = {.prov_include = NULL,
32-
.prov_exclude = NULL,
33-
.registered = 0,
34-
.verbose = 0};
38+
opal_common_ofi_module_t opal_common_ofi = {.prov_include = NULL,
39+
.prov_exclude = NULL,
40+
.registered = 0,
41+
.verbose = 0};
3542

3643
static const char default_prov_exclude_list[] = "shm,sockets,tcp,udp,rstream,usnic";
3744
static opal_mutex_t opal_common_ofi_mutex = OPAL_MUTEX_STATIC_INIT;
@@ -75,15 +82,15 @@ static struct fi_ops_mem_monitor opal_common_ofi_export_ops = {
7582
.valid = opal_common_ofi_monitor_valid,
7683
};
7784

78-
OPAL_DECLSPEC void opal_common_ofi_mem_release_cb(void *buf, size_t length,
79-
void *cbdata, bool from_alloc)
85+
static void opal_common_ofi_mem_release_cb(void *buf, size_t length,
86+
void *cbdata, bool from_alloc)
8087
{
8188
opal_common_ofi_monitor->import_ops->notify(opal_common_ofi_monitor,
8289
buf, length);
8390
}
8491
#endif /* OPAL_OFI_IMPORT_MONITOR_SUPPORT */
8592

86-
OPAL_DECLSPEC int opal_common_ofi_init(void)
93+
int opal_common_ofi_init(void)
8794
{
8895
int ret;
8996

@@ -135,7 +142,7 @@ OPAL_DECLSPEC int opal_common_ofi_init(void)
135142
#endif
136143
}
137144

138-
OPAL_DECLSPEC int opal_common_ofi_fini(void)
145+
int opal_common_ofi_fini(void)
139146
{
140147
if (opal_common_ofi_initialized && !--opal_common_ofi_init_ref_cnt) {
141148
#if OPAL_OFI_IMPORT_MONITOR_SUPPORT
@@ -150,7 +157,7 @@ OPAL_DECLSPEC int opal_common_ofi_fini(void)
150157
return OPAL_SUCCESS;
151158
}
152159

153-
OPAL_DECLSPEC int opal_common_ofi_is_in_list(char **list, char *item)
160+
int opal_common_ofi_is_in_list(char **list, char *item)
154161
{
155162
int i = 0;
156163

@@ -169,7 +176,7 @@ OPAL_DECLSPEC int opal_common_ofi_is_in_list(char **list, char *item)
169176
return 0;
170177
}
171178

172-
OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_component_t *component)
179+
int opal_common_ofi_register_mca_variables(const mca_base_component_t *component)
173180
{
174181
static int include_index;
175182
static int exclude_index;
@@ -253,7 +260,7 @@ OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_componen
253260
return OPAL_SUCCESS;
254261
}
255262

256-
OPAL_DECLSPEC void opal_common_ofi_mca_register(void)
263+
void opal_common_ofi_mca_register(void)
257264
{
258265
opal_common_ofi.registered++;
259266
if (opal_common_ofi.registered > 1) {
@@ -265,7 +272,7 @@ OPAL_DECLSPEC void opal_common_ofi_mca_register(void)
265272
opal_output_set_verbosity(opal_common_ofi.output, opal_common_ofi.verbose);
266273
}
267274

268-
OPAL_DECLSPEC void opal_common_ofi_mca_deregister(void)
275+
void opal_common_ofi_mca_deregister(void)
269276
{
270277
/* unregister only on last deregister */
271278
opal_common_ofi.registered--;

opal/mca/common/ofi/common_ofi.h

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,8 @@
1818
#ifndef OPAL_MCA_COMMON_OFI_H
1919
#define OPAL_MCA_COMMON_OFI_H
2020

21-
#include "opal_config.h"
22-
#include "opal/mca/base/mca_base_framework.h"
23-
#include "opal/mca/base/mca_base_var.h"
2421
#include "opal/util/proc.h"
2522
#include "opal/memoryhooks/memory.h"
26-
#include <rdma/fabric.h>
27-
#if OPAL_OFI_IMPORT_MONITOR_SUPPORT
28-
#include <rdma/fi_ext.h>
29-
#endif
3023

3124
BEGIN_C_DECLS
3225

@@ -39,7 +32,6 @@ typedef struct opal_common_ofi_module {
3932
} opal_common_ofi_module_t;
4033

4134
extern opal_common_ofi_module_t opal_common_ofi;
42-
extern mca_base_framework_t opal_memory_base_framework;
4335

4436
OPAL_DECLSPEC int opal_common_ofi_register_mca_variables(const mca_base_component_t *component);
4537
OPAL_DECLSPEC void opal_common_ofi_mca_register(void);
@@ -61,24 +53,6 @@ OPAL_DECLSPEC void opal_common_ofi_mca_deregister(void);
6153
*/
6254
OPAL_DECLSPEC int opal_common_ofi_is_in_list(char **list, char *item);
6355

64-
#if OPAL_OFI_IMPORT_MONITOR_SUPPORT
65-
/*
66-
* @param buf (IN) Pointer to the start of the allocation
67-
* @param length (IN) Length of the allocation
68-
* @param cbdata (IN) Data passed to memory hooks when callback
69-
* was registered
70-
* @param from_alloc (IN) True if the callback is caused by a call to the
71-
* general allocation routines (malloc, calloc, free,
72-
* etc.) or directly from the user (mmap, munmap, etc.)
73-
*
74-
* Callback function triggered when memory is about to be freed.
75-
* is about to be freed. The callback will be triggered according to
76-
* the note in opal_mem_hooks_register_release().
77-
*
78-
*/
79-
OPAL_DECLSPEC void opal_common_ofi_mem_release_cb(void *buf, size_t length, void *cbdata, bool from_alloc);
80-
#endif /* OPAL_OFI_IMPORT_MONITOR_SUPPORT */
81-
8256
/*
8357
* Initializes common objects for libfabric
8458
*/
@@ -89,9 +63,9 @@ OPAL_DECLSPEC int opal_common_ofi_init(void);
8963
*/
9064
OPAL_DECLSPEC int opal_common_ofi_fini(void);
9165

92-
END_C_DECLS
66+
OPAL_DECLSPEC struct fi_info *opal_mca_common_ofi_select_provider(struct fi_info *provider_list,
67+
opal_process_info_t *process_info);
9368

94-
struct fi_info *opal_mca_common_ofi_select_provider(struct fi_info *provider_list,
95-
opal_process_info_t *process_info);
69+
END_C_DECLS
9670

9771
#endif /* OPAL_MCA_COMMON_OFI_H */

0 commit comments

Comments
 (0)