pnetcdf-write-nb.c non-blocking

Wei-keng Liao wkliao at eecs.northwestern.edu
Mon Sep 7 17:12:14 CDT 2015


Hi, Wadud

Yes, the user write buffers in ncmpi_iput calls will be used to write to the file.
However, the actual writes will not happen until the call to ncmpi_wait_all.
Thus, modifying the contents of those user write buffers before the wait will
cause incorrect data written to the file.

Similar for the read cases, the user read buffers will only contain the
correct data from file once the wait call is complete.

There is another set of APIs, called buffered write APIs ncmpi_bput_xxx,
which make a copy of user write buffers internally in PnetCDF library.
You can touch (or even free) the write buffer once the call returns.
Please see the example program pnetcdf-write-buffered.c.


Wei-keng

On Sep 7, 2015, at 4:58 PM, W. Miah wrote:

> Hi Wei-Keng,
> 
> Many thanks for the quick reply. From my understand, the write buffers
> for non-blocking can be the same for writing to disk but have to be
> different for reading from disk. So I guess by what you mean by
> "touched" is that they cannot even be read until the corresponding
> wait subroutine has passed.
> 
> Thanks for the clarification.
> Wadud.
> 
> On 7 September 2015 at 22:25, Wei-keng Liao
> <wkliao at eecs.northwestern.edu> wrote:
>> Hi,
>> 
>> The example program is buggy.
>> The write buffers for the two iput calls should be different.
>> FYI. Once a nonblocking iput/iget API is posted, the contents
>> of the buffers should not be touched before the call to
>> ncmpi_wait_all/ncmpi_wait. Otherwise, the results can be incorrect.
>> 
>> Please see the bug fix in http://trac.mcs.anl.gov/projects/parallel-netcdf/changeset/2095
>> Thanks for reporting this problem.
>> 
>> Wei-keng
>> 
>> On Sep 7, 2015, at 1:52 PM, W. Miah wrote:
>> 
>>> Hello,
>>> 
>>> I have downloaded pNetCDF and am browsing through the example code
>>> parallel-netcdf-1.6.0/examples/tutorial/pnetcdf-write-nb.c (attached
>>> with this email) which should write the MPI ranks into two arrays, but
>>> instead seems to be writing random values:
>>> 
>>> [miahw at bengal tutorial]$ ncdump output.nc
>>> netcdf output {
>>> dimensions:
>>>   d1 = 4 ;
>>> variables:
>>>   int v1(d1) ;
>>>   int v2(d1) ;
>>> 
>>> // global attributes:
>>>       :string = "Hello World\n",
>>>           "" ;
>>> data:
>>> 
>>> v1 = 0, 16777216, 33554432, 50331648 ;
>>> 
>>> v2 = 0, 16777216, 33554432, 50331648 ;
>>> }
>>> 
>>> I have looked at the code but can't see anything wrong with it. Could
>>> it be that the library has a bug?
>>> 
>>> Regards,
>>> 
>>> --
>>> web: http://miahw.wordpress.com
>>> gnupg: 2E29 B22F
>>> <pnetcdf-write-nb.c>
>> 
> 
> 
> 
> -- 
> web: http://miahw.wordpress.com
> mobile: 07905 755604
> gnupg: 2E29 B22F



More information about the parallel-netcdf mailing list