1111//  Copyright (c) 2004-2005 The Regents of the University of California.
1212//                          All rights reserved.
1313//  Copyright (c) 2007-2008 Cisco Systems, Inc.  All rights reserved.
14+ //  Copyright (c) 2016      Los Alamos National Security, LLC. All rights
15+ //                          reserved.
1416//  $COPYRIGHT$
1517// 
1618//  Additional copyrights may follow
2022
2123//  do not include ompi_config.h because it kills the free/malloc defines
2224#include  " mpi.h" 
25+ #include  " ompi/constants.h" 
2326#include  " ompi/mpi/cxx/mpicxx.h" 
24- 
25- #ifdef  HAVE_SCHED_H
26- #include  < sched.h> 
27- #endif 
28- 
29- 
30- #include  " ompi/communicator/communicator.h" 
31- #include  " ompi/attribute/attribute.h" 
32- #include  " ompi/errhandler/errhandler.h" 
27+ #include  " cxx_glue.h" 
3328
3429
3530// 
@@ -56,14 +51,7 @@ MPI::Comm::Comm(const Comm_Null& data) : Comm_Null(data)
5651MPI::Errhandler
5752MPI::Comm::Create_errhandler (MPI::Comm::_MPI2CPP_ERRHANDLERFN_* function)
5853{
59-     MPI_Errhandler c_errhandler =
60-         ompi_errhandler_create (OMPI_ERRHANDLER_TYPE_COMM,
61-                                (ompi_errhandler_generic_handler_fn_t *) function,
62-                                OMPI_ERRHANDLER_LANG_CXX);
63-     c_errhandler->eh_cxx_dispatch_fn  =
64-         (ompi_errhandler_cxx_dispatch_fn_t *)
65-         ompi_mpi_cxx_comm_errhandler_invoke;
66-     return  c_errhandler;
54+     return  ompi_cxx_errhandler_create_comm  ((void  *) function);
6755}
6856
6957
@@ -77,20 +65,15 @@ MPI::Comm::do_create_keyval(MPI_Comm_copy_attr_function* c_copy_fn,
7765                            void * extra_state, int  &keyval)
7866{
7967    int  ret, count = 0 ;
80-     ompi_attribute_fn_ptr_union_t  copy_fn;
81-     ompi_attribute_fn_ptr_union_t  delete_fn;
8268    keyval_intercept_data_t  *cxx_extra_state;
8369
8470    //  If both the callbacks are C, then do the simple thing -- no
8571    //  need for all the C++ machinery.
8672    if  (NULL  != c_copy_fn && NULL  != c_delete_fn) {
87-         copy_fn.attr_communicator_copy_fn  =
88-             (MPI_Comm_internal_copy_attr_function*) c_copy_fn;
89-         delete_fn.attr_communicator_delete_fn  = c_delete_fn;
90-         ret = ompi_attr_create_keyval (COMM_ATTR, copy_fn, delete_fn,
91-                                       &keyval, extra_state, 0 , NULL );
73+         ret = ompi_cxx_attr_create_keyval_comm  (c_copy_fn, c_delete_fn, &keyval,
74+                                                 extra_state, 0 , NULL );
9275        if  (MPI_SUCCESS != ret) {
93-             return  OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, ret,
76+             return  ompi_cxx_errhandler_invoke_comm (MPI_COMM_WORLD, ret,
9477                                          " MPI::Comm::Create_keyval"  );
9578        }
9679    }
@@ -107,8 +90,8 @@ MPI::Comm::do_create_keyval(MPI_Comm_copy_attr_function* c_copy_fn,
10790    cxx_extra_state = (keyval_intercept_data_t *)
10891        malloc (sizeof (keyval_intercept_data_t ));
10992    if  (NULL  == cxx_extra_state) {
110-         return  OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_NO_MEM,
111-                                       " MPI::Comm::Create_keyval"  );
93+         return  ompi_cxx_errhandler_invoke_comm   (MPI_COMM_WORLD, MPI_ERR_NO_MEM,
94+                                                  " MPI::Comm::Create_keyval"  );
11295    }
11396    cxx_extra_state->c_copy_fn  = c_copy_fn;
11497    cxx_extra_state->cxx_copy_fn  = cxx_copy_fn;
@@ -131,26 +114,20 @@ MPI::Comm::do_create_keyval(MPI_Comm_copy_attr_function* c_copy_fn,
131114    }
132115    if  (2  != count) {
133116        free (cxx_extra_state);
134-         return  OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, MPI_ERR_ARG,
135-                                       " MPI::Comm::Create_keyval"  );
117+         return  ompi_cxx_errhandler_invoke_comm   (MPI_COMM_WORLD, MPI_ERR_ARG,
118+                                                  " MPI::Comm::Create_keyval"  );
136119    }
137120
138121    //  We do not call MPI_Comm_create_keyval() here because we need to
139122    //  pass in the cxx_extra_state to the backend keyval creation so
140123    //  that when the keyval is destroyed (i.e., when its refcount goes
141124    //  to 0), the cxx_extra_state is free()'ed.
142- 
143-     copy_fn.attr_communicator_copy_fn  =
144-         (MPI_Comm_internal_copy_attr_function*)
145-         ompi_mpi_cxx_comm_copy_attr_intercept;
146-     delete_fn.attr_communicator_delete_fn  =
147-         ompi_mpi_cxx_comm_delete_attr_intercept;
148-     ret = ompi_attr_create_keyval (COMM_ATTR, copy_fn, delete_fn,
149-                                   &keyval, cxx_extra_state, 0 ,
150-                                   cxx_extra_state);
125+     ret = ompi_cxx_attr_create_keyval_comm  ((MPI_Comm_copy_attr_function *) ompi_mpi_cxx_comm_copy_attr_intercept,
126+                                             ompi_mpi_cxx_comm_delete_attr_intercept,
127+                                             &keyval, cxx_extra_state, 0 , cxx_extra_state);
151128    if  (OMPI_SUCCESS != ret) {
152-         return  OMPI_ERRHANDLER_INVOKE (MPI_COMM_WORLD, ret,
153-                                       " MPI::Comm::Create_keyval"  );
129+         return  ompi_cxx_errhandler_invoke_comm   (MPI_COMM_WORLD, ret,
130+                                                  " MPI::Comm::Create_keyval"  );
154131    }
155132
156133    return  MPI_SUCCESS;
0 commit comments