From 3a9907f8b7217e89ae609c50ad27a5812feea569 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Tue, 18 Jun 2019 09:59:05 -0400 Subject: [PATCH 1/5] * Reduce gridlink memory footprint for autocorrelations --- utils/gridlink_impl.c.src | 7 +++++-- utils/gridlink_mocks_impl.c.src | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/utils/gridlink_impl.c.src b/utils/gridlink_impl.c.src index c7203acf..ba7df077 100644 --- a/utils/gridlink_impl.c.src +++ b/utils/gridlink_impl.c.src @@ -428,9 +428,12 @@ struct cell_pair_DOUBLE * generate_cell_pairs_DOUBLE(struct cellarray_DOUBLE *la const int64_t nx_ngb = 2*xbin_refine_factor + 1; const int64_t ny_ngb = 2*ybin_refine_factor + 1; const int64_t nz_ngb = 2*zbin_refine_factor + 1; - const int64_t max_ngb_cells = nx_ngb * ny_ngb * nz_ngb; + const int64_t max_ngb_cells = nx_ngb * ny_ngb * nz_ngb - 1; // -1 for self - const int64_t max_num_cell_pairs = totncells * max_ngb_cells; + const int64_t num_self_pairs = totncells; + const int64_t num_nonself_pairs = totncells * max_ngb_cells / (1 + autocorr); + + const int64_t max_num_cell_pairs = num_self_pairs + num_nonself_pairs; int64_t num_cell_pairs = 0; struct cell_pair_DOUBLE *all_cell_pairs = my_malloc(sizeof(*all_cell_pairs), max_num_cell_pairs); XRETURN(all_cell_pairs != NULL, NULL, diff --git a/utils/gridlink_mocks_impl.c.src b/utils/gridlink_mocks_impl.c.src index 01a77bdb..b2d6a536 100644 --- a/utils/gridlink_mocks_impl.c.src +++ b/utils/gridlink_mocks_impl.c.src @@ -430,9 +430,12 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_DOUBLE(struct cellarray_mock const int64_t nx_ngb = 2*xbin_refine_factor + 1; const int64_t ny_ngb = 2*ybin_refine_factor + 1; const int64_t nz_ngb = 2*zbin_refine_factor + 1; - const int64_t max_ngb_cells = nx_ngb * ny_ngb * nz_ngb; + const int64_t max_ngb_cells = nx_ngb * ny_ngb * nz_ngb - 1; // -1 for self - const int64_t max_num_cell_pairs = totncells * max_ngb_cells; + const int64_t num_self_pairs = totncells; + const int64_t num_nonself_pairs = totncells * max_ngb_cells / (autocorr + 1); + + const int64_t max_num_cell_pairs = num_self_pairs + num_nonself_pairs; int64_t num_cell_pairs = 0; struct cell_pair_DOUBLE *all_cell_pairs = my_malloc(sizeof(*all_cell_pairs), max_num_cell_pairs); XRETURN(all_cell_pairs != NULL, NULL, @@ -921,8 +924,13 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_theta_dec_DOUBLE(cellarray_m */ const DOUBLE sqr_max_chord_sep = 2.0 * (1.0 - COSD(thetamax)); - const int64_t max_ngb_cells = 2*dec_refine_factor + 1; - const int64_t max_num_cell_pairs = totncells * max_ngb_cells; + const int64_t max_ngb_cells = 2*dec_refine_factor; // -1 for self + + const int64_t num_self_pairs = totncells; + const int64_t num_nonself_pairs = totncells * max_ngb_cells / (autocorr + 1); + + const int64_t max_num_cell_pairs = num_self_pairs + num_nonself_pairs; + int64_t num_cell_pairs = 0; struct cell_pair_DOUBLE *all_cell_pairs = my_malloc(sizeof(*all_cell_pairs), max_num_cell_pairs); XRETURN(all_cell_pairs != NULL, NULL, From 80d8f5b5edabbca7c675c4bf1f154fdd5d8ffdef Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Tue, 18 Jun 2019 10:13:38 -0400 Subject: [PATCH 2/5] Update changelog --- CHANGES.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0ef783dc..a572a3dd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,9 +10,17 @@ New features - conda installable package - GPU version -2.3.0 (upcoming) +2.3.1 (upcoming) ================ +Enhancements +------------ +- Reduce gridlink memory footprint [#186] + + +2.3.0 (2019-05-20) +================== + **Breaking Changes** -------------------- From 68b13a0e19495eec1c2b4fa6f64d91418850339a Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Wed, 19 Jun 2019 06:02:44 +1000 Subject: [PATCH 3/5] Reduced the size of the cell_pair struct --- common.mk | 2 +- .../countpairs_rp_pi_mocks_impl.c.src | 11 ++-- .../countpairs_s_mu_mocks_impl.c.src | 11 ++-- .../countpairs_theta_mocks_impl.c.src | 11 ++-- theory/DD/countpairs_impl.c.src | 11 ++-- theory/DDrppi/countpairs_rp_pi_impl.c.src | 11 ++-- theory/DDsmu/countpairs_s_mu_impl.c.src | 11 ++-- theory/wp/countpairs_wp_impl.c.src | 13 +++-- theory/xi/countpairs_xi_impl.c.src | 11 ++-- utils/cell_pair.h.src | 23 -------- utils/defs.h | 2 +- utils/gridlink_impl.c.src | 22 ++------ utils/gridlink_mocks_impl.c.src | 53 +++---------------- 13 files changed, 72 insertions(+), 120 deletions(-) diff --git a/common.mk b/common.mk index 89b4f075..c2754dc8 100644 --- a/common.mk +++ b/common.mk @@ -41,7 +41,7 @@ OPT += -DUSE_OMP DISTNAME:=Corrfunc MAJOR:=2 MINOR:=3 -PATCHLEVEL:=0 +PATCHLEVEL:=1 VERSION:=$(MAJOR).$(MINOR).$(PATCHLEVEL) ABI_COMPAT_VERSION:=$(MAJOR).0 # Whenever conda needs to be checked again diff --git a/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_impl.c.src b/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_impl.c.src index acc36d5d..21c00513 100644 --- a/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_impl.c.src +++ b/mocks/DDrppi_mocks/countpairs_rp_pi_mocks_impl.c.src @@ -625,10 +625,13 @@ int countpairs_mocks_DOUBLE(const int64_t ND1, DOUBLE *ra1, DOUBLE *dec1, DOUBLE DOUBLE *this_rpavg = options->need_avg_sep ? rpavg:NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = countpairs_rp_pi_mocks_function_DOUBLE(this_cell_pair->N1, this_cell_pair->x1, - this_cell_pair->y1, this_cell_pair->z1, this_cell_pair->weights1, - this_cell_pair->N2, this_cell_pair->x2, - this_cell_pair->y2, this_cell_pair->z2, this_cell_pair->weights2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_mocks_DOUBLE *first = &lattice1[icell]; + const cellarray_mocks_DOUBLE *second = &lattice2[icell2]; + + const int status = countpairs_rp_pi_mocks_function_DOUBLE(first->nelements, first->x, first->y, first->z, &(first->weights), + second->nelements, second->x, second->y, second->z, &(second->weights), this_cell_pair->same_cell, options->fast_divide_and_NR_steps, sqr_rpmax, sqr_rpmin, nrpbin, npibin, rupp_sqr, pimax, diff --git a/mocks/DDsmu_mocks/countpairs_s_mu_mocks_impl.c.src b/mocks/DDsmu_mocks/countpairs_s_mu_mocks_impl.c.src index c8b598b5..df60763e 100644 --- a/mocks/DDsmu_mocks/countpairs_s_mu_mocks_impl.c.src +++ b/mocks/DDsmu_mocks/countpairs_s_mu_mocks_impl.c.src @@ -631,10 +631,13 @@ int countpairs_mocks_s_mu_DOUBLE(const int64_t ND1, DOUBLE *ra1, DOUBLE *dec1, D DOUBLE *this_savg = options->need_avg_sep ? &(savg[0]):NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = countpairs_s_mu_mocks_function_DOUBLE(this_cell_pair->N1, this_cell_pair->x1, - this_cell_pair->y1, this_cell_pair->z1, this_cell_pair->weights1, - this_cell_pair->N2, this_cell_pair->x2, - this_cell_pair->y2, this_cell_pair->z2, this_cell_pair->weights2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_mocks_DOUBLE *first = &lattice1[icell]; + const cellarray_mocks_DOUBLE *second = &lattice2[icell2]; + + const int status = countpairs_s_mu_mocks_function_DOUBLE(first->nelements, first->x, first->y, first->z, &(first->weights), + second->nelements, second->x, second->y, second->z, &(second->weights), this_cell_pair->same_cell, options->fast_divide_and_NR_steps, sqr_smax, sqr_smin, nsbin, nmu_bins, supp_sqr, mu_max, diff --git a/mocks/DDtheta_mocks/countpairs_theta_mocks_impl.c.src b/mocks/DDtheta_mocks/countpairs_theta_mocks_impl.c.src index 7e2a6b36..164228f4 100644 --- a/mocks/DDtheta_mocks/countpairs_theta_mocks_impl.c.src +++ b/mocks/DDtheta_mocks/countpairs_theta_mocks_impl.c.src @@ -1007,10 +1007,13 @@ int countpairs_theta_mocks_DOUBLE(const int64_t ND1, DOUBLE *ra1, DOUBLE *dec1, DOUBLE *this_thetaavg = options->need_avg_sep ? thetaavg:NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = countpairs_theta_mocks_function_DOUBLE(this_cell_pair->N1, this_cell_pair->x1, - this_cell_pair->y1, this_cell_pair->z1, this_cell_pair->weights1, - this_cell_pair->N2, this_cell_pair->x2, - this_cell_pair->y2, this_cell_pair->z2, this_cell_pair->weights2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_mocks_DOUBLE *first = &lattice1[icell]; + const cellarray_mocks_DOUBLE *second = &lattice2[icell2]; + + const int status = countpairs_theta_mocks_function_DOUBLE(first->nelements, first->x, first->y, first->z, &(first->weights), + second->nelements, second->x, second->y, second->z, &(second->weights), this_cell_pair->same_cell, options->fast_acos, costhetamax, costhetamin, nthetabin, diff --git a/theory/DD/countpairs_impl.c.src b/theory/DD/countpairs_impl.c.src index 2c9fed58..7b8603c4 100644 --- a/theory/DD/countpairs_impl.c.src +++ b/theory/DD/countpairs_impl.c.src @@ -452,10 +452,13 @@ int countpairs_DOUBLE(const int64_t ND1, DOUBLE *X1, DOUBLE *Y1, DOUBLE *Z1, DOUBLE *this_rpavg = options->need_avg_sep ? rpavg:NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = countpairs_function_DOUBLE(this_cell_pair->N1, this_cell_pair->x1, - this_cell_pair->y1, this_cell_pair->z1, this_cell_pair->weights1, - this_cell_pair->N2, this_cell_pair->x2, - this_cell_pair->y2, this_cell_pair->z2, this_cell_pair->weights2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_DOUBLE *first = &lattice1[icell]; + const cellarray_DOUBLE *second = &lattice2[icell2]; + + const int status = countpairs_function_DOUBLE(first->nelements, first->x, first->y, first->z, &(first->weights), + second->nelements, second->x, second->y, second->z, &(second->weights), this_cell_pair->same_cell, sqr_rpmax, sqr_rpmin, nrpbin, rupp_sqr, pimax, //pimax is simply rpmax cast to DOUBLE this_cell_pair->xwrap, this_cell_pair->ywrap, this_cell_pair->zwrap, diff --git a/theory/DDrppi/countpairs_rp_pi_impl.c.src b/theory/DDrppi/countpairs_rp_pi_impl.c.src index 5cc71d92..d82bcfce 100644 --- a/theory/DDrppi/countpairs_rp_pi_impl.c.src +++ b/theory/DDrppi/countpairs_rp_pi_impl.c.src @@ -446,10 +446,13 @@ int countpairs_rp_pi_DOUBLE(const int64_t ND1, DOUBLE *X1, DOUBLE *Y1, DOUBLE *Z DOUBLE *this_rpavg = options->need_avg_sep ? rpavg:NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = countpairs_rp_pi_function_DOUBLE(this_cell_pair->N1, this_cell_pair->x1, - this_cell_pair->y1, this_cell_pair->z1, this_cell_pair->weights1, - this_cell_pair->N2, this_cell_pair->x2, - this_cell_pair->y2, this_cell_pair->z2, this_cell_pair->weights2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_DOUBLE *first = &lattice1[icell]; + const cellarray_DOUBLE *second = &lattice2[icell2]; + + const int status = countpairs_rp_pi_function_DOUBLE(first->nelements, first->x, first->y, first->z, &(first->weights), + second->nelements, second->x, second->y, second->z, &(second->weights), this_cell_pair->same_cell, sqr_rpmax, sqr_rpmin, nrpbin, npibin, rupp_sqr, pimax, this_cell_pair->xwrap, this_cell_pair->ywrap, this_cell_pair->zwrap, diff --git a/theory/DDsmu/countpairs_s_mu_impl.c.src b/theory/DDsmu/countpairs_s_mu_impl.c.src index 359275da..6d30470b 100644 --- a/theory/DDsmu/countpairs_s_mu_impl.c.src +++ b/theory/DDsmu/countpairs_s_mu_impl.c.src @@ -466,10 +466,13 @@ int countpairs_s_mu_DOUBLE(const int64_t ND1, DOUBLE *X1, DOUBLE *Y1, DOUBLE *Z1 DOUBLE *this_rpavg = options->need_avg_sep ? savg:NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = countpairs_s_mu_function_DOUBLE(this_cell_pair->N1, this_cell_pair->x1, - this_cell_pair->y1, this_cell_pair->z1, this_cell_pair->weights1, - this_cell_pair->N2, this_cell_pair->x2, - this_cell_pair->y2, this_cell_pair->z2, this_cell_pair->weights2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_DOUBLE *first = &lattice1[icell]; + const cellarray_DOUBLE *second = &lattice2[icell2]; + + const int status = countpairs_s_mu_function_DOUBLE(first->nelements, first->x, first->y, first->z, &(first->weights), + second->nelements, second->x, second->y, second->z, &(second->weights), this_cell_pair->same_cell, options->fast_divide_and_NR_steps, sqr_smax, sqr_smin, nsbin, nmu_bins, supp_sqr, mu_max, pimax, diff --git a/theory/wp/countpairs_wp_impl.c.src b/theory/wp/countpairs_wp_impl.c.src index 31c4bec9..d54725d5 100644 --- a/theory/wp/countpairs_wp_impl.c.src +++ b/theory/wp/countpairs_wp_impl.c.src @@ -427,10 +427,13 @@ int countpairs_wp_DOUBLE(const int64_t ND, DOUBLE * restrict X, DOUBLE * restric current_utc_time(&tcell_start); } - const int status = wp_function_DOUBLE(this_cell_pair->x1, this_cell_pair->y1, this_cell_pair->z1, - this_cell_pair->weights1, this_cell_pair->N1, - this_cell_pair->x2, this_cell_pair->y2, this_cell_pair->z2, - this_cell_pair->weights2, this_cell_pair->N2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_DOUBLE *first = &lattice[icell]; + const cellarray_DOUBLE *second = &lattice[icell2]; + + const int status = wp_function_DOUBLE(first->x, first->y, first->z, &(first->weights), first->nelements, + second->x, second->y, second->z, &(second->weights), second->nelements, this_cell_pair->same_cell, sqr_rpmax, sqr_rpmin, nrpbins, rupp_sqr, pimax, this_cell_pair->xwrap, this_cell_pair->ywrap, this_cell_pair->zwrap, @@ -448,7 +451,7 @@ int countpairs_wp_DOUBLE(const int64_t ND, DOUBLE * restrict X, DOUBLE * restric current_utc_time(&tcell_end); double time_in_ns = REALTIME_ELAPSED_NS(tcell_start, tcell_end); struct api_cell_timings *base_cell = &(options->cell_timings[icellpair]); - ASSIGN_CELL_TIMINGS(base_cell, this_cell_pair->N1, this_cell_pair->N2, time_in_ns, + ASSIGN_CELL_TIMINGS(base_cell, first->nelements, second->nelements, time_in_ns, tid, this_cell_pair->cellindex1, this_cell_pair->cellindex2); } }//abort-status diff --git a/theory/xi/countpairs_xi_impl.c.src b/theory/xi/countpairs_xi_impl.c.src index 40544f52..8523fbd3 100644 --- a/theory/xi/countpairs_xi_impl.c.src +++ b/theory/xi/countpairs_xi_impl.c.src @@ -395,10 +395,13 @@ int countpairs_xi_DOUBLE(const int64_t ND, DOUBLE * restrict X, DOUBLE * restric DOUBLE *this_rpavg = options->need_avg_sep ? ravg:NULL; DOUBLE *this_weightavg = need_weightavg ? weightavg:NULL; - const int status = xi_function_DOUBLE(this_cell_pair->x1, this_cell_pair->y1, this_cell_pair->z1, - this_cell_pair->weights1, this_cell_pair->N1, - this_cell_pair->x2, this_cell_pair->y2, this_cell_pair->z2, - this_cell_pair->weights2, this_cell_pair->N2, + const int64_t icell = this_cell_pair->cellindex1; + const int64_t icell2 = this_cell_pair->cellindex2; + const cellarray_DOUBLE *first = &lattice[icell]; + const cellarray_DOUBLE *second = &lattice[icell2]; + + const int status = xi_function_DOUBLE(first->x, first->y, first->z, &(first->weights), first->nelements, + second->x, second->y, second->z, &(second->weights), second->nelements, this_cell_pair->same_cell, sqr_rmax, sqr_rmin, nbins, rupp_sqr, this_cell_pair->xwrap, this_cell_pair->ywrap, this_cell_pair->zwrap, diff --git a/utils/cell_pair.h.src b/utils/cell_pair.h.src index 94482718..466fb497 100644 --- a/utils/cell_pair.h.src +++ b/utils/cell_pair.h.src @@ -18,20 +18,7 @@ extern "C" { #include "weight_defs_DOUBLE.h" struct cell_pair_DOUBLE{ - int64_t N1; - DOUBLE *x1; - DOUBLE *y1; - DOUBLE *z1; - int64_t *orig_index1; - weight_struct_DOUBLE *weights1; int64_t cellindex1; - - int64_t N2; - DOUBLE *x2; - DOUBLE *y2; - DOUBLE *z2; - int64_t *orig_index2; - weight_struct_DOUBLE *weights2; int64_t cellindex2; DOUBLE xwrap; @@ -47,16 +34,6 @@ struct cell_pair_DOUBLE{ DOUBLE closest_z1; int8_t same_cell; - union{ - int16_t xbin_offset; - int16_t ra_bin_offset; - }; - union{ - int16_t ybin_offset; - int16_t dec_bin_offset; - }; - int16_t zbin_offset; - int8_t unused;//explicitly adding here for alignment }; #ifdef __cplusplus diff --git a/utils/defs.h b/utils/defs.h index 0c06d3fb..5674c601 100644 --- a/utils/defs.h +++ b/utils/defs.h @@ -19,7 +19,7 @@ extern "C" { #endif -#define API_VERSION STR("2.3.0") +#define API_VERSION STR("2.3.1") typedef enum { DEFAULT=-42,/* present simply to make the enum a signed int*/ diff --git a/utils/gridlink_impl.c.src b/utils/gridlink_impl.c.src index ba7df077..f30dbf40 100644 --- a/utils/gridlink_impl.c.src +++ b/utils/gridlink_impl.c.src @@ -430,6 +430,11 @@ struct cell_pair_DOUBLE * generate_cell_pairs_DOUBLE(struct cellarray_DOUBLE *la const int64_t nz_ngb = 2*zbin_refine_factor + 1; const int64_t max_ngb_cells = nx_ngb * ny_ngb * nz_ngb - 1; // -1 for self + + if( ! (autocorr == 0 || autocorr == 1) ) { + fprintf(stderr,"Error: Strange value of autocorr = %d. Expected to receive either 1 (auto-correlations) or 0 (cross-correlations)\n", autocorr); + return NULL; + } const int64_t num_self_pairs = totncells; const int64_t num_nonself_pairs = totncells * max_ngb_cells / (1 + autocorr); @@ -545,20 +550,7 @@ struct cell_pair_DOUBLE * generate_cell_pairs_DOUBLE(struct cellarray_DOUBLE *la //If we have reached here, then this cell *MIGHT* have a pair. We //need to add a cell-pair to the array of all cell-pairs struct cell_pair_DOUBLE *this_cell_pair = &all_cell_pairs[num_cell_pairs]; - this_cell_pair->N1 = first->nelements; - this_cell_pair->x1 = first->x; - this_cell_pair->y1 = first->y; - this_cell_pair->z1 = first->z; - this_cell_pair->orig_index1 = first->original_index; - this_cell_pair->weights1 = &first->weights; this_cell_pair->cellindex1 = icell; - - this_cell_pair->N2 = second->nelements; - this_cell_pair->x2 = second->x; - this_cell_pair->y2 = second->y; - this_cell_pair->z2 = second->z; - this_cell_pair->orig_index2 = second->original_index; - this_cell_pair->weights2 = &second->weights; this_cell_pair->cellindex2 = icell2; this_cell_pair->xwrap = off_xwrap; @@ -573,10 +565,6 @@ struct cell_pair_DOUBLE * generate_cell_pairs_DOUBLE(struct cellarray_DOUBLE *la this_cell_pair->closest_y1 = closest_y1; this_cell_pair->closest_z1 = closest_z1; - this_cell_pair->xbin_offset = iix; - this_cell_pair->ybin_offset = iiy; - this_cell_pair->zbin_offset = iiz; - this_cell_pair->same_cell = (autocorr == 1 && icell2 == icell) ? 1:0; num_cell_pairs++; diff --git a/utils/gridlink_mocks_impl.c.src b/utils/gridlink_mocks_impl.c.src index b2d6a536..00511bd4 100644 --- a/utils/gridlink_mocks_impl.c.src +++ b/utils/gridlink_mocks_impl.c.src @@ -432,6 +432,10 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_DOUBLE(struct cellarray_mock const int64_t nz_ngb = 2*zbin_refine_factor + 1; const int64_t max_ngb_cells = nx_ngb * ny_ngb * nz_ngb - 1; // -1 for self + if( ! (autocorr == 0 || autocorr == 1) ) { + fprintf(stderr,"Error: Strange value of autocorr = %d. Expected to receive either 1 (auto-correlations) or 0 (cross-correlations)\n", autocorr); + return NULL; + } const int64_t num_self_pairs = totncells; const int64_t num_nonself_pairs = totncells * max_ngb_cells / (autocorr + 1); @@ -518,20 +522,7 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_DOUBLE(struct cellarray_mock "Expected that the total number of cell pairs can be at most %"PRId64" but " "currently have number of cell pairs = %"PRId64"\n", max_num_cell_pairs, num_cell_pairs); struct cell_pair_DOUBLE *this_cell_pair = &all_cell_pairs[num_cell_pairs]; - this_cell_pair->N1 = first->nelements; - this_cell_pair->x1 = first->x; - this_cell_pair->y1 = first->y; - this_cell_pair->z1 = first->z; - this_cell_pair->orig_index1 = first->original_index; - this_cell_pair->weights1 = &first->weights; this_cell_pair->cellindex1 = icell; - - this_cell_pair->N2 = second->nelements; - this_cell_pair->x2 = second->x; - this_cell_pair->y2 = second->y; - this_cell_pair->z2 = second->z; - this_cell_pair->orig_index2 = second->original_index; - this_cell_pair->weights2 = &second->weights; this_cell_pair->cellindex2 = icell2; this_cell_pair->min_dx = min_dx; @@ -926,6 +917,10 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_theta_dec_DOUBLE(cellarray_m const int64_t max_ngb_cells = 2*dec_refine_factor; // -1 for self + if( ! (autocorr == 0 || autocorr == 1) ) { + fprintf(stderr,"Error: Strange value of autocorr = %d. Expected to receive either 1 (auto-correlations) or 0 (cross-correlations)\n", autocorr); + return NULL; + } const int64_t num_self_pairs = totncells; const int64_t num_nonself_pairs = totncells * max_ngb_cells / (autocorr + 1); @@ -984,20 +979,7 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_theta_dec_DOUBLE(cellarray_m //If we have reached here, then this cell *MIGHT* have a pair. We //need to add a cell-pair to the array of all cell-pairs struct cell_pair_DOUBLE *this_cell_pair = &all_cell_pairs[num_cell_pairs]; - this_cell_pair->N1 = first->nelements; - this_cell_pair->x1 = first->x; - this_cell_pair->y1 = first->y; - this_cell_pair->z1 = first->z; - this_cell_pair->orig_index1 = first->original_index; - this_cell_pair->weights1 = &first->weights; this_cell_pair->cellindex1 = icell; - - this_cell_pair->N2 = second->nelements; - this_cell_pair->x2 = second->x; - this_cell_pair->y2 = second->y; - this_cell_pair->z2 = second->z; - this_cell_pair->orig_index2 = second->original_index; - this_cell_pair->weights2 = &second->weights; this_cell_pair->cellindex2 = icell2; this_cell_pair->min_dx = min_dx; @@ -1008,9 +990,6 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_theta_dec_DOUBLE(cellarray_m this_cell_pair->closest_y1 = closest_y1; this_cell_pair->closest_z1 = closest_z1; - this_cell_pair->ra_bin_offset = 0; - this_cell_pair->dec_bin_offset = idec; - this_cell_pair->same_cell = (autocorr == 1 && icell2 == icell) ? 1:0; num_cell_pairs++; @@ -1659,20 +1638,7 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_theta_ra_dec_DOUBLE(cellarra //If we have reached here, then this cell *MIGHT* have a pair. We //need to add a cell-pair to the array of all cell-pairs struct cell_pair_DOUBLE *this_cell_pair = &all_cell_pairs[num_cell_pairs]; - this_cell_pair->N1 = first->nelements; - this_cell_pair->x1 = first->x; - this_cell_pair->y1 = first->y; - this_cell_pair->z1 = first->z; - this_cell_pair->orig_index1 = first->original_index; - this_cell_pair->weights1 = &first->weights; this_cell_pair->cellindex1 = icell; - - this_cell_pair->N2 = second->nelements; - this_cell_pair->x2 = second->x; - this_cell_pair->y2 = second->y; - this_cell_pair->z2 = second->z; - this_cell_pair->orig_index2 = second->original_index; - this_cell_pair->weights2 = &second->weights; this_cell_pair->cellindex2 = icell2; this_cell_pair->min_dx = min_dx; @@ -1683,9 +1649,6 @@ struct cell_pair_DOUBLE * generate_cell_pairs_mocks_theta_ra_dec_DOUBLE(cellarra this_cell_pair->closest_y1 = closest_y1; this_cell_pair->closest_z1 = closest_z1; - this_cell_pair->ra_bin_offset = iira; - this_cell_pair->dec_bin_offset = dec_refine; - this_cell_pair->same_cell = (autocorr == 1 && icell2 == icell) ? 1:0; num_cell_pairs++; From c9bbeda03e999dbb9270246d534617cac1f532e3 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Wed, 19 Jun 2019 06:19:20 +1000 Subject: [PATCH 4/5] (Hopefully) Made the changelog entry clearer [ci skip] --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a572a3dd..1c6ad63b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -15,7 +15,7 @@ New features Enhancements ------------ -- Reduce gridlink memory footprint [#186] +- Reduce memory footprint of the cell pairs [#186] 2.3.0 (2019-05-20) From 9ed92bc8c2dc6359f781154b1203b9cf95a35928 Mon Sep 17 00:00:00 2001 From: Lehman Garrison Date: Tue, 18 Jun 2019 16:28:12 -0400 Subject: [PATCH 5/5] Fix Python version so Travis will run --- Corrfunc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Corrfunc/__init__.py b/Corrfunc/__init__.py index 288cb230..04211be9 100644 --- a/Corrfunc/__init__.py +++ b/Corrfunc/__init__.py @@ -10,7 +10,7 @@ unicode_literals) import os -__version__ = "2.3.0" +__version__ = "2.3.1" __author__ = "Manodeep Sinha "