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
3f8a4cfe
Commit
3f8a4cfe
authored
12 years ago
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
call engine_prepare before each step.
Former-commit-id: db6de0b4654111f68fb0fd87a88858c671edbefe
parent
d40765a6
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/Makefile.am
+4
-3
4 additions, 3 deletions
examples/Makefile.am
examples/test.c
+30
-16
30 additions, 16 deletions
examples/test.c
examples/test_mc.sh
+3
-3
3 additions, 3 deletions
examples/test_mc.sh
with
37 additions
and
22 deletions
examples/Makefile.am
+
4
−
3
View file @
3f8a4cfe
# This file is part of GadgetSMP.
# This file is part of GadgetSMP.
# Coypright (c) 2012 pedro.gonnet@durham.ac.uk.
# Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
# Matthieu Schaller (matthieu.schaller@durham.ac.uk).
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
...
@@ -21,7 +22,7 @@ AUTOMAKE_OPTIONS=gnu
...
@@ -21,7 +22,7 @@ AUTOMAKE_OPTIONS=gnu
# Add the source directory and debug to CFLAGS
# Add the source directory and debug to CFLAGS
AM_CFLAGS
=
-g
-Wall
-Werror
-I
../src
$(
OPENMP_CFLAGS
)
-DCPU_TPS
=
2.67e9
AM_CFLAGS
=
-g
-Wall
-Werror
-I
../src
$(
OPENMP_CFLAGS
)
-DCPU_TPS
=
2.67e9
AM_LDFLAGS
=
$(
HDF5_LDFLAGS
)
AM_LDFLAGS
=
# Set-up the library
# Set-up the library
bin_PROGRAMS
=
test
bin_PROGRAMS
=
test
...
@@ -29,5 +30,5 @@ bin_PROGRAMS = test
...
@@ -29,5 +30,5 @@ bin_PROGRAMS = test
# Sources for test
# Sources for test
test_SOURCES
=
test.c
test_SOURCES
=
test.c
test_CFLAGS
=
-DCOUNTER
-DTIMER
$(
AM_CFLAGS
)
test_CFLAGS
=
-DCOUNTER
-DTIMER
$(
AM_CFLAGS
)
test_LDADD
=
../src/.libs/libgadgetsmp.a
test_LDADD
=
../src/.libs/libgadgetsmp.a
$(
HDF5_LDFLAGS
)
This diff is collapsed.
Click to expand it.
examples/test.c
+
30
−
16
View file @
3f8a4cfe
/*******************************************************************************
/*******************************************************************************
* This file is part of GadgetSMP.
* This file is part of GadgetSMP.
* Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
* Coypright (c) 2012 Pedro Gonnet (pedro.gonnet@durham.ac.uk),
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
*
*
* This program is free software: you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* it under the terms of the GNU Lesser General Public License as published
...
@@ -352,7 +353,7 @@ void read_id ( char *fname , struct part *parts , int N ) {
...
@@ -352,7 +353,7 @@ void read_id ( char *fname , struct part *parts , int N ) {
for
(
k
=
0
;
k
<
N
;
k
++
)
{
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%li"
,
&
parts
[
k
].
id
)
!=
1
)
{
if
(
sscanf
(
buff
,
"%
l
li"
,
&
parts
[
k
].
id
)
!=
1
)
{
printf
(
"read_id: failed to parse %ith entry.
\n
"
,
k
);
printf
(
"read_id: failed to parse %ith entry.
\n
"
,
k
);
error
(
"Error parsing id file."
);
error
(
"Error parsing id file."
);
}
}
...
@@ -406,7 +407,7 @@ void read_dt ( char *fname , struct part *parts , int N ) {
...
@@ -406,7 +407,7 @@ void read_dt ( char *fname , struct part *parts , int N ) {
for
(
k
=
0
;
k
<
N
;
k
++
)
{
for
(
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
if
(
gzgets
(
fd
,
buff
,
1024
)
==
NULL
)
error
(
"Error reading id file."
);
error
(
"Error reading id file."
);
if
(
sscanf
(
buff
,
"%
i
"
,
&
parts
[
k
].
dt
)
!=
1
)
if
(
sscanf
(
buff
,
"%
f
"
,
&
parts
[
k
].
dt
)
!=
1
)
error
(
"Error parsing dt file."
);
error
(
"Error parsing dt file."
);
}
}
...
@@ -532,7 +533,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in
...
@@ -532,7 +533,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in
r2
=
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
];
r2
=
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
];
if
(
r2
<
p
->
h
*
p
->
h
)
{
if
(
r2
<
p
->
h
*
p
->
h
)
{
runner_iact_density
(
r2
,
NULL
,
p
->
h
,
parts
[
k
].
h
,
p
,
&
parts
[
k
]
);
runner_iact_density
(
r2
,
NULL
,
p
->
h
,
parts
[
k
].
h
,
p
,
&
parts
[
k
]
);
printf
(
"runner_dopair: interacting particles %i [%i,%i,%i] and %li [%i,%i,%i].
\n
"
,
printf
(
"runner_dopair: interacting particles %i [%i,%i,%i] and %
l
li [%i,%i,%i].
\n
"
,
pid
,
(
int
)(
parts
[
pid
].
x
[
0
]
*
ih
)
,
(
int
)(
parts
[
pid
].
x
[
1
]
*
ih
)
,
(
int
)(
parts
[
pid
].
x
[
2
]
*
ih
)
,
pid
,
(
int
)(
parts
[
pid
].
x
[
0
]
*
ih
)
,
(
int
)(
parts
[
pid
].
x
[
1
]
*
ih
)
,
(
int
)(
parts
[
pid
].
x
[
2
]
*
ih
)
,
parts
[
k
].
id
,
(
int
)(
parts
[
k
].
x
[
0
]
*
ih
)
,
(
int
)(
parts
[
k
].
x
[
1
]
*
ih
)
,
(
int
)(
parts
[
k
].
x
[
2
]
*
ih
)
);
parts
[
k
].
id
,
(
int
)(
parts
[
k
].
x
[
0
]
*
ih
)
,
(
int
)(
parts
[
k
].
x
[
1
]
*
ih
)
,
(
int
)(
parts
[
k
].
x
[
2
]
*
ih
)
);
parts
[
k
].
rho
=
0
.
0
;
parts
[
k
].
rho
=
0
.
0
;
...
@@ -542,7 +543,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in
...
@@ -542,7 +543,7 @@ void pairs_single ( double *dim , int pid , struct part *__restrict__ parts , in
}
}
/* Dump the result. */
/* Dump the result. */
printf
(
"pairs_single: wcount of part %li (h=%e) is %.3f (nr. pairs %i).
\n
"
,
p
->
id
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
printf
(
"pairs_single: wcount of part %
l
li (h=%e) is %.3f (nr. pairs %i).
\n
"
,
p
->
id
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
fflush
(
stdout
);
fflush
(
stdout
);
p
->
rho
=
0
.
0
;
p
->
rho
=
0
.
0
;
...
@@ -590,7 +591,7 @@ void pairs_single_old ( double *dim , struct part *__restrict__ parts , int N ,
...
@@ -590,7 +591,7 @@ void pairs_single_old ( double *dim , struct part *__restrict__ parts , int N ,
}
}
r
=
sqrt
(
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
]
);
r
=
sqrt
(
dx
[
0
]
*
dx
[
0
]
+
dx
[
1
]
*
dx
[
1
]
+
dx
[
2
]
*
dx
[
2
]
);
if
(
r
<
th
)
if
(
r
<
th
)
printf
(
"pairs_single: %i %li [%e,%e,%e] %e
\n
"
,
printf
(
"pairs_single: %i %
l
li [%e,%e,%e] %e
\n
"
,
tid
,
parts
[
k
].
id
,
dx
[
0
]
,
dx
[
1
]
,
dx
[
2
]
,
r
);
tid
,
parts
[
k
].
id
,
dx
[
0
]
,
dx
[
1
]
,
dx
[
2
]
,
r
);
}
}
...
@@ -633,25 +634,31 @@ int main ( int argc , char *argv[] ) {
...
@@ -633,25 +634,31 @@ int main ( int argc , char *argv[] ) {
struct
space
s
;
struct
space
s
;
struct
engine
e
;
struct
engine
e
;
char
ICfileName
[
200
];
char
ICfileName
[
200
];
float
dt
=
1
.
0
f
;
ticks
tic
;
ticks
tic
;
/* Init the space. */
/* Init the space. */
bzero
(
&
s
,
sizeof
(
struct
space
)
);
bzero
(
&
s
,
sizeof
(
struct
space
)
);
/* Parse the options */
/* Parse the options */
while
(
(
c
=
getopt
(
argc
,
argv
,
"
f:a
:m:s:t:q:r:z:"
)
)
!=
-
1
)
while
(
(
c
=
getopt
(
argc
,
argv
,
"
a:d:f
:m:s:t:q:r:z:"
)
)
!=
-
1
)
switch
(
c
)
switch
(
c
)
{
{
case
'f'
:
if
(
!
strcpy
(
ICfileName
,
optarg
))
error
(
"Error parsing IC file name."
);
printf
(
"main: IC to be read from file '%s'
\n
"
,
ICfileName
);
break
;
case
'a'
:
case
'a'
:
if
(
sscanf
(
optarg
,
"%lf"
,
&
scaling
)
!=
1
)
if
(
sscanf
(
optarg
,
"%lf"
,
&
scaling
)
!=
1
)
error
(
"Error parsing cutoff scaling."
);
error
(
"Error parsing cutoff scaling."
);
printf
(
"main: scaling cutoff by %.3f.
\n
"
,
scaling
);
fflush
(
stdout
);
printf
(
"main: scaling cutoff by %.3f.
\n
"
,
scaling
);
fflush
(
stdout
);
break
;
break
;
case
'd'
:
if
(
sscanf
(
optarg
,
"%f"
,
&
dt
)
!=
1
)
error
(
"Error parsing timestep."
);
printf
(
"main: dt set to %.3f.
\n
"
,
dt
);
fflush
(
stdout
);
break
;
case
'f'
:
if
(
!
strcpy
(
ICfileName
,
optarg
))
error
(
"Error parsing IC file name."
);
printf
(
"main: IC to be read from file '%s'
\n
"
,
ICfileName
);
break
;
case
'm'
:
case
'm'
:
if
(
sscanf
(
optarg
,
"%lf"
,
&
h_max
)
!=
1
)
if
(
sscanf
(
optarg
,
"%lf"
,
&
h_max
)
!=
1
)
error
(
"Error parsing h_max."
);
error
(
"Error parsing h_max."
);
...
@@ -816,6 +823,10 @@ int main ( int argc , char *argv[] ) {
...
@@ -816,6 +823,10 @@ int main ( int argc , char *argv[] ) {
space_init
(
&
s
,
dim
,
parts
,
N
,
periodic
,
h_max
);
space_init
(
&
s
,
dim
,
parts
,
N
,
periodic
,
h_max
);
printf
(
"main: space_init took %.3f ms.
\n
"
,
((
double
)(
getticks
()
-
tic
))
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
printf
(
"main: space_init took %.3f ms.
\n
"
,
((
double
)(
getticks
()
-
tic
))
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
/* Set the default time step to 1.0f. */
s
.
dt
=
dt
;
printf
(
"main: space dt is %f.
\n
"
,
s
.
dt
);
/* Say a few nice things about the space we just created. */
/* Say a few nice things about the space we just created. */
printf
(
"main: space dimensions are [ %.3f %.3f %.3f ].
\n
"
,
s
.
dim
[
0
]
,
s
.
dim
[
1
]
,
s
.
dim
[
2
]
);
printf
(
"main: space dimensions are [ %.3f %.3f %.3f ].
\n
"
,
s
.
dim
[
0
]
,
s
.
dim
[
1
]
,
s
.
dim
[
2
]
);
printf
(
"main: space %s periodic.
\n
"
,
s
.
periodic
?
"is"
:
"isn't"
);
printf
(
"main: space %s periodic.
\n
"
,
s
.
periodic
?
"is"
:
"isn't"
);
...
@@ -856,7 +867,6 @@ int main ( int argc , char *argv[] ) {
...
@@ -856,7 +867,6 @@ int main ( int argc , char *argv[] ) {
/* Let loose a runner on the space. */
/* Let loose a runner on the space. */
for
(
j
=
0
;
j
<
runs
;
j
++
)
{
for
(
j
=
0
;
j
<
runs
;
j
++
)
{
printf
(
"main: starting run %i/%i with %i threads and %i queues...
\n
"
,
j
+
1
,
runs
,
e
.
nr_threads
,
e
.
nr_queues
);
fflush
(
stdout
);
printf
(
"main: starting run %i/%i with %i threads and %i queues...
\n
"
,
j
+
1
,
runs
,
e
.
nr_threads
,
e
.
nr_queues
);
fflush
(
stdout
);
tic
=
getticks
();
#ifdef TIMER
#ifdef TIMER
for
(
k
=
0
;
k
<
runner_timer_count
;
k
++
)
for
(
k
=
0
;
k
<
runner_timer_count
;
k
++
)
runner_timer
[
k
]
=
0
;
runner_timer
[
k
]
=
0
;
...
@@ -869,6 +879,10 @@ int main ( int argc , char *argv[] ) {
...
@@ -869,6 +879,10 @@ int main ( int argc , char *argv[] ) {
for
(
k
=
0
;
k
<
runner_counter_count
;
k
++
)
for
(
k
=
0
;
k
<
runner_counter_count
;
k
++
)
runner_counter
[
k
]
=
0
;
runner_counter
[
k
]
=
0
;
#endif
#endif
tic
=
getticks
();
engine_prepare
(
&
e
,
0
);
printf
(
"main: engine_prepare took %.3f ms.
\n
"
,
((
double
)(
getticks
()
-
tic
))
/
CPU_TPS
*
1000
);
fflush
(
stdout
);
tic
=
getticks
();
engine_run
(
&
e
,
0
);
engine_run
(
&
e
,
0
);
#ifdef TIMER
#ifdef TIMER
printf
(
"main: runner timers are [ %.3f"
,
runner_timer
[
0
]
/
CPU_TPS
*
1000
);
printf
(
"main: runner timers are [ %.3f"
,
runner_timer
[
0
]
/
CPU_TPS
*
1000
);
...
@@ -921,7 +935,7 @@ int main ( int argc , char *argv[] ) {
...
@@ -921,7 +935,7 @@ int main ( int argc , char *argv[] ) {
/* Get the particle with the lowest wcount. */
/* Get the particle with the lowest wcount. */
p
=
&
s
.
parts
[
0
];
p
=
&
s
.
parts
[
0
];
space_map_parts
(
&
s
,
&
map_wcount_min
,
&
p
);
space_map_parts
(
&
s
,
&
map_wcount_min
,
&
p
);
printf
(
"main: particle %li/%i at [ %e %e %e ] (h=%e) has minimum wcount %.3f (icount=%i).
\n
"
,
printf
(
"main: particle %
l
li/%i at [ %e %e %e ] (h=%e) has minimum wcount %.3f (icount=%i).
\n
"
,
p
->
id
,
(
int
)(
p
-
s
.
parts
)
,
p
->
x
[
0
]
,
p
->
x
[
1
]
,
p
->
x
[
2
]
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
p
->
id
,
(
int
)(
p
-
s
.
parts
)
,
p
->
x
[
0
]
,
p
->
x
[
1
]
,
p
->
x
[
2
]
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
/* Loop over all the tasks and dump the ones containing p. */
/* Loop over all the tasks and dump the ones containing p. */
...
@@ -960,7 +974,7 @@ int main ( int argc , char *argv[] ) {
...
@@ -960,7 +974,7 @@ int main ( int argc , char *argv[] ) {
/* Get the particle with the highest wcount. */
/* Get the particle with the highest wcount. */
p
=
&
s
.
parts
[
0
];
p
=
&
s
.
parts
[
0
];
space_map_parts
(
&
s
,
&
map_wcount_max
,
&
p
);
space_map_parts
(
&
s
,
&
map_wcount_max
,
&
p
);
printf
(
"main: particle %li/%i at [ %e %e %e ] (h=%e) has maximum wcount %.3f (icount=%i).
\n
"
,
printf
(
"main: particle %
l
li/%i at [ %e %e %e ] (h=%e) has maximum wcount %.3f (icount=%i).
\n
"
,
p
->
id
,
(
int
)(
p
-
s
.
parts
)
,
p
->
x
[
0
]
,
p
->
x
[
1
]
,
p
->
x
[
2
]
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
p
->
id
,
(
int
)(
p
-
s
.
parts
)
,
p
->
x
[
0
]
,
p
->
x
[
1
]
,
p
->
x
[
2
]
,
p
->
h
,
p
->
wcount
+
32
.
0
/
3
,
p
->
icount
);
/* Get the average interactions per particle. */
/* Get the average interactions per particle. */
...
@@ -969,7 +983,7 @@ int main ( int argc , char *argv[] ) {
...
@@ -969,7 +983,7 @@ int main ( int argc , char *argv[] ) {
printf
(
"main: average neighbours per particle is %.3f.
\n
"
,
(
double
)
icount
/
s
.
nr_parts
);
printf
(
"main: average neighbours per particle is %.3f.
\n
"
,
(
double
)
icount
/
s
.
nr_parts
);
/* Dump the acceleration of the first particle. */
/* Dump the acceleration of the first particle. */
printf
(
"main: parts[%li].a is [ %.16e %.16e %.16e ].
\n
"
,
s
.
parts
[
6178
].
id
,
s
.
parts
[
6178
].
a
[
0
]
,
s
.
parts
[
6178
].
a
[
1
]
,
s
.
parts
[
6178
].
a
[
2
]
);
printf
(
"main: parts[%
l
li].a is [ %.16e %.16e %.16e ].
\n
"
,
s
.
parts
[
6178
].
id
,
s
.
parts
[
6178
].
a
[
0
]
,
s
.
parts
[
6178
].
a
[
1
]
,
s
.
parts
[
6178
].
a
[
2
]
);
/* Get all the cells of a certain depth. */
/* Get all the cells of a certain depth. */
// icount = 1;
// icount = 1;
...
...
This diff is collapsed.
Click to expand it.
examples/test_mc.sh
+
3
−
3
View file @
3f8a4cfe
...
@@ -23,10 +23,10 @@ do
...
@@ -23,10 +23,10 @@ do
export
OMP_THREAD_LIMIT
=
$cpu
export
OMP_THREAD_LIMIT
=
$cpu
export
OMP_PROC_BIND
=
TRUE
export
OMP_PROC_BIND
=
TRUE
./test
-r
1000
-t
$cpu
-b
"1400 1400 1400"
-N
74240
-c
small/Coordinates.txt.gz
-s
"700 700 700"
-p
0
-h
small/SmoothingLength.txt.gz
-m
470
-z
200
>
small_
${
cpu
}
.dump
#
./test -r 1000 -t $cpu -b "1400 1400 1400" -N 74240 -c small/Coordinates.txt.gz -s "700 700 700" -p 0 -h small/SmoothingLength.txt.gz -m 470 -z 200 > small_${cpu}.dump
./test
-r
100
-t
$cpu
-b
"100 100 100"
-N
3558892
-c
snap_C09/Coordinates.txt.gz
-s
"50 50 50"
-p
0
-h
snap_C09/SmoothingLength.txt.gz
-m
6.138
>
snap_C09_
${
cpu
}
.dump
#
./test -r 100 -t $cpu -b "100 100 100" -N 3558892 -c snap_C09/Coordinates.txt.gz -s "50 50 50" -p 0 -h snap_C09/SmoothingLength.txt.gz -m 6.138 > snap_C09_${cpu}.dump
./test
-r
100
-t
$cpu
-
b
"6.25 6.25 6.25"
-N
1841127
-c
scaling/Coordinates.txt.gz
-p
1
-h
scaling/SmoothingLength.txt.gz
-m
0.5
-z
200
>
scaling_
${
cpu
}
.dump
./test
-r
100
-t
$cpu
-
f
scaling/snap_023_z000p503.hdf5
-m
0.5
-z
200
>
scaling_
${
cpu
}
.dump
done
done
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