H5FDdirect.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * Copyright by the Board of Trustees of the University of Illinois. *
  4. * All rights reserved. *
  5. * *
  6. * This file is part of HDF5. The full HDF5 copyright notice, including *
  7. * terms governing use, modification, and redistribution, is contained in *
  8. * the COPYING file, which can be found at the root of the source code *
  9. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  10. * If you do not have access to either file, you may request a copy from *
  11. * help@hdfgroup.org. *
  12. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  13. /*
  14. * Programmer: Raymond Lu
  15. * Wednesday, 20 September 2006
  16. *
  17. * Purpose: The public header file for the direct driver.
  18. */
  19. #ifndef H5FDdirect_H
  20. #define H5FDdirect_H
  21. #ifdef H5_HAVE_DIRECT
  22. #define H5FD_DIRECT (H5FDperform_init(H5FD_direct_init))
  23. #define H5FD_DIRECT_VALUE H5_VFD_DIRECT
  24. #else
  25. #define H5FD_DIRECT (H5I_INVALID_HID)
  26. #define H5FD_DIRECT_VALUE H5_VFD_INVALID
  27. #endif /* H5_HAVE_DIRECT */
  28. #ifdef H5_HAVE_DIRECT
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* Default values for memory boundary, file block size, and maximal copy buffer size.
  33. * Application can set these values through the function H5Pset_fapl_direct. */
  34. #define MBOUNDARY_DEF 4096
  35. #define FBSIZE_DEF 4096
  36. #define CBSIZE_DEF 16 * 1024 * 1024
  37. H5_DLL hid_t H5FD_direct_init(void);
  38. /**
  39. * \ingroup FAPL
  40. *
  41. * \brief Sets up use of the direct I/O driver
  42. *
  43. * \fapl_id
  44. * \param[in] alignment Required memory alignment boundary
  45. * \param[in] block_size File system block size
  46. * \param[in] cbuf_size Copy buffer size
  47. * \returns \herr_t
  48. *
  49. * \details H5Pset_fapl_direct() sets the file access property list, \p fapl_id,
  50. * to use the direct I/O driver, #H5FD_DIRECT. With this driver, data
  51. * is written to or read from the file synchronously without being
  52. * cached by the system.
  53. *
  54. * File systems usually require the data address in memory, the file
  55. * address, and the size of the data to be aligned. The HDF5 library’s
  56. * direct I/O driver is able to handle unaligned data, though that will
  57. * consume some additional memory resources and may slow
  58. * performance. To get better performance, use the system function \p
  59. * posix_memalign to align the data buffer in memory and the HDF5
  60. * function H5Pset_alignment() to align the data in the file. Be aware,
  61. * however, that aligned data I/O may cause the HDF5 file to be bigger
  62. * than the actual data size would otherwise require because the
  63. * alignment may leave some holes in the file.
  64. *
  65. * \p alignment specifies the required alignment boundary in memory.
  66. *
  67. * \p block_size specifies the file system block size. A value of 0
  68. * (zero) means to use HDF5 library’s default value of 4KB.
  69. *
  70. * \p cbuf_size specifies the copy buffer size.
  71. *
  72. * \since 1.8.0
  73. *
  74. */
  75. H5_DLL herr_t H5Pset_fapl_direct(hid_t fapl_id, size_t alignment, size_t block_size, size_t cbuf_size);
  76. /**
  77. * \ingroup FAPL
  78. *
  79. * \brief Retrieves direct I/O driver settings
  80. *
  81. * \fapl_id
  82. * \param[out] boundary Required memory alignment boundary
  83. * \param[out] block_size File system block size
  84. * \param[out] cbuf_size Copy buffer size
  85. * \returns \herr_t
  86. *
  87. * \details H5Pget_fapl_direct() retrieves the required memory alignment (\p
  88. * alignment), file system block size (\p block_size), and copy buffer
  89. * size (\p cbuf_size) settings for the direct I/O driver, #H5FD_DIRECT,
  90. * from the file access property list \p fapl_id.
  91. *
  92. * See H5Pset_fapl_direct() for discussion of these values,
  93. * requirements, and important considerations.
  94. *
  95. * \since 1.8.0
  96. *
  97. */
  98. H5_DLL herr_t H5Pget_fapl_direct(hid_t fapl_id, size_t *boundary /*out*/, size_t *block_size /*out*/,
  99. size_t *cbuf_size /*out*/);
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif /* H5_HAVE_DIRECT */
  104. #endif