From: Thomas Koenig Date: Sun, 2 Sep 2018 15:08:47 +0000 (+0000) Subject: multi.c (_gfortran_caf_sync_images): Handle SYNC IMAGGES (*) correctly. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72a7867c5cb436a3996d577ff5f90a82b13ccb35;p=thirdparty%2Fgcc.git multi.c (_gfortran_caf_sync_images): Handle SYNC IMAGGES (*) correctly. 2018-09-02 Thomas Koenig * caf/multi.c (_gfortran_caf_sync_images): Handle SYNC IMAGGES (*) correctly. From-SVN: r264041 --- diff --git a/libgfortran/ChangeLog.dev b/libgfortran/ChangeLog.dev index 225637277c71..d466bec4ccbd 100644 --- a/libgfortran/ChangeLog.dev +++ b/libgfortran/ChangeLog.dev @@ -1,3 +1,8 @@ +2018-09-02 Thomas Koenig + + * caf/multi.c (_gfortran_caf_sync_images): Handle + SYNC IMAGGES (*) correctly. + 2018-09-02 Thomas Koenig Nicolas Koenig diff --git a/libgfortran/caf/multi.c b/libgfortran/caf/multi.c index d980436e772d..d02e49db4d18 100644 --- a/libgfortran/caf/multi.c +++ b/libgfortran/caf/multi.c @@ -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;