VOL-Async: Debugging Async operation failures

Though what would be your suggestion in that case, would it be better to free() after or to simply use “memcpy”?

This is something that often must be determined on a case by case basis. Allowing the connector to copy your buffer can allow for more asynchrony, but also usually increases the amount of memory used at any given time during program execution. It also tends to give you less control over when buffers are freed. But if the system you’re running on has lots of memory to throw at a problem, allowing the buffer copies can be helpful.

Looking back at your program, you should make sure that the calls to H5Dclose_async() and H5Fclose_async() come after the call to H5ESwait(). Otherwise, H5ESclose() should fail if there are any active operations going on in the event set being closed.

For checking for errors, the following is boilerplate for this from the async VOL document:

// Check if event set has failed operations (es_err_status is set to true)
status = H5ESget_err_status(es_id, &es_err_status);
// Retrieve the number of failed operations in this event set
H5ESget_err_count(es_id, &es_err_count);
// Retrieve information about failed operations
H5ESget_err_info(es_id, 1, &err_info, &es_err_cleared);
// Inspect and handle the error if there is any
...
H5free_memory(err_info.api_name);
H5free_memory(err_info.api_args);
H5free_memory(err_info.app_file_name);
H5free_memory(err_info.app_func_name);

H5ESget_err_status() just returns a boolean in es_err_status telling you whether an error occurred. If it’s true, then you call H5ESget_err_count() to get the number of errors that occurred (returned in es_err_count) and then you should allocate an array of H5ES_err_info_t structures of size es_err_count, then call H5ESget_err_info() to populate those structures with info about each error that occurred. Each structure contains information like the API routine that was called, the source line in the program where it was called, etc. that you can inspect. Then, for each structure in the array you should call H5free_memory on the above fields to free memory that the library allocated. Note that all this error handling code should basically be the last thing in your current program, after the call to H5ESwait() and before closing the event set with H5ESclose().

1 Like