Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Energy, onHostDestruction: ensured ptr existence
[simgrid.git] / examples / smpi / NAS / IS / is.c
index 01bd9dd..57b370b 100644 (file)
@@ -44,6 +44,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "simgrid/instr.h" //TRACE_
+
 /******************/
 /* default values */
 /******************/
@@ -257,7 +259,7 @@ const INT_TYPE2
 /***********************/
 /* function prototypes */
 /***********************/
-double randlc( double *X, double *A );
+double  randlc( double *X, double *A );
 
 void full_verify( global_data* gd );
 
@@ -271,7 +273,7 @@ void c_print_results( char   *name,
                       int    nprocs_total,
                       double t,
                       double mops,
-                     char   *optype,
+          char   *optype,
                       int    passed_verification,
                       char   *npbversion,
                       char   *compiletime,
@@ -343,17 +345,17 @@ double  timer_read(global_data* gd, int n ) {
 /*************    portable random number generator    ************/
 /*****************************************************************/
 
-double randlc( double *X, double *A )
+double  randlc( double *X, double *A )
 {
       static int        KS=0;
-      static double    R23, R46, T23, T46;
-      double           T1, T2, T3, T4;
-      double           A1;
-      double           A2;
-      double           X1;
-      double           X2;
-      double           Z;
-      int              i, j;
+      static double  R23, R46, T23, T46;
+      double    T1, T2, T3, T4;
+      double    A1;
+      double    A2;
+      double    X1;
+      double    X2;
+      double    Z;
+      int         i, j;
 
       if (KS == 0) 
       {
@@ -470,22 +472,22 @@ double   find_my_seed( int  kn,       /* my processor rank, 0<=kn<=num procs */
 /*************      C  R  E  A  T  E  _  S  E  Q      ************/
 /*****************************************************************/
 
-void   create_seq( global_data* gd, double seed, double a )
+void  create_seq( global_data* gd, double seed, double a )
 {
-       double x;
-       int    i, k;
+  double x;
+  int    i, k;
 
         k = MAX_KEY/4;
 
-       for (i=0; i<NUM_KEYS; i++)
-       {
-           x = randlc(&seed, &a);
-           x += randlc(&seed, &a);
-           x += randlc(&seed, &a);
-           x += randlc(&seed, &a);  
+  for (i=0; i<NUM_KEYS; i++)
+  {
+      x = randlc(&seed, &a);
+      x += randlc(&seed, &a);
+          x += randlc(&seed, &a);
+      x += randlc(&seed, &a);  
 
             gd->key_array[i] = k*x;
-       }
+  }
 }
 
 
@@ -702,7 +704,6 @@ void rank( global_data* gd, int iteration )
                   1,
                   MPI_INT,
                   MPI_COMM_WORLD );
-    MPI_Wtime();
 
 /*  Determine the receive array displacements for the buckets */    
     gd->recv_displ[0] = 0;
@@ -710,7 +711,6 @@ void rank( global_data* gd, int iteration )
         gd->recv_displ[i] = gd->recv_displ[i-1] + gd->recv_count[i-1];
 
 
-    MPI_Wtime();
 /*  Now send the keys to respective processors  */    
     MPI_Alltoallv( gd->key_buff1,
                    gd->send_count,
@@ -825,12 +825,12 @@ void rank( global_data* gd, int iteration )
                     break;
                 case 'A':
                     if( i <= 2 )
-                   {
+              {
                         if( key_rank != gd->test_rank_array[i]+(iteration-1) )
                             failed = 1;
                         else
                           gd->passed_verification++;
-                   }
+              }
                     else
                     {
                         if( key_rank !=  gd->test_rank_array[i]-(iteration-1) )
@@ -841,12 +841,12 @@ void rank( global_data* gd, int iteration )
                     break;
                 case 'B':
                     if( i == 1 || i == 2 || i == 4 )
-                   {
+              {
                         if( key_rank != gd->test_rank_array[i]+iteration )
                             failed = 1;
                         else
                             gd->passed_verification++;
-                   }
+              }
                     else
                     {
                         if( key_rank != gd->test_rank_array[i]-iteration )
@@ -857,12 +857,12 @@ void rank( global_data* gd, int iteration )
                     break;
                 case 'C':
                     if( i <= 2 )
-                   {
+              {
                         if( key_rank != gd->test_rank_array[i]+iteration )
                             failed = 1;
                         else
                             gd->passed_verification++;
-                   }
+              }
                     else
                     {
                         if( key_rank != gd->test_rank_array[i]-iteration )
@@ -873,12 +873,12 @@ void rank( global_data* gd, int iteration )
                     break;
                 case 'D':
                     if( i < 2 )
-                   {
+              {
                         if( key_rank != gd->test_rank_array[i]+iteration )
                             failed = 1;
                         else
                             gd->passed_verification++;
-                   }
+              }
                     else
                     {
                         if( key_rank != gd->test_rank_array[i]-iteration )
@@ -1027,13 +1027,17 @@ int main( int argc, char **argv )
     timer_start(gd, 2 );
 #endif
 
+    char smpi_category[100];
+    snprintf (smpi_category, 100, "%d", gd->my_rank);
+    TRACE_smpi_set_category (smpi_category);
+
 /*  This is the main iteration */
     for( iteration=1; iteration<=MAX_ITERATIONS; iteration++ )
     {
         if( gd->my_rank == 0 && CLASS != 'S' ) printf( "        %d\n", iteration );
         rank(gd,  iteration );
     }
-
+    TRACE_smpi_set_category (NULL);
 
 #ifdef  TIMING_ENABLED
     timer_stop(gd, 2 );