Date: 2022-03-31T04:49:09+00:00

Actual source code: PetscMemcmp.c

      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;
     10:   PetscBool      flg;

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

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

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

     49:   PetscFinalize();
     50:   return 0;
     51: }