H5ESpublic.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * Copyright by The HDF Group. *
  3. * All rights reserved. *
  4. * *
  5. * This file is part of HDF5. The full HDF5 copyright notice, including *
  6. * terms governing use, modification, and redistribution, is contained in *
  7. * the COPYING file, which can be found at the root of the source code *
  8. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  9. * If you do not have access to either file, you may request a copy from *
  10. * help@hdfgroup.org. *
  11. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  12. /*
  13. * This file contains public declarations for the H5ES (event set) module.
  14. */
  15. #ifndef H5ESpublic_H
  16. #define H5ESpublic_H
  17. /* Public headers needed by this file */
  18. #include "H5public.h" /* Generic Functions */
  19. /*****************/
  20. /* Public Macros */
  21. /*****************/
  22. /* Default value for "no event set" / synchronous execution */
  23. #define H5ES_NONE 0 /* (hid_t) */
  24. /* Special "wait" timeout values */
  25. #define H5ES_WAIT_FOREVER (UINT64_MAX) /* Wait until all operations complete */
  26. #define H5ES_WAIT_NONE \
  27. (0) /* Don't wait for operations to complete, \
  28. * just check their status. \
  29. * (this allows H5ESwait to behave \
  30. * like a 'test' operation) \
  31. */
  32. /*******************/
  33. /* Public Typedefs */
  34. /*******************/
  35. /* Asynchronous operation status */
  36. typedef enum H5ES_status_t {
  37. H5ES_STATUS_IN_PROGRESS, /* Operation(s) have not yet completed */
  38. H5ES_STATUS_SUCCEED, /* Operation(s) have completed, successfully */
  39. H5ES_STATUS_CANCELED, /* Operation(s) has been canceled */
  40. H5ES_STATUS_FAIL /* An operation has completed, but failed */
  41. } H5ES_status_t;
  42. /* Information about operations in an event set */
  43. typedef struct H5ES_op_info_t {
  44. /* API call info */
  45. const char *api_name; /* Name of HDF5 API routine called */
  46. char * api_args; /* "Argument string" for arguments to HDF5 API routine called */
  47. /* Application info */
  48. const char *app_file_name; /* Name of source file where the HDF5 API routine was called */
  49. const char *app_func_name; /* Name of function where the HDF5 API routine was called */
  50. unsigned app_line_num; /* Line # of source file where the HDF5 API routine was called */
  51. /* Operation info */
  52. uint64_t op_ins_count; /* Counter of operation's insertion into event set */
  53. uint64_t op_ins_ts; /* Timestamp for when the operation was inserted into the event set */
  54. uint64_t op_exec_ts; /* Timestamp for when the operation began execution */
  55. uint64_t op_exec_time; /* Execution time for operation (in ns) */
  56. } H5ES_op_info_t;
  57. //! <!-- [H5ES_err_info_t_snip] -->
  58. /**
  59. * Information about failed operations in event set
  60. */
  61. typedef struct H5ES_err_info_t {
  62. /* API call info */
  63. char *api_name; /**< Name of HDF5 API routine called */
  64. char *api_args; /**< "Argument string" for arguments to HDF5 API routine called */
  65. /* Application info */
  66. char * app_file_name; /**< Name of source file where the HDF5 API routine was called */
  67. char * app_func_name; /**< Name of function where the HDF5 API routine was called */
  68. unsigned app_line_num; /**< Line # of source file where the HDF5 API routine was called */
  69. /* Operation info */
  70. uint64_t op_ins_count; /**< Counter of operation's insertion into event set */
  71. uint64_t op_ins_ts; /**< Timestamp for when the operation was inserted into the event set */
  72. uint64_t op_exec_ts; /**< Timestamp for when the operation began execution */
  73. uint64_t op_exec_time; /**< Execution time for operation (in ns) */
  74. /* Error info */
  75. hid_t err_stack_id; /**< ID for error stack from failed operation */
  76. } H5ES_err_info_t;
  77. //! <!-- [H5ES_err_info_t_snip] -->
  78. /*
  79. More Possible Info for H5ES_op_info_t:
  80. Parent Operation's request token (*) -> "parent event count"? -- Could be
  81. used to "prune" child operations from reported errors, with flag
  82. to H5ESget_err_info?
  83. Possible debugging routines: (Should also be configured from Env Var)
  84. H5ESdebug_signal(hid_t es_id, signal_t sig, uint64_t <event count>);
  85. H5ESdebug_err_trace_log(hid_t es_id, const char *filename);
  86. H5ESdebug_err_trace_fh(hid_t es_id, FILE *fh);
  87. H5ESdebug_err_signal(hid_t es_id, signal_t sig);
  88. [Possibly option to allow operations to be inserted into event set with error?]
  89. Example usage:
  90. es_id = H5EScreate();
  91. H5ESdebug...(es_id, ...);
  92. ...
  93. H5Dwrite_async(..., es_id);
  94. How to Trace Async Operations?
  95. <Example of stacking Logging VOL Connector w/Async VOL Connector>
  96. */
  97. typedef int (*H5ES_event_insert_func_t)(const H5ES_op_info_t *op_info, void *ctx);
  98. typedef int (*H5ES_event_complete_func_t)(const H5ES_op_info_t *op_info, H5ES_status_t status,
  99. hid_t err_stack, void *ctx);
  100. /********************/
  101. /* Public Variables */
  102. /********************/
  103. /*********************/
  104. /* Public Prototypes */
  105. /*********************/
  106. #ifdef __cplusplus
  107. extern "C" {
  108. #endif
  109. /**
  110. * \ingroup H5ES
  111. *
  112. * \brief Creates an event set
  113. *
  114. * \returns \hid_ti{event set}
  115. *
  116. * \details H5EScreate() creates a new event set and returns a corresponding
  117. * event set identifier.
  118. *
  119. * \since 1.13.0
  120. *
  121. */
  122. H5_DLL hid_t H5EScreate(void);
  123. /**
  124. * \ingroup H5ES
  125. *
  126. * \brief Waits for operations in event set to complete
  127. *
  128. * \es_id
  129. * \param[in] timeout Total time in nanoseconds to wait for all operations in
  130. * the event set to complete
  131. * \param[out] num_in_progress The number of operations still in progress
  132. * \param[out] err_occurred Flag if an operation in the event set failed
  133. * \returns \herr_t
  134. *
  135. * \details H5ESwait() waits for operations in an event set \p es_id to wait
  136. * with \p timeout.
  137. *
  138. * Timeout value is in nanoseconds, and is for the H5ESwait() call and
  139. * not for each individual operation in the event set. For example, if
  140. * "10" is passed as a timeout value and the event set waited 4
  141. * nanoseconds for the first operation to complete, the remaining
  142. * operations would be allowed to wait for at most 6 nanoseconds more,
  143. * i.e., the timeout value used across all operations in the event set
  144. * until it reaches 0, then any remaining operations are only checked
  145. * for completion, not waited on.
  146. *
  147. * This call will stop waiting on operations and will return
  148. * immediately if an operation fails. If a failure occurs, the value
  149. * returned for the number of operations in progress may be inaccurate.
  150. *
  151. * \since 1.13.0
  152. *
  153. */
  154. H5_DLL herr_t H5ESwait(hid_t es_id, uint64_t timeout, size_t *num_in_progress, hbool_t *err_occurred);
  155. H5_DLL herr_t H5EScancel(hid_t es_id, size_t *num_not_canceled, hbool_t *err_occurred);
  156. /**
  157. * \ingroup H5ES
  158. *
  159. * \brief Retrieves number of events in an event set
  160. *
  161. * \es_id
  162. * \param[out] count The number of events in the event set
  163. * \returns \herr_t
  164. *
  165. * \details H5ESget_count() retrieves number of events in an event set specified
  166. * by \p es_id.
  167. *
  168. * \since 1.13.0
  169. *
  170. */
  171. H5_DLL herr_t H5ESget_count(hid_t es_id, size_t *count);
  172. /**
  173. * \ingroup H5ES
  174. *
  175. * \brief Retrieves the next operation counter to be assigned in an event set
  176. *
  177. * \es_id
  178. * \param[out] counter The next counter value to be assigned to an event
  179. * \returns \herr_t
  180. *
  181. * \details H5ESget_op_counter() retrieves the \p counter that will be assigned
  182. * to the next operation inserted into the event set \p es_id.
  183. *
  184. * \note This is designed for wrapper libraries mainly, to use as a mechanism
  185. * for matching operations inserted into the event set with possible
  186. * errors that occur.
  187. *
  188. * \since 1.13.0
  189. *
  190. */
  191. H5_DLL herr_t H5ESget_op_counter(hid_t es_id, uint64_t *counter);
  192. /**
  193. * \ingroup H5ES
  194. *
  195. * \brief Checks for failed operations
  196. *
  197. * \es_id
  198. * \param[out] err_occurred Status indicating if error is present in the event
  199. * set
  200. * \returns \herr_t
  201. *
  202. * \details H5ESget_err_status() checks if event set specified by es_id has
  203. * failed operations.
  204. *
  205. * \since 1.13.0
  206. *
  207. */
  208. H5_DLL herr_t H5ESget_err_status(hid_t es_id, hbool_t *err_occurred);
  209. /**
  210. * \ingroup H5ES
  211. *
  212. * \brief Retrieves the number of failed operations
  213. *
  214. * \es_id
  215. * \param[out] num_errs Number of errors
  216. * \returns \herr_t
  217. *
  218. * \details H5ESget_err_count() retrieves the number of failed operations in an
  219. * event set specified by \p es_id.
  220. *
  221. * The function does not wait for active operations to complete, so
  222. * count may not include all failures.
  223. *
  224. * \since 1.13.0
  225. *
  226. */
  227. H5_DLL herr_t H5ESget_err_count(hid_t es_id, size_t *num_errs);
  228. /**
  229. * \ingroup H5ES
  230. *
  231. * \brief Retrieves information about failed operations
  232. *
  233. * \es_id
  234. * \param[in] num_err_info The number of elements in \p err_info array
  235. * \param[out] err_info Array of structures
  236. * \param[out] err_cleared Number of cleared errors
  237. * \returns \herr_t
  238. *
  239. * \details H5ESget_err_info() retrieves information about failed operations in
  240. * an event set specified by \p es_id. The strings retrieved for each
  241. * error info must be released by calling H5free_memory().
  242. *
  243. * Below is the description of the \ref H5ES_err_info_t structure:
  244. * \snippet this H5ES_err_info_t_snip
  245. * \click4more
  246. *
  247. * \since 1.13.0
  248. *
  249. */
  250. H5_DLL herr_t H5ESget_err_info(hid_t es_id, size_t num_err_info, H5ES_err_info_t err_info[],
  251. size_t *err_cleared);
  252. H5_DLL herr_t H5ESfree_err_info(size_t num_err_info, H5ES_err_info_t err_info[]);
  253. H5_DLL herr_t H5ESregister_insert_func(hid_t es_id, H5ES_event_insert_func_t func, void *ctx);
  254. H5_DLL herr_t H5ESregister_complete_func(hid_t es_id, H5ES_event_complete_func_t func, void *ctx);
  255. /**
  256. * \ingroup H5ES
  257. *
  258. * \brief Terminates access to an event set
  259. *
  260. * \es_id
  261. * \returns \herr_t
  262. *
  263. * \details H5ESclose() terminates access to an event set specified by \p es_id.
  264. *
  265. * \since 1.13.0
  266. *
  267. */
  268. H5_DLL herr_t H5ESclose(hid_t es_id);
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272. #endif /* H5ESpublic_H */