...
 
Commits (18)
all: lib/libdarshan.a lib/libdarshan-stubs.a lib/darshan-null.o
all: lib/libdarshan.a lib/libdarshan-stubs.a
#TODO: each module provides own makefile with module-specific objects, build options, etc.
......@@ -24,7 +24,7 @@ DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
DARSHAN_VERSION = @DARSHAN_VERSION@
ifndef DISABLE_LDPRELOAD
all: lib/libdarshan.so lib/darshan-null.po
all: lib/libdarshan.so
endif
VPATH = $(srcdir)
......@@ -37,15 +37,51 @@ LIBS = -lz @LIBBZ2@
BUILD_HDF5_MODULE = @BUILD_HDF5_MODULE@
BUILD_MDHIM_MODULE = @BUILD_MDHIM_MODULE@
BUILD_POSIX_MODULE = @BUILD_POSIX_MODULE@
BUILD_MPIIO_MODULE = @BUILD_MPIIO_MODULE@
BUILD_PNETCDF_MODULE = @BUILD_PNETCDF_MODULE@
BUILD_STDIO_MODULE = @BUILD_STDIO_MODULE@
BUILD_DXT_MODULE = @BUILD_DXT_MODULE@
BUILD_NULL_MODULE = @BUILD_NULL_MODULE@
DARSHAN_STATIC_MOD_OBJS =
DARSHAN_DYNAMIC_MOD_OBJS =
ifdef BUILD_POSIX_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-posix.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-posix.po
endif
ifdef BUILD_MPIIO_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-mpiio.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-mpiio.po
endif
ifdef BUILD_PNETCDF_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-pnetcdf.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-pnetcdf.po
endif
DARSHAN_STATIC_MOD_OBJS = lib/darshan-posix.o lib/darshan-mpiio.o lib/darshan-pnetcdf.o lib/darshan-stdio.o lib/darshan-dxt.o
DARSHAN_DYNAMIC_MOD_OBJS = lib/darshan-posix.po lib/darshan-mpiio.po lib/darshan-pnetcdf.po lib/darshan-stdio.po lib/darshan-dxt.po
ifdef BUILD_STDIO_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-stdio.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-stdio.po
endif
ifdef BUILD_DXT_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-dxt.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-dxt.po
endif
ifdef BUILD_HDF5_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-hdf5.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-hdf5.po
endif
ifdef BUILD_NULL_MODULE
DARSHAN_STATIC_MOD_OBJS += lib/darshan-null.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-null.po
endif
ifdef DARSHAN_USE_BGQ
DARSHAN_STATIC_MOD_OBJS += lib/darshan-bgq.o
DARSHAN_DYNAMIC_MOD_OBJS += lib/darshan-bgq.po
......@@ -225,8 +261,8 @@ endif
install -m 644 lib/pkgconfig/darshan-runtime.pc $(libdir)/pkgconfig/darshan-runtime.pc
clean::
rm -f *.o *.a lib/*.o lib/*.po lib/*.a lib/*.so
rm -f *.o *.a lib/*.o lib/*.po lib/*.a lib/*.so
distclean:: clean
rm -f darshan-runtime-config.h darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-gen-cc.pl darshan-mk-log-dirs.pl darshan-config lib/pkgconfig/darshan-runtime.pc share/craype-1.x/darshan-module share/craype-2.x/darshan-module share/darshan-mmap-epilog.sh share/ld-opts/darshan-base-ld-opts share/mpi-profile/darshan-bg-cc.conf share/mpi-profile/darshan-bg-cxx.conf share/mpi-profile/darshan-bg-f.conf share/mpi-profile/darshan-cc.conf share/mpi-profile/darshan-cxx.conf share/mpi-profile/darshan-f.conf aclocal.m4 autom4te.cache/* config.status config.log Makefile
rm -f darshan-runtime-config.h darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-gen-cc.pl darshan-mk-log-dirs.pl darshan-config lib/pkgconfig/darshan-runtime.pc share/craype-1.x/darshan-module share/craype-2.x/darshan-module share/darshan-mmap-epilog.sh share/ld-opts/darshan-base-ld-opts share/mpi-profile/darshan-bg-cc.conf share/mpi-profile/darshan-bg-cxx.conf share/mpi-profile/darshan-bg-f.conf share/mpi-profile/darshan-cc.conf share/mpi-profile/darshan-cxx.conf share/mpi-profile/darshan-f.conf aclocal.m4 autom4te.cache/* config.status config.log Makefile
rm -rf autom4te.cache
This diff is collapsed.
This diff is collapsed.
......@@ -263,6 +263,7 @@ void darshan_common_val_counter(
int64_t *val_p,
int64_t *cnt_p);
#ifdef HAVE_MPI
/* darshan_variance_reduce()
*
* MPI reduction operation to calculate variances on counters in
......@@ -279,5 +280,6 @@ void darshan_variance_reduce(
void *inoutvec,
int *len,
MPI_Datatype *dt);
#endif
#endif /* __DARSHAN_COMMON_H */
......@@ -7,12 +7,19 @@
#ifndef __DARSHAN_CORE_H
#define __DARSHAN_CORE_H
#include "darshan-runtime-config.h"
#include <unistd.h>
#include <sys/types.h>
#include <stdint.h>
#include <limits.h>
#ifdef HAVE_MPI
#include <mpi.h>
#endif
#include "uthash.h"
#include "darshan.h"
#include "darshan-log-format.h"
/* Environment variable to override __DARSHAN_JOBID */
......@@ -30,6 +37,9 @@
/* Environment variable to override memory per module */
#define DARSHAN_MOD_MEM_OVERRIDE "DARSHAN_MODMEM"
/* Environment variable to enable profiling without MPI */
#define DARSHAN_ENABLE_NONMPI "DARSHAN_ENABLE_NONMPI"
#ifdef __DARSHAN_ENABLE_MMAP_LOGS
/* Environment variable to override default mmap log path */
#define DARSHAN_MMAP_LOG_PATH_OVERRIDE "DARSHAN_MMAP_LOGPATH"
......@@ -48,13 +58,32 @@
/* default name record buf can store 2048 records of size 100 bytes */
#define DARSHAN_NAME_RECORD_BUF_SIZE (2048 * 100)
typedef union
{
int nompi_fd;
#ifdef HAVE_MPI
MPI_File mpi_fh;
#endif
} darshan_core_log_fh;
/* FS mount information */
#define DARSHAN_MAX_MNTS 64
#define DARSHAN_MAX_MNT_PATH 256
#define DARSHAN_MAX_MNT_TYPE 32
struct darshan_core_mnt_data
{
char path[DARSHAN_MAX_MNT_PATH];
char type[DARSHAN_MAX_MNT_TYPE];
struct darshan_fs_info fs_info;
};
/* structure to track registered modules */
struct darshan_core_module
{
void *rec_buf_start;
void *rec_buf_p;
int rec_mem_avail;
darshan_module_shutdown mod_shutdown_func;
darshan_module_funcs mod_funcs;
};
/* strucutre for keeping a reference to registered name records */
......
......@@ -12,6 +12,7 @@
#define DARSHAN_EXTERN_DECL(name,ret,args) \
extern ret (*__real_ ## name)args;
#ifdef HAVE_MPI
DARSHAN_EXTERN_DECL(PMPI_File_close, int, (MPI_File *fh));
DARSHAN_EXTERN_DECL(PMPI_File_iread_at, int, (MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, __D_MPI_REQUEST *request));
DARSHAN_EXTERN_DECL(PMPI_File_iread, int, (MPI_File fh, void *buf, int count, MPI_Datatype datatype, __D_MPI_REQUEST *request));
......@@ -131,6 +132,7 @@ DARSHAN_EXTERN_DECL(PMPI_Gather, int, (const void *sendbuf, int sendcount, MPI_D
DARSHAN_EXTERN_DECL(PMPI_Gather, int, (void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm));
#endif
DARSHAN_EXTERN_DECL(PMPI_Barrier, int, (MPI_Comm comm));
#endif /* HAVE_MPI */
#endif
......
......@@ -21,6 +21,9 @@
/* Define to 1 if you have the <mntent.h> header file. */
#undef HAVE_MNTENT_H
/* Define if build is MPI-enabled */
#undef HAVE_MPI
/* Define if MPI-IO prototypes use const qualifier */
#undef HAVE_MPIIO_CONST
......
......@@ -10,7 +10,10 @@
#include <unistd.h>
#include <sys/types.h>
#include <stdint.h>
#ifdef HAVE_MPI
#include <mpi.h>
#endif
#include "darshan-log-format.h"
#include "darshan-common.h"
......@@ -76,22 +79,37 @@
/* default number of records to attempt to store for each module */
#define DARSHAN_DEF_MOD_REC_COUNT 1024
/* module developers must define a 'darshan_module_shutdown' function
#ifdef HAVE_MPI
/*
* module developers _can_ define a 'darshan_module_redux' function
* to run collective MPI operations at shutdown time. Typically this
* functionality has been used to reduce records shared globablly (given
* in the 'shared_recs' array) into a single data record. Set to NULL
* avoid any reduction steps.
*/
typedef void (*darshan_module_redux)(
void *mod_buf, /* input parameter indicating module's buffer address */
MPI_Comm mod_comm, /* MPI communicator to run collectives with */
darshan_record_id *shared_recs, /* list of shared data record ids */
int shared_rec_count /* count of shared data records */
);
#endif
/*
* module developers _must_ define a 'darshan_module_shutdown' function
* for allowing darshan-core to call into a module and retrieve final
* output data to be saved in the log.
*
* NOTE: module developers can use this function to run collective
* MPI operations at shutdown time. Typically this functionality
* has been used to reduce records shared globablly (given in the
* 'shared_recs' array) into a single data record.
*/
typedef void (*darshan_module_shutdown)(
MPI_Comm mod_comm, /* MPI communicator to run collectives with */
darshan_record_id *shared_recs, /* list of shared data record ids */
int shared_rec_count, /* count of shared data records */
void **mod_buf, /* output parameter to save module buffer address */
int *mod_buf_sz /* output parameter to save module buffer size */
);
typedef struct darshan_module_funcs
{
#ifdef HAVE_MPI
darshan_module_redux mod_redux_func;
#endif
darshan_module_shutdown mod_shutdown_func;
} darshan_module_funcs;
/* stores FS info from statfs calls for a given mount point */
struct darshan_fs_info
......@@ -124,19 +142,19 @@ void darshan_instrument_fs_data(
*
* Register module identifier 'mod_id' with the darshan-core runtime
* environment, allowing the module to store I/O characterization data.
* 'mod_shutdown_func is a pointer to a function responsible for
* shutting down the module and returning final output data to darshan-core.
* 'inout_mod_buf_size' is an input/output argument, with it being
* set to the requested amount of module memory on input, and set to
* the amount allocated by darshan-core on output. If given, 'rank' is
* a pointer to an integer which will contain the calling process's
* MPI rank on return. If given, 'sys_mem_alignment' is a pointer to
* an integer which will contain the memory alignment value Darshan
* 'mod_funcs' is a set of function pointers that implement module-specific
* shutdown functionality (including a possible data reduction step when
* using MPI). 'inout_mod_buf_size' is an input/output argument, with it
* being set to the requested amount of module memory on input, and set to
* the amount allocated by darshan-core on output. If Darshan is built with
* MPI support, 'rank' is a pointer to an integer which will contain the
* calling process's MPI rank on return. If given, 'sys_mem_alignment' is a
* pointer to an integer which will contain the memory alignment value Darshan
* was configured with on return.
*/
void darshan_core_register_module(
darshan_module_id mod_id,
darshan_module_shutdown mod_shutdown_func,
darshan_module_funcs mod_funcs,
int *inout_mod_buf_size,
int *rank,
int *sys_mem_alignment);
......
......@@ -278,6 +278,7 @@ void darshan_common_val_counter(void **common_val_root, int *common_val_count,
return;
}
#ifdef HAVE_MPI
void darshan_variance_reduce(void *invec, void *inoutvec, int *len,
MPI_Datatype *dt)
{
......@@ -298,6 +299,7 @@ void darshan_variance_reduce(void *invec, void *inoutvec, int *len,
return;
}
#endif
/*
* Local variables:
......
......@@ -11,12 +11,15 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_MPI
#include <mpi.h>
#endif
#include "darshan.h"
#include "darshan-core.h"
#include "darshan-dynamic.h"
#ifdef HAVE_MPI
DARSHAN_FORWARD_DECL(PMPI_Finalize, int, ());
DARSHAN_FORWARD_DECL(PMPI_Init, int, (int *argc, char ***argv));
DARSHAN_FORWARD_DECL(PMPI_Init_thread, int, (int *argc, char ***argv, int required, int *provided));
......@@ -85,6 +88,30 @@ int DARSHAN_DECL(MPI_Finalize)(void)
return(ret);
}
DARSHAN_WRAPPER_MAP(PMPI_Finalize, int, (void), MPI_Finalize())
#endif
/*
* Initialization hook that does not rely on MPI
*/
#ifdef __GNUC__
__attribute__((constructor)) void serial_init(void)
{
char *no_mpi;
no_mpi = getenv(DARSHAN_ENABLE_NONMPI);
if (no_mpi)
darshan_core_initialize(0, NULL);
return;
}
__attribute__((destructor)) void serial_finalize(void)
{
char *no_mpi;
no_mpi = getenv(DARSHAN_ENABLE_NONMPI);
if (no_mpi)
darshan_core_shutdown();
return;
}
#endif
/*
* Local variables:
......
This diff is collapsed.
......@@ -129,11 +129,9 @@ static void dxt_mpiio_cleanup_runtime(
void);
static void dxt_posix_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **dxt_buf, int *dxt_buf_sz);
void **dxt_buf, int *dxt_buf_sz);
static void dxt_mpiio_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **dxt_buf, int *dxt_buf_sz);
void **dxt_buf, int *dxt_buf_sz);
static struct dxt_posix_runtime *dxt_posix_runtime = NULL;
static struct dxt_mpiio_runtime *dxt_mpiio_runtime = NULL;
......@@ -380,6 +378,12 @@ static void dxt_posix_runtime_initialize()
* over realloc'ing module memory as needed.
*/
int dxt_psx_buf_size = 0;
darshan_module_funcs mod_funcs = {
#ifdef HAVE_MPI
.mod_redux_func = NULL,
#endif
.mod_shutdown_func = &dxt_posix_shutdown
};
int ret;
double tmpfloat;
char *envstr;
......@@ -387,7 +391,7 @@ static void dxt_posix_runtime_initialize()
/* register the DXT module with darshan core */
darshan_core_register_module(
DXT_POSIX_MOD,
&dxt_posix_shutdown,
mod_funcs,
&dxt_psx_buf_size,
&dxt_my_rank,
NULL);
......@@ -433,6 +437,12 @@ void dxt_mpiio_runtime_initialize()
* over realloc'ing module memory as needed.
*/
int dxt_mpiio_buf_size = 0;
darshan_module_funcs mod_funcs = {
#ifdef HAVE_MPI
.mod_redux_func = NULL,
#endif
.mod_shutdown_func = &dxt_mpiio_shutdown
};
int ret;
double tmpfloat;
char *envstr;
......@@ -440,7 +450,7 @@ void dxt_mpiio_runtime_initialize()
/* register the DXT module with darshan core */
darshan_core_register_module(
DXT_MPIIO_MOD,
&dxt_mpiio_shutdown,
mod_funcs,
&dxt_mpiio_buf_size,
&dxt_my_rank,
NULL);
......@@ -715,9 +725,6 @@ static void dxt_serialize_posix_records(void *rec_ref_p)
}
static void dxt_posix_shutdown(
MPI_Comm mod_comm,
darshan_record_id *shared_recs,
int shared_rec_count,
void **dxt_posix_buf,
int *dxt_posix_buf_sz)
{
......@@ -825,9 +832,6 @@ static void dxt_serialize_mpiio_records(void *rec_ref_p)
}
static void dxt_mpiio_shutdown(
MPI_Comm mod_comm,
darshan_record_id *shared_recs,
int shared_rec_count,
void **dxt_mpiio_buf,
int *dxt_mpiio_buf_sz)
{
......
This diff is collapsed.
......@@ -46,14 +46,17 @@ static void pnetcdf_runtime_initialize(
void);
static struct pnetcdf_file_record_ref *pnetcdf_track_new_file_record(
darshan_record_id rec_id, const char *path);
static void pnetcdf_record_reduction_op(
void* infile_v, void* inoutfile_v, int *len, MPI_Datatype *datatype);
static void pnetcdf_cleanup_runtime(
void);
#ifdef HAVE_MPI
static void pnetcdf_record_reduction_op(
void* infile_v, void* inoutfile_v, int *len, MPI_Datatype *datatype);
static void pnetcdf_mpi_redux(
void *pnetcdf_buf, MPI_Comm mod_comm,
darshan_record_id *shared_recs, int shared_rec_count);
#endif
static void pnetcdf_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **pnetcdf_buf, int *pnetcdf_buf_sz);
void **pnetcdf_buf, int *pnetcdf_buf_sz);
static struct pnetcdf_runtime *pnetcdf_runtime = NULL;
static pthread_mutex_t pnetcdf_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
......@@ -210,6 +213,12 @@ int DARSHAN_DECL(ncmpi_close)(int ncid)
static void pnetcdf_runtime_initialize()
{
int pnetcdf_buf_size;
darshan_module_funcs mod_funcs = {
#ifdef HAVE_MPI
.mod_redux_func = &pnetcdf_mpi_redux,
#endif
.mod_shutdown_func = &pnetcdf_shutdown
};
/* try and store the default number of records for this module */
pnetcdf_buf_size = DARSHAN_DEF_MOD_REC_COUNT * sizeof(struct darshan_pnetcdf_file);
......@@ -217,7 +226,7 @@ static void pnetcdf_runtime_initialize()
/* register pnetcdf module with darshan-core */
darshan_core_register_module(
DARSHAN_PNETCDF_MOD,
&pnetcdf_shutdown,
mod_funcs,
&pnetcdf_buf_size,
&my_rank,
NULL);
......@@ -288,6 +297,18 @@ static struct pnetcdf_file_record_ref *pnetcdf_track_new_file_record(
return(rec_ref);
}
static void pnetcdf_cleanup_runtime()
{
darshan_clear_record_refs(&(pnetcdf_runtime->ncid_hash), 0);
darshan_clear_record_refs(&(pnetcdf_runtime->rec_id_hash), 1);
free(pnetcdf_runtime);
pnetcdf_runtime = NULL;
return;
}
#ifdef HAVE_MPI
static void pnetcdf_record_reduction_op(void* infile_v, void* inoutfile_v,
int *len, MPI_Datatype *datatype)
{
......@@ -337,33 +358,22 @@ static void pnetcdf_record_reduction_op(void* infile_v, void* inoutfile_v,
return;
}
static void pnetcdf_cleanup_runtime()
{
darshan_clear_record_refs(&(pnetcdf_runtime->ncid_hash), 0);
darshan_clear_record_refs(&(pnetcdf_runtime->rec_id_hash), 1);
free(pnetcdf_runtime);
pnetcdf_runtime = NULL;
return;
}
#endif
/***************************************************************************
* Functions exported by PNETCDF module for coordinating with darshan-core *
***************************************************************************/
static void pnetcdf_shutdown(
#ifdef HAVE_MPI
static void pnetcdf_mpi_redux(
void *pnetcdf_buf,
MPI_Comm mod_comm,
darshan_record_id *shared_recs,
int shared_rec_count,
void **pnetcdf_buf,
int *pnetcdf_buf_sz)
int shared_rec_count)
{
struct pnetcdf_file_record_ref *rec_ref;
struct darshan_pnetcdf_file *pnetcdf_rec_buf =
*(struct darshan_pnetcdf_file **)pnetcdf_buf;
int pnetcdf_rec_count;
struct pnetcdf_file_record_ref *rec_ref;
struct darshan_pnetcdf_file *pnetcdf_rec_buf = (struct darshan_pnetcdf_file *)pnetcdf_buf;
struct darshan_pnetcdf_file *red_send_buf = NULL;
struct darshan_pnetcdf_file *red_recv_buf = NULL;
MPI_Datatype red_type;
......@@ -375,80 +385,88 @@ static void pnetcdf_shutdown(
pnetcdf_rec_count = pnetcdf_runtime->file_rec_count;
/* if there are globally shared files, do a shared file reduction */
/* NOTE: the shared file reduction is also skipped if the
* DARSHAN_DISABLE_SHARED_REDUCTION environment variable is set.
*/
if(shared_rec_count && !getenv("DARSHAN_DISABLE_SHARED_REDUCTION"))
/* necessary initialization of shared records */
for(i = 0; i < shared_rec_count; i++)
{
/* necessary initialization of shared records */
for(i = 0; i < shared_rec_count; i++)
{
rec_ref = darshan_lookup_record_ref(pnetcdf_runtime->rec_id_hash,
&shared_recs[i], sizeof(darshan_record_id));
assert(rec_ref);
rec_ref->file_rec->base_rec.rank = -1;
}
rec_ref = darshan_lookup_record_ref(pnetcdf_runtime->rec_id_hash,
&shared_recs[i], sizeof(darshan_record_id));
assert(rec_ref);
rec_ref->file_rec->base_rec.rank = -1;
}
/* sort the array of records so we get all of the shared records
* (marked by rank -1) in a contiguous portion at end of the array
*/
darshan_record_sort(pnetcdf_rec_buf, pnetcdf_rec_count,
sizeof(struct darshan_pnetcdf_file));
/* sort the array of records so we get all of the shared records
* (marked by rank -1) in a contiguous portion at end of the array
*/
darshan_record_sort(pnetcdf_rec_buf, pnetcdf_rec_count,
sizeof(struct darshan_pnetcdf_file));
/* make *send_buf point to the shared files at the end of sorted array */
red_send_buf = &(pnetcdf_rec_buf[pnetcdf_rec_count-shared_rec_count]);
/* make *send_buf point to the shared files at the end of sorted array */
red_send_buf = &(pnetcdf_rec_buf[pnetcdf_rec_count-shared_rec_count]);
/* allocate memory for the reduction output on rank 0 */
if(my_rank == 0)
/* allocate memory for the reduction output on rank 0 */
if(my_rank == 0)
{
red_recv_buf = malloc(shared_rec_count * sizeof(struct darshan_pnetcdf_file));
if(!red_recv_buf)
{
red_recv_buf = malloc(shared_rec_count * sizeof(struct darshan_pnetcdf_file));
if(!red_recv_buf)
{
PNETCDF_UNLOCK();
return;
}
PNETCDF_UNLOCK();
return;
}
}
/* construct a datatype for a PNETCDF file record. This is serving no purpose
* except to make sure we can do a reduction on proper boundaries
*/
PMPI_Type_contiguous(sizeof(struct darshan_pnetcdf_file),
MPI_BYTE, &red_type);
PMPI_Type_commit(&red_type);
/* register a PNETCDF file record reduction operator */
PMPI_Op_create(pnetcdf_record_reduction_op, 1, &red_op);
/* construct a datatype for a PNETCDF file record. This is serving no purpose
* except to make sure we can do a reduction on proper boundaries
*/
PMPI_Type_contiguous(sizeof(struct darshan_pnetcdf_file),
MPI_BYTE, &red_type);
PMPI_Type_commit(&red_type);
/* reduce shared PNETCDF file records */
PMPI_Reduce(red_send_buf, red_recv_buf,
shared_rec_count, red_type, red_op, 0, mod_comm);
/* register a PNETCDF file record reduction operator */
PMPI_Op_create(pnetcdf_record_reduction_op, 1, &red_op);
/* clean up reduction state */
if(my_rank == 0)
{
int tmp_ndx = pnetcdf_rec_count - shared_rec_count;
memcpy(&(pnetcdf_rec_buf[tmp_ndx]), red_recv_buf,
shared_rec_count * sizeof(struct darshan_pnetcdf_file));
free(red_recv_buf);
}
else
{
pnetcdf_rec_count -= shared_rec_count;
}
/* reduce shared PNETCDF file records */
PMPI_Reduce(red_send_buf, red_recv_buf,
shared_rec_count, red_type, red_op, 0, mod_comm);
PMPI_Type_free(&red_type);
PMPI_Op_free(&red_op);
/* clean up reduction state */
if(my_rank == 0)
{
int tmp_ndx = pnetcdf_rec_count - shared_rec_count;
memcpy(&(pnetcdf_rec_buf[tmp_ndx]), red_recv_buf,
shared_rec_count * sizeof(struct darshan_pnetcdf_file));
free(red_recv_buf);
}
else
{
pnetcdf_rec_count -= shared_rec_count;
}
/* update output buffer size to account for shared file reduction */
*pnetcdf_buf_sz = pnetcdf_rec_count * sizeof(struct darshan_pnetcdf_file);
PMPI_Type_free(&red_type);
PMPI_Op_free(&red_op);
PNETCDF_UNLOCK();
return;
}
#endif
static void pnetcdf_shutdown(
void **pnetcdf_buf,
int *pnetcdf_buf_sz)
{
int pnetcdf_rec_count;
PNETCDF_LOCK();
assert(pnetcdf_runtime);
pnetcdf_rec_count = pnetcdf_runtime->file_rec_count;
/* shutdown internal structures used for instrumenting */
pnetcdf_cleanup_runtime();
/* update output buffer size to account for shared file reduction */
*pnetcdf_buf_sz = pnetcdf_rec_count * sizeof(struct darshan_pnetcdf_file);
PNETCDF_UNLOCK();
return;
}
......
This diff is collapsed.
This diff is collapsed.
# ===========================================================================
# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_mpi.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PROG_CC_MPI([MPI-WANTED-TEST[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]])
#
# DESCRIPTION
#
# This macro tries to find out how to compile C programs that use MPI
# (Message Passing Interface), a standard API for parallel process
# communication (see http://www-unix.mcs.anl.gov/mpi/). The macro has to
# be used instead of the standard macro AC_PROG_CC and will replace the
# standard variable CC with the found compiler.
#
# MPI-WANTED-TEST is used to test whether MPI is actually wanted by the
# user. If MPI-WANTED_TEST is omitted or if it succeeds, the macro will
# try to find out how to use MPI, if it fails, the macro will call
# AC_PROG_CC to find a standard C compiler instead.
#
# When MPI is found, ACTION-IF-FOUND will be executed, if MPI is not found
# (or MPI-WANTED-TEST fails) ACTION-IF-NOT-FOUND is executed. If
# ACTION-IF-FOUND is not set, the macro will define HAVE_MPI.
#
# The following example demonstrates usage of the macro:
#
# # If --with-mpi=auto is used, try to find MPI, but use standard C compiler if it is not found.
# # If --with-mpi=yes is used, try to find MPI and fail if it isn't found.
# # If --with-mpi=no is used, use a standard C compiler instead.
# AC_ARG_WITH(mpi, [AS_HELP_STRING([--with-mpi],
# [compile with MPI (parallelization) support. If none is found,
# MPI is not used. Default: auto])
# ],,[with_mpi=auto])
# #
# AX_PROG_CC_MPI([test x"$with_mpi" != xno],[use_mpi=yes],[
# use_mpi=no
# if test x"$with_mpi" = xyes; then
# AC_MSG_FAILURE([MPI compiler requested, but couldn't use MPI.])
# else
# AC_MSG_WARN([No MPI compiler found, won't use MPI.])
# fi
# ])
#
# LICENSE
#
# Copyright (c) 2010,2011 Olaf Lenz <olenz@icp.uni-stuttgart.de>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 2
AC_DEFUN([AX_PROG_CC_MPI], [
AC_PREREQ(2.50)
# Check for compiler
# Needs to be split off into an extra macro to ensure right expansion
# order.
AC_REQUIRE([_AX_PROG_CC_MPI],[_AX_PROG_CC_MPI([$1])])
AS_IF([test x"$_ax_prog_cc_mpi_mpi_wanted" = xno],
[ _ax_prog_cc_mpi_mpi_found=no ],
[
AC_LANG_PUSH([C])
# test whether MPI_Init is available
# We do not use AC_SEARCH_LIBS here, as it caches its outcome and
# thus disallows corresponding calls in the other AX_PROG_*_MPI
# macros.
for lib in NONE mpi mpich; do
save_LIBS=$LIBS
if test x"$lib" = xNONE; then
AC_MSG_CHECKING([for function MPI_Init])
else
AC_MSG_CHECKING([for function MPI_Init in -l$lib])
LIBS="-l$lib $LIBS"
fi
AC_LINK_IFELSE([AC_LANG_CALL([],[MPI_Init])],
[ _ax_prog_cc_mpi_mpi_found=yes ],
[ _ax_prog_cc_mpi_mpi_found=no ])
AC_MSG_RESULT($_ax_prog_cc_mpi_mpi_found)
if test "x$_ax_prog_cc_mpi_mpi_found" = "xyes"; then
break;
fi
LIBS=$save_LIBS
done
# Check for header
AS_IF([test x"$_ax_prog_cc_mpi_mpi_found" = xyes], [
AC_MSG_CHECKING([for mpi.h])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <mpi.h>])],
[ AC_MSG_RESULT(yes)],
[ AC_MSG_RESULT(no)
_ax_prog_cc_mpi_mpi_found=no
])
])
AC_LANG_POP([C])
])
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
AS_IF([test x"$_ax_prog_cc_mpi_mpi_found" = xyes], [
ifelse([$2],,[AC_DEFINE(HAVE_MPI,1,[Define if you have the MPI library.])],[$2])
:
],[
$3
:
])
])dnl AX_PROG_CC_MPI
dnl _AX_PROG_CC_MPI is an internal macro required by AX_PROG_CC_MPI.
dnl To ensure the right expansion order, the main function AX_PROG_CC_MPI
dnl has to be split into two parts.
dnl
dnl Known MPI C compilers:
dnl mpicc
dnl mpixlc_r
dnl mpixlc
dnl hcc
dnl mpxlc_r
dnl mpxlc
dnl sxmpicc NEC SX
dnl mpifcc Fujitsu
dnl mpgcc
dnl mpcc
dnl cmpicc
dnl cc
dnl
AC_DEFUN([_AX_PROG_CC_MPI], [
AC_ARG_VAR(MPICC,[MPI C compiler command])
ifelse([$1],,[_ax_prog_cc_mpi_mpi_wanted=yes],[
AC_MSG_CHECKING([whether to compile using MPI])
if $1; then
_ax_prog_cc_mpi_mpi_wanted=yes
else
_ax_prog_cc_mpi_mpi_wanted=no
fi
AC_MSG_RESULT($_ax_prog_cc_mpi_mpi_wanted)
])
if test x"$_ax_prog_cc_mpi_mpi_wanted" = xyes; then
if test -z "$CC" && test -n "$MPICC"; then
CC="$MPICC"
else
AC_CHECK_TOOLS([CC], [mpicc mpixlc_r mpixlc hcc mpxlc_r mpxlc sxmpicc mpifcc mpgcc mpcc cmpicc cc gcc])
fi
fi
AC_PROG_CC
])dnl _AX_PROG_CC_MPI