2013-09-10 15:34:09 +00:00
|
|
|
/*
|
2015-11-17 11:21:05 +02:00
|
|
|
* Copyright (c) 2013-2015 Mellanox Technologies, Inc.
|
2013-09-10 15:34:09 +00:00
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
2015-06-23 20:59:57 -07:00
|
|
|
*
|
2013-09-10 15:34:09 +00:00
|
|
|
* Additional copyrights may follow
|
2015-06-23 20:59:57 -07:00
|
|
|
*
|
2013-09-10 15:34:09 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
#include "oshmem_config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "oshmem/constants.h"
|
|
|
|
#include "oshmem/include/shmem.h"
|
|
|
|
|
|
|
|
#include "oshmem/runtime/runtime.h"
|
|
|
|
|
|
|
|
#include "oshmem/shmem/shmem_api_logger.h"
|
|
|
|
#include "oshmem/mca/memheap/memheap.h"
|
|
|
|
|
2014-04-07 22:55:21 +00:00
|
|
|
#if OSHMEM_PROFILING
|
2014-04-14 20:51:06 +00:00
|
|
|
#include "oshmem/include/pshmem.h"
|
2015-11-17 11:21:05 +02:00
|
|
|
#pragma weak shmem_realloc = pshmem_realloc
|
2014-04-07 22:55:21 +00:00
|
|
|
#pragma weak shrealloc = pshrealloc
|
|
|
|
#include "oshmem/shmem/c/profile/defines.h"
|
|
|
|
#endif
|
|
|
|
|
2015-11-17 11:21:05 +02:00
|
|
|
static inline void* _shrealloc(void *ptr, size_t size);
|
|
|
|
|
|
|
|
void* shmem_realloc(void *ptr, size_t size)
|
|
|
|
{
|
|
|
|
return _shrealloc(ptr, size);
|
|
|
|
}
|
|
|
|
|
2013-09-10 15:34:09 +00:00
|
|
|
void* shrealloc(void *ptr, size_t size)
|
2015-11-17 11:21:05 +02:00
|
|
|
{
|
|
|
|
return _shrealloc(ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void* _shrealloc(void *ptr, size_t size)
|
2013-09-10 15:34:09 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
void* pBuff = NULL;
|
|
|
|
|
|
|
|
RUNTIME_CHECK_INIT();
|
|
|
|
|
|
|
|
rc = MCA_MEMHEAP_CALL(realloc(size, ptr, &pBuff));
|
|
|
|
|
|
|
|
if (OSHMEM_SUCCESS != rc) {
|
|
|
|
SHMEM_API_VERBOSE(1,
|
|
|
|
"Allocation with shrealloc(ptr=%p, size=%lu) failed.",
|
|
|
|
ptr, (unsigned long)size);
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if OSHMEM_SPEC_COMPAT == 1
|
|
|
|
shmem_barrier_all();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return pBuff;
|
|
|
|
}
|