diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2012-02-24 21:16:26 +0000 |
---|---|---|
committer | Andrew Macleod <amacleod@gcc.gnu.org> | 2012-02-24 21:16:26 +0000 |
commit | 9fced7562f07a2ff569dbb472f5f600d56fd0859 (patch) | |
tree | a0b3d285254aa38e8077dc9baf77a4aca28fda76 | |
parent | 15498cfa4ee495c125aaf847a77bf1001505178b (diff) | |
download | gcc-9fced7562f07a2ff569dbb472f5f600d56fd0859.zip gcc-9fced7562f07a2ff569dbb472f5f600d56fd0859.tar.gz gcc-9fced7562f07a2ff569dbb472f5f600d56fd0859.tar.bz2 |
simulate-thread.gdb: Use return value from simulate_thread_wrapper_other_threads
* gcc.dg/simulate-thread/simulate-thread.gdb: Use return value from
simulate_thread_wrapper_other_threads
* gcc.dg/simulate-thread/atomic-load-int128.c (simulate_thread_main):
Move initialization of 'value' to main().
(main): Initialize 'value';
* gcc.dg/simulate-thread/speculative-store.c
(simulate_thread_step_verify): Return 0 when successful.
* gcc.dg/simulate-thread/simulate-thread.h (HOSTILE_THREAD_THRESHOLD):
Reduce threshold.
(INSN_COUNT_THRESHOLD): New. Instruction limit to terminate test.
(simulate_thread_wrapper_other_threads): Return a success/fail value
and issue an error if the instruction count threshold is exceeded.
From-SVN: r184564
5 files changed, 53 insertions, 16 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9f4b03b..ec95bcd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2012-02-24 Andrew MacLeod <amacleod@redhat.com> + + * gcc.dg/simulate-thread/simulate-thread.gdb: Use return value from + simulate_thread_wrapper_other_threads + * gcc.dg/simulate-thread/atomic-load-int128.c (simulate_thread_main): + Move initialization of 'value' to main(). + (main): Initialize 'value'; + * gcc.dg/simulate-thread/speculative-store.c + (simulate_thread_step_verify): Return 0 when successful. + * gcc.dg/simulate-thread/simulate-thread.h (HOSTILE_THREAD_THRESHOLD): + Reduce threshold. + (INSN_COUNT_THRESHOLD): New. Instruction limit to terminate test. + (simulate_thread_wrapper_other_threads): Return a success/fail value + and issue an error if the instruction count threshold is exceeded. + 2012-02-24 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> PR target/50580 diff --git a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int128.c b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int128.c index c5aa623..651e76a 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int128.c +++ b/gcc/testsuite/gcc.dg/simulate-thread/atomic-load-int128.c @@ -105,9 +105,6 @@ void simulate_thread_main() { int x; - /* Make sure value starts with an atomic value now. */ - __atomic_store_n (&value, ret, __ATOMIC_SEQ_CST); - /* Execute loads with value changing at various cyclic values. */ for (table_cycle_size = 16; table_cycle_size > 4 ; table_cycle_size--) { @@ -126,6 +123,10 @@ void simulate_thread_main() main() { fill_table (); + + /* Make sure value starts with an atomic value from the table. */ + __atomic_store_n (&value, table[0], __ATOMIC_SEQ_CST); + simulate_thread_main (); simulate_thread_done (); return 0; diff --git a/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.gdb b/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.gdb index cbb65db..93f60c3 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.gdb +++ b/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.gdb @@ -5,7 +5,7 @@ run set $ret = 0 while (simulate_thread_fini != 1) && (! $ret) - call simulate_thread_wrapper_other_threads() + set $ret |= simulate_thread_wrapper_other_threads() stepi set $ret |= simulate_thread_step_verify() end diff --git a/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.h b/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.h index 9e2361f..22c0508 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.h +++ b/gcc/testsuite/gcc.dg/simulate-thread/simulate-thread.h @@ -37,7 +37,7 @@ simulate_thread_done () infinite loop to be avoided. If the testcase defines HOSTILE_PAUSE_ERROR, then it will be - considered an RUNTIME FAILURE if the hostile pause is triggered. + considered a RUNTIME FAILURE if the hostile pause is triggered. This will allow to test for guaranteed forward progress routines. If the default values for HOSTILE_THREAD_THRESHOLD or @@ -50,17 +50,29 @@ simulate_thread_done () hostile condition is interferring. */ -/* Define the threshold to start pausing the hostile thread. */ +/* Define the threshold instruction count to start pausing the hostile + thread. To avoid huge potential log files when things are not going well, + set this number very low. If a test specifically requires that the forward + progress guarantee is made, this number should be raised by the testcase. */ #if !defined (HOSTILE_THREAD_THRESHOLD) -#define HOSTILE_THREAD_THRESHOLD 500 +#define HOSTILE_THREAD_THRESHOLD 50 #endif /* Define the length of pause in cycles for the hostile thread to pause to - allow forward progress to be made. */ + allow forward progress to be made. If this number is too low, a + compare_and_swap loop may not have time to finish, especially on a + 128 bit operation. */ #if !defined (HOSTILE_THREAD_PAUSE) #define HOSTILE_THREAD_PAUSE 20 #endif +/* Define the number of instructions which are allowed to be executed before + the testcase is deemed to fail. This is primarily to avoid huge log files + when a testcase goes into an infinte loop. */ +#if !defined (INSN_COUNT_THRESHOLD) +#define INSN_COUNT_THRESHOLD 10000 +#endif + void simulate_thread_other_threads (void); int simulate_thread_final_verify (void); @@ -71,26 +83,34 @@ static int simulate_thread_hostile_pause = 0; is reached, the other_thread process is paused for HOSTILE_THREAD_PAUSE cycles before resuming, and the counters start again. */ -void +int simulate_thread_wrapper_other_threads() { - static int count = 0; - static int pause = 0; + static int insn_count = 0; + static int hostile_count = 0; + static int hostile_pause = 0; + + if (++insn_count >= INSN_COUNT_THRESHOLD) + { + printf ("FAIL: Testcase exceeded maximum instruction count threshold\n"); + return 1; + } - if (++count >= HOSTILE_THREAD_THRESHOLD) + if (++hostile_count >= HOSTILE_THREAD_THRESHOLD) { if (!simulate_thread_hostile_pause) simulate_thread_hostile_pause = 1; /* Count cycles before calling the hostile thread again. */ - if (pause++ < HOSTILE_THREAD_PAUSE) - return; + if (hostile_pause++ < HOSTILE_THREAD_PAUSE) + return 0; /* Reset the pause counter, as well as the thread counter. */ - pause = 0; - count = 0; + hostile_pause = 0; + hostile_count = 0; } simulate_thread_other_threads (); + return 0; } diff --git a/gcc/testsuite/gcc.dg/simulate-thread/speculative-store.c b/gcc/testsuite/gcc.dg/simulate-thread/speculative-store.c index 71d1cca..ff9d71e 100644 --- a/gcc/testsuite/gcc.dg/simulate-thread/speculative-store.c +++ b/gcc/testsuite/gcc.dg/simulate-thread/speculative-store.c @@ -24,6 +24,7 @@ int simulate_thread_step_verify() printf("FAIL: global variable was assigned to. \n"); return 1; } + return 0; } int simulate_thread_final_verify() |