Skip to content

Commit c8a30e2

Browse files
committed
Remove hard-coded buffer sizes
1 parent 6e97603 commit c8a30e2

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

ring_of_CPUs.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,23 @@ def print2logandstdo(message, mode='a+'):
1010

1111

1212
class RingOfCPUs(object):
13-
def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, comm=None):
13+
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):
1415

1516
self.sim_content = sim_content
1617
self.N_turns = sim_content.N_turns
1718
self.N_pieces_per_transfer = N_pieces_per_transfer
19+
self.N_buffer_float_size = N_buffer_float_size
20+
self.N_buffer_int_size = N_buffer_int_size
1821

1922
if hasattr(sim_content, 'N_pieces_per_transfer'):
2023
self.N_pieces_per_transfer = sim_content.N_pieces_per_transfer
24+
25+
if hasattr(sim_content, 'N_buffer_float_size'):
26+
self.N_buffer_float_size = sim_content.N_buffer_float_size
27+
28+
if hasattr(sim_content, 'N_buffer_int_size'):
29+
self.N_buffer_int_size = sim_content.N_buffer_int_size
2130

2231

2332
self.sim_content.ring_of_CPUs = self
@@ -48,9 +57,9 @@ def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, c
4857
self.I_am_the_master = not(self.I_am_a_worker)
4958

5059
# allocate buffers for communication
51-
self.N_buffer_float_size = 1000000
60+
5261
self.buf_float = np.array(self.N_buffer_float_size*[0.])
53-
self.N_buffer_int_size = 100
62+
5463
self.buf_int = np.array(self.N_buffer_int_size*[0])
5564

5665
self.sim_content.init_all()
@@ -60,6 +69,8 @@ def __init__(self, sim_content, N_pieces_per_transfer=1, force_serial = False, c
6069
print2logandstdo(comm_info)
6170
print2logandstdo('N_cores = %d'%self.N_nodes)
6271
print2logandstdo('N_pieces_per_transfer = %d'%self.N_pieces_per_transfer)
72+
print2logandstdo('N_buffer_float_size = %d'%self.N_buffer_float_size)
73+
print2logandstdo('N_buffer_int_size = %d'%self.N_buffer_int_size)
6374
import socket
6475
import sys
6576
print2logandstdo('Running on %s'%socket.gethostname())
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/bash
22

33
# Run Parallel without MPI
4-
# ../multiprocexec.py -n 3 sim_class=Simulation.Simulation
4+
../multiprocexec.py -n 3 sim_class=Simulation.Simulation
55

66
# Run Serial
77
# ../serialexec.py sim_class=Simulation.Simulation
88

99
# Run MPI
10-
mpiexec -n 4 ../withmpi.py sim_class=Simulation.Simulation
10+
# mpiexec -n 4 ../withmpi.py sim_class=Simulation.Simulation
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/bash
22

33
# Run Parallel without MPI
4-
../multiprocexec.py -n 3 sim_class=Simulation.Simulation
4+
../multiprocexec.py -n 3 sim_class=Simulation_with_eclouds.Simulation
55

66
# Run Serial
7-
# ../serialexec.py sim_class=Simulation.Simulation
7+
# ../serialexec.py sim_class=Simulation_with_eclouds.Simulation
88

99
# Run MPI
1010
# mpiexec -n 4 ../withmpi.py sim_class=Simulation_with_eclouds.Simulation

test_ring_with_objects/Simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
class Simulation(object):
1515
def __init__(self):
1616
self.N_turns = 128
17+
self.N_buffer_float_size = 500000
18+
self.N_buffer_int_size = 450
1719

1820
def init_all(self):
1921
n_slices = 100

0 commit comments

Comments
 (0)