SpiNNFrontEndCommon 7.3.1
Common support code for user-facing front end systems.
Loading...
Searching...
No Matches
simple_compressor.c
Go to the documentation of this file.
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
30#include <spin1_api.h>
31#include <debug.h>
32#include <malloc_extras.h>
34#include "rt_single.h"
35
39void compress_start(UNUSED uint unused0, UNUSED uint unused1) {
40 log_info("Starting on chip router compressor");
41
42 // Prepare to minimise the routing tables
43 log_debug("looking for header using tag %u app_id %u", 1, sark_app_id());
44 header_t *header = (header_t *) sark_tag_ptr(1, sark_app_id());
45 log_debug("reading data from 0x%08x", (uint32_t) header);
46 print_header(header);
47
48 // set the flag to something non-useful
49 sark.vcpu->user0 = 20;
50
51 // Load the routing table
52 log_debug("start reading table");
53 read_table(header);
54 log_debug("finished reading table");
55
56 // Store intermediate sizes for later reporting (if we fail to minimise)
57 uint32_t size_original = routing_table_get_n_entries();
58
59 // Currently not used here but used by the bitfeild stuff
60 bool failed_by_malloc = false;
61 // Currently not used here but used by the bitfeild stuff
62 bool stop_compressing = false;
64 &failed_by_malloc, &stop_compressing)) {
65 // report size to the host for provenance aspects
66 log_info("Compressed the router table from %d to %d entries",
67 size_original, routing_table_get_n_entries());
68 } else {
69 log_info("Exiting as compressor reported failure");
70 // set the failed flag and exit
72
73 }
74 // Try to load the routing table
75 log_debug("try loading tables");
76 if (load_routing_table(header->app_id)) {
77 log_info("completed router compressor");
79 } else {
80 // Otherwise give up and exit with an error
81 log_error("Failed to minimise routing table to fit %u entries. "
82 "(Original table: %u after compression: %u).",
83 rtr_alloc_max(), size_original,
85
86 // Free the block of SDRAM used to load the routing table.
87 log_debug("free sdram blocks which held router tables");
88 FREE((void *) header);
89
90 // set the failed flag and exit
92 }
93}
94
97bool standalone(void) {
98 return true;
99}
100
102void c_main(void) {
103 log_debug("%u bytes of free DTCM", sark_heap_max(sark.heap, 0));
105
106 // kick-start the process
108
109 // go
111}
SpiNNaker routing table minimisation.
bool run_compressor(int compress_as_much_as_possible, bool *failed_by_malloc, volatile bool *stop_compressing)
The callback for setting off the router compressor.
Definition compressor.h:46
SpiNNaker debug header file.
void log_error(const char *message,...)
This function logs errors. Errors usually indicate a serious fault in the program,...
void log_debug(const char *message,...)
This function logs debugging messages. This level of message is normally not printed except when the ...
void log_info(const char *message,...)
This function logs informational messages. This is the lowest level of message normally printed.
Support for adding debugging information to dynamic allocation.
@ EXITED_CLEANLY
Everything is fine.
@ EXIT_FAIL
We went wrong but we dont want to RTE.
void malloc_extras_terminate(uint result_code)
Stops execution with a result code.
#define FREE
An easily-insertable name for the memory free.
void malloc_extras_turn_off_print(void)
Turn off printing.
int routing_table_get_n_entries(void)
Get the number of entries in the routing table.
Definition rt_single.h:102
SpiNNaker routing table minimisation.
uint32_t app_id
Definition rt_single.h:89
static void read_table(header_t *header)
Read a new copy of the routing table from SDRAM.
Definition rt_single.h:125
void print_header(header_t *header)
Print the header object for debug purposes.
Definition rt_single.h:116
uint32_t compress_as_much_as_possible
Definition rt_single.h:93
bool load_routing_table(uint32_t app_id)
Load a routing table to the router.
Definition rt_single.h:144
The header of the routing table information in the input data block.
Definition rt_single.h:85
heap_t * heap
uint sark_app_id(void)
uint user0
SYNC_NOWAIT
sark_data_t sark
uint sark_heap_max(heap_t *heap, uint flag)
void * sark_tag_ptr(uint tag, uint app_id)
vcpu_t * vcpu
uint rtr_alloc_max(void)
void compress_start(uint unused0, uint unused1)
The callback for setting off the router compressor.
void c_main(void)
the main entrance.
bool standalone(void)
Whether this is a standalone compressor.
uint spin1_schedule_callback(callback_t cback, uint arg0, uint arg1, uint priority)
uint spin1_start(sync_bool sync)
unsigned int uint