root/oshmem/shmem/c/shmem_align.c

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

DEFINITIONS

This source file includes following definitions.
  1. shmem_align
  2. shmemalign
  3. _shmemalign

   1 /*
   2  * Copyright (c) 2013-2015 Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  */
  10 #include "oshmem_config.h"
  11 
  12 #include "oshmem/constants.h"
  13 #include "oshmem/include/shmem.h"
  14 
  15 #include "oshmem/shmem/shmem_api_logger.h"
  16 
  17 #include "oshmem/runtime/runtime.h"
  18 #include "oshmem/mca/memheap/memheap.h"
  19 
  20 #if OSHMEM_PROFILING
  21 #include "oshmem/include/pshmem.h"
  22 #pragma weak shmem_align = pshmem_align
  23 #pragma weak shmemalign = pshmemalign
  24 #include "oshmem/shmem/c/profile/defines.h"
  25 #endif
  26 
  27 static inline void* _shmemalign(size_t align, size_t size);
  28 
  29 void* shmem_align(size_t align, size_t size)
  30 {
  31     return _shmemalign(align, size);
  32 }
  33 
  34 void* shmemalign(size_t align, size_t size)
  35 {
  36     return _shmemalign(align, size);
  37 }
  38 
  39 static inline void* _shmemalign(size_t align, size_t size)
  40 {
  41     int rc;
  42     void* pBuff = NULL;
  43 
  44     RUNTIME_CHECK_INIT();
  45 
  46     SHMEM_MUTEX_LOCK(shmem_internal_mutex_alloc);
  47 
  48     rc = MCA_MEMHEAP_CALL(memalign(align, size, &pBuff));
  49 
  50     SHMEM_MUTEX_UNLOCK(shmem_internal_mutex_alloc);
  51 
  52     if (OSHMEM_SUCCESS != rc) {
  53         SHMEM_API_VERBOSE(1,
  54                           "Allocation with shmemalign(align=%lu, size=%lu) failed.",
  55                           (unsigned long)align, (unsigned long)size);
  56         return NULL ;
  57     }
  58 
  59 #if OSHMEM_SPEC_COMPAT == 1
  60     shmem_barrier_all();
  61 #endif
  62     return pBuff;
  63 }
  64 

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