Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 18, 2024
1 parent 231515c commit a3d6e6e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 43 deletions.
9 changes: 6 additions & 3 deletions src/H5Tconv_complex.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
/* TODO: may need to edit NOTE comment above depending on approach */
herr_t
H5T__conv_complex(const H5T_t *src_p, const H5T_t *dst_p, H5T_cdata_t *cdata, const H5T_conv_ctx_t *conv_ctx,
size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg)
size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, void *buf,
void H5_ATTR_UNUSED *bkg)
{
H5T_atomic_t src_atomic; /* source datatype atomic info */
H5T_atomic_t dst_atomic; /* destination datatype atomic info */
Expand All @@ -84,14 +85,16 @@ H5T__conv_complex(const H5T_t *src_p, const H5T_t *dst_p, H5T_cdata_t *cdata, co
if (!H5T_IS_ATOMIC(dst_p->shared->parent->shared))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid destination complex number datatype");
if (!src_p->shared->u.cplx.homogeneous || !dst_p->shared->u.cplx.homogeneous)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "source and destination complex number datatypes must be homogeneous");
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"source and destination complex number datatypes must be homogeneous");
src_atomic = src_p->shared->parent->shared->u.atomic;
dst_atomic = dst_p->shared->parent->shared->u.atomic;
if (H5T_ORDER_LE != src_atomic.order && H5T_ORDER_BE != src_atomic.order &&
H5T_ORDER_VAX != src_atomic.order)
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unsupported byte order for source datatype");
if (H5T_ORDER_LE != dst_atomic.order && H5T_ORDER_BE != dst_atomic.order && H5T_ORDER_VAX != src_atomic.order)
if (H5T_ORDER_LE != dst_atomic.order && H5T_ORDER_BE != dst_atomic.order &&
H5T_ORDER_VAX != src_atomic.order)
HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
"unsupported byte order for destination datatype");
if (dst_p->shared->size > TEMP_FLOAT_CONV_BUFFER_SIZE)
Expand Down
92 changes: 53 additions & 39 deletions test/dt_arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ typedef enum dtype_t {
} dtype_t;

typedef enum conv_func_ret_t {
CONV_ERROR = -1, /* Failure during conversion */
CONV_SUCCESS, /* Converted without overflow or underflow */
CONV_OVERFLOW, /* Converted with overflow */
CONV_UNDERFLOW, /* Converted with underflow */
CONV_ERROR = -1, /* Failure during conversion */
CONV_SUCCESS, /* Converted without overflow or underflow */
CONV_OVERFLOW, /* Converted with overflow */
CONV_UNDERFLOW, /* Converted with underflow */

/* Complex number overflow/underflow values */
CONV_OVERFLOW_REAL, /* Converted with overflow on real part */
Expand Down Expand Up @@ -3729,7 +3729,7 @@ test_conv_flt_1_hw_conv_from_ldouble(void *hw_dst, unsigned char *src_buf, size_
static conv_func_ret_t
test_conv_flt_1_hw_conv_from_fcomplex(void *hw_dst, unsigned char *src_buf, size_t idx, dtype_t dst_type)
{
float _Complex aligned;
float _Complex aligned;
conv_func_ret_t ret = CONV_SUCCESS;

memcpy(&aligned, src_buf + idx * sizeof(float _Complex), sizeof(float _Complex));
Expand Down Expand Up @@ -3967,8 +3967,8 @@ static conv_func_ret_t
test_conv_flt_1_hw_conv_from_lcomplex(void *hw_dst, unsigned char *src_buf, size_t idx, dtype_t dst_type)
{
long double _Complex aligned;
long double real_val, imag_val;
conv_func_ret_t ret = CONV_SUCCESS;
long double real_val, imag_val;
conv_func_ret_t ret = CONV_SUCCESS;

memcpy(&aligned, src_buf + idx * sizeof(long double _Complex), sizeof(long double _Complex));

Expand Down Expand Up @@ -4631,10 +4631,12 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
if (conv_ret == CONV_ERROR)
goto error;

overflow = (conv_ret == CONV_OVERFLOW || conv_ret == CONV_OVERFLOW_REAL || conv_ret == CONV_OVERFLOW_IMAG ||
conv_ret == CONV_OVERFLOW_BOTH || conv_ret == CONV_OVERUNDER || conv_ret == CONV_UNDEROVER);
underflow = (conv_ret == CONV_UNDERFLOW || conv_ret == CONV_UNDERFLOW_REAL || conv_ret == CONV_UNDERFLOW_IMAG ||
conv_ret == CONV_UNDERFLOW_BOTH || conv_ret == CONV_OVERUNDER || conv_ret == CONV_UNDEROVER);
overflow =
(conv_ret == CONV_OVERFLOW || conv_ret == CONV_OVERFLOW_REAL || conv_ret == CONV_OVERFLOW_IMAG ||
conv_ret == CONV_OVERFLOW_BOTH || conv_ret == CONV_OVERUNDER || conv_ret == CONV_UNDEROVER);
underflow = (conv_ret == CONV_UNDERFLOW || conv_ret == CONV_UNDERFLOW_REAL ||
conv_ret == CONV_UNDERFLOW_IMAG || conv_ret == CONV_UNDERFLOW_BOTH ||
conv_ret == CONV_OVERUNDER || conv_ret == CONV_UNDEROVER);

/* For Intel machines, the size of "long double" is 12 bytes, precision
* is 80 bits; for Intel IA64 and AMD processors, the size of "long double"
Expand Down Expand Up @@ -4826,9 +4828,9 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
#ifdef H5_HAVE_COMPLEX_NUMBERS
else if (FLT_COMPLEX == dst_type) {
float _Complex fc;
float real_val, hw_real_val;
float imag_val, hw_imag_val;
bool val_passes = true;
float real_val, hw_real_val;
float imag_val, hw_imag_val;
bool val_passes = true;

memcpy(&fc, &buf[j * dst_size], sizeof(float _Complex));
real_val = crealf(fc);
Expand All @@ -4838,27 +4840,31 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)

if (underflow) {
/* Check real part against hardware */
if (conv_ret == CONV_UNDERFLOW_REAL || conv_ret == CONV_UNDERFLOW_BOTH || conv_ret == CONV_UNDEROVER)
if (conv_ret == CONV_UNDERFLOW_REAL || conv_ret == CONV_UNDERFLOW_BOTH ||
conv_ret == CONV_UNDEROVER)
if (fabsf(real_val) > FLT_MIN || fabsf(hw_real_val) > FLT_MIN)
val_passes = false;

/* Check imaginary part against hardware */
if (conv_ret == CONV_UNDERFLOW_IMAG || conv_ret == CONV_UNDERFLOW_BOTH || conv_ret == CONV_OVERUNDER)
if (conv_ret == CONV_UNDERFLOW_IMAG || conv_ret == CONV_UNDERFLOW_BOTH ||
conv_ret == CONV_OVERUNDER)
if (fabsf(imag_val) > FLT_MIN || fabsf(hw_imag_val) > FLT_MIN)
val_passes = false;
}

if (overflow) {
/* Check real part against hardware */
if (conv_ret == CONV_OVERFLOW_REAL || conv_ret == CONV_OVERFLOW_BOTH || conv_ret == CONV_OVERUNDER)
if (conv_ret == CONV_OVERFLOW_REAL || conv_ret == CONV_OVERFLOW_BOTH ||
conv_ret == CONV_OVERUNDER)
if (!my_isinf(dendian, buf + j * sizeof(float _Complex), dst_size / 2, dst_mpos,
dst_msize, dst_epos, dst_esize))
val_passes = false;

/* Check imaginary part against hardware */
if (conv_ret == CONV_OVERFLOW_IMAG || conv_ret == CONV_OVERFLOW_BOTH || conv_ret == CONV_UNDEROVER)
if (!my_isinf(dendian, buf + (j * sizeof(float _Complex)) + (dst_size / 2), dst_size / 2,
dst_mpos, dst_msize, dst_epos, dst_esize))
if (conv_ret == CONV_OVERFLOW_IMAG || conv_ret == CONV_OVERFLOW_BOTH ||
conv_ret == CONV_UNDEROVER)
if (!my_isinf(dendian, buf + (j * sizeof(float _Complex)) + (dst_size / 2),
dst_size / 2, dst_mpos, dst_msize, dst_epos, dst_esize))
val_passes = false;
}

Expand All @@ -4872,9 +4878,9 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
}
else if (DBL_COMPLEX == dst_type) {
double _Complex dc;
double real_val, hw_real_val;
double imag_val, hw_imag_val;
bool val_passes = true;
double real_val, hw_real_val;
double imag_val, hw_imag_val;
bool val_passes = true;

memcpy(&dc, &buf[j * dst_size], sizeof(double _Complex));
real_val = creal(dc);
Expand All @@ -4884,27 +4890,31 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)

if (underflow) {
/* Check real part against hardware */
if (conv_ret == CONV_UNDERFLOW_REAL || conv_ret == CONV_UNDERFLOW_BOTH || conv_ret == CONV_UNDEROVER)
if (conv_ret == CONV_UNDERFLOW_REAL || conv_ret == CONV_UNDERFLOW_BOTH ||
conv_ret == CONV_UNDEROVER)
if (fabs(real_val) > DBL_MIN || fabs(hw_real_val) > DBL_MIN)
val_passes = false;

/* Check imaginary part against hardware */
if (conv_ret == CONV_UNDERFLOW_IMAG || conv_ret == CONV_UNDERFLOW_BOTH || conv_ret == CONV_OVERUNDER)
if (conv_ret == CONV_UNDERFLOW_IMAG || conv_ret == CONV_UNDERFLOW_BOTH ||
conv_ret == CONV_OVERUNDER)
if (fabs(imag_val) > DBL_MIN || fabs(hw_imag_val) > DBL_MIN)
val_passes = false;
}

if (overflow) {
/* Check real part against hardware */
if (conv_ret == CONV_OVERFLOW_REAL || conv_ret == CONV_OVERFLOW_BOTH || conv_ret == CONV_OVERUNDER)
if (conv_ret == CONV_OVERFLOW_REAL || conv_ret == CONV_OVERFLOW_BOTH ||
conv_ret == CONV_OVERUNDER)
if (!my_isinf(dendian, buf + j * sizeof(double _Complex), dst_size / 2, dst_mpos,
dst_msize, dst_epos, dst_esize))
val_passes = false;

/* Check imaginary part against hardware */
if (conv_ret == CONV_OVERFLOW_IMAG || conv_ret == CONV_OVERFLOW_BOTH || conv_ret == CONV_UNDEROVER)
if (!my_isinf(dendian, buf + (j * sizeof(double _Complex)) + (dst_size / 2), dst_size / 2,
dst_mpos, dst_msize, dst_epos, dst_esize))
if (conv_ret == CONV_OVERFLOW_IMAG || conv_ret == CONV_OVERFLOW_BOTH ||
conv_ret == CONV_UNDEROVER)
if (!my_isinf(dendian, buf + (j * sizeof(double _Complex)) + (dst_size / 2),
dst_size / 2, dst_mpos, dst_msize, dst_epos, dst_esize))
val_passes = false;
}

Expand All @@ -4918,8 +4928,8 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
}
else if (LDBL_COMPLEX == dst_type) {
long double _Complex ldc;
long double real_val, hw_real_val;
long double imag_val, hw_imag_val;
long double real_val, hw_real_val;
long double imag_val, hw_imag_val;

memcpy(&ldc, &buf[j * dst_size], sizeof(long double _Complex));
real_val = creall(ldc);
Expand All @@ -4941,12 +4951,14 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
if (FLT_COMPLEX == dst_type || DBL_COMPLEX == dst_type || LDBL_COMPLEX == dst_type) {
if (check_expo[0] < (-(int)dst_ebias) || check_expo[1] < (-(int)dst_ebias) ||
check_expo[2] < (-(int)dst_ebias) || check_expo[3] < (-(int)dst_ebias)) {
double epsilon_real = 1.0;
double epsilon_imag = 1.0;
int expo_diff_real = check_expo[0] - check_expo[1];
int expo_diff_imag = check_expo[2] - check_expo[3];
int valid_bits_real = (int)((dst_ebias + dst_msize) + (size_t)MIN(check_expo[0], check_expo[1])) - 1;
int valid_bits_imag = (int)((dst_ebias + dst_msize) + (size_t)MIN(check_expo[2], check_expo[3])) - 1;
double epsilon_real = 1.0;
double epsilon_imag = 1.0;
int expo_diff_real = check_expo[0] - check_expo[1];
int expo_diff_imag = check_expo[2] - check_expo[3];
int valid_bits_real =
(int)((dst_ebias + dst_msize) + (size_t)MIN(check_expo[0], check_expo[1])) - 1;
int valid_bits_imag =
(int)((dst_ebias + dst_msize) + (size_t)MIN(check_expo[2], check_expo[3])) - 1;

/* Re-scale the mantissas based on any exponent difference */
if (expo_diff_real != 0)
Expand All @@ -4964,8 +4976,10 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst)
continue;
}
else {
if ((check_expo[0] == check_expo[1] && fabs(check_mant[0] - check_mant[1]) < (double)FP_EPSILON) &&
(check_expo[2] == check_expo[3] && fabs(check_mant[2] - check_mant[3]) < (double)FP_EPSILON))
if ((check_expo[0] == check_expo[1] &&
fabs(check_mant[0] - check_mant[1]) < (double)FP_EPSILON) &&
(check_expo[2] == check_expo[3] &&
fabs(check_mant[2] - check_mant[3]) < (double)FP_EPSILON))
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/dtypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -7221,7 +7221,7 @@ test_complex_type_conv(void)
H5T_t *native_double_complex = NULL;
H5T_t *native_ldouble_complex = NULL;
#endif
hid_t complex_tid = H5I_INVALID_HID;
hid_t complex_tid = H5I_INVALID_HID;

TESTING("complex number datatype conversions");

Expand Down

0 comments on commit a3d6e6e

Please sign in to comment.