diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-19 13:52:41 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-21 09:38:54 +0100 |
commit | 47d6013417c63115356042695e7125ecfcfe4696 (patch) | |
tree | e45e767e2d794cbd7ab5d0932aba9d38dfc22e87 /testsuites/smptests/smpmigration01/init.c | |
parent | score: _Thread_Start_multitasking() (diff) | |
download | rtems-47d6013417c63115356042695e7125ecfcfe4696.tar.bz2 |
score: _CPU_SMP_Get_current_processor()
Remove RTEMS_COMPILER_PURE_ATTRIBUTE from _SMP_Get_current_processor()
and all _CPU_SMP_Get_current_processor(). Make inline ASM statements
volatile again. Test smptests/smpmigration01 showed that GCC optimizes
too much otherwise.
Diffstat (limited to 'testsuites/smptests/smpmigration01/init.c')
-rw-r--r-- | testsuites/smptests/smpmigration01/init.c | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/testsuites/smptests/smpmigration01/init.c b/testsuites/smptests/smpmigration01/init.c index 1500dba3bc..2422466ee9 100644 --- a/testsuites/smptests/smpmigration01/init.c +++ b/testsuites/smptests/smpmigration01/init.c @@ -16,9 +16,11 @@ #include "config.h" #endif +#define TESTS_USE_PRINTF #include "tmacros.h" #include <stdio.h> +#include <math.h> #include <inttypes.h> #define CPU_COUNT 2 @@ -102,6 +104,11 @@ static void stopper(rtems_task_argument arg) } } +static uint32_t abs_delta(uint32_t a, uint32_t b) +{ + return a > b ? a - b : b - a; +} + static void test(void) { test_context *ctx = &ctx_instance; @@ -110,6 +117,8 @@ static void test(void) rtems_id stopper_id; uint32_t expected_tokens; uint32_t total_delta; + uint64_t total_cycles; + uint32_t average_cycles; sc = rtems_task_create( rtems_build_name('S', 'T', 'O', 'P'), @@ -144,21 +153,49 @@ static void test(void) sc = rtems_task_start(stopper_id, stopper, 0); rtems_test_assert(sc == RTEMS_SUCCESSFUL); + total_cycles = 0; for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) { - test_counters *counters = &ctx->counters[runner_index]; + const test_counters *counters = &ctx->counters[runner_index]; + size_t cpu; + + for (cpu = 0; cpu < CPU_COUNT; ++cpu) { + total_cycles += counters->cycles_per_cpu[cpu].counter; + } + } + average_cycles = (uint32_t) (total_cycles / (RUNNER_COUNT * CPU_COUNT)); + + printf( + "total cycles %" PRIu64 "\n" + "average cycles %" PRIu32 "\n", + total_cycles, + average_cycles + ); + + for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) { + const test_counters *counters = &ctx->counters[runner_index]; size_t cpu; printf("runner %" PRIuPTR "\n", runner_index); for (cpu = 0; cpu < CPU_COUNT; ++cpu) { + uint32_t tokens = counters->tokens_per_cpu[cpu].counter; + uint32_t cycles = counters->cycles_per_cpu[cpu].counter; + double cycle_deviation = ((double) cycles - average_cycles) + / average_cycles; + printf( "\tcpu %zu tokens %" PRIu32 "\n" - "\tcpu %zu cycles %" PRIu32 "\n", + "\tcpu %zu cycles %" PRIu32 "\n" + "\tcpu %zu cycle deviation %f\n", + cpu, + tokens, cpu, - counters->tokens_per_cpu[cpu].counter, + cycles, cpu, - counters->cycles_per_cpu[cpu].counter + cycle_deviation ); + + rtems_test_assert(fabs(cycle_deviation) < 0.5); } } @@ -170,8 +207,7 @@ static void test(void) for (cpu = 0; cpu < CPU_COUNT; ++cpu) { uint32_t tokens = counters->tokens_per_cpu[cpu].counter; - uint32_t delta = tokens > expected_tokens ? - tokens - expected_tokens : expected_tokens - tokens; + uint32_t delta = abs_delta(tokens, expected_tokens); rtems_test_assert(delta <= 1); @@ -204,6 +240,8 @@ static void Init(rtems_task_argument arg) #define CONFIGURE_MAXIMUM_TASKS (2 + RUNNER_COUNT) +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT + #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_INIT |