Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
L
load_leveller
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lukas Weber
load_leveller
Commits
471682d0
Commit
471682d0
authored
Aug 16, 2019
by
Lukas Weber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
really actually fix the new optimizer
parent
d024e973
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
17 deletions
+63
-17
src/runner_pt.cpp
src/runner_pt.cpp
+9
-11
src/util.cpp
src/util.cpp
+4
-4
test/meson.build
test/meson.build
+3
-2
test/monotone_interpolator.cpp
test/monotone_interpolator.cpp
+47
-0
No files found.
src/runner_pt.cpp
View file @
471682d0
...
...
@@ -110,32 +110,30 @@ std::tuple<double, double> pt_chain::optimize_params() {
double
sum
{};
double
efficiency
{};
for
(
size_t
i
=
0
;
i
<
comm_barrier
.
size
()
-
1
;
i
++
)
{
comm_barrier
[
i
]
=
sum
;
sum
+=
rejection_est
[
i
];
efficiency
+=
rejection_est
[
i
]
/
(
1
-
rejection_est
[
i
]);
}
comm_barrier
[
comm_barrier
.
size
()
-
1
]
=
sum
;
monotonic_interpolator
lambda
{
comm_barrier
,
params
};
double
convergence
{};
double
nonlinearity
=
0
;
for
(
size_t
i
=
1
;
i
<
params
.
size
()
-
1
;
i
++
)
{
double
new_param
=
lambda
(
sum
*
i
/
(
params
.
size
()
-
1
));
double
d
=
(
new_param
-
params
[
i
]);
double
ideal_comm_barrier
=
sum
*
i
/
(
params
.
size
()
-
1
);
nonlinearity
+=
pow
(
comm_barrier
[
i
]
-
ideal_comm_barrier
,
2
);
convergence
+=
d
*
d
;
params
[
i
]
=
new_param
;
}
int
n
=
params
.
size
();
double
nonlinearity_worst
=
sqrt
(
n
/
3.
+
1.
/
(
6
*
(
n
-
1
))
-
5.
/
6.
);
nonlinearity
=
sqrt
(
nonlinearity
)
/
nonlinearity_worst
;
convergence
=
sqrt
(
convergence
)
/
params
.
size
();
return
std
::
tie
(
nonlinearity
,
convergence
);
double
round_trip_rate
=
(
1
+
sum
)
/
(
1
+
efficiency
);
return
std
::
tie
(
round_trip_rate
,
convergence
);
}
bool
pt_chain
::
is_done
()
{
...
...
@@ -539,7 +537,6 @@ void runner_pt_master::react() {
if
(
chain_run
.
weight_ratios
[
pos
]
<
0
)
{
double
weight
;
MPI_Recv
(
&
weight
,
1
,
MPI_DOUBLE
,
target_rank
,
0
,
MPI_COMM_WORLD
,
&
stat
);
assert
(
weight
>=
0
);
chain_run
.
weight_ratios
[
pos
]
=
weight
;
}
}
...
...
@@ -571,11 +568,11 @@ void runner_pt_master::pt_global_update(pt_chain &chain, pt_chain_run &chain_run
double
w1
=
chain_run
.
weight_ratios
[
i
];
double
w2
=
chain_run
.
weight_ratios
[
i
+
1
];
double
p
=
std
::
min
(
exp
(
w1
+
w2
),
1.
);
double
r
=
rng_
->
random_double
();
chain
.
rejection_rates
[
i
]
+=
1
-
std
::
min
(
w1
*
w2
,
1.
);
chain
.
rejection_rate_entries
[
chain_run
.
swap_odd
]
++
;
if
(
r
<
w1
*
w2
)
{
chain
.
rejection_rates
[
i
]
+=
1
-
p
;
if
(
r
<
p
)
{
int
rank0
{};
int
rank1
{};
...
...
@@ -596,6 +593,7 @@ void runner_pt_master::pt_global_update(pt_chain &chain, pt_chain_run &chain_run
}
}
chain
.
rejection_rate_entries
[
chain_run
.
swap_odd
]
++
;
chain_run
.
swap_odd
=
!
chain_run
.
swap_odd
;
}
...
...
src/util.cpp
View file @
471682d0
...
...
@@ -54,11 +54,11 @@ double monotonic_interpolator::operator()(double x0) {
// replace by binary search if necessary!
size_t
idx
=
0
;
assert
(
x0
<
x_
[
x_
.
size
()
-
1
]);
while
(
x0
>=
x_
[
idx
])
{
idx
++
;
for
(;
idx
<
x_
.
size
()
-
1
;
idx
++
)
{
if
((
x0
-
x_
[
idx
])
*
(
x0
-
x_
[
idx
+
1
])
<=
0
)
{
break
;
}
}
assert
(
idx
>=
1
);
idx
--
;
assert
(
idx
<
x_
.
size
()
-
1
);
double
del
=
x_
[
idx
+
1
]
-
x_
[
idx
];
...
...
test/meson.build
View file @
471682d0
t1 = executable('test_duration_parser', 'duration_parser.cpp',
t1 = executable('tests',
['duration_parser.cpp', 'monotone_interpolator.cpp'],
dependencies : loadleveller_dep,
include_directories : include_directories('../src')
)
test('test
duration parser
', t1)
test('test
s
', t1)
test/monotone_interpolator.cpp
0 → 100644
View file @
471682d0
#include "catch.hpp"
#include "util.h"
using
namespace
loadl
;
double
testfun1
(
double
x
)
{
return
x
+
sin
(
x
);
}
double
testfun2
(
double
x
)
{
return
-
x
*
x
-
sin
(
x
*
x
);
}
double
testfun3
(
double
x
)
{
return
x
*
x
*
x
;
}
double
interpolate
(
double
(
*
f
)(
double
),
double
xmax
,
int
npoints
,
int
ncheck
)
{
double
dx
=
xmax
/
(
npoints
-
1
);
std
::
vector
<
double
>
x
(
npoints
);
std
::
vector
<
double
>
y
(
npoints
);
for
(
int
i
=
0
;
i
<
npoints
;
i
++
)
{
x
[
i
]
=
dx
*
i
;
y
[
i
]
=
f
(
x
[
i
]);
}
monotonic_interpolator
inter
(
x
,
y
);
double
rms
=
0
;
double
dx_check
=
xmax
/
(
ncheck
+
1
);
for
(
int
i
=
0
;
i
<
ncheck
;
i
++
)
{
double
x
=
i
*
dx_check
;
double
y
=
inter
(
x
);
rms
+=
(
f
(
x
)
-
y
)
*
(
f
(
x
)
-
y
);
}
rms
=
sqrt
(
rms
)
/
ncheck
;
return
rms
;
}
TEST_CASE
(
"monotonic interpolator"
)
{
REQUIRE
(
interpolate
(
testfun1
,
10
,
30
,
100
)
<
0.0001
);
REQUIRE
(
interpolate
(
testfun2
,
10
,
150
,
200
)
<
0.001
);
REQUIRE
(
interpolate
(
testfun2
,
3
,
60
,
100
)
<
0.0001
);
REQUIRE
(
interpolate
(
testfun3
,
1
,
10
,
100
)
<
0.0005
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment