From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6520 invoked by alias); 3 May 2014 22:04:56 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 6499 invoked by uid 48); 3 May 2014 22:04:53 -0000 From: "guido at vanguardiasur dot com.ar" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/61050] New: OpenMP: wrong behavior of 'omp for' on corner cases Date: Sat, 03 May 2014 22:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: guido at vanguardiasur dot com.ar X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg00153.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61050 Bug ID: 61050 Summary: OpenMP: wrong behavior of 'omp for' on corner cases Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: guido at vanguardiasur dot com.ar Created attachment 32728 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32728&action=edit example input Note: by infinite loop, we mean something of the form 'for (i=0; i>=0; i++)', not considering overflow. #pragma omp for changes the behavior of empty/infinite loops. Some empty loops are entered once per thread, and some infinite loops are either not entered at all or entered once. An example is attached and more are found in [1]. In the attached example, this loop: char i; #pragma omp for for (i=100; i<90; i--) printf("Hello %i %i\n", i, omp_get_thread_num()); is entered exactly once, with i = 100, when it should never be entered. There are no parallel directives. We believe this is caused by a miscalculation of the number of iterations, or a wrong empty loop check (or both). The calculated number of iterations (extracted from the assembly) for the previous example is 12, when it should probably be zero. Also, some loops give a negative loop count but are still entered (once). This happens on gcc 4.9.0, 4.8.2 and some older versions too. We've reproduced it easily. We checked the OpenMP specification and it does not mention an exception in these cases. Also note, this behavior does not seem to occur in fortran. gcc -v -save-temps output at http://sprunge.us/TfaC. [1] http://sprunge.us/TbWj http://sprunge.us/NCeA http://sprunge.us/PAZD http://sprunge.us/faTD http://sprunge.us/CIMN