Browse Source

Configure metadata cache

Peter Colberg 3 years ago
parent
commit
9df6484533
4 changed files with 62 additions and 16 deletions
  1. 6
    0
      doc/reference.html
  2. 10
    0
      doc/reference.mdwn
  3. 30
    16
      hdf5/init.lua
  4. 16
    0
      test/file.lua

+ 6
- 0
doc/reference.html View File

@@ -901,6 +901,12 @@
901 901
 <dt><code>fapl:get_libver_bounds()</code></dt>
902 902
 <dd><p>Returns the lower and the upper bound on the file format version.</p>
903 903
 </dd>
904
+<dt><code>fapl:set_mdc_config(config)</code></dt>
905
+<dd><p>Sets the current initial <a href="https://www.hdfgroup.org/HDF5/doc/Advanced/MetadataCache/">metadata cache</a> configuration.</p>
906
+</dd>
907
+<dt><code>fapl:get_mdc_config()</code></dt>
908
+<dd><p>Returns the current initial <a href="https://www.hdfgroup.org/HDF5/doc/Advanced/MetadataCache/">metadata cache</a> configuration.</p>
909
+</dd>
904 910
 <dt><code>fapl:set_fapl_core(increment, backing_store)</code></dt>
905 911
 <dd><p>Sets the core file driver for read and write access to a file. The contents of the file are stored in a buffer for which memory is allocated as needed in multiples of the given increment size in bytes. If <code>backing_store</code> is <strong>true</strong>, an empty file is created on disk, and the contents of the file are written to disk when the file is flushed or closed; otherwise, if <strong>false</strong>, the file is not created on disk, and the contents of the file are discarded when the file is closed.</p>
906 912
 </dd>

+ 10
- 0
doc/reference.mdwn View File

@@ -981,6 +981,16 @@ Property lists
981 981
 
982 982
   : Returns the lower and the upper bound on the file format version.
983 983
 
984
+`fapl:set_mdc_config(config)`
985
+
986
+  : Sets the current initial [metadata cache] configuration.
987
+
988
+    [metadata cache]: https://www.hdfgroup.org/HDF5/doc/Advanced/MetadataCache/
989
+
990
+`fapl:get_mdc_config()`
991
+
992
+  : Returns the current initial [metadata cache] configuration.
993
+
984 994
 `fapl:set_fapl_core(increment, backing_store)`
985 995
 
986 996
   : Sets the core file driver for read and write access to a file. The contents

+ 30
- 16
hdf5/init.lua View File

@@ -14,22 +14,23 @@ local assert, error, min, rawget, rawset, tonumber = assert, error, math.min, ra
14 14
 local _M = {}
15 15
 
16 16
 -- C types.
17
-local H5D_fill_value_t_1 = ffi.typeof("H5D_fill_value_t[1]")
18
-local H5E_walk_t         = ffi.typeof("H5E_walk_t")
19
-local H5F_libver_t_1     = ffi.typeof("H5F_libver_t[1]")
20
-local H5G_info_t         = ffi.typeof("H5G_info_t")
21
-local H5G_info_t_1       = ffi.typeof("H5G_info_t[1]")
22
-local H5O_info_t         = ffi.typeof("H5O_info_t")
23
-local H5O_info_t_1       = ffi.typeof("H5O_info_t[1]")
24
-local H5O_type_t_1       = ffi.typeof("H5O_type_t[1]")
25
-local char_n             = ffi.typeof("char[?]")
26
-local hbool_t_1          = ffi.typeof("hbool_t[1]")
27
-local hid_t_n            = ffi.typeof("hid_t[?]")
28
-local hsize_t_n          = ffi.typeof("hsize_t[?]")
29
-local hssize_t_n         = ffi.typeof("hssize_t[?]")
30
-local size_t_1           = ffi.typeof("size_t[1]")
31
-local unsigned_1         = ffi.typeof("unsigned[1]")
32
-local void_ptr_1         = ffi.typeof("void *[1]")
17
+local H5AC_cache_config_t = ffi.typeof("H5AC_cache_config_t")
18
+local H5D_fill_value_t_1  = ffi.typeof("H5D_fill_value_t[1]")
19
+local H5E_walk_t          = ffi.typeof("H5E_walk_t")
20
+local H5F_libver_t_1      = ffi.typeof("H5F_libver_t[1]")
21
+local H5G_info_t          = ffi.typeof("H5G_info_t")
22
+local H5G_info_t_1        = ffi.typeof("H5G_info_t[1]")
23
+local H5O_info_t          = ffi.typeof("H5O_info_t")
24
+local H5O_info_t_1        = ffi.typeof("H5O_info_t[1]")
25
+local H5O_type_t_1        = ffi.typeof("H5O_type_t[1]")
26
+local char_n              = ffi.typeof("char[?]")
27
+local hbool_t_1           = ffi.typeof("hbool_t[1]")
28
+local hid_t_n             = ffi.typeof("hid_t[?]")
29
+local hsize_t_n           = ffi.typeof("hsize_t[?]")
30
+local hssize_t_n          = ffi.typeof("hssize_t[?]")
31
+local size_t_1            = ffi.typeof("size_t[1]")
32
+local unsigned_1          = ffi.typeof("unsigned[1]")
33
+local void_ptr_1          = ffi.typeof("void *[1]")
33 34
 
34 35
 -- Object identifiers.
35 36
 local attribute_id = ffi.typeof("struct { hid_t id; }")
@@ -1114,6 +1115,19 @@ do
1114 1115
   end
1115 1116
 end
1116 1117
 
1118
+function plist.get_mdc_config(fapl)
1119
+  local mdc_config = H5AC_cache_config_t()
1120
+  mdc_config.version = C.H5AC__CURR_CACHE_CONFIG_VERSION
1121
+  local err = C.H5Pget_mdc_config(fapl.id, mdc_config)
1122
+  if err < 0 then return error(get_error()) end
1123
+  return mdc_config
1124
+end
1125
+
1126
+function plist.set_mdc_config(fapl, mdc_config)
1127
+  local err = C.H5Pset_mdc_config(fapl.id, mdc_config)
1128
+  if err < 0 then return error(get_error()) end
1129
+end
1130
+
1117 1131
 function plist.set_fapl_core(fapl, increment, backing_store)
1118 1132
   local err = C.H5Pset_fapl_core(fapl.id, increment, backing_store)
1119 1133
   if err < 0 then return error(get_error()) end

+ 16
- 0
test/file.lua View File

@@ -156,6 +156,22 @@ end
156 156
 
157 157
 do
158 158
   local fapl = hdf5.create_plist("file_access")
159
+  do
160
+    local mdc_config = fapl:get_mdc_config()
161
+    mdc_config.evictions_enabled = false
162
+    mdc_config.incr_mode = "H5C_incr__off"
163
+    mdc_config.decr_mode = "H5C_decr__off"
164
+    mdc_config.flash_incr_mode = "H5C_flash_incr__off"
165
+    fapl:set_mdc_config(mdc_config)
166
+  end
167
+  local file = hdf5.create_file(path, "trunc", nil, fapl)
168
+  fapl:close()
169
+  file:flush()
170
+  file:close()
171
+end
172
+
173
+do
174
+  local fapl = hdf5.create_plist("file_access")
159 175
   fapl:set_fapl_core(2 ^ 20, true)
160 176
   local file = hdf5.create_file(path, "trunc", nil, fapl)
161 177
   fapl:close()

Loading…
Cancel
Save