re PR libgomp/42942 (OpenMP omp_set_max_active_levels(0) isn't resetting value)
PR libgomp/42942 * env.c (parse_unsigned_long): Add ALLOW_ZERO argument. (initialize_env): Adjust callers. (omp_set_max_active_levels): Set gomp_max_active_levels_var even when the argument is 0. * testsuite/libgomp.c/pr42942.c: New test. From-SVN: r157635
This commit is contained in:
parent
57fd5f9525
commit
80f046cced
@ -1,3 +1,13 @@
|
||||
2010-03-22 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR libgomp/42942
|
||||
* env.c (parse_unsigned_long): Add ALLOW_ZERO argument.
|
||||
(initialize_env): Adjust callers.
|
||||
(omp_set_max_active_levels): Set gomp_max_active_levels_var even
|
||||
when the argument is 0.
|
||||
|
||||
* testsuite/libgomp.c/pr42942.c: New test.
|
||||
|
||||
2010-03-08 Tobias Grosser <grosser@fim.uni-passau.de>
|
||||
|
||||
PR middle-end/42644
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
|
||||
Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU OpenMP Library (libgomp).
|
||||
@ -145,7 +146,7 @@ parse_schedule (void)
|
||||
present and it was successfully parsed. */
|
||||
|
||||
static bool
|
||||
parse_unsigned_long (const char *name, unsigned long *pvalue)
|
||||
parse_unsigned_long (const char *name, unsigned long *pvalue, bool allow_zero)
|
||||
{
|
||||
char *env, *end;
|
||||
unsigned long value;
|
||||
@ -161,7 +162,7 @@ parse_unsigned_long (const char *name, unsigned long *pvalue)
|
||||
|
||||
errno = 0;
|
||||
value = strtoul (env, &end, 10);
|
||||
if (errno || (long) value <= 0)
|
||||
if (errno || (long) value <= 0 - allow_zero)
|
||||
goto invalid;
|
||||
|
||||
while (isspace ((unsigned char) *end))
|
||||
@ -481,8 +482,9 @@ initialize_env (void)
|
||||
parse_schedule ();
|
||||
parse_boolean ("OMP_DYNAMIC", &gomp_global_icv.dyn_var);
|
||||
parse_boolean ("OMP_NESTED", &gomp_global_icv.nest_var);
|
||||
parse_unsigned_long ("OMP_MAX_ACTIVE_LEVELS", &gomp_max_active_levels_var);
|
||||
parse_unsigned_long ("OMP_THREAD_LIMIT", &gomp_thread_limit_var);
|
||||
parse_unsigned_long ("OMP_MAX_ACTIVE_LEVELS", &gomp_max_active_levels_var,
|
||||
true);
|
||||
parse_unsigned_long ("OMP_THREAD_LIMIT", &gomp_thread_limit_var, false);
|
||||
if (gomp_thread_limit_var != ULONG_MAX)
|
||||
gomp_remaining_threads_count = gomp_thread_limit_var - 1;
|
||||
#ifndef HAVE_SYNC_BUILTINS
|
||||
@ -490,7 +492,8 @@ initialize_env (void)
|
||||
#endif
|
||||
gomp_init_num_threads ();
|
||||
gomp_available_cpus = gomp_global_icv.nthreads_var;
|
||||
if (!parse_unsigned_long ("OMP_NUM_THREADS", &gomp_global_icv.nthreads_var))
|
||||
if (!parse_unsigned_long ("OMP_NUM_THREADS", &gomp_global_icv.nthreads_var,
|
||||
false))
|
||||
gomp_global_icv.nthreads_var = gomp_available_cpus;
|
||||
if (parse_affinity ())
|
||||
gomp_init_affinity ();
|
||||
@ -632,7 +635,7 @@ omp_get_thread_limit (void)
|
||||
void
|
||||
omp_set_max_active_levels (int max_levels)
|
||||
{
|
||||
if (max_levels > 0)
|
||||
if (max_levels >= 0)
|
||||
gomp_max_active_levels_var = max_levels;
|
||||
}
|
||||
|
||||
|
61
libgomp/testsuite/libgomp.c/pr42942.c
Normal file
61
libgomp/testsuite/libgomp.c/pr42942.c
Normal file
@ -0,0 +1,61 @@
|
||||
/* PR libgomp/42942 */
|
||||
/* { dg-do run } */
|
||||
|
||||
#include <omp.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
int e = 0;
|
||||
omp_set_dynamic (0);
|
||||
omp_set_nested (1);
|
||||
omp_set_max_active_levels (1);
|
||||
if (omp_get_max_active_levels () != 1)
|
||||
abort ();
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (!omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 2)
|
||||
e = 1;
|
||||
else
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (!omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 1)
|
||||
e = 1;
|
||||
if (e)
|
||||
abort ();
|
||||
omp_set_max_active_levels (0);
|
||||
if (omp_get_max_active_levels () != 0)
|
||||
abort ();
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 1)
|
||||
e = 1;
|
||||
else
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 1)
|
||||
e = 1;
|
||||
if (e)
|
||||
abort ();
|
||||
omp_set_max_active_levels (2);
|
||||
if (omp_get_max_active_levels () != 2)
|
||||
abort ();
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (!omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 2)
|
||||
e = 1;
|
||||
else
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (!omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 2)
|
||||
e = 1;
|
||||
else
|
||||
#pragma omp parallel num_threads(2) reduction(|:e)
|
||||
if (!omp_in_parallel ()
|
||||
|| omp_get_num_threads () != 1)
|
||||
e = 1;
|
||||
if (e)
|
||||
abort ();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user