From: Maxim Baryshnikov Date: Fri, 13 May 2016 12:11:57 +0000 (+0200) Subject: l4: benchmark: Make benchmark work. X-Git-Url: https://rtime.felk.cvut.cz/gitweb/l4.git/commitdiff_plain/90396b8a810cec43686e3355b43bf290248beb4c l4: benchmark: Make benchmark work. --- diff --git a/l4/pkg/benchmark/server/src/main.c b/l4/pkg/benchmark/server/src/main.c index 4181d76ed..324d222fa 100644 --- a/l4/pkg/benchmark/server/src/main.c +++ b/l4/pkg/benchmark/server/src/main.c @@ -14,16 +14,86 @@ */ #include +#include #include -#include + +// #include +// #include +// #include +// #include #include #include +#include +#include + +#define DEF_SIZE (4*1024) +#define DEF_STRIDE (1) +#define TEST_TYPE l4_uint8_t +#define POLLITE_CACHE void use_dummy(int result); -size_t* words_initialize(size_t max, int scale); +TEST_TYPE* words_initialize(l4_uint64_t max, int scale); l4_uint64_t parse_param( char param, int argc, char* argv[]); +//------------------------------------------------------------- +//---------L4 memory allocation-------------------------------- +/*------from examples/libs/l4re/c/ma+rm.c example-------------*/ +// static int allocate_mem(unsigned long size_in_bytes, unsigned long flags, +// void **virt_addr) +// { +// int r; +// l4re_ds_t ds; + +// /* Allocate a free capability index for our data space */ +// ds = l4re_util_cap_alloc(); +// if (l4_is_invalid_cap(ds)) +// return -L4_ENOMEM; + +// size_in_bytes = l4_trunc_page(size_in_bytes); + +// /* Allocate memory via a dataspace */ +// if ((r = l4re_ma_alloc(size_in_bytes, ds, flags))) +// return r; + +// /* Make the dataspace visible in our address space */ +// *virt_addr = 0; +// if ((r = l4re_rm_attach(virt_addr, size_in_bytes, +// L4RE_RM_SEARCH_ADDR, ds, 0, +// flags & L4RE_MA_SUPER_PAGES +// ? L4_SUPERPAGESHIFT : L4_PAGESHIFT))) +// return r; + +// /* Done, virtual address is in virt_addr */ +// return 0; +// } + +// /** +// * \brief Free previously allocated memory. +// * +// * \param virt_addr Virtual address return by allocate_mem +// * +// * \return 0 on success, error code otherwise +// */ +// static int free_mem(void *virt_addr) +// { +// int r; +// l4re_ds_t ds; + +// /* Detach memory from our address space */ +// if ((r = l4re_rm_detach_ds(virt_addr, &ds))) +// return r; + +// /* Free memory at our memory allocator */ +// if ((r = l4re_ma_free(ds))) +// return r; +// l4re_util_cap_free(ds); + +// /* All went ok */ +// return 0; +// } + +//------------------------------------------------------------- static volatile l4_uint64_t use_result_dummy; void use_dummy(int result) { use_result_dummy += result; } @@ -36,25 +106,30 @@ void use_dummy(int result) { use_result_dummy += result; } * as to maximize the number of potential cache misses, and to * minimize the possibility of re-using a cache line. */ -size_t* words_initialize(size_t max, int scale) + +TEST_TYPE* words_initialize(l4_uint64_t max, int scale) { - size_t i, j, nbits; - size_t* words = (size_t*)calloc(max, sizeof(size_t)); + l4_uint64_t i, j, nbits; + TEST_TYPE* words = (TEST_TYPE*) malloc(max); + printf("%llu bytes allocated.\n", max*sizeof(TEST_TYPE)); + memset(words, 0, max); if (!words) return NULL; + printf("Start init."); //bzero(words, max * sizeof(size_t)); - for (i = max>>1, nbits = 0; i != 0; i >>= 1, nbits++) - ; - for (i = 0; i < max; ++i) { - /* now reverse the bits */ - for (j = 0; j < nbits; j++) { - if (i & (1<>1, nbits = 0; i != 0; i >>= 1, nbits++); + for (i = 0; i < max; ++i) { + /* now reverse the bits */ + for (j = 0; j < nbits; j++) { + if (i & (1<