2003-04-01 02:02:10 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
|
|
|
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
1998-07-02 05:33:35 +08:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parallel tests for file operations
|
|
|
|
*/
|
|
|
|
|
2001-04-06 01:09:42 +08:00
|
|
|
#include "testphdf5.h"
|
1998-07-02 05:33:35 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* test file access by communicator besides COMM_WORLD.
|
|
|
|
* Split COMM_WORLD into two, one (even_comm) contains the original
|
|
|
|
* processes of even ranks. The other (odd_comm) contains the original
|
|
|
|
* processes of odd ranks. Processes in even_comm creates a file, then
|
|
|
|
* cloose it, using even_comm. Processes in old_comm just do a barrier
|
|
|
|
* using odd_comm. Then they all do a barrier using COMM_WORLD.
|
|
|
|
* If the file creation and cloose does not do correct collective action
|
|
|
|
* according to the communicator argument, the processes will freeze up
|
|
|
|
* sooner or later due to barrier mixed up.
|
|
|
|
*/
|
|
|
|
void
|
2000-01-26 12:33:38 +08:00
|
|
|
test_split_comm_access(char *filename)
|
1998-07-02 05:33:35 +08:00
|
|
|
{
|
|
|
|
int mpi_size, mpi_rank;
|
|
|
|
MPI_Comm comm;
|
|
|
|
MPI_Info info = MPI_INFO_NULL;
|
|
|
|
int color, mrc;
|
|
|
|
int newrank, newprocs;
|
|
|
|
hid_t fid; /* file IDs */
|
|
|
|
hid_t acc_tpl; /* File access properties */
|
2003-05-06 04:48:33 +08:00
|
|
|
hbool_t use_gpfs = FALSE; /* Use GPFS hints */
|
1998-07-02 05:33:35 +08:00
|
|
|
herr_t ret; /* generic return value */
|
|
|
|
|
|
|
|
if (verbose)
|
2000-01-26 12:33:38 +08:00
|
|
|
printf("Split Communicator access test on file %s\n",
|
|
|
|
filename);
|
1998-07-02 05:33:35 +08:00
|
|
|
|
|
|
|
/* set up MPI parameters */
|
|
|
|
MPI_Comm_size(MPI_COMM_WORLD,&mpi_size);
|
|
|
|
MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank);
|
|
|
|
color = mpi_rank%2;
|
|
|
|
mrc = MPI_Comm_split (MPI_COMM_WORLD, color, mpi_rank, &comm);
|
|
|
|
VRFY((mrc==MPI_SUCCESS), "");
|
|
|
|
MPI_Comm_size(comm,&newprocs);
|
|
|
|
MPI_Comm_rank(comm,&newrank);
|
|
|
|
|
|
|
|
if (color){
|
|
|
|
/* odd-rank processes */
|
|
|
|
mrc = MPI_Barrier(comm);
|
|
|
|
VRFY((mrc==MPI_SUCCESS), "");
|
|
|
|
}else{
|
|
|
|
/* even-rank processes */
|
|
|
|
int sub_mpi_rank; /* rank in the sub-comm */
|
|
|
|
MPI_Comm_rank(comm,&sub_mpi_rank);
|
|
|
|
|
|
|
|
/* setup file access template */
|
2003-05-06 04:48:33 +08:00
|
|
|
acc_tpl = create_faccess_plist(comm, info, facc_type, use_gpfs);
|
1999-02-17 12:39:22 +08:00
|
|
|
VRFY((acc_tpl >= 0), "");
|
1998-07-02 05:33:35 +08:00
|
|
|
|
|
|
|
/* create the file collectively */
|
2000-01-26 12:33:38 +08:00
|
|
|
fid=H5Fcreate(filename,H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl);
|
1999-02-17 12:39:22 +08:00
|
|
|
VRFY((fid >= 0), "H5Fcreate succeeded");
|
1998-07-02 05:33:35 +08:00
|
|
|
|
|
|
|
/* Release file-access template */
|
|
|
|
ret=H5Pclose(acc_tpl);
|
1999-02-17 12:39:22 +08:00
|
|
|
VRFY((ret >= 0), "");
|
1998-07-02 05:33:35 +08:00
|
|
|
|
|
|
|
/* close the file */
|
|
|
|
ret=H5Fclose(fid);
|
1999-02-17 12:39:22 +08:00
|
|
|
VRFY((ret >= 0), "");
|
1998-07-02 05:33:35 +08:00
|
|
|
|
|
|
|
/* detele the test file */
|
|
|
|
if (sub_mpi_rank == 0){
|
2000-01-26 12:33:38 +08:00
|
|
|
mrc = MPI_File_delete(filename, info);
|
2001-11-02 23:21:51 +08:00
|
|
|
/*VRFY((mrc==MPI_SUCCESS), ""); */
|
1998-07-02 05:33:35 +08:00
|
|
|
}
|
|
|
|
}
|
2000-12-13 07:12:57 +08:00
|
|
|
mrc = MPI_Barrier(MPI_COMM_WORLD);
|
|
|
|
VRFY((mrc==MPI_SUCCESS), "final MPI_Barrier succeeded");
|
1998-07-02 05:33:35 +08:00
|
|
|
}
|
1999-01-27 12:12:04 +08:00
|
|
|
|
|
|
|
|