summaryrefslogtreecommitdiffstats
path: root/testsuites/smptests/smpmigration01
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-02-19 13:52:41 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-02-21 09:38:54 +0100
commit47d6013417c63115356042695e7125ecfcfe4696 (patch)
treee45e767e2d794cbd7ab5d0932aba9d38dfc22e87 /testsuites/smptests/smpmigration01
parentscore: _Thread_Start_multitasking() (diff)
downloadrtems-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')
-rw-r--r--testsuites/smptests/smpmigration01/init.c50
-rw-r--r--testsuites/smptests/smpmigration01/smpmigration01.scn32
2 files changed, 64 insertions, 18 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
diff --git a/testsuites/smptests/smpmigration01/smpmigration01.scn b/testsuites/smptests/smpmigration01/smpmigration01.scn
index b2b56ffcb8..ba42cd4942 100644
--- a/testsuites/smptests/smpmigration01/smpmigration01.scn
+++ b/testsuites/smptests/smpmigration01/smpmigration01.scn
@@ -1,17 +1,25 @@
*** TEST SMPMIGRATION 1 ***
+total cycles 94476101
+average cycles 15746016
runner 0
- cpu 0 tokens 453284
- cpu 0 cycles 14955317
- cpu 1 tokens 453283
- cpu 1 cycles 14978390
+ cpu 0 tokens 456994
+ cpu 0 cycles 16451659
+ cpu 0 cycle deviation 0.044814
+ cpu 1 tokens 456994
+ cpu 1 cycles 16895680
+ cpu 1 cycle deviation 0.073013
runner 1
- cpu 0 tokens 453283
- cpu 0 cycles 21302793
- cpu 1 tokens 453283
- cpu 1 cycles 21318817
+ cpu 0 tokens 456993
+ cpu 0 cycles 20561545
+ cpu 0 cycle deviation 0.305825
+ cpu 1 tokens 456994
+ cpu 1 cycles 20548432
+ cpu 1 cycle deviation 0.304992
runner 2
- cpu 0 tokens 453283
- cpu 0 cycles 19973312
- cpu 1 tokens 453283
- cpu 1 cycles 21315227
+ cpu 0 tokens 456994
+ cpu 0 cycles 10007206
+ cpu 0 cycle deviation -0.364461
+ cpu 1 tokens 456993
+ cpu 1 cycles 10011579
+ cpu 1 cycle deviation -0.364183
*** END OF TEST SMPMIGRATION 1 ***