diff options
author | Alexander Krutwig <alexander.krutwig@embedded-brains.de> | 2015-03-06 16:13:40 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-03-06 16:20:20 +0100 |
commit | 33b72fde61b3e50be52000e6ed9030225eab4eb0 (patch) | |
tree | 2ec76aa6d9a780941478e109fd722d566425a4fe /cpukit | |
parent | shell: Add PROFREPORT command (diff) | |
download | rtems-33b72fde61b3e50be52000e6ed9030225eab4eb0.tar.bz2 |
testsupport: Add cascade option to parallel test
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/libmisc/testsupport/test.h | 25 | ||||
-rw-r--r-- | cpukit/libmisc/testsupport/testparallel.c | 30 |
2 files changed, 44 insertions, 11 deletions
diff --git a/cpukit/libmisc/testsupport/test.h b/cpukit/libmisc/testsupport/test.h index afed462a01..ae6c17e388 100644 --- a/cpukit/libmisc/testsupport/test.h +++ b/cpukit/libmisc/testsupport/test.h @@ -141,13 +141,16 @@ typedef struct { * * @param[in] ctx The parallel context. * @param[in] arg The user specified argument. + * @param[in] active_workers Count of active workers. Depends on the cascade + * option. * * @return The desired job body execution time in clock ticks. See * rtems_test_parallel_stop_job(). */ rtems_interval (*init)( rtems_test_parallel_context *ctx, - void *arg + void *arg, + size_t active_workers ); /** @@ -155,12 +158,15 @@ typedef struct { * * @param[in] ctx The parallel context. * @param[in] arg The user specified argument. + * @param[in] active_workers Count of active workers. Depends on the cascade + * option. * @param[in] worker_index The worker index. It ranges from 0 to the * processor count minus one. */ void (*body)( rtems_test_parallel_context *ctx, void *arg, + size_t active_workers, size_t worker_index ); @@ -172,13 +178,28 @@ typedef struct { * * @param[in] ctx The parallel context. * @param[in] arg The user specified argument. + * @param[in] active_workers Count of active workers. Depends on the cascade + * option. */ void (*fini)( rtems_test_parallel_context *ctx, - void *arg + void *arg, + size_t active_workers ); + /** + * @brief Job specific argument. + */ void *arg; + + /** + * @brief Job cascading flag. + * + * This flag indicates whether the job should be executed in a cascaded + * manner (the job is executed on one processor first, two processors + * afterwards and incremented step by step until all processors are used). + */ + bool cascade; } rtems_test_parallel_job; /** diff --git a/cpukit/libmisc/testsupport/testparallel.c b/cpukit/libmisc/testsupport/testparallel.c index 681f769124..c1bdeda9f0 100644 --- a/cpukit/libmisc/testsupport/testparallel.c +++ b/cpukit/libmisc/testsupport/testparallel.c @@ -44,6 +44,7 @@ static void start_worker_stop_timer( ctx ); _Assert(sc == RTEMS_SUCCESSFUL); + (void) sc; } static void run_tests( @@ -58,21 +59,31 @@ static void run_tests( for (i = 0; i < job_count; ++i) { const rtems_test_parallel_job *job = &jobs[i]; + size_t n = rtems_get_processor_count(); + size_t j = job->cascade ? 0 : rtems_get_processor_count() - 1; - if (rtems_test_parallel_is_master_worker(worker_index)) { - rtems_interval duration = (*job->init)(ctx, job->arg); + while (j < n) { + size_t active_worker = j + 1; - start_worker_stop_timer(ctx, duration); - } + if (rtems_test_parallel_is_master_worker(worker_index)) { + rtems_interval duration = (*job->init)(ctx, job->arg, active_worker); + + start_worker_stop_timer(ctx, duration); + } + + _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count); - _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count); + if (worker_index <= j) { + (*job->body)(ctx, job->arg, active_worker, worker_index); + } - (*job->body)(ctx, job->arg, worker_index); + _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count); - _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count); + if (rtems_test_parallel_is_master_worker(worker_index)) { + (*job->fini)(ctx, job->arg, active_worker); + } - if (rtems_test_parallel_is_master_worker(worker_index)) { - (*job->fini)(ctx, job->arg); + ++j; } } } @@ -91,6 +102,7 @@ static void worker_task(rtems_task_argument arg) sc = rtems_event_transient_send(warg.ctx->master_id); _Assert(sc == RTEMS_SUCCESSFUL); + (void) sc; run_tests(warg.ctx, warg.jobs, warg.job_count, warg.worker_index); |