spinnaker_tools 3.4.0
SpiNNaker API, sark, sc&mp, bmp firmware and build tools
Loading...
Searching...
No Matches
Macros | Functions | Variables
scamp-3.c File Reference

SC&MP - Spinnaker Control & Monitor Program. More...

#include "sark.h"
#include "scamp.h"
#include "spinn_net.h"
#include "spinn_phy.h"
#include "spinn_regs.h"
#include <string.h>

Macros

#define LIVENESS_FLASH_INTERVAL   256
 
#define LIVENESS_FLASH_SPACING   5
 
#define LOAD_FRAC_BITS   1
 
#define PWM_BITS   4
 
#define MINIMUM_PINGS_RECEIVED   60
 The minimum number of packets we expect to receive over P2P or MC.
 
#define P2PB_DIVISOR   8192
 Division to apply to n_chips to work out the repeats.
 
#define TX_NOT_FULL_MASK   0x10000000
 Mask to recognise the Comms Controller "not full" flag.
 

Functions

void pkt_mc_int (void)
 Interrupt handlers for multicast.
 
void test_mc_int (void)
 
void send_nn_netinit (uint netinit_phase)
 
void p2pc_reth_nn_send (uint, uint)
 Transmit our address back to an Ethernet.
 
void iptag_timer (void)
 Update timeouts in IPTags.
 
uint iptag_new (void)
 Find a free IPTag.
 
uint transient_tag (uchar *ip, uchar *mac, uint port, uint timeout)
 Get and initialise a transient IPTag, used for later handling replies to a request.
 
void queue_init (void)
 Initialise the packet transmission queue.
 
void proc_byte_set (uint a1, uint a2)
 Write a byte at a location.
 
void proc_word_set (uint a1, uint a2)
 Write a word at a location.
 
void proc_route_msg (uint arg1, uint srce_ip)
 Main message dispatcher.
 
void msg_queue_insert (sdp_msg_t *msg, uint srce_ip)
 Adds a message to SCAMP's master message queue, to be processed by proc_route_msg().
 
uint pkt_tx (uint tcr, uint data, uint key)
 Add a SpiNNaker message to the queue of messages to send.
 
static uint wait_for_cc (void)
 
uint pkt_tx_wait (uint tcr, uint data, uint key)
 
static void timer1_init (uint count)
 Initialise the primary timer to count down.
 
void eth_discard (void)
 Release the currently received Ethernet packet's buffer.
 
void udp_pkt (uchar *rx_pkt, uint rx_len)
 Handle a received UDP packet.
 
void eth_receive (void)
 Receive and handle all pending ethernet packets.
 
void eth_send_msg (uint tag, sdp_msg_t *msg)
 Send an SDP message to the outside world via ethernet using an IPTag to say where to go.
 
uint shm_ping (uint dest)
 Ping an application core to see if it is alive.
 
uint shm_send_msg (uint dest, sdp_msg_t *msg)
 Send an SDP message to an application core.
 
void swap_sdp_hdr (sdp_msg_t *msg)
 Swap source and destination in an SDP message. This allows us to use a message (buffer) as its own reply.
 
void return_msg_err (sdp_msg_t *msg, uint rc, uint extra_size)
 Adds a result message to the main message queue.
 
void return_msg_ok (sdp_msg_t *msg)
 Adds an OK result message to the main message queue.
 
void assign_virt_cpu (uint phys_cpu)
 Build virtual/physical CPU maps.
 
void remap_phys_cores (uint phys_cores)
 Disables a specified core and recomputes the virtual core map accordingly.
 
uint ram_size (void *mem)
 Determine the size of RAM.
 
void get_board_info (void)
 Get board information from SROM.
 
void sv_init (void)
 Initialise the System Variables area.
 
void sdram_init (void)
 Initialise SDRAM (controller and critical pointers into it)
 
void random_init (void)
 Initialise the SARK PRNG.
 
void update_load (uint arg1, uint arg2)
 Update the 'load' variable with an estimate of the system's load.
 
void proc_1hz (uint a1, uint a2)
 Regular 1Hz timer callback, put on the event queue every second.
 
void soft_wdog (uint max)
 Software watchdog check.
 
uint n_addr (uint link)
 
uint opp_link (uint link)
 
void init_link_en_nn ()
 Initialise inter-chip link state bitmap.
 
static void send_link_checks_pp ()
 
static void send_link_checks_mc ()
 
static void final_link_checks ()
 
static void setup_link_checks ()
 Set up for link checking.
 
static void disable_unidirectional_links (void)
 Disable links that have been disabled by neighbours.
 
void netinit_start (void)
 Start the higher-level network initialisation process.
 
void compute_st (void)
 Sets up a broadcast MC route by constructing a spanning tree of the P2P routes constructed routing back to chip used to boot the machine (see p2p_root).
 
static uint netinit_biff_barrier ()
 
void proc_100hz (uint a1, uint a2)
 Regular 100Hz timer callback, put on the event queue every 10ms.
 
void proc_1khz (uint a1, uint a2)
 Regular 1kHz timer callback, put on the event queue every millisecond.
 
static uint pll_mult (uint freq)
 Get the PLL multiplier for a frequency.
 
void pll_init (void)
 Initialise PLLs.
 
void eth_setup (void)
 Set up the ethernet (if present)
 
void jtag_init (void)
 Initialise JTAG support.
 
void sark_config (void)
 Initialise SARK.
 
void delegate (void)
 Delegate acting as a monitor to another core.
 
void chk_bl_del (void)
 Check for problems in blacklist and delegate if necessary.
 
void c_main (void)
 Main entry point.
 
Board information flood fill
void send_nn_links (uint links_enabled)
 

Variables

uint num_cpus
 Number of operational CPUs.
 
uint ping_cpu = 1
 Which application CPU to ping next in soft_wdog()
 
uchar v2p_map [MAX_CPUS]
 Virtual-core-ID to physical-core-ID map.
 
uint p2p_addr = 0
 Our P2P address.
 
uint p2p_dims = 0
 Dimensions of the P2P-addressable area.
 
uint p2p_root = 0
 The address of the P2P root.
 
uint p2p_up = 0
 Whether the P2P system is operational or still needs to be initialised.
 
uint ltpc_timer
 Counter used to decide when to send an LTPC packet.
 
uint link_en = 0x3f
 Bitmap of enabled links.
 
srom_data_t srom
 Copy of SROM struct.
 
pkt_queue_t tx_pkt_queue
 Packet transmit queue.
 
uchar watchdog [20]
 Watchdog counters.
 
iptag_t tag_table [TAG_TABLE_SIZE]
 Table of all IPTags.
 
uint tag_tto = 9
 IPTag timeout (logarithmic)
 
enum netinit_phase_e netinit_phase
 The network initialisation process phase currently in progress.
 
enum ethinit_phase_e ethinit_phase
 The Ethernet initialisation process phase currently in progress.
 
volatile uint ticks_since_last_p2pc_new
 Number of 10ms ticks ellapsed since the last P2PC_NEW arrived.
 
volatile uint ticks_since_last_p2pc_dims
 Number of 10ms ticks ellapsed since the last P2PC_DIMS arrived.
 
ucharp2p_addr_table = NULL
 
volatile uchar load = 0
 The current system load.
 
volatile uint disp_load = 0 << LOAD_FRAC_BITS
 The actual, displayed load value (fixed point).
 
volatile uint do_sync = 1
 Whether to perform clock synchronization (on by default at start)
 
volatile uint mc_ping_count [NUM_LINKS]
 Reserved for performing MC and P2P pings.
 
volatile uint pp_ping_count [NUM_LINKS]
 Reserved for performing P2P pings.
 
uint opposite_link [NUM_LINKS]
 
uint ping_addr [NUM_LINKS]
 
static uint x
 The x coordinate of this chip.
 
static uint y
 The y coordinate of this chip.
 
static uint w
 The width of the machine.
 
static uint h
 The height of the machine.
 
static uint p2pb_repeats
 The count of p2pb repeats to go.
 
static uint p2pb_period
 The total time over which p2pb will be sent.
 
static uint n_biff_words
 Counter of how many more BIFF words need to be sent.
 
static uintnext_biff_word
 Pointer to the next BIFF word to send.
 
const signed char dx [6] = { 1, 1, 0, -1, -1, 0}
 X deltas, by link ID.
 
const signed char dy [6] = { 0, 1, 1, 0, -1, -1}
 Y deltas, by link ID.
 
static uint netinit_biff_tick_counter = 0
 
volatile uint neighbour_netinit_level [NUM_LINKS]
 neighbour over link netinit level
 
volatile uint neighbour_links_enabled [NUM_LINKS]
 neighbour over link links enabled
 
const uint rst_init []
 Reset vectors.
 
P2P Address Guess

During NETINIT_PHASE_P2P_ADDR, the current best guess of P2P address.

Note
this value may be negative and may be much larger than realistic machines as the first P2P address assigned may be the result of a packet taking a very spirally route.
volatile int p2p_addr_guess_x
 X coordinate of the current best guess of P2P address.
 
volatile int p2p_addr_guess_y
 Y coordinate of the current best guess of P2P address.
 
P2P Dimension Guess

During NETINIT_PHASE_P2P_DIMS, records the current best guess of the system's dimensions.

volatile int p2p_min_x
 Estimated minimum X size.
 
volatile int p2p_max_x
 Estimated maximum X size.
 
volatile int p2p_min_y
 Estimated minimum Y size.
 
volatile int p2p_max_y
 

Detailed Description

SC&MP - Spinnaker Control & Monitor Program.

Author
Steve Temple, APT Group, School of Computer Science

Macro Definition Documentation

◆ LIVENESS_FLASH_INTERVAL

#define LIVENESS_FLASH_INTERVAL   256

Interval between flashing the LEDs when displaying load to indicate chip liveness in 10ms units

◆ LIVENESS_FLASH_SPACING

#define LIVENESS_FLASH_SPACING   5

Spacing between flashing adjacent chips when indicating liveness in 10ms units

◆ LOAD_FRAC_BITS

#define LOAD_FRAC_BITS   1

The number of fractional bits to use for the internal representation of the load. The more bits, the longer the displayed load will take to catch up with the actual load.

◆ PWM_BITS

#define PWM_BITS   4

The number of bits to use for the PWM generator. The larger this is, the greater the resolution of the brightness but the more flicker-y it will look.

Function Documentation

◆ pkt_mc_int()

void pkt_mc_int ( void  )
extern

Interrupt handlers for multicast.

Interrupt handlers for multicast.

◆ p2pc_reth_nn_send()

void p2pc_reth_nn_send ( uint  eth,
uint  arg2 
)
extern

Transmit our address back to an Ethernet.

Parameters
ethThe Ethernet address to send to
arg2unused

◆ iptag_new()

uint iptag_new ( void  )

Find a free IPTag.

Returns
The ID of the IPTag, or TAG_NONE if all tags are in use

◆ transient_tag()

uint transient_tag ( uchar ip,
uchar mac,
uint  port,
uint  timeout 
)

Get and initialise a transient IPTag, used for later handling replies to a request.

Parameters
[in]ipIP address of the requesting host
[in]macMAC address that the ethernet packet came from
[in]portUDP port of the requesting host's socket
[in]timeoutlog2 of how long the tag should last for
Returns
The IPTag ID

◆ proc_byte_set()

void proc_byte_set ( uint  a1,
uint  a2 
)

Write a byte at a location.

Parameters
[in]a1The location to write
[in]a2The byte to write there

◆ proc_word_set()

void proc_word_set ( uint  a1,
uint  a2 
)

Write a word at a location.

Parameters
[in]a1The location to write
[in]a2The byte to write there

◆ proc_route_msg()

void proc_route_msg ( uint  arg1,
uint  srce_ip 
)

Main message dispatcher.

Parameters
[in]arg1SDP message. This function will free this message!
[in]srce_ipSource IP address for message (where known).

◆ msg_queue_insert()

void msg_queue_insert ( sdp_msg_t msg,
uint  srce_ip 
)

Adds a message to SCAMP's master message queue, to be processed by proc_route_msg().

Note
This silently drops messages if the queue is full.
Parameters
[in]msgThe message to dispatch. Transfers ownership of the message.
[in]srce_ipSource IP address (if meaningful).

◆ pkt_tx()

uint pkt_tx ( uint  tcr,
uint  data,
uint  key 
)

Add a SpiNNaker message to the queue of messages to send.

Parameters
[in]tcrControl word
[in]dataPayload word
[in]keyKey word
Returns
True if the packet was correctly enqueued

◆ timer1_init()

static void timer1_init ( uint  count)
static

Initialise the primary timer to count down.

Parameters
[in]countWhat value should be counted down from.

◆ eth_discard()

void eth_discard ( void  )

Release the currently received Ethernet packet's buffer.

After calling this, the received packet is unsafe to access!

◆ udp_pkt()

void udp_pkt ( uchar rx_pkt,
uint  rx_len 
)

Handle a received UDP packet.

Parameters
[in]rx_pktThe UDP packet, including the IP header. Note that this pointer is only half-word aligned!
[in]rx_lenThe length of the packet in rx_pkt

◆ eth_receive()

void eth_receive ( void  )

Receive and handle all pending ethernet packets.

Delegates the handling of received messages to:

◆ eth_send_msg()

void eth_send_msg ( uint  tag,
sdp_msg_t msg 
)

Send an SDP message to the outside world via ethernet using an IPTag to say where to go.

Should only be invoked on cores with an ethernet connection

Parameters
[in]tagThe tag, contains information about the message destination (IP address, UDP port, MAC address, etc.)
[in]msgThe SDP message to send

◆ shm_ping()

uint shm_ping ( uint  dest)

Ping an application core to see if it is alive.

Parameters
[in]destThe destination virtual core ID
Returns
a return code

◆ shm_send_msg()

uint shm_send_msg ( uint  dest,
sdp_msg_t msg 
)

Send an SDP message to an application core.

Parameters
[in]destThe destination virtual core ID
[in]msgThe message to send.
Returns
a return code

◆ swap_sdp_hdr()

void swap_sdp_hdr ( sdp_msg_t msg)

Swap source and destination in an SDP message. This allows us to use a message (buffer) as its own reply.

Parameters
[in,out]msgThe message to modify.

◆ return_msg_err()

void return_msg_err ( sdp_msg_t msg,
uint  rc,
uint  extra_size 
)

Adds a result message to the main message queue.

Parameters
[in]msgThe SCP message holding the reply. Ownership transferred by this call.
[in]rcThe return code.
[in]extra_sizeSize over and above error size

◆ return_msg_ok()

void return_msg_ok ( sdp_msg_t msg)

Adds an OK result message to the main message queue.

Parameters
[in]msgThe SCP message holding the reply. Ownership transferred by this call.

◆ assign_virt_cpu()

void assign_virt_cpu ( uint  phys_cpu)

Build virtual/physical CPU maps.

Caller is monitor processor and passes its physical CPU.

Parameters
[in]phys_cpuWhat our physical CPU number is.

◆ remap_phys_cores()

void remap_phys_cores ( uint  phys_cores)

Disables a specified core and recomputes the virtual core map accordingly.

This command has a number of dangerous effects:

  • All application cores are rebooted (so that the new virtual core map takes effect)
  • If the core to be disabled includes the monitor then the monitor is disabled without being remapped rendering the chip non-communicative.
    Parameters
    [in]phys_coresBitmap of which cores to remap.

◆ ram_size()

uint ram_size ( void *  mem)

Determine the size of RAM.

Parameters
[in]memThe start of the memory. Will be written to.
Returns
The estimated number of bytes that may be written to at that point

◆ update_load()

void update_load ( uint  arg1,
uint  arg2 
)

Update the 'load' variable with an estimate of the system's load.

Parameters
arg1unused
arg2unused

◆ proc_1hz()

void proc_1hz ( uint  a1,
uint  a2 
)

Regular 1Hz timer callback, put on the event queue every second.

It handles network physical state monitoring.

Parameters
a1unused
a2unused

◆ soft_wdog()

void soft_wdog ( uint  max)

Software watchdog check.

Parameters
[in]maxNumber of pings of a CPU (without reply) when that CPU should be marked as watchdogged.

◆ netinit_start()

void netinit_start ( void  )

Start the higher-level network initialisation process.

Must be called only once, before the nearest neighbour interrupt handler is enabled.

◆ proc_100hz()

void proc_100hz ( uint  a1,
uint  a2 
)

Regular 100Hz timer callback, put on the event queue every 10ms.

Handles:

  1. Discovery of the machine.
  2. Initialisation of the P2P network.
  3. LED state update (liveness monitoring)
  4. IPTag timeouts
  5. Watchdog ping
  6. LTPC
    Parameters
    a1unused
    a2unused

◆ proc_1khz()

void proc_1khz ( uint  a1,
uint  a2 
)

Regular 1kHz timer callback, put on the event queue every millisecond.

Used to PWM the LEDs.

Parameters
a1unused
a2unused

◆ pll_mult()

static uint pll_mult ( uint  freq)
static

Get the PLL multiplier for a frequency.

Parameters
[in]freqThe desired frequency (in MHz)
Returns
the PLL multiplier to ues

Variable Documentation

◆ tag_tto

uint tag_tto = 9

IPTag timeout (logarithmic)

2.56s = 10ms * (1 << (9-1))

◆ p2p_max_y

volatile int p2p_max_y

Estimated maximum Y size

◆ p2p_addr_table

uchar* p2p_addr_table = NULL

A bitmap giving the coordinates of all P2P coordinates which have been seen mentioned in a P2PC_NEW message. A 2D array of bits whose bit indexes are ((bx<<9) | by) where bx and by are x + 256 and y + 256 respectively.

◆ load

volatile uchar load = 0

The current system load.

The LED brightness smoothly will track this value (when in load-tracking mode). 0 = idle, 255 = saturated.

◆ disp_load

volatile uint disp_load = 0 << LOAD_FRAC_BITS

The actual, displayed load value (fixed point).

This value tracks the load value above, transitioning smoothly towards it over time.

◆ rst_init

const uint rst_init[]
Initial value:
= {0x45206e49, 0x79726576, 0x65724420, 0x48206d61,
0x20656d6f, 0x65482061, 0x61747261, 0x00656863}

Reset vectors.