Skip to content

Commit d26bc7c

Browse files
committed
Copy from GitLab
0 parents  commit d26bc7c

34 files changed

+4293
-0
lines changed

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2021, PIK - Infrastructure and Complex Networks
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
This repository contains scripts for benchmarking dynamical systems on networks. Usage Instructions are found below. Details on our methodology are reported in our paper on [NetworkDynamics.jl -- Composing and simulating complex networks in Julia](https://arxiv.org/abs/2012.12696). Below you see a plot of competing runtimes simulating a Kuramoto network of 1000 oscillators with Dormand-Prince's 5th order method.
2+
3+
![](utils/plotting/WPD1000.pdf)
4+
5+
6+
# Instructions
7+
8+
## High level Requirements
9+
10+
- sqlite
11+
- make
12+
- python3
13+
- Julia 1.5
14+
15+
## Setup python environment
16+
We suggest a virtual env for python
17+
18+
```
19+
python3 -m venv .env
20+
```
21+
22+
activate and install the requirements
23+
24+
```
25+
source .env/bin/activate
26+
pip install -r src/python/requirements.pip
27+
```
28+
29+
## Setup Julia enviroment
30+
31+
The julia env should be activated automatically by the scripts.
32+
33+
## Compile fortran program
34+
35+
If you would like to run the fortran benchmarks, you must have a Fortran
36+
2003 compiler. In the example we use GFortran. If you do not wish to run
37+
the fortran benchmark, bypass this section.
38+
39+
The fortran program uses FPM, the fortran package manager. Install from
40+
https://github.com/fortran-lang/fpm
41+
42+
Using this tool, you can build the fortran program with fpm
43+
44+
```
45+
cd src/fortran
46+
fpm build --flag -ldl --flag -lpthread
47+
```
48+
49+
now, set KURABENCH_FEXE to the newly built binary
50+
51+
```
52+
cd ../../
53+
export
54+
KURABENCH_FEXE=`pwd`/src/fortran/build/<compiler>_<uuid>/app/FKuraBenchmark
55+
```
56+
57+
where compiler and uuid are the details of your compilation process
58+
resulting from the fpm build command.
59+
60+
## Prepare Database
61+
62+
In these benchmarks, we use an SQLite database to store the setup of
63+
each system (node parameters, edge parameters, system parameters,
64+
connectivity) and also the experiment log and trajectory outputs.
65+
66+
You may place your database at a location of your choosing. Each program
67+
uses the environmental variable KURABENCH_DB to identify the location of
68+
the database. In this case, we will place the database in the `data`
69+
directory.
70+
71+
```
72+
export KURABENCH_DB=`pwd`/data/kurabench.db
73+
make database
74+
```
75+
76+
## Generate systems
77+
78+
Be sure that your python virtual env is activated
79+
80+
```
81+
make systems
82+
```
83+
84+
## Generate reference trajectories
85+
86+
The "ground-truth" trajectories are generated using the (implicit) radau
87+
solver at low tolerance settings. Julia is used to run this generation
88+
step. Some timing information will be printed to stdout during the
89+
program execution. Compute the trajectories with:
90+
91+
```
92+
make reference
93+
```
94+
95+
## Generate benchmarks
96+
97+
Now, generate any benchmarks of interest by running
98+
99+
```
100+
make <X>
101+
```
102+
103+
where `<X>` is one of
104+
105+
networkdynamics
106+
diffeq
107+
jitcode
108+
scipy
109+
fortran
110+
111+
The resulting experiment summary is stored in the database in the
112+
experiments table. The trajectory of each state is stored in the
113+
`states` table, indexed by the experiment id found in the `experiments`
114+
table.
115+
116+
The `experiments` table includes the timing and `err_v_ref`, the average
117+
deviation (across all states) of the experiment trajectory and the
118+
reference (radau-computed) trajectory for that system and initial
119+
condition.

data/KuraBench.sql

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
CREATE TABLE edges (system integer NOT NULL, id integer NOT NULL, source integer, dest integer, PRIMARY KEY (system, id));
2+
CREATE TABLE IF NOT EXISTS "systems" (
3+
"id" INTEGER,
4+
"name" TEXT,
5+
"nodes" INTEGER,
6+
"edges" INTEGER,
7+
"q" NUMERIC,
8+
"c" NUMERIC,
9+
"coupling_constant" NUMERIC,
10+
PRIMARY KEY("id")
11+
);
12+
CREATE TABLE IF NOT EXISTS "nodes" (
13+
"system" integer NOT NULL,
14+
"id" integer NOT NULL,
15+
"omega" DOUBLE,
16+
"initialCondition" DOUBLE,
17+
FOREIGN KEY("system") REFERENCES "systems"("id"),
18+
PRIMARY KEY("system","id")
19+
);
20+
CREATE TABLE IF NOT EXISTS "states" (
21+
"experimentid" INTEGER NOT NULL,
22+
"time" NUMERIC,
23+
"idx" INTEGER,
24+
"node" INTEGER,
25+
"state" DOUBLE,
26+
PRIMARY KEY("experimentid","idx","time"),
27+
FOREIGN KEY("experimentid") REFERENCES "experiments"("experimentid")
28+
);
29+
CREATE TABLE IF NOT EXISTS "experiments" (
30+
"experimentid" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
31+
"runtime" TEXT,
32+
"datetime" TEXT,
33+
"githash" TEXT,
34+
"gitchanges" TEXT,
35+
"commandline" TEXT,
36+
"host" TEXT,
37+
"system" INTEGER,
38+
"solver" TEXT,
39+
"atol" NUMERIC,
40+
"rtol" NUMERIC,
41+
"tstart" INTEGER,
42+
"tend" INTEGER,
43+
"nfcn" INTEGER,
44+
"njac" INTEGER,
45+
"nstep" INTEGER,
46+
"naccept" INTEGER,
47+
"nreject" INTEGER,
48+
"ndec" INTEGER,
49+
"nsol" INTEGER,
50+
"tstartup" NUMERIC,
51+
"tload" NUMERIC,
52+
"tjit" NUMERIC,
53+
"tintegration" NUMERIC,
54+
"ttotal" NUMERIC,
55+
"peak_mem" NUMERIC,
56+
"err_v_ref" NUMERIC,
57+
"refeid" INTEGER,
58+
"notes" TEXT,
59+
FOREIGN KEY("system") REFERENCES "systems"("id")
60+
);

data/KuraBenchXeon.db

2.08 MB
Binary file not shown.

makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
database:
4+
@echo "Building database.."
5+
@sqlite3 ${KURABENCH_DB} < ./data/KuraBench.sql
6+
7+
systems:
8+
@echo "Generating systems.."
9+
@KURABENCH_DB=${KURABENCH_DB} python3 ./utils/generate_systems.py
10+
11+
reference:
12+
@echo "Computing reference trajectories"
13+
@KURABENCH_DB=${KURABENCH_DB} ./utils/gen_ref.sh
14+
15+
jitcode:
16+
@echo "Computing jitcode trajectories"
17+
@KURABENCH_DB=${KURABENCH_DB} ./utils/run_jitcode.sh
18+
19+
scipy:
20+
@echo "Computing scipy trajectories"
21+
@KURABENCH_DB=${KURABENCH_DB} ./utils/run_scipy.sh
22+
23+
networkdynamics:
24+
@echo "Computing networkdynamics trajectories"
25+
@KURABENCH_DB=${KURABENCH_DB} ./utils/run_nd.sh
26+
27+
diffeq:
28+
@echo "Computing pure diffeq.jl trajectories"
29+
@KURABENCH_DB=${KURABENCH_DB} ./utils/run_diffeq.sh
30+
31+
fortran:
32+
@echo "Computing fortran trajectories"
33+
@KURABENCH_DB=${KURABENCH_DB} ./utils/run_f.sh
34+
35+
clean:
36+
@rm ${KURABENCH_DB} || echo "Nothing to cleanup.."

src/fortran/LICENSE.txt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Fortran Kuramoto System Benchmark (c) 2021, Lucas Lincoln
2+
3+
"BSD 3-Clause"
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
31+
32+
33+
Original dopri5.f by Ernst Hairer (now embedded in dopri5.f90) is included
34+
under the following license:
35+
36+
Copyright (c) 2004, UNIGE
37+
38+
Redistribution and use in source and binary forms, with or without
39+
modification, are permitted provided that the following conditions are
40+
met:
41+
42+
- Redistributions of source code must retain the above copyright
43+
notice, this list of conditions and the following disclaimer.
44+
45+
- Redistributions in binary form must reproduce the above copyright
46+
notice, this list of conditions and the following disclaimer in the
47+
documentation and/or other materials provided with the distribution.
48+
49+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS
50+
IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
51+
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
52+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
53+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
54+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
55+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
56+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
57+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
58+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60+
61+

src/fortran/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# kurabenchmark
2+
3+
Benchmark for the kuramoto system, in pure fortran 2003
4+
5+
Compile using FPM (https://github.com/fortran-lang/fpm)

src/fortran/app/DopriWrap.f90

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module dopriWrap
2+
!======= Inclusions ===========
3+
use KuraNetwork
4+
use LoadNetwork
5+
use iso_fortran_env, only: real64
6+
!======= Declarations =========
7+
implicit none
8+
9+
!type(KuramotoNetwork(:,:)),allocatable :: net
10+
type(KuramotoNetwork) :: net
11+
real(real64),parameter :: dt = 2.0_real64
12+
13+
contains
14+
subroutine dopri_loadNet(database, systemid)
15+
implicit none
16+
17+
character(len=*), intent(in) :: database
18+
integer, intent(in) :: systemid
19+
integer :: state_length
20+
!real(kind=real64),dimension(:), allocatable :: y,dy
21+
call get_system_info(database,systemid)
22+
!call load_network(net)
23+
net = load_network()
24+
return
25+
end subroutine dopri_loadNet
26+
27+
! ----------------------------------------------------------------
28+
! RhsFn provides the right hand side function for the
29+
! ODE: dy/dt = f(t,y)
30+
! Here wrapped for use with the dopri5 solver
31+
! ----------------------------------------------------------------
32+
subroutine dopri_RhsFn(N,t,y,dy,rpar,ipar)
33+
34+
implicit none
35+
36+
integer, intent(in) :: N
37+
real(real64) ,intent(in) :: t
38+
real(real64) ,dimension(N),intent(in) :: y
39+
real(real64) ,dimension(N),intent(out) :: dy
40+
real(real64), dimension(:), intent(in),optional :: rpar ! real params
41+
integer, dimension(:), intent(in),optional :: ipar ! integer params
42+
43+
! fill RHS vector fvec
44+
call f(net,t,y,dy)
45+
46+
! return success
47+
end subroutine dopri_RhsFn
48+
end module dopriWrap

0 commit comments

Comments
 (0)