[commtech] Add calculation method
Add a calculation method which add the value of the first integer of n consecutive cache lines and write the results in one of the integer of these cache lines. Next calculation uses the next n consecutives cache lines and write the result in the next integer.
This commit is contained in:
parent
975411a824
commit
c3aad28ad5
|
@ -22,6 +22,7 @@ CC=gcc
|
|||
# Files
|
||||
BINNAMES:=c_cache_comm lamport_comm shared_mem_opt_comm none_comm csq_2_comm
|
||||
BINNAMES+=csq_64_comm fast_forward_comm mcringbuffer_comm #pipe_comm jikes_barrier_comm asm_cache_comm
|
||||
CALCLIBSNAMES:=calc_mat calc_line calc_useless_loop
|
||||
BINS:=$(patsubst %,$(BINDIR)/%,$(BINNAMES))
|
||||
CALCLIBS:=$(patsubst %,$(LIBDIR)/$(CALCDIR)/lib%.so.1,$(CALCLIBSNAMES))
|
||||
MAIN_OBJS:=main.o
|
||||
|
|
|
@ -10,7 +10,7 @@ calcDir="calculation"
|
|||
# Param
|
||||
binList="$(ls -1 "${binDir}"| sed '$!s/$/ /' | tr -d '\n')"
|
||||
nbProdList="1" # Nombre de cores producteurs
|
||||
typeProdList="none matrice useless_loop" # Methode pour produire les valeurs
|
||||
typeProdList="none useless_loop line matrice" # Methode pour produire les valeurs
|
||||
typeCacheList="L2 Memory" # Niveau de cache partage
|
||||
perfOpt="stat -r 10 -e cycles -e L1-dcache-loads -e L1-dcache-stores -e LLC-load-misses -e LLC-store-misses"
|
||||
|
||||
|
@ -31,6 +31,7 @@ export LD_LIBRARY_PATH
|
|||
function_run () {
|
||||
case $typeProd in
|
||||
"none" ) optTypeProd="" ;;
|
||||
"line" ) optTypeProd="-c lib/${calcDir}/libcalc_line.so ${argTypeProd}" ;;
|
||||
"matrice" ) optTypeProd="-c lib/${calcDir}/libcalc_mat.so 16" ;;
|
||||
"useless_loop" ) optTypeProd="-c lib/${calcDir}/libcalc_useless_loop.so ${argTypeProd}" ;;
|
||||
* ) exit 1 ;;
|
||||
|
@ -68,15 +69,13 @@ for nbProd in $nbProdList ; do
|
|||
for bin in $binList ; do
|
||||
case $typeProd in
|
||||
"useless_loop" )
|
||||
case $bin in
|
||||
"jikes_barrier_comm" | "asm_cache_comm" | "c_cache_comm" )
|
||||
for argTypeProd in 1 `seq 5 5 50` ; do
|
||||
function_run ;
|
||||
done ;;
|
||||
* )
|
||||
argTypeProd=1 ;
|
||||
function_run ;;
|
||||
esac ;;
|
||||
"line" )
|
||||
for argTypeProd in 1 2 4 8 16 32 64 ; do
|
||||
function_run ;
|
||||
done ;;
|
||||
"matrice" )
|
||||
argTypeProd=16 ;
|
||||
function_run ;;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
||||
/* Non standard include */
|
||||
#include <commtech.h>
|
||||
|
||||
#define CACHE_SIZE (32 * 1024)
|
||||
|
||||
|
||||
static volatile uintptr_t *line_array;
|
||||
static int write_idx, read_idx;
|
||||
static int lines_per_calc;
|
||||
|
||||
#define CACHE_LINE_ENTRIES (CACHE_LINE_SIZE / sizeof(*line_array))
|
||||
|
||||
int init_calc(int lines_per_calc_param)
|
||||
{
|
||||
int i;
|
||||
|
||||
assert(!(CACHE_SIZE % (lines_per_calc_param * CACHE_LINE_SIZE)));
|
||||
lines_per_calc = lines_per_calc_param;
|
||||
write_idx = 0;
|
||||
read_idx = 0;
|
||||
srand(42);
|
||||
if (posix_memalign((void **) &line_array, CACHE_LINE_SIZE, CACHE_SIZE))
|
||||
{
|
||||
fprintf(stderr, "calc_line: Unable to allocate memory for random line-sized calculation\n");
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < CACHE_SIZE / sizeof(*line_array); i++)
|
||||
line_array[i] = rand();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void **do_calc(void)
|
||||
{
|
||||
int next_stop_read_idx, mres, cur_write_idx;
|
||||
|
||||
mres = 0;
|
||||
next_stop_read_idx = read_idx + lines_per_calc * CACHE_LINE_ENTRIES;
|
||||
for (; read_idx < next_stop_read_idx; read_idx += CACHE_LINE_ENTRIES)
|
||||
{
|
||||
mres += line_array[read_idx];
|
||||
line_array[read_idx]++;
|
||||
}
|
||||
read_idx %= CACHE_SIZE / sizeof(*line_array);
|
||||
cur_write_idx = write_idx;
|
||||
write_idx++;
|
||||
write_idx %= CACHE_SIZE / sizeof(*line_array);
|
||||
line_array[cur_write_idx] = mres;
|
||||
return (void **) &line_array[cur_write_idx];
|
||||
}
|
||||
|
||||
int end_calc(void)
|
||||
{
|
||||
free((void *) line_array);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue