public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/33720]  New: A negative value in OpenMP clause num_threasds is not detected at runtime
@ 2007-10-09 20:49 geir at cray dot com
  2007-10-09 23:28 ` [Bug libgomp/33720] " bkoz at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: geir at cray dot com @ 2007-10-09 20:49 UTC (permalink / raw)
  To: gcc-bugs

The 'num_threads' clause in a OpenMP pragma is not being checked to see if it
is a positive integer.  An error should be return if it is not.

The OpenMP API Version 2.5 May 2005 on p. 28 lines 29-30 offers the following
restriction:

" * ... The num_threads expression must evaluate to a positive integer value."


$ cat bug2883.c
/* derived from ISU's RTED_OpenMP/C/Col3_Env_and_Claus_Errs/c_C_1_1_a.c test */
#include <omp.h>
#include <stdio.h>
#include <math.h>
int main() {
  double s, pi;
  int n_thread;
  int actual_num_threads;
  omp_set_num_threads(4);

  s = 0;
  pi = 4.0*atan(1.0);
  n_thread = (int) (sin(-0.25*pi)*10.0);

  printf("pi % 12.4f n_thread %d \n", pi, n_thread);
#pragma omp parallel default(none) shared(actual_num_threads)
num_threads(n_thread)
 {
#pragma omp single
   {
     actual_num_threads = omp_get_num_threads();
   }
 }

 printf("actual_num_threads = %d\n", actual_num_threads);
 return 0;
}

$ gcc -o x -fopenmp bug2883.c -lm
$ ./x 
pi       3.1416 n_thread -7

libgomp: Out of memory allocating 34359738400 bytes
$


-- 
           Summary: A negative value in OpenMP clause num_threasds is not
                    detected at runtime
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geir at cray dot com


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


^ permalink raw reply	[flat|nested] 10+ messages in thread
[parent not found: <bug-33720-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-12-29  7:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-09 20:49 [Bug c/33720] New: A negative value in OpenMP clause num_threasds is not detected at runtime geir at cray dot com
2007-10-09 23:28 ` [Bug libgomp/33720] " bkoz at gcc dot gnu dot org
2007-11-12 19:37 ` [Bug libgomp/33720] A negative value in OpenMP clause num_threads " jakub at gcc dot gnu dot org
2008-08-07  2:56 ` manu at gcc dot gnu dot org
2009-07-31 15:12 ` manu at gcc dot gnu dot org
2009-09-14 20:00 ` geir at cray dot com
     [not found] <bug-33720-4@http.gcc.gnu.org/bugzilla/>
2013-06-19 18:19 ` geir at cray dot com
2013-06-19 18:23 ` jakub at gcc dot gnu.org
2013-06-19 20:45 ` manu at gcc dot gnu.org
2021-12-29  7:54 ` pinskia at gcc dot gnu.org

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