SpiNNFrontEndCommon 7.1.1
Common support code for user-facing front end systems.
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
chip_power_monitor.c File Reference

The implementation of the Chip Power Monitor. More...

#include <spin1_api.h>
#include <spinn_extra.h>
#include <simulation.h>
#include <spinnaker.h>
#include <recording.h>
#include <debug.h>
#include <data_specification.h>

Go to the source code of this file.

Data Structures

struct  sample_params
 Describes the format of the configuration region. More...
 

Macros

#define NUM_RANDOM_BITS   12
 

Enumerations

enum  { SYSTEM = 0 , CONFIG = 1 , RECORDING = 2 }
 The IDs of each DSG region used. More...
 
enum  { TIMER = 0 , SDP = 1 , DMA = 2 }
 values for the priority for each callback More...
 

Functions

static uint32_t get_sample (void)
 Read which cores on the chip are asleep right now.
 
static uint32_t get_random_busy (void)
 Computes a random value used to break up chance periodicities in sampling.
 
static void record_aggregate_sample (void)
 Synchronously records the current contents of the core_counters to the recording region.
 
static void reset_core_counters (void)
 Resets the state of the core_counters and the sample_count variables to zero.
 
static void rescale_sim_ticks (void)
 Change simulation ticks to be a number related to sampling frequency.
 
static void resume_callback (void)
 The function to call when resuming a simulation.
 
static void count_core_states (void)
 Accumulate a count of how active each core on the current chip is. The counter for the core is incremented if the core is active.
 
static void sample_in_slot (uint unused0, uint unused1)
 Called to actually record a sample.
 
static bool read_parameters (struct sample_params *sample_params)
 Reads the configuration of the application out of the configuration region.
 
static bool initialize (void)
 Initialises the program.
 
void c_main (void)
 The application entry point.
 

Variables

static const uint32_t RECORDING_CHANNEL_ID = 0
 The recording channel we use.
 
static uint32_t simulation_ticks = 0
 The main simulation tick.
 
static uint32_t infinite_run = 0
 Whether we are running "forever".
 
static uint32_t time
 Our internal notion of time.
 
static uint32_t timer = 0
 The main simulation time period.
 
static uint32_t core_counters [NUM_CPUS]
 Where we aggregate the sample activity counts.
 
static uint32_t sample_count
 How many samples have we done so far within this aggregate step?
 
static uint32_t sample_count_limit
 The number of samples to aggregate per recording entry.
 
static uint32_t recording_flags
 General recording flags. (Unused by this code.)
 
static uint32_t sample_frequency
 The frequency with which we sample the execution state of all cores.
 

Detailed Description

The implementation of the Chip Power Monitor.

The purpose of this application is to monitor the activity of the other CPU cores on the chip on which it runs. It does this using the SpiNNaker System Controller, enabling it to run with just the overhead due to using a core; it does not change the individual performance of the other cores on the chip.

Definition in file chip_power_monitor.c.


Data Structure Documentation

◆ sample_params

struct sample_params

Describes the format of the configuration region.

Definition at line 47 of file chip_power_monitor.c.

Data Fields
uint32_t count_limit The number of samples to aggregate per recording entry.
uint32_t frequency The fundamental sampling frequency.

Macro Definition Documentation

◆ NUM_RANDOM_BITS

#define NUM_RANDOM_BITS   12

The number of bits of randomness used to break up sampling periodicity errors.

Definition at line 37 of file chip_power_monitor.c.

Enumeration Type Documentation

◆ anonymous enum

The IDs of each DSG region used.

Enumerator
SYSTEM 

The system data region ID.

CONFIG 

The configuration region ID.

RECORDING 

The recorded data region ID.

Definition at line 40 of file chip_power_monitor.c.

◆ anonymous enum

values for the priority for each callback

Enumerator
TIMER 

The timer callback is highest priority.

SDP 

Responding to communications from host is next highest.

DMA 

DMA processing is lowest priority.

Definition at line 60 of file chip_power_monitor.c.

Function Documentation

◆ get_sample()

static uint32_t get_sample ( void  )
inlinestatic

Read which cores on the chip are asleep right now.

Returns
A word (with 18 relevant bits in the low bits of the word) where a bit is set when a core is asleep and waiting for events, and clear when the core is active.

Note that this accesses into the SpiNNaker System Controller hardware (see Data Sheet, section 14, register 25).

Definition at line 93 of file chip_power_monitor.c.

◆ get_random_busy()

static uint32_t get_random_busy ( void  )
inlinestatic

Computes a random value used to break up chance periodicities in sampling.

In range 0 to 4095.

Returns
The number of times a busy loop must run.

Definition at line 101 of file chip_power_monitor.c.

◆ record_aggregate_sample()

static void record_aggregate_sample ( void  )
inlinestatic

Synchronously records the current contents of the core_counters to the recording region.

Definition at line 107 of file chip_power_monitor.c.

◆ reset_core_counters()

static void reset_core_counters ( void  )
inlinestatic

Resets the state of the core_counters and the sample_count variables to zero.

Definition at line 114 of file chip_power_monitor.c.

◆ rescale_sim_ticks()

static void rescale_sim_ticks ( void  )
inlinestatic

Change simulation ticks to be a number related to sampling frequency.

Definition at line 122 of file chip_power_monitor.c.

◆ resume_callback()

static void resume_callback ( void  )
static

The function to call when resuming a simulation.

Definition at line 129 of file chip_power_monitor.c.

◆ count_core_states()

static void count_core_states ( void  )
inlinestatic

Accumulate a count of how active each core on the current chip is. The counter for the core is incremented if the core is active.

Uses get_sample() to obtain the state of the cores.

Definition at line 152 of file chip_power_monitor.c.

◆ sample_in_slot()

static void sample_in_slot ( uint  unused0,
uint  unused1 
)
static

Called to actually record a sample.

Parameters
unused0unused
unused1unused

Definition at line 165 of file chip_power_monitor.c.

◆ read_parameters()

static bool read_parameters ( struct sample_params sample_params)
static

Reads the configuration of the application out of the configuration region.

Parameters
[in]sample_paramsPointer to the configuration region.
Returns
True if the read was successful. (Does not currently fail.)

Definition at line 204 of file chip_power_monitor.c.

◆ initialize()

static bool initialize ( void  )
static

Initialises the program.

Returns
True if initialisation succeeded, false if it failed.

Definition at line 214 of file chip_power_monitor.c.

◆ c_main()

void c_main ( void  )

The application entry point.

Initialises the application state, installs all required callbacks, and runs the "simulation" loop until told to terminate.

Definition at line 240 of file chip_power_monitor.c.

Variable Documentation

◆ RECORDING_CHANNEL_ID

const uint32_t RECORDING_CHANNEL_ID = 0
static

The recording channel we use.

Only one recording channel is used by this application.

Definition at line 57 of file chip_power_monitor.c.

◆ simulation_ticks

uint32_t simulation_ticks = 0
static

The main simulation tick.

Definition at line 67 of file chip_power_monitor.c.

◆ infinite_run

uint32_t infinite_run = 0
static

Whether we are running "forever".

Definition at line 69 of file chip_power_monitor.c.

◆ time

uint32_t time
static

Our internal notion of time.

Definition at line 71 of file chip_power_monitor.c.

◆ timer

uint32_t timer = 0
static

The main simulation time period.

Definition at line 73 of file chip_power_monitor.c.

◆ core_counters

uint32_t core_counters[NUM_CPUS]
static

Where we aggregate the sample activity counts.

Definition at line 76 of file chip_power_monitor.c.

◆ sample_count

uint32_t sample_count
static

How many samples have we done so far within this aggregate step?

Definition at line 78 of file chip_power_monitor.c.

◆ sample_count_limit

uint32_t sample_count_limit
static

The number of samples to aggregate per recording entry.

Definition at line 80 of file chip_power_monitor.c.

◆ recording_flags

uint32_t recording_flags
static

General recording flags. (Unused by this code.)

Definition at line 82 of file chip_power_monitor.c.

◆ sample_frequency

uint32_t sample_frequency
static

The frequency with which we sample the execution state of all cores.

Definition at line 84 of file chip_power_monitor.c.