root/oshmem/shmem/fortran/shpalloc_f.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. SHMEM_GENERATE_WEAK_BINDINGS

   1 /*
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * Copyright (c) 2013 Cisco Systems, Inc.  All rights reserved.
   5  * Copyright (c) 2014      Research Organization for Information Science
   6  *                         and Technology (RIST). All rights reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include "oshmem_config.h"
  15 #include "oshmem/shmem/fortran/bindings.h"
  16 #include "oshmem/include/shmem.h"
  17 #include "oshmem/shmem/shmem_api_logger.h"
  18 #include "oshmem/runtime/runtime.h"
  19 #include "stdio.h"
  20 
  21 #if OSHMEM_PROFILING
  22 #include "oshmem/shmem/fortran/profile/pbindings.h"
  23 SHMEM_GENERATE_WEAK_BINDINGS(SHPALLOC, shpalloc)
  24 #include "oshmem/shmem/fortran/profile/defines.h"
  25 #endif
  26 
  27 SHMEM_GENERATE_FORTRAN_BINDINGS_SUB (void,
  28         SHPALLOC,
  29         shpalloc_,
  30         shpalloc__,
  31         shpalloc_f,
  32         (FORTRAN_POINTER_T *addr, MPI_Fint *length, MPI_Fint *errcode, MPI_Fint *abort),
  33         (addr,length,errcode,abort) )
  34 
  35 void shpalloc_f(FORTRAN_POINTER_T *addr, MPI_Fint *length, MPI_Fint *errcode, MPI_Fint *abort)
  36 {
  37     *errcode = 0;
  38     /*current shmem spec implies that the length parameter to SHPALLOC function is the number of 32-bit words to allocate*/
  39     uint32_t *address;
  40     if (*length <= 0) {
  41         *errcode = -1;
  42     }
  43     address = shmalloc(*length*4);
  44 
  45     *addr = (FORTRAN_POINTER_T)(uintptr_t)address;
  46     if (!(*addr))
  47     {
  48         *errcode = -2;
  49         SHMEM_API_ERROR("could not allocate %i bytes in symmetric heap",*length*4);
  50         if (*abort)
  51         {
  52             SHMEM_API_ERROR("nonzero abort value, aborting..");
  53             oshmem_shmem_abort(-1);
  54         }
  55     }
  56 }
  57 

/* [<][>][^][v][top][bottom][index][help] */