2004-11-22 00:37:56 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* 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.
|
2004-11-28 20:09:25 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-03-07 13:28:06 +00:00
|
|
|
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
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
|
|
|
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 00:37:56 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 01:03:09 +00:00
|
|
|
#include "ompi_config.h"
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <errno.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <unistd.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#endif
|
2005-12-12 20:24:07 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <string.h>
|
2005-12-12 20:24:07 +00:00
|
|
|
#endif /* HAVE_STRING_H */
|
|
|
|
#ifdef HAVE_FCNTL_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <fcntl.h>
|
2005-12-12 20:24:07 +00:00
|
|
|
#endif /* HAVE_FCNTL_H */
|
|
|
|
#ifdef HAVE_TIME_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <time.h>
|
2005-12-12 20:24:07 +00:00
|
|
|
#endif /* HAVE_TIME_H */
|
2004-10-22 16:06:05 +00:00
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <sys/types.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#endif
|
2005-12-12 20:24:07 +00:00
|
|
|
#ifdef HAVE_SYS_STAT_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <sys/stat.h>
|
2005-12-12 20:24:07 +00:00
|
|
|
#endif /* HAVE_SYS_STAT_H */
|
2004-10-22 16:06:05 +00:00
|
|
|
#ifdef HAVE_SYS_MMAN_H
|
2004-06-16 15:41:29 +00:00
|
|
|
#include <sys/mman.h>
|
2004-10-22 16:06:05 +00:00
|
|
|
#endif
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2009-02-14 02:26:12 +00:00
|
|
|
#include "opal/util/output.h"
|
2008-03-30 13:41:47 +00:00
|
|
|
#include "opal/align.h"
|
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
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
|
2009-03-12 17:58:39 +00:00
|
|
|
#include "orte/mca/rml/rml.h"
|
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
|
|
|
#include "orte/util/name_fns.h"
|
2004-06-16 15:41:29 +00:00
|
|
|
|
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
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/proc/proc.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
#include "ompi/mca/dpm/dpm.h"
|
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
|
|
|
#include "ompi/mca/mpool/sm/mpool_sm.h"
|
|
|
|
#include "common_sm_mmap.h"
|
2008-02-28 01:57:57 +00:00
|
|
|
|
2004-06-16 15:41:29 +00:00
|
|
|
OBJ_CLASS_INSTANCE(
|
2004-08-06 19:35:57 +00:00
|
|
|
mca_common_sm_mmap_t,
|
2005-07-03 16:06:07 +00:00
|
|
|
opal_object_t,
|
2004-06-16 15:41:29 +00:00
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
2004-08-06 19:35:57 +00:00
|
|
|
/*
|
|
|
|
* Instance that is shared between components that use shared memory
|
|
|
|
*/
|
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
|
|
|
#if 0
|
|
|
|
/* JMS remove me! */
|
2004-08-06 19:35:57 +00:00
|
|
|
mca_common_sm_mmap_t *mca_common_sm_mmap = NULL;
|
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
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock to protect multiple instances of mmap_init() from being
|
|
|
|
* invoked simultaneously (because of RML usage).
|
|
|
|
*/
|
|
|
|
static opal_mutex_t mutex;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* List of RML messages that have arrived that have not yet been
|
|
|
|
* consumed by the thread who is looking to attach to the backing file
|
|
|
|
* that the RML message corresponds to.
|
|
|
|
*/
|
|
|
|
static opal_list_t pending_rml_msgs;
|
|
|
|
static bool pending_rml_msgs_init = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Items on the pending_rml_msgs list
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
opal_list_item_t super;
|
|
|
|
char file_name[OPAL_PATH_MAX];
|
|
|
|
int sm_file_inited;
|
|
|
|
} pending_rml_msg_t;
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(pending_rml_msg_t, opal_list_item_t, NULL, NULL);
|
2004-08-06 19:35:57 +00:00
|
|
|
|
2007-01-01 02:39:02 +00:00
|
|
|
#if !defined(__WINDOWS__)
|
2008-03-30 13:41:47 +00:00
|
|
|
|
|
|
|
static mca_common_sm_mmap_t* create_map(int fd, size_t size, char *file_name,
|
|
|
|
size_t size_ctl_structure,
|
|
|
|
size_t data_seg_alignment)
|
|
|
|
{
|
|
|
|
mca_common_sm_mmap_t *map;
|
|
|
|
mca_common_sm_file_header_t *seg;
|
2005-08-15 16:48:43 +00:00
|
|
|
unsigned char *addr = NULL;
|
2004-08-04 17:22:16 +00:00
|
|
|
|
2008-03-30 13:41:47 +00:00
|
|
|
/* map the file and initialize segment state */
|
|
|
|
seg = (mca_common_sm_file_header_t*)
|
|
|
|
mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
|
|
|
if((void*)-1 == seg) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set up the map object */
|
|
|
|
map = OBJ_NEW(mca_common_sm_mmap_t);
|
2009-05-06 20:11:28 +00:00
|
|
|
strncpy(map->map_path, file_name, OPAL_PATH_MAX);
|
2008-03-30 13:41:47 +00:00
|
|
|
/* the first entry in the file is the control structure. The first
|
|
|
|
entry in the control structure is an mca_common_sm_file_header_t
|
|
|
|
element */
|
|
|
|
map->map_seg = seg;
|
|
|
|
|
|
|
|
addr = ((unsigned char *)seg) + size_ctl_structure;
|
|
|
|
/* If we have a data segment (i.e., if 0 != data_seg_alignment),
|
|
|
|
then make it the first aligned address after the control
|
|
|
|
structure. */
|
|
|
|
if (0 != data_seg_alignment) {
|
|
|
|
addr = OPAL_ALIGN_PTR(addr, data_seg_alignment, unsigned char*);
|
|
|
|
|
|
|
|
/* is addr past end of file ? */
|
|
|
|
if((unsigned char*)seg + size < addr) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_common_sm_mmap_init: "
|
2008-03-30 13:41:47 +00:00
|
|
|
"memory region too small len %lu addr %p\n",
|
|
|
|
(unsigned long)size, addr);
|
|
|
|
return NULL;
|
2007-01-03 00:06:02 +00:00
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
}
|
2008-03-30 13:41:47 +00:00
|
|
|
map->data_addr = addr;
|
|
|
|
map->map_addr = (unsigned char *)seg;
|
|
|
|
map->map_size = size;
|
|
|
|
|
|
|
|
return map;
|
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Same as mca_common_sm_mmap_init(), but takes an (ompi_group_t*)
|
|
|
|
* argument instead of na array of ompi_proc_t's.
|
|
|
|
*
|
|
|
|
* This function just checks the group to ensure that all the procs
|
|
|
|
* are local, and if they are, calls mca_common_sm_mmap_init().
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
size_t i, group_size;
|
|
|
|
ompi_proc_t *proc, **procs;
|
|
|
|
|
|
|
|
group_size = ompi_group_size(group);
|
|
|
|
procs = (ompi_proc_t**) malloc(sizeof(ompi_proc_t*) * group_size);
|
|
|
|
if (NULL == procs) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
for (i = 0; i < group_size; ++i) {
|
|
|
|
proc = ompi_group_peer_lookup(group,i);
|
|
|
|
if (!OPAL_PROC_ON_LOCAL_NODE(proc->proc_flags)) {
|
|
|
|
free(procs);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
procs[i] = proc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mca_common_sm_mmap_init(procs, group_size, size, file_name,
|
|
|
|
size_ctl_structure, data_seg_alignment);
|
|
|
|
}
|
|
|
|
|
|
|
|
mca_common_sm_mmap_t* mca_common_sm_mmap_init(ompi_proc_t **procs,
|
|
|
|
size_t num_procs,
|
|
|
|
size_t size, char *file_name,
|
2008-03-30 13:41:47 +00:00
|
|
|
size_t size_ctl_structure,
|
|
|
|
size_t data_seg_alignment)
|
|
|
|
{
|
|
|
|
int fd = -1;
|
|
|
|
mca_common_sm_mmap_t* map = NULL;
|
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
|
|
|
size_t mem_offset, p;
|
|
|
|
int rc = 0, sm_file_inited = 0, num_local_procs = 0;
|
|
|
|
struct iovec iov[3];
|
2008-03-30 13:41:47 +00:00
|
|
|
int sm_file_created = OMPI_RML_TAG_SM_BACK_FILE_CREATED;
|
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
|
|
|
orte_process_name_t *lowest_name = NULL;
|
|
|
|
char filename_to_send[OPAL_PATH_MAX];
|
|
|
|
opal_list_item_t *item;
|
|
|
|
pending_rml_msg_t *rml_msg;
|
|
|
|
|
|
|
|
/* Reorder all procs array to have all the local procs at the
|
|
|
|
beginning. Simultaneously look for the local proc with the
|
|
|
|
lowest name. */
|
|
|
|
for (p = 0; p < num_procs; p++) {
|
|
|
|
if (OPAL_PROC_ON_LOCAL_NODE(procs[p]->proc_flags)) {
|
|
|
|
procs[num_local_procs] = procs[p];
|
|
|
|
if (NULL == lowest_name) {
|
|
|
|
lowest_name = &(procs[0]->proc_name);
|
|
|
|
} else if (orte_util_compare_name_fields(ORTE_NS_CMP_ALL,
|
|
|
|
&(procs[p]->proc_name),
|
|
|
|
lowest_name) < 0) {
|
|
|
|
lowest_name = &(procs[p]->proc_name);
|
|
|
|
}
|
|
|
|
++num_local_procs;
|
2007-01-01 02:39:02 +00:00
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
}
|
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
|
|
|
/* If there's no local procs, there's nothing to do */
|
|
|
|
if (0 == num_local_procs) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
num_procs = num_local_procs;
|
2008-03-30 13:41:47 +00:00
|
|
|
|
|
|
|
iov[0].iov_base = &sm_file_created;
|
|
|
|
iov[0].iov_len = sizeof(sm_file_created);
|
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
|
|
|
memset(filename_to_send, 0, sizeof(filename_to_send));
|
|
|
|
strncpy(filename_to_send, file_name, sizeof(filename_to_send) - 1);
|
|
|
|
iov[1].iov_base = filename_to_send;
|
|
|
|
iov[1].iov_len = sizeof(filename_to_send);
|
|
|
|
iov[2].iov_base = &sm_file_inited;
|
|
|
|
iov[2].iov_len = sizeof(sm_file_inited);
|
|
|
|
|
|
|
|
/* Lock here to prevent multiple threads from invoking this
|
|
|
|
function simultaneously. The critical section we're protecting
|
|
|
|
is usage of the RML in this block. */
|
|
|
|
opal_mutex_lock(&mutex);
|
|
|
|
|
|
|
|
if (!pending_rml_msgs_init) {
|
|
|
|
OBJ_CONSTRUCT(&(pending_rml_msgs), opal_list_t);
|
|
|
|
pending_rml_msgs_init = true;
|
|
|
|
}
|
2008-03-30 13:41:47 +00:00
|
|
|
|
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
|
|
|
/* Figure out if I am the lowest rank in the group. If so, I will
|
|
|
|
create the shared file. */
|
|
|
|
if (0 == orte_util_compare_name_fields(ORTE_NS_CMP_ALL,
|
|
|
|
&(ompi_proc_local()->proc_name),
|
|
|
|
lowest_name)) {
|
2007-01-01 02:39:02 +00:00
|
|
|
/* process initializing the file */
|
|
|
|
fd = open(file_name, O_CREAT|O_RDWR, 0600);
|
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
|
|
|
if (fd < 0) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_common_sm_mmap_init: "
|
2008-03-30 13:41:47 +00:00
|
|
|
"open %s failed with errno=%d\n", file_name, errno);
|
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
|
|
|
} else if (ftruncate(fd, size) != 0) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_common_sm_mmap_init: "
|
2008-03-30 13:41:47 +00:00
|
|
|
"ftruncate failed with errno=%d\n", errno);
|
2007-01-01 02:39:02 +00:00
|
|
|
} else {
|
2008-03-30 13:41:47 +00:00
|
|
|
map = create_map(fd, size, file_name, size_ctl_structure,
|
|
|
|
data_seg_alignment);
|
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
|
|
|
if (map != NULL) {
|
2008-03-30 13:41:47 +00:00
|
|
|
sm_file_inited = 1;
|
|
|
|
|
|
|
|
/* initialize the segment - only the first process
|
|
|
|
to open the file */
|
|
|
|
mem_offset = map->data_addr - (unsigned char *)map->map_seg;
|
|
|
|
map->map_seg->seg_offset = mem_offset;
|
|
|
|
map->map_seg->seg_size = size - mem_offset;
|
|
|
|
opal_atomic_unlock(&map->map_seg->seg_lock);
|
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
|
|
|
map->map_seg->seg_inited = 0;
|
2008-03-30 13:41:47 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-03 00:06:02 +00:00
|
|
|
|
2007-01-01 02:39:02 +00:00
|
|
|
/* signal the rest of the local procs that the backing file
|
|
|
|
has been created */
|
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
|
|
|
for (p = 1; p < num_procs; p++) {
|
|
|
|
rc = orte_rml.send(&(procs[p]->proc_name), iov, 3,
|
2008-03-30 13:41:47 +00:00
|
|
|
OMPI_RML_TAG_SM_BACK_FILE_CREATED, 0);
|
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
|
|
|
if (rc < 0) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_common_sm_mmap_init: "
|
2008-03-30 13:41:47 +00:00
|
|
|
"orte_rml.send failed to %lu with errno=%d\n",
|
|
|
|
(unsigned long)p, errno);
|
|
|
|
goto out;
|
2007-01-01 02:39:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
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
|
|
|
/* All other procs wait for the file to be initialized before
|
|
|
|
using the backing file. However, since these shared
|
|
|
|
backing files may be created simultaneously in multiple
|
|
|
|
threads, the RML messages may arrive in any order. So
|
|
|
|
first check to see if we previously received a message for
|
|
|
|
me. */
|
|
|
|
for (item = opal_list_get_first(&pending_rml_msgs);
|
|
|
|
opal_list_get_end(&pending_rml_msgs) != item;
|
|
|
|
item = opal_list_get_next(item)) {
|
|
|
|
rml_msg = (pending_rml_msg_t*) item;
|
|
|
|
if (0 == strcmp(rml_msg->file_name, file_name)) {
|
|
|
|
opal_list_remove_item(&pending_rml_msgs, item);
|
|
|
|
sm_file_inited = rml_msg->sm_file_inited;
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't find a message already waiting, block on
|
|
|
|
receiving from the RML. */
|
|
|
|
if (opal_list_get_end(&pending_rml_msgs) == item) {
|
|
|
|
while (1) {
|
|
|
|
rc = orte_rml.recv(&(procs[0]->proc_name), iov, 3,
|
|
|
|
OMPI_RML_TAG_SM_BACK_FILE_CREATED, 0);
|
|
|
|
if (rc < 0) {
|
|
|
|
opal_output(0, "mca_common_sm_mmap_init: "
|
|
|
|
"orte_rml.recv failed from %d with errno=%d\n",
|
|
|
|
0, errno);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Was the message for me? If so, we're done */
|
|
|
|
if (0 == strcmp(filename_to_send, file_name)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If not, put it on the pending list and try again */
|
|
|
|
rml_msg = OBJ_NEW(pending_rml_msg_t);
|
|
|
|
if (NULL == rml_msg) {
|
|
|
|
opal_output(0, "mca_common_sm_mmap_init: failed to create pending rml message");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
memcpy(rml_msg->file_name, filename_to_send,
|
|
|
|
sizeof(rml_msg->file_name));
|
|
|
|
rml_msg->sm_file_inited = sm_file_inited;
|
|
|
|
opal_list_append(&pending_rml_msgs, &(rml_msg->super));
|
|
|
|
}
|
2007-01-03 00:06:02 +00:00
|
|
|
}
|
|
|
|
|
2008-03-30 13:41:47 +00:00
|
|
|
/* check to see if file inited correctly */
|
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
|
|
|
if (sm_file_inited != 0) {
|
2008-03-30 13:41:47 +00:00
|
|
|
fd = open(file_name, O_RDWR, 0600);
|
2007-01-01 02:39:02 +00:00
|
|
|
|
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
|
|
|
if (fd != -1) {
|
2008-03-30 13:41:47 +00:00
|
|
|
map = create_map(fd, size, file_name, size_ctl_structure,
|
|
|
|
data_seg_alignment);
|
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
|
|
|
}
|
2007-01-01 02:39:02 +00:00
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
}
|
2007-01-01 02:39:02 +00:00
|
|
|
|
2008-03-30 13:41:47 +00:00
|
|
|
out:
|
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
|
|
|
opal_mutex_unlock(&mutex);
|
|
|
|
|
|
|
|
if (fd != -1) {
|
|
|
|
close(fd);
|
|
|
|
}
|
2007-01-01 02:39:02 +00:00
|
|
|
|
2008-03-30 13:41:47 +00:00
|
|
|
return map;
|
|
|
|
}
|
2005-12-12 20:24:07 +00:00
|
|
|
#else
|
2008-03-30 13:41:47 +00:00
|
|
|
mca_common_sm_mmap_t* mca_common_sm_mmap_init(size_t size, char *file_name,
|
|
|
|
size_t size_ctl_structure, size_t data_seg_alignment)
|
|
|
|
{
|
2007-01-01 02:39:02 +00:00
|
|
|
int fd = -1, return_code = OMPI_SUCCESS;
|
|
|
|
bool file_previously_opened = false;
|
|
|
|
mca_common_sm_file_header_t* seg = NULL;
|
|
|
|
mca_common_sm_mmap_t* map = NULL;
|
|
|
|
unsigned char *addr = NULL;
|
2008-03-30 13:41:47 +00:00
|
|
|
size_t tmp, mem_offset;
|
2007-01-01 02:39:02 +00:00
|
|
|
|
2005-12-31 15:06:24 +00:00
|
|
|
HANDLE hMapObject = INVALID_HANDLE_VALUE;
|
2005-12-12 20:24:07 +00:00
|
|
|
LPVOID lpvMem = NULL;
|
2006-08-20 19:45:28 +00:00
|
|
|
char *temp1, *temp2;
|
|
|
|
int rc;
|
2005-12-12 20:24:07 +00:00
|
|
|
|
2006-08-20 19:45:28 +00:00
|
|
|
/**
|
|
|
|
* On Windows the shared file will be created by the OS directly on
|
|
|
|
* the system ressources. Therefore, no file get involved in the
|
|
|
|
* operation. However, a unique key should be used as name for the
|
|
|
|
* shared memory object in order to allow all processes to access
|
|
|
|
* the same unique shared memory region. The key will be obtained
|
|
|
|
* from the original file_name by replacing all path separator
|
|
|
|
* occurences by '/' (as '\' is not allowed on the object name).
|
|
|
|
*/
|
|
|
|
temp1 = strdup(file_name);
|
|
|
|
temp2 = temp1;
|
|
|
|
while( NULL != (temp2 = strchr(temp2, OPAL_PATH_SEP[0])) ) {
|
|
|
|
*temp2 = '/';
|
|
|
|
}
|
2005-12-12 20:24:07 +00:00
|
|
|
hMapObject = CreateFileMapping( INVALID_HANDLE_VALUE, /* use paging file */
|
|
|
|
NULL, /* no security attributes */
|
|
|
|
PAGE_READWRITE, /* read/write access */
|
|
|
|
0, /* size: high 32-bits */
|
2007-01-24 00:51:01 +00:00
|
|
|
(DWORD)size, /* size: low 32-bits */
|
2006-08-20 19:45:28 +00:00
|
|
|
temp1); /* name of map object */
|
|
|
|
if( NULL == hMapObject ) {
|
|
|
|
rc = GetLastError();
|
|
|
|
goto return_error;
|
|
|
|
}
|
2005-12-31 15:06:24 +00:00
|
|
|
if( ERROR_ALREADY_EXISTS == GetLastError() )
|
|
|
|
file_previously_opened=true;
|
2006-08-20 19:45:28 +00:00
|
|
|
free(temp1); /* relase the temporary file name */
|
2005-12-31 15:06:24 +00:00
|
|
|
|
2006-08-20 19:45:28 +00:00
|
|
|
/* Get a pointer to the file-mapped shared memory. */
|
|
|
|
lpvMem = MapViewOfFile( hMapObject, /* object to map view of */
|
|
|
|
FILE_MAP_WRITE, /* read/write access */
|
|
|
|
0, /* high offset: map from */
|
|
|
|
0, /* low offset: beginning */
|
|
|
|
0); /* default: map entire file */
|
2006-01-19 07:07:47 +00:00
|
|
|
if( NULL == lpvMem ) {
|
2006-08-20 19:45:28 +00:00
|
|
|
rc = GetLastError();
|
2005-12-31 15:06:24 +00:00
|
|
|
goto return_error;
|
2006-01-19 07:07:47 +00:00
|
|
|
}
|
2006-08-20 19:45:28 +00:00
|
|
|
seg = (mca_common_sm_file_header_t*)lpvMem;
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2004-08-04 17:22:16 +00:00
|
|
|
/* set up the map object */
|
2004-08-06 19:35:57 +00:00
|
|
|
map = OBJ_NEW(mca_common_sm_mmap_t);
|
2009-05-06 20:11:28 +00:00
|
|
|
strncpy(map->map_path, file_name, OPAL_PATH_MAX);
|
2005-12-31 15:06:24 +00:00
|
|
|
/* the first entry in the file is the control structure. The first
|
2004-08-18 15:02:21 +00:00
|
|
|
entry in the control structure is an mca_common_sm_file_header_t
|
2004-08-11 16:06:14 +00:00
|
|
|
element */
|
2004-06-16 15:41:29 +00:00
|
|
|
map->map_seg = seg;
|
2004-08-11 16:06:14 +00:00
|
|
|
|
2005-08-08 21:38:27 +00:00
|
|
|
/* If we have a data segment (i.e., if 0 != data_seg_alignment),
|
|
|
|
then make it the first aligned address after the control
|
|
|
|
structure. */
|
|
|
|
if (0 != data_seg_alignment) {
|
|
|
|
addr = ((unsigned char *) seg) + size_ctl_structure;
|
|
|
|
/* calculate how far off alignment we are */
|
|
|
|
tmp = ((size_t) addr) % data_seg_alignment;
|
|
|
|
/* if we're off alignment, then move up to the next alignment */
|
2005-12-31 15:06:24 +00:00
|
|
|
if( tmp > 0 )
|
2005-08-08 21:38:27 +00:00
|
|
|
addr += (data_seg_alignment - tmp);
|
2005-08-08 21:29:05 +00:00
|
|
|
|
2005-08-08 21:38:27 +00:00
|
|
|
/* is addr past end of file ? */
|
2005-12-31 15:06:24 +00:00
|
|
|
if( (unsigned char*)seg+size < addr ) {
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output(0, "mca_common_sm_mmap_init: memory region too small len %d addr %p\n",
|
2005-08-08 21:38:27 +00:00
|
|
|
size,addr);
|
2005-12-31 15:06:24 +00:00
|
|
|
goto return_error;
|
2005-08-08 21:38:27 +00:00
|
|
|
}
|
2005-12-31 15:18:58 +00:00
|
|
|
map->data_addr = addr;
|
|
|
|
} else {
|
|
|
|
map->data_addr = NULL;
|
2004-08-04 17:22:16 +00:00
|
|
|
}
|
2005-12-31 15:06:24 +00:00
|
|
|
mem_offset = addr-(unsigned char *)seg;
|
2004-08-13 16:01:51 +00:00
|
|
|
map->map_addr = (unsigned char *)seg;
|
2004-08-11 16:06:14 +00:00
|
|
|
map->map_size = size;
|
2004-08-04 17:22:16 +00:00
|
|
|
|
|
|
|
/* initialize the segment - only the first process to open the file */
|
|
|
|
if( !file_previously_opened ) {
|
2005-07-03 21:38:51 +00:00
|
|
|
opal_atomic_unlock(&seg->seg_lock);
|
2004-08-04 17:22:16 +00:00
|
|
|
seg->seg_inited = false;
|
2004-08-11 16:06:14 +00:00
|
|
|
seg->seg_offset = mem_offset;
|
2007-03-07 13:28:06 +00:00
|
|
|
/* initialize size after subtracting out space used by the header */
|
|
|
|
seg->seg_size = size - mem_offset;
|
2004-08-04 17:22:16 +00:00
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2006-08-21 04:05:19 +00:00
|
|
|
map->hMappedObject = hMapObject;
|
2004-08-04 17:22:16 +00:00
|
|
|
|
2004-06-16 15:41:29 +00:00
|
|
|
return map;
|
2005-12-31 15:06:24 +00:00
|
|
|
|
|
|
|
return_error:
|
2006-08-20 19:45:28 +00:00
|
|
|
{
|
|
|
|
char* localbuf = NULL;
|
|
|
|
FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL, rc, 0, (LPTSTR)&localbuf, 1024, NULL );
|
2008-06-09 14:53:58 +00:00
|
|
|
opal_output( 0, "%s\n", localbuf );
|
2006-08-20 19:45:28 +00:00
|
|
|
LocalFree( localbuf );
|
|
|
|
}
|
2005-12-31 15:06:24 +00:00
|
|
|
if( NULL != lpvMem ) UnmapViewOfFile( lpvMem );
|
|
|
|
if( NULL != hMapObject ) CloseHandle(hMapObject);
|
|
|
|
|
|
|
|
return NULL;
|
2004-06-16 15:41:29 +00:00
|
|
|
}
|
2008-03-30 13:41:47 +00:00
|
|
|
#endif
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2005-12-31 15:06:24 +00:00
|
|
|
int mca_common_sm_mmap_fini( mca_common_sm_mmap_t* sm_mmap )
|
|
|
|
{
|
2005-12-31 16:11:58 +00:00
|
|
|
int rc = OMPI_SUCCESS;
|
|
|
|
|
2005-12-31 15:06:24 +00:00
|
|
|
if( NULL != sm_mmap->map_seg ) {
|
|
|
|
#if !defined(__WINDOWS__)
|
2006-04-23 21:15:09 +00:00
|
|
|
rc = munmap((void*) sm_mmap->map_addr, sm_mmap->map_size );
|
2005-12-31 16:11:58 +00:00
|
|
|
sm_mmap->map_addr = NULL;
|
|
|
|
sm_mmap->map_size = 0;
|
2005-12-31 15:06:24 +00:00
|
|
|
#else
|
2005-12-31 16:11:58 +00:00
|
|
|
BOOL return_error = UnmapViewOfFile( sm_mmap->map_addr );
|
2005-12-31 15:06:24 +00:00
|
|
|
if( false == return_error ) {
|
2005-12-31 16:11:58 +00:00
|
|
|
rc = GetLastError();
|
2005-12-31 15:06:24 +00:00
|
|
|
}
|
2006-08-20 19:45:28 +00:00
|
|
|
CloseHandle(sm_mmap->hMappedObject);
|
|
|
|
|
2005-12-31 15:06:24 +00:00
|
|
|
#endif /* !defined(__WINDOWS__) */
|
|
|
|
}
|
2005-12-31 16:11:58 +00:00
|
|
|
return rc;
|
2005-12-31 15:06:24 +00:00
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
|
2004-08-11 16:06:14 +00:00
|
|
|
/**
|
|
|
|
* allocate memory from a previously allocated shared memory
|
|
|
|
* block.
|
|
|
|
*
|
|
|
|
* @param size size of request, in bytes (IN)
|
|
|
|
*
|
|
|
|
* @retval addr virtual address
|
|
|
|
*/
|
2005-06-21 17:10:28 +00:00
|
|
|
|
|
|
|
void* mca_common_sm_mmap_seg_alloc(
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
size_t* size,
|
2005-06-24 21:12:38 +00:00
|
|
|
mca_mpool_base_registration_t** registration)
|
2004-06-16 15:41:29 +00:00
|
|
|
{
|
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
|
|
|
mca_mpool_sm_module_t *sm_module = (mca_mpool_sm_module_t*) mpool;
|
|
|
|
mca_common_sm_mmap_t *map = sm_module->sm_common_mmap;
|
2004-08-18 15:02:21 +00:00
|
|
|
mca_common_sm_file_header_t* seg = map->map_seg;
|
2004-06-16 15:41:29 +00:00
|
|
|
void* addr;
|
|
|
|
|
2005-07-03 21:38:51 +00:00
|
|
|
opal_atomic_lock(&seg->seg_lock);
|
2007-03-07 13:28:06 +00:00
|
|
|
if(seg->seg_offset + *size > seg->seg_size) {
|
2004-06-16 15:41:29 +00:00
|
|
|
addr = NULL;
|
|
|
|
} else {
|
2006-04-23 21:14:03 +00:00
|
|
|
size_t fixup;
|
|
|
|
|
2004-08-11 16:06:14 +00:00
|
|
|
/* add base address to segment offset */
|
|
|
|
addr = map->data_addr + seg->seg_offset;
|
2004-06-16 15:41:29 +00:00
|
|
|
seg->seg_offset += *size;
|
2006-04-23 21:14:03 +00:00
|
|
|
|
|
|
|
/* fix up seg_offset so next allocation is aligned on a
|
|
|
|
sizeof(long) boundry. Do it here so that we don't have to
|
|
|
|
check before checking remaining size in buffer */
|
|
|
|
if ((fixup = (seg->seg_offset & (sizeof(long) - 1))) > 0) {
|
|
|
|
seg->seg_offset += sizeof(long) - fixup;
|
|
|
|
}
|
2004-06-16 15:41:29 +00:00
|
|
|
}
|
2005-08-08 21:29:05 +00:00
|
|
|
if (NULL != registration) {
|
2005-07-14 19:10:46 +00:00
|
|
|
*registration = NULL;
|
2005-08-08 21:29:05 +00:00
|
|
|
}
|
2005-07-03 21:38:51 +00:00
|
|
|
opal_atomic_unlock(&seg->seg_lock);
|
2004-06-16 15:41:29 +00:00
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|