Move global variables into files with functions in them. POSIX says
that linkers don't have to pull in .o files unless they have functions in them, so having global symbols in files by themselves does not guarantee that a program trying to use them will be able to link successfully. This commit was SVN r652.
Этот коммит содержится в:
родитель
9d0b36c34d
Коммит
056485c6da
@ -14,7 +14,7 @@ headers = \
|
||||
|
||||
libmpi_communicator_la_SOURCES = \
|
||||
$(headers) \
|
||||
mpi_comm_globals.c
|
||||
lam_comm_init.c
|
||||
|
||||
# Conditionally install the header files
|
||||
|
||||
|
@ -69,4 +69,12 @@ static inline lam_proc_t* lam_comm_lookup_peer(lam_communicator_t* comm, size_t
|
||||
return comm->c_remote_group->g_procs[peer_id];
|
||||
}
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int lam_comm_init(lam_communicator_t *comm);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LAM_COMMUNICATOR_H */
|
||||
|
34
src/mpi/communicator/lam_comm_init.c
Обычный файл
34
src/mpi/communicator/lam_comm_init.c
Обычный файл
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mpi.h"
|
||||
#include "mpi/communicator/communicator.h"
|
||||
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
|
||||
lam_communicator_t *lam_mpi_comm_array;
|
||||
size_t lam_mpi_comm_array_size;
|
||||
|
||||
lam_communicator_t lam_mpi_comm_world;
|
||||
lam_communicator_t lam_mpi_comm_self;
|
||||
|
||||
|
||||
/*
|
||||
* This is a shell function that needs to be filled in. It is here so
|
||||
* that this file will get linked into MPI executables (POSIX says
|
||||
* that linkers do not have to pull .o files from libraries without
|
||||
* function symbols -- global variable symbols alone are not
|
||||
* sufficient to pull in .o files).
|
||||
*/
|
||||
int lam_comm_init(lam_communicator_t *comm)
|
||||
{
|
||||
return LAM_SUCCESS;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mpi.h"
|
||||
#include "mpi/communicator/communicator.h"
|
||||
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
|
||||
lam_communicator_t *lam_mpi_comm_array;
|
||||
size_t lam_mpi_comm_array_size;
|
||||
|
||||
lam_communicator_t lam_mpi_comm_world;
|
||||
lam_communicator_t lam_mpi_comm_self;
|
@ -15,8 +15,7 @@ headers = \
|
||||
libmpi_runtime_la_SOURCES = \
|
||||
$(headers) \
|
||||
lam_mpi_init.c \
|
||||
lam_mpi_finalize.c \
|
||||
lam_mpi_globals.c
|
||||
lam_mpi_finalize.c
|
||||
|
||||
# Conditionally install the header files
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
#include "lam_config.h"
|
||||
|
||||
#include "mpi.h"
|
||||
|
||||
|
||||
/*
|
||||
* Global variables and symbols for the MPI layer
|
||||
*/
|
||||
|
||||
bool lam_mpi_initialized = false;
|
||||
bool lam_mpi_finalized = false;
|
||||
|
||||
bool lam_mpi_thread_multiple = false;
|
||||
int lam_mpi_thread_requested = MPI_THREAD_SINGLE;
|
||||
int lam_mpi_thread_provided = MPI_THREAD_SINGLE;
|
||||
|
@ -18,6 +18,18 @@
|
||||
#include "mca/mpi/coll/base/base.h"
|
||||
|
||||
|
||||
/*
|
||||
* Global variables and symbols for the MPI layer
|
||||
*/
|
||||
|
||||
bool lam_mpi_initialized = false;
|
||||
bool lam_mpi_finalized = false;
|
||||
|
||||
bool lam_mpi_thread_multiple = false;
|
||||
int lam_mpi_thread_requested = MPI_THREAD_SINGLE;
|
||||
int lam_mpi_thread_provided = MPI_THREAD_SINGLE;
|
||||
|
||||
|
||||
int lam_mpi_init(int argc, char **argv, int requested, int *provided)
|
||||
{
|
||||
int ret;
|
||||
@ -80,6 +92,14 @@ int lam_mpi_init(int argc, char **argv, int requested, int *provided)
|
||||
*provided = lam_mpi_thread_provided;
|
||||
lam_mpi_thread_multiple = (lam_mpi_thread_provided == MPI_THREAD_MULTIPLE);
|
||||
|
||||
/* Setup MPI_COMM_WORLD */
|
||||
|
||||
lam_comm_init(MPI_COMM_WORLD);
|
||||
|
||||
/* Setup MPI_COMM_SELF */
|
||||
|
||||
lam_comm_init(MPI_COMM_SELF);
|
||||
|
||||
/* All done */
|
||||
|
||||
lam_mpi_initialized = true;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user