From ec15015df6839e92ce2b544378543f00600f533d Mon Sep 17 00:00:00 2001 From: Arnaud De-Mattia Date: Tue, 21 Sep 2021 23:57:50 +0200 Subject: [PATCH] change default bin_type to custom --- .../countpairs_rp_pi_mocks_kernels.c.src | 20 +++++++++---------- utils/defs.h | 4 ++-- utils/utils.c | 12 +++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_kernels.c.src b/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_kernels.c.src index 8df7e4ca..ba3d0638 100644 --- a/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_kernels.c.src +++ b/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_kernels.c.src @@ -56,7 +56,7 @@ static inline int countpairs_rp_pi_mocks_avx512_intrinsics_DOUBLE(const int64_t DOUBLE inv_rpstep=0., rpmin_invstep=0.; AVX512_FLOATS m_inv_rpstep = AVX512_SETZERO_FLOAT(); AVX512_FLOATS m_rpmin_invstep = AVX512_SETZERO_FLOAT(); - if (bin_type == 1) { + if (bin_type == BIN_LIN) { inv_rpstep = (nbin - 1)/(rpmax - rpmin); rpmin_invstep = 1 - rpmin*inv_rpstep; //trick to avoid adding one to (r - rmin)/rstep m_inv_rpstep = AVX512_SET_FLOAT(inv_rpstep); @@ -310,7 +310,7 @@ static inline int countpairs_rp_pi_mocks_avx512_intrinsics_DOUBLE(const int64_t const AVX512_MASK m_mask = m_mask_left; AVX512_FLOATS m_rpbin = AVX512_SETZERO_FLOAT(); - if (bin_type == 1) { + if (bin_type == BIN_LIN) { if (!need_rpavg) { union_mDperp.m_Dperp = AVX512_MASKZ_SQRT_FLOAT(m_mask_left, m_sqr_Dperp); } @@ -397,7 +397,7 @@ static inline int countpairs_rp_pi_mocks_avx_intrinsics_DOUBLE(const int64_t N0, DOUBLE inv_rpstep=0., rpmin_invstep=0.; AVX_FLOATS m_inv_rpstep = AVX_SETZERO_FLOAT(); AVX_FLOATS m_rpmin_invstep = AVX_SETZERO_FLOAT(); - if (bin_type == 1) { + if (bin_type == BIN_LIN) { inv_rpstep = (nbin - 1)/(rpmax - rpmin); rpmin_invstep = 1 - rpmin*inv_rpstep; //trick to avoid adding one to (r - rmin)/rstep m_inv_rpstep = AVX_SET_FLOAT(inv_rpstep); @@ -663,7 +663,7 @@ static inline int countpairs_rp_pi_mocks_avx_intrinsics_DOUBLE(const int64_t N0, const AVX_FLOATS m_mask = m_mask_left; AVX_FLOATS m_rpbin = AVX_SETZERO_FLOAT(); - if (bin_type == 1) { + if (bin_type == BIN_LIN) { if (!need_rpavg) { union_mDperp.m_Dperp = AVX_SQRT_FLOAT(m_sqr_Dperp); } @@ -749,7 +749,7 @@ static inline int countpairs_rp_pi_mocks_avx_intrinsics_DOUBLE(const int64_t N0, } int kbin = 0; - if (bin_type == 1) { + if (bin_type == BIN_LIN) { if (!need_rpavg) { rp = SQRT(sqr_Dperp); } @@ -820,7 +820,7 @@ static inline int countpairs_rp_pi_mocks_sse_intrinsics_DOUBLE(const int64_t N0, DOUBLE inv_rpstep=0., rpmin_invstep=0.; SSE_FLOATS m_inv_rpstep = SSE_SETZERO_FLOAT(); SSE_FLOATS m_rpmin_invstep = SSE_SETZERO_FLOAT(); - if (bin_type == 1) { + if (bin_type == BIN_LIN) { inv_rpstep = (nbin - 1)/(rpmax - rpmin); rpmin_invstep = 1 - rpmin*inv_rpstep; //trick to avoid adding one to (r - rmin)/rstep m_inv_rpstep = SSE_SET_FLOAT(inv_rpstep); @@ -1065,7 +1065,7 @@ static inline int countpairs_rp_pi_mocks_sse_intrinsics_DOUBLE(const int64_t N0, const SSE_FLOATS m_mask = m_mask_left; SSE_FLOATS m_rpbin = SSE_SETZERO_FLOAT(); - if (bin_type == 1) { + if (bin_type == BIN_LIN) { if (!need_rpavg) { union_mDperp.m_Dperp = SSE_SQRT_FLOAT(m_sqr_Dperp); } @@ -1152,7 +1152,7 @@ static inline int countpairs_rp_pi_mocks_sse_intrinsics_DOUBLE(const int64_t N0, pairweight = fallback_weight_func(&pair); } int kbin = 0; - if (bin_type == 1) { + if (bin_type == BIN_LIN) { if (!need_rpavg) { rp = SQRT(sqr_Dperp); } @@ -1215,7 +1215,7 @@ static inline int countpairs_rp_pi_mocks_fallback_DOUBLE(const int64_t N0, DOUBL const int32_t need_weightavg = src_weightavg != NULL; const DOUBLE sqr_rpmin=rpmin*rpmin, sqr_rpmax=rpmax*rpmax; DOUBLE inv_rpstep=0., rpmin_invstep=0.; - if (bin_type == 1) { + if (bin_type == BIN_LIN) { inv_rpstep = (nbin - 1)/(rpmax - rpmin); rpmin_invstep = 1 - rpmin*inv_rpstep; //trick to avoid adding one to (r - rmin)/rstep } @@ -1380,7 +1380,7 @@ static inline int countpairs_rp_pi_mocks_fallback_DOUBLE(const int64_t N0, DOUBL } int kbin = 0; - if (bin_type == 1) { + if (bin_type == BIN_LIN) { if (!need_rpavg) { rp = SQRT(sqr_Dperp); } diff --git a/utils/defs.h b/utils/defs.h index bfc3f504..b5753c90 100644 --- a/utils/defs.h +++ b/utils/defs.h @@ -252,8 +252,8 @@ static inline struct config_options get_config_options(void) // If periodic, set to -1 to require the user to set a boxsize. // A value of 0 will use automatic detection of the particle extent options.boxsize = -1.; - // Default: automatic detection of linear binning - options.bin_type = 0; + // Default: custom binning + options.bin_type = BIN_CUSTOM; #ifdef DOUBLE_PREC options.float_type = sizeof(double); diff --git a/utils/utils.c b/utils/utils.c index 0397e860..a2ef7645 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -62,9 +62,9 @@ void get_max_double(const int64_t ND1, const double *cz1, double *czmax) static int detect_bin_type_float(const float *rupp, int nbin, bin_type_t *bin_type) { if (*bin_type == BIN_AUTO) { - // if linear spacing, return 1, else 0 - const float atol = 1e-12; - const float rtol = 1e-12; + // if linear spacing, return BIN_LIN, else BIN_CUSTOM + const float atol = 1e-8; // same tol as numpy.allclose + const float rtol = 1e-5; float rmin = rupp[0]; float rstep = (rupp[nbin-1] - rupp[0])/(nbin - 1); *bin_type = BIN_LIN; @@ -82,9 +82,9 @@ static int detect_bin_type_float(const float *rupp, int nbin, bin_type_t *bin_ty static int detect_bin_type_double(const double *rupp, int nbin, bin_type_t *bin_type) { if (*bin_type == BIN_AUTO) { - // if linear spacing, return 1, else 0 - const double atol = 1e-12; - const double rtol = 1e-12; + // if linear spacing, return BIN_LIN, else BIN_CUSTOM + const double atol = 1e-8; // same tol as numpy.allclose + const double rtol = 1e-5; double rmin = rupp[0]; double rstep = (rupp[nbin-1] - rupp[0])/(nbin - 1); *bin_type = BIN_LIN;