libSDDS and threads

Moderators: cyao, michael_borland

Post Reply
jan
Posts: 13
Joined: 02 Oct 2013, 07:20
Location: ELSA, Bonn, Germany

libSDDS and threads

Post by jan » 17 Nov 2015, 07:39

Hi,
I am using libSDDS from the SDDSToolKit-devel RPM to read sdds files in c++ applications. It works very good - thanks again for the package.
Now I tried to use it in a multi threading application and get various SDDS errors when reading the same file with multiple threads at the same time.
Is there a way to do this thread-safe? I naively assumed reading a file parallelized is no problem.
Do you know which function(s) cause the problem? I basically create a new SDDS_TABLE in each thread and use functions like
  • SDDS_InitializeInput()
  • SDDS_ReadPage()
  • SDDS_FilterRowsOfInterest()
  • SDDS_GetValue()
  • SDDS_GetParameterIndex()
  • SDDS_GetParameterType()
  • SDDS_GetParameterByIndex()
  • SDDS_Terminate()

soliday
Posts: 408
Joined: 28 May 2008, 09:15

Re: libSDDS and threads

Post by soliday » 17 Nov 2015, 10:14

I never tried that. Let me look into it and see what I can do.

michael_borland
Posts: 2006
Joined: 19 May 2008, 09:33
Location: Argonne National Laboratory
Contact:

Re: libSDDS and threads

Post by michael_borland » 17 Nov 2015, 10:41

By the way, we usually use MPI for parallelization. There's an MPI version of the library (libSDDSmpi).

--Michael

soliday
Posts: 408
Joined: 28 May 2008, 09:15

Re: libSDDS and threads

Post by soliday » 24 Nov 2015, 13:32

I put together a new SDDSToolKit-devel that should solve the threading problems.
http://www.aps.anl.gov/asd/oag/download ... x86_64.rpm

Most of the important functions should now be thread safe. There are still issues with some functions which you probably aren't using:
SDDS_MakePointerArrayRecursively
SDDS_SetNameValidityFlags
SDDS_SetDefaultIOBufferSize
SDDS_InitializeAppendToPage
SDDS_SetRowLimit
SDDS_SetTerminateMode
SDDS_ComputeColumn
SDDS_FilterRowsWithRpnTest
SDDS_RegisterProgramName
SDDS_MatchColumns
SDDS_MatchParameters
SDDS_MatchArrays

There are also an issue related to setting the error values and printing them out. One thread may print another thread's error message which isn't a huge deal since there is an error anyway that needs to be fixed.

jan
Posts: 13
Joined: 02 Oct 2013, 07:20
Location: ELSA, Bonn, Germany

Re: libSDDS and threads

Post by jan » 26 Nov 2015, 05:08

Thank you very much for looking into this.
The new version works much better, no SDDS errors!

But sometimes (about 1 of 4 runs) the program terminates unexpectedly with "realloc(): invalid next size". I have not identified the causing function, but it could be related to the issue with error values you mentioned: I use the error returned by SDDS_InitializeInput to handle a non existing file at runtime. Maybe I can try another method for this next week.

jan
Posts: 13
Joined: 02 Oct 2013, 07:20
Location: ELSA, Bonn, Germany

Re: libSDDS and threads

Post by jan » 09 Feb 2016, 09:56

Here is a very late feedback:
All functions listed in the first post work with threads without problems. I fixed the remaining issue described in the previous post by avoiding SDDS_InitializeInput errors (I check for file existence beforehand).

Thank you very much!

Post Reply