1 2 #include <petscsys.h> 3 #include <petsctime.h> 4 5 int main(int argc,char **argv) 6 { 7 PetscLogDouble x,y; 8 PetscScalar *A,*B; 9 10 PetscCall(PetscInitialize(&argc,&argv,0,0)); 11 PetscCall(PetscCalloc1(8000000,&A)); 12 PetscCall(PetscMalloc1(8000000,&B)); 13 14 for (i=0; i<8000000; i++) { 15 A[i] = i%61897; 16 B[i] = i%61897; 17 } 18 /* To take care of paging effects */ 19 PetscCall(PetscArraycpy(A,B,8000000)); 20 PetscCall(PetscTime(&x)); 21 PetscCall(PetscArraycpy(A,B,8000000)); 22 PetscCall(PetscTime(&x)); 23 24 fprintf(stdout,"%s : \n","PetscMemcpy"); 25 fprintf(stdout," %-15s : %e MB/s\n","Bandwidth",10.0*8*8/(y-x)); 26 27 PetscCall(PetscFree(A)); 28 PetscCall(PetscFree(B)); 29 PetscCall(PetscFinalize()); 30 return 0; 31 } 32