[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 336ddee 04/19: Error in `match_kdtree_worker`
From: |
Mohammad Akhlaghi |
Subject: |
[gnuastro-commits] master 336ddee 04/19: Error in `match_kdtree_worker` in lib/match.c |
Date: |
Sun, 14 Nov 2021 20:40:58 -0500 (EST) |
branch: master
commit 336ddee7178e5b2f71ce440a9b1baccb1fcfeda3
Author: Sachin Kumar Singh <sachinkumarsingh092@gmail.com>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Error in `match_kdtree_worker` in lib/match.c
A segmentation falut occurs during the execution of tests/during-dev.sh
which is traced back to `gal_pointer_alloc` in `match_kdtree_worker` in
lib/match.c.
---
bin/match/match.c | 11 +++++++++--
lib/gnuastro/match.h | 6 +++++-
lib/match.c | 14 +++++++++++++-
3 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/bin/match/match.c b/bin/match/match.c
index a8a2bbe..cf94b15 100644
--- a/bin/match/match.c
+++ b/bin/match/match.c
@@ -32,6 +32,7 @@ along with Gnuastro. If not, see
<http://www.gnu.org/licenses/>.
#include <gnuastro/table.h>
#include <gnuastro/kdtree.h>
#include <gnuastro/pointer.h>
+#include <gnuastro/threads.h>
#include <gnuastro/permutation.h>
#include <gnuastro-internal/checkset.h>
@@ -500,7 +501,10 @@ match_catalog_kdtree_auto(struct matchparams *p)
static gal_data_t *
match_catalog_kdtree(struct matchparams *p)
{
+ size_t root;
gal_data_t *out=NULL;
+ gal_data_t *kdtree=NULL;
+ size_t numthreads = gal_threads_number();
/* If we are in automatic mode, we should look at the data (number of
rows/columns) and system (number of threads) to decide if the mode
@@ -518,8 +522,11 @@ match_catalog_kdtree(struct matchparams *p)
/* Do the k-d tree matching. */
case MATCH_KDTREE_INTERNAL:
- error(EXIT_FAILURE, 0, "%s: internal kd tree usage not "
- "yet implemented", __func__);
+ kdtree = gal_kdtree_create(p->cols1, &root);
+ out = gal_match_kdtree(p->cols1, p->cols2, kdtree, root,
+ p->aperture->array, numthreads,
+ p->cp.minmapsize, p->cp.quietmmap);
+ gal_list_data_free(kdtree);
break;
/* No 'default' necessary because the modes include disabling. */
diff --git a/lib/gnuastro/match.h b/lib/gnuastro/match.h
index aa1a7c6..b35d918 100644
--- a/lib/gnuastro/match.h
+++ b/lib/gnuastro/match.h
@@ -51,7 +51,11 @@ gal_match_coordinates(gal_data_t *coord1, gal_data_t *coord2,
size_t *nummatched);
-
+gal_data_t *
+gal_match_kdtree(gal_data_t *coord1, gal_data_t *coord2,
+ gal_data_t *coord1_kdtree, size_t kdtree_root,
+ double *aperture, size_t numthreads, size_t minmapsize,
+ int quietmmap);
__END_C_DECLS /* From C++ preparations */
diff --git a/lib/match.c b/lib/match.c
index 4497788..ff60fa5 100644
--- a/lib/match.c
+++ b/lib/match.c
@@ -1006,7 +1006,7 @@ match_kdtree_worker(void *in_prm)
/* High level definitions. */
gal_data_t *ccol;
- double *point, least_dist;
+ double *point=NULL, least_dist;
size_t i, j, index, mindex;
/* Allocate space for all the matching points (based on the number of
@@ -1020,8 +1020,12 @@ match_kdtree_worker(void *in_prm)
/* Fill the 'point' for this thread. */
j=0;
index = tprm->indexs[i];
+ printf("%s: index = %zu point = %g ccol = %g\n", __func__, index,
point[0], ((double *)(p->coord2->array))[index]);
for(ccol=p->coord2; ccol!=NULL; ccol=ccol->next)
+ {
point[ j++ ] = ((double *)(ccol->array))[index];
+ printf("%s: point: %g\n", __func__, point[j]);
+ }
/* Find the index of the nearest neighbor to this item. */
mindex=gal_kdtree_nearest_neighbour(p->coord1, p->coord1_kdtree,
@@ -1088,6 +1092,14 @@ gal_match_kdtree(gal_data_t *coord1, gal_data_t *coord2,
p.c2match=c2match->array;
p.kdtree_root=kdtree_root;
p.coord1_kdtree=coord1_kdtree;
+
+ /** NUMBER OF ARGUMENTS IS INCORRECT BUT COMPILER FINDS IT TO BE FINE **/
gal_threads_spin_off(match_kdtree_worker, &p, coord2->size, numthreads,
minmapsize, quietmmap);
+
+ for (int i = 0; i < coord2->size; ++i)
+ printf("%s: size of c2match = %zu", __func__, p.c2match[i]);
+
+ exit(0);
+ return c2match;
}
- [gnuastro-commits] master updated (33b7b70 -> f5d7d1a), Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 0dcaf02 02/19: Match: Added build functionalty for kdtree, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master c36f753 01/19: Match: Option to work with k-d trees has been defined, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master e04f4ac 03/19: First implementation of k-d tree matching, not complete, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 20ad77d 07/19: Final output for kdtree matching, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 7354e33 09/19: Library (match.h): match_coordinate_ replaced by match_sort_based_, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 03d1a25 15/19: Library (fits.h): corrected segmentation fault in parallel reading, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 336ddee 04/19: Error in `match_kdtree_worker` in lib/match.c,
Mohammad Akhlaghi <=
- [gnuastro-commits] master 2877acb 05/19: Added fits files for testing in `during-dev-test-data`, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 48d760d 12/19: Library (match.h): k-d tree method discards regions with no overlap, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master d0b19b8 10/19: Match: make check script for k-d tree matching now executable, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 095c788 13/19: Match: matched rows aren't permuted, but new column allocated, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 9e258a8 14/19: Library (fits.h): reading table columns now done in parallel, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 29f8b20 16/19: Table and Arithmetic: corrected some memory leaks, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 8b17675 06/19: Corrected segmentation fault, included aperture, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master a7bfa5b 11/19: Match: k-d tree matching UI fixed, to do: finalizing docs and tests, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master f5d7d1a 19/19: Match: added tests, completed docs of new k-d tree based matching, Mohammad Akhlaghi, 2021/11/14
- [gnuastro-commits] master 6f7ff61 08/19: Library (match.h): Using the old infra-structure for double-matches, Mohammad Akhlaghi, 2021/11/14