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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
345b6aa5
Commit
345b6aa5
authored
Jan 25, 2017
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Fixed GCC warnings for signed and unsigned integer comparison.
parent
b2d2bf64
No related branches found
No related tags found
1 merge request
!306
Added test that benchmarks the interaction functions against their vectorised counterparts.
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/benchmarkInteractions.c
+12
-17
12 additions, 17 deletions
tests/benchmarkInteractions.c
with
12 additions
and
17 deletions
tests/benchmarkInteractions.c
+
12
−
17
View file @
345b6aa5
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
*separation.
*separation.
* @param partId The running counter of IDs.
* @param partId The running counter of IDs.
*/
*/
struct
part
*
make_particles
(
in
t
count
,
double
*
offset
,
double
spacing
,
double
h
,
struct
part
*
make_particles
(
size_
t
count
,
double
*
offset
,
double
spacing
,
double
h
,
long
long
*
partId
)
{
long
long
*
partId
)
{
struct
part
*
particles
;
struct
part
*
particles
;
...
@@ -118,7 +118,7 @@ struct part *make_particles(int count, double *offset, double spacing, double h,
...
@@ -118,7 +118,7 @@ struct part *make_particles(int count, double *offset, double spacing, double h,
/**
/**
* @brief Populates particle properties needed for the force calculation.
* @brief Populates particle properties needed for the force calculation.
*/
*/
void
prepare_force
(
struct
part
*
parts
,
in
t
count
)
{
void
prepare_force
(
struct
part
*
parts
,
size_
t
count
)
{
struct
part
*
p
;
struct
part
*
p
;
for
(
size_t
i
=
0
;
i
<
count
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
count
;
++
i
)
{
...
@@ -211,7 +211,7 @@ int check_results(struct part serial_test_part, struct part *serial_parts,
...
@@ -211,7 +211,7 @@ int check_results(struct part serial_test_part, struct part *serial_parts,
* @param runs No. of times to call interactions
* @param runs No. of times to call interactions
*
*
*/
*/
void
test_interactions
(
struct
part
test_part
,
struct
part
*
parts
,
in
t
count
,
void
test_interactions
(
struct
part
test_part
,
struct
part
*
parts
,
size_
t
count
,
char
*
filePrefix
,
int
runs
)
{
char
*
filePrefix
,
int
runs
)
{
ticks
serial_time
=
0
;
ticks
serial_time
=
0
;
...
@@ -232,21 +232,19 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -232,21 +232,19 @@ void test_interactions(struct part test_part, struct part *parts, int count,
write_header
(
vec_filename
);
write_header
(
vec_filename
);
struct
part
pi_serial
,
pi_vec
;
struct
part
pi_serial
,
pi_vec
;
struct
part
pj_serial
[
count
],
pi_list_vec
[
count
],
pj_vec
[
count
];
struct
part
pj_serial
[
count
],
pj_vec
[
count
];
float
r2
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
r2
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
dx
[
3
*
count
]
__attribute__
((
aligned
(
array_align
)));
float
dx
[
3
*
count
]
__attribute__
((
aligned
(
array_align
)));
float
r2q
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
r2q
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
hiq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
hiq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
hjq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
dxq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
dxq
[
count
]
__attribute__
((
aligned
(
array_align
)));
struct
part
*
piq
[
count
],
*
pjq
[
count
];
struct
part
*
piq
[
count
],
*
pjq
[
count
];
float
dyq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
dyq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
dzq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
dzq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
miq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
mjq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
mjq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
vixq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
vixq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
viyq
[
count
]
__attribute__
((
aligned
(
array_align
)));
float
viyq
[
count
]
__attribute__
((
aligned
(
array_align
)));
...
@@ -259,7 +257,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -259,7 +257,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
for
(
int
k
=
0
;
k
<
runs
;
k
++
)
{
for
(
int
k
=
0
;
k
<
runs
;
k
++
)
{
/* Reset particle to initial setup */
/* Reset particle to initial setup */
pi_serial
=
test_part
;
pi_serial
=
test_part
;
for
(
in
t
i
=
0
;
i
<
count
;
i
++
)
pj_serial
[
i
]
=
parts
[
i
];
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
pj_serial
[
i
]
=
parts
[
i
];
/* Only dump data on first run. */
/* Only dump data on first run. */
if
(
k
==
0
)
{
if
(
k
==
0
)
{
...
@@ -270,7 +268,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -270,7 +268,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
}
}
/* Perform serial interaction */
/* Perform serial interaction */
for
(
in
t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
{
/* Compute the pairwise distance. */
/* Compute the pairwise distance. */
r2
[
i
]
=
0
.
0
f
;
r2
[
i
]
=
0
.
0
f
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
...
@@ -283,7 +281,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -283,7 +281,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
const
ticks
tic
=
getticks
();
const
ticks
tic
=
getticks
();
/* Perform serial interaction */
/* Perform serial interaction */
#pragma novector
#pragma novector
for
(
in
t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
{
IACT
(
r2
[
i
],
&
(
dx
[
3
*
i
]),
pi_serial
.
h
,
pj_serial
[
i
].
h
,
&
pi_serial
,
IACT
(
r2
[
i
],
&
(
dx
[
3
*
i
]),
pi_serial
.
h
,
pj_serial
[
i
].
h
,
&
pi_serial
,
&
pj_serial
[
i
]);
&
pj_serial
[
i
]);
}
}
...
@@ -303,11 +301,10 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -303,11 +301,10 @@ void test_interactions(struct part test_part, struct part *parts, int count,
for
(
int
k
=
0
;
k
<
runs
;
k
++
)
{
for
(
int
k
=
0
;
k
<
runs
;
k
++
)
{
/* Reset particle to initial setup */
/* Reset particle to initial setup */
pi_vec
=
test_part
;
pi_vec
=
test_part
;
for
(
int
i
=
0
;
i
<
count
;
i
++
)
pj_vec
[
i
]
=
parts
[
i
];
for
(
size_t
i
=
0
;
i
<
count
;
i
++
)
pj_vec
[
i
]
=
parts
[
i
];
for
(
int
i
=
0
;
i
<
count
;
i
++
)
pi_list_vec
[
i
]
=
test_part
;
/* Setup arrays for vector interaction. */
/* Setup arrays for vector interaction. */
for
(
in
t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
{
/* Compute the pairwise distance. */
/* Compute the pairwise distance. */
float
r2
=
0
.
0
f
;
float
r2
=
0
.
0
f
;
float
dx
[
3
];
float
dx
[
3
];
...
@@ -319,13 +316,11 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -319,13 +316,11 @@ void test_interactions(struct part test_part, struct part *parts, int count,
r2q
[
i
]
=
r2
;
r2q
[
i
]
=
r2
;
dxq
[
i
]
=
dx
[
0
];
dxq
[
i
]
=
dx
[
0
];
hiq
[
i
]
=
pi_vec
.
h
;
hiq
[
i
]
=
pi_vec
.
h
;
hjq
[
i
]
=
pj_vec
[
i
].
h
;
piq
[
i
]
=
&
pi_vec
;
piq
[
i
]
=
&
pi_vec
;
pjq
[
i
]
=
&
pj_vec
[
i
];
pjq
[
i
]
=
&
pj_vec
[
i
];
dyq
[
i
]
=
dx
[
1
];
dyq
[
i
]
=
dx
[
1
];
dzq
[
i
]
=
dx
[
2
];
dzq
[
i
]
=
dx
[
2
];
miq
[
i
]
=
pi_vec
.
mass
;
mjq
[
i
]
=
pj_vec
[
i
].
mass
;
mjq
[
i
]
=
pj_vec
[
i
].
mass
;
vixq
[
i
]
=
pi_vec
.
v
[
0
];
vixq
[
i
]
=
pi_vec
.
v
[
0
];
viyq
[
i
]
=
pi_vec
.
v
[
1
];
viyq
[
i
]
=
pi_vec
.
v
[
1
];
...
@@ -375,7 +370,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
...
@@ -375,7 +370,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
const
ticks
vec_tic
=
getticks
();
const
ticks
vec_tic
=
getticks
();
for
(
in
t
i
=
0
;
i
<
count
;
i
+=
2
*
VEC_SIZE
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
+=
2
*
VEC_SIZE
)
{
IACT_VEC
(
&
(
r2q
[
i
]),
&
(
dxq
[
i
]),
&
(
dyq
[
i
]),
&
(
dzq
[
i
]),
(
hi_inv_vec
),
IACT_VEC
(
&
(
r2q
[
i
]),
&
(
dxq
[
i
]),
&
(
dyq
[
i
]),
&
(
dzq
[
i
]),
(
hi_inv_vec
),
(
vix_vec
),
(
viy_vec
),
(
viz_vec
),
&
(
vjxq
[
i
]),
&
(
vjyq
[
i
]),
(
vix_vec
),
(
viy_vec
),
(
viz_vec
),
&
(
vjxq
[
i
]),
&
(
vjyq
[
i
]),
...
@@ -430,7 +425,7 @@ int main(int argc, char *argv[]) {
...
@@ -430,7 +425,7 @@ int main(int argc, char *argv[]) {
size_t
runs
=
10000
;
size_t
runs
=
10000
;
double
h
=
1
.
0
,
spacing
=
0
.
5
;
double
h
=
1
.
0
,
spacing
=
0
.
5
;
double
offset
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
double
offset
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
in
t
count
=
256
;
size_
t
count
=
256
;
/* Get some randomness going */
/* Get some randomness going */
srand
(
0
);
srand
(
0
);
...
@@ -444,7 +439,7 @@ int main(int argc, char *argv[]) {
...
@@ -444,7 +439,7 @@ int main(int argc, char *argv[]) {
case
's'
:
case
's'
:
sscanf
(
optarg
,
"%lf"
,
&
spacing
);
sscanf
(
optarg
,
"%lf"
,
&
spacing
);
case
'n'
:
case
'n'
:
sscanf
(
optarg
,
"%
d
"
,
&
count
);
sscanf
(
optarg
,
"%
zu
"
,
&
count
);
break
;
break
;
case
'r'
:
case
'r'
:
sscanf
(
optarg
,
"%zu"
,
&
runs
);
sscanf
(
optarg
,
"%zu"
,
&
runs
);
...
...
...
...
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