root/oshmem/mca/memheap/buddy/memheap_buddy.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_BUDDY_H
  15 #define MCA_MEMHEAP_BUDDY_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 #define BITS_PER_BYTE                    8
  32 #define __BITOPS_WORDSIZE                64
  33 #define DEFAULT_HASHTABLE_SIZE           100
  34 
  35 #define BITOP_WORD(nr)                   ((nr) / bits_per_long())
  36 #define DIV_ROUND_UP(n,d)                (((n) + (d) - 1) / (d))
  37 #define BITS_TO_LONGS(nr)                DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(unsigned long))
  38 #define __BITOPS_WORDS(bits)             (((bits)+__BITOPS_WORDSIZE-1)/__BITOPS_WORDSIZE)
  39 #define clear_bit(x,y)                   __clear_bit((x), (y))
  40 #define set_bit(x,y)                     __set_bit((x), (y))
  41 #define find_first_bit(addr, size)      find_next_bit((addr), (size), 0)
  42 
  43 BEGIN_C_DECLS
  44 
  45 struct mca_memheap_buddy_heap_t {
  46     unsigned long **bits; /** Part of the buddy allocator */
  47     unsigned *num_free; /** Part of the buddy allocator */
  48     unsigned max_order; /** Log2 of Maximal heap size, part of the allocator */
  49     unsigned min_order; /** min alloc order */
  50     void* symmetric_heap; /** Symmetric Heap */
  51     opal_hash_table_t* symmetric_heap_hashtable; /** Pointer to the Symmetric heap used for moving on it */
  52 };
  53 typedef struct mca_memheap_buddy_heap_t mca_memheap_buddy_heap_t;
  54 
  55 /* Structure for managing shmem symmetric heap */
  56 struct mca_memheap_buddy_module_t {
  57     mca_memheap_base_module_t super;
  58 
  59     int priority; /** Module's Priority */
  60     mca_memheap_buddy_heap_t heap;
  61     mca_memheap_buddy_heap_t private_heap;
  62     opal_mutex_t lock; /** Part of the buddy allocator */
  63 };
  64 typedef struct mca_memheap_buddy_module_t mca_memheap_buddy_module_t;
  65 OSHMEM_DECLSPEC extern mca_memheap_buddy_module_t memheap_buddy;
  66 
  67 /*
  68  * Buddy interface.
  69  * Please pay attention to the new differences in the interface.
  70  */
  71 OSHMEM_DECLSPEC extern int mca_memheap_buddy_module_init(memheap_context_t *);
  72 OSHMEM_DECLSPEC extern int mca_memheap_buddy_alloc(size_t, void**);
  73 OSHMEM_DECLSPEC extern int mca_memheap_buddy_realloc(size_t, void*, void **);
  74 OSHMEM_DECLSPEC extern int mca_memheap_buddy_align(size_t, size_t, void**);
  75 OSHMEM_DECLSPEC extern int mca_memheap_buddy_free(void*);
  76 OSHMEM_DECLSPEC extern int mca_memheap_buddy_finalize(void);
  77 
  78 /* private alloc/free functions */
  79 OSHMEM_DECLSPEC extern int mca_memheap_buddy_private_alloc(size_t, void**);
  80 OSHMEM_DECLSPEC extern int mca_memheap_buddy_private_free(void*);
  81 
  82 /**
  83  * static/global variables support. Consider making it a separate component
  84  */
  85 
  86 END_C_DECLS
  87 
  88 #endif /* MCA_MEMHEAP_BUDDY_H */

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