Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dADP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luca Tornatore
dADP
Commits
2d2c6a6d
Commit
2d2c6a6d
authored
Feb 29, 2024
by
lykos98
Browse files
Options
Downloads
Patches
Plain Diff
node bounding box impl
parent
fe30144a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tree/tree.c
+61
-33
61 additions, 33 deletions
src/tree/tree.c
src/tree/tree.h
+2
-2
2 additions, 2 deletions
src/tree/tree.h
with
63 additions
and
35 deletions
src/tree/tree.c
+
61
−
33
View file @
2d2c6a6d
...
@@ -1209,8 +1209,8 @@ void top_tree_free(global_context_t *ctx, top_kdtree_t *tree)
...
@@ -1209,8 +1209,8 @@ void top_tree_free(global_context_t *ctx, top_kdtree_t *tree)
{
{
for
(
int
i
=
0
;
i
<
tree
->
count
;
++
i
)
for
(
int
i
=
0
;
i
<
tree
->
count
;
++
i
)
{
{
if
(
tree
->
_nodes
[
i
].
node_box
_lb
)
free
(
tree
->
_nodes
[
i
].
node_box
_lb
);
if
(
tree
->
_nodes
[
i
].
lb_
node_box
)
free
(
tree
->
_nodes
[
i
].
lb_
node_box
);
if
(
tree
->
_nodes
[
i
].
node_box
_ub
)
free
(
tree
->
_nodes
[
i
].
node_box
_ub
);
if
(
tree
->
_nodes
[
i
].
ub_
node_box
)
free
(
tree
->
_nodes
[
i
].
ub_
node_box
);
}
}
free
(
tree
->
_nodes
);
free
(
tree
->
_nodes
);
return
;
return
;
...
@@ -1225,18 +1225,13 @@ top_kdtree_node_t* top_tree_generate_node(global_context_t* ctx, top_kdtree_t* t
...
@@ -1225,18 +1225,13 @@ top_kdtree_node_t* top_tree_generate_node(global_context_t* ctx, top_kdtree_t* t
tree
->
_capacity
=
new_cap
;
tree
->
_capacity
=
new_cap
;
}
}
top_kdtree_node_t
*
ptr
=
tree
->
_nodes
+
tree
->
count
;
top_kdtree_node_t
*
ptr
=
tree
->
_nodes
+
tree
->
count
;
ptr
->
node_box
_lb
=
(
float_t
*
)
malloc
(
ctx
->
dims
*
sizeof
(
float_t
));
ptr
->
lb_
node_box
=
(
float_t
*
)
malloc
(
ctx
->
dims
*
sizeof
(
float_t
));
ptr
->
node_box
_ub
=
(
float_t
*
)
malloc
(
ctx
->
dims
*
sizeof
(
float_t
));
ptr
->
ub_
node_box
=
(
float_t
*
)
malloc
(
ctx
->
dims
*
sizeof
(
float_t
));
++
tree
->
count
;
++
tree
->
count
;
return
ptr
;
return
ptr
;
}
}
void
compute_boxes
(
global_context_t
*
ctx
,
top_kdtree_t
*
tree
)
{
return
;
}
void
build_top_kdtree
(
global_context_t
*
ctx
,
pointset_t
*
og_pointset
,
top_kdtree_t
*
tree
,
int
n_bins
,
float_t
tolerance
)
void
build_top_kdtree
(
global_context_t
*
ctx
,
pointset_t
*
og_pointset
,
top_kdtree_t
*
tree
,
int
n_bins
,
float_t
tolerance
)
{
{
size_t
tot_n_points
=
0
;
size_t
tot_n_points
=
0
;
...
@@ -1283,6 +1278,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
...
@@ -1283,6 +1278,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
top_kdtree_node_t
*
current_node
=
current_node
=
top_tree_generate_node
(
ctx
,
tree
);
top_kdtree_node_t
*
current_node
=
current_node
=
top_tree_generate_node
(
ctx
,
tree
);
/* insert node */
/* insert node */
/*
MPI_DB_PRINT("Handling partition: \n\tcurrent_node %p, \n\tdim %d, \n\tn_points %d, \n\tstart_proc %d, \n\tn_procs %d, \n\tparent %p\n",
MPI_DB_PRINT("Handling partition: \n\tcurrent_node %p, \n\tdim %d, \n\tn_points %d, \n\tstart_proc %d, \n\tn_procs %d, \n\tparent %p\n",
current_node,
current_node,
current_partition.d,
current_partition.d,
...
@@ -1290,7 +1286,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
...
@@ -1290,7 +1286,7 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
current_partition.start_proc,
current_partition.start_proc,
current_partition.n_procs,
current_partition.n_procs,
current_partition.parent);
current_partition.parent);
MPI_DB_PRINT
(
"-------------------
\n\n
"
);
*/
switch
(
current_partition
.
lr
)
{
switch
(
current_partition
.
lr
)
{
case
TOP_TREE_LCH
:
case
TOP_TREE_LCH
:
...
@@ -1298,6 +1294,18 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
...
@@ -1298,6 +1294,18 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
{
{
current_node
->
parent
=
current_partition
.
parent
;
current_node
->
parent
=
current_partition
.
parent
;
current_node
->
parent
->
lch
=
current_node
;
current_node
->
parent
->
lch
=
current_node
;
/* compute the box */
/*
* left child has lb equal to parent
* ub equal to parent except for the dim of splitting
*/
int
parent_split_dim
=
current_node
->
parent
->
split_dim
;
float_t
parent_hp
=
current_node
->
parent
->
data
;
memcpy
(
current_node
->
lb_node_box
,
current_node
->
parent
->
lb_node_box
,
ctx
->
dims
*
sizeof
(
float_t
));
memcpy
(
current_node
->
ub_node_box
,
current_node
->
parent
->
ub_node_box
,
ctx
->
dims
*
sizeof
(
float_t
));
current_node
->
ub_node_box
[
parent_split_dim
]
=
parent_hp
;
}
}
break
;
break
;
...
@@ -1306,13 +1314,31 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
...
@@ -1306,13 +1314,31 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
{
{
current_node
->
parent
=
current_partition
.
parent
;
current_node
->
parent
=
current_partition
.
parent
;
current_node
->
parent
->
rch
=
current_node
;
current_node
->
parent
->
rch
=
current_node
;
int
parent_split_dim
=
current_node
->
parent
->
split_dim
;
float_t
parent_hp
=
current_node
->
parent
->
data
;
/*
* right child has ub equal to parent
* lb equal to parent except for the dim of splitting
*/
memcpy
(
current_node
->
lb_node_box
,
current_node
->
parent
->
lb_node_box
,
ctx
->
dims
*
sizeof
(
float_t
));
memcpy
(
current_node
->
ub_node_box
,
current_node
->
parent
->
ub_node_box
,
ctx
->
dims
*
sizeof
(
float_t
));
current_node
->
lb_node_box
[
parent_split_dim
]
=
parent_hp
;
}
}
break
;
break
;
default:
default:
{
tree
->
root
=
current_node
;
memcpy
(
current_node
->
lb_node_box
,
og_pointset
->
lb_box
,
ctx
->
dims
*
sizeof
(
float_t
));
memcpy
(
current_node
->
ub_node_box
,
og_pointset
->
ub_box
,
ctx
->
dims
*
sizeof
(
float_t
));
}
break
;
break
;
}
}
current_node
->
split_dim
=
selected_dim
;
current_node
->
split_dim
=
current_partition
.
d
;
current_node
->
parent
=
current_partition
.
parent
;
current_node
->
parent
=
current_partition
.
parent
;
current_node
->
lch
=
NULL
;
current_node
->
lch
=
NULL
;
current_node
->
rch
=
NULL
;
current_node
->
rch
=
NULL
;
...
@@ -1332,6 +1358,10 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
...
@@ -1332,6 +1358,10 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
int
procs_left
=
current_partition
.
n_procs
*
fraction
;
int
procs_left
=
current_partition
.
n_procs
*
fraction
;
int
procs_right
=
current_partition
.
n_procs
-
procs_left
;
int
procs_right
=
current_partition
.
n_procs
-
procs_left
;
/*
MPI_DB_PRINT("Chosing as guess: %lf, seareching for %lf, obtained %lf\n", g.x_guess, fraction, g.ep);
MPI_DB_PRINT("-------------------\n\n");
*/
int
next_dimension
=
(
++
selected_dim
)
%
(
ctx
->
dims
);
int
next_dimension
=
(
++
selected_dim
)
%
(
ctx
->
dims
);
partition_t
left_partition
=
{
partition_t
left_partition
=
{
...
@@ -1362,8 +1392,6 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
...
@@ -1362,8 +1392,6 @@ void build_top_kdtree(global_context_t *ctx, pointset_t *og_pointset, top_kdtree
{
{
current_node
->
owner
=
current_partition
.
start_proc
;
current_node
->
owner
=
current_partition
.
start_proc
;
}
}
/* set the root */
if
(
current_node
->
parent
==
NULL
)
tree
->
root
=
current_node
;
}
}
MPI_DB_PRINT
(
"Root is %p
\n
"
,
tree
->
root
);
MPI_DB_PRINT
(
"Root is %p
\n
"
,
tree
->
root
);
...
...
This diff is collapsed.
Click to expand it.
src/tree/tree.h
+
2
−
2
View file @
2d2c6a6d
...
@@ -42,8 +42,8 @@ typedef struct partition_queue_t
...
@@ -42,8 +42,8 @@ typedef struct partition_queue_t
typedef
struct
top_kdtree_node_t
typedef
struct
top_kdtree_node_t
{
{
float_t
data
;
float_t
data
;
float_t
*
node_box
_lb
;
//Needed?
float_t
*
lb_
node_box
;
//Needed?
float_t
*
node_box
_ub
;
//Needed?
float_t
*
ub_
node_box
;
//Needed?
int
owner
;
int
owner
;
int
split_dim
;
int
split_dim
;
size_t
n_points
;
size_t
n_points
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment