2004-07-14 18:11:03 +04:00
|
|
|
// -*- c++ -*-
|
|
|
|
//
|
2005-11-05 22:57:48 +03: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 23:09:25 +03:00
|
|
|
// Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
// University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
// Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
// All rights reserved.
|
2008-01-12 16:20:38 +03:00
|
|
|
// Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
// $COPYRIGHT$
|
|
|
|
//
|
|
|
|
// Additional copyrights may follow
|
|
|
|
//
|
2004-07-14 18:11:03 +04:00
|
|
|
// $HEADER$
|
|
|
|
//
|
|
|
|
|
2004-07-14 22:01:21 +04:00
|
|
|
// do not include ompi_config.h because it kills the free/malloc defines
|
|
|
|
#include "mpi.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mpi/cxx/mpicxx.h"
|
2008-01-12 16:20:38 +03:00
|
|
|
|
|
|
|
#ifdef HAVE_SCHED_H
|
|
|
|
#include <sched.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "opal/threads/mutex.h"
|
|
|
|
#include "opal/class/opal_object.h"
|
2005-07-04 02:45:48 +04:00
|
|
|
#include "opal/threads/mutex.h"
|
2004-07-14 18:11:03 +04:00
|
|
|
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
#include "ompi/communicator/communicator.h"
|
|
|
|
#include "ompi/attribute/attribute.h"
|
|
|
|
#include "ompi/errhandler/errhandler.h"
|
|
|
|
|
2008-01-12 16:20:38 +03:00
|
|
|
// Struct to make a linked list of keyval intercept data
|
|
|
|
struct keyval_intercept_data_item_t {
|
|
|
|
opal_list_item_t super;
|
|
|
|
int kid_keyval;
|
|
|
|
MPI::Comm::keyval_intercept_data_t *kid_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
// We are explicitly *not* using the STL here (just for the sake of
|
|
|
|
// avoiding using the STL; e.g., Solaris has 2 STL's -- which one
|
|
|
|
// should OMPI use? What if OMPI uses one and the MPI app wants to
|
|
|
|
// use the other?), so use the C++-like opal_list_t stuff.
|
|
|
|
OBJ_CLASS_DECLARATION(keyval_intercept_data_item_t);
|
|
|
|
OBJ_CLASS_INSTANCE(keyval_intercept_data_item_t, opal_list_item_t, NULL, NULL);
|
|
|
|
|
|
|
|
// List to hold the cxx_extra_state structs that are new'ed when C++
|
|
|
|
// keyvals are created
|
|
|
|
static opal_list_t cxx_extra_states;
|
|
|
|
// Whether or not cxx_extra_states has been initialized yet
|
|
|
|
static volatile bool cxx_extra_states_init = false;
|
|
|
|
// Will be set to 1 by the thread who is actually doing the initialization
|
|
|
|
static volatile int32_t cxx_extra_states_init_thread = 0;
|
|
|
|
// Lock to protect cxx_extra_states from being accessed by multiple
|
|
|
|
// threads at the same time
|
|
|
|
opal_mutex_t MPI::Comm::cxx_extra_states_lock;
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
//
|
|
|
|
// These functions are all not inlined because they need to use locks to
|
|
|
|
// protect the handle maps and it would be bad to have those in headers
|
|
|
|
// because that would require that we always install the lock headers.
|
|
|
|
// Instead we take the function call hit (we're locking - who cares about
|
|
|
|
// a function call. And these aren't exactly the performance critical
|
|
|
|
// functions) and make everyone's life easier.
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
// construction
|
|
|
|
MPI::Comm::Comm()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy
|
|
|
|
MPI::Comm::Comm(const Comm_Null& data) : Comm_Null(data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
MPI::Comm::Set_errhandler(const MPI::Errhandler& errhandler)
|
|
|
|
{
|
|
|
|
my_errhandler = (MPI::Errhandler *)&errhandler;
|
2006-12-31 02:41:42 +03:00
|
|
|
OPAL_THREAD_LOCK(MPI::mpi_map_mutex);
|
|
|
|
MPI::Comm::mpi_comm_err_map[mpi_comm] = this;
|
|
|
|
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
2004-07-14 18:11:03 +04:00
|
|
|
(void)MPI_Errhandler_set(mpi_comm, errhandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-12 16:20:38 +03:00
|
|
|
// This function is called back out of the keyval destructor in the C
|
|
|
|
// layer when the keyval is not be used by any attributes anymore,
|
|
|
|
// anywhere. So we can definitely safely remove the entry for this
|
|
|
|
// keyval's C++ intercept extra_state from the list
|
|
|
|
static void cxx_comm_keyval_destructor(int keyval)
|
|
|
|
{
|
|
|
|
opal_list_item_t *item;
|
|
|
|
keyval_intercept_data_item_t *kid;
|
|
|
|
|
|
|
|
// Search the list until we find the item with the same keyval
|
|
|
|
for (item = opal_list_get_first(&cxx_extra_states);
|
|
|
|
opal_list_get_end(&cxx_extra_states) != item;
|
|
|
|
item = opal_list_get_next(item)) {
|
|
|
|
kid = (keyval_intercept_data_item_t *) item;
|
|
|
|
if (kid->kid_keyval == keyval) {
|
|
|
|
delete kid->kid_data;
|
|
|
|
opal_list_remove_item(&cxx_extra_states, item);
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-14 18:11:03 +04:00
|
|
|
//JGS I took the const out because it causes problems when trying to
|
|
|
|
//call this function with the predefined NULL_COPY_FN etc.
|
|
|
|
int
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
MPI::Comm::do_create_keyval(MPI_Comm_copy_attr_function* c_copy_fn,
|
|
|
|
MPI_Comm_delete_attr_function* c_delete_fn,
|
|
|
|
Copy_attr_function* cxx_copy_fn,
|
|
|
|
Delete_attr_function* cxx_delete_fn,
|
2008-01-12 16:20:38 +03:00
|
|
|
void* extra_state, int &keyval)
|
2004-07-14 18:11:03 +04:00
|
|
|
{
|
2008-01-12 16:20:38 +03:00
|
|
|
int ret, count = 0;
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
ompi_attribute_fn_ptr_union_t copy_fn;
|
|
|
|
ompi_attribute_fn_ptr_union_t delete_fn;
|
2008-01-12 16:20:38 +03:00
|
|
|
keyval_intercept_data_t *cxx_extra_state;
|
2004-07-14 18:11:03 +04:00
|
|
|
|
2008-01-12 16:20:38 +03:00
|
|
|
// If both the callbacks are C, then do the simple thing -- no
|
|
|
|
// need for all the C++ machinery.
|
|
|
|
if (NULL != c_copy_fn && NULL != c_delete_fn) {
|
|
|
|
copy_fn.attr_communicator_copy_fn =
|
|
|
|
(MPI_Comm_internal_copy_attr_function*) c_copy_fn;
|
|
|
|
delete_fn.attr_communicator_delete_fn = c_delete_fn;
|
|
|
|
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn, delete_fn,
|
|
|
|
&keyval, extra_state, 0, NULL);
|
|
|
|
if (MPI_SUCCESS != ret) {
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, ret,
|
|
|
|
"MPI::Comm::Create_keyval");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If either callback is C++, then we have to use the C++
|
|
|
|
// callbacks for both, because we have to generate a new
|
|
|
|
// extra_state. And since we only get one extra_state (i.e., we
|
|
|
|
// don't get one extra_state for the copy callback and another
|
|
|
|
// extra_state for the delete callback), we have to use the C++
|
|
|
|
// callbacks for both (and therefore translate the C++-special
|
|
|
|
// extra_state into the user's original extra_state).
|
|
|
|
cxx_extra_state = new keyval_intercept_data_t;
|
|
|
|
if (NULL == cxx_extra_state) {
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM,
|
|
|
|
"MPI::Comm::Create_keyval");
|
|
|
|
}
|
|
|
|
cxx_extra_state->c_copy_fn = c_copy_fn;
|
|
|
|
cxx_extra_state->cxx_copy_fn = cxx_copy_fn;
|
|
|
|
cxx_extra_state->c_delete_fn = c_delete_fn;
|
|
|
|
cxx_extra_state->cxx_delete_fn = cxx_delete_fn;
|
2004-07-14 18:11:03 +04:00
|
|
|
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
// Error check. Must have exactly 2 non-NULL function pointers.
|
|
|
|
if (NULL != c_copy_fn) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
if (NULL != c_delete_fn) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
if (NULL != cxx_copy_fn) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
if (NULL != cxx_delete_fn) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
if (2 != count) {
|
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_ARG,
|
|
|
|
"MPI::Comm::Create_keyval");
|
|
|
|
}
|
|
|
|
|
2008-01-12 16:20:38 +03:00
|
|
|
// We do not call MPI_Comm_create_keyval() here because we need to
|
|
|
|
// pass in a special destructor to the backend keyval creation
|
|
|
|
// that gets invoked when the keyval's reference count goes to 0
|
|
|
|
// and is finally destroyed (i.e., clean up some caching/lookup
|
|
|
|
// data here in the C++ bindings layer). This destructor is
|
|
|
|
// *only* used in the C++ bindings, so it's not set by the C
|
|
|
|
// MPI_Comm_create_keyval(). Hence, we do all the work here (and
|
|
|
|
// ensure to set the destructor atomicly when the keyval is
|
|
|
|
// created).
|
|
|
|
|
|
|
|
copy_fn.attr_communicator_copy_fn =
|
|
|
|
(MPI_Comm_internal_copy_attr_function*)
|
|
|
|
ompi_mpi_cxx_comm_copy_attr_intercept;
|
|
|
|
delete_fn.attr_communicator_delete_fn =
|
|
|
|
ompi_mpi_cxx_comm_delete_attr_intercept;
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn, delete_fn,
|
2008-01-12 16:20:38 +03:00
|
|
|
&keyval, cxx_extra_state, 0,
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
cxx_comm_keyval_destructor);
|
|
|
|
if (OMPI_SUCCESS != ret) {
|
2008-01-12 16:20:38 +03:00
|
|
|
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, ret,
|
|
|
|
"MPI::Comm::Create_keyval");
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
}
|
|
|
|
|
2008-01-12 16:20:38 +03:00
|
|
|
// Ensure to initialize the list safely
|
|
|
|
if (opal_atomic_cmpset_32(&cxx_extra_states_init_thread, 0, 1)) {
|
|
|
|
OBJ_CONSTRUCT(&cxx_extra_states, opal_list_t);
|
|
|
|
OBJ_CONSTRUCT(&cxx_extra_states_lock, opal_mutex_t);
|
|
|
|
cxx_extra_states_init = true;
|
|
|
|
} else {
|
|
|
|
while (!cxx_extra_states_init) {
|
|
|
|
#if defined(__WINDOWS__)
|
|
|
|
SwitchToThread();
|
|
|
|
#else
|
|
|
|
sched_yield();
|
|
|
|
#endif /* defined(__WINDOWS__) */
|
|
|
|
}
|
2004-07-14 18:11:03 +04:00
|
|
|
}
|
2008-01-12 16:20:38 +03:00
|
|
|
|
|
|
|
// Put this cxx_extra_state in a place where the
|
|
|
|
// cxx_comm_keyval_destructor can find it based on the keyval
|
|
|
|
// (because that's all the cxx_comm_keyval_destructor gets as an
|
|
|
|
// argument)
|
|
|
|
keyval_intercept_data_item_t *kid = OBJ_NEW(keyval_intercept_data_item_t);
|
|
|
|
kid->kid_keyval = keyval;
|
|
|
|
kid->kid_data = cxx_extra_state;
|
|
|
|
OPAL_THREAD_LOCK(&cxx_extra_states_lock);
|
|
|
|
opal_list_append(&cxx_extra_states, &kid->super);
|
|
|
|
OPAL_THREAD_UNLOCK(&cxx_extra_states_lock);
|
|
|
|
|
|
|
|
return MPI_SUCCESS;
|
2004-07-14 18:11:03 +04:00
|
|
|
}
|
Fixes trac:817
The C++ bindings were not tracking keyvals properly -- they were
freeing some internal meta data when Free_keyval() was called, not
when the keyval was actually destroyed (keyvals are refcounted in the
C layer, just like all other MPI objects, because they can live for
long after their corresponding Free call is invoked). This commit
fixes this problem and several other things:
* Add infrastructure on the ompi_attribute_keyval_t for an "extra"
destructor pointer that will be invoked during the "real"
constructor (i.e., when OBJ_RELEASE puts the refcount to 0). This
allows calling back into the C++ layer to release meta data
associated with the keyval.
* Adjust all cases where keyvals are created to pass in relevant
destructors (NULL or the C++ destructor).
* Do essentially the same for MPI::Comm, MPI::Win, and MPI:Datatype:
* Move several functions out of the .cc file into the _inln.h file
since they no longer require locks
* Make the 4 Create_keyval() functions call a common back-end
keyval creation function that does the Right Thing depending on
whether C or C++ function pointers were used for the keyval
functions. The back-end function does not call the corresponding
C MPI_*_create_keyval function, but rather does the work itself
so that it can associate a "destructor" callback for the C++
bindings for when the keyval is actually destroyed.
* Change a few type names to be more indicative of what they are
(mostly dealing with keyvals [not "keys"]).
* Add the 3 missing bindings for MPI::Comm::Create_keyval().
* Remove MPI::Comm::comm_map (and associated types) because it's no
longer necessary in the intercepts -- it was a by-product of being
a portable C++ bindings layer. Now we can just query the C layer
directly to figure out what type a communicator is. This solves
some logistics / callback issues, too.
* Rename several types, variables, and fix many comments in the
back-end C attribute implementation to make the names really
reflect what they are (keyvals vs. attributes). The previous names
heavily overloaded the name "key" and were ''extremely''
confusing.
This commit was SVN r13565.
The following Trac tickets were found above:
Ticket 817 --> https://svn.open-mpi.org/trac/ompi/ticket/817
2007-02-09 02:50:04 +03:00
|
|
|
|