1
1
openmpi/ompi/mca/common/sm/common_sm_mmap.h
Jeff Squyres 533633b8cb Fixes trac:1988. The little bug that turned out to be huge. Yoinks.
* Various cosmetic/style updates in the btl sm
 * Clean up concept of mpool module (I think that code was written way
   back when the concept of "modules" was fuzzy)
 * Bring over some old fixes from the /tmp/timattox-sm-coll/ tree to
   fix potential segv's when mmap'ed regions were at different
   addresses in different processes (thanks Tim!).
 * Change sm coll to no longer use mpool as its main source of shmem;
   rather, just mmap its own segment (because it's fixed size --
   there was nothing to be gained by using mpool; shedding the use of
   mpool saved a lot of complexity in the sm coll setup).  This
   effectively made Tim's fixes moot (because now everything is an
   offset into the mmap that is computed locally; there are no global
   pointers).  :-)
 * Slightly updated common/sm to allow making mmap's for a specific
   set of procs (vs. ''all'' procs in the process).  This potentially
   allows for same-host-inter-proc mmaps -- yay!
 * Fixed many, many things in the coll sm (particularly in reduce):
   * Fixed handling of MPI_IN_PLACE in reduce and allreduce
   * Fixed handling of non-contiguous datatypes in reduce
   * Changed the order of reductions to go from process (n-1)'s data
     to process 0's data, because that's how all other OMPI coll
     components work
   * Fixed lots of usage of ddt functions
   * When using a non-contiguous datatype, if the root process is not
     (n-1), now we used a 2nd convertor to copy from shmem to the rbuf
     (saves a memory copy vs. what was done before)
   * Lots and lots of little cleanups, clarifications, and minor
     optimizations (although still more could be done -- e.g., I think
     the use of write memory barriers is fairly sub-optimal; they
     could be ganged together at the root, for example)

I'm marking this as "fixes trac:1988" and closing the ticket; if something
is still broken, we can re-open the ticket.

This commit was SVN r21967.

The following Trac tickets were found above:
  Ticket 1988 --> https://svn.open-mpi.org/trac/ompi/ticket/1988
2009-09-15 00:25:21 +00:00

159 строки
5.0 KiB
C

/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef _COMMON_SM_MMAP_H_
#define _COMMON_SM_MMAP_H_
#include "ompi_config.h"
#include "opal/class/opal_object.h"
#include "opal/class/opal_list.h"
#include "opal/sys/atomic.h"
#include "ompi/mca/mpool/mpool.h"
#include "ompi/proc/proc.h"
#include "ompi/group/group.h"
BEGIN_C_DECLS
struct mca_mpool_base_module_t;
typedef struct mca_common_sm_file_header_t {
/* lock to control atomic access */
opal_atomic_lock_t seg_lock;
/* is the segment ready for use */
volatile int32_t seg_inited;
/* Offset to next available memory location available for allocation */
size_t seg_offset;
/* total size of the segment */
size_t seg_size;
} mca_common_sm_file_header_t;
typedef struct mca_common_sm_mmap_t {
/* double link list element */
opal_list_item_t map_item;
/* pointer to header imbeded in the shared memory file */
mca_common_sm_file_header_t *map_seg;
/* base address of the mmap'ed file */
unsigned char *map_addr;
/* base address of data segment */
unsigned char *data_addr;
/* How big it is (in bytes) */
size_t map_size;
/* Filename */
char map_path[OPAL_PATH_MAX];
#if defined(__WINDOWS__)
/* Handle to the object */
HANDLE hMappedObject;
#endif /* defined(__WINDOWS__) */
} mca_common_sm_mmap_t;
OBJ_CLASS_DECLARATION(mca_common_sm_mmap_t);
/**
* This routine is used to set up a shared memory file, backed
* by a specified file. It is assumed that the file does not
* exist before any of the current set of processes try and open
* it.
*
* @param procs - array of (ompi_proc_t*)'s to create this shared
* memory segment for. This array must be writable; it may be edited
* (in undefined ways) if the array contains procs that are not on
* this host. It is assumed that the caller will simply free this
* array upon return. (INOUT)
*
* @param num_procs - length of the procs array (IN)
*
* @param size - size of the file, in bytes (IN)
*
* @param file_name name of file to be opened. (IN)
*
* @param size_ctl_structure size of the control structure at
* the head of the file. The control structure
* is assumed to have mca_common_sm_file_header_t
* as its first segment (IN)
*
* @param data_set_alignment alignment of the data segment. this
* follows the control structure. If this
* value if 0, then assume that there will
* be no data segment following the control
* structure. (IN)
*
* @return value pointer to control structure at head of file.
*/
OMPI_DECLSPEC extern
mca_common_sm_mmap_t* mca_common_sm_mmap_init(
ompi_proc_t **procs,
size_t num_procs,
size_t size,
char *file_name,
size_t size_ctl_structure,
size_t data_seg_alignment);
/**
* This routine is used to set up a shared memory file, backed
* by a specified file. It is assumed that the file does not
* exist before any of the current set of processes try and open
* it.
*
* This routine is the same as mca_common_sm_mmap_init() except that
* it takes an (ompi_group_t*) parameter to specify the peers rather
* than an array of procs. Unlike mca_common_sm_mmap_init(), the
* group must contain *only* local peers, or this function will return
* NULL and not create any shared memory segment.
*/
OMPI_DECLSPEC extern
mca_common_sm_mmap_t* mca_common_sm_mmap_init_group(
ompi_group_t *group,
size_t size,
char *file_name,
size_t size_ctl_structure,
size_t data_seg_alignment);
/*
* Callback from the sm mpool
*/
OMPI_DECLSPEC extern
void* mca_common_sm_mmap_seg_alloc(
struct mca_mpool_base_module_t* mpool,
size_t* size,
mca_mpool_base_registration_t** registration);
/**
* This function will release all local ressources attached to the
* mmapped file. We assume that the operating system will destroy the
* file when the last process release it.
*
* @param sm_mmap - the control structure at head of file.
*
* @returnvalue 0 if everything was OK, otherwise a negative value.
*/
OMPI_DECLSPEC extern
int mca_common_sm_mmap_fini( mca_common_sm_mmap_t* sm_mmap );
END_C_DECLS
#endif