From bc60cf7aaa7c82752819cbd5021f865b4ee052f5 Mon Sep 17 00:00:00 2001 From: Simon Shanks <59612559+sshanks-kx@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:03:50 +0100 Subject: [PATCH] Add threaded details & .hdf5.isThreadsafe (#42) --- README.md | 6 ++++++ q/hdf5.q | 4 +++- src/hdf5_general.c | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c03f9b2..c8571f7 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,12 @@ This interface is in active developement and as such there are a number of use-c If your use case requires the above functionality to be available, please open an issue [here](https://github.com/KxSystems/hdf5/issues). If you are capable, please consider contributing to the project. +## Threaded/Concurrent Access + +Please view this [HDF5 FAQ article](https://portal.hdfgroup.org/display/knowledge/Questions+about+thread-safety+and+concurrent+access#Questionsaboutthread-safetyandconcurrentaccess-thread-safety) that explains when you can use threads (e.g. peach) or concurrently process files from multiple instances. + +By default, our releases are not built with multi-thread support. Please download the source from our release page in order to build against your HDF5 library with threading enabled if you wish to avail of that functionality. It is recommended to use the standard non-thread safe version of hdf5 when not wishing to use multiple threads. + ## Documentation Documentation outlining the functionality available for this interface can be found [here](https://code.kx.com/q/interfaces/hdf5). diff --git a/q/hdf5.q b/q/hdf5.q index 52cac06..035048f 100644 --- a/q/hdf5.q +++ b/q/hdf5.q @@ -23,6 +23,8 @@ funcs:( // .hdf5.writeAttrDataset[fname:C; dname:C; aname:C; dset:*; kdims:J; ktype:c]:_ (`hdf5version;1); // .hdf5.version[]:S!J + (`hdf5isThreadsafe;1); + // .hdf5.isThreadsafe[]:b (`hdf5errorOn;1); // .hdf5.errorOn[]:_ (`hdf5errorOff;1); @@ -123,4 +125,4 @@ readDictTab:{[fname;dname;typ] // initialize init[]; -\d . \ No newline at end of file +\d . diff --git a/src/hdf5_general.c b/src/hdf5_general.c index 4c2e4c8..89648b6 100644 --- a/src/hdf5_general.c +++ b/src/hdf5_general.c @@ -19,6 +19,12 @@ EXP K hdf5errorOff(K UNUSED(dummy)){ return KNL; } +EXP K hdf5isThreadsafe(K UNUSED(dummy)){ + hbool_t is; + H5is_library_threadsafe(&is); + return kb(is); +} + EXP K hdf5version(K UNUSED(dummy)){ unsigned int maj, min, rel; if(H5get_libversion(&maj, &min, &rel) < 0)