cache_common.h

00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00002  * Copyright by The HDF Group.                                               *
00003  * Copyright by the Board of Trustees of the University of Illinois.         *
00004  * All rights reserved.                                                      *
00005  *                                                                           *
00006  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00007  * terms governing use, modification, and redistribution, is contained in    *
00008  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00009  * of the source code distribution tree; Copyright.html can be found at the  *
00010  * root level of an installed copy of the electronic HDF5 document set and   *
00011  * is linked from the top-level documents page.  It can also be found at     *
00012  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00013  * access to either file, you may request a copy from help@hdfgroup.org.     *
00014  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00015 
00016 /* Programmer:  John Mainzer
00017  *              10/27/05
00018  *
00019  *              This file contains common #defines, type definitions, and
00020  *              externs for tests of the cache implemented in H5C.c
00021  */
00022 #ifndef _CACHE_COMMON_H
00023 #define _CACHE_COMMON_H
00024 
00025 #define H5C_PACKAGE             /*suppress error about including H5Cpkg   */
00026 #define H5F_PACKAGE             /*suppress error about including H5Fpkg   */
00027 
00028 /* Include library header files */
00029 #include "H5ACprivate.h"
00030 #include "H5Cpkg.h"
00031 #include "H5Fpkg.h"
00032 #include "H5Iprivate.h"
00033 
00034 /* Include test header files */
00035 #include "h5test.h"
00036 
00037 #define NO_CHANGE       -1
00038 
00039 /* with apologies for the abuse of terminology... */
00040 
00041 #define PICO_ENTRY_TYPE         0
00042 #define NANO_ENTRY_TYPE         1
00043 #define MICRO_ENTRY_TYPE        2
00044 #define TINY_ENTRY_TYPE         3
00045 #define SMALL_ENTRY_TYPE        4
00046 #define MEDIUM_ENTRY_TYPE       5
00047 #define LARGE_ENTRY_TYPE        6
00048 #define HUGE_ENTRY_TYPE         7
00049 #define MONSTER_ENTRY_TYPE      8
00050 #define VARIABLE_ENTRY_TYPE     9
00051 
00052 #define NUMBER_OF_ENTRY_TYPES   10
00053 
00054 #define PICO_ENTRY_SIZE         (size_t)1
00055 #define NANO_ENTRY_SIZE         (size_t)4
00056 #define MICRO_ENTRY_SIZE        (size_t)16
00057 #define TINY_ENTRY_SIZE         (size_t)64
00058 #define SMALL_ENTRY_SIZE        (size_t)256
00059 #define MEDIUM_ENTRY_SIZE       (size_t)1024
00060 #define LARGE_ENTRY_SIZE        (size_t)(4 * 1024)
00061 #define HUGE_ENTRY_SIZE         (size_t)(16 * 1024)
00062 #define MONSTER_ENTRY_SIZE      (size_t)(64 * 1024)
00063 #define VARIABLE_ENTRY_SIZE     (size_t)(10 * 1024)
00064 
00065 #define NUM_PICO_ENTRIES        (10 * 1024)
00066 #define NUM_NANO_ENTRIES        (10 * 1024)
00067 #define NUM_MICRO_ENTRIES       (10 * 1024)
00068 #define NUM_TINY_ENTRIES        (10 * 1024)
00069 #define NUM_SMALL_ENTRIES       (10 * 1024)
00070 #define NUM_MEDIUM_ENTRIES      (10 * 1024)
00071 #define NUM_LARGE_ENTRIES       (10 * 1024)
00072 #define NUM_HUGE_ENTRIES        (10 * 1024)
00073 #define NUM_MONSTER_ENTRIES     (10 * 1024)
00074 #define NUM_VARIABLE_ENTRIES    (10 * 1024)
00075 
00076 #define MAX_ENTRIES             (10 * 1024)
00077 
00078 /* The choice of the BASE_ADDR below is arbitrary -- it just has to be
00079  * larger than the superblock.
00080  */
00081 #define BASE_ADDR               (haddr_t)1024
00082 #define PICO_BASE_ADDR          BASE_ADDR
00083 #define NANO_BASE_ADDR          (haddr_t)(PICO_BASE_ADDR + \
00084                                       (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES))
00085 #define MICRO_BASE_ADDR         (haddr_t)(NANO_BASE_ADDR + \
00086                                       (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES))
00087 #define TINY_BASE_ADDR          (haddr_t)(MICRO_BASE_ADDR + \
00088                                       (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES))
00089 #define SMALL_BASE_ADDR         (haddr_t)(TINY_BASE_ADDR + \
00090                                       (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES))
00091 #define MEDIUM_BASE_ADDR        (haddr_t)(SMALL_BASE_ADDR + \
00092                                       (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES))
00093 #define LARGE_BASE_ADDR         (haddr_t)(MEDIUM_BASE_ADDR + \
00094                                       (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES))
00095 #define HUGE_BASE_ADDR          (haddr_t)(LARGE_BASE_ADDR + \
00096                                       (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES))
00097 #define MONSTER_BASE_ADDR       (haddr_t)(HUGE_BASE_ADDR + \
00098                                       (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES))
00099 #define VARIABLE_BASE_ADDR      (haddr_t)(MONSTER_BASE_ADDR + \
00100                                      (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES))
00101 
00102 #define PICO_ALT_BASE_ADDR      (haddr_t)(VARIABLE_BASE_ADDR + \
00103                                    (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES))
00104 #define NANO_ALT_BASE_ADDR      (haddr_t)(PICO_ALT_BASE_ADDR + \
00105                                       (PICO_ENTRY_SIZE * NUM_PICO_ENTRIES))
00106 #define MICRO_ALT_BASE_ADDR     (haddr_t)(NANO_ALT_BASE_ADDR + \
00107                                       (NANO_ENTRY_SIZE * NUM_NANO_ENTRIES))
00108 #define TINY_ALT_BASE_ADDR      (haddr_t)(MICRO_ALT_BASE_ADDR + \
00109                                       (MICRO_ENTRY_SIZE * NUM_MICRO_ENTRIES))
00110 #define SMALL_ALT_BASE_ADDR     (haddr_t)(TINY_ALT_BASE_ADDR + \
00111                                       (TINY_ENTRY_SIZE * NUM_TINY_ENTRIES))
00112 #define MEDIUM_ALT_BASE_ADDR    (haddr_t)(SMALL_ALT_BASE_ADDR + \
00113                                       (SMALL_ENTRY_SIZE * NUM_SMALL_ENTRIES))
00114 #define LARGE_ALT_BASE_ADDR     (haddr_t)(MEDIUM_ALT_BASE_ADDR + \
00115                                       (MEDIUM_ENTRY_SIZE * NUM_MEDIUM_ENTRIES))
00116 #define HUGE_ALT_BASE_ADDR      (haddr_t)(LARGE_ALT_BASE_ADDR + \
00117                                       (LARGE_ENTRY_SIZE * NUM_LARGE_ENTRIES))
00118 #define MONSTER_ALT_BASE_ADDR   (haddr_t)(HUGE_ALT_BASE_ADDR + \
00119                                       (HUGE_ENTRY_SIZE * NUM_HUGE_ENTRIES))
00120 #define VARIABLE_ALT_BASE_ADDR  (haddr_t)(MONSTER_ALT_BASE_ADDR + \
00121                                      (MONSTER_ENTRY_SIZE * NUM_MONSTER_ENTRIES))
00122 #define MAX_ADDR                (haddr_t)(VARIABLE_ALT_BASE_ADDR + \
00123                                    (VARIABLE_ENTRY_SIZE * NUM_VARIABLE_ENTRIES))
00124 #define ADDR_SPACE_SIZE         (haddr_t)(MAX_ADDR - BASE_ADDR)
00125 
00126 #define MAX_PINS        8       /* Maximum number of entries that can be
00127                                  * directly pinned by a single entry.
00128                                  */
00129 
00130 #define FLUSH_OP__NO_OP         0
00131 #define FLUSH_OP__DIRTY         1
00132 #define FLUSH_OP__RESIZE        2
00133 #define FLUSH_OP__RENAME        3
00134 #define FLUSH_OP__MAX_OP        3
00135 
00136 #define MAX_FLUSH_OPS           10      /* Maximum number of flush operations
00137                                          * that can be associated with a
00138                                          * cache entry.
00139                                          */
00140 
00141 typedef struct flush_op
00142 {
00143     int                 op_code;        /* integer op code indicating the
00144                                          * operation to be performed.  At
00145                                          * present it must be one of:
00146                                          *
00147                                          *   FLUSH_OP__NO_OP
00148                                          *   FLUSH_OP__DIRTY
00149                                          *   FLUSH_OP__RESIZE
00150                                          *   FLUSH_OP__RENAME
00151                                          */
00152     int                 type;           /* type code of the cache entry that
00153                                          * is the target of the operation.
00154                                          * This value is passed into the
00155                                          * function implementing the flush
00156                                          * operation.
00157                                          */
00158     int                 idx;            /* index of the cache entry that
00159                                          * is the target of the operation.
00160                                          * This value is passed into the
00161                                          * function implementing the flush
00162                                          * operation.
00163                                          */
00164     hbool_t             flag;           /* boolean flag passed into the
00165                                          * function implementing the flush
00166                                          * operation.  The meaning of the
00167                                          * flag is dependant upon the flush
00168                                          * operation:
00169                                          *
00170                                          * FLUSH_OP__DIRTY: TRUE iff the
00171                                          *   target is pinned, and is to
00172                                          *   be dirtied via the
00173                                          *   H5C_mark_pinned_entry_dirty()
00174                                          *   call.
00175                                          *
00176                                          * FLUSH_OP__RESIZE: TRUE iff the
00177                                          *   target is pinned, and is to
00178                                          *   be resized via the
00179                                          *   H5C_mark_pinned_entry_dirty()
00180                                          *   call.
00181                                          *
00182                                          * FLUSH_OP__RENAME: TRUE iff the
00183                                          *    target is to be renamed to
00184                                          *    its main address.
00185                                          */
00186     size_t              size;           /* New target size in the
00187                                          * FLUSH_OP__RENAME operation.
00188                                          * Unused elsewhere.
00189                                          */
00190 } flush_op;
00191 
00192 typedef struct test_entry_t
00193 {
00194     H5C_cache_entry_t     header;       /* entry data used by the cache
00195                                          * -- must be first
00196                                          */
00197     struct test_entry_t * self;         /* pointer to this entry -- used for
00198                                          * sanity checking.
00199                                          */
00200     H5C_t               * cache_ptr;    /* pointer to the cache in which
00201                                          * the entry resides, or NULL if the
00202                                          * entry is not in cache.
00203                                          */
00204     haddr_t               addr;         /* where the cache thinks this entry
00205                                          * is located
00206                                          */
00207     hbool_t               at_main_addr; /* boolean flag indicating whether
00208                                          * the entry is supposed to be at
00209                                          * either its main or alternate
00210                                          * address.
00211                                          */
00212     haddr_t               main_addr;    /* initial location of the entry
00213                                          */
00214     haddr_t               alt_addr;     /* location to which the entry
00215                                          * can be relocated or "renamed"
00216                                          */
00217     size_t                size;         /* how big the cache thinks this
00218                                          * entry is
00219                                          */
00220     int32_t               type;         /* indicates which entry array this
00221                                          * entry is in
00222                                          */
00223     int32_t               index;        /* index in its entry array
00224                                          */
00225     int32_t               reads;        /* number of times this entry has
00226                                          * been loaded.
00227                                          */
00228     int32_t               writes;       /* number of times this entry has
00229                                          * been written
00230                                          */
00231     hbool_t               is_dirty;     /* entry has been modified since
00232                                          * last write
00233                                          */
00234     hbool_t               is_protected; /* entry should currently be on
00235                                          * the cache's protected list.
00236                                          */
00237     hbool_t               is_read_only; /* TRUE iff the entry should be
00238                                          * protected read only.
00239                                          */
00240     int                   ro_ref_count; /* Number of outstanding read only
00241                                          * protects on the entry.
00242                                          */
00243     hbool_t               is_pinned;    /* entry is currently pinned in
00244                                          * the cache.
00245                                          */
00246     int                   pinning_ref_count; /* Number of entries that
00247                                          * pin this entry in the cache.
00248                                          * When this count drops to zero,
00249                                          * this entry should be unpinned.
00250                                          */
00251     int                   num_pins;     /* Number of entries that this
00252                                          * entry pins in the cache.  This
00253                                          * value must be in the range
00254                                          * [0, MAX_PINS].
00255                                          */
00256     int                   pin_type[MAX_PINS]; /* array of the types of entries
00257                                          * pinned by this entry.
00258                                          */
00259     int                   pin_idx[MAX_PINS]; /* array of the indicies of
00260                                          * entries pinned by this entry.
00261                                          */
00262     int                   num_flush_ops; /* integer field containing the
00263                                          * number of flush operations to
00264                                          * be executed when the entry is
00265                                          * flushed.  This value must lie in
00266                                          * the closed interval
00267                                          * [0, MAX_FLUSH_OPS].
00268                                          */
00269     struct flush_op       flush_ops[MAX_FLUSH_OPS]; /* Array of instances
00270                                          * of struct flush_op detailing the
00271                                          * flush operations (if any) that
00272                                          * are to be executed when the entry
00273                                          * is flushed from the cache.
00274                                          *
00275                                          * num_flush_ops contains the number
00276                                          * of valid entries in this array.
00277                                          */
00278     hbool_t               flush_op_self_resize_in_progress; /* Boolean flag
00279                                          * that is set to TRUE iff this
00280                                          * entry is being flushed, it has
00281                                          * been resized by a resize flush
00282                                          * op, and the flush function has
00283                                          * not yet returned,  This field is
00284                                          * used to turn off overactive santity
00285                                          * checking code that would otherwise
00286                                          * cause a false test failure.
00287                                          */
00288     hbool_t               loaded;       /* entry has been loaded since the
00289                                          * last time it was reset.
00290                                          */
00291     hbool_t               cleared;      /* entry has been cleared since the
00292                                          * last time it was reset.
00293                                          */
00294     hbool_t               flushed;      /* entry has been flushed since the
00295                                          * last time it was reset.
00296                                          */
00297     hbool_t               destroyed;    /* entry has been destroyed since the
00298                                          * last time it was reset.
00299                                          */
00300 } test_entry_t;
00301 
00302 /* The following is a cut down copy of the hash table manipulation
00303  * macros from H5C.c, which have been further modified to avoid references
00304  * to the error reporting macros.  Needless to say, these macros must be
00305  * updated as necessary.
00306  */
00307 
00308 #define H5C__HASH_MASK          ((size_t)(H5C__HASH_TABLE_LEN - 1) << 3)
00309 #define H5C__HASH_FCN(x)        (int)(((x) & H5C__HASH_MASK) >> 3)
00310 
00311 #define H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr)          \
00312 if ( ( (cache_ptr) == NULL ) ||                         \
00313      ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) ||      \
00314      ( (cache_ptr)->index_size !=                       \
00315        ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \
00316      ( ! H5F_addr_defined(Addr) ) ||                    \
00317      ( H5C__HASH_FCN(Addr) < 0 ) ||                     \
00318      ( H5C__HASH_FCN(Addr) >= H5C__HASH_TABLE_LEN ) ) { \
00319     HDfprintf(stdout, "Pre HT search SC failed.\n");    \
00320 }
00321 
00322 #define H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, Addr, k) \
00323 if ( ( (cache_ptr) == NULL ) ||                                   \
00324      ( (cache_ptr)->magic != H5C__H5C_T_MAGIC ) ||                \
00325      ( (cache_ptr)->index_len < 1 ) ||                            \
00326      ( (entry_ptr) == NULL ) ||                                   \
00327      ( (cache_ptr)->index_size < (entry_ptr)->size ) ||           \
00328      ( (cache_ptr)->index_size !=                                 \
00329        ((cache_ptr)->clean_index_size + (cache_ptr)->dirty_index_size) ) || \
00330      ( H5F_addr_ne((entry_ptr)->addr, (Addr)) ) ||                \
00331      ( (entry_ptr)->size <= 0 ) ||                                \
00332      ( ((cache_ptr)->index)[k] == NULL ) ||                       \
00333      ( ( ((cache_ptr)->index)[k] != (entry_ptr) ) &&              \
00334        ( (entry_ptr)->ht_prev == NULL ) ) ||                      \
00335      ( ( ((cache_ptr)->index)[k] == (entry_ptr) ) &&              \
00336        ( (entry_ptr)->ht_prev != NULL ) ) ||                      \
00337      ( ( (entry_ptr)->ht_prev != NULL ) &&                        \
00338        ( (entry_ptr)->ht_prev->ht_next != (entry_ptr) ) ) ||      \
00339      ( ( (entry_ptr)->ht_next != NULL ) &&                        \
00340        ( (entry_ptr)->ht_next->ht_prev != (entry_ptr) ) ) ) {     \
00341     HDfprintf(stdout, "Post successful HT search SC failed.\n");  \
00342 }
00343 
00344 #define H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k)           \
00345 if ( ( (cache_ptr) == NULL ) ||                                        \
00346      ( ((cache_ptr)->index)[k] != (entry_ptr) ) ||                     \
00347      ( (entry_ptr)->ht_prev != NULL ) ) {                              \
00348     HDfprintf(stdout, "Post HT shift to front failed.\n");             \
00349 }
00350 
00351 #define H5C_TEST__SEARCH_INDEX(cache_ptr, Addr, entry_ptr)                   \
00352 {                                                                       \
00353     int k;                                                              \
00354     int depth = 0;                                                      \
00355     H5C_TEST__PRE_HT_SEARCH_SC(cache_ptr, Addr)                              \
00356     k = H5C__HASH_FCN(Addr);                                            \
00357     entry_ptr = ((cache_ptr)->index)[k];                                \
00358     while ( ( entry_ptr ) && ( H5F_addr_ne(Addr, (entry_ptr)->addr) ) ) \
00359     {                                                                   \
00360         (entry_ptr) = (entry_ptr)->ht_next;                             \
00361         (depth)++;                                                      \
00362     }                                                                   \
00363     if ( entry_ptr )                                                    \
00364     {                                                                   \
00365         H5C_TEST__POST_SUC_HT_SEARCH_SC(cache_ptr, entry_ptr, Addr, k)       \
00366         if ( entry_ptr != ((cache_ptr)->index)[k] )                     \
00367         {                                                               \
00368             if ( (entry_ptr)->ht_next )                                 \
00369             {                                                           \
00370                 (entry_ptr)->ht_next->ht_prev = (entry_ptr)->ht_prev;   \
00371             }                                                           \
00372             HDassert( (entry_ptr)->ht_prev != NULL );                   \
00373             (entry_ptr)->ht_prev->ht_next = (entry_ptr)->ht_next;       \
00374             ((cache_ptr)->index)[k]->ht_prev = (entry_ptr);             \
00375             (entry_ptr)->ht_next = ((cache_ptr)->index)[k];             \
00376             (entry_ptr)->ht_prev = NULL;                                \
00377             ((cache_ptr)->index)[k] = (entry_ptr);                      \
00378             H5C_TEST__POST_HT_SHIFT_TO_FRONT(cache_ptr, entry_ptr, k)        \
00379         }                                                               \
00380     }                                                                   \
00381 }
00382 
00383 
00384 /* misc type definitions */
00385 
00386 struct flush_cache_test_spec
00387 {
00388     int                 entry_num;
00389     int                 entry_type;
00390     int                 entry_index;
00391     hbool_t             insert_flag;
00392     hbool_t             dirty_flag;
00393     unsigned int        flags;
00394     hbool_t             expected_loaded;
00395     hbool_t             expected_cleared;
00396     hbool_t             expected_flushed;
00397     hbool_t             expected_destroyed;
00398 };
00399 
00400 struct pe_flush_cache_test_spec
00401 {
00402     int                 entry_num;
00403     int                 entry_type;
00404     int                 entry_index;
00405     hbool_t             insert_flag;
00406     hbool_t             dirty_flag;
00407     unsigned int        flags;
00408     int                 num_pins;
00409     int                 pin_type[MAX_PINS];
00410     int                 pin_idx[MAX_PINS];
00411     hbool_t             expected_loaded;
00412     hbool_t             expected_cleared;
00413     hbool_t             expected_flushed;
00414     hbool_t             expected_destroyed;
00415 };
00416 
00417 struct fo_flush_entry_check
00418 {
00419     int                 entry_num;
00420     int                 entry_type;
00421     int                 entry_index;
00422     size_t              expected_size;
00423     hbool_t             in_cache;
00424     hbool_t             at_main_addr;
00425     hbool_t             is_dirty;
00426     hbool_t             is_protected;
00427     hbool_t             is_pinned;
00428     hbool_t             expected_loaded;
00429     hbool_t             expected_cleared;
00430     hbool_t             expected_flushed;
00431     hbool_t             expected_destroyed;
00432 };
00433 
00434 struct fo_flush_cache_test_spec
00435 {
00436     int                         entry_num;
00437     int                         entry_type;
00438     int                         entry_index;
00439     hbool_t                     insert_flag;
00440     unsigned int                flags;
00441     size_t                      new_size;
00442     int                         num_pins;
00443     int                         pin_type[MAX_PINS];
00444     int                         pin_idx[MAX_PINS];
00445     int                         num_flush_ops;
00446     struct flush_op             flush_ops[MAX_FLUSH_OPS];
00447     hbool_t                     expected_loaded;
00448     hbool_t                     expected_cleared;
00449     hbool_t                     expected_flushed;
00450     hbool_t                     expected_destroyed;
00451 };
00452 
00453 struct rename_entry_test_spec
00454 {
00455     int                 entry_type;
00456     int                 entry_index;
00457     hbool_t             is_dirty;
00458     hbool_t             is_pinned;
00459 };
00460 
00461 struct expected_entry_status
00462 {
00463     int                 entry_type;
00464     int                 entry_index;
00465     size_t              size;
00466     unsigned char       in_cache;
00467     unsigned char       at_main_addr;
00468     unsigned char       is_dirty;
00469     unsigned char       is_protected;
00470     unsigned char       is_pinned;
00471     unsigned char       loaded;
00472     unsigned char       cleared;
00473     unsigned char       flushed;
00474     unsigned char       destroyed;
00475 };
00476 
00477 
00478 
00479 
00480 /* global variable externs: */
00481 
00482 extern const char *FILENAME[];
00483 
00484 extern hbool_t write_permitted;
00485 extern hbool_t pass; /* set to false on error */
00486 extern hbool_t skip_long_tests;
00487 extern hbool_t run_full_test;
00488 extern const char *failure_mssg;
00489 
00490 extern test_entry_t pico_entries[NUM_PICO_ENTRIES];
00491 extern test_entry_t nano_entries[NUM_NANO_ENTRIES];
00492 extern test_entry_t micro_entries[NUM_MICRO_ENTRIES];
00493 extern test_entry_t tiny_entries[NUM_TINY_ENTRIES];
00494 extern test_entry_t small_entries[NUM_SMALL_ENTRIES];
00495 extern test_entry_t medium_entries[NUM_MEDIUM_ENTRIES];
00496 extern test_entry_t large_entries[NUM_LARGE_ENTRIES];
00497 extern test_entry_t huge_entries[NUM_HUGE_ENTRIES];
00498 extern test_entry_t monster_entries[NUM_MONSTER_ENTRIES];
00499 
00500 extern test_entry_t * entries[NUMBER_OF_ENTRY_TYPES];
00501 extern const int32_t max_indices[NUMBER_OF_ENTRY_TYPES];
00502 extern const size_t entry_sizes[NUMBER_OF_ENTRY_TYPES];
00503 extern const haddr_t base_addrs[NUMBER_OF_ENTRY_TYPES];
00504 extern const haddr_t alt_base_addrs[NUMBER_OF_ENTRY_TYPES];
00505 extern const char * entry_type_names[NUMBER_OF_ENTRY_TYPES];
00506 
00507 
00508 /* call back function declarations: */
00509 
00510 herr_t check_write_permitted(const H5F_t * f,
00511                              hid_t dxpl_id,
00512                              hbool_t * write_permitted_ptr);
00513 
00514 herr_t pico_clear(H5F_t * f, void *  thing, hbool_t dest);
00515 herr_t nano_clear(H5F_t * f, void *  thing, hbool_t dest);
00516 herr_t micro_clear(H5F_t * f, void *  thing, hbool_t dest);
00517 herr_t tiny_clear(H5F_t * f, void *  thing, hbool_t dest);
00518 herr_t small_clear(H5F_t * f, void *  thing, hbool_t dest);
00519 herr_t medium_clear(H5F_t * f, void *  thing, hbool_t dest);
00520 herr_t large_clear(H5F_t * f, void *  thing, hbool_t dest);
00521 herr_t huge_clear(H5F_t * f, void *  thing, hbool_t dest);
00522 herr_t monster_clear(H5F_t * f, void *  thing, hbool_t dest);
00523 herr_t variable_clear(H5F_t * f, void *  thing, hbool_t dest);
00524 
00525 
00526 herr_t pico_dest(H5F_t * f, void * thing);
00527 herr_t nano_dest(H5F_t * f, void * thing);
00528 herr_t micro_dest(H5F_t * f, void * thing);
00529 herr_t tiny_dest(H5F_t * f, void * thing);
00530 herr_t small_dest(H5F_t * f, void * thing);
00531 herr_t medium_dest(H5F_t * f, void * thing);
00532 herr_t large_dest(H5F_t * f, void * thing);
00533 herr_t huge_dest(H5F_t * f, void *  thing);
00534 herr_t monster_dest(H5F_t * f, void *  thing);
00535 herr_t variable_dest(H5F_t * f, void *  thing);
00536 
00537 
00538 herr_t pico_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00539                   haddr_t addr, void *thing, unsigned * flags_ptr);
00540 herr_t nano_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00541                   haddr_t addr, void *thing, unsigned * flags_ptr);
00542 herr_t micro_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00543                    haddr_t addr, void *thing, unsigned * flags_ptr);
00544 herr_t tiny_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00545                   haddr_t addr, void *thing, unsigned * flags_ptr);
00546 herr_t small_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00547                    haddr_t addr, void *thing, unsigned * flags_ptr);
00548 herr_t medium_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00549                     haddr_t addr, void *thing, unsigned * flags_ptr);
00550 herr_t large_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00551                    haddr_t addr, void *thing, unsigned * flags_ptr);
00552 herr_t huge_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00553                   haddr_t addr, void *thing, unsigned * flags_ptr);
00554 herr_t monster_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00555                      haddr_t addr, void *thing, unsigned * flags_ptr);
00556 herr_t variable_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
00557                       haddr_t addr, void *thing, unsigned * flags_ptr);
00558 
00559 
00560 void * pico_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00561                  const void *udata1, void *udata2);
00562 void * nano_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00563                  const void *udata1, void *udata2);
00564 void * micro_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00565                   const void *udata1, void *udata2);
00566 void * tiny_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00567                  const void *udata1, void *udata2);
00568 void * small_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00569                   const void *udata1, void *udata2);
00570 void * medium_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00571                    const void *udata1, void *udata2);
00572 void * large_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00573                   const void *udata1, void *udata2);
00574 void * huge_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00575                  const void *udata1, void *udata2);
00576 void * monster_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00577                     const void *udata1, void *udata2);
00578 void * variable_load(H5F_t *f, hid_t dxpl_id, haddr_t addr,
00579                      const void *udata1, void *udata2);
00580 
00581 
00582 herr_t pico_size(H5F_t * f, void * thing, size_t * size_ptr);
00583 herr_t nano_size(H5F_t * f, void * thing, size_t * size_ptr);
00584 herr_t micro_size(H5F_t * f, void * thing, size_t * size_ptr);
00585 herr_t tiny_size(H5F_t * f, void * thing, size_t * size_ptr);
00586 herr_t small_size(H5F_t * f, void * thing, size_t * size_ptr);
00587 herr_t medium_size(H5F_t * f, void * thing, size_t * size_ptr);
00588 herr_t large_size(H5F_t * f, void * thing, size_t * size_ptr);
00589 herr_t huge_size(H5F_t * f, void * thing, size_t * size_ptr);
00590 herr_t monster_size(H5F_t * f, void * thing, size_t * size_ptr);
00591 herr_t variable_size(H5F_t * f, void * thing, size_t * size_ptr);
00592 
00593 /* callback table extern */
00594 
00595 extern const H5C_class_t types[NUMBER_OF_ENTRY_TYPES];
00596 
00597 
00598 /* function declarations: */
00599 
00600 void add_flush_op(int target_type,
00601                   int target_idx,
00602                   int op_code,
00603                   int type,
00604                   int idx,
00605                   hbool_t flag,
00606                   size_t size);
00607 
00608 
00609 void addr_to_type_and_index(haddr_t addr,
00610                             int32_t * type_ptr,
00611                             int32_t * index_ptr);
00612 
00613 #if 0 /* keep this for a while -- it may be useful */
00614 haddr_t type_and_index_to_addr(int32_t type,
00615                                int32_t idx);
00616 #endif
00617 
00618 void dirty_entry(H5F_t * file_ptr,
00619                  int32_t type,
00620                  int32_t idx,
00621                  hbool_t dirty_pin);
00622 
00623 void expunge_entry(H5F_t * file_ptr,
00624                    int32_t type,
00625                    int32_t idx);
00626 
00627 void insert_entry(H5F_t * file_ptr,
00628                   int32_t type,
00629                   int32_t idx,
00630                   hbool_t dirty,
00631                   unsigned int flags);
00632 
00633 void mark_pinned_entry_dirty(int32_t type,
00634                              int32_t idx,
00635                              hbool_t size_changed,
00636                              size_t  new_size);
00637 
00638 void mark_pinned_or_protected_entry_dirty(int32_t type,
00639                                           int32_t idx);
00640 
00641 void rename_entry(H5C_t * cache_ptr,
00642                   int32_t type,
00643                   int32_t idx,
00644                   hbool_t main_addr);
00645 
00646 void protect_entry(H5F_t * file_ptr,
00647                    int32_t type,
00648                    int32_t idx);
00649 
00650 void protect_entry_ro(H5F_t * file_ptr,
00651                       int32_t type,
00652                       int32_t idx);
00653 
00654 hbool_t entry_in_cache(H5C_t * cache_ptr,
00655                        int32_t type,
00656                        int32_t idx);
00657 
00658 void create_pinned_entry_dependency(H5F_t * file_ptr,
00659                                     int pinning_type,
00660                                     int pinning_idx,
00661                                     int pinned_type,
00662                                     int pinned_idx);
00663 
00664 void reset_entries(void);
00665 
00666 void resize_entry(H5F_t * file_ptr,
00667                    int32_t type,
00668                    int32_t idx,
00669                    size_t new_size,
00670                    hbool_t resize_pin);
00671 
00672 void resize_pinned_entry(H5C_t * cache_ptr,
00673                          int32_t type,
00674                          int32_t idx,
00675                          size_t new_size);
00676 
00677 H5F_t *setup_cache(size_t max_cache_size, size_t min_clean_size);
00678 
00679 void row_major_scan_forward(H5F_t * file_ptr,
00680                             int32_t lag,
00681                             hbool_t verbose,
00682                             hbool_t reset_stats,
00683                             hbool_t display_stats,
00684                             hbool_t display_detailed_stats,
00685                             hbool_t do_inserts,
00686                             hbool_t dirty_inserts,
00687                             hbool_t do_renames,
00688                             hbool_t rename_to_main_addr,
00689                             hbool_t do_destroys,
00690                             hbool_t do_mult_ro_protects,
00691                             int dirty_destroys,
00692                             int dirty_unprotects);
00693 
00694 void hl_row_major_scan_forward(H5F_t * file_ptr,
00695                                int32_t max_index,
00696                                hbool_t verbose,
00697                                hbool_t reset_stats,
00698                                hbool_t display_stats,
00699                                hbool_t display_detailed_stats,
00700                                hbool_t do_inserts,
00701                                hbool_t dirty_inserts);
00702 
00703 void row_major_scan_backward(H5F_t * file_ptr,
00704                              int32_t lag,
00705                              hbool_t verbose,
00706                              hbool_t reset_stats,
00707                              hbool_t display_stats,
00708                              hbool_t display_detailed_stats,
00709                              hbool_t do_inserts,
00710                              hbool_t dirty_inserts,
00711                              hbool_t do_renames,
00712                              hbool_t rename_to_main_addr,
00713                              hbool_t do_destroys,
00714                              hbool_t do_mult_ro_protects,
00715                              int dirty_destroys,
00716                              int dirty_unprotects);
00717 
00718 void hl_row_major_scan_backward(H5F_t * file_ptr,
00719                                 int32_t max_index,
00720                                 hbool_t verbose,
00721                                 hbool_t reset_stats,
00722                                 hbool_t display_stats,
00723                                 hbool_t display_detailed_stats,
00724                                 hbool_t do_inserts,
00725                                 hbool_t dirty_inserts);
00726 
00727 void col_major_scan_forward(H5F_t * file_ptr,
00728                             int32_t lag,
00729                             hbool_t verbose,
00730                             hbool_t reset_stats,
00731                             hbool_t display_stats,
00732                             hbool_t display_detailed_stats,
00733                             hbool_t do_inserts,
00734                             hbool_t dirty_inserts,
00735                             int dirty_unprotects);
00736 
00737 void hl_col_major_scan_forward(H5F_t * file_ptr,
00738                                int32_t max_index,
00739                                hbool_t verbose,
00740                                hbool_t reset_stats,
00741                                hbool_t display_stats,
00742                                hbool_t display_detailed_stats,
00743                                hbool_t do_inserts,
00744                                hbool_t dirty_inserts,
00745                                int dirty_unprotects);
00746 
00747 void col_major_scan_backward(H5F_t * file_ptr,
00748                              int32_t lag,
00749                              hbool_t verbose,
00750                              hbool_t reset_stats,
00751                              hbool_t display_stats,
00752                              hbool_t display_detailed_stats,
00753                              hbool_t do_inserts,
00754                              hbool_t dirty_inserts,
00755                              int dirty_unprotects);
00756 
00757 void hl_col_major_scan_backward(H5F_t * file_ptr,
00758                                 int32_t max_index,
00759                                 hbool_t verbose,
00760                                 hbool_t reset_stats,
00761                                 hbool_t display_stats,
00762                                 hbool_t display_detailed_stats,
00763                                 hbool_t do_inserts,
00764                                 hbool_t dirty_inserts,
00765                                 int dirty_unprotects);
00766 
00767 void takedown_cache(H5F_t * file_ptr,
00768                     hbool_t dump_stats,
00769                     hbool_t dump_detailed_stats);
00770 
00771 void flush_cache(H5F_t * file_ptr,
00772                  hbool_t destroy_entries,
00773                  hbool_t dump_stats,
00774                  hbool_t dump_detailed_stats);
00775 
00776 void unpin_entry(int32_t type,
00777                  int32_t idx);
00778 
00779 void unprotect_entry(H5F_t * file_ptr,
00780                      int32_t type,
00781                      int32_t idx,
00782                      int dirty,
00783                      unsigned int flags);
00784 
00785 void unprotect_entry_with_size_change(H5F_t * file_ptr,
00786                                       int32_t type,
00787                                       int32_t idx,
00788                                       unsigned int flags,
00789                                       size_t new_size);
00790 
00791 void verify_clean(void);
00792 
00793 void verify_entry_status(H5C_t * cache_ptr,
00794                          int tag,
00795                          int num_entries,
00796                          struct expected_entry_status expected[]);
00797 
00798 void verify_unprotected(void);
00799 
00800 #endif /* _CACHE_COMMON_H */
00801