Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a boolean to each node indicating whether it's an internal node or not to allow...
[simgrid.git] / examples / gras / chrono / chrono.c
index c0c8888..eb31f9a 100644 (file)
@@ -8,6 +8,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "gras.h"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "gras.h"
+#include "xbt/log.h"
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono,"Messages specific to this example");
 
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(Chrono,"Messages specific to this example");
 
@@ -17,29 +18,38 @@ int multiplier (int argc,char *argv[]);
 
 int multiplier (int argc,char *argv[])
 {
 
 int multiplier (int argc,char *argv[])
 {
-  int i,j,k;
+  int i,j,k,l;
   double *A,*B,*C;
   int n = 500;
   double *A,*B,*C;
   int n = 500;
+  double start = 0.0;
+
   gras_init(&argc, argv, NULL);
   gras_init(&argc, argv, NULL);
-  
+
   A = malloc(n*n*sizeof(double));
   B = malloc(n*n*sizeof(double));
   C = malloc(n*n*sizeof(double));
 
   A = malloc(n*n*sizeof(double));
   B = malloc(n*n*sizeof(double));
   C = malloc(n*n*sizeof(double));
 
-  INFO1("Before computation : %lg", gras_os_time());
-  for(i=0; i<n; i++)
-    for(j=0; j<n; j++) {
-      A[i*n+j]=2/n;
-      B[i*n+j]=1/n;
-      C[i*n+j]=0.0;
-    }
-
-  for(i=0; i<n; i++)
-    for(j=0; j<n; j++)
-      for(k=0; k<n; k++)       
-       C[i*n+j] += A[i*n+k]*B[k*n+j];
-
-  INFO1("After computation : %lg", gras_os_time());
+  INFO1("Before computation: %lg", start=gras_os_time());
+
+  for(l=0; l<4; l++) {
+    GRAS_BENCH_ONCE_RUN_ONCE_BEGIN();
+    for(i=0; i<n; i++)
+      for(j=0; j<n; j++) {
+       A[i*n+j]=2/n;
+       B[i*n+j]=1/n;
+       C[i*n+j]=0.0;
+      }
+    
+    for(i=0; i<n; i++)
+      for(j=0; j<n; j++)
+       for(k=0; k<n; k++)      
+         C[i*n+j] += A[i*n+k]*B[k*n+j];
+    
+    GRAS_BENCH_ONCE_RUN_ONCE_END();
+  }
+
+  start = gras_os_time()-start;
+  INFO2("After computation: %lg; Duration: %lg ", gras_os_time(), start);
 
   return 0;
 }
 
   return 0;
 }