Josef Weidendorfer efa0f1d7bd 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
2006-04-02 22:23:27 +00:00

48 lines
650 B
C

/* 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;
}