Changeset 2584 in Sophya for trunk/Eval


Ignore:
Timestamp:
Jul 30, 2004, 1:04:18 PM (21 years ago)
Author:
ansari
Message:

Ajout test simple boucle (fop0) ds cpupower.c - Reza 30/07/2004

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Eval/Speed/cpupower.c

    r2553 r2584  
    1717#define  T_Type  double
    1818
    19 static int SZ;                    /* Taille de tableau */
    20 static double N_OP;               /* Nb operations */
    21 static  int OPE;                  /* Choix Operation fop_1/2/3/4    */
    22 static int ckprt;                 /* > 0 : Print check apres calcul */
     19static int SZ=20000;                    /* Taille de tableau */
     20static double N_OP=0;               /* Nb operations */
     21static  int OPE=0;                  /* Choix Operation fop_1/2/3/4    */
     22static int ckprt=0;                 /* > 0 : Print check apres calcul */
    2323
    2424/*  Tableaux X,Y,Z   */
     
    2626static T_Type * y;
    2727static T_Type * z;
     28
     29void fop_0()
     30{
     31  T_Type s=0;
     32  int i,k;
     33  printf("--- fop_0: Simple Loop: z[k] = x[k]*y[i] --- \n");
     34  for(k=0; k<SZ; k++) z[k] = x[k]*y[k];
     35  N_OP += SZ;
     36  return;
     37}
    2838
    2939void fop_1()
     
    101111{
    102112  int maxnprt = 1000;
     113  int nloop = 1000;
    103114  int i,nprt;
    104115  double mflops;
     
    109120  if (narg < 2) {
    110121    printf("--- Programme cpupower: (Puissance de calcul) ---- \n");
    111     printf("  Usage cpupower Op=1/2/3 [Size=20000] [CkPrt=0] \n");
     122    printf("  Usage cpupower Op=0/1/2/3/4/5 [Size=20000] [NLoop=1000] [CkPrt=0]\n");
     123    printf("  Op=0 Simple Loop: z[k] = x[k]*y[k]  effectue NLoop fois\n");
     124    printf("    Size=10^6 par defaut, NLoop=100 \n");
    112125    printf("  Op=1 Double Loop: z[k] = Somme_i(x[k]*y[i])  \n");
    113126    printf("    Op=1 *,+=2 op / tour de boucle \n");
     
    120133    printf("  Op=5 Double Loop: z[k] = Somme_i(x[k]*sin(y[i])+log(fabs(x[i])+0.1)+y[k]) \n");
    121134    printf("    Op=5   ~ 100 op float /  tour de boucle \n");
     135    printf("    Test 4,5 Size=2000 par defaut  \n");
    122136    return 1;
    123137  }
    124138  OPE = atoi(arg[1]);
    125139  SZ = 20000;
     140  if (OPE == 0) SZ = 1000000;
     141  if (OPE >= 4) SZ = 2000;
    126142  if (narg > 2)  SZ = atoi(arg[2]);
     143  nloop = 100;
     144  if (narg > 3)  nloop = atoi(arg[3]);
    127145  ckprt = 0;
    128   if (narg > 3)  ckprt = atoi(arg[3]);
     146  if (narg > 3)  ckprt = atoi(arg[4]);
    129147
    130148  printf("::::::: cpupower: OPE=%d SZ= %d ::::::: \n", OPE,SZ);
     
    136154    x[i] = (T_Type)((random()%10000)-5000); 
    137155    y[i] = (T_Type)((random()%10000)-5000); 
    138     y[i] = (T_Type)(0);
     156    z[i] = (T_Type)(0);
    139157  }
    140158  PrtTim("--Fin malloc+init x,y,z ");
     159  N_OP = 0;
    141160  if (OPE == 5)  fop_5();
    142161  else if (OPE == 4)  fop_4();
    143162  else if (OPE == 3)  fop_3();
    144163  else if (OPE == 2)  fop_2();
    145   else fop_1();
     164  else if (OPE == 1)  fop_1();
     165  else for(i=0; i<nloop; i++) fop_0();
    146166  PrtTim("---Fin OpeDoubleBoucle ");
    147167  mflops = N_OP/ GetPartialCPUTime()*1.e-6;
Note: See TracChangeset for help on using the changeset viewer.