Actual source code: run-map.h

petsc-3.3-p7 2013-05-11
  1: #if !defined(RUN_MAP_H)
  2: #define RUN_MAP_H

  4: #if defined(__cplusplus)
  5: PETSC_EXTERN "C" {
  6: #endif

  8:     static int desc_size = 0;
  9:     static int entry_size = 0;
 10:     static int bucket_size = 0;
 11:     static int entries_per_bucket = 0;
 12:     static int buckets_per_block = 0;
 13:     static int map_size = 0;

 15: #   define DEFAULT_MAP_SIZE                1000
 16: #   define DEFAULT_BUCKET_SIZE                10
 17: #   define DEFAULT_BUCKETS_PER_BLOCK        100
 18:     typedef struct {
 19:         void* key;
 20:         double val[1];
 21:     } Pair;
 22:     typedef struct {
 23:         Pair* cache;
 24:         Pair* next;
 25:     } MapEntry;
 26:     static MapEntry* map_def = 0;

 28:     typedef struct genlist {
 29:         struct genlist *next;
 30:         double data[1];
 31:     } genlist_t;
 32:     static genlist_t* freeList;
 33:     static genlist_t* blockList;
 34:     static genlist_t* curBlock;

 36:     typedef struct {
 37:         int isSingle;
 38:         double* base;
 39:         double* top;
 40:         void* desc;
 41:     } ArrayEntry;


 44:     void* ad_map_init(int dsize, int msize, int bsize, int asize);
 45:     void ad_map_cleanup();
 46:     void* ad_map_reg_array_d(double* base, int size);
 47:     void* ad_map_reg_array_s(float* base, int size);
 48:     void* ad_map_get(void* key);
 49:     static void* ad_map_alloc_bucket(void);
 50:     void* ad_map_free_bucket(void* ptr);
 51:     void* ad_map_free(void* key);

 53: #if defined(__cplusplus)
 54: }
 55: #endif

 57: #endif /*RUN_MAP_H*/