[m-rev.] diff: Fix hlc.gc.par

Paul Bone pbone at csse.unimelb.edu.au
Mon May 31 19:45:05 AEST 2010


On Wed, May 26, 2010 at 05:38:48PM +1000, Paul Bone wrote:
> On Wed, May 26, 2010 at 02:14:22PM +1000, Paul Bone wrote:
> > 
> > For review by anyone.
> > 
> > I'll commit this once the bootchecks finish in a number of grades.
> 
> I've committed this.  I'll address any review comments post-commit.
> 

Fix hlc.gc.par.

The hlc.gc.par grade was broken after committing my fix for the stack segment
parallel grades.  The problem is that hlc grades use Mercury engines but don't
follow the same code paths as the low-level C grades.  This means that they
expect that the MR_all_engine_bases array isn't allocated by the time the
engine structures are being created.

This change set makes the MR_all_engine_bases array only available in low-level
C parallel grades making problems involving this array impossible in high level
C grades.

runtime/mercury_engine.h:
runtime/mercury_engine.c:
    Only make MR_all_engine_bases available in thread safe low-level C grades.

runtime/mercury_thread.h:
runtime/mercury_thread.c:
    Only make MR_init_engine_array_lock available in thread safe low-level C
    grades.

    Only try to populate MR_all_engine_bases in thread safe low-level C grades.

runtime/mercury_context.c:
    Only initialise MR_init_engine_array_lock in thread safe low-level C
    grades.

Index: runtime/mercury_context.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_context.c,v
retrieving revision 1.80
diff -u -p -b -r1.80 mercury_context.c
--- runtime/mercury_context.c	26 May 2010 07:45:48 -0000	1.80
+++ runtime/mercury_context.c	31 May 2010 05:16:01 -0000
@@ -186,7 +186,6 @@ MR_init_thread_stuff(void)
     pthread_cond_init(&MR_runqueue_cond, MR_COND_ATTR);
     pthread_mutex_init(&free_context_list_lock, MR_MUTEX_ATTR);
     pthread_mutex_init(&MR_global_lock, MR_MUTEX_ATTR);
-    pthread_mutex_init(&MR_init_engine_array_lock, MR_MUTEX_ATTR);
     pthread_mutex_init(&MR_pending_contexts_lock, MR_MUTEX_ATTR);
   #ifdef MR_LL_PARALLEL_CONJ
     pthread_mutex_init(&spark_deques_lock, MR_MUTEX_ATTR);
@@ -212,6 +211,8 @@ MR_init_thread_stuff(void)
     pthread_mutex_init(&MR_thread_barrier_lock, MR_MUTEX_ATTR);
   #ifdef MR_HIGHLEVEL_CODE
     pthread_cond_init(&MR_thread_barrier_cond, MR_COND_ATTR);
+  #else
+    pthread_mutex_init(&MR_init_engine_array_lock, MR_MUTEX_ATTR);
   #endif
 
     /* 
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.c,v
retrieving revision 1.61
diff -u -p -b -r1.61 mercury_engine.c
--- runtime/mercury_engine.c	26 May 2010 07:45:48 -0000	1.61
+++ runtime/mercury_engine.c	31 May 2010 05:11:32 -0000
@@ -80,10 +80,12 @@ MR_Debug_Flag_Info  MR_debug_flag_info[M
 };
 
 #ifdef MR_THREAD_SAFE 
+  #ifndef MR_HIGHLEVEL_CODE
 /*
 ** Writes to this array are protected by the init_engine_array_lock.
 */
 MercuryEngine **MR_all_engine_bases = NULL;
+  #endif
 #else
 MercuryEngine MR_engine_base;
 #endif
Index: runtime/mercury_engine.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_engine.h,v
retrieving revision 1.53
diff -u -p -b -r1.53 mercury_engine.h
--- runtime/mercury_engine.h	26 May 2010 07:45:48 -0000	1.53
+++ runtime/mercury_engine.h	31 May 2010 05:12:14 -0000
@@ -471,6 +471,7 @@ typedef struct MR_mercury_engine_struct 
   #define MR_cur_engine()   ((MercuryEngine *) MR_engine_base)
   #define MR_get_engine()   ((MercuryEngine *) MR_thread_engine_base)
 
+  #ifndef MR_HIGHLEVEL_CODE
   /*
   ** This points to an array containing MR_num_threads pointers to Mercury engines.
   ** The first item in the array is the primordial thread.  During
@@ -478,6 +479,7 @@ typedef struct MR_mercury_engine_struct 
   ** inside.
   */
   extern MercuryEngine      **MR_all_engine_bases;
+  #endif
 
 #else   /* !MR_THREAD_SAFE */
 
Index: runtime/mercury_thread.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.c,v
retrieving revision 1.41
diff -u -p -b -r1.41 mercury_thread.c
--- runtime/mercury_thread.c	26 May 2010 07:45:48 -0000	1.41
+++ runtime/mercury_thread.c	31 May 2010 05:10:57 -0000
@@ -28,7 +28,9 @@
     MercuryThreadKey MR_engine_base_key;
   #endif
   MercuryLock       MR_global_lock;
+  #ifndef MR_HIGHLEVEL_CODE
   MercuryLock       MR_init_engine_array_lock;
+  #endif
 #endif
 
 volatile MR_bool    MR_exit_now;
@@ -124,6 +126,7 @@ MR_init_thread(MR_when_to_use when_to_us
   #ifdef MR_ENGINE_BASE_REGISTER
     MR_engine_base_word = (MR_Word) eng;
   #endif
+  #ifndef MR_HIGHLEVEL_CODE
     MR_LOCK(&MR_init_engine_array_lock, "MR_init_thread");
     {
         int i;
@@ -135,6 +138,7 @@ MR_init_thread(MR_when_to_use when_to_us
         }
     }
     MR_UNLOCK(&MR_init_engine_array_lock, "MR_init_thread");
+  #endif
 #else
     MR_memcpy(&MR_engine_base, eng, sizeof(MercuryEngine));
     MR_restore_registers();
Index: runtime/mercury_thread.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_thread.h,v
retrieving revision 1.30
diff -u -p -b -r1.30 mercury_thread.h
--- runtime/mercury_thread.h	26 May 2010 07:45:48 -0000	1.30
+++ runtime/mercury_thread.h	31 May 2010 07:08:18 -0000
@@ -158,10 +158,12 @@ MR_cond_timed_wait(MercuryCond *cond, Me
   */
   extern MercuryLock        MR_global_lock;
   
+  #ifndef MR_HIGHLEVEL_CODE
   /*
   ** This lock protects writes to the MR_all_engine_bases structure.
   */
   extern MercuryLock        MR_init_engine_array_lock;
+  #endif
 
   /*
   ** MR_exception_handler_key stores a key which can be used to get
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20100531/0fbee692/attachment.sig>


More information about the reviews mailing list