* Fix the MPI::Datatype::Create_keyval() & MPI::Win::Create_keyval()
not being able to take C function pointers for either of the copy or the delete fn. Fix by overloading the Create_keyval methods. Fix trac #737, #738. Reviewed by jsquyres. * A couple of cxx tests in ompi-tests (winkeyval.cc & typekeyval.cc) will be re-enabled to regression test for this fix. This commit was SVN r13391.
Этот коммит содержится в:
родитель
b7ef2027de
Коммит
289fbd08de
@ -2,6 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2006 Los Alamos National Security, LLC. All rights
|
// Copyright (c) 2006 Los Alamos National Security, LLC. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
|
// Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||||
// $COPYRIGHT$
|
// $COPYRIGHT$
|
||||||
//
|
//
|
||||||
// Additional copyrights may follow
|
// Additional copyrights may follow
|
||||||
@ -27,6 +28,7 @@ MPI::Datatype::Free()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 1) original Create_keyval that takes the first 2 arguments as C++ macros
|
||||||
int
|
int
|
||||||
MPI::Datatype::Create_keyval(MPI::Datatype::Copy_attr_function* type_copy_attr_fn,
|
MPI::Datatype::Create_keyval(MPI::Datatype::Copy_attr_function* type_copy_attr_fn,
|
||||||
MPI::Datatype::Delete_attr_function* type_delete_attr_fn,
|
MPI::Datatype::Delete_attr_function* type_delete_attr_fn,
|
||||||
@ -44,6 +46,58 @@ MPI::Datatype::Create_keyval(MPI::Datatype::Copy_attr_function* type_copy_attr_f
|
|||||||
return keyval;
|
return keyval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2) overload Create_keyval to take the first 2 arguments as C macros
|
||||||
|
int
|
||||||
|
MPI::Datatype::Create_keyval(MPI_Type_copy_attr_function* type_copy_attr_fn,
|
||||||
|
MPI_Type_delete_attr_function* type_delete_attr_fn,
|
||||||
|
void* extra_state)
|
||||||
|
{
|
||||||
|
int keyval;
|
||||||
|
(void) MPI_Type_create_keyval(type_copy_attr_fn,
|
||||||
|
type_delete_attr_fn,
|
||||||
|
&keyval, extra_state);
|
||||||
|
return keyval;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) overload Create_keyval to take the first 2 arguments as C++ & C macros
|
||||||
|
int
|
||||||
|
MPI::Datatype::Create_keyval(MPI::Datatype::Copy_attr_function* type_copy_attr_fn,
|
||||||
|
MPI_Type_delete_attr_function* type_delete_attr_fn,
|
||||||
|
void* extra_state)
|
||||||
|
{
|
||||||
|
int keyval;
|
||||||
|
// use a dummy attr_fn to create the c++ key pair
|
||||||
|
MPI::Datatype::Delete_attr_function* dummy_type_delete_attr_fn;
|
||||||
|
(void) MPI_Type_create_keyval(ompi_mpi_cxx_type_copy_attr_intercept,
|
||||||
|
type_delete_attr_fn,
|
||||||
|
&keyval, extra_state);
|
||||||
|
key_pair_t* copy_and_delete =
|
||||||
|
new key_pair_t(type_copy_attr_fn, dummy_type_delete_attr_fn);
|
||||||
|
OPAL_THREAD_LOCK(MPI::mpi_map_mutex);
|
||||||
|
MPI::Datatype::mpi_type_key_fn_map[keyval] = copy_and_delete;
|
||||||
|
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
||||||
|
return keyval;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4) overload Create_keyval to take the first 2 arguments as C & C++ macros
|
||||||
|
int
|
||||||
|
MPI::Datatype::Create_keyval(MPI_Type_copy_attr_function* type_copy_attr_fn,
|
||||||
|
MPI::Datatype::Delete_attr_function* type_delete_attr_fn,
|
||||||
|
void* extra_state)
|
||||||
|
{
|
||||||
|
int keyval;
|
||||||
|
// use a dummy attr_fn to create the c++ key pair
|
||||||
|
MPI::Datatype::Copy_attr_function* dummy_type_copy_attr_fn;
|
||||||
|
(void) MPI_Type_create_keyval(type_copy_attr_fn,
|
||||||
|
ompi_mpi_cxx_type_delete_attr_intercept,
|
||||||
|
&keyval, extra_state);
|
||||||
|
key_pair_t* copy_and_delete =
|
||||||
|
new key_pair_t(dummy_type_copy_attr_fn, type_delete_attr_fn);
|
||||||
|
OPAL_THREAD_LOCK(MPI::mpi_map_mutex);
|
||||||
|
MPI::Datatype::mpi_type_key_fn_map[keyval] = copy_and_delete;
|
||||||
|
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
||||||
|
return keyval;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MPI::Datatype::Free_keyval(int& type_keyval)
|
MPI::Datatype::Free_keyval(int& type_keyval)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
// University of Stuttgart. All rights reserved.
|
// University of Stuttgart. All rights reserved.
|
||||||
// Copyright (c) 2004-2005 The Regents of the University of California.
|
// Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
// Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved.
|
// Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
|
||||||
// Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
// Copyright (c) 2006 Cisco Systems, Inc. All rights reserved.
|
||||||
// $COPYRIGHT$
|
// $COPYRIGHT$
|
||||||
//
|
//
|
||||||
@ -165,6 +165,15 @@ public:
|
|||||||
static int Create_keyval(Copy_attr_function* type_copy_attr_fn,
|
static int Create_keyval(Copy_attr_function* type_copy_attr_fn,
|
||||||
Delete_attr_function* type_delete_attr_fn,
|
Delete_attr_function* type_delete_attr_fn,
|
||||||
void* extra_state);
|
void* extra_state);
|
||||||
|
static int Create_keyval(MPI_Type_copy_attr_function* type_copy_attr_fn,
|
||||||
|
MPI_Type_delete_attr_function* type_delete_attr_fn,
|
||||||
|
void* extra_state);
|
||||||
|
static int Create_keyval(Copy_attr_function* type_copy_attr_fn,
|
||||||
|
MPI_Type_delete_attr_function* type_delete_attr_fn,
|
||||||
|
void* extra_state);
|
||||||
|
static int Create_keyval(MPI_Type_copy_attr_function* type_copy_attr_fn,
|
||||||
|
Delete_attr_function* type_delete_attr_fn,
|
||||||
|
void* extra_state);
|
||||||
|
|
||||||
virtual void Delete_attr(int type_keyval);
|
virtual void Delete_attr(int type_keyval);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2006 Los Alamos National Security, LLC. All rights
|
// Copyright (c) 2006 Los Alamos National Security, LLC. All rights
|
||||||
// reserved.
|
// reserved.
|
||||||
|
// Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
|
||||||
// $COPYRIGHT$
|
// $COPYRIGHT$
|
||||||
//
|
//
|
||||||
// Additional copyrights may follow
|
// Additional copyrights may follow
|
||||||
@ -36,6 +37,7 @@ MPI::Win::Set_errhandler(const MPI::Errhandler& errhandler)
|
|||||||
(void)MPI_Win_set_errhandler(mpi_win, errhandler);
|
(void)MPI_Win_set_errhandler(mpi_win, errhandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1) original Create_keyval that takes the first 2 arguments as C++ macros
|
||||||
int
|
int
|
||||||
MPI::Win::Create_keyval(MPI::Win::Copy_attr_function* win_copy_attr_fn,
|
MPI::Win::Create_keyval(MPI::Win::Copy_attr_function* win_copy_attr_fn,
|
||||||
MPI::Win::Delete_attr_function* win_delete_attr_fn,
|
MPI::Win::Delete_attr_function* win_delete_attr_fn,
|
||||||
@ -52,7 +54,56 @@ MPI::Win::Create_keyval(MPI::Win::Copy_attr_function* win_copy_attr_fn,
|
|||||||
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
||||||
return keyval;
|
return keyval;
|
||||||
}
|
}
|
||||||
|
// 2) overload Create_keyval to take the first 2 arguments as C macros
|
||||||
|
int
|
||||||
|
MPI::Win::Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn,
|
||||||
|
MPI_Win_delete_attr_function* win_delete_attr_fn,
|
||||||
|
void* extra_state)
|
||||||
|
{
|
||||||
|
int keyval;
|
||||||
|
(void) MPI_Win_create_keyval(win_copy_attr_fn,
|
||||||
|
win_delete_attr_fn,
|
||||||
|
&keyval, extra_state);
|
||||||
|
return keyval;
|
||||||
|
}
|
||||||
|
// 3) overload Create_keyval to take the first 2 arguments as C++ & C macros
|
||||||
|
int
|
||||||
|
MPI::Win::Create_keyval(MPI::Win::Copy_attr_function* win_copy_attr_fn,
|
||||||
|
MPI_Win_delete_attr_function* win_delete_attr_fn,
|
||||||
|
void* extra_state)
|
||||||
|
{
|
||||||
|
int keyval;
|
||||||
|
// use a dummy attr_fn to create the c++ key pair
|
||||||
|
MPI::Win::Delete_attr_function* dummy_win_delete_attr_fn;
|
||||||
|
(void) MPI_Win_create_keyval(ompi_mpi_cxx_win_copy_attr_intercept,
|
||||||
|
win_delete_attr_fn,
|
||||||
|
&keyval, extra_state);
|
||||||
|
key_pair_t* copy_and_delete =
|
||||||
|
new key_pair_t(win_copy_attr_fn, dummy_win_delete_attr_fn);
|
||||||
|
OPAL_THREAD_LOCK(MPI::mpi_map_mutex);
|
||||||
|
MPI::Win::mpi_win_key_fn_map[keyval] = copy_and_delete;
|
||||||
|
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
||||||
|
return keyval;
|
||||||
|
}
|
||||||
|
// 4) overload Create_keyval to take the first 2 arguments as C & C++ macros
|
||||||
|
int
|
||||||
|
MPI::Win::Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn,
|
||||||
|
MPI::Win::Delete_attr_function* win_delete_attr_fn,
|
||||||
|
void* extra_state)
|
||||||
|
{
|
||||||
|
int keyval;
|
||||||
|
// use a dummy attr_fn to create the c++ key pair
|
||||||
|
MPI::Win::Copy_attr_function* dummy_win_copy_attr_fn;
|
||||||
|
(void) MPI_Win_create_keyval(win_copy_attr_fn,
|
||||||
|
ompi_mpi_cxx_win_delete_attr_intercept,
|
||||||
|
&keyval, extra_state);
|
||||||
|
key_pair_t* copy_and_delete =
|
||||||
|
new key_pair_t(dummy_win_copy_attr_fn, win_delete_attr_fn);
|
||||||
|
OPAL_THREAD_LOCK(MPI::mpi_map_mutex);
|
||||||
|
MPI::Win::mpi_win_key_fn_map[keyval] = copy_and_delete;
|
||||||
|
OPAL_THREAD_UNLOCK(MPI::mpi_map_mutex);
|
||||||
|
return keyval;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MPI::Win::Free_keyval(int& win_keyval)
|
MPI::Win::Free_keyval(int& win_keyval)
|
||||||
|
@ -146,6 +146,15 @@ public:
|
|||||||
static int Create_keyval(Copy_attr_function* win_copy_attr_fn,
|
static int Create_keyval(Copy_attr_function* win_copy_attr_fn,
|
||||||
Delete_attr_function* win_delete_attr_fn,
|
Delete_attr_function* win_delete_attr_fn,
|
||||||
void* extra_state);
|
void* extra_state);
|
||||||
|
static int Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn,
|
||||||
|
MPI_Win_delete_attr_function* win_delete_attr_fn,
|
||||||
|
void* extra_state);
|
||||||
|
static int Create_keyval(Copy_attr_function* win_copy_attr_fn,
|
||||||
|
MPI_Win_delete_attr_function* win_delete_attr_fn,
|
||||||
|
void* extra_state);
|
||||||
|
static int Create_keyval(MPI_Win_copy_attr_function* win_copy_attr_fn,
|
||||||
|
Delete_attr_function* win_delete_attr_fn,
|
||||||
|
void* extra_state);
|
||||||
|
|
||||||
virtual void Delete_attr(int win_keyval);
|
virtual void Delete_attr(int win_keyval);
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user