Hi! On Mon, 29 Sep 2014 13:58:31 +0000, "Tannenbaum, Barry M" <barry.m.tannenb...@intel.com> wrote: > In a nutshell, add the following code to main() before the call to f3(): > > int status = __cilkrts_set_param("nworkers", "2"); > if (0 != status) { > // Failed to set the number of Cilk workers > return status; > }
Yeah, that's what I had proposed with the patch at the end of my previous email, <http://news.gmane.org/find-root.php?message_id=%3C8761g6g0je.fsf%40kepler.schwinge.homeip.net%3E>. I'm sorry if I didn't make it obvious that more text and the patch were following after the full-quote of the original issue description. > Here's the details: [...] Thanks again for your helpful comments; that's appreciated. Here's again my proposed patch. Note, that the include paths in GCC compiler testing (gcc/testsuite/) are not set up to pick up the <cilk/cilk_api.h> include file, so I've manually added a propotype for the __cilkrts_set_param function to the three files. I can change that, if requested. commit ee7138e451d1f3284d6fa0f61fe517c82db94060 Author: Thomas Schwinge <tho...@codesourcery.com> Date: Mon Sep 29 12:47:34 2014 +0200 Audit Cilk Plus tests for CILK_NWORKERS=1. gcc/testsuite/ * c-c++-common/cilk-plus/CK/spawning_arg.c (main): Call __cilkrts_set_param to set two workers. * c-c++-common/cilk-plus/CK/steal_check.c (main): Likewise. * g++.dg/cilk-plus/CK/catch_exc.cc (main): Likewise. --- gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c | 15 +++++++++++++++ gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c | 17 ++++++++++++++--- gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c index 95e6cab..138b82c 100644 --- gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c +++ gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c @@ -2,6 +2,17 @@ /* { dg-options "-fcilkplus" } */ /* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ +#ifdef __cplusplus +extern "C" { +#endif + +extern int __cilkrts_set_param (const char *, const char *); + +#ifdef __cplusplus +} +#endif + + void f0(volatile int *steal_flag) { int i = 0; @@ -32,6 +43,10 @@ void f3() int main() { + /* Ensure more than one worker. */ + if (__cilkrts_set_param("nworkers", "2") != 0) + __builtin_abort(); + f3(); return 0; } diff --git gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c index 6e28765..6b41c7f 100644 --- gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c +++ gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c @@ -2,8 +2,16 @@ /* { dg-options "-fcilkplus" } */ /* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ -// #include <cilk/cilk_api.h> -extern void __cilkrts_set_param (char *, char *); +#ifdef __cplusplus +extern "C" { +#endif + +extern int __cilkrts_set_param (const char *, const char *); + +#ifdef __cplusplus +} +#endif + void foo(volatile int *); @@ -11,7 +19,10 @@ void main2(void); int main(void) { - // __cilkrts_set_param ((char *)"nworkers", (char *)"2"); + /* Ensure more than one worker. */ + if (__cilkrts_set_param("nworkers", "2") != 0) + __builtin_abort(); + main2(); return 0; } diff --git gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc index 0633d19..09ddf8b 100644 --- gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc +++ gcc/testsuite/g++.dg/cilk-plus/CK/catch_exc.cc @@ -10,6 +10,16 @@ #endif #include <cstdlib> +#ifdef __cplusplus +extern "C" { +#endif + +extern int __cilkrts_set_param (const char *, const char *); + +#ifdef __cplusplus +} +#endif + void func(int volatile* steal_me) { @@ -59,6 +69,10 @@ void my_test() int main() { + /* Ensure more than one worker. */ + if (__cilkrts_set_param("nworkers", "2") != 0) + __builtin_abort(); + my_test(); #if HAVE_IO printf("PASSED\n"); Grüße, Thomas
pgpnNzunM87ZE.pgp
Description: PGP signature