From efc26cd13a34504dd84973ac58f0aa42300691a3 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Mon, 6 Dec 2021 13:28:17 +0000 Subject: [PATCH 01/13] Move provenance analysis using pandas etc. out of main tools --- spinncer/cerebellum_experiment.py | 10 +++ spinncer/provenance_analysis.py | 145 ++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+) diff --git a/spinncer/cerebellum_experiment.py b/spinncer/cerebellum_experiment.py index 146b49d..6b0050d 100644 --- a/spinncer/cerebellum_experiment.py +++ b/spinncer/cerebellum_experiment.py @@ -32,6 +32,8 @@ import pylab as plt import os import traceback +from spinn_front_end_common.utilities.globals_variables import get_simulator +from spinncer.provenance_analysis import save_provenance_to_file_from_database # Record SCRIPT start time (wall clock) start_time = plt.datetime.datetime.now() @@ -234,6 +236,9 @@ recorded_spikes = {} other_recordings = {} +# Store simulator and run +simulator = get_simulator() + # Record simulation start time (wall clock) sim_start_time = plt.datetime.datetime.now() current_error = None @@ -311,6 +316,11 @@ # Appropriately end the simulation sim.end() +# Get the provenance from the simulator's database +structured_provenance_filename = "structured_provenance.csv" +save_provenance_to_file_from_database( + structured_provenance_filename, simulator) + # Analysis time! spike_analysis(results_file=results_file, fig_folder=args.figures_dir, worst_case=args.worst_case_spikes, delay_sensitive=True) diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index 1ac187b..60cd0ed 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -1,10 +1,15 @@ import itertools +import pandas as pd from spinncer.analysis_common import * from os.path import join as join from numpy.polynomial.polynomial import Polynomial import traceback +from spinn_front_end_common.utilities.globals_variables import ( + provenance_file_path) +from spinn_front_end_common.interface.provenance import ProvenanceReader + def extract_per_pop_placements(df, pops): placement_results = {} @@ -56,6 +61,146 @@ def extract_per_pop_info(df, type_of_prov, pops, report=False): return pop_results +def save_provenance_to_file_from_database(in_file, simulator): + # Here we need to get the provenance from the database and put it in + # the specified file + + # list provenance of interest + router_provenance_of_interest = [ + 'Dumped_from_a_Link', + 'Dumped_from_a_processor', + 'Local_Multicast_Packets', + 'External_Multicast_Packets', + 'Dropped_Multicast_Packets', + 'Missed_For_Reinjection' + ] + prov_of_interest = [ + 'Maximum number of spikes in a timer tick', + 'Times_synaptic_weights_have_saturated', + 'late_packets', + 'Times_the_input_buffer_lost_packets', + 'Times_the_timer_tic_over_ran', + 'Total_pre_synaptic_events', + 'Maximum number of DMAs in a timer tick', + 'Maximum pipeline restarts', + 'send_multicast_packets', + 'Maximum number of spikes flushed in a timer tick', + 'Total number of spikes flushed' + ] + + # Custom provenance presentation from SpiNNCer + # write provenance to file here in a useful way + columns = ['pop', 'label', 'min_atom', 'max_atom', 'no_atoms', + 'x', 'y', 'p', + 'prov_name', 'prov_value', + 'fixed_sdram', 'sdram_per_timestep', + 'cpu_cycles', 'dtcm'] + # assert (len(prov_placement) == len(prov_items)) + structured_provenance = list() + metadata = {} + # Retrieve filename from spynnaker8/spinnaker.py + provenance_filename = in_file + + if provenance_filename: + # Produce metadata from the simulator info + metadata['name'] = simulator.name + metadata['no_machine_time_steps'] = simulator.no_machine_time_steps + metadata['machine_time_step'] = simulator.machine_time_step + # metadata['config'] = simulator.config + metadata['machine'] = simulator.machine + metadata['structured_provenance_filename'] = \ + simulator.structured_provenance_filename + + # how do we loop over all the placements in the database at this point? + # can we get router_provenance from the database? + # placements is 0... so is this router(0, 0)? + pr = ProvenanceReader(os.path.join( + provenance_file_path(), "provenance.sqlite3")) + + cores_list = pr.get_cores_with_provenance() + + # router_provenance = pr.get_provenance_for_router(0, 0) + # print("router_provenance: ", router_provenance) + + # for i, (provenance, placement) in enumerate(zip(prov_items, prov_placement)): + for core in cores_list: + x = core[1] + y = core[2] + p = core[3] + structured_prov_core = get_provenance_for_core(pr, x, y, p) + + pop = structured_prov_core['pop'] + if pop == []: + continue + pop = pop[0][0] + fixed_sdram = structured_prov_core['fixed_sdram'][0][0] + sdram_per_timestep = structured_prov_core['sdram_per_timestep'][0][0] + cpu_cycles = structured_prov_core['cpu_cycles'][0][0] + + label = structured_prov_core['label'][0][0] + max_atom = structured_prov_core['max_atom'][0][0] + min_atom = structured_prov_core['min_atom'][0][0] + no_atoms = structured_prov_core['no_atoms'][0][0] + dtcm = structured_prov_core['dtcm'][0][0] + + for prov_name in prov_of_interest: + prov_value = get_core_provenance_value(pr, x, y, p, prov_name) + if prov_value == []: + prov_value = 0 + else: + prov_value = prov_value[0][0] + + structured_provenance.append( + [pop, label, min_atom, max_atom, no_atoms, + x, y, p, + prov_name, prov_value, + fixed_sdram, sdram_per_timestep, + cpu_cycles, dtcm] + ) + + for prov_name in router_provenance_of_interest: + prov_value = get_router_provenance_value(pr, x, y, prov_name) + if prov_value == []: + prov_value = 0 + else: + prov_value = prov_value[0][0] + + structured_provenance.append( + [pop, label, min_atom, max_atom, no_atoms, + x, y, p, + prov_name, prov_value, + fixed_sdram, sdram_per_timestep, + cpu_cycles, dtcm] + ) + + # print("structured provenance: ", structured_provenance) + + structured_provenance_df = pd.DataFrame.from_records( + structured_provenance, columns=columns) + + # check if the same structured prov already exists + if os.path.exists(provenance_filename): + existing_data = np.load(provenance_filename, allow_pickle=True) + # TODO check that metadata is correct + + # figure out the past run id + numerical_runs = [int(x) for x in existing_data.files if x not in ["metadata"]] + prev_run = np.max(numerical_runs) + + else: + existing_data = {"metadata": metadata} + prev_run = -1 # no previous run + + # Current data assembly + current_data = {str(prev_run + 1): + structured_provenance_df.to_records(index=False)} + + # Append current data to existing data + np.savez_compressed(provenance_filename, + **existing_data, + **current_data) + + def provenance_csv_analysis(in_folder, fig_folder): write_header("Reading provenances in folder " + in_folder) prov = pd.read_csv(join(in_folder, "structured_provenance.csv")) From a48de4256ccb3e47df1b17a2f6a4748885a0b3e7 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Thu, 16 Dec 2021 15:08:12 +0000 Subject: [PATCH 02/13] Update analysis scripts --- spinncer/cerebellum_analysis.py | 13 ++++++----- spinncer/provenance_analysis.py | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/spinncer/cerebellum_analysis.py b/spinncer/cerebellum_analysis.py index e8ce049..8ef9fae 100644 --- a/spinncer/cerebellum_analysis.py +++ b/spinncer/cerebellum_analysis.py @@ -465,6 +465,7 @@ def spike_analysis(results_file, fig_folder, # before, during and after stimulation _filtered_spike_rates = np.zeros(stimulus_periods) _spike_times = spikes[:, 1] + _spike_nids = spikes[:, 0] # Initialise per_neuron_firing per_neuron_firing[pop] = np.ones((all_neurons[pop], stimulus_periods)) * -10 @@ -498,7 +499,7 @@ def spike_analysis(results_file, fig_folder, np.count_nonzero(_filtered_spike_times) / \ (current_period_duration * ms) for nid in range(all_neurons[pop]): - _spikes_for_nid = spikes[spikes[:, 0] == nid][:, 1] + _spikes_for_nid = spikes[_spike_nids == nid][:, 1] _no_spike_for_nid = np.count_nonzero(np.logical_and( _spikes_for_nid >= time_filter_pre, _spikes_for_nid < time_filter_post)) @@ -712,8 +713,10 @@ def spike_analysis(results_file, fig_folder, print("Connection Name ") print("{:27} | {:10} | ".format("Connection Name", "Def. W"), "{:20}".format("SpiNN. W")) - sorted_keys = list(final_connectivity.keys()) - sorted_keys.sort() + sorted_keys = [] + if final_connectivity != []: + sorted_keys = list(final_connectivity.keys()) + sorted_keys.sort() for key in sorted_keys: conn = conn_dict[key] mean = np.abs(np.mean(conn[:, 2])) @@ -802,8 +805,8 @@ def spike_analysis(results_file, fig_folder, # Report statistics here for key, v in all_voltages.items(): nid, tstep = np.unravel_index(np.argmax(v, axis=None), v.shape) - print("{:20}-> neuron {:>8d} received {:>6d}".format( - key, int(nid), int(np.max(v))), + print("{:20}-> neuron {:>8d} received {:4.2f}".format( + key, int(nid), np.max(v)), "nA in timestep #{:8d}".format(int(tstep))) # THIS IS BROKEN! it will be removed soon # # Also treat voltage as if it's a piggybacked value packaging diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index 60cd0ed..f5c67e3 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -233,6 +233,45 @@ def provenance_csv_analysis(in_folder, fig_folder): return results, types_of_provenance, prov_of_interest, placements +def get_provenance_for_core(pr, x, y, p): + structured_prov = {} + columns_to_get = ['pop', 'label', 'min_atom', 'max_atom', 'no_atoms', + 'fixed_sdram', 'sdram_per_timestep', + 'cpu_cycles', 'dtcm'] # add more as needed + + for column_to_get in columns_to_get: + query = """ + SELECT the_value + FROM core_provenance + WHERE x = ? AND y = ? AND p = ? AND description = ? + """ + # result = pr.run_query(query, [x, y, p, column_to_get]) + structured_prov[column_to_get] = pr.run_query( + query, [x, y, p, column_to_get]) + # print('x,y,p,desc: ', x, y, p, column_to_get, + # structured_prov[column_to_get]) + + return structured_prov + + +def get_core_provenance_value(pr, x, y, p, description): + query = """ + SELECT the_value + FROM core_provenance + WHERE x = ? AND y = ? AND p = ? AND description = ? + """ + return pr.run_query(query, [x, y, p, description]) + + +def get_router_provenance_value(pr, x, y, description): + query = """ + SELECT the_value + FROM router_provenance + WHERE x = ? AND y = ? AND description = ? + """ + return pr.run_query(query, [x, y, description]) + + def sweep_provenance_analysis(in_folder, fig_folder, group_on, group_on_name): # Check if the folders exist From 10408886edb00342703df047ebea34d347028ad0 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Tue, 21 Dec 2021 11:33:15 +0000 Subject: [PATCH 03/13] strange that this is a different format here than in icub_vor --- spinncer/provenance_analysis.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index f5c67e3..68af0c8 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -178,27 +178,7 @@ def save_provenance_to_file_from_database(in_file, simulator): structured_provenance_df = pd.DataFrame.from_records( structured_provenance, columns=columns) - # check if the same structured prov already exists - if os.path.exists(provenance_filename): - existing_data = np.load(provenance_filename, allow_pickle=True) - # TODO check that metadata is correct - - # figure out the past run id - numerical_runs = [int(x) for x in existing_data.files if x not in ["metadata"]] - prev_run = np.max(numerical_runs) - - else: - existing_data = {"metadata": metadata} - prev_run = -1 # no previous run - - # Current data assembly - current_data = {str(prev_run + 1): - structured_provenance_df.to_records(index=False)} - - # Append current data to existing data - np.savez_compressed(provenance_filename, - **existing_data, - **current_data) + structured_provenance_df.to_csv("structured_provenance.csv") def provenance_csv_analysis(in_folder, fig_folder): From 7f52f996334a034fc520c4e4034696a4e1d59f62 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 20 Jul 2022 09:57:16 +0100 Subject: [PATCH 04/13] switch to import pyNN.spinnaker; update gitignore --- .gitignore | 4 ++-- spinncer/cerebellum_analysis.py | 5 +++++ spinncer/cerebellum_experiment.py | 6 +----- spinncer/single_cell_experiment.py | 6 +----- spinncer/testing_granule_cells.py | 6 +----- tests/01_ms_tests/20_ms_test.py | 6 +----- tests/01_ms_tests/6000_spikes_01_ms.py | 6 +----- tests/01_ms_tests/nest_testing_all_connections.py | 6 +----- tests/01_ms_tests/test_long_delay_extension.py | 6 +----- tests/01_ms_tests/testing_all_cells_dc.py | 6 +----- tests/01_ms_tests/testing_all_cells_single_spikes.py | 6 +----- tests/01_ms_tests/testing_all_cells_spikes.py | 6 +----- .../01_ms_tests/testing_all_cells_spikes_realistic_conn.py | 6 +----- tests/01_ms_tests/testing_all_connections.py | 6 +----- tests/100_spikes.py | 6 +----- tests/100_spikes_0_dmas.py | 6 +----- tests/6000_spikes.py | 6 +----- tests/if_cond_alpha_tests/synfire_if_cond_alpha.py | 2 +- tests/no_spikes.py | 6 +----- tests/one_spike.py | 6 +----- tests/test_abcd_counter.py | 6 +----- 21 files changed, 26 insertions(+), 93 deletions(-) diff --git a/.gitignore b/.gitignore index 1bed9b3..2cd4aa2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -application_generated_data_files/* -reports/* +*application_generated_data_files/ +*reports/ __pycache__/ .idea/ spynnaker.cfg diff --git a/spinncer/cerebellum_analysis.py b/spinncer/cerebellum_analysis.py index 8ef9fae..96d1c78 100644 --- a/spinncer/cerebellum_analysis.py +++ b/spinncer/cerebellum_analysis.py @@ -417,6 +417,8 @@ def spike_analysis(results_file, fig_folder, try: for pop in plot_order: curr_spikes = neo_all_spikes[pop].segments[0].spiketrains + print("pop, curr_spikes: ", pop, curr_spikes) + print("elephant, timestep, simtime", elephant_timestep, elephant_simtime) curr_inst_rates = \ elephant.statistics.instantaneous_rate( curr_spikes, @@ -437,6 +439,9 @@ def spike_analysis(results_file, fig_folder, except: traceback.print_exc() + print("elephant_instantaneous_rates: ", elephant_instantaneous_rates) + print("all_neurons: ", all_neurons) + stim_period_start = {} stim_period_end = {} per_pop_stim_durations = {k: [] for k in plot_order} diff --git a/spinncer/cerebellum_experiment.py b/spinncer/cerebellum_experiment.py index 6b0050d..74995f9 100644 --- a/spinncer/cerebellum_experiment.py +++ b/spinncer/cerebellum_experiment.py @@ -12,11 +12,7 @@ # import simulator spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/spinncer/single_cell_experiment.py b/spinncer/single_cell_experiment.py index ea60e20..bce7e47 100644 --- a/spinncer/single_cell_experiment.py +++ b/spinncer/single_cell_experiment.py @@ -13,11 +13,7 @@ # import simulator spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/spinncer/testing_granule_cells.py b/spinncer/testing_granule_cells.py index 6418da9..d531abb 100644 --- a/spinncer/testing_granule_cells.py +++ b/spinncer/testing_granule_cells.py @@ -16,11 +16,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/20_ms_test.py b/tests/01_ms_tests/20_ms_test.py index a6fd42c..16553e7 100644 --- a/tests/01_ms_tests/20_ms_test.py +++ b/tests/01_ms_tests/20_ms_test.py @@ -1,11 +1,7 @@ """ This script tests whether delays are implemented correctly """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt import numpy as np diff --git a/tests/01_ms_tests/6000_spikes_01_ms.py b/tests/01_ms_tests/6000_spikes_01_ms.py index 19e4647..013b24d 100644 --- a/tests/01_ms_tests/6000_spikes_01_ms.py +++ b/tests/01_ms_tests/6000_spikes_01_ms.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim sim.setup(timestep=0.1, min_delay=0.1, max_delay=1) # Generate 6000 spikes (1 for each input neuron) diff --git a/tests/01_ms_tests/nest_testing_all_connections.py b/tests/01_ms_tests/nest_testing_all_connections.py index b468de5..9145198 100644 --- a/tests/01_ms_tests/nest_testing_all_connections.py +++ b/tests/01_ms_tests/nest_testing_all_connections.py @@ -16,11 +16,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/test_long_delay_extension.py b/tests/01_ms_tests/test_long_delay_extension.py index 45a4941..7160384 100644 --- a/tests/01_ms_tests/test_long_delay_extension.py +++ b/tests/01_ms_tests/test_long_delay_extension.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt sim.setup(timestep=0.1, min_delay=0.1, max_delay=80) diff --git a/tests/01_ms_tests/testing_all_cells_dc.py b/tests/01_ms_tests/testing_all_cells_dc.py index f37716c..8c29e94 100644 --- a/tests/01_ms_tests/testing_all_cells_dc.py +++ b/tests/01_ms_tests/testing_all_cells_dc.py @@ -6,11 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_cells_single_spikes.py b/tests/01_ms_tests/testing_all_cells_single_spikes.py index f161e41..20002b2 100644 --- a/tests/01_ms_tests/testing_all_cells_single_spikes.py +++ b/tests/01_ms_tests/testing_all_cells_single_spikes.py @@ -6,11 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_cells_spikes.py b/tests/01_ms_tests/testing_all_cells_spikes.py index 6245845..8151a92 100644 --- a/tests/01_ms_tests/testing_all_cells_spikes.py +++ b/tests/01_ms_tests/testing_all_cells_spikes.py @@ -6,11 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py b/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py index fefbb45..afbc90e 100644 --- a/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py +++ b/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py @@ -6,11 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_connections.py b/tests/01_ms_tests/testing_all_connections.py index aa79bd4..16082b9 100644 --- a/tests/01_ms_tests/testing_all_connections.py +++ b/tests/01_ms_tests/testing_all_connections.py @@ -16,11 +16,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - try: - # this might be deprecated soon - import spynnaker8 as sim - except ImportError: - import pyNN.spynnaker as sim + import pyNN.spynnaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/100_spikes.py b/tests/100_spikes.py index fd6cbfc..1030e9e 100644 --- a/tests/100_spikes.py +++ b/tests/100_spikes.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Compute 100 spike diff --git a/tests/100_spikes_0_dmas.py b/tests/100_spikes_0_dmas.py index 7140bdc..da8a388 100644 --- a/tests/100_spikes_0_dmas.py +++ b/tests/100_spikes_0_dmas.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Compute 100 spike diff --git a/tests/6000_spikes.py b/tests/6000_spikes.py index c3bd447..d186c09 100644 --- a/tests/6000_spikes.py +++ b/tests/6000_spikes.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Generate 6000 spikes (1 for each input neuron) diff --git a/tests/if_cond_alpha_tests/synfire_if_cond_alpha.py b/tests/if_cond_alpha_tests/synfire_if_cond_alpha.py index 56ed01d..f0e1b9f 100644 --- a/tests/if_cond_alpha_tests/synfire_if_cond_alpha.py +++ b/tests/if_cond_alpha_tests/synfire_if_cond_alpha.py @@ -16,7 +16,7 @@ """ Synfirechain-like example """ -import spynnaker8 as sim +import pyNN.spiNNaker as sim from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt diff --git a/tests/no_spikes.py b/tests/no_spikes.py index 08cd83f..6885a38 100644 --- a/tests/no_spikes.py +++ b/tests/no_spikes.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) diff --git a/tests/one_spike.py b/tests/one_spike.py index 209606d..f55d0ac 100644 --- a/tests/one_spike.py +++ b/tests/one_spike.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Compute 1 spike diff --git a/tests/test_abcd_counter.py b/tests/test_abcd_counter.py index ca012b0..a519b39 100644 --- a/tests/test_abcd_counter.py +++ b/tests/test_abcd_counter.py @@ -1,11 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -try: - # this might be deprecated soon - import spynnaker8 as sim -except ImportError: - import pyNN.spynnaker as sim +import pyNN.spynnaker as sim from spinncer.analysis_common import * plt.viridis() From f59935a10b54340312cd6cbb2fccfc5b14a3acb8 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 20 Jul 2022 10:11:32 +0100 Subject: [PATCH 05/13] Try matching numpy/scipy versions to main toolchain --- requirements.txt | 8 ++++++-- setup.py | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index e87f664..1a96d17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,9 @@ -numpy==1.15.4 -scipy==1.3.0 +numpy > 1.13, < 1.20; python_version == '3.6' +numpy > 1.13, < 1.21; python_version == '3.7' +numpy; python_version >= '3.8' +scipy >= 0.16.0, < 1.6; python_version == '3.6' +scipy >= 0.16.0, < 1.8; python_version == '3.7' +scipy >= 0.16.0; python_version >= '3.8' brian2 neo==0.7.1 pynn diff --git a/setup.py b/setup.py index 1d89c13..cb0d1fa 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,12 @@ install_requires = [ - "numpy==1.15.4", - "scipy==1.3.0", + "numpy > 1.13, < 1.20; python_version == '3.6'", + "numpy > 1.13, < 1.21; python_version == '3.7'", + "numpy; python_version >= '3.8'", + "scipy >= 0.16.0, < 1.6; python_version == '3.6'", + "scipy >= 0.16.0, < 1.8; python_version == '3.7'", + "scipy >= 0.16.0; python_version >= '3.8'" "brian2", "neo==0.7.1", "pynn==0.9.5", @@ -38,7 +42,7 @@ "Programming Language :: Python :: 3" "Programming Language :: Python :: 3.7" - + "Topic :: Scientific/Engineering", ] ) From 70b583ddcd3efb02f6a8ca648472a01709abdb1b Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 20 Jul 2022 10:14:23 +0100 Subject: [PATCH 06/13] Use the correct import --- spinncer/cerebellum_experiment.py | 2 +- spinncer/single_cell_experiment.py | 2 +- spinncer/testing_granule_cells.py | 2 +- tests/01_ms_tests/20_ms_test.py | 2 +- tests/01_ms_tests/6000_spikes_01_ms.py | 2 +- tests/01_ms_tests/nest_testing_all_connections.py | 2 +- tests/01_ms_tests/test_long_delay_extension.py | 2 +- tests/01_ms_tests/testing_all_cells_dc.py | 2 +- tests/01_ms_tests/testing_all_cells_single_spikes.py | 2 +- tests/01_ms_tests/testing_all_cells_spikes.py | 2 +- tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py | 2 +- tests/01_ms_tests/testing_all_connections.py | 2 +- tests/100_spikes.py | 2 +- tests/100_spikes_0_dmas.py | 2 +- tests/6000_spikes.py | 2 +- tests/no_spikes.py | 2 +- tests/one_spike.py | 2 +- tests/test_abcd_counter.py | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/spinncer/cerebellum_experiment.py b/spinncer/cerebellum_experiment.py index 74995f9..5e7294b 100644 --- a/spinncer/cerebellum_experiment.py +++ b/spinncer/cerebellum_experiment.py @@ -12,7 +12,7 @@ # import simulator spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/spinncer/single_cell_experiment.py b/spinncer/single_cell_experiment.py index bce7e47..13204ed 100644 --- a/spinncer/single_cell_experiment.py +++ b/spinncer/single_cell_experiment.py @@ -13,7 +13,7 @@ # import simulator spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/spinncer/testing_granule_cells.py b/spinncer/testing_granule_cells.py index d531abb..7bd2faf 100644 --- a/spinncer/testing_granule_cells.py +++ b/spinncer/testing_granule_cells.py @@ -16,7 +16,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/20_ms_test.py b/tests/01_ms_tests/20_ms_test.py index 16553e7..74ee97b 100644 --- a/tests/01_ms_tests/20_ms_test.py +++ b/tests/01_ms_tests/20_ms_test.py @@ -1,7 +1,7 @@ """ This script tests whether delays are implemented correctly """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt import numpy as np diff --git a/tests/01_ms_tests/6000_spikes_01_ms.py b/tests/01_ms_tests/6000_spikes_01_ms.py index 013b24d..ec0e61a 100644 --- a/tests/01_ms_tests/6000_spikes_01_ms.py +++ b/tests/01_ms_tests/6000_spikes_01_ms.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim sim.setup(timestep=0.1, min_delay=0.1, max_delay=1) # Generate 6000 spikes (1 for each input neuron) diff --git a/tests/01_ms_tests/nest_testing_all_connections.py b/tests/01_ms_tests/nest_testing_all_connections.py index 9145198..94633b0 100644 --- a/tests/01_ms_tests/nest_testing_all_connections.py +++ b/tests/01_ms_tests/nest_testing_all_connections.py @@ -16,7 +16,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/test_long_delay_extension.py b/tests/01_ms_tests/test_long_delay_extension.py index 7160384..61820d5 100644 --- a/tests/01_ms_tests/test_long_delay_extension.py +++ b/tests/01_ms_tests/test_long_delay_extension.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt sim.setup(timestep=0.1, min_delay=0.1, max_delay=80) diff --git a/tests/01_ms_tests/testing_all_cells_dc.py b/tests/01_ms_tests/testing_all_cells_dc.py index 8c29e94..1ff6ef3 100644 --- a/tests/01_ms_tests/testing_all_cells_dc.py +++ b/tests/01_ms_tests/testing_all_cells_dc.py @@ -6,7 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_cells_single_spikes.py b/tests/01_ms_tests/testing_all_cells_single_spikes.py index 20002b2..66ffcef 100644 --- a/tests/01_ms_tests/testing_all_cells_single_spikes.py +++ b/tests/01_ms_tests/testing_all_cells_single_spikes.py @@ -6,7 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_cells_spikes.py b/tests/01_ms_tests/testing_all_cells_spikes.py index 8151a92..0acb9da 100644 --- a/tests/01_ms_tests/testing_all_cells_spikes.py +++ b/tests/01_ms_tests/testing_all_cells_spikes.py @@ -6,7 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py b/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py index afbc90e..417cbbb 100644 --- a/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py +++ b/tests/01_ms_tests/testing_all_cells_spikes_realistic_conn.py @@ -6,7 +6,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/01_ms_tests/testing_all_connections.py b/tests/01_ms_tests/testing_all_connections.py index 16082b9..2013f2d 100644 --- a/tests/01_ms_tests/testing_all_connections.py +++ b/tests/01_ms_tests/testing_all_connections.py @@ -16,7 +16,7 @@ spinnaker_sim = False if str.lower(args.simulator) in ["spinnaker", "spynnaker"]: - import pyNN.spynnaker as sim + import pyNN.spiNNaker as sim spinnaker_sim = True elif str.lower(args.simulator) in ["nest"]: import pyNN.nest as sim diff --git a/tests/100_spikes.py b/tests/100_spikes.py index 1030e9e..24e949f 100644 --- a/tests/100_spikes.py +++ b/tests/100_spikes.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Compute 100 spike diff --git a/tests/100_spikes_0_dmas.py b/tests/100_spikes_0_dmas.py index da8a388..aff5fdd 100644 --- a/tests/100_spikes_0_dmas.py +++ b/tests/100_spikes_0_dmas.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Compute 100 spike diff --git a/tests/6000_spikes.py b/tests/6000_spikes.py index d186c09..70c829e 100644 --- a/tests/6000_spikes.py +++ b/tests/6000_spikes.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Generate 6000 spikes (1 for each input neuron) diff --git a/tests/no_spikes.py b/tests/no_spikes.py index 6885a38..6dd3926 100644 --- a/tests/no_spikes.py +++ b/tests/no_spikes.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) diff --git a/tests/one_spike.py b/tests/one_spike.py index f55d0ac..7e7bbd3 100644 --- a/tests/one_spike.py +++ b/tests/one_spike.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim sim.setup(timestep=1, min_delay=1, max_delay=1) # Compute 1 spike diff --git a/tests/test_abcd_counter.py b/tests/test_abcd_counter.py index a519b39..a30372c 100644 --- a/tests/test_abcd_counter.py +++ b/tests/test_abcd_counter.py @@ -1,7 +1,7 @@ """ This script tests whether spike counting additional provenance is correct """ -import pyNN.spynnaker as sim +import pyNN.spiNNaker as sim from spinncer.analysis_common import * plt.viridis() From 3251ab0bcc1b2c4b19cef805ce6a65516b4a8f8f Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 24 Aug 2022 17:37:13 +0100 Subject: [PATCH 07/13] cpu_cycles and dtcm are no longer in structured provenance --- spinncer/provenance_analysis.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index 68af0c8..6bf9770 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -93,8 +93,7 @@ def save_provenance_to_file_from_database(in_file, simulator): columns = ['pop', 'label', 'min_atom', 'max_atom', 'no_atoms', 'x', 'y', 'p', 'prov_name', 'prov_value', - 'fixed_sdram', 'sdram_per_timestep', - 'cpu_cycles', 'dtcm'] + 'fixed_sdram', 'sdram_per_timestep'] # assert (len(prov_placement) == len(prov_items)) structured_provenance = list() metadata = {} @@ -135,13 +134,11 @@ def save_provenance_to_file_from_database(in_file, simulator): pop = pop[0][0] fixed_sdram = structured_prov_core['fixed_sdram'][0][0] sdram_per_timestep = structured_prov_core['sdram_per_timestep'][0][0] - cpu_cycles = structured_prov_core['cpu_cycles'][0][0] label = structured_prov_core['label'][0][0] max_atom = structured_prov_core['max_atom'][0][0] min_atom = structured_prov_core['min_atom'][0][0] no_atoms = structured_prov_core['no_atoms'][0][0] - dtcm = structured_prov_core['dtcm'][0][0] for prov_name in prov_of_interest: prov_value = get_core_provenance_value(pr, x, y, p, prov_name) @@ -154,8 +151,7 @@ def save_provenance_to_file_from_database(in_file, simulator): [pop, label, min_atom, max_atom, no_atoms, x, y, p, prov_name, prov_value, - fixed_sdram, sdram_per_timestep, - cpu_cycles, dtcm] + fixed_sdram, sdram_per_timestep] ) for prov_name in router_provenance_of_interest: @@ -169,8 +165,7 @@ def save_provenance_to_file_from_database(in_file, simulator): [pop, label, min_atom, max_atom, no_atoms, x, y, p, prov_name, prov_value, - fixed_sdram, sdram_per_timestep, - cpu_cycles, dtcm] + fixed_sdram, sdram_per_timestep] ) # print("structured provenance: ", structured_provenance) @@ -216,8 +211,7 @@ def provenance_csv_analysis(in_folder, fig_folder): def get_provenance_for_core(pr, x, y, p): structured_prov = {} columns_to_get = ['pop', 'label', 'min_atom', 'max_atom', 'no_atoms', - 'fixed_sdram', 'sdram_per_timestep', - 'cpu_cycles', 'dtcm'] # add more as needed + 'fixed_sdram', 'sdram_per_timestep'] # add more as needed for column_to_get in columns_to_get: query = """ From 31d66709aa15fb3afc8f92cc9117f2fba5f9af68 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Thu, 25 Aug 2022 09:50:14 +0100 Subject: [PATCH 08/13] Update to get file path from data view --- spinncer/provenance_analysis.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index 6bf9770..1749b2b 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -6,10 +6,10 @@ from numpy.polynomial.polynomial import Polynomial import traceback -from spinn_front_end_common.utilities.globals_variables import ( - provenance_file_path) from spinn_front_end_common.interface.provenance import ProvenanceReader +from spynnaker.pyNN.data import SpynnakerDataView + def extract_per_pop_placements(df, pops): placement_results = {} @@ -114,7 +114,8 @@ def save_provenance_to_file_from_database(in_file, simulator): # can we get router_provenance from the database? # placements is 0... so is this router(0, 0)? pr = ProvenanceReader(os.path.join( - provenance_file_path(), "provenance.sqlite3")) + SpynnakerDataView().get_provenance_dir_path(), + "provenance.sqlite3")) cores_list = pr.get_cores_with_provenance() From 59631edd68cfed29a19e6b373e117a0623021d63 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Thu, 25 Aug 2022 09:50:58 +0100 Subject: [PATCH 09/13] Update to use splitters on all non-SpikeSourcePoisson populations --- spinncer/cerebellum.py | 23 +++++++++++++++++++++++ spinncer/cerebellum_experiment.py | 3 +++ spinncer/single_cell_experiment.py | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/spinncer/cerebellum.py b/spinncer/cerebellum.py index 80e060a..b6a3a18 100644 --- a/spinncer/cerebellum.py +++ b/spinncer/cerebellum.py @@ -16,6 +16,9 @@ import numpy as np import h5py +from spynnaker.pyNN.extra_algorithms.splitter_components import ( + SplitterAbstractPopulationVertexNeuronsSynapses) + from spinncer.analysis_common import get_plot_order from spinncer.circuit import Circuit from spinncer.utilities.constants import * @@ -45,6 +48,9 @@ def __init__(self, sim, connectivity, stimulus_information, reporting=True, neuron_model="IF_cond_exp", force_number_of_neurons=None, input_spikes=None, rb_left_shifts=None, + use_split_model=False, + n_synapse_cores=1, + n_delay_slots=64, no_loops=3, round_input_spike_times=None, id_remap=None, @@ -78,6 +84,11 @@ def __init__(self, sim, connectivity, stimulus_information, reporting=True, self.id_remap = id_remap self.r_mem = r_mem + # Values for splitters + self.use_split_model = use_split_model + self.n_synapse_cores = n_synapse_cores + self.n_delay_slots = n_delay_slots + self.expected_max_spikes = expected_max_spikes self.implicit_shift = implicit_shift self.ensure_weight_is_representable = ensure_weight_is_representable @@ -475,6 +486,18 @@ def build_populations(self, positions): elif cell_model == "if_cond_alpha": cell_model = self.sim.IF_cond_alpha + # Add splitters everywhere except for SSP populations + if self.use_split_model: + if cell_name in ["granule", "golgi", "stellate", "basket", + "purkinjie", "dcn"]: + print("Cell {} using split synapse neuron model with {} " + "synapse cores and {} delay slots".format( + cell_name, self.n_synapse_cores, + self.n_delay_slots)) + additional_params["splitter"] = \ + SplitterAbstractPopulationVertexNeuronsSynapses( + self.n_synapse_cores, self.n_delay_slots, False) + # Adding the population to the network try: self.populations[cell_name] = self.sim.Population( diff --git a/spinncer/cerebellum_experiment.py b/spinncer/cerebellum_experiment.py index 5e7294b..bcd10ba 100644 --- a/spinncer/cerebellum_experiment.py +++ b/spinncer/cerebellum_experiment.py @@ -147,6 +147,9 @@ neuron_model=args.neuron_model, input_spikes=input_spikes, rb_left_shifts=canonical_rbls, + use_split_model=True, + n_synapse_cores=1, + n_delay_slots=64, no_loops=args.loops_grc, round_input_spike_times=round_spike_times, id_remap=args.id_remap, diff --git a/spinncer/single_cell_experiment.py b/spinncer/single_cell_experiment.py index 13204ed..acff06b 100644 --- a/spinncer/single_cell_experiment.py +++ b/spinncer/single_cell_experiment.py @@ -88,7 +88,7 @@ weight_scaling=args.weight_scaling, neuron_model=args.neuron_model, input_spikes=input_spikes, - rb_left_shifts=args.rb_left_shifts + rb_left_shifts=args.rb_left_shifts, ) if args.generate_conversion_constants: From dc6ff737c37ddbd1f1152ebadb493aba542c7a6d Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 31 Aug 2022 13:46:35 +0100 Subject: [PATCH 10/13] Modifications to provenance and interface for split model --- spinncer/cerebellum.py | 6 +++--- spinncer/cerebellum_experiment.py | 11 ++++++----- spinncer/provenance_analysis.py | 15 ++++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/spinncer/cerebellum.py b/spinncer/cerebellum.py index b6a3a18..0b430ff 100644 --- a/spinncer/cerebellum.py +++ b/spinncer/cerebellum.py @@ -490,9 +490,9 @@ def build_populations(self, positions): if self.use_split_model: if cell_name in ["granule", "golgi", "stellate", "basket", "purkinjie", "dcn"]: - print("Cell {} using split synapse neuron model with {} " - "synapse cores and {} delay slots".format( - cell_name, self.n_synapse_cores, + print("Cell {} model {} using split synapse neuron model " + "with {} synapse cores and {} delay slots".format( + cell_name, cell_model, self.n_synapse_cores, self.n_delay_slots)) additional_params["splitter"] = \ SplitterAbstractPopulationVertexNeuronsSynapses( diff --git a/spinncer/cerebellum_experiment.py b/spinncer/cerebellum_experiment.py index bcd10ba..a937ec6 100644 --- a/spinncer/cerebellum_experiment.py +++ b/spinncer/cerebellum_experiment.py @@ -28,7 +28,6 @@ import pylab as plt import os import traceback -from spinn_front_end_common.utilities.globals_variables import get_simulator from spinncer.provenance_analysis import save_provenance_to_file_from_database # Record SCRIPT start time (wall clock) @@ -135,6 +134,8 @@ expected_max_spikes = EXPECTED_MAX_SPIKES_200 canonical_rbls = RMEM_RBLS if args.r_mem else VANILLA_RBLS print("Canonical ring buffer left shifts:", canonical_rbls) +use_split_model = True +print("use_split_model is ", use_split_model) # Instantiate a Cerebellum cerebellum_circuit = Cerebellum( @@ -147,7 +148,7 @@ neuron_model=args.neuron_model, input_spikes=input_spikes, rb_left_shifts=canonical_rbls, - use_split_model=True, + use_split_model=use_split_model, n_synapse_cores=1, n_delay_slots=64, no_loops=args.loops_grc, @@ -235,8 +236,8 @@ recorded_spikes = {} other_recordings = {} -# Store simulator and run -simulator = get_simulator() +# Store simulator name and run +sim_name = sim.name # Record simulation start time (wall clock) sim_start_time = plt.datetime.datetime.now() @@ -318,7 +319,7 @@ # Get the provenance from the simulator's database structured_provenance_filename = "structured_provenance.csv" save_provenance_to_file_from_database( - structured_provenance_filename, simulator) + structured_provenance_filename, sim_name) # Analysis time! spike_analysis(results_file=results_file, fig_folder=args.figures_dir, diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index 1749b2b..57cfa50 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -61,7 +61,7 @@ def extract_per_pop_info(df, type_of_prov, pops, report=False): return pop_results -def save_provenance_to_file_from_database(in_file, simulator): +def save_provenance_to_file_from_database(in_file, sim_name): # Here we need to get the provenance from the database and put it in # the specified file @@ -102,13 +102,14 @@ def save_provenance_to_file_from_database(in_file, simulator): if provenance_filename: # Produce metadata from the simulator info - metadata['name'] = simulator.name - metadata['no_machine_time_steps'] = simulator.no_machine_time_steps - metadata['machine_time_step'] = simulator.machine_time_step + metadata['name'] = sim_name + metadata['no_machine_time_steps'] = \ + SpynnakerDataView.get_max_run_time_steps() + metadata['machine_time_step'] = \ + SpynnakerDataView.get_simulation_time_step_ms() # metadata['config'] = simulator.config - metadata['machine'] = simulator.machine - metadata['structured_provenance_filename'] = \ - simulator.structured_provenance_filename + metadata['machine'] = SpynnakerDataView.get_machine() + metadata['structured_provenance_filename'] = in_file # how do we loop over all the placements in the database at this point? # can we get router_provenance from the database? From 4148d83aafc14bbaad1cd8afa10aab233ffbdd4c Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Tue, 17 Jan 2023 12:19:00 +0000 Subject: [PATCH 11/13] Missing comma --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cb0d1fa..e316713 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ "numpy; python_version >= '3.8'", "scipy >= 0.16.0, < 1.6; python_version == '3.6'", "scipy >= 0.16.0, < 1.8; python_version == '3.7'", - "scipy >= 0.16.0; python_version >= '3.8'" + "scipy >= 0.16.0; python_version >= '3.8'", "brian2", "neo==0.7.1", "pynn==0.9.5", From 8fc2308310ba84f95749fcfbe5eb184ed7bda8f0 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Mon, 6 Mar 2023 14:24:31 +0000 Subject: [PATCH 12/13] Update to match database changes in the toolchain --- spinncer/provenance_analysis.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spinncer/provenance_analysis.py b/spinncer/provenance_analysis.py index 57cfa50..5c61f50 100644 --- a/spinncer/provenance_analysis.py +++ b/spinncer/provenance_analysis.py @@ -111,12 +111,9 @@ def save_provenance_to_file_from_database(in_file, sim_name): metadata['machine'] = SpynnakerDataView.get_machine() metadata['structured_provenance_filename'] = in_file - # how do we loop over all the placements in the database at this point? - # can we get router_provenance from the database? - # placements is 0... so is this router(0, 0)? pr = ProvenanceReader(os.path.join( - SpynnakerDataView().get_provenance_dir_path(), - "provenance.sqlite3")) + SpynnakerDataView().get_run_dir_path(), + "data.sqlite3")) cores_list = pr.get_cores_with_provenance() @@ -218,7 +215,7 @@ def get_provenance_for_core(pr, x, y, p): for column_to_get in columns_to_get: query = """ SELECT the_value - FROM core_provenance + FROM core_provenance_view WHERE x = ? AND y = ? AND p = ? AND description = ? """ # result = pr.run_query(query, [x, y, p, column_to_get]) @@ -233,7 +230,7 @@ def get_provenance_for_core(pr, x, y, p): def get_core_provenance_value(pr, x, y, p, description): query = """ SELECT the_value - FROM core_provenance + FROM core_provenance_view WHERE x = ? AND y = ? AND p = ? AND description = ? """ return pr.run_query(query, [x, y, p, description]) From 346b9ba686f1b54aea2db721e8538e59f2a86132 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Fri, 29 Sep 2023 08:45:40 +0100 Subject: [PATCH 13/13] Add cfg file (and don't ignore it) --- .gitignore | 3 +-- spinncer/spynnaker.cfg | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 spinncer/spynnaker.cfg diff --git a/.gitignore b/.gitignore index 2cd4aa2..248f617 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ *reports/ __pycache__/ .idea/ -spynnaker.cfg *.egg-info *.npz -*.out \ No newline at end of file +*.out diff --git a/spinncer/spynnaker.cfg b/spinncer/spynnaker.cfg new file mode 100644 index 0000000..d09bd77 --- /dev/null +++ b/spinncer/spynnaker.cfg @@ -0,0 +1,11 @@ +[Machine] +timeScaleFactor = 1000 + +[Simulation] +incoming_spike_buffer_size = 1024 + +[Mode] +violate_1ms_wall_clock_restriction = True + +#[Java] +#use_java = True