Actual source code: PetscMemcmp.c
petsc-3.10.5 2019-03-28
Report Typos and Errors

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

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

     13:   PetscInitialize(&argc,&argv,0,0);if (ierr) return ierr;
     14:   for (i=0; i<10000; i++) {
     15:     A[i] = i%61897;
     16:     B[i] = i%61897;
     17:   }
     18:   /* To take care of paging effects */
     19:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     20:   PetscTime(&x);

     22:   PetscTime(&x);
     23:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     24:   PetscMemcmp(A,B,sizeof(PetscScalar)*10000,&flg);
     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:   PetscTime(&y);
     34:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     35:   PetscMemcmp(A,B,sizeof(PetscScalar)*0,&flg);
     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:   PetscTime(&z);

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

     50:   PetscFinalize();
     51:   return ierr;
     52: }