[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #MUE-314708]: Issue with NetCDF with PGI beta compilers on POWER



Hi Chris,

Thank you for the detailed email; I appreciate the forensic work you and your 
developer have done.  The same issue was identified on ARM platforms after 
4.4.0 was released, and the recently-released 4.4.1 has a slightly different 
fix in place for this issue.  It achieves the same result in a slightly 
different fashion.

I do not have PGI compilers to test against, so I would be very interested to 
know if the issue persists with our fix in versions 4.4.1 or later.  Would it 
be possible to test this version on your end?

Thanks again for your work on this; it is very much appreciated!

Have a great day,

-Ward

> Greetings,
> 
> I wanted to reach out to you regarding an issue with NetCDF that we
> discovered here at PGI while testing the 16.7-beta version of our
> compilers on the POWER architecture.  These compilers use LLVM as a
> backend for generating code on POWER.
> 
> I am testing NetCDF 4.4.0 here, though I note that 4.4.1 is now available
> from your website.  I am testing against a PGI 16.7-beta build of
> HDF5 1.8.15-patch1, although again, I do recognize newer versions are
> available.
> 
> NetCDF 4.4.0 builds fine with PGI 16.7-beta on POWER.  However, when I
> run the t est suite via "make check", I get a test failure:
> 
> make[4]: Entering directory `/tmp/qa/netcdf_app_0/netcdf-4.4.0/nc_test'
> PASS: t_nc
> PASS: tst_small
> FAIL: nc_test
> PASS: tst_misc
> PASS: tst_norm
> PASS: tst_names
> PASS: tst_nofill
> PASS: tst_nofill2
> PASS: tst_nofill3
> PASS: tst_atts3
> PASS: tst_meta
> PASS: tst_atts
> PASS: tst_put_vars
> PASS: run_diskless.sh
> ============================================================================
> Testsuite summary for netCDF 4.4.0
> ============================================================================
> # TOTAL: 14
> # PASS: 13
> # SKIP: 0
> # XFAIL: 0
> # FAIL: 1
> # XPASS: 0
> # ERROR: 0
> ============================================================================
> See nc_test/test-suite.log
> Please report to address@hidden
> ============================================================================
> make[4]: *** [test-suite.log] Error 1
> make[4]: Leaving directory `/tmp/qa/netcdf_app_0/netcdf-4.4.0/nc_test'
> make[3]: *** [check-TESTS] Error 2
> make[3]: Leaving directory `/tmp/qa/netcdf_app_0/netcdf-4.4.0/nc_test'
> make[2]: *** [check-am] Error 2
> make[2]: Leaving directory `/tmp/qa/netcdf_app_0/netcdf-4.4.0/nc_test'
> make[1]: *** [check-recursive] Error 1
> make[1]: Leaving directory `/tmp/qa/netcdf_app_0/netcdf-4.4.0'
> make: *** [run] Error 2
> 
> When I run the nc_test test by hand, I get a number of errors similar to the 
> following:
> 
> *** testing nc_get_att_schar ...
> FAILURE at line 8529 of test_get.c: value read not that expected
> FAILURE at line 8529 of test_get.c: value read not that expected
> 39 good comparisons.
> ### 2 FAILURES TESTING nc_get_att_schar! ###
> 
> Working with our developer here, we identified the following section
> of code in the function ncx_putn_uchar_double(), in the file ncx.c at
> around line 4842, as being problematic:
> 
> while(nelems-- != 0)
> {
> if(*tp > X_UCHAR_MAX || *tp < 0)
> status = NC_ERANGE;
> 
> *xp++ = (uchar) *tp++;
> }
> 
> In the failing case, *tp is the double value -1.0. This value cannot
> be represented by an unsigned char. The C standard, section 6.3.1.4,
> paragraph 1 reads
> 
> When a finite value of real floating type is converted to an integer
> type other than _Bool, the fractional part is discarded (i.e., the value
> is truncated toward zero). If the value of the integral part cannot be
> represented by the integer type, the behavior is und efined.61)
> 
> The behavior of this operation is undefined. pgcc and gcc apparently
> convert this to 0 while clang converts to 255. Since the behavior is
> undefined, the test is not well-defined.
> 
> I have worked around this issue in the code by doing explicit conversions
> to convert the double values to unsigned chars:
> 
> int i;
> signed char c;
> 
> while(nelems-- != 0)
> {
> if(*tp > X_UCHAR_MAX || *tp < 0)
> status = NC_ERANGE;
> 
> i = (int) *tp++;
> c = (signed char) i;
> *xp++ = (uchar) c;
> }
> 
> This ensures that NetCDF writes out the expected values with all
> compilers.  I also applied similar fixes to ncx_putn_uchar_float(),
> ncx_pad_putn_uchar_float(), and ncx_pad_putn_uchar_double().  With all
> of these functions fixed, the test suite now completely passes with the
> PGI 16.7-beta compilers on POWER.
> 
> I have attached a patch of the ncx.c file versus the stock 4.4.0 version
> for your perusal.  Please consider fixing this in a future release
> of NetCDF.
> 
> Thanks in advance,
> 
> +chris
> 
> --
> Chris Parrott
> Applications Engineer
> NVIDIA, Inc. / The Portland Group
> address@hidden<mailto:address@hidden>
> address@hidden<mailto:address@hidden>
> 
> -----------------------------------------------------------------------------------
> This email message is for the sole use of the intended recipient(s)
> and may contain confidential information.  Any unauthorized review, use,
> disclosure or distribution is prohibited.  If you are not the intended
> recipient, please contact the sender by reply email and destroy all
> copies of the original message.
> -----------------------------------------------------------------------------------
> 
> 


Ticket Details
===================
Ticket ID: MUE-314708
Department: Support netCDF
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.