]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
multi.c (_gfortran_caf_sync_images): Handle SYNC IMAGGES (*) correctly.
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 2 Sep 2018 15:08:47 +0000 (15:08 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 2 Sep 2018 15:08:47 +0000 (15:08 +0000)
2018-09-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

* caf/multi.c (_gfortran_caf_sync_images): Handle
SYNC IMAGGES (*) correctly.

From-SVN: r264041

libgfortran/ChangeLog.dev
libgfortran/caf/multi.c

index 225637277c71d03740446477895498b07c1bd59e..d466bec4ccbd8c12adc7cc323c063cc6c1a93f0a 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       * caf/multi.c (_gfortran_caf_sync_images): Handle
+       SYNC IMAGGES (*) correctly.
+
 2018-09-02  Thomas Koenig  <tkoenig@gcc.gnu.org>
            Nicolas Koenig <koenigni@gcc.gnu.org>
 
index d980436e772d930269389fe7f0b0f1ab8db16988..d02e49db4d1831bde694be4b391907598b216de3 100644 (file)
@@ -226,21 +226,24 @@ cond_signal (cond_t *cond)
 #define A(i,j) (sim[(i) + caf_num_images * (j)])
 
 void
-_gfortran_caf_sync_images (int count __attribute__ ((unused)),
-                          int images[] __attribute__ ((unused)),
-                          int *stat,
+_gfortran_caf_sync_images (int count, int *images,
+                          int *stat __attribute__ ((unused)),
                           char *errmsg __attribute__ ((unused)),
                           size_t errmsg_len __attribute__ ((unused)))
 {
   pthread_mutex_t *my_mutex;
 
+  if (count < 0)
+    count = caf_num_images;
+
   for (int i=0; i < count; i++)
     {
-      if (images[i] - 1 != _gfortrani_caf_this_image)
+      int other_img = images == NULL ? i : images[i] - 1;
+      if (other_img != _gfortrani_caf_this_image)
        {
-         cond_t *other_thread = cim + images[i] - 1;
+         cond_t *other_thread = cim + other_img;
          pthread_mutex_lock (&other_thread->mutex);
-         A(_gfortrani_caf_this_image, images[i] - 1) ++;
+         A(_gfortrani_caf_this_image, other_img) ++;
          cond_signal(other_thread);
        }
     }
@@ -255,10 +258,11 @@ _gfortran_caf_sync_images (int count __attribute__ ((unused)),
 
       for (int i = 0; i < count; i++)
        {
-         if (images[i] - 1 != _gfortrani_caf_this_image)
+         int other_img = images == NULL ? i : images[i] - 1;
+         if (other_img != _gfortrani_caf_this_image)
            {
-             x = A(images[i] - 1,_gfortrani_caf_this_image)
-               < A(_gfortrani_caf_this_image, images[i] - 1);
+             x = A(other_img, _gfortrani_caf_this_image)
+               < A(_gfortrani_caf_this_image, other_img);
              if (x)
                {
                  do_wait = 1;