SpiNNFrontEndCommon 7.1.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
68
70typedef void (*prov_callback_t)(address_t);
71
73typedef void (*resume_callback_t)(void);
74
77typedef void (*exit_callback_t)(void);
78
81
108 address_t address, uint32_t expected_application_magic_number,
109 uint32_t* timer_period, uint32_t *simulation_ticks_pointer,
110 uint32_t *infinite_run_pointer, uint32_t *time_pointer,
111 int sdp_packet_callback_priority, int dma_transfer_complete_priority);
112
138 address_t address, uint32_t expected_application_magic_number,
139 uint32_t *simulation_steps_pointer, uint32_t *infinite_steps_pointer,
140 uint32_t *step_pointer, int sdp_packet_callback_priority,
141 int dma_transfer_complete_priority) {
142 // Use the normal simulation initialise, passing in matching parameters
143 uint32_t unused_timer_period;
144 return simulation_initialise(address, expected_application_magic_number,
145 &unused_timer_period, simulation_steps_pointer, infinite_steps_pointer,
146 step_pointer, sdp_packet_callback_priority,
147 dma_transfer_complete_priority);
148}
149
154void simulation_set_provenance_data_address(address_t provenance_data_address);
155
161 prov_callback_t provenance_function, address_t provenance_data_address);
162
168
173
181
184void simulation_exit(void);
185
187void simulation_run(void);
188
191void simulation_ready_to_read(void);
192
200 uint sdp_port, callback_t sdp_callback);
201
204void simulation_sdp_callback_off(uint sdp_port);
205
210bool simulation_dma_transfer_done_callback_on(uint tag, callback_t callback);
211
215
221void simulation_set_uses_timer(bool sim_uses_timer);
222
228void simulation_set_sync_steps(uint32_t n_steps);
229
233bool simulation_is_finished(void);
234
235#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:110
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:296
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:391
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:387
void(* resume_callback_t)(void)
the definition of the callback used by pause and resume
Definition simulation.h:73
void(* exit_callback_t)(void)
Definition simulation.h:77
void simulation_exit(void)
a helper method for people not using the auto pause and resume functionality
Definition simulation.c:124
void simulation_set_start_function(start_callback_t start_function)
Set an additional function to call before starting the binary.
Definition simulation.c:402
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:406
resume_callback_t start_callback_t
the definition of the callback used to call a function once at start
Definition simulation.h:80
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:398
bool simulation_is_finished(void)
determine if the simulation is finished. Will also pause the simulation for resynchronisation if requ...
Definition simulation.c:417
void(* prov_callback_t)(address_t)
the definition of the callback used by provenance data functions
Definition simulation.h:70
bool simulation_dma_transfer_done_callback_on(uint tag, callback_t callback)
registers a DMA transfer callback to the simulation system
Definition simulation.c:319
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:128
void simulation_sdp_callback_off(uint sdp_port)
disables SDP callbacks on the given port
Definition simulation.c:306
void simulation_set_sync_steps(uint32_t n_steps)
sets the simulation to enter a synchronisation barrier repeatedly during the simulation....
Definition simulation.c:410
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:137
void simulation_dma_transfer_done_callback_off(uint tag)
turns off a registered callback for a given DMA transfer done tag
Definition simulation.c:339
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
@ 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:105
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:343
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