Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
2dfbc2bb
Commit
2dfbc2bb
authored
8 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Added more test cases and restructured functions.
parent
2cc2d44c
No related branches found
No related tags found
1 merge request
!396
Avx512 fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testActivePair.c
+127
-65
127 additions, 65 deletions
tests/testActivePair.c
with
127 additions
and
65 deletions
tests/testActivePair.c
+
127
−
65
View file @
2dfbc2bb
...
...
@@ -24,6 +24,7 @@
#include
<stdlib.h>
#include
<string.h>
#include
<unistd.h>
#include
<time.h>
/* Local headers. */
#include
"swift.h"
...
...
@@ -206,6 +207,9 @@ void runner_doself1_density_vec(struct runner *r, struct cell *ci);
void
runner_dopair1_branch_density
(
struct
runner
*
r
,
struct
cell
*
ci
,
struct
cell
*
cj
);
/**
* @brief Computes the pair interactions of two cells using SWIFT and a brute force implementation.
*/
void
test_pair_interactions
(
struct
runner
*
runner
,
struct
cell
**
ci
,
struct
cell
**
cj
,
char
*
swiftOutputFileName
,
char
*
bruteForceOutputFileName
)
{
...
...
@@ -244,11 +248,112 @@ void test_pair_interactions(struct runner *runner,
}
/**
* @brief Computes the pair interactions of two cells in various configurations.
*/
void
test_all_pair_interactions
(
struct
runner
*
runner
,
double
*
offset2
,
size_t
particles
,
double
size
,
double
h
,
double
rho
,
long
long
*
partId
,
double
perturbation
,
double
h_pert
,
char
*
swiftOutputFileName
,
char
*
bruteForceOutputFileName
)
{
double
offset1
[
3
]
=
{
0
,
0
,
0
};
struct
cell
*
ci
,
*
cj
;
/* All active particles. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
1
.);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
1
.);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* Half particles are active. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
5
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
5
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* All particles inactive. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* 10% of particles active. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
1
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
1
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* One active cell one inactive cell. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
1
.
0
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* One active cell one inactive cell. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
1
.
0
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* Smaller cells, all active. */
ci
=
make_cell
(
2
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
1
.
0
);
cj
=
make_cell
(
2
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
1
.
0
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* Different numbers of particles in each cell. */
ci
=
make_cell
(
10
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
5
);
cj
=
make_cell
(
3
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
75
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* One cell inactive and the other only half active. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
5
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* One cell inactive and the other only half active. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
partId
,
perturbation
,
h_pert
,
0
.
5
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
/* Clean things to make the sanitizer happy ... */
clean_up
(
ci
);
clean_up
(
cj
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
size_t
particles
=
0
,
runs
=
0
,
type
=
0
;
double
offset1
[
3
]
=
{
0
,
0
,
0
},
offset2
[
3
]
=
{
1
.,
0
.,
0
.},
h
=
1
.
23485
,
size
=
1
.,
rho
=
1
.;
double
h
=
1
.
23485
,
size
=
1
.,
rho
=
1
.;
double
perturbation
=
0
.
1
,
h_pert
=
1
.
1
;
struct
cell
*
ci
,
*
cj
;
struct
space
space
;
struct
engine
engine
;
struct
runner
*
runner
;
...
...
@@ -265,9 +370,10 @@ int main(int argc, char *argv[]) {
/* Choke on FP-exceptions */
feenableexcept
(
FE_DIVBYZERO
|
FE_INVALID
|
FE_OVERFLOW
);
srand
(
0
);
/* Generate a RNG seed from time. */
unsigned
int
seed
=
time
(
NULL
);
while
((
c
=
getopt
(
argc
,
argv
,
"h:p:n:r:t:d:f:"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"h:p:n:r:t:d:
s:
f:"
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
sscanf
(
optarg
,
"%lf"
,
&
h
);
...
...
@@ -287,6 +393,9 @@ int main(int argc, char *argv[]) {
case
'd'
:
sscanf
(
optarg
,
"%lf"
,
&
perturbation
);
break
;
case
's'
:
sscanf
(
optarg
,
"%u"
,
&
seed
);
break
;
case
'f'
:
strcpy
(
outputFileNameExtension
,
optarg
);
break
;
...
...
@@ -306,11 +415,16 @@ int main(int argc, char *argv[]) {
"
\n
-h DISTANCE=1.2348 - smoothing length"
"
\n
-p - Random fractional change in h, h=h*random(1,p)"
"
\n
-d pert - perturbation to apply to the particles [0,1["
"
\n
-s seed - seed for RNG"
"
\n
-f fileName - part of the file name used to save the dumps
\n
"
,
argv
[
0
]);
exit
(
1
);
}
/* Seed RNG. */
message
(
"Seed used for RNG: %d"
,
seed
);
srand
(
seed
);
space
.
periodic
=
0
;
engine
.
s
=
&
space
;
...
...
@@ -335,10 +449,6 @@ int main(int argc, char *argv[]) {
remove
(
swiftOutputFileName
);
remove
(
bruteForceOutputFileName
);
/* All active particles. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.);
#ifdef WITH_VECTORIZATION
runner
->
ci_cache
.
count
=
0
;
cache_init
(
&
runner
->
ci_cache
,
512
);
...
...
@@ -346,65 +456,17 @@ int main(int argc, char *argv[]) {
cache_init
(
&
runner
->
cj_cache
,
512
);
#endif
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* Half particles are active. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.
5
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.
5
);
double
offset
[
3
]
=
{
1
.,
0
.,
0
.};
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
/* Test a pair of cells face-on. */
test_all_pair_interactions
(
runner
,
offset
,
particles
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* All particles inactive. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* 10% of particles active. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.
1
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.
1
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* One active cell one inactive cell. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.
0
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
0
.);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* One active cell one inactive cell. */
ci
=
make_cell
(
particles
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.
0
);
cj
=
make_cell
(
particles
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.
0
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
clean_up
(
ci
);
clean_up
(
cj
);
/* Smaller cells, all active. */
ci
=
make_cell
(
2
,
offset1
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.
0
);
cj
=
make_cell
(
2
,
offset2
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
1
.
0
);
test_pair_interactions
(
runner
,
&
ci
,
&
cj
,
swiftOutputFileName
,
bruteForceOutputFileName
);
/* Clean things to make the sanitizer happy ... */
clean_up
(
ci
);
clean_up
(
cj
);
/* Test a pair of cells edge-on. */
offset
[
0
]
=
1
.;
offset
[
1
]
=
1
.;
offset
[
2
]
=
0
.;
test_all_pair_interactions
(
runner
,
offset
,
particles
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
swiftOutputFileName
,
bruteForceOutputFileName
);
/* Test a pair of cells corner-on. */
offset
[
0
]
=
1
.;
offset
[
1
]
=
1
.;
offset
[
2
]
=
1
.;
test_all_pair_interactions
(
runner
,
offset
,
particles
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
,
swiftOutputFileName
,
bruteForceOutputFileName
);
return
0
;
}
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