#include #include #ifndef SINGLE #include #else #include #endif #define space_loop for(x=0;x%d (%d) %d (%.3e MB of %.3e MB total)\n" ,rank, lxs, lxs+lnx,lnx, lyst, lsize*sizeof(fftw_complex)*1.0e-6, nn*nn*nn*sizeof(fftw_complex)*1.0e-6); /* malloc data and work vectors */ t1 = MPI_Wtime(); data = (fftw_complex*) malloc(sizeof(fftw_complex) * lsize); if(!data) {printf("malloc failed for data (task = %d)\n",rank);} work = (fftw_complex*) malloc(sizeof(fftw_complex) * lsize); if(!data) {printf("malloc failed for work (task = %d)\n",rank);} t2 = MPI_Wtime(); if(!rank) { printf("time to malloc(%d total = %d tasks * %d l) ... %.3e\n", nn*nn*nn,numtasks,lsize,t2-t1); } space_loop{ data[(x*ny + y) * nz + z].re = 1.0; data[(x*ny + y) * nz + z].im = 0.0; /* printf("input %d %d %d %.3e %.3e\n", x+lxs, y, z, data[(x*ny + y) * nz + z].re, data[(x*ny + y) * nz + z].im); */ } for(it = 1; it<=nit; it++) { t1 = MPI_Wtime(); fftwnd_mpi(plan, 1, data, work, FFTW_TRANSPOSED_ORDER); fftwnd_mpi(iplan, 1, data, work, FFTW_TRANSPOSED_ORDER); t2 = MPI_Wtime(); err = myerr = 0.0; space_loop{ myerr += (nn*nn*nn-data[(x*ny + y) * nz + z].re)* (nn*nn*nn-data[(x*ny + y) * nz + z].re) + (data[(x*ny + y) * nz + z].im)* (data[(x*ny + y) * nz + z].im); } if(myerr > 0.0) printf("ERROR:: rank=%d myerr=%.3e on iter %d \n", rank,myerr,it); if(!rank && it%(nit/10)==0) printf("progress:: %d %% complete\n", 100*it/nit); space_loop{ data[(x*ny + y) * nz + z].re = 1.0; data[(x*ny + y) * nz + z].im = 0.0; } } free(data); free(work); fftwnd_mpi_destroy_plan(plan); fftwnd_mpi_destroy_plan(iplan); MPI_Finalize(); if(!rank) { gettimeofday(&tv,NULL); printf("MPI_Finalize done at %d\n", tv.tv_sec); tf=tv.tv_sec; printf("total_time:: %.3e seconds\n", tf-ti); } }