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
c6972a00
Commit
c6972a00
authored
8 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Replaced all integers with size_t.
parent
cfb3df9a
No related branches found
No related tags found
1 merge request
!287
Particle caching
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testInteractions.c
+15
-15
15 additions, 15 deletions
tests/testInteractions.c
with
15 additions
and
15 deletions
tests/testInteractions.c
+
15
−
15
View file @
c6972a00
...
...
@@ -51,7 +51,7 @@ typedef void (*vec_interaction)(float *, float *, float *, float *,
*separation.
* @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
)
{
struct
part
*
particles
;
...
...
@@ -101,7 +101,7 @@ struct part *make_particles(int count, double *offset, double spacing, double h,
/**
* @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
;
for
(
size_t
i
=
0
;
i
<
count
;
++
i
)
{
...
...
@@ -198,10 +198,10 @@ int check_results(struct part serial_test_part, struct part *serial_parts,
* @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
,
serial_interaction
serial_inter_func
,
vec_interaction
vec_inter_func
,
char
*
filePrefix
,
in
t
runs
)
{
size_
t
runs
)
{
ticks
serial_time
=
0
,
vec_time
=
0
;
...
...
@@ -232,10 +232,10 @@ void test_interactions(struct part test_part, struct part *parts, int count,
struct
part
*
piq
[
count
],
*
pjq
[
count
];
/* Call serial interaction a set number of times. */
for
(
in
t
k
=
0
;
k
<
runs
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
runs
;
k
++
)
{
/* Reset particle to initial setup */
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. */
if
(
k
==
0
)
{
...
...
@@ -246,11 +246,11 @@ void test_interactions(struct part test_part, struct part *parts, int count,
}
/* Perform serial interaction */
for
(
in
t
i
=
0
;
i
<
count
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
{
/* Compute the pairwise distance. */
float
r2
=
0
.
0
f
;
float
dx
[
3
];
for
(
in
t
k
=
0
;
k
<
3
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
pi_serial
.
x
[
k
]
-
pj_serial
[
i
].
x
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
}
...
...
@@ -274,17 +274,17 @@ void test_interactions(struct part test_part, struct part *parts, int count,
dump_indv_particle_fields
(
serial_filename
,
&
pj_serial
[
i
]);
/* Call vector interaction a set number of times. */
for
(
in
t
k
=
0
;
k
<
runs
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
runs
;
k
++
)
{
/* Reset particle to initial setup */
pi_vec
=
test_part
;
for
(
in
t
i
=
0
;
i
<
count
;
i
++
)
pj_vec
[
i
]
=
parts
[
i
];
for
(
size_
t
i
=
0
;
i
<
count
;
i
++
)
pj_vec
[
i
]
=
parts
[
i
];
/* 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. */
float
r2
=
0
.
0
f
;
float
dx
[
3
];
for
(
in
t
k
=
0
;
k
<
3
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
pi_vec
.
x
[
k
]
-
pj_vec
[
i
].
x
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
}
...
...
@@ -310,7 +310,7 @@ void test_interactions(struct part test_part, struct part *parts, int count,
const
ticks
vec_tic
=
getticks
();
/* Perform vector interaction. */
for
(
in
t
i
=
0
;
i
<
count
;
i
+=
VEC_SIZE
)
{
for
(
size_
t
i
=
0
;
i
<
count
;
i
+=
VEC_SIZE
)
{
vec_inter_func
(
&
(
r2q
[
i
]),
&
(
dxq
[
3
*
i
]),
&
(
hiq
[
i
]),
&
(
hjq
[
i
]),
&
(
piq
[
i
]),
&
(
pjq
[
i
]));
}
...
...
@@ -341,7 +341,7 @@ int main(int argc, char *argv[]) {
size_t
runs
=
10000
;
double
h
=
1
.
0
,
spacing
=
0
.
5
;
double
offset
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
in
t
count
=
256
;
size_
t
count
=
256
;
/* Get some randomness going */
srand
(
0
);
...
...
@@ -355,7 +355,7 @@ int main(int argc, char *argv[]) {
case
's'
:
sscanf
(
optarg
,
"%lf"
,
&
spacing
);
case
'n'
:
sscanf
(
optarg
,
"%
d
"
,
&
count
);
sscanf
(
optarg
,
"%
zu
"
,
&
count
);
break
;
case
'r'
:
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
register
or
sign in
to comment