Actual source code: PetscMemcmp.c
petsc-3.7.1 2016-05-15
Report Typos and Errors

      2: #include <petscsys.h>
      3: #include <petsctime.h>

      7: int main(int argc,char **argv)
      8: {
      9:   PetscLogDouble x,y,z;
     10:   PetscScalar    A[10000],B[10000];
     11:   int            i,ierr;
     12:   PetscBool      flg;

     14:   PetscInitialize(&argc,&argv,0,0);

     16:   for (i=0; i<10000; i++) {
     17:     A[i] = i%61897;
     18:     B[i] = i%61897;
     19:   }
     20:   /* To take care of paging effects */
     21:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     22:   PetscTime(&x);

     24:   PetscTime(&x);
     25:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     26:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     27:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     28:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     29:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     30:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     31:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     32:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     33:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     34:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     35:   PetscTime(&y);
     36:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     37:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     38:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     39:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     40:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     41:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     42:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     43:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     44:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     45:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     46:   PetscTime(&z);

     48:   fprintf(stdout,"%s : \n","PetscMemcmp");
     49:   fprintf(stdout,"    %-15s : %e sec\n","Latency",(z-y)/10.0);
     50:   fprintf(stdout,"    %-15s : %e sec\n","Per PetscScalar",(2*y-x-z)/100000);

     52:   PetscFinalize();
     53:   return(0);
     54: }