sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
c_main_common.h
1/*
2 * Copyright (c) 2017 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
17#include <stdbool.h>
18#include <stdint.h>
19
20#include <debug.h>
21#include <data_specification.h>
22#include <simulation.h>
23#include <profiler.h>
24#include <recording.h>
25
26/* validates that the model being compiled does indeed contain a application
27 * magic number*/
28#ifndef APPLICATION_NAME_HASH
29#error APPLICATION_NAME_HASH was undefined. Make sure you define this\
30 constant
31#endif
32
36 uint32_t system;
38 uint32_t provenance;
40 uint32_t profiler;
42 uint32_t recording;
43};
44
48 uint32_t sdp;
50 uint32_t dma;
52 uint32_t timer;
53};
54
76static inline bool initialise_common_regions(
77 uint32_t *timer_period, uint32_t *simulation_ticks,
78 uint32_t *infinite_run, uint32_t *time, uint32_t *recording_flags,
79 prov_callback_t store_provenance_function, callback_t timer_callback,
80 struct common_regions regions, struct common_priorities priorities,
81 data_specification_metadata_t **ds_regions) {
82
83 // Get the address this core's DTCM data starts at from SRAM
85
86 // Read the header
87 if (!data_specification_read_header(*ds_regions)) {
88 return false;
89 }
90
91 // Get the timing details and set up the simulation interface
93 data_specification_get_region(regions.system, *ds_regions),
94 APPLICATION_NAME_HASH, timer_period, simulation_ticks,
95 infinite_run, time, priorities.sdp, priorities.dma)) {
96 return false;
97 }
99 store_provenance_function,
100 data_specification_get_region(regions.provenance, *ds_regions));
101
102 // Setup profiler
103 profiler_init(data_specification_get_region(regions.profiler, *ds_regions));
104
105 // Setup recording
106 void *rec_addr = data_specification_get_region(regions.recording, *ds_regions);
107 if (!recording_initialize(&rec_addr, recording_flags)) {
108 return false;
109 }
110
111 if (timer_callback) {
112
113 // Set up the timer tick callback (others are handled elsewhere)
114 spin1_callback_on(TIMER_TICK, timer_callback, priorities.timer);
115 }
116
117 return true;
118}
119
122static inline void common_pause(uint32_t recording_flags) {
123
124 // Finalise any recordings that are in progress
125 if (recording_flags > 0) {
127 }
128
130}
data_specification_metadata_t * data_specification_get_data_address(void)
bool data_specification_read_header(data_specification_metadata_t *ds_regions)
static uint32_t timer_period
Used for configuring the timer hardware.
void profiler_init(uint32_t *data_region)
void profiler_finalise(void)
bool recording_initialize(void **recording_data_address, uint32_t *recording_flags)
void recording_finalise(void)
void simulation_set_provenance_function(prov_callback_t provenance_function, address_t provenance_data_address)
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)
void spin1_callback_on(uint event_id, callback_t cback, int priority)
The callback priorities used by all simulation cores.
uint32_t sdp
The SDP callback priority.
uint32_t dma
The DMA callback priority.
uint32_t timer
The timer callback priority.
The identifiers of the regions used by all simulation cores.
uint32_t provenance
Where provenance data will be stored.
uint32_t recording
Where recording metadata will be read and stored.
uint32_t profiler
Where profile data will be read and stored.
uint32_t system
Data for general simulation setup.