Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Tsss... :)
[simgrid.git] / examples / gras / chrono / chrono.c
1 /* $Id$ */
2
3 /* chrono - demo of GRAS benchmarking features                              */
4
5 /* Copyright (c) 2005 Martin Quinson, Arnaud Legrand. All rights reserved.  */
6
7 /* This program is free software; you can redistribute it and/or modify it
8  * under the terms of the license (GNU LGPL) which comes with this package. */
9
10 #include "gras.h"
11
12 XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono,"Messages specific to this example");
13
14
15 /* Function prototypes */
16 int multiplier (int argc,char *argv[]);
17
18 int multiplier (int argc,char *argv[])
19 {
20   int i,j,k;
21   double *A,*B,*C;
22   int n = 500;
23   gras_init(&argc, argv, NULL);
24   
25   A = malloc(n*n*sizeof(double));
26   B = malloc(n*n*sizeof(double));
27   C = malloc(n*n*sizeof(double));
28
29   INFO1("Before computation : %lg", gras_os_time());
30   for(i=0; i<n; i++)
31     for(j=0; j<n; j++) {
32       A[i*n+j]=2/n;
33       B[i*n+j]=1/n;
34       C[i*n+j]=0.0;
35     }
36
37   for(i=0; i<n; i++)
38     for(j=0; j<n; j++)
39       for(k=0; k<n; k++)        
40         C[i*n+j] += A[i*n+k]*B[k*n+j];
41
42   INFO1("After computation : %lg", gras_os_time());
43
44   return 0;
45 }