# High Level & Thread Safe

**URL:** <https://forum.hdfgroup.org/t/high-level-thread-safe/902>\
**Category:** HDF5 Library\
**Created:** [March 10, 2018, 1:52am UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902 "2018-03-10T01:52:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![smitch12](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@smitch12](https://forum.hdfgroup.org/u/smitch12)\
**Post date:** [March 10, 2018, 1:52am UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/1 "2018-03-10T01:52:37Z")

</div>

I’m seeing what it would take to upgrade my HDF implementation and I’m running into issues.

When I run hdf5-1.10.1 through CMake it complains that HL and thread-safety options are not supported. When did this happen? I use both.

I found this discussion from July 2016 on a netcdf group saying that they are mutually exclusive.  
[https://www.unidata.ucar.edu/mailing\_lists/archives/netcdfgroup/2016/msg00223.html](https://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2016/msg00223.html)

Trying both alone in Cmake seems to work.

I use Packet Tables extensively and Dimension Scales (less so). And I do have multiple threads accessing multiple independent files (on Windows). Can I live without HDF’s thread safety? Or is there a work around?

Are the HL interfaces mostly an afterthought these days? They never were supported in the old HDF5DotNet wrappers and weren’t in the PInvoke implementation when I last looked.

Scott

---

<div class="post-metadata">

**Author:** ![derobins](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/derobins/32/1481_2.png) [@derobins](https://forum.hdfgroup.org/u/derobins)\
**Post date:** [March 10, 2018, 3:03am UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/2 "2018-03-10T03:03:28Z")

</div>

The reason the high-level library is not considered thread-safe is because the global library lock only exists in the C library and is not hoisted up into the HL library. The thread-safe + high-level library combination was not explicitly marked as unsafe and unsupported until a few years ago. You can override this setting in CMake by setting ~~ENABLE\_UNSUPPORTED~~ (edit: ALLOW\_UNSUPPORTED) to ON or configuring with --enable-unsupported in the autotools.

This may work for you or you may encounter problems; we simply haven’t had the internal resources to investigate this properly. Making thread-safety and the high-level library mutually exclusive came about when we were cleaning up the build systems and that combination (as well as the language wrappers) was flagged as problematic and not supported, not because we know for sure that there are problems.

We’ve talked about fixing this for some time, but unfortunately it’s never made it to the front of our queue. If anyone cares deeply about this and wants to fund the work, that could quickly change.

Also, for what it’s worth, regardless of your file access patterns, the HDF5 C library contains global state that can mutate in even read-only cases. You are far, far better off building with thread-safety and the high-level library (even though it’s technically unsupported) than attempting to use the non-thread-safe library from multiple threads. In the former, you at least have the bulk of the code protected by the global lock.

---

<div class="post-metadata">

**Author:** ![smitch12](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@smitch12](https://forum.hdfgroup.org/u/smitch12)\
**Post date:** [March 12, 2018, 3:42pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/3 "2018-03-12T15:42:53Z")

</div>

Thanks Dana,

But, is ENABLE\_UNSUPPORTED right? That doesn’t change a thing when I add it. I don’t see a reference to it in the files. I see a reference to ALLOW\_UNSUPPORTED, but it doesn’t help either.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [March 12, 2018, 5:15pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/4 "2018-03-12T17:15:46Z")

</div>

In 1.10.1 the CMake option is ALLOW\_UNSUPPORTED.

---

<div class="post-metadata">

**Author:** ![smitch12](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@smitch12](https://forum.hdfgroup.org/u/smitch12)\
**Post date:** [March 12, 2018, 5:32pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/5 "2018-03-12T17:32:42Z")

</div>

Like I said, that didn’t work for me. And it keeps getting deleted whenever I run the CMake Configure.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [March 12, 2018, 5:38pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/6 "2018-03-12T17:38:37Z")

</div>

Okay, can you provide your command line, maybe I might see something that I am not doing to repeat the issue.

Allen

---

<div class="post-metadata">

**Author:** ![smitch12](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@smitch12](https://forum.hdfgroup.org/u/smitch12)\
**Post date:** [March 12, 2018, 5:47pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/7 "2018-03-12T17:47:33Z")

</div>

I’m using the CMake GUI (3.11.0-0rc2) not the command line version. The following are on ( **Bold** is something I specifically set):

**BUILD\_SHARED\_LIBS** , BUILD\_TESTING, **ALLOW\_UNSUPPORTED** (added manually), **HDF5\_BUILD\_HL\_LIB** , HDF5\_BUILD\_TOOLS, HDF5\_ENABLE\_ALL\_WARNINGS, HDF5\_ENABLE\_DEPRECATED\_SYMBOLS, HDF5\_ENABLE\_EMBEDDED\_LIBINFO, HDF5\_ENABLE\_SIZET, & **HDF5\_ENABLE\_THREADSAFE**.

All the other booleans that autopopulate are off. All the rest are defaults.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [March 12, 2018, 6:03pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/8 "2018-03-12T18:03:53Z")

</div>

The GUI has an advanced option, that will display more options, ALLOW\_UNSUPPORTED is one of those.  
I would think that the manual entry is incorrectly setting the option.

Allen

---

<div class="post-metadata">

**Author:** ![derobins](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/derobins/32/1481_2.png) [@derobins](https://forum.hdfgroup.org/u/derobins)\
**Post date:** [March 12, 2018, 6:10pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/9 "2018-03-12T18:10:08Z")

</div>

Sorry for the typo, ALLOW\_UNSUPPORTED is correct. A quick test on our development trunk (very close to 1.10.1) with ccmake shows that ALLOW\_UNSUPPORTED, HDF5\_BUILD\_HL\_LIB, and HDF5\_ENABLE\_THREADSAFE work correctly.

Allen might have more insight into what is failing.

---

<div class="post-metadata">

**Author:** ![smitch12](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@smitch12](https://forum.hdfgroup.org/u/smitch12)\
**Post date:** [March 12, 2018, 8:39pm UTC](https://forum.hdfgroup.org/t/high-level-thread-safe/902/10 "2018-03-12T20:39:32Z")

</div>

That works, thank you.
