Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QuickSched
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
QuickSched
Commits
56412a63
Commit
56412a63
authored
Sep 2, 2014
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
The sanity checks are now activated only if SANITY_CHECKS is defined.
parent
1513f332
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/test_bh_sorted.c
+65
-34
65 additions, 34 deletions
examples/test_bh_sorted.c
with
65 additions
and
34 deletions
examples/test_bh_sorted.c
+
65
−
34
View file @
56412a63
...
...
@@ -44,6 +44,8 @@
#define iact_pair_direct iact_pair_direct_unsorted
#define ICHECK -1
#define SANITY_CHECKS
/** Data structure for the particles. */
struct
part
{
double
x
[
3
];
...
...
@@ -570,11 +572,13 @@ void cell_split(struct cell *c, struct qsched *s) {
for
(
k
=
0
;
k
<
8
;
k
++
)
if
(
progenitors
[
k
]
->
count
>
0
)
{
c
->
firstchild
=
progenitors
[
k
];
// message( "first child= %d", k);
break
;
}
#ifdef SANITY_CHECKS
if
(
c
->
firstchild
==
NULL
)
error
(
"Cell has been split but all progenitors have 0 particles"
);
#endif
/* Prepare the pointers. */
for
(
k
=
0
;
k
<
8
;
k
++
)
{
...
...
@@ -682,6 +686,8 @@ static inline void make_interact_pc(struct cell* leaf, struct cell* cj) {
double
com
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
float
mcom
,
dx
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
},
r2
,
ir
,
w
;
#ifdef SANITY_CHECKS
/* Sanity checks */
if
(
leaf
->
count
==
0
)
error
(
"Empty cell!"
);
...
...
@@ -697,6 +703,8 @@ static inline void make_interact_pc(struct cell* leaf, struct cell* cj) {
error
(
"com does not seem to have been set."
);
}
#endif
/* Init the com's data. */
for
(
k
=
0
;
k
<
3
;
k
++
)
com
[
k
]
=
cj
->
new
.
com
[
k
];
mcom
=
cj
->
new
.
mass
;
...
...
@@ -780,11 +788,12 @@ static inline int are_neighbours(struct cell* ci, struct cell* cj){
*/
static
inline
void
iact_pair_pc
(
struct
cell
*
ci
,
struct
cell
*
cj
,
struct
cell
*
leaf
)
{
int
count_i
=
ci
->
count
,
count_j
=
cj
->
count
;
struct
cell
*
cp
,
*
cps
;
#ifdef SANITY_CHECKS
/* Early abort? */
if
(
count
_i
==
0
||
count
_j
==
0
)
error
(
"Empty cell !"
);
if
(
ci
->
count
==
0
||
cj
->
count
==
0
)
error
(
"Empty cell !"
);
/* Sanity check */
if
(
ci
==
cj
)
...
...
@@ -795,6 +804,8 @@ static inline void iact_pair_pc(struct cell *ci, struct cell *cj, struct cell *l
if
(
!
is_inside
(
leaf
,
ci
)
)
error
(
"The impossible has happened: The leaf is not within ci"
);
#endif
/* Are the cells NOT direct neighbours? */
if
(
!
are_neighbours
(
ci
,
cj
)
)
{
...
...
@@ -822,16 +833,25 @@ static inline void iact_pair_pc(struct cell *ci, struct cell *cj, struct cell *l
}
/**
* @brief Compute the interactions between all particles in a leaf and
* and all the monopoles in the cell c
*
* @param c The #cell containing the monopoles
* @param leaf The #cell containing the particles
*/
static
inline
void
iact_self_pc
(
struct
cell
*
c
,
struct
cell
*
leaf
)
{
struct
cell
*
cp
,
*
cps
;
#ifdef SANITY_CHECKS
/* Early abort? */
if
(
c
->
count
==
0
)
error
(
"Empty cell !"
);
if
(
c
->
split
)
{
if
(
!
c
->
split
)
error
(
"Cell is not split !"
);
#endif
/* Find in which subcell of c the leaf is */
for
(
cp
=
c
->
firstchild
;
cp
!=
c
->
sibling
;
cp
=
cp
->
sibling
)
{
...
...
@@ -856,13 +876,6 @@ static inline void iact_self_pc(struct cell *c, struct cell *leaf) {
}
}
}
}
...
...
@@ -892,10 +905,14 @@ static inline void iact_pair_direct_unsorted(struct cell *ci, struct cell *cj) {
double
xi
[
3
];
float
dx
[
3
],
ai
[
3
],
mi
,
mj
,
r2
,
w
,
ir
;
#ifdef SANITY_CHECKS
/* Bad stuff will happen if cell sizes are different */
if
(
ci
->
h
!=
cj
->
h
)
error
(
"Non matching cell sizes !! h_i=%f h_j=%f
\n
"
,
ci
->
h
,
cj
->
h
);
#endif
/* Loop over all particles in ci... */
for
(
i
=
0
;
i
<
count_i
;
i
++
)
{
...
...
@@ -957,10 +974,14 @@ static inline void iact_pair_direct_sorted(struct cell *ci, struct cell *cj) {
double
xi
[
3
];
float
dx
[
3
],
ai
[
3
],
mi
,
mj
,
r2
,
w
,
ir
;
#ifdef SANITY_CHECKS
/* Bad stuff will happen if cell sizes are different */
if
(
ci
->
h
!=
cj
->
h
)
error
(
"Non matching cell sizes !! h_i=%f h_j=%f
\n
"
,
ci
->
h
,
cj
->
h
);
#endif
/* Get the sorted indices and stuff. */
struct
index
*
ind_i
,
*
ind_j
;
float
corr
;
...
...
@@ -1120,11 +1141,12 @@ static inline void iact_pair_direct_sorted(struct cell *ci, struct cell *cj) {
*/
void
iact_pair
(
struct
cell
*
ci
,
struct
cell
*
cj
)
{
int
count_i
=
ci
->
count
,
count_j
=
cj
->
count
;
struct
cell
*
cp
,
*
cps
;
#ifdef SANITY_CHECKS
/* Early abort? */
if
(
count
_i
==
0
||
count
_j
==
0
)
if
(
ci
->
count
==
0
||
cj
->
count
==
0
)
error
(
"Empty cell !"
);
/* Bad stuff will happen if cell sizes are different */
...
...
@@ -1136,6 +1158,8 @@ void iact_pair(struct cell *ci, struct cell *cj) {
error
(
"The impossible has happened: pair interaction between a cell and "
"itself."
);
#endif
/* Are the cells direct neighbours? */
if
(
are_neighbours
(
ci
,
cj
)
)
{
...
...
@@ -1174,9 +1198,13 @@ void iact_self_direct(struct cell *c) {
struct
part
*
parts
=
c
->
parts
;
struct
cell
*
cp
,
*
cps
;
#ifdef SANITY_CHECKS
/* Early abort? */
if
(
count
==
0
)
error
(
"Empty cell !"
);
#endif
/* If the cell is split, interact each progeny with itself, and with
each of its siblings. */
if
(
c
->
split
)
{
...
...
@@ -1250,10 +1278,13 @@ void create_tasks(struct qsched *s, struct cell *ci, struct cell *cj) {
qsched_task_t
tid
;
struct
cell
*
data
[
2
],
*
cp
,
*
cps
;
#ifdef SANITY_CHECKS
/* If either cell is empty, stop. */
if
(
ci
->
count
==
0
||
(
cj
!=
NULL
&&
cj
->
count
==
0
))
error
(
"Empty cell !"
);
#endif
/* Single cell? */
if
(
cj
==
NULL
)
{
...
...
@@ -1693,7 +1724,7 @@ void test_bh(int N, int nr_threads, int runs, char *fileName) {
}
message
(
"Average number of parts per leaf is %f."
,
((
double
)
N
)
/
nr_leaves
);
#if ICHECK > 0
//
#if ICHECK > 0
printf
(
"----------------------------------------------------------
\n
"
);
/* Do a N^2 interactions calculation */
...
...
@@ -1706,7 +1737,7 @@ void test_bh(int N, int nr_threads, int runs, char *fileName) {
toc_exact
-
tic_exact
,
(
float
)(
toc_exact
-
tic_exact
));
printf
(
"----------------------------------------------------------
\n
"
);
#endif
//
#endif
/* Create the tasks. */
tic
=
getticks
();
...
...
...
...
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
sign in
to comment