root/oshmem/mca/memheap/ptmalloc/memheap_ptmalloc.h

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

INCLUDED FROM


   1 /**
   2  * Copyright (c) 2013      Mellanox Technologies, Inc.
   3  *                         All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   9  */
  10 /**
  11  * @file
  12  * Description of the Registration Cache framework
  13  */
  14 #ifndef MCA_MEMHEAP_PTMALLOC_H
  15 #define MCA_MEMHEAP_PTMALLOC_H
  16 
  17 #include "oshmem_config.h"
  18 #include "oshmem/mca/mca.h"
  19 #include "opal/class/opal_list.h"
  20 #include "opal/threads/mutex.h"
  21 #include "oshmem/mca/memheap/memheap.h"
  22 #include "oshmem/mca/memheap/base/base.h"
  23 #include "oshmem/mca/spml/spml.h"
  24 #include "oshmem/util/oshmem_util.h"
  25 #include "opal/class/opal_hash_table.h"
  26 #include "opal/mca/btl/btl.h"
  27 #include <string.h>
  28 #include <sys/types.h>
  29 #include <math.h>
  30 
  31 BEGIN_C_DECLS
  32 
  33 #include "malloc_defs.h"
  34 /*
  35  * At the moment we use only dlmalloc part of the ptmalloc3. Thread safety is implemented by using locks on
  36  * alloc operations. Since all shmem alloc ops are collectives, malloc performance is not a problem. So it makes
  37  * sense to use simpler algorithm.
  38  *
  39  * Heap is allocate in one chunk, and we implement our on sbrk like function that serves portions of the memory
  40  * to malloc.
  41  *
  42  * At the moment we do not support growing/returning heap based memory to OS.
  43  */
  44 
  45 /* Structure for managing shmem symmetric heap */
  46 struct mca_memheap_ptmalloc_module_t {
  47     mca_memheap_base_module_t super;
  48     int priority; /** Module's Priority */
  49     void *base;
  50     size_t cur_size;
  51     size_t max_size;
  52     size_t max_alloc_size;
  53     opal_mutex_t lock; /** Part of the allocator */
  54 };
  55 
  56 typedef struct mca_memheap_ptmalloc_module_t mca_memheap_ptmalloc_module_t;
  57 OSHMEM_DECLSPEC extern mca_memheap_ptmalloc_module_t memheap_ptmalloc;
  58 
  59 /*
  60  * Buddy interface.
  61  * Please pay attention to the new differences in the interface.
  62  */
  63 OSHMEM_DECLSPEC extern int mca_memheap_ptmalloc_module_init(memheap_context_t *);
  64 OSHMEM_DECLSPEC extern int mca_memheap_ptmalloc_alloc(size_t, void**);
  65 OSHMEM_DECLSPEC extern int mca_memheap_ptmalloc_realloc(size_t, void*, void **);
  66 OSHMEM_DECLSPEC extern int mca_memheap_ptmalloc_align(size_t, size_t, void**);
  67 OSHMEM_DECLSPEC extern int mca_memheap_ptmalloc_free(void*);
  68 OSHMEM_DECLSPEC extern int mca_memheap_ptmalloc_finalize(void);
  69 
  70 END_C_DECLS
  71 
  72 #endif /* MCA_MEMHEAP_BUDDY_H */

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