From 82ae8ac4e0ec0929e432c99361e68f5f60cb5553 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Fri, 25 Feb 2005 15:26:32 -0500 Subject: [svn-r10087] Purpose: New feature and test Description: Somehow, the hardware conversions between "long double" and other native floating-point types were left out. Solution: Added the hardware conversion functions in H5Tconv.c and test cases in dtypes.c. Platforms tested: h5committest and fuss. Misc. update: updated MANIFEST to replace bin/reconfigure.sh with bin/reconfigure --- MANIFEST | 2 +- src/H5Tconv.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/H5Tpkg.h | 23 ++++++++-- src/H5Tpublic.h | 2 +- test/dtypes.c | 8 +++- 5 files changed, 157 insertions(+), 8 deletions(-) diff --git a/MANIFEST b/MANIFEST index 6e058d5..0950b65 100644 --- a/MANIFEST +++ b/MANIFEST @@ -43,7 +43,7 @@ ./bin/missing ./bin/mkdirs ./bin/mkinstalldirs -./bin/reconfigure.sh _DO_NOT_DISTRIBUTE_ +./bin/reconfigure _DO_NOT_DISTRIBUTE_ ./bin/release ./bin/runtest _DO_NOT_DISTRIBUTE_ ./bin/snapshot diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 156287e..891d6f8 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -6984,6 +6984,38 @@ done: /*------------------------------------------------------------------------- + * Function: H5T_conv_float_ldouble + * + * Purpose: Convert native `float' to native `long double' using hardware. + * This is a fast special case. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Friday, Feb 25, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_conv_float_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, + size_t nelmts, size_t buf_stride, + size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, + hid_t UNUSED dxpl_id) +{ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5T_conv_float_ldouble, FAIL); + + H5T_CONV_fF(FLOAT, LDOUBLE, float, long double, -, -); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- * Function: H5T_conv_double_float * * Purpose: Convert native `double' to native `float' using hardware. @@ -7023,6 +7055,102 @@ done: /*------------------------------------------------------------------------- + * Function: H5T_conv_double_ldouble + * + * Purpose: Convert native `double' to native `long double' using hardware. + * This is a fast special case. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Friday, Feb 25, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_conv_double_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, + size_t nelmts, size_t buf_stride, + size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, + hid_t UNUSED dxpl_id) +{ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5T_conv_double_ldouble, FAIL); + + H5T_CONV_fF(DOUBLE, LDOUBLE, double, long double, -, -); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5T_conv_ldouble_float + * + * Purpose: Convert native `long double' to native `float' using hardware. + * This is a fast special case. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Friday, Feb 25, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_conv_ldouble_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, + size_t nelmts, size_t buf_stride, + size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, + hid_t UNUSED dxpl_id) +{ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5T_conv_ldouble_float, FAIL); + + H5T_CONV_Ff(LDOUBLE, FLOAT, long double, float, -FLT_MAX, FLT_MAX); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5T_conv_ldouble_double + * + * Purpose: Convert native `long double' to native `double' using hardware. + * This is a fast special case. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Friday, Feb 25, 2005 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_conv_ldouble_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, + size_t nelmts, size_t buf_stride, + size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg, + hid_t UNUSED dxpl_id) +{ + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5T_conv_ldouble_double, FAIL); + + H5T_CONV_Ff(LDOUBLE, DOUBLE, long double, double, -DBL_MAX, DBL_MAX); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} + + +/*------------------------------------------------------------------------- * Function: H5T_conv_schar_float * * Purpose: Convert native signed char to native float using hardware. @@ -7886,7 +8014,6 @@ done: } -#ifdef H5_ULLONG_TO_FP_CAST_WORKS /*------------------------------------------------------------------------- * Function: H5T_conv_ullong_float * @@ -7981,7 +8108,6 @@ H5T_conv_ullong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, done: FUNC_LEAVE_NOAPI(ret_value); } -#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ /*------------------------------------------------------------------------- diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index edac524..9d8900a 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -848,17 +848,36 @@ H5_DLL herr_t H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); - H5_DLL herr_t H5T_conv_float_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); +H5_DLL herr_t H5T_conv_float_ldouble(hid_t src_id, hid_t dst_id, + H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg, + hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_double_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); +H5_DLL herr_t H5T_conv_double_ldouble(hid_t src_id, hid_t dst_id, + H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg, + hid_t dset_xfer_plist); +H5_DLL herr_t H5T_conv_ldouble_float(hid_t src_id, hid_t dst_id, + H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg, + hid_t dset_xfer_plist); +H5_DLL herr_t H5T_conv_ldouble_double(hid_t src_id, hid_t dst_id, + H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, + void *buf, void *bkg, + hid_t dset_xfer_plist); H5_DLL herr_t H5T_conv_schar_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, @@ -994,7 +1013,6 @@ H5_DLL herr_t H5T_conv_llong_ldouble(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -#ifdef H5_ULLONG_TO_FP_CAST_WORKS H5_DLL herr_t H5T_conv_ullong_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, @@ -1010,7 +1028,6 @@ H5_DLL herr_t H5T_conv_ullong_ldouble(hid_t src_id, hid_t dst_id, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg, hid_t dset_xfer_plist); -#endif /* H5_ULLONG_TO_FP_CAST_WORKS */ H5_DLL herr_t H5T_conv_float_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index 5d1af95..ddec8bb 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -202,7 +202,7 @@ typedef herr_t (*H5T_conv_t) (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, void *bkg, hid_t dset_xfer_plist); /* Exception handler. If an exception like overflow happenes during conversion, - * this function is called if it's registered through H5Tset_type_conv_cb. + * this function is called if it's registered through H5Pset_type_conv_cb. */ typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(int except_type, hid_t src_id, hid_t dst_id, void *src_buf, void *dst_buf, void *user_data); diff --git a/test/dtypes.c b/test/dtypes.c index bf99433..c10fc15 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -7966,7 +7966,13 @@ main(void) /* Test hardware floating-point conversion functions */ nerrors += test_conv_flt_1("hw", H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1("hw", H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT); - +#if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE + nerrors += test_conv_flt_1("hw", H5T_NATIVE_FLOAT, H5T_NATIVE_LDOUBLE); + nerrors += test_conv_flt_1("hw", H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE); + nerrors += test_conv_flt_1("hw", H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT); + nerrors += test_conv_flt_1("hw", H5T_NATIVE_LDOUBLE, H5T_NATIVE_DOUBLE); +#endif + /* Test hardware integer-float conversion functions */ nerrors += run_int_float_conv("hw"); -- cgit v0.12