mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-11 16:01:00 +08:00
[svn-r439] Changed the PHDF test programs substantially. Used to be just one
big testphdf5.c file. Broke it into modules of related routines. testphdf5.c -- main routine and global variables initialization plus some ulitility routines. t_file.c -- tests of file operations using parallel I/O. t_dset.c -- tests of datasets operations.
This commit is contained in:
parent
0b5e6ee7a1
commit
a9b794a012
@ -24,7 +24,7 @@ MOSTLYCLEAN=ParaEg1.h5f ParaEg2.h5f
|
||||
DISTCLEAN=go
|
||||
|
||||
# The default is to build the library and programs.
|
||||
all: testphdf5
|
||||
all: progs
|
||||
|
||||
|
||||
# These are our main targets. They should be listed in the order to be
|
||||
@ -36,10 +36,10 @@ TESTS=$(PROGS)
|
||||
# source files and is used for things like dependencies, archiving, etc. The
|
||||
# other source lists are for the individual tests, the files of which may
|
||||
# overlap with other tests.
|
||||
PROG_SRC=testphdf5.c
|
||||
PROG_SRC=testphdf5.c t_dset.c t_file.c
|
||||
PROG_OBJ=$(PROG_SRC:.c=.o)
|
||||
|
||||
TESTPHDF5_SRC=testphdf5.c
|
||||
TESTPHDF5_SRC=testphdf5.c t_dset.c t_file.c
|
||||
TESTPHDF5_OBJ=$(TESTPHDF5_SRC:.c=.o)
|
||||
|
||||
# Private header files (not to be installed)...
|
||||
@ -92,7 +92,7 @@ distclean: clean
|
||||
maintainer-clean: distclean
|
||||
|
||||
# Implicit rules
|
||||
.c.o:
|
||||
.c.o: testphdf5.h
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
||||
|
||||
|
||||
|
1009
testpar/t_dset.c
Normal file
1009
testpar/t_dset.c
Normal file
File diff suppressed because it is too large
Load Diff
80
testpar/t_file.c
Normal file
80
testpar/t_file.c
Normal file
@ -0,0 +1,80 @@
|
||||
/* $Id$ */
|
||||
|
||||
/*
|
||||
* Parallel tests for file operations
|
||||
*/
|
||||
|
||||
#include <testphdf5.h>
|
||||
|
||||
/*
|
||||
* 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
|
||||
test_split_comm_access(char *filename[])
|
||||
{
|
||||
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 */
|
||||
herr_t ret; /* generic return value */
|
||||
|
||||
if (verbose)
|
||||
printf("Split Communicator access test on file %s %s\n",
|
||||
filename[0], filename[1]);
|
||||
|
||||
/* 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 */
|
||||
acc_tpl = H5Pcreate (H5P_FILE_ACCESS);
|
||||
VRFY((acc_tpl != FAIL), "");
|
||||
|
||||
/* set Parallel access with communicator */
|
||||
ret = H5Pset_mpi(acc_tpl, comm, info);
|
||||
VRFY((ret != FAIL), "");
|
||||
|
||||
/* create the file collectively */
|
||||
fid=H5Fcreate(filename[color],H5F_ACC_TRUNC,H5P_DEFAULT,acc_tpl);
|
||||
VRFY((fid != FAIL), "H5Fcreate succeed");
|
||||
|
||||
/* Release file-access template */
|
||||
ret=H5Pclose(acc_tpl);
|
||||
VRFY((ret != FAIL), "");
|
||||
|
||||
/* close the file */
|
||||
ret=H5Fclose(fid);
|
||||
VRFY((ret != FAIL), "");
|
||||
|
||||
/* detele the test file */
|
||||
if (sub_mpi_rank == 0){
|
||||
mrc = MPI_File_delete(filename[color], info);
|
||||
VRFY((mrc==MPI_SUCCESS), "");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user