From: Tobias Burnus <tobias@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>,
Thomas Schwinge <thomas@codesourcery.com>,
Hafiz Abid Qadeer <abidh@codesourcery.com>
Cc: Jakub Jelinek <jakub@redhat.com>, <gcc-patches@gcc.gnu.org>,
<fortran@gcc.gnu.org>
Subject: Re: [PATCH] [gfortran] Add support for allocate clause (OpenMP 5.0).
Date: Mon, 24 Jan 2022 09:45:48 +0100 [thread overview]
Message-ID: <e536f2c4-fdfe-7e6c-56b5-191713404933@codesourcery.com> (raw)
In-Reply-To: <48d8c123-fa4f-d4a3-17de-b082de32f0bf@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 2676 bytes --]
On 21.01.22 18:43, Tobias Burnus wrote:
> On 21.01.22 18:15, Thomas Schwinge wrote:
>> 11 | integer(c_int) function is_64bit_aligned (a) bind(C)
>> Warning: Variable ‘a’ at (1) is a dummy argument of the BIND(C)
>> procedure ‘is_64bit_aligned’ but may not be C interoperable
>> [-Wc-binding-type]
>>
>> Is that something to worry about?
I have attached a patch (not commited), which silences the three kind of
warnings and fixes the interface issue.
TODO: commit it.
On 21.01.22 18:15, Thomas Schwinge wrote:
> I'm seeing this test case randomly/non-deterministically FAIL to execute,
> differently on different systems and runs, for example: [...]
> I'd assume there's some concurrency issue: the problem disappears if I
> manually specify a lowerish 'OMP_NUM_THREADS'
If one compiles the program with -fsanitize=thread, it shows tons of errors :-(
The first one is:
WARNING: ThreadSanitizer: data race (pid=3034413)
Read of size 8 at 0x7fff8b5a8340 by thread T1:
#0 __m_MOD_foo._omp_fn.2 ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:116 (a.out+0x402a88)
#1 gomp_thread_start ../../../repos/gcc-trunk-commit/libgomp/team.c:129 (libgomp.so.1+0x1e5ed)
Previous write of size 8 at 0x7fff8b5a8340 by main thread:
#0 __m_MOD_foo._omp_fn.1 ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:116 (a.out+0x4029c0)
#1 GOMP_teams_reg ../../../repos/gcc-trunk-commit/libgomp/teams.c:51 (libgomp.so.1+0x3638c)
#2 MAIN__ ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:328 (a.out+0x4024c0)
#3 main ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:312 (a.out+0x4025b0)
Location is stack of main thread.
Location is global '<null>' at 0x000000000000 ([stack]+0x1f340)
Thread T1 (tid=3034416, running) created by main thread at:
#0 pthread_create ../../../../repos/gcc-trunk-commit/libsanitizer/tsan/tsan_interceptors_posix.cpp:1001 (libtsan.so.2+0x62c76)
#1 gomp_team_start ../../../repos/gcc-trunk-commit/libgomp/team.c:858 (libgomp.so.1+0x1ec18)
#2 MAIN__ ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:328 (a.out+0x4024c0)
#3 main ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:312 (a.out+0x4025b0)
SUMMARY: ThreadSanitizer: data race ../../libgomp/testsuite/libgomp.fortran/allocate-1.f90:116 in __m_MOD_foo._omp_fn.2
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 6422 bytes --]
diff --git a/libgomp/testsuite/libgomp.fortran/allocate-1.c b/libgomp/testsuite/libgomp.fortran/allocate-1.c
index d33acc6feef..cb6d355afc6 100644
--- a/libgomp/testsuite/libgomp.fortran/allocate-1.c
+++ b/libgomp/testsuite/libgomp.fortran/allocate-1.c
@@ -1,7 +1,7 @@
#include <stdint.h>
int
-is_64bit_aligned_ (uintptr_t a)
+is_64bit_aligned (uintptr_t a)
{
return ( (a & 0x3f) == 0);
}
diff --git a/libgomp/testsuite/libgomp.fortran/allocate-1.f90 b/libgomp/testsuite/libgomp.fortran/allocate-1.f90
index 35d1750b878..f31bd533e7f 100644
--- a/libgomp/testsuite/libgomp.fortran/allocate-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/allocate-1.f90
@@ -5,30 +5,30 @@
module m
use omp_lib
use iso_c_binding
- implicit none
+ implicit none (type, external)
interface
integer(c_int) function is_64bit_aligned (a) bind(C)
import :: c_int
- integer :: a
+ type(*) :: a
end
end interface
-end module m
-subroutine foo (x, p, q, px, h, fl)
+contains
+
+subroutine foo (x, p, q, h, fl)
use omp_lib
use iso_c_binding
integer :: x
integer, dimension(4) :: p
integer, dimension(4) :: q
- integer :: px
integer (kind=omp_allocator_handle_kind) :: h
integer :: fl
integer :: y
integer :: r, i, i1, i2, i3, i4, i5
integer :: l, l3, l4, l5, l6
- integer :: n, n1, n2, n3, n4
+ integer :: n, n2, n3, n4
integer :: j2, j3, j4
integer, dimension(4) :: l2
integer, dimension(4) :: r2
@@ -118,6 +118,7 @@ subroutine foo (x, p, q, px, h, fl)
end if
!$omp end parallel
!$omp end teams
+stop
!$omp parallel do private (y) firstprivate (x) reduction(+: r) allocate (h: x, y, r, l, n) lastprivate (l) linear (n: 16)
do i = 0, 63
@@ -153,77 +154,77 @@ subroutine foo (x, p, q, px, h, fl)
((is_64bit_aligned(l2(1)) == 0) .or. &
(is_64bit_aligned(l3) == 0) .or. &
(is_64bit_aligned(i1) == 0))) then
- stop 10
+ stop 10
end if
end do
!$omp do collapse(2) lastprivate(l4, i2, j2) linear (n2:17) allocate (h: n2, l4, i2, j2)
do i2 = 3, 4
do j2 = 17, 22, 2
- n2 = n2 + 17
- l4 = i2 * 31 + j2
- if ( (and(fl, 1) /= 0) .and. &
- ((is_64bit_aligned(l4) == 0) .or. &
- (is_64bit_aligned(n2) == 0) .or. &
- (is_64bit_aligned(i2) == 0) .or. &
- (is_64bit_aligned(j2) == 0))) then
- stop 11
- end if
+ n2 = n2 + 17
+ l4 = i2 * 31 + j2
+ if ( (and(fl, 1) /= 0) .and. &
+ ((is_64bit_aligned(l4) == 0) .or. &
+ (is_64bit_aligned(n2) == 0) .or. &
+ (is_64bit_aligned(i2) == 0) .or. &
+ (is_64bit_aligned(j2) == 0))) then
+ stop 11
+ end if
end do
end do
!$omp do collapse(2) lastprivate(l5, i3, j3) linear (n3:17) schedule (static, 3) allocate (n3, l5, i3, j3)
do i3 = 3, 4
do j3 = 17, 22, 2
- n3 = n3 + 17
- l5 = i3 * 31 + j3
- if ( (and(fl, 2) /= 0) .and. &
- ((is_64bit_aligned(l5) == 0) .or. &
- (is_64bit_aligned(n3) == 0) .or. &
- (is_64bit_aligned(i3) == 0) .or. &
- (is_64bit_aligned(j3) == 0))) then
- stop 12
- end if
+ n3 = n3 + 17
+ l5 = i3 * 31 + j3
+ if ( (and(fl, 2) /= 0) .and. &
+ ((is_64bit_aligned(l5) == 0) .or. &
+ (is_64bit_aligned(n3) == 0) .or. &
+ (is_64bit_aligned(i3) == 0) .or. &
+ (is_64bit_aligned(j3) == 0))) then
+ stop 12
+ end if
end do
end do
!$omp do collapse(2) lastprivate(l6, i4, j4) linear (n4:17) schedule (dynamic) allocate (h: n4, l6, i4, j4)
do i4 = 3, 4
do j4 = 17, 22,2
- n4 = n4 + 17;
- l6 = i4 * 31 + j4;
- if ( (and(fl, 1) /= 0) .and. &
- ((is_64bit_aligned(l6) == 0) .or. &
- (is_64bit_aligned(n4) == 0) .or. &
- (is_64bit_aligned(i4) == 0) .or. &
- (is_64bit_aligned(j4) == 0))) then
- stop 13
- end if
+ n4 = n4 + 17;
+ l6 = i4 * 31 + j4;
+ if ( (and(fl, 1) /= 0) .and. &
+ ((is_64bit_aligned(l6) == 0) .or. &
+ (is_64bit_aligned(n4) == 0) .or. &
+ (is_64bit_aligned(i4) == 0) .or. &
+ (is_64bit_aligned(j4) == 0))) then
+ stop 13
+ end if
end do
end do
!$omp do lastprivate (i5) allocate (i5)
do i5 = 1, 17, 3
if ( (and(fl, 2) /= 0) .and. &
- (is_64bit_aligned(i5) == 0)) then
- stop 14
+ (is_64bit_aligned(i5) == 0)) then
+ stop 14
end if
end do
!$omp do reduction(+:p, q, r2) allocate(h: p, q, r2)
do i = 0, 31
- p(3) = p(3) + i;
- p(4) = p(4) + (2 * i)
- q(1) = q(1) + (3 * i)
- q(3) = q(3) + (4 * i)
- r2(1) = r2(1) + (5 * i)
- r2(4) = r2(4) + (6 * i)
- if ( (and(fl, 1) /= 0) .and. &
- ((is_64bit_aligned(q(1)) == 0) .or. &
- (is_64bit_aligned(p(1)) == 0) .or. &
- (is_64bit_aligned(r2(1)) == 0) )) then
- stop 15
- end if
+ p(3) = p(3) + i;
+ p(4) = p(4) + (2 * i)
+ q(1) = q(1) + (3 * i)
+ q(3) = q(3) + (4 * i)
+ r2(1) = r2(1) + (5 * i)
+ r2(4) = r2(4) + (6 * i)
+ if ( (and(fl, 1) /= 0) .and. &
+ ((is_64bit_aligned(q(1)) == 0) .or. &
+ (is_64bit_aligned(p(1)) == 0) .or. &
+ (is_64bit_aligned(r2(1)) == 0) )) then
+ stop 15
+ end if
end do
!$omp task private(y) firstprivate(x) allocate(x, y)
@@ -305,11 +306,13 @@ subroutine foo (x, p, q, px, h, fl)
.or. r2(1) /= (5 * p(3)) .or. r2(4) /= (6 * p(3))) then
stop 25
end if
-
end subroutine
+end module m
program main
use omp_lib
+ use m
+ implicit none (type, external)
integer, dimension(4) :: p
integer, dimension(4) :: q
@@ -323,11 +326,11 @@ program main
if (a == omp_null_allocator) stop 1
call omp_set_default_allocator (omp_default_mem_alloc);
- call foo (42, p, q, 2, a, 0);
- call foo (42, p, q, 2, omp_default_mem_alloc, 0);
- call foo (42, p, q, 2, a, 1);
+ call foo (42, p, q, a, 0);
+ call foo (42, p, q, omp_default_mem_alloc, 0);
+ call foo (42, p, q, a, 1);
call omp_set_default_allocator (a);
- call foo (42, p, q, 2, omp_null_allocator, 3);
- call foo (42, p, q, 2, omp_default_mem_alloc, 2);
+ call foo (42, p, q, omp_null_allocator, 3);
+ call foo (42, p, q, omp_default_mem_alloc, 2);
call omp_destroy_allocator (a);
end
next prev parent reply other threads:[~2022-01-24 8:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211022130502.2211568-1-abidh@codesourcery.com>
2021-10-22 13:28 ` Tobias Burnus
[not found] ` <20211102162714.GF304296@tucnak>
[not found] ` <e3c9083c-0906-699a-b437-84a49ece33b8@mentor.com>
[not found] ` <20211220200650.GN2646553@tucnak>
[not found] ` <fddcdfcf-3fab-1674-722e-2756a1d6aef8@mentor.com>
2022-01-14 9:10 ` Thomas Schwinge
2022-01-14 11:45 ` Tobias Burnus
2022-01-14 11:55 ` Jakub Jelinek
2022-01-14 12:20 ` Tobias Burnus
2022-01-17 14:01 ` Hafiz Abid Qadeer
2022-01-21 17:15 ` Thomas Schwinge
2022-01-21 17:43 ` Tobias Burnus
2022-01-24 8:45 ` Tobias Burnus [this message]
2022-01-24 12:54 ` Hafiz Abid Qadeer
2022-01-25 9:19 ` Thomas Schwinge
2022-01-25 10:32 ` Tobias Burnus
2022-01-31 19:13 ` Hafiz Abid Qadeer
2022-02-04 9:46 ` Thomas Schwinge
2022-02-04 11:25 ` Hafiz Abid Qadeer
2022-02-05 19:09 ` Hafiz Abid Qadeer
2022-02-16 10:29 ` Hafiz Abid Qadeer
2022-02-04 9:37 ` Thomas Schwinge
2022-02-04 13:57 ` [committed] libgomp.fortran/allocate-1.f90: Minor cleanup (was: Re: [PATCH] [gfortran] Add support for allocate clause (OpenMP 5.0).) Tobias Burnus
2022-02-04 15:33 ` Thomas Schwinge
2022-02-04 16:34 ` Tobias Burnus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e536f2c4-fdfe-7e6c-56b5-191713404933@codesourcery.com \
--to=tobias@codesourcery.com \
--cc=abidh@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=thomas@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).