Skip to content

Commit 53eb094

Browse files
williamjameshandleyLukas Hergt
andauthored
Synchronous parallelisation (#67)
* Synchronous parallelisation implemented * Updated version numbers * add missing i for int for the additional boolean sync parameter in weird str describing parameter types (#66) * Updated branch * Added anesthetic to the README * Modification so that now all dead points are saved for anesthetic usage * Bug fix for linear mode setting birth contour * changed huge to logzero in logweights, as this causes inability to resume with intel compilers Co-authored-by: Lukas Hergt <[email protected]>
1 parent be0993f commit 53eb094

15 files changed

+100
-21
lines changed

README.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
:target: https://arxiv.org/abs/1506.00171
66
:alt: Open-access paper
77

8-
PolyChord v 1.18.2
8+
PolyChord v 1.20.0
99

1010
Will Handley, Mike Hobson & Anthony Lasenby
1111

@@ -56,6 +56,14 @@ If any of the above steps fail (this can in general happen for certain Mac OSX v
5656
5757
If you do not have sudo access/virtual environments/anaconda, then appending `--user` to the install command may be necessary.
5858

59+
Post Processing
60+
===============
61+
62+
We recommend the tool `anesthetic <https://github.com/williamjameshandley/anesthetic>`_ for post-processing your nested sampling runs. A plot gallery can be found `here <http://htmlpreview.github.io/?https://github.com/williamjameshandley/cosmo_example/blob/master/demos/demo.html>`_
63+
64+
65+
https://github.com/williamjameshandley/anesthetic
66+
5967
MPI Support
6068
===========
6169

pypolychord/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def wrap_prior(cube, theta):
199199
settings.write_prior,
200200
settings.maximise,
201201
settings.compression_factor,
202+
settings.synchronous,
202203
settings.base_dir,
203204
settings.file_root,
204205
settings.grade_frac,

pypolychord/_pypolychord.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static PyObject *run_pypolychord(PyObject *, PyObject *args)
126126

127127

128128
if (!PyArg_ParseTuple(args,
129-
"OOOiiiiiiiiddidiiiiiiiiiiidssO!O!O!i:run",
129+
"OOOiiiiiiiiddidiiiiiiiiiiidissO!O!O!i:run",
130130
&temp_logl,
131131
&temp_prior,
132132
&temp_dumper,
@@ -154,6 +154,7 @@ static PyObject *run_pypolychord(PyObject *, PyObject *args)
154154
&S.write_prior,
155155
&S.maximise,
156156
&S.compression_factor,
157+
&S.synchronous,
157158
&base_dir,
158159
&file_root,
159160
&PyList_Type,

pypolychord/settings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ class PolyChordSettings:
120120
(Default: exp(-1))
121121
How often to update the files and do clustering
122122
123+
synchronous : boolean
124+
(Default: True)
125+
Parallelise with synchronous workers, rather than asynchronous ones.
126+
This can be set to False if the likelihood speed is known to be
127+
approximately constant across the parameter space. Synchronous
128+
parallelisation is less effective than asynchronous by a factor ~O(1)
129+
for large parallelisation.
130+
123131
base_dir : string
124132
(Default: 'chains')
125133
Where to store output files.
@@ -179,6 +187,7 @@ def __init__(self, nDims, nDerived, **kwargs):
179187
self.maximise = kwargs.pop('maximise', False)
180188
self.compression_factor = kwargs.pop('compression_factor',
181189
numpy.exp(-1))
190+
self.synchronous = kwargs.pop('synchronous', True)
182191
self.base_dir = kwargs.pop('base_dir', 'chains')
183192
self.file_root = kwargs.pop('file_root', 'test')
184193
self.seed = kwargs.pop('seed', -1)

src/drivers/polychord_CC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ int main()
3131

3232
settings.feedback = 1;
3333
settings.compression_factor = 0.36787944117144233;
34+
settings.synchronous = true;
3435

3536
settings.boost_posterior= 5.0;
3637

src/polychord/c_interface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Settings::Settings(int _nDims,int _nDerived):
2828
write_prior {true},
2929
maximise {true},
3030
compression_factor {0.36787944117144233},
31+
synchronous {true},
3132
base_dir {"chains"},
3233
file_root {"test"},
3334
grade_frac {1.0},
@@ -95,6 +96,7 @@ void run_polychord(
9596
s.write_prior,
9697
s.maximise,
9798
s.compression_factor,
99+
s.synchronous,
98100
s.nDims,
99101
s.nDerived,
100102
base_dir,

src/polychord/feedback.f90

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ subroutine write_opening_statement(settings)
2828
write(stdout_unit,'("")')
2929
write(stdout_unit,'("PolyChord: Next Generation Nested Sampling")')
3030
write(stdout_unit,'("copyright: Will Handley, Mike Hobson & Anthony Lasenby")')
31-
write(stdout_unit,'(" version: 1.18.2")')
32-
write(stdout_unit,'(" release: 7th April 2020")')
31+
write(stdout_unit,'(" version: 1.20.0")')
32+
write(stdout_unit,'(" release: 1st June 2021")')
3333
write(stdout_unit,'(" email: [email protected]")')
3434
write(stdout_unit,'("")')
3535
end if
@@ -40,6 +40,7 @@ subroutine write_opening_statement(settings)
4040
write(stdout_unit,'("nDims :",I8)') settings%nDims
4141
write(stdout_unit,'("nDerived :",I8)') settings%nDerived
4242
if(settings%do_clustering) write(stdout_unit,'("Doing Clustering")')
43+
if(settings%synchronous) write(stdout_unit,'("Synchronous parallelisation")')
4344
if(settings%equals) write(stdout_unit,'("Generating equally weighted posteriors")')
4445
if(settings%posteriors) write(stdout_unit,'("Generating weighted posteriors")')
4546
if((settings%equals.or.settings%posteriors).and.settings%cluster_posteriors.and.settings%do_clustering) write(stdout_unit,'("Clustering on posteriors")')

src/polychord/generate.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ function prior(cube) result(theta)
196196
! Recieve a point from any worker
197197
worker_id = catch_point(live_point,mpi_information)
198198

199-
! If its valid, and we need more points, add it to the array
200-
if(live_point(settings%l0)>settings%logzero .and. RTI%nlive(1)<nprior) then
199+
! If its valid, add it to the array
200+
if(live_point(settings%l0)>settings%logzero) then
201201

202202
call add_point(live_point,RTI%live,RTI%nlive,1) ! Add this point to the array
203203

src/polychord/ini.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ subroutine read_params(file_name,settings,params,derived_params)
7575
settings%write_prior = get_logical(file_name,'write_prior',.false.)
7676
settings%maximise = get_logical(file_name,'maximise',.false.)
7777
settings%compression_factor = get_double(file_name,'compression_factor',exp(-1d0))
78+
settings%synchronous = get_logical(file_name,'synchronous',.true.)
7879
settings%base_dir = get_string(file_name,'base_dir','chains')
7980
settings%file_root = get_string(file_name,'file_root','test')
8081
settings%seed = get_integer(file_name,'seed', -1)

src/polychord/interfaces.F90

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ subroutine polychord_c_interface(&
282282
write_prior,&
283283
maximise,&
284284
compression_factor,&
285+
synchronous,&
285286
nDims,&
286287
nDerived, &
287288
base_dir,&
@@ -360,6 +361,7 @@ end subroutine c_dumper
360361
logical(c_bool), intent(in), value :: write_prior
361362
logical(c_bool), intent(in), value :: maximise
362363
real(c_double), intent(in), value :: compression_factor
364+
logical(c_bool), intent(in), value :: synchronous
363365
integer(c_int), intent(in), value :: nDims
364366
integer(c_int), intent(in), value :: nDerived
365367
character(len=1,kind=c_char), intent(in), dimension(STR_LENGTH) :: base_dir
@@ -407,6 +409,7 @@ end subroutine c_dumper
407409
settings%write_prior = write_prior
408410
settings%maximise = maximise
409411
settings%compression_factor = compression_factor
412+
settings%synchronous = synchronous
410413
settings%nDims = nDims
411414
settings%nDerived = nDerived
412415

0 commit comments

Comments
 (0)