Changeset 33b72fd in rtems


Ignore:
Timestamp:
Mar 6, 2015, 3:13:40 PM (5 years ago)
Author:
Alexander Krutwig <alexander.krutwig@…>
Branches:
4.11, master
Children:
cc69334f
Parents:
2bd71d95
git-author:
Alexander Krutwig <alexander.krutwig@…> (03/06/15 15:13:40)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/06/15 15:20:20)
Message:

testsupport: Add cascade option to parallel test

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libmisc/testsupport/test.h

    r2bd71d95 r33b72fd  
    142142   * @param[in] ctx The parallel context.
    143143   * @param[in] arg The user specified argument.
     144   * @param[in] active_workers Count of active workers.  Depends on the cascade
     145   *   option.
    144146   *
    145147   * @return The desired job body execution time in clock ticks.  See
     
    148150  rtems_interval (*init)(
    149151    rtems_test_parallel_context *ctx,
    150     void *arg
     152    void *arg,
     153    size_t active_workers
    151154  );
    152155
     
    156159   * @param[in] ctx The parallel context.
    157160   * @param[in] arg The user specified argument.
     161   * @param[in] active_workers Count of active workers.  Depends on the cascade
     162   *   option.
    158163   * @param[in] worker_index The worker index.  It ranges from 0 to the
    159164   *   processor count minus one.
     
    162167    rtems_test_parallel_context *ctx,
    163168    void *arg,
     169    size_t active_workers,
    164170    size_t worker_index
    165171  );
     
    173179   * @param[in] ctx The parallel context.
    174180   * @param[in] arg The user specified argument.
     181   * @param[in] active_workers Count of active workers.  Depends on the cascade
     182   *   option.
    175183   */
    176184  void (*fini)(
    177185    rtems_test_parallel_context *ctx,
    178     void *arg
     186    void *arg,
     187    size_t active_workers
    179188  );
    180189
     190  /**
     191   * @brief Job specific argument.
     192   */
    181193  void *arg;
     194
     195  /**
     196   * @brief Job cascading flag.
     197   *
     198   * This flag indicates whether the job should be executed in a cascaded
     199   * manner (the job is executed on one processor first, two processors
     200   * afterwards and incremented step by step until all processors are used).
     201   */
     202  bool cascade;
    182203} rtems_test_parallel_job;
    183204
  • cpukit/libmisc/testsupport/testparallel.c

    r2bd71d95 r33b72fd  
    4545  );
    4646  _Assert(sc == RTEMS_SUCCESSFUL);
     47  (void) sc;
    4748}
    4849
     
    5960  for (i = 0; i < job_count; ++i) {
    6061    const rtems_test_parallel_job *job = &jobs[i];
     62    size_t n = rtems_get_processor_count();
     63    size_t j = job->cascade ? 0 : rtems_get_processor_count() - 1;
    6164
    62     if (rtems_test_parallel_is_master_worker(worker_index)) {
    63       rtems_interval duration = (*job->init)(ctx, job->arg);
     65    while (j < n) {
     66      size_t active_worker = j + 1;
    6467
    65       start_worker_stop_timer(ctx, duration);
    66     }
     68      if (rtems_test_parallel_is_master_worker(worker_index)) {
     69        rtems_interval duration = (*job->init)(ctx, job->arg, active_worker);
    6770
    68     _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count);
     71        start_worker_stop_timer(ctx, duration);
     72      }
    6973
    70     (*job->body)(ctx, job->arg, worker_index);
     74      _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count);
    7175
    72     _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count);
     76      if (worker_index <= j) {
     77        (*job->body)(ctx, job->arg, active_worker, worker_index);
     78      }
    7379
    74     if (rtems_test_parallel_is_master_worker(worker_index)) {
    75       (*job->fini)(ctx, job->arg);
     80      _SMP_barrier_Wait(&ctx->barrier, &bs, ctx->worker_count);
     81
     82      if (rtems_test_parallel_is_master_worker(worker_index)) {
     83        (*job->fini)(ctx, job->arg, active_worker);
     84      }
     85
     86      ++j;
    7687    }
    7788  }
     
    92103  sc = rtems_event_transient_send(warg.ctx->master_id);
    93104  _Assert(sc == RTEMS_SUCCESSFUL);
     105  (void) sc;
    94106
    95107  run_tests(warg.ctx, warg.jobs, warg.job_count, warg.worker_index);
  • testsuites/smptests/smpatomic01/init.c

    r2bd71d95 r33b72fd  
    9999static rtems_interval test_atomic_add_init(
    100100  rtems_test_parallel_context *base,
    101   void *arg
     101  void *arg,
     102  size_t active_workers
    102103)
    103104{
     
    112113  rtems_test_parallel_context *base,
    113114  void *arg,
     115  size_t active_workers,
    114116  size_t worker_index
    115117)
     
    126128}
    127129
    128 static void test_atomic_add_fini(rtems_test_parallel_context *base, void *arg)
     130static void test_atomic_add_fini(
     131  rtems_test_parallel_context *base,
     132  void *arg,
     133  size_t active_workers
     134)
    129135{
    130136  smpatomic01_context *ctx = (smpatomic01_context *) base;
     
    135141static rtems_interval test_atomic_flag_init(
    136142  rtems_test_parallel_context *base,
    137   void *arg
     143  void *arg,
     144  size_t active_workers
    138145)
    139146{
     
    149156  rtems_test_parallel_context *base,
    150157  void *arg,
     158  size_t active_workers,
    151159  size_t worker_index
    152160)
     
    169177}
    170178
    171 static void test_atomic_flag_fini(rtems_test_parallel_context *base, void *arg)
     179static void test_atomic_flag_fini(
     180  rtems_test_parallel_context *base,
     181  void *arg,
     182  size_t active_workers
     183  )
    172184{
    173185  smpatomic01_context *ctx = (smpatomic01_context *) base;
     
    178190static rtems_interval test_atomic_sub_init(
    179191  rtems_test_parallel_context *base,
    180   void *arg
     192  void *arg,
     193  size_t active_workers
    181194)
    182195{
     
    191204  rtems_test_parallel_context *base,
    192205  void *arg,
     206  size_t active_workers,
    193207  size_t worker_index
    194208)
     
    205219}
    206220
    207 static void test_atomic_sub_fini(rtems_test_parallel_context *base, void *arg)
     221static void test_atomic_sub_fini(
     222  rtems_test_parallel_context *base,
     223  void *arg,
     224  size_t active_workers
     225)
    208226{
    209227  smpatomic01_context *ctx = (smpatomic01_context *) base;
     
    214232static rtems_interval test_atomic_compare_exchange_init(
    215233  rtems_test_parallel_context *base,
    216   void *arg
     234  void *arg,
     235  size_t active_workers
    217236)
    218237{
     
    228247  rtems_test_parallel_context *base,
    229248  void *arg,
     249  size_t active_workers,
    230250  size_t worker_index
    231251)
     
    260280static void test_atomic_compare_exchange_fini(
    261281  rtems_test_parallel_context *base,
    262   void *arg
     282  void *arg,
     283  size_t active_workers
    263284)
    264285{
     
    270291static rtems_interval test_atomic_or_and_init(
    271292  rtems_test_parallel_context *base,
    272   void *arg
     293  void *arg,
     294  size_t active_workers
    273295)
    274296{
     
    283305  rtems_test_parallel_context *base,
    284306  void *arg,
     307  size_t active_workers,
    285308  size_t worker_index
    286309)
     
    317340static void test_atomic_or_and_fini(
    318341  rtems_test_parallel_context *base,
    319   void *arg
     342  void *arg,
     343  size_t active_workers
    320344)
    321345{
     
    327351static rtems_interval test_atomic_fence_init(
    328352  rtems_test_parallel_context *base,
    329   void *arg
     353  void *arg,
     354  size_t active_workers
    330355)
    331356{
     
    342367  rtems_test_parallel_context *base,
    343368  void *arg,
     369  size_t active_workers,
    344370  size_t worker_index
    345371)
     
    370396}
    371397
    372 static void test_atomic_fence_fini(rtems_test_parallel_context *base, void *arg)
     398static void test_atomic_fence_fini(
     399  rtems_test_parallel_context *base,
     400  void *arg,
     401  size_t active_workers
     402)
    373403{
    374404  smpatomic01_context *ctx = (smpatomic01_context *) base;
     
    384414static const rtems_test_parallel_job test_jobs[] = {
    385415  {
    386     test_atomic_add_init,
    387     test_atomic_add_body,
    388     test_atomic_add_fini
     416    .init = test_atomic_add_init,
     417    .body = test_atomic_add_body,
     418    .fini = test_atomic_add_fini
    389419  }, {
    390     test_atomic_flag_init,
    391     test_atomic_flag_body,
    392     test_atomic_flag_fini
     420    .init = test_atomic_flag_init,
     421    .body =test_atomic_flag_body,
     422    .fini =test_atomic_flag_fini
    393423  }, {
    394     test_atomic_sub_init,
    395     test_atomic_sub_body,
    396     test_atomic_sub_fini
     424    .init = test_atomic_sub_init,
     425    .body =test_atomic_sub_body,
     426    .fini =test_atomic_sub_fini
    397427  }, {
    398     test_atomic_compare_exchange_init,
    399     test_atomic_compare_exchange_body,
    400     test_atomic_compare_exchange_fini
     428    .init = test_atomic_compare_exchange_init,
     429    .body =test_atomic_compare_exchange_body,
     430    .fini =test_atomic_compare_exchange_fini
    401431  }, {
    402     test_atomic_or_and_init,
    403     test_atomic_or_and_body,
    404     test_atomic_or_and_fini
     432    .init = test_atomic_or_and_init,
     433    .body =test_atomic_or_and_body,
     434    .fini =test_atomic_or_and_fini
    405435  }, {
    406     test_atomic_fence_init,
    407     test_atomic_fence_body,
    408     test_atomic_fence_fini
     436    .init = test_atomic_fence_init,
     437    .body =test_atomic_fence_body,
     438    .fini =test_atomic_fence_fini
    409439  },
    410440};
Note: See TracChangeset for help on using the changeset viewer.