public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/45784] New: gcc OpenMP - error: invalid controlling predicate
@ 2010-09-24 19:52 geir at cray dot com
  2013-06-19 18:13 ` [Bug c/45784] " geir at cray dot com
  0 siblings, 1 reply; 2+ messages in thread
From: geir at cray dot com @ 2010-09-24 19:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45784

           Summary: gcc OpenMP - error: invalid controlling predicate
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: geir@cray.com


The test is verifying that the parallel for loop construct may use
a variable of a pointer type in C.  

The OpenMP API Version 3.0 (May 2008) describes this usage on page
39 of the document.

Currently the GNU gcc compiler produces the following messages for
this test case:

ISU3417.c: In function 'vla_test':
ISU3417.c:23:25: error: invalid controlling predicate

The PGI, Intel, and Cray compilers compile this test case successfully.

$ cat ISU3417.c
//  derived from OpenMP test omp3c/c03_2_5_1_2c.c
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
#define NT 4
#define INCREMENT 2
#define ARRAY_SIZE INCREMENT*NT

// VLAs are standard only in C99; might as well use a C99-specific data type
// (long long int) while we're testing C99-specific features
void vla_test(int num_threads) {
    long long int *ptr, vla[INCREMENT*num_threads];
    //long long int *ptr, vla[INCREMENT*40];
    int i;

    // variable-length array initialized to -1
    for (i = 0; i < sizeof(vla)/sizeof(vla[0]); i++) {
        vla[i] = -1;
    }

    #pragma omp parallel shared(vla)
    {
        #pragma omp for schedule(static, 1)
        for (ptr = vla; ptr < vla + sizeof(vla)/sizeof(vla[0]); 
             ptr = ptr + INCREMENT)
             *ptr = omp_get_thread_num();
    }

    for (i = 0; i < sizeof(vla)/sizeof(vla[0]); i++) {
        if (vla[i] != (i % INCREMENT == 0 ? (i/INCREMENT) % num_threads : -1))
{
            fprintf(stderr, "%s:%i: FAIL - vla[%i] == %lli != %i\n", 
                    __FILE__, __LINE__, i, vla[i], 
                   (i % INCREMENT == 0 ? (i/INCREMENT) % num_threads : -1));
            exit(1);
        }
    }
}

int main(void) {
    omp_set_dynamic(0);
    omp_set_num_threads(NT);

    vla_test(NT);

    return 0;
}
$ gcc -c -fopenmp -std=c99 ISU3417.c
ISU3417.c: In function 'vla_test':
ISU3417.c:24:25: error: invalid controlling predicate
$

Other compilers working:

$ pgcc -mp -c ISU3417.c
$ icc -c -openmp ISU3417.c
$ cc -c -omp -V ISU3417.c
/opt/cray/xt-asyncpe/4.4.9/bin/cc: INFO: Compiling for compute nodes running
CLE.
Cray C : Version 7.2.7 (u7267c72242i72182p72540a72002e60006z72540)
Cray C :               (x7205r72009w71001t7207)
Cray C : Fri Sep 24, 2010  14:34:26
$

-- 
Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/45784] gcc OpenMP - error: invalid controlling predicate
  2010-09-24 19:52 [Bug c/45784] New: gcc OpenMP - error: invalid controlling predicate geir at cray dot com
@ 2013-06-19 18:13 ` geir at cray dot com
  0 siblings, 0 replies; 2+ messages in thread
From: geir at cray dot com @ 2013-06-19 18:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45784

--- Comment #2 from Geir Johansen <geir at cray dot com> ---
Fails in GCC 4.8.0:

$ gcc --version
gcc (GCC) 4.8.0 20130322 (Cray Inc.)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -c -fopenmp -std=c99 ISU3417.c
ISU3417.c: In function 'vla_test':
ISU3417.c:24:25: error: invalid controlling predicate
         for (ptr = vla; ptr < vla + sizeof(vla)/sizeof(vla[0]);
                         ^
$


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-19 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-24 19:52 [Bug c/45784] New: gcc OpenMP - error: invalid controlling predicate geir at cray dot com
2013-06-19 18:13 ` [Bug c/45784] " geir at cray dot com

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).