Skip to content

Commit eddfa1b

Browse files
committed
Merge branch 'develop'
2 parents 5f8c26d + a6a4c18 commit eddfa1b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ring_of_CPUs.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def print2logandstdo(message, mode='a+'):
1111

1212
class RingOfCPUs(object):
1313
def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, comm=None,
14-
N_buffer_float_size = 1000000, N_buffer_int_size = 100):
14+
N_buffer_float_size = 1000000, N_buffer_int_size = 100,
15+
init_sim_objects_auto=True):
1516

1617
self.sim_content = sim_content
1718
self.N_turns = sim_content.N_turns
@@ -62,8 +63,6 @@ def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, c
6263

6364
self.buf_int = np.array(self.N_buffer_int_size*[0])
6465

65-
self.sim_content.init_all()
66-
6766
if self.I_am_the_master:
6867
print2logandstdo('PyPARIS simulation')#, mode='w+')
6968
print2logandstdo(comm_info)
@@ -77,7 +76,16 @@ def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, c
7776
print2logandstdo('Interpreter at %s'%sys.executable)
7877

7978
self.comm.Barrier() # only for stdoutp
79+
80+
# Initialize simulation objects
81+
if init_sim_objects_auto:
82+
self.init_sim_objects()
83+
self.comm.Barrier() # wait that all are done with the init
84+
85+
86+
def init_sim_objects(self):
8087

88+
self.sim_content.init_all()
8189
if self.I_am_the_master:
8290
self.pieces_to_be_treated = self.sim_content.init_master()
8391
self.N_pieces = len(self.pieces_to_be_treated)
@@ -93,7 +101,6 @@ def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, c
93101
self.left = self.myid-1
94102
self.right = self.myid+1
95103

96-
self.comm.Barrier() # wait that all are done with the init
97104

98105
def run(self):
99106
if self.I_am_the_master:

0 commit comments

Comments
 (0)