Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add threaded-timer support to hpc-benchmark #14

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 35 additions & 20 deletions hpc_benchmark/hpc_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,18 +399,18 @@ def run_simulation():
for d in range(presim_steps):
nest.Run(nest.min_delay)
times[d] = time.time() - tic
vmsizes[presim_steps] = get_vmsize()
vmpeaks[presim_steps] = get_vmpeak()
vmrsss[presim_steps] = get_rss()
vmsizes[d] = get_vmsize()
vmpeaks[d] = get_vmpeak()
vmrsss[d] = get_rss()
for key in step_data_keys:
step_data[key][d] = getattr(nest, key)

if presim_remaining_time > 0:
nest.Run(presim_remaining_time)
times[presim_steps] = time.time() - tic
vmsizes[presim_steps + sim_steps] = get_vmsize()
vmpeaks[presim_steps + sim_steps] = get_vmpeak()
vmrsss[presim_steps + sim_steps] = get_rss()
vmsizes[presim_steps] = get_vmsize()
vmpeaks[presim_steps] = get_vmpeak()
vmrsss[presim_steps] = get_rss()
for key in step_data_keys:
step_data[key][presim_steps] = getattr(nest, key)
presim_steps += 1
Expand All @@ -424,21 +424,21 @@ def run_simulation():
for d in range(sim_steps):
nest.Run(nest.min_delay)
times[presim_steps + d] = time.time() - tic
vmsizes[presim_steps + d] = get_vmsize()
vmpeaks[presim_steps + d] = get_vmpeak()
vmrsss[presim_steps + d] = get_rss()
for key in step_data_keys:
step_data[key][presim_steps + d] = getattr(nest, key)

if sim_remaining_time > 0:
nest.Run(sim_remaining_time)
times[presim_steps + sim_steps] = time.time() - tic
vmsizes[presim_steps + sim_steps] = get_vmsize()
vmpeaks[presim_steps + sim_steps] = get_vmpeak()
vmrsss[presim_steps + sim_steps] = get_rss()
for key in step_data_keys:
step_data[key][presim_steps + sim_steps] = getattr(nest, key)
sim_steps += 1

SimCPUTime = time.time() - tic
total_memory = str(get_vmsize())
total_memory_rss = str(get_rss())
total_memory_peak = str(get_vmpeak())

else:
build_dict, sr = build_network()

Expand All @@ -456,10 +456,13 @@ def run_simulation():
intermediate_kernel_status = nest.kernel_status

tic = time.time()
nest.Run(params['presimtime'])
SimCPUTime = time.time() - tic
total_memory = str(get_vmsize())
nest.Run(params['simtime'])

SimCPUTime = time.time() - tic
total_memory = str(get_vmsize())
total_memory_rss = str(get_rss())
total_memory_peak = str(get_vmpeak())

average_rate = 0.0
if params['record_spikes']:
average_rate = compute_rate(sr)
Expand Down Expand Up @@ -487,14 +490,26 @@ def run_simulation():
d.update(final_kernel_status)

# Subtract timer information from presimulation period
timers = ['time_collocate_spike_data', 'time_communicate_prepare',
'time_communicate_spike_data', 'time_deliver_spike_data',
'time_gather_spike_data', 'time_update', 'time_simulate']
timers = ['time_collocate_spike_data', 'time_communicate_spike_data', 'time_communicate_target_data', 'time_deliver_secondary_data', 'time_deliver_spike_data', 'time_gather_secondary_data', 'time_gather_spike_data', 'time_omp_synchronization_simulation', 'time_mpi_synchronization', 'time_simulate', 'time_update']
timers.extend([timer + '_cpu' for timer in timers])

for timer in timers:
try:
d[timer + '_presim'] = intermediate_kernel_status[timer]
d[timer] -= intermediate_kernel_status[timer]
if type(d[timer]) == tuple or type(d[timer]) == list:
timer_array = tuple(d[timer][tid] - intermediate_kernel_status[timer][tid] for tid in range(len(d[timer])))
d[timer] = timer_array[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for adding only the first value of the tuple to the logfile? And why is this handled differently for the presim timers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding the first value would be equivalent to just measuring on the master thread, i.e., makes the data comparable with pre-threaded-timer data. This is just required for now, as beNNch only handles scalar data at the moment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see thanks. But why is this handled differently for sim time and presim time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was just an oversight from my side, I added the same code for presim as well now!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

d[timer + "_max"] = max(timer_array)
d[timer + "_min"] = min(timer_array)
d[timer + "_avg"] = np.mean(timer_array)
d[timer + "_all"] = timer_array
d[timer + '_presim'] = intermediate_kernel_status[timer][0]
d[timer + "_presim_max"] = max(intermediate_kernel_status[timer])
d[timer + "_presim_min"] = min(intermediate_kernel_status[timer])
d[timer + "_presim_avg"] = np.mean(intermediate_kernel_status[timer])
d[timer + "_presim_all"] = intermediate_kernel_status[timer]
else:
d[timer] -= intermediate_kernel_status[timer]
d[timer + '_presim'] = intermediate_kernel_status[timer]
except KeyError:
# KeyError if compiled without detailed timers, except time_simulate
continue
Expand Down