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
d7e1dbef
Commit
d7e1dbef
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Google style formatting
parent
d4ad8e44
No related branches found
No related tags found
1 merge request
!64
Agreed upon version of the density vectorization test
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/tools.c
+23
-35
23 additions, 35 deletions
src/tools.c
src/tools.h
+0
-2
0 additions, 2 deletions
src/tools.h
tests/testVectorize.c
+0
-2
0 additions, 2 deletions
tests/testVectorize.c
with
23 additions
and
39 deletions
src/tools.c
+
23
−
35
View file @
d7e1dbef
...
@@ -19,20 +19,17 @@
...
@@ -19,20 +19,17 @@
*
*
******************************************************************************/
******************************************************************************/
#include
<math.h>
#include
<math.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<stddef.h>
#include
<stddef.h>
#include
<stdio.h>
#include
<stdio.h>
#include
"error.h"
#include
"error.h"
#include
"part.h"
#include
"part.h"
#include
"cell.h"
#include
"cell.h"
#include
"tools.h"
#include
"tools.h"
#include
"swift.h"
#include
"swift.h"
/**
/**
* Factorize a given integer, attempts to keep larger pair of factors.
* Factorize a given integer, attempts to keep larger pair of factors.
*/
*/
...
@@ -50,8 +47,6 @@ void factor(int value, int *f1, int *f2) {
...
@@ -50,8 +47,6 @@ void factor(int value, int *f1, int *f2) {
}
}
}
}
/**
/**
* @brief Compute the average number of pairs per particle using
* @brief Compute the average number of pairs per particle using
* a brute-force O(N^2) computation.
* a brute-force O(N^2) computation.
...
@@ -181,24 +176,22 @@ void pairs_single_density(double *dim, long long int pid,
...
@@ -181,24 +176,22 @@ void pairs_single_density(double *dim, long long int pid,
fflush
(
stdout
);
fflush
(
stdout
);
}
}
void
pairs_all_density
(
struct
runner
*
r
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
void
pairs_all_density
(
struct
runner
*
r
,
struct
cell
*
ci
,
struct
cell
*
cj
)
{
float
r2
,
hi
,
hj
,
hig2
,
hjg2
,
dx
[
3
];
float
r2
,
hi
,
hj
,
hig2
,
hjg2
,
dx
[
3
];
struct
part
*
pi
,
*
pj
;
struct
part
*
pi
,
*
pj
;
/* Implements a double-for loop and checks every interaction */
/* Implements a double-for loop and checks every interaction */
for
(
int
i
=
0
;
i
<
ci
->
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
ci
->
count
;
++
i
)
{
pi
=
&
ci
->
parts
[
i
];
pi
=
&
ci
->
parts
[
i
];
hi
=
pi
->
h
;
hi
=
pi
->
h
;
hig2
=
hi
*
hi
*
kernel_gamma2
;
hig2
=
hi
*
hi
*
kernel_gamma2
;
for
(
int
j
=
0
;
j
<
cj
->
count
;
++
j
)
{
for
(
int
j
=
0
;
j
<
cj
->
count
;
++
j
)
{
pj
=
&
cj
->
parts
[
j
];
pj
=
&
cj
->
parts
[
j
];
/* Pairwise distance */
/* Pairwise distance */
r2
=
0
.
0
f
;
r2
=
0
.
0
f
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
...
@@ -209,28 +202,29 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
...
@@ -209,28 +202,29 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Hit or miss? */
/* Hit or miss? */
if
(
r2
<
hig2
)
{
if
(
r2
<
hig2
)
{
//message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, pi->rho);
// message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass,
// pi->rho);
/* Interact */
runner_iact_nonsym_density
(
r2
,
dx
,
hi
,
pj
->
h
,
pi
,
pj
);
//message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass, pi->rho);
/* Interact */
}
runner_iact_nonsym_density
(
r2
,
dx
,
hi
,
pj
->
h
,
pi
,
pj
);
// message("hit %d %d %f %f %f %f", i, j, sqrt(r2), hi, pi->mass,
// pi->rho);
}
}
}
}
}
/* Reverse double-for loop and checks every interaction */
/* Reverse double-for loop and checks every interaction */
for
(
int
j
=
0
;
j
<
cj
->
count
;
++
j
)
{
for
(
int
j
=
0
;
j
<
cj
->
count
;
++
j
)
{
pj
=
&
cj
->
parts
[
j
];
pj
=
&
cj
->
parts
[
j
];
hj
=
pj
->
h
;
hj
=
pj
->
h
;
hjg2
=
hj
*
hj
*
kernel_gamma2
;
hjg2
=
hj
*
hj
*
kernel_gamma2
;
for
(
int
i
=
0
;
i
<
ci
->
count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
ci
->
count
;
++
i
)
{
pi
=
&
ci
->
parts
[
i
];
pi
=
&
ci
->
parts
[
i
];
/* Pairwise distance */
/* Pairwise distance */
r2
=
0
.
0
f
;
r2
=
0
.
0
f
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
...
@@ -241,18 +235,13 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
...
@@ -241,18 +235,13 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Hit or miss? */
/* Hit or miss? */
if
(
r2
<
hjg2
)
{
if
(
r2
<
hjg2
)
{
/* Interact */
/* Interact */
runner_iact_nonsym_density
(
r2
,
dx
,
hj
,
pi
->
h
,
pj
,
pi
);
runner_iact_nonsym_density
(
r2
,
dx
,
hj
,
pi
->
h
,
pj
,
pi
);
}
}
}
}
}
}
}
}
void
pairs_single_grav
(
double
*
dim
,
long
long
int
pid
,
void
pairs_single_grav
(
double
*
dim
,
long
long
int
pid
,
struct
gpart
*
__restrict__
parts
,
int
N
,
int
periodic
)
{
struct
gpart
*
__restrict__
parts
,
int
N
,
int
periodic
)
{
...
@@ -307,7 +296,6 @@ void pairs_single_grav(double *dim, long long int pid,
...
@@ -307,7 +296,6 @@ void pairs_single_grav(double *dim, long long int pid,
pi
.
part
->
id
,
a
[
0
],
a
[
1
],
a
[
2
],
aabs
[
0
],
aabs
[
1
],
aabs
[
2
]);
pi
.
part
->
id
,
a
[
0
],
a
[
1
],
a
[
2
],
aabs
[
0
],
aabs
[
1
],
aabs
[
2
]);
}
}
/**
/**
* @brief Test the density function by dumping it for two random parts.
* @brief Test the density function by dumping it for two random parts.
*
*
...
...
This diff is collapsed.
Click to expand it.
src/tools.h
+
0
−
2
View file @
d7e1dbef
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#ifndef SWIFT_TOOL_H
#ifndef SWIFT_TOOL_H
#define SWIFT_TOOL_H
#define SWIFT_TOOL_H
#include
"runner.h"
#include
"runner.h"
#include
"cell.h"
#include
"cell.h"
...
@@ -38,5 +37,4 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj);
...
@@ -38,5 +37,4 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj);
void
pairs_n2
(
double
*
dim
,
struct
part
*
__restrict__
parts
,
int
N
,
void
pairs_n2
(
double
*
dim
,
struct
part
*
__restrict__
parts
,
int
N
,
int
periodic
);
int
periodic
);
#endif
/* SWIFT_TOOL_H */
#endif
/* SWIFT_TOOL_H */
This diff is collapsed.
Click to expand it.
tests/testVectorize.c
+
0
−
2
View file @
d7e1dbef
...
@@ -20,7 +20,6 @@ struct cell *make_cell(size_t n, double *offset, double h,
...
@@ -20,7 +20,6 @@ struct cell *make_cell(size_t n, double *offset, double h,
error
(
"couldn't allocate particles, no. of particles: %d"
,
(
int
)
count
);
error
(
"couldn't allocate particles, no. of particles: %d"
,
(
int
)
count
);
}
}
part
=
cell
->
parts
;
part
=
cell
->
parts
;
for
(
x
=
0
;
x
<
n
;
++
x
)
{
for
(
x
=
0
;
x
<
n
;
++
x
)
{
for
(
y
=
0
;
y
<
n
;
++
y
)
{
for
(
y
=
0
;
y
<
n
;
++
y
)
{
...
@@ -182,7 +181,6 @@ int main(int argc, char *argv[]) {
...
@@ -182,7 +181,6 @@ int main(int argc, char *argv[]) {
pairs_all_density
(
&
runner
,
ci
,
cj
);
pairs_all_density
(
&
runner
,
ci
,
cj
);
dump_particle_fields
(
"brute_force.dat"
,
ci
,
cj
);
dump_particle_fields
(
"brute_force.dat"
,
ci
,
cj
);
/* Clean things to make the sanitizer happy ... */
/* Clean things to make the sanitizer happy ... */
clean_up
(
ci
);
clean_up
(
ci
);
clean_up
(
cj
);
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