MPI_File_read_at函数与C语言中的fread函数,依次读取一个100M的文件,读取时间如下所示:
实验一:
[zhangyang@mpi002 kmeans_exper]$ mpiexec -np 1 ./mpi_c_fspeed
There are 1500015 samples...
Start test mpi_file_read....
In mpi002 mpi_file_read takes 1.566990137100 seconds...
Start test fread....
In mpi002 fread takes 0.078104019165 seconds...
实验二:
[zhangyang@mpi002 kmeans_exper]$ mpiexec -np 1 ./mpi_c_fspeed
There are 1500000 samples...
Start test mpi_file_read....
In mpi002 mpi_file_read takes 1.315994024277 seconds...
Start test fread....
In mpi002 fread takes 1.259196043015 seconds...
两次实验具有不同的结果,原因是:
实验一:MPI_File_read_at与fread读取同一数据块,MPI先读,fread后读,因此,MPI花费的时间较多
fread花费的时间较短,主要是受到了缓存的