Last modified: 22 July 2014
Name: H5Pset_cache
Signature:
  `herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0)`
Purpose:
  Sets the raw data chunk cache parameters.
Motivation:
  Setting raw data chunk cache parameters can be done with `H5Pset_cache`, `H5Pset_chunk_cache`, or a combination of both. `H5Pset_cache` is used to adjust the chunk cache parameters for all datasets via a global setting for the file, and `H5Pset_chunk_cache` is used to adjust the chunk cache parameters for individual datasets. When both are used, parameters set with `H5Pset_chunk_cache` will override any parameters set with `H5Pset_cache`.

  Optimum chunk cache parameters may vary widely depending on different data layout and access patterns. For datasets with low performance requirements for example, changing the cache settings can save memory.

Description:
  `H5Pset_cache` sets the number of elements, the total number of bytes, and the preemption policy value for all datasets in a file on the file’s file access property list.

  The raw data chunk cache inserts chunks into the cache by first computing a hash value using the address of a chunk and then by using that hash value as the chunk’s index into the table of cached chunks. In other words, the size of this hash table and the number of possible hash values is determined by the `rdcc_nslots` parameter. If a different chunk in the cache has the same hash value, a collision will occur, which will reduce efficiency. If inserting the chunk into the cache would cause the cache to be too big, then the cache will be pruned according to the `rdcc_w0` parameter.

  The `mdc_nelmts` parameter is no longer used; any value passed in that parameter will be ignored.

Note:
  Raw dataset chunk caching is not currently supported when using the MPI I/O and MPI POSIX file drivers in read/write mode; see `H5Pset_fapl_mpio` and `H5Pset_fapl_mpiposix`, respectively. When using one of these file drivers, all calls to `H5Dread` and `H5Dwrite` will access the disk directly, and `H5Pset_cache` will have no effect on performance.

  Raw dataset chunk caching is supported when these drivers are used in read-only mode.

Parameters:

  `hid_t plist_id` | IN: File access property list identifier.
  `int mdc_nelmts` | IN: No longer used; any value passed is ignored.
  `size_t rdcc_nslots` | IN: The number of chunk slots in the raw data chunk cache for this dataset. Increasing this value reduces the number of cache collisions, but slightly increases the memory used. Due to the hashing strategy, this value should ideally be a prime number. As a rule of thumb, this value should be at least 10 times the number of chunks that can fit in `rdcc_nbytes` bytes. For maximum performance, this value should be set approximately 100 times that number of chunks. The default value is 521.
  `size_t rdcc_nbytes` | IN: Total size of the raw data chunk cache in bytes. The default size is 1 MB per dataset.
  `double rdcc_w0` | IN: The chunk preemption policy for all datasets. This must be between 0 and 1 inclusive and indicates the weighting according to which chunks which have been fully read or written are penalized when determining which chunks to flush from cache. A value of 0 means fully read or written chunks are treated no differently than other chunks (the preemption is strictly LRU) while a value of 1 means fully read or written chunks are always preempted before other chunks. If your application only reads or writes data once, this can be safely set to 1. Otherwise, this should be set lower depending on how often you re-read or re-write the same data. The default value is 0.75. If the value passed is `H5D_CHUNK_CACHE_W0_DEFAULT`, then the property will not be set on `dapl_id`, and the parameter will come from the file access property list.

Returns:
  Returns a non-negative value if successful; otherwise returns a negative value.
Fortran90 Interface: h5pset_cache_f

      SUBROUTINE h5pset_cache_f(prp_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0, hdferr)
        IMPLICIT NONE
        INTEGER(HID_T), INTENT(IN) :: prp_id        ! Property list identifier
        INTEGER, INTENT(IN) :: mdc_nelmts           ! No longer used; any value passed
                                                    ! is ignored.
        INTEGER(SIZE_T), INTENT(IN) :: rdcc_nslots  ! The number of chunk slots
                                                    ! in the raw data chunk cache.
        INTEGER(SIZE_T), INTENT(IN) :: rdcc_nbytes  ! Total size of the raw data
                                                    ! chunk cache in bytes.
        REAL, INTENT(IN) :: rdcc_w0                 ! Preemption policy
        INTEGER, INTENT(OUT) :: hdferr              ! Error code
                                                    ! 0 on success and -1 on failure
      END SUBROUTINE h5pset_cache_f

See Also:
  `H5Pget_cache`
  `H5Pset_chunk_cache`
  “Chunking in HDF5”
History:

Release | Change
1.8.0 | In C, use of the `mdc_nelmts` parameter discontinued. Metadata cache configuration is managed with `H5Pset_mdc_config` and `H5Pget_mdc_config`.
1.6.1 | Fortran `rdcc_nbytes` parameter type changed to `INTEGER(SIZE_T)`.
1.6.0 | In C, the `rdcc_nbytes` and `rdcc_nelmts` parameters changed from type int to size_t. |  |