#include #include #include /* * This program measures the time for copying a dataset of 32M size * between two parallel HDF5 files. The dataset has a contiguous layout, * which means the dataset object consists of metadata and raw data. * * mpicc -Wall -O2 -o h5copy_mpio h5copy_mpio.c -lhdf5 */ int main(int argc, char **argv) { double start, stop; int step, rank, i; hid_t file1, file2, fapl, space, dset; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); fapl = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL); file1 = H5Fcreate("h5copy_mpio_1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); hsize_t dims[1] = {4194304}; space = H5Screate_simple(1, dims, NULL); dset = H5Dcreate(file1, "position", H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); H5Sclose(space); H5Dclose(dset); H5Fflush(file1, H5F_SCOPE_LOCAL); H5Fclose(file1); file1 = H5Fopen("h5copy_mpio_1.h5", H5F_ACC_RDONLY, fapl); file2 = H5Fcreate("h5copy_mpio_2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); start = MPI_Wtime(); H5Ocopy(file1, "position", file2, "position", H5P_DEFAULT, H5P_DEFAULT); H5Fflush(file2, H5F_SCOPE_LOCAL); stop = MPI_Wtime(); if (rank == 0) printf("%.3g s\n", stop-start); H5Fclose(file1); H5Fclose(file2); H5Pclose(fapl); MPI_Finalize(); }