mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
Callgrind: add 4 regression tests
The simwork tests check different cache simulator options/modes. These tests should be extended to check for the produced call graph. The threads check tests the callgrind mode where counts are aggregated separate per thread. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5816
This commit is contained in:
parent
6135031a89
commit
efa0f1d7bd
@ -1046,7 +1046,6 @@ void CLG_(post_clo_init)(void)
|
||||
CLG_(instrument_state) = CLG_(clo).instrument_atstart;
|
||||
|
||||
if (VG_(clo_verbosity > 0)) {
|
||||
VG_(message)(Vg_UserMsg, "");
|
||||
VG_(message)(Vg_UserMsg,
|
||||
"For interactive control, run 'callgrind_control -h'.");
|
||||
}
|
||||
|
||||
@ -6,11 +6,15 @@ DIST_SUBDIRS = .
|
||||
|
||||
noinst_SCRIPTS = filter_stderr
|
||||
|
||||
EXTRA_DIST = clreq.vgtest clreq.stderr.exp
|
||||
EXTRA_DIST = clreq.vgtest clreq.stderr.exp \
|
||||
simwork1.vgtest simwork1.stdout.exp simwork1.stderr.exp \
|
||||
simwork2.vgtest simwork2.stdout.exp simwork2.stderr.exp \
|
||||
simwork3.vgtest simwork3.stdout.exp simwork3.stderr.exp \
|
||||
threads.vgtest threads.stderr.exp
|
||||
|
||||
check_PROGRAMS = clreq
|
||||
check_PROGRAMS = clreq simwork threads
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/include
|
||||
AM_CFLAGS = $(WERROR) -Winline -Wall -Wshadow -g $(AM_FLAG_M3264_PRI)
|
||||
|
||||
|
||||
threads_LDADD = -lpthread
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
Events : Ir
|
||||
Collected :
|
||||
|
||||
I refs:
|
||||
@ -1,3 +1,3 @@
|
||||
prog: clreq
|
||||
vgopts: -q
|
||||
vgopts:
|
||||
cleanup: rm callgrind.out.*
|
||||
|
||||
@ -7,6 +7,12 @@ $dir/../../tests/filter_stderr_basic |
|
||||
# Remove "Callgrind, ..." line and the following copyright line.
|
||||
sed "/^Callgrind, a call-graph generating cache profiler./ , /./ d" |
|
||||
|
||||
# Remove pointer to callgrind_control
|
||||
sed "/^For interactive control,.*$/d" |
|
||||
|
||||
# Remove numbers from "Collected" line
|
||||
sed "s/^\(Collected *:\)[ 0-9]*$/\1/" |
|
||||
|
||||
# Remove numbers from I/D/L2 "refs:" lines
|
||||
sed "s/\(\(I\|D\|L2\) *refs:\)[ 0-9,()+rdw]*$/\1/" |
|
||||
|
||||
|
||||
66
callgrind/tests/simwork.c
Normal file
66
callgrind/tests/simwork.c
Normal file
@ -0,0 +1,66 @@
|
||||
// Some work exercising the cache simulator
|
||||
// with a simple call graph
|
||||
|
||||
#include "../callgrind.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SIZE 100000
|
||||
|
||||
double *a, *b, *c;
|
||||
|
||||
void init()
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i< SIZE; i++) a[i] = b[i] = 1.0;
|
||||
}
|
||||
|
||||
void do_add()
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i< SIZE; i++) {
|
||||
a[i] += 1.0;
|
||||
c[i] = a[i] + b[i];
|
||||
}
|
||||
}
|
||||
|
||||
double do_sum()
|
||||
{
|
||||
int i;
|
||||
double sum=0.0;
|
||||
|
||||
do_add();
|
||||
for(i = 0; i< SIZE; i++) sum += c[i];
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
double do_some_work(int iter)
|
||||
{
|
||||
double sum=0.0;
|
||||
|
||||
if (iter > 0) sum += do_some_work(iter-1);
|
||||
do_add();
|
||||
sum += do_sum();
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
double res;
|
||||
|
||||
a = (double*) malloc(SIZE * sizeof(double));
|
||||
b = (double*) malloc(SIZE * sizeof(double));
|
||||
c = (double*) malloc(SIZE * sizeof(double));
|
||||
|
||||
CALLGRIND_ZERO_STATS;
|
||||
init();
|
||||
res = do_some_work(1);
|
||||
CALLGRIND_DUMP_STATS;
|
||||
|
||||
printf("Sum: %.0f\n", res);
|
||||
return RUNNING_ON_VALGRIND;
|
||||
}
|
||||
|
||||
20
callgrind/tests/simwork1.stderr.exp
Normal file
20
callgrind/tests/simwork1.stderr.exp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
Events : Ir Dr Dw I1mr D1mr D1mw I2mr D2mr D2mw
|
||||
Collected :
|
||||
|
||||
I refs:
|
||||
I1 misses:
|
||||
L2i misses:
|
||||
I1 miss rate:
|
||||
L2i miss rate:
|
||||
|
||||
D refs:
|
||||
D1 misses:
|
||||
L2d misses:
|
||||
D1 miss rate:
|
||||
L2d miss rate:
|
||||
|
||||
L2 refs:
|
||||
L2 misses:
|
||||
L2 miss rate:
|
||||
1
callgrind/tests/simwork1.stdout.exp
Normal file
1
callgrind/tests/simwork1.stdout.exp
Normal file
@ -0,0 +1 @@
|
||||
Sum: 1000000
|
||||
3
callgrind/tests/simwork1.vgtest
Normal file
3
callgrind/tests/simwork1.vgtest
Normal file
@ -0,0 +1,3 @@
|
||||
prog: simwork
|
||||
vgopts: --simulate-hwpref=yes
|
||||
cleanup: rm callgrind.out.*
|
||||
20
callgrind/tests/simwork2.stderr.exp
Normal file
20
callgrind/tests/simwork2.stderr.exp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
Events : Ir Dr Dw I1mr D1mr D1mw I2mr D2mr D2mw I2dmr D2dmr D2dmw
|
||||
Collected :
|
||||
|
||||
I refs:
|
||||
I1 misses:
|
||||
L2i misses:
|
||||
I1 miss rate:
|
||||
L2i miss rate:
|
||||
|
||||
D refs:
|
||||
D1 misses:
|
||||
L2d misses:
|
||||
D1 miss rate:
|
||||
L2d miss rate:
|
||||
|
||||
L2 refs:
|
||||
L2 misses:
|
||||
L2 miss rate:
|
||||
1
callgrind/tests/simwork2.stdout.exp
Normal file
1
callgrind/tests/simwork2.stdout.exp
Normal file
@ -0,0 +1 @@
|
||||
Sum: 1000000
|
||||
3
callgrind/tests/simwork2.vgtest
Normal file
3
callgrind/tests/simwork2.vgtest
Normal file
@ -0,0 +1,3 @@
|
||||
prog: simwork
|
||||
vgopts: --simulate-wb=yes --simulate-hwpref=yes
|
||||
cleanup: rm callgrind.out.*
|
||||
20
callgrind/tests/simwork3.stderr.exp
Normal file
20
callgrind/tests/simwork3.stderr.exp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
|
||||
Events : Ir Dr Dw I1mr D1mr D1mw I2mr D2mr D2mw AcCost1 SpLoss1 AcCost2 SpLoss2
|
||||
Collected :
|
||||
|
||||
I refs:
|
||||
I1 misses:
|
||||
L2i misses:
|
||||
I1 miss rate:
|
||||
L2i miss rate:
|
||||
|
||||
D refs:
|
||||
D1 misses:
|
||||
L2d misses:
|
||||
D1 miss rate:
|
||||
L2d miss rate:
|
||||
|
||||
L2 refs:
|
||||
L2 misses:
|
||||
L2 miss rate:
|
||||
1
callgrind/tests/simwork3.stdout.exp
Normal file
1
callgrind/tests/simwork3.stdout.exp
Normal file
@ -0,0 +1 @@
|
||||
Sum: 1000000
|
||||
3
callgrind/tests/simwork3.vgtest
Normal file
3
callgrind/tests/simwork3.vgtest
Normal file
@ -0,0 +1,3 @@
|
||||
prog: simwork
|
||||
vgopts: --cacheuse=yes
|
||||
cleanup: rm callgrind.out.*
|
||||
47
callgrind/tests/threads.c
Normal file
47
callgrind/tests/threads.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* A simple example with 4 threads */
|
||||
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
double a[1000];
|
||||
|
||||
static void init()
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<1000;i++) a[i] = (double)i;
|
||||
}
|
||||
|
||||
static void *th(void *v)
|
||||
{
|
||||
double sum = 0.0;
|
||||
int i,j;
|
||||
|
||||
for(j=0;j<1000;j++)
|
||||
for(i=0;i<1000;i++)
|
||||
sum += a[i];
|
||||
|
||||
*( (double*)v ) = sum;
|
||||
|
||||
/* make sure that no threads is so fast that it finishes
|
||||
* before last thread is created, thus reusing the TID */
|
||||
sleep(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
pthread_t t[4];
|
||||
double sum[4];
|
||||
int i;
|
||||
|
||||
init();
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
pthread_create(&t[i], NULL, th, &sum[i]);
|
||||
|
||||
for(i=0;i<4;i++)
|
||||
pthread_join(t[i], NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
6
callgrind/tests/threads.stderr.exp
Normal file
6
callgrind/tests/threads.stderr.exp
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
Events : Ir
|
||||
Collected :
|
||||
|
||||
I refs:
|
||||
3
callgrind/tests/threads.vgtest
Normal file
3
callgrind/tests/threads.vgtest
Normal file
@ -0,0 +1,3 @@
|
||||
prog: threads
|
||||
vgopts: --separate-threads=yes
|
||||
cleanup: rm callgrind.out.*
|
||||
Loading…
x
Reference in New Issue
Block a user