Threadsafe Windows & 64-bit

I implemented the thread safe version of HDF5 for Windows to get past some issues writing to HDF5 files from different threads. I hoped I didn't need to bother since each thread had exclusive access to one file, but testing proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly be moving to a 64 bit platform. A quick search didn't turn up a 64 bit variant. Is there a way to implement this in 64 bit?

Scott

···

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

Some time ago I made an experimental port for HDF5 threads using native Windows API calls, thus being independent of pthreads.

It hasn't been thoroughly tested and involves some changes in the HDF source which might be out of sync with the latest version, but most changes had been in just one file. Also, I only implemented it for Windows 32 bit, but as it's native windows calls, it might just be the same for Windows 64.

If you're interested in looking at it, could dig it out.

  Werner

···

On Fri, 19 Mar 2010 11:51:13 -0500, Mitchell, Scott - IS <Scott.Mitchell@itt.com> wrote:

I implemented the thread safe version of HDF5 for Windows to get past some issues writing to HDF5 files from different threads. I hoped I didn't need to bother since each thread had exclusive access to one file, but testing proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly be moving to a 64 bit platform. A quick search didn't turn up a 64 bit variant. Is there a way to implement this in 64 bit?

Scott

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Laboratory for Creative Arts and Technology (LCAT)
Center for Computation & Technology at Louisiana State University (CCT/LSU)
211 Johnston Hall, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

Is there any work scheduled to allow parallel access to HDF5 files from a
single process? The current implementation implements thread-safety by
restricting access to one thread at a time, which is certainly safe, but
restricts scalability of processes, like web or database servers, which may
be serving many users at once. I understand it would likely be some fairly
involved work to deal with cache coherence issues!

···

On Fri, Mar 19, 2010 at 12:31 PM, Werner Benger <werner@cct.lsu.edu> wrote:

Some time ago I made an experimental port for HDF5 threads using native
Windows API calls, thus being independent of pthreads.

It hasn't been thoroughly tested and involves some changes in the HDF
source which might be out of sync with the latest version, but most changes
had been in just one file. Also, I only implemented it for Windows 32 bit,
but as it's native windows calls, it might just be the same for Windows 64.

If you're interested in looking at it, could dig it out.

       Werner

On Fri, 19 Mar 2010 11:51:13 -0500, Mitchell, Scott - IS < > Scott.Mitchell@itt.com> wrote:

I implemented the thread safe version of HDF5 for Windows to get past some

issues writing to HDF5 files from different threads. I hoped I didn't need
to bother since each thread had exclusive access to one file, but testing
proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly
be moving to a 64 bit platform. A quick search didn't turn up a 64 bit
variant. Is there a way to implement this in 64 bit?

Scott

________________________________
This e-mail and any files transmitted with it may be proprietary and are
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this e-mail in error please notify the
sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of ITT
Corporation. The recipient should check this e-mail and any attachments for
the presence of viruses. ITT accepts no liability for any damage caused by
any virus transmitted by this e-mail.

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Laboratory for Creative Arts and Technology (LCAT)
Center for Computation & Technology at Louisiana State University (CCT/LSU)
211 Johnston Hall, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Scott,

I compiled pthreads for 64bit almost out of the box. It works fine so far
with HDF5. Note that I linked statically in order not to mess with any other
library. To make it work, you need to patch pthreads (see below). I also
added the following lines in H5TS.c in H5TS_first_thread_init, but that's
only for static linking

#ifdef _WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#endif

HTH

-- dimitris

Index: implement.h

···

===================================================================
--- implement.h (revision 19389)
+++ implement.h (revision 19390)
@@ -667,8 +667,12 @@
  * See ptw32_InterlockedCompareExchange.c
  */
#ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE
+#ifdef _WIN64
+#define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
+#else
#define PTW32_INTERLOCKED_COMPARE_EXCHANGE
ptw32_interlocked_compare_exchange
#endif
+#endif

#ifndef PTW32_INTERLOCKED_EXCHANGE
#define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange

Index: ptw32_InterlockedCompareExchange.c

--- ptw32_InterlockedCompareExchange.c (revision 19389)
+++ ptw32_InterlockedCompareExchange.c (revision 19390)
@@ -34,6 +34,7 @@
  * if not, write to the Free Software Foundation, Inc.,
  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
+#ifndef _WIN64

#include "pthread.h"
#include "implement.h"
@@ -301,3 +302,5 @@
#endif

#endif
+
+#endif

Index: pthread_win32_attach_detach_np.c

--- pthread_win32_attach_detach_np.c (revision 19389)
+++ pthread_win32_attach_detach_np.c (revision 19390)
@@ -91,6 +91,14 @@

#endif

+#ifdef _WIN64
+/*
+ * InterlockedCompareExchange routine in WIN64 is an intrinsic function.
+ * See PTW32_INTERLOCKED_COMPARE_EXCHANGE implement.h
+ */
+
+#else
+
#ifdef WINCE

   /*
@@ -143,6 +151,7 @@
     {
       ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE;
     }
+#endif

   /*

    * Load QUSEREX.DLL and try to get address of QueueUserAPCEx

2010/3/19 Mitchell, Scott - IS <Scott.Mitchell@itt.com>

I implemented the thread safe version of HDF5 for Windows to get past
some issues writing to HDF5 files from different threads. I hoped I didn’t
need to bother since each thread had exclusive access to one file, but
testing proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly be
moving to a 64 bit platform. A quick search didn’t turn up a 64 bit variant.
Is there a way to implement this in 64 bit?

Scott

------------------------------
This e-mail and any files transmitted with it may be proprietary and are
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this e-mail in error please notify the
sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of ITT
Corporation. The recipient should check this e-mail and any attachments for
the presence of viruses. ITT accepts no liability for any damage caused by
any virus transmitted by this e-mail.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Hi Sebastian,

Is there any work scheduled to allow parallel access to HDF5 files from a single process? The current implementation implements thread-safety by restricting access to one thread at a time, which is certainly safe, but restricts scalability of processes, like web or database servers, which may be serving many users at once. I understand it would likely be some fairly involved work to deal with cache coherence issues!

  Yes, we are progressing down this path, although not terribly quickly. At this point, we've contributed to the development of an open "portable atomics" library (http://trac.mcs.anl.gov/projects/openpa) with the developers at Argonne National Laboratory. We're a little side-tracked on other projects right now, but I expect that we'll get back to working on this and improve the concurrency of the HDF5 library. No timeline right now though... :-/

  Quincey

···

On Mar 19, 2010, at 12:53 PM, Sebastian Good wrote:

On Fri, Mar 19, 2010 at 12:31 PM, Werner Benger <werner@cct.lsu.edu> wrote:
Some time ago I made an experimental port for HDF5 threads using native Windows API calls, thus being independent of pthreads.

It hasn't been thoroughly tested and involves some changes in the HDF source which might be out of sync with the latest version, but most changes had been in just one file. Also, I only implemented it for Windows 32 bit, but as it's native windows calls, it might just be the same for Windows 64.

If you're interested in looking at it, could dig it out.

       Werner

On Fri, 19 Mar 2010 11:51:13 -0500, Mitchell, Scott - IS <Scott.Mitchell@itt.com> wrote:

I implemented the thread safe version of HDF5 for Windows to get past some issues writing to HDF5 files from different threads. I hoped I didn't need to bother since each thread had exclusive access to one file, but testing proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly be moving to a 64 bit platform. A quick search didn't turn up a 64 bit variant. Is there a way to implement this in 64 bit?

Scott

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Laboratory for Creative Arts and Technology (LCAT)
Center for Computation & Technology at Louisiana State University (CCT/LSU)
211 Johnston Hall, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

Another point: AFAIK HDF5 does not launch any threads. It only uses some
synchronization methods of pthreads. These could very easily be implemented
and skip the need for yet another library.

Best

-- dimitris

···

2010/3/19 Dimitris Servis <servisster@gmail.com>

Scott,

I compiled pthreads for 64bit almost out of the box. It works fine so far
with HDF5. Note that I linked statically in order not to mess with any other
library. To make it work, you need to patch pthreads (see below). I also
added the following lines in H5TS.c in H5TS_first_thread_init, but that's
only for static linking

#ifdef _WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#endif

HTH

-- dimitris

Index: implement.h

--- implement.h (revision 19389)
+++ implement.h (revision 19390)
@@ -667,8 +667,12 @@
  * See ptw32_InterlockedCompareExchange.c
  */
#ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE
+#ifdef _WIN64

+#define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange
+#else
#define PTW32_INTERLOCKED_COMPARE_EXCHANGE
ptw32_interlocked_compare_exchange
#endif
+#endif

#ifndef PTW32_INTERLOCKED_EXCHANGE

#define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange

Index: ptw32_InterlockedCompareExchange.c

--- ptw32_InterlockedCompareExchange.c (revision 19389)

+++ ptw32_InterlockedCompareExchange.c (revision 19390)
@@ -34,6 +34,7 @@
  * if not, write to the Free Software Foundation, Inc.,
  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */

+#ifndef _WIN64

#include "pthread.h"
#include "implement.h"
@@ -301,3 +302,5 @@
#endif

#endif
+
+#endif

Index: pthread_win32_attach_detach_np.c

--- pthread_win32_attach_detach_np.c (revision 19389)
+++ pthread_win32_attach_detach_np.c (revision 19390)
@@ -91,6 +91,14 @@

#endif

+#ifdef _WIN64
+/*
+ * InterlockedCompareExchange routine in WIN64 is an intrinsic function.

+ * See PTW32_INTERLOCKED_COMPARE_EXCHANGE implement.h
+ */
+
+#else
+
#ifdef WINCE

   /*
@@ -143,6 +151,7 @@
     {
       ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE;

     }
+#endif

   /*

    * Load QUSEREX.DLL and try to get address of QueueUserAPCEx

2010/3/19 Mitchell, Scott - IS <Scott.Mitchell@itt.com>

I implemented the thread safe version of HDF5 for Windows to get past
some issues writing to HDF5 files from different threads. I hoped I didn’t
need to bother since each thread had exclusive access to one file, but
testing proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly
be moving to a 64 bit platform. A quick search didn’t turn up a 64 bit
variant. Is there a way to implement this in 64 bit?

Scott

------------------------------
This e-mail and any files transmitted with it may be proprietary and are
intended solely for the use of the individual or entity to whom they are
addressed. If you have received this e-mail in error please notify the
sender.
Please note that any views or opinions presented in this e-mail are solely
those of the author and do not necessarily represent those of ITT
Corporation. The recipient should check this e-mail and any attachments for
the presence of viruses. ITT accepts no liability for any damage caused by
any virus transmitted by this e-mail.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

I'm finally getting to the 64bit installation and having some trouble.

It appears that Microsoft's support for odbc ended with Vista/Windows Server 2008. What libraries are folks attaching to?

Also building a 64-bit pthread has been a problem. I downloaded the latest, and Visual Studio (9) can't seem to make heads or tails of the project. Making one from scratch has its own problems. I found a post saying a pthreads 2.9 was due real soon now with 64 bit support... but that was 3 years ago.

How have folks tackled these problems?

Thanks,
Scott

···

From: hdf-forum-bounces@hdfgroup.org [mailto:hdf-forum-bounces@hdfgroup.org] On Behalf Of Dimitris Servis
Sent: Friday, March 19, 2010 1:14 PM
To: HDF Users Discussion List
Subject: Re: [Hdf-forum] Threadsafe Windows & 64-bit

Another point: AFAIK HDF5 does not launch any threads. It only uses some synchronization methods of pthreads. These could very easily be implemented and skip the need for yet another library.

Best

-- dimitris
2010/3/19 Dimitris Servis <servisster@gmail.com<mailto:servisster@gmail.com>>
Scott,

I compiled pthreads for 64bit almost out of the box. It works fine so far with HDF5. Note that I linked statically in order not to mess with any other library. To make it work, you need to patch pthreads (see below). I also added the following lines in H5TS.c in H5TS_first_thread_init, but that's only for static linking

#ifdef _WIN32
#ifdef PTW32_STATIC_LIB
pthread_win32_process_attach_np();
#endif
#endif

HTH

-- dimitris

Index: implement.h

===================================================================

--- implement.h (revision 19389)

+++ implement.h (revision 19390)

@@ -667,8 +667,12 @@

  * See ptw32_InterlockedCompareExchange.c

  */

#ifndef PTW32_INTERLOCKED_COMPARE_EXCHANGE

+#ifdef _WIN64

+#define PTW32_INTERLOCKED_COMPARE_EXCHANGE _InterlockedCompareExchange

+#else

#define PTW32_INTERLOCKED_COMPARE_EXCHANGE

ptw32_interlocked_compare_exchange

#endif

+#endif

#ifndef PTW32_INTERLOCKED_EXCHANGE

#define PTW32_INTERLOCKED_EXCHANGE InterlockedExchange

Index: ptw32_InterlockedCompareExchange.c

===================================================================

--- ptw32_InterlockedCompareExchange.c (revision 19389)

+++ ptw32_InterlockedCompareExchange.c (revision 19390)

@@ -34,6 +34,7 @@

  * if not, write to the Free Software Foundation, Inc.,

  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

  */

+#ifndef _WIN64

#include "pthread.h"

#include "implement.h"

@@ -301,3 +302,5 @@

#endif

#endif

+

+#endif

Index: pthread_win32_attach_detach_np.c

===================================================================

--- pthread_win32_attach_detach_np.c (revision 19389)

+++ pthread_win32_attach_detach_np.c (revision 19390)

@@ -91,6 +91,14 @@

#endif

+#ifdef _WIN64

+/*

+ * InterlockedCompareExchange routine in WIN64 is an intrinsic function.

+ * See PTW32_INTERLOCKED_COMPARE_EXCHANGE implement.h

+ */

+

+#else

+

#ifdef WINCE

   /*

@@ -143,6 +151,7 @@

     {

       ptw32_features |= PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE;

     }

+#endif

   /*

    * Load QUSEREX.DLL and try to get address of QueueUserAPCEx

2010/3/19 Mitchell, Scott - IS <Scott.Mitchell@itt.com<mailto:Scott.Mitchell@itt.com>>
I implemented the thread safe version of HDF5 for Windows to get past some issues writing to HDF5 files from different threads. I hoped I didn't need to bother since each thread had exclusive access to one file, but testing proved otherwise.

So the thread-safe option uses PThreads (32 bit). This code will shortly be moving to a 64 bit platform. A quick search didn't turn up a 64 bit variant. Is there a way to implement this in 64 bit?

Scott

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT Corporation. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail.

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@hdfgroup.org<mailto:Hdf-forum@hdfgroup.org>
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org