root/oshmem/shmem/c/shmem_free.c

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

DEFINITIONS

This source file includes following definitions.
  1. shmem_free
  2. shfree
  3. _shfree

   1 /*
   2  * Copyright (c) 2013-2015 Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * Copyright (c) 2018      IBM Corporation.  All rights reserved.
   5  * $COPYRIGHT$
   6  *
   7  * Additional copyrights may follow
   8  *
   9  * $HEADER$
  10  */
  11 #include "oshmem_config.h"
  12 
  13 #include "oshmem/constants.h"
  14 #include "oshmem/include/shmem.h"
  15 
  16 #include "oshmem/shmem/shmem_api_logger.h"
  17 
  18 #include "oshmem/runtime/runtime.h"
  19 
  20 #include "oshmem/mca/memheap/memheap.h"
  21 #include "oshmem/mca/memheap/base/base.h"
  22 
  23 #if OSHMEM_PROFILING
  24 #include "oshmem/include/pshmem.h"
  25 #pragma weak shmem_free = pshmem_free
  26 #pragma weak shfree = pshfree
  27 #include "oshmem/shmem/c/profile/defines.h"
  28 #endif
  29 
  30 static inline void _shfree(void* ptr);
  31 
  32 void shmem_free(void* ptr)
  33 {
  34     _shfree(ptr);
  35 }
  36 
  37 void shfree(void* ptr)
  38 {
  39     _shfree(ptr);
  40 }
  41 
  42 static inline void _shfree(void* ptr)
  43 {
  44     int rc;
  45     map_segment_t *s;
  46 
  47     RUNTIME_CHECK_INIT();
  48     if (NULL == ptr) {
  49         return;
  50     }
  51 
  52     RUNTIME_CHECK_ADDR(ptr);
  53 
  54 #if OSHMEM_SPEC_COMPAT == 1
  55     shmem_barrier_all();
  56 #endif
  57 
  58     SHMEM_MUTEX_LOCK(shmem_internal_mutex_alloc);
  59 
  60     if (ptr) {
  61         s = memheap_find_va(ptr);
  62     }
  63 
  64     if (s && s->allocator) {
  65         rc = s->allocator->free(s, ptr);
  66     } else {
  67         rc = MCA_MEMHEAP_CALL(free(ptr));
  68     }
  69 
  70     SHMEM_MUTEX_UNLOCK(shmem_internal_mutex_alloc);
  71 
  72     if (OSHMEM_SUCCESS != rc) {
  73         SHMEM_API_VERBOSE(10, "shfree failure.");
  74     }
  75 }
  76 

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