Changeset 47d60134 in rtems


Ignore:
Timestamp:
Feb 19, 2014, 12:52:41 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
1be15db1
Parents:
7ee4e72
git-author:
Sebastian Huber <sebastian.huber@…> (02/19/14 12:52:41)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/21/14 08:38:54)
Message:

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.

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/cpu/arm/rtems/score/cpu.h

    r7ee4e72 r47d60134  
    470470  uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
    471471
    472   RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
    473     _CPU_SMP_Get_current_processor( void )
     472  static inline uint32_t _CPU_SMP_Get_current_processor( void )
    474473  {
    475474    uint32_t mpidr;
    476475
    477476    /* Use ARMv7 Multiprocessor Affinity Register (MPIDR) */
    478     __asm__ (
     477    __asm__ volatile (
    479478      "mrc p15, 0, %[mpidr], c0, c0, 5\n"
    480479      : [mpidr] "=&r" (mpidr)
  • cpukit/score/cpu/i386/rtems/score/cpu.h

    r7ee4e72 r47d60134  
    465465  uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
    466466
    467   RTEMS_COMPILER_PURE_ATTRIBUTE uint32_t _CPU_SMP_Get_current_processor( void );
     467  uint32_t _CPU_SMP_Get_current_processor( void );
    468468
    469469  void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
  • cpukit/score/cpu/no_cpu/rtems/score/cpu.h

    r7ee4e72 r47d60134  
    14871487   * range of integers starting with zero up to the processor count minus one.
    14881488   */
    1489   RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
    1490     _CPU_SMP_Get_current_processor( void )
     1489  static inline uint32_t _CPU_SMP_Get_current_processor( void )
    14911490  {
    14921491    return 123;
  • cpukit/score/cpu/powerpc/rtems/score/cpu.h

    r7ee4e72 r47d60134  
    10371037  uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
    10381038
    1039   RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
    1040     _CPU_SMP_Get_current_processor( void )
     1039  static inline uint32_t _CPU_SMP_Get_current_processor( void )
    10411040  {
    10421041    uint32_t pir;
    10431042
    10441043    /* Use Book E Processor ID Register (PIR) */
    1045     __asm__ (
     1044    __asm__ volatile (
    10461045      "mfspr %[pir], 286"
    10471046      : [pir] "=&r" (pir)
  • cpukit/score/cpu/sparc/rtems/score/cpu.h

    r7ee4e72 r47d60134  
    11641164  uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
    11651165
    1166   RTEMS_COMPILER_PURE_ATTRIBUTE uint32_t _CPU_SMP_Get_current_processor( void );
     1166  uint32_t _CPU_SMP_Get_current_processor( void );
    11671167
    11681168  void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
  • cpukit/score/cpu/sparc/rtems/score/sparc.h

    r7ee4e72 r47d60134  
    299299  uint32_t asr17;
    300300
    301   __asm__ (
     301  __asm__ volatile (
    302302    "rd %%asr17, %0"
    303303    : "=&r" (asr17)
  • cpukit/score/include/rtems/score/smp.h

    r7ee4e72 r47d60134  
    4747
    4848#if defined( RTEMS_SMP )
    49   RTEMS_COMPILER_PURE_ATTRIBUTE static inline uint32_t
    50     _SMP_Get_current_processor( void )
     49  static inline uint32_t _SMP_Get_current_processor( void )
    5150  {
    5251    return _CPU_SMP_Get_current_processor();
  • testsuites/smptests/smpmigration01/init.c

    r7ee4e72 r47d60134  
    1717#endif
    1818
     19#define TESTS_USE_PRINTF
    1920#include "tmacros.h"
    2021
    2122#include <stdio.h>
     23#include <math.h>
    2224#include <inttypes.h>
    2325
     
    101103    /* Do nothing */
    102104  }
     105}
     106
     107static uint32_t abs_delta(uint32_t a, uint32_t b)
     108{
     109  return a > b ?  a - b : b - a;
    103110}
    104111
     
    111118  uint32_t expected_tokens;
    112119  uint32_t total_delta;
     120  uint64_t total_cycles;
     121  uint32_t average_cycles;
    113122
    114123  sc = rtems_task_create(
     
    145154  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    146155
     156  total_cycles = 0;
     157  for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
     158    const test_counters *counters = &ctx->counters[runner_index];
     159    size_t cpu;
     160
     161    for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
     162      total_cycles += counters->cycles_per_cpu[cpu].counter;
     163    }
     164  }
     165  average_cycles = (uint32_t) (total_cycles / (RUNNER_COUNT * CPU_COUNT));
     166
     167  printf(
     168    "total cycles %" PRIu64 "\n"
     169    "average cycles %" PRIu32 "\n",
     170    total_cycles,
     171    average_cycles
     172  );
     173
     174  for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
     175    const test_counters *counters = &ctx->counters[runner_index];
     176    size_t cpu;
     177
     178    printf("runner %" PRIuPTR "\n", runner_index);
     179
     180    for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
     181      uint32_t tokens = counters->tokens_per_cpu[cpu].counter;
     182      uint32_t cycles = counters->cycles_per_cpu[cpu].counter;
     183      double cycle_deviation = ((double) cycles - average_cycles)
     184        / average_cycles;
     185
     186      printf(
     187        "\tcpu %zu tokens %" PRIu32 "\n"
     188        "\tcpu %zu cycles %" PRIu32 "\n"
     189        "\tcpu %zu cycle deviation %f\n",
     190        cpu,
     191        tokens,
     192        cpu,
     193        cycles,
     194        cpu,
     195        cycle_deviation
     196      );
     197
     198      rtems_test_assert(fabs(cycle_deviation) < 0.5);
     199    }
     200  }
     201
     202  expected_tokens = ctx->counters[0].tokens_per_cpu[0].counter;
     203  total_delta = 0;
    147204  for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
    148205    test_counters *counters = &ctx->counters[runner_index];
    149206    size_t cpu;
    150207
    151     printf("runner %" PRIuPTR "\n", runner_index);
    152 
    153     for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
    154       printf(
    155         "\tcpu %zu tokens %" PRIu32 "\n"
    156         "\tcpu %zu cycles %" PRIu32 "\n",
    157         cpu,
    158         counters->tokens_per_cpu[cpu].counter,
    159         cpu,
    160         counters->cycles_per_cpu[cpu].counter
    161       );
    162     }
    163   }
    164 
    165   expected_tokens = ctx->counters[0].tokens_per_cpu[0].counter;
    166   total_delta = 0;
    167   for (runner_index = 0; runner_index < RUNNER_COUNT; ++runner_index) {
    168     test_counters *counters = &ctx->counters[runner_index];
    169     size_t cpu;
    170 
    171208    for (cpu = 0; cpu < CPU_COUNT; ++cpu) {
    172209      uint32_t tokens = counters->tokens_per_cpu[cpu].counter;
    173       uint32_t delta = tokens > expected_tokens ?
    174         tokens - expected_tokens : expected_tokens - tokens;
     210      uint32_t delta = abs_delta(tokens, expected_tokens);
    175211
    176212      rtems_test_assert(delta <= 1);
     
    205241#define CONFIGURE_MAXIMUM_TASKS (2 + RUNNER_COUNT)
    206242
     243#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
     244
    207245#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
    208246
  • testsuites/smptests/smpmigration01/smpmigration01.scn

    r7ee4e72 r47d60134  
    11*** TEST SMPMIGRATION 1 ***
     2total cycles 94476101
     3average cycles 15746016
    24runner 0
    3         cpu 0 tokens 453284
    4         cpu 0 cycles 14955317
    5         cpu 1 tokens 453283
    6         cpu 1 cycles 14978390
     5        cpu 0 tokens 456994
     6        cpu 0 cycles 16451659
     7        cpu 0 cycle deviation 0.044814
     8        cpu 1 tokens 456994
     9        cpu 1 cycles 16895680
     10        cpu 1 cycle deviation 0.073013
    711runner 1
    8         cpu 0 tokens 453283
    9         cpu 0 cycles 21302793
    10         cpu 1 tokens 453283
    11         cpu 1 cycles 21318817
     12        cpu 0 tokens 456993
     13        cpu 0 cycles 20561545
     14        cpu 0 cycle deviation 0.305825
     15        cpu 1 tokens 456994
     16        cpu 1 cycles 20548432
     17        cpu 1 cycle deviation 0.304992
    1218runner 2
    13         cpu 0 tokens 453283
    14         cpu 0 cycles 19973312
    15         cpu 1 tokens 453283
    16         cpu 1 cycles 21315227
     19        cpu 0 tokens 456994
     20        cpu 0 cycles 10007206
     21        cpu 0 cycle deviation -0.364461
     22        cpu 1 tokens 456993
     23        cpu 1 cycles 10011579
     24        cpu 1 cycle deviation -0.364183
    1725*** END OF TEST SMPMIGRATION 1 ***
Note: See TracChangeset for help on using the changeset viewer.