def nightly_calib_path() -> Path: """ Find path for calibration automatically from environment. Set by Slurm when allocating resources. """ # TODO: opening a connection is architecturally wrong, cf. issue #3868 with hxcomm.ManagedConnection() as connection: identifier = connection.get_unique_identifier() path = f"/wang/data/calibration/hicann-dls-sr-hx/{identifier}/stable/"\ "latest/spiking_cocolist.bin" return Path(path)
def get_nightly_calibration(filename='spiking_cocolist.bin' if in_collaboratory() else 'spiking_cocolist.pbin'): ''' Get the nightly deployed calibration. If the code is executed in the EBrains in the collabatory the calibration is downloaded otherwise it is expected to be present locally. ''' if in_collaboratory(): with hxcomm.ManagedConnection() as connection: identifier = connection.get_unique_identifier() # download calibration file folder = "last-binary" if in_collaboratory() else "latest" download_url = "https://openproject.bioai.eu/data_calibration/" \ f"hicann-dls-sr-hx/{identifier}/stable/{folder}" \ f"/{filename}" contents = urllib.request.urlopen(download_url).read() path_to_calib = filename with open(path_to_calib, 'wb') as f: f.write(contents) else: calib_path = pynn.helper.nightly_calib_path().parent path_to_calib = calib_path.joinpath(filename) coco = pynn.helper.coco_from_file(path_to_calib) # save calibration data in variables: neuron_coco = pynn.helper.filter_atomic_neuron(coco) general_coco = pynn.helper.filter_non_atomic_neuron(coco) return neuron_coco, general_coco
def test_connection(cls): with hxcomm.ManagedConnection() as connection: sta.run(connection, sta.PlaybackProgramBuilder().done())
def test_digital_init(cls): with hxcomm.ManagedConnection() as connection: builder, _ = sta.generate(sta.DigitalInit()) program = builder.done() sta.run(connection, program)
def run(self, runtime: Optional[float]): """ Performs a hardware run for `runtime` milliseconds. If runtime is `None`, we only perform preparatory steps. """ if runtime is None: self.log.INFO("User requested 'None' runtime: " + "no hardware run performed.") else: self.t += runtime self.running = True # generate chip initialization init_builder, _ = sta.ExperimentInit().generate() # injected configuration pre non realtime tmpdumper = sta.DumperDone() tmpdumper.values = list(self.injected_config.pre_non_realtime.items()) config = grenade.convert_to_chip(tmpdumper) builder1 = sta.convert_to_builder(tmpdumper) # generate common static configuration builder1, config = self._configure_common(builder1, config) builder1, config = self._configure_routing(builder1, config) # generate network graph network_graph = self._generate_network_graph() # configure populations and recorders config = self._configure_recorders_populations(config) # injected configuration post non realtime tmpdumper = sta.DumperDone() tmpdumper.values = list(self.injected_config.post_non_realtime.items()) pre_realtime = sta.convert_to_builder(tmpdumper) # injected configuration pre realtime tmpdumper = sta.DumperDone() tmpdumper.values = list(self.injected_config.pre_realtime.items()) pre_realtime.merge_back(sta.convert_to_builder(tmpdumper)) # injected configuration post realtime tmpdumper = sta.DumperDone() tmpdumper.values = list(self.injected_config.post_realtime.items()) post_realtime = sta.convert_to_builder(tmpdumper) playback_hooks = grenade.ExecutionInstancePlaybackHooks( builder1, pre_realtime, post_realtime) if runtime is None: return # wait 20000 us for capmem voltages to stabilize initial_wait = 20000 # us builder1.write(halco.TimerOnDLS(), hal.Timer()) builder1.block_until( halco.TimerOnDLS(), int(initial_wait * int(hal.Timer.Value.fpga_clock_cycles_per_us))) builder1.block_until(halco.BarrierOnFPGA(), hal.Barrier()) # generate external spike trains inputs = self._generate_inputs(network_graph) inputs.runtime = \ [int(runtime * int(hal.Timer.Value.fpga_clock_cycles_per_us) * 1000)] if self.conn_manager is None: self.conn_manager = hxcomm.ManagedConnection() assert self.conn is None self.conn = self.conn_manager.__enter__() try: sta.run(self.conn, init_builder.done()) outputs = grenade.run(self.conn, config, network_graph, inputs, playback_hooks) except RuntimeError: # perform post-mortem read out of status self._perform_post_fail_analysis(self.conn) raise # make list 'spikes' of tupel (neuron id, spike time) self.spikes = self._get_spikes(network_graph, outputs) # make two list for madc samples: times, madc_samples self.times, self.madc_samples = self._get_v(network_graph, outputs)