[MPICH2-dev] MPI_Alloc_mem() mpich2-0.94b1

Doug Gilmore dgilmore at cray.com
Tue Sep 9 15:10:26 CDT 2003


I noticed a problem in MPI_Alloc_mem() while running example that
uses RMA.  The following change seems appropriate.

Doug

*** alloc_mem.c.~1.1.1.5~	Tue Sep  9 12:04:06 2003
--- alloc_mem.c	Tue Sep  9 12:03:17 2003
***************
*** 55,60 ****
--- 55,61 ----
      static const char FCNAME[] = "MPI_Alloc_mem";
      int mpi_errno = MPI_SUCCESS;
      MPID_MPI_STATE_DECL(MPID_STATE_MPI_ALLOC_MEM);
+     void *ap;
  
      MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_ALLOC_MEM);
  #   ifdef HAVE_ERROR_CHECKING
***************
*** 79,89 ****
  #   endif /* HAVE_ERROR_CHECKING */
  
      /* FIXME: This should be MPID_Mem_alloc */
!     baseptr = MPIU_Malloc(size);
!     if (!baseptr) {
          mpi_errno = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_NO_MEM, "**allocmem", 0 );
          return mpi_errno;
      }
  
      MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_ALLOC_MEM);
      return MPI_SUCCESS;
--- 80,91 ----
  #   endif /* HAVE_ERROR_CHECKING */
  
      /* FIXME: This should be MPID_Mem_alloc */
!     ap = MPIU_Malloc(size);
!     if (!ap) {
          mpi_errno = MPIR_Err_create_code( MPI_SUCCESS, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_NO_MEM, "**allocmem", 0 );
          return mpi_errno;
      }
+     *(void **)baseptr = ap;
  
      MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_ALLOC_MEM);
      return MPI_SUCCESS;



More information about the mpich2-dev mailing list