Skip to content

Commit

Permalink
change default bin_type to custom
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud De-Mattia committed Sep 21, 2021
1 parent b743704 commit ec15015
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions mocks/DDrppi_mocks/countpairs_rp_pi_mocks_kernels.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions utils/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions utils/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit ec15015

Please sign in to comment.