1 /* 2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana 3 * University Research and Technology 4 * Corporation. All rights reserved. 5 * Copyright (c) 2004-2005 The University of Tennessee and The University 6 * of Tennessee Research Foundation. All rights 7 * reserved. 8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 9 * University of Stuttgart. All rights reserved. 10 * Copyright (c) 2004-2005 The Regents of the University of California. 11 * All rights reserved. 12 * Copyright (c) 2015 Research Organization for Information Science 13 * and Technology (RIST). All rights reserved. 14 * $COPYRIGHT$ 15 * 16 * Additional copyrights may follow 17 * 18 * $HEADER$ 19 */ 20 21 #include "ompi_config.h" 22 23 #include "ompi/mpi/c/bindings.h" 24 #include "ompi/runtime/params.h" 25 #include "ompi/communicator/communicator.h" 26 #include "ompi/errhandler/errhandler.h" 27 #include "ompi/info/info.h" 28 29 #if OMPI_BUILD_MPI_PROFILING 30 #if OPAL_HAVE_WEAK_SYMBOLS 31 #pragma weak MPI_Info_dup = PMPI_Info_dup 32 #endif 33 #define MPI_Info_dup PMPI_Info_dup 34 #endif 35 36 static const char FUNC_NAME[] = "MPI_Info_dup"; 37 38 39 /** 40 * MPI_Info_dup - Duplicate an 'MPI_Info' object 41 * 42 * @param info source info object (handle) 43 * @param newinfo pointer to the new info object (handle) 44 * 45 * @retval MPI_SUCCESS 46 * @retval MPI_ERR_INFO 47 * @retval MPI_ERR_NO_MEM 48 * 49 * Not only will the (key, value) pairs be duplicated, the order of keys 50 * will be the same in 'newinfo' as it is in 'info'. 51 * When an info object is no longer being used, it should be freed with 52 * 'MPI_Info_free'. 53 */ 54 int MPI_Info_dup(MPI_Info info, MPI_Info *newinfo) { 55 int err; 56 57 /** 58 * Here we need to do 2 things 59 * 1. Create a newinfo object using MPI_Info_create 60 * 2. Fetch all the values from info and copy them to 61 * newinfo using MPI_Info_set 62 * The new implementation facilitates traversal in many ways. 63 * I have chosen to get the number of elements on the list 64 * and copy them to newinfo one by one 65 */ 66 67 if (MPI_PARAM_CHECK) { 68 OMPI_ERR_INIT_FINALIZE(FUNC_NAME); 69 if (NULL == info || MPI_INFO_NULL == info || NULL == newinfo || 70 ompi_info_is_freed(info)) { 71 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_INFO, 72 FUNC_NAME); 73 } 74 } 75 76 *newinfo = OBJ_NEW(ompi_info_t); 77 if (NULL == *newinfo) { 78 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_NO_MEM, 79 FUNC_NAME); 80 } 81 82 OPAL_CR_ENTER_LIBRARY(); 83 84 /* 85 * Now to actually duplicate all the values 86 */ 87 err = ompi_info_dup (info, newinfo); 88 OMPI_ERRHANDLER_RETURN(err, MPI_COMM_WORLD, err, FUNC_NAME); 89 }