Array size for stats was iterations/numcpus.
Concurrent threads used to write their stats in the same rows,
overwriting each other's results.
This patch makes array size = iterations
and threads not overlapping their results by shifting their
index.
Signed-off-by: Gilles Carry <[EMAIL PROTECTED]>
---
testcases/realtime/func/matrix_mult/matrix_mult.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/testcases/realtime/func/matrix_mult/matrix_mult.c
b/testcases/realtime/func/matrix_mult/matrix_mult.c
index 78f3d46..e89aeee 100644
--- a/testcases/realtime/func/matrix_mult/matrix_mult.c
+++ b/testcases/realtime/func/matrix_mult/matrix_mult.c
@@ -64,7 +64,6 @@ static int run_jvmsim = 0;
static int ops = DEF_OPS;
static int numcpus;
static float criteria;
-static int *mult_index;
static int *tids;
static int online_cpu_id = -1;
static int iterations = ITERATIONS;
@@ -179,6 +178,7 @@ void *concurrent_thread(void *thread)
int thread_id = (intptr_t)t->arg;
int cpuid;
int i;
+ int index;
cpuid = set_affinity();
if (cpuid == -1) {
@@ -189,9 +189,10 @@ void *concurrent_thread(void *thread)
printf("Thread %d: Affinity set to cpu%d\n", thread_id,
cpuid);
}
+ index = iterations_percpu * thread_id; /* To avoid stats overlapping */
pthread_barrier_wait(&mult_start);
for (i=0; i < iterations_percpu; i++)
- matrix_mult_record(MATRIX_SIZE, mult_index[thread_id]++);
+ matrix_mult_record(MATRIX_SIZE, index++);
return NULL;
}
@@ -207,7 +208,7 @@ void main_thread(void)
if ( stats_container_init(&sdat, iterations) ||
stats_container_init(&shist, HIST_BUCKETS) ||
- stats_container_init(&cdat, iterations_percpu) ||
+ stats_container_init(&cdat, iterations) ||
stats_container_init(&chist, HIST_BUCKETS)
)
{
@@ -215,12 +216,6 @@ void main_thread(void)
exit(1);
}
- mult_index = malloc(sizeof(int) * numcpus);
- if (!mult_index) {
- perror("malloc");
- exit(1);
- }
- memset(mult_index, 0, numcpus);
tids = malloc(sizeof(int) * numcpus);
if (!tids) {
perror("malloc");
@@ -349,6 +344,7 @@ int main(int argc, char *argv[])
printf("Rounding up iterations value to nearest multiple of
total online CPUs\n");
iterations = new_iterations;
+ iterations_percpu = iterations / numcpus;
printf("Running %d iterations\n", iterations);
printf("Matrix Dimensions: %dx%d\n", MATRIX_SIZE, MATRIX_SIZE);
--
1.5.5.GIT
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list