Ignore:
Timestamp:
Sep 11, 2014, 5:33:16 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
6e0000c
Parents:
ecf64a5e
Message:

tmtests/tmcontext01: Improve cache dirty function

Increment by cache line size to allow more cycles per second.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/tmtests/tmcontext01/init.c

    recf64a5e rf3508c44  
    3939static volatile bool always_true = true;
    4040
     41static size_t cache_line_size;
     42
    4143static size_t data_size;
    4244
     
    4547static Context_Control ctx;
    4648
    47 static int dirty_data_cache(volatile int *d, int j)
    48 {
    49   size_t n = data_size / sizeof(*d);
     49static int dirty_data_cache(volatile int *data, size_t n, size_t clsz, int j)
     50{
     51  size_t m = n / sizeof(*data);
     52  size_t k = clsz / sizeof(*data);
    5053  size_t i;
    5154
    52   for (i = 0; i < n; ++i) {
    53     d[i] = i + j;
     55  for (i = 0; i < m; i += k) {
     56    data[i] = i + j;
    5457  }
    5558
     
    9194
    9295    if (dirty) {
    93       dirty_data_cache(main_data, fl);
     96      dirty_data_cache(main_data, data_size, cache_line_size, fl);
    9497      rtems_cache_invalidate_entire_instruction();
    9598    }
     
    113116{
    114117  volatile int *load_data = (volatile int *) arg;
     118  size_t n = data_size;
     119  size_t clsz = cache_line_size;
    115120  int j = (int) rtems_get_current_processor();
    116121
    117122  while (true) {
    118     j = dirty_data_cache(load_data, j);
     123    j = dirty_data_cache(load_data, n, clsz, j);
    119124  }
    120125}
     
    209214  printf("<Test>\n");
    210215
     216  cache_line_size = rtems_cache_get_data_line_size();
     217  if (cache_line_size == 0) {
     218    cache_line_size = 32;
     219  }
     220
    211221  data_size = rtems_cache_get_data_cache_size(0);
    212   if (data_size > 0) {
    213     main_data = malloc(data_size);
    214     rtems_test_assert(main_data != NULL);
    215   }
     222  if (data_size == 0) {
     223    data_size = cache_line_size;
     224  }
     225
     226  main_data = malloc(data_size);
     227  rtems_test_assert(main_data != NULL);
    216228
    217229  test(false, load);
     
    223235    volatile int *load_data = NULL;
    224236
    225     if (data_size > 0) {
    226       load_data = malloc(data_size);
    227       if (load_data == NULL) {
    228         load_data = main_data;
    229       }
     237    load_data = malloc(data_size);
     238    if (load_data == NULL) {
     239      load_data = main_data;
    230240    }
    231241
Note: See TracChangeset for help on using the changeset viewer.