[Hdf-forum] MPI Virtual File Driver
Quincey Koziol
koziol at hdfgroup.org
Tue Jan 19 17:01:35 EST 2010
Hi John,
On Jan 14, 2010, at 6:56 AM, Biddiscombe, John A. wrote:
> Quincey
>
>>> Add a function to the file driver class struct, which would be called
>> during H5FD_term_interface to set the static H5FD_DSM_g to zero - but we
>> can't do this, because when we reach the point in H5FD_term_interface where
>> H5FD_dsm_term() is called, the handle to the driver has already been closed,
>> and we've invalidate the memory, so the function pointer to callback is not
>> valid.
>>
>> That's the right solution, yes. We can change the order that the
>> interfaces are shut down at library termination so this problem doesn't
>> happen.
>
> I've added a terminate function pointer to the H5FD_class_t structure and modified all the file drivers accordingly. All is well.
Super!
> However, H5_term_library iterates over all the libraries and shuts them down, when H5FD is closed down, the handles outstanding are counted up and iterated over and the reference counts checked to ensure they're safe to delete.
> When the ref count is 1, and it's safe to delete the handle, the handle->free function is called. In the case of the H5I_VFL handle type, the H5FD_class_t free function is called, and the class object is freed - along with all the function pointers it holds.
> We must therefore call our FD class terminate function just before this point, so what I've done is added the following to H5I.c inside the H5I_clear_type(...) function.
>
> // If our object is a Virtual File Driver class, then before destroying it,
> // we must tell the driver to clean up its singleton(s)
> if (type==H5I_VFL) {
> H5FD_class_t *cls = (H5FD_class_t *)(cur->obj_ptr);
> if (cls && cls->terminate) cls->terminate();
> }
>
> This seems to work nicely. The terminate function is called immediately before the class structure is freed, and everyone is happy. (Note that the H5FD_class_t free function doesn't do much, could we tag our terminate inside that to save one callback?)
No, the free callback in the H5FD_class_t struct is for releasing memory in the file.
> The trouble is, that I have no idea if this is a 'good' solution. My knowledge of the rest of the HDF5 internals is still minimal, so if this has other side effects I don't know. It seems to work and have no downside (other than an otherwise irrelevant check in every single call to H5I_clear_type - frequently called?).
>
> Inside H5FD.c there is no longer any need for the code (below) because the term functions for each driver have been called during the H5I cleaning. File drivers can now be independent and linked in at run time.
>
> I welcome your thoughts.
Hmm, I'd rather not mangle the H5I_clear_type() routine that way. Can you modify the H5FD_free_cls() routine to call the new terminate callback that you've added? That would fit perfectly with the library's design.
Quincey
> JB
>
>
> =======
> /* Reset the VFL drivers, if they've been closed */
> if(H5I_nmembers(H5I_VFL)==0) {
> H5FD_sec2_term();
> #ifdef H5_HAVE_DIRECT
> H5FD_direct_term();
> #endif
> H5FD_log_term();
> H5FD_stdio_term();
> #ifdef H5_HAVE_WINDOWS
> H5FD_windows_term();
> #endif
> H5FD_family_term();
> H5FD_core_term();
> H5FD_multi_term();
> #ifdef H5_HAVE_PARALLEL
> H5FD_mpio_term();
> H5FD_mpiposix_term();
> #ifdef H5_HAVE_DSM
> H5FD_dsm_term();
> #endif
>
>
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> Hdf-forum at hdfgroup.org
> http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
More information about the Hdf-forum
mailing list