Please redirect me to a more appropriate list/forum if this question is not of interest...
When writing data using collective IO, I have N processes participating, but occasionally, one or more processes has an empty dataset and nothing to write.
Due to the way the code is structured, empty processes do not know the type of the data that other processes are writing. It may be a list of float/double/int/long etc etc, usually, the processes check the type using C++ rtti and then do the write.
Processes with no data - cannot query the information, and so can't send a NULL pointer with zero size because I don't know which routine is being called (which datatype)
By way of example, we have a series of templates, which use macros so that for any datatype, we end up here ...
// A Convenience Macro which does what we want for any dataset type
// note that we use a dummy parameter and the ## macro operator to delay expansion
// of the T2 parameter which causes problems if we don't
#define WriteDataArray(null, T2, f, name, dataarray) \
sprintf(typestring, "%s", #T2); \
dataset = H5Dcreate(f->timegroup, name.c_str(), null##T2, f->shape, H5P_DEFAULT); \
if (dataset<0) { \
ErrorMacro(<<"Dataset create failed for " << name.c_str() \
<< " Timestep " << f->timestep \
<< " Shape " << f->shape \
<< " Data Type " << #T2); \
r = -1; \
} else { \
void *dataptr = dataarray->GetVoidPointer(0); \
dataptr = dataptr ? dataptr : &buffer[0]; \
r = H5Dwrite(dataset, T2, memshape, diskshape, H5P_DEFAULT, dataptr); \
} \
H5Dclose(dataset);
And when calling H5Dcreate - we do not know what datatype we have ended up with (result of the ##macro expansion.
I realize that this is a bit strange, but it does work - providing all processes have something to write!
Is there any way for a process to simply skip being part of the IO when it has nothing? I don't want to create a new MPI_Group or anything, but tell proc N (or rather the controller that is waiting for something from it) that proc N is not sending anything.
When using independent IO, I do not need to worry, but collective causes trouble.
Apologies if I have made a mistake or explained badly, I'm revisiting some old code after a bit of time away ...
thanks
JB
···
--
John Biddiscombe, email:biddisco @ cscs.ch
CSCS, Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
----------------------------------------------------------------------
This mailing list is for HDF software users discussion.
To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.
To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.