SpiNNFrontEndCommon 7.3.1
Common support code for user-facing front end systems.
Loading...
Searching...
No Matches
simulation.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
26#ifndef _SIMULATION_H_
27#define _SIMULATION_H_
28
29#include <stdbool.h>
30#include "common-typedefs.h"
31#include <spin1_api.h>
32
35#define MAX_DMA_CALLBACK_TAG 16
36
40 uint32_t application_magic_number;
41 uint32_t timer_period;
42 uint32_t control_sdp_port;
43 uint32_t num_timing_detail_words;
44};
45
48 uint32_t transmission_event_overflow;
49 uint32_t callback_queue_overloads;
50 uint32_t dma_queue_overloads;
51 uint32_t user_queue_overloads;
52 uint32_t timer_tic_has_overrun;
53 uint32_t max_num_timer_tic_overrun;
54 uint32_t provenance_data_elements[];
55};
56
73
75typedef void (*prov_callback_t)(address_t);
76
78typedef void (*resume_callback_t)(void);
79
82typedef void (*exit_callback_t)(void);
83
86
113 address_t address, uint32_t expected_application_magic_number,
114 uint32_t* timer_period, uint32_t *simulation_ticks_pointer,
115 uint32_t *infinite_run_pointer, uint32_t *time_pointer,
116 int sdp_packet_callback_priority, int dma_transfer_complete_priority);
117
143 address_t address, uint32_t expected_application_magic_number,
144 uint32_t *simulation_steps_pointer, uint32_t *infinite_steps_pointer,
145 uint32_t *step_pointer, int sdp_packet_callback_priority,
146 int dma_transfer_complete_priority) {
147 // Use the normal simulation initialise, passing in matching parameters
148 uint32_t unused_timer_period;
149 return simulation_initialise(address, expected_application_magic_number,
150 &unused_timer_period, simulation_steps_pointer, infinite_steps_pointer,
151 step_pointer, sdp_packet_callback_priority,
152 dma_transfer_complete_priority);
153}
154
159void simulation_set_provenance_data_address(address_t provenance_data_address);
160
166 prov_callback_t provenance_function, address_t provenance_data_address);
167
173
178
186
189void simulation_exit(void);
190
192void simulation_run(void);
193
196void simulation_ready_to_read(void);
197
205 uint sdp_port, callback_t sdp_callback);
206
209void simulation_sdp_callback_off(uint sdp_port);
210
215bool simulation_dma_transfer_done_callback_on(uint tag, callback_t callback);
216
220
226void simulation_set_uses_timer(bool sim_uses_timer);
227
233void simulation_set_sync_steps(uint32_t n_steps);
234
238bool simulation_is_finished(void);
239
240#endif // _SIMULATION_H_
Data type definitions for SpiNNaker Neuron-modelling.
uint32_t * address_t
A generic pointer to a word.
static callback_t sdp_callback[NUM_SDP_PORTS]
the list of SDP callbacks for ports
Definition simulation.c:61
void simulation_handle_pause_resume(resume_callback_t callback)
cleans up the house keeping, falls into a sync state and handles the resetting up of states as requir...
Definition simulation.c:113
bool simulation_sdp_callback_on(uint sdp_port, callback_t sdp_callback)
Registers an additional SDP callback on a given SDP port. This is required when using simulation_regi...
Definition simulation.c:323
void simulation_set_provenance_function(prov_callback_t provenance_function, address_t provenance_data_address)
Set an additional callback function to store extra provenance data.
Definition simulation.c:418
void simulation_set_provenance_data_address(address_t provenance_data_address)
Set the address of the data region where provenance data is to be stored.
Definition simulation.c:414
void(* resume_callback_t)(void)
the definition of the callback used by pause and resume
Definition simulation.h:78
void(* exit_callback_t)(void)
Definition simulation.h:82
void simulation_exit(void)
a helper method for people not using the auto pause and resume functionality
Definition simulation.c:127
void simulation_set_start_function(start_callback_t start_function)
Set an additional function to call before starting the binary.
Definition simulation.c:429
void simulation_set_uses_timer(bool sim_uses_timer)
set whether the simulation uses the timer. By default it will be assumed that simulations use the tim...
Definition simulation.c:433
resume_callback_t start_callback_t
the definition of the callback used to call a function once at start
Definition simulation.h:85
void simulation_set_exit_function(exit_callback_t exit_function)
Set an additional function to call before exiting the binary when running without a fixed duration of...
Definition simulation.c:425
bool simulation_is_finished(void)
determine if the simulation is finished. Will also pause the simulation for resynchronisation if requ...
Definition simulation.c:444
void(* prov_callback_t)(address_t)
the definition of the callback used by provenance data functions
Definition simulation.h:75
bool simulation_dma_transfer_done_callback_on(uint tag, callback_t callback)
registers a DMA transfer callback to the simulation system
Definition simulation.c:346
void simulation_ready_to_read(void)
Indicates that all data has been written and the core is going idle, so any data can now be read.
Definition simulation.c:131
void simulation_sdp_callback_off(uint sdp_port)
disables SDP callbacks on the given port
Definition simulation.c:333
void simulation_set_sync_steps(uint32_t n_steps)
sets the simulation to enter a synchronisation barrier repeatedly during the simulation....
Definition simulation.c:437
static bool simulation_steps_initialise(address_t address, uint32_t expected_application_magic_number, uint32_t *simulation_steps_pointer, uint32_t *infinite_steps_pointer, uint32_t *step_pointer, int sdp_packet_callback_priority, int dma_transfer_complete_priority)
initialises the simulation interface for step-based simulation, which involves:
Definition simulation.h:142
void simulation_dma_transfer_done_callback_off(uint tag)
turns off a registered callback for a given DMA transfer done tag
Definition simulation.c:366
simulation_commands
the commands that the simulation control protocol may send
Definition simulation.h:58
@ CMD_STOP
Asks the simulation loop to stop as soon as possible.
Definition simulation.h:60
@ CMD_PAUSE
Definition simulation.h:69
@ CMD_GET_TIME
Get the current simulation time.
Definition simulation.h:71
@ PROVENANCE_DATA_GATHERING
Asks the application to gather provenance data.
Definition simulation.h:64
@ CMD_RUNTIME
Tells the simulation loop how long to run for.
Definition simulation.h:62
@ IOBUF_CLEAR
Clears the IOBUF.
Definition simulation.h:66
void simulation_run(void)
Starts the simulation running, returning when it is complete,.
Definition simulation.c:108
bool simulation_initialise(address_t address, uint32_t expected_application_magic_number, uint32_t *timer_period, uint32_t *simulation_ticks_pointer, uint32_t *infinite_run_pointer, uint32_t *time_pointer, int sdp_packet_callback_priority, int dma_transfer_complete_priority)
initialises the simulation interface which involves:
Definition simulation.c:370
the position and human readable terms for each element from the region containing the timing details.
Definition simulation.h:39
elements that are always grabbed for provenance if possible when requested
Definition simulation.h:47
unsigned int uint