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
33df9332
Commit
33df9332
authored
7 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Tests various pairs of cells with different numbers of active particles.
parent
002b056c
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
+90
-24
90 additions, 24 deletions
tests/testActivePair.c
with
90 additions
and
24 deletions
tests/testActivePair.c
+
90
−
24
View file @
33df9332
...
...
@@ -45,7 +45,7 @@
*/
struct
cell
*
make_cell
(
size_t
n
,
double
*
offset
,
double
size
,
double
h
,
double
density
,
long
long
*
partId
,
double
pert
,
double
h_pert
)
{
double
h_pert
,
double
fraction_active
)
{
const
size_t
count
=
n
*
n
*
n
;
const
double
volume
=
size
*
size
*
size
;
float
h_max
=
0
.
f
;
...
...
@@ -100,8 +100,10 @@ struct cell *make_cell(size_t n, double *offset, double size, double h,
part
->
entropy
=
1
.
f
;
part
->
entropy_one_over_gamma
=
1
.
f
;
#endif
part
->
time_bin
=
1
;
if
(
random_uniform
(
0
,
1
.
f
)
<
fraction_active
)
part
->
time_bin
=
1
;
else
part
->
time_bin
=
num_time_bins
+
1
;
#ifdef SWIFT_DEBUG_CHECKS
part
->
ti_drift
=
8
;
...
...
@@ -171,7 +173,7 @@ void end_calculation(struct cell *c) {
* @brief Dump all the particles to a file
*/
void
dump_particle_fields
(
char
*
fileName
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
FILE
*
file
=
fopen
(
fileName
,
"
w
"
);
FILE
*
file
=
fopen
(
fileName
,
"
a
"
);
/* Write header */
fprintf
(
file
,
...
...
@@ -204,26 +206,19 @@ 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
);
void
test_pair_interactions
(
struct
runner
runner
,
struct
cell
**
ci
,
struct
cell
**
cj
,
char
*
swiftOutputFileName
,
char
*
bruteForceOutputFileName
)
{
void
test_pair_interactions
(
struct
runner
*
runner
,
struct
cell
**
ci
,
struct
cell
**
cj
,
char
*
swiftOutputFileName
,
char
*
bruteForceOutputFileName
)
{
runner_do_sort
(
&
runner
,
*
ci
,
0x1FFF
,
0
,
0
);
runner_do_sort
(
&
runner
,
*
cj
,
0x1FFF
,
0
,
0
);
runner_do_sort
(
runner
,
*
ci
,
0x1FFF
,
0
,
0
);
runner_do_sort
(
runner
,
*
cj
,
0x1FFF
,
0
,
0
);
/* Zero the fields */
zero_particle_fields
(
*
ci
);
zero_particle_fields
(
*
cj
);
#ifdef WITH_VECTORIZATION
runner
.
ci_cache
.
count
=
0
;
cache_init
(
&
runner
.
ci_cache
,
512
);
runner
.
cj_cache
.
count
=
0
;
cache_init
(
&
runner
.
cj_cache
,
512
);
#endif
/* Run the test */
runner_dopair1_branch_density
(
&
runner
,
*
ci
,
*
cj
);
runner_dopair1_branch_density
(
runner
,
*
ci
,
*
cj
);
/* Let's get physical ! */
end_calculation
(
*
ci
);
...
...
@@ -239,7 +234,7 @@ void test_pair_interactions(struct runner runner,
zero_particle_fields
(
*
cj
);
/* Run the brute-force test */
pairs_all_density
(
&
runner
,
*
ci
,
*
cj
);
pairs_all_density
(
runner
,
*
ci
,
*
cj
);
/* Let's get physical ! */
end_calculation
(
*
ci
);
...
...
@@ -251,12 +246,12 @@ void test_pair_interactions(struct runner runner,
int
main
(
int
argc
,
char
*
argv
[])
{
size_t
particles
=
0
,
runs
=
0
,
type
=
0
;
double
offset
[
3
]
=
{
0
,
0
,
0
},
h
=
1
.
23485
,
size
=
1
.,
rho
=
1
.;
double
offset
1
[
3
]
=
{
0
,
0
,
0
},
offset2
[
3
]
=
{
1
.,
0
.,
0
.},
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
;
struct
runner
*
runner
;
char
c
;
static
long
long
partId
=
0
;
char
outputFileNameExtension
[
200
]
=
""
;
...
...
@@ -322,7 +317,13 @@ int main(int argc, char *argv[]) {
engine
.
time
=
0
.
1
f
;
engine
.
ti_current
=
8
;
engine
.
max_active_bin
=
num_time_bins
;
runner
.
e
=
&
engine
;
if
(
posix_memalign
((
void
**
)
&
runner
,
part_align
,
sizeof
(
struct
runner
))
!=
0
)
{
error
(
"couldn't allocate runner"
);
}
runner
->
e
=
&
engine
;
/* Create output file names. */
sprintf
(
swiftOutputFileName
,
"swift_dopair_%s.dat"
,
...
...
@@ -330,12 +331,77 @@ int main(int argc, char *argv[]) {
sprintf
(
bruteForceOutputFileName
,
"brute_force_%s.dat"
,
outputFileNameExtension
);
ci
=
make_cell
(
particles
,
offset
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
);
for
(
size_t
i
=
0
;
i
<
type
+
1
;
++
i
)
offset
[
i
]
=
1
.;
cj
=
make_cell
(
particles
,
offset
,
size
,
h
,
rho
,
&
partId
,
perturbation
,
h_pert
);
/* Delete files if they already exist. */
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
);
runner
->
cj_cache
.
count
=
0
;
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
);
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
,
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
);
...
...
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