Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
c02dc47
using pandas to save csv of all interesting provenance info
pabogdan Mar 9, 2020
0fd046b
fix bug in matching sizes between provenance and placements. added as…
pabogdan Mar 10, 2020
c32394d
Add provenance writing for app_vertex
andrewgait Oct 27, 2021
3d682df
Use the correct type
andrewgait Oct 27, 2021
7b3b104
Merge branch 'master' into weight_scale
andrewgait Nov 5, 2021
55a6f3e
Merge branch 'master' into weight_scale
andrewgait Nov 5, 2021
f2d18fb
Merge branch 'master' into weight_scale
andrewgait Nov 10, 2021
2febcfd
Merge branch 'master' into weight_scale
andrewgait Nov 11, 2021
0ffb914
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 25, 2021
9936834
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Dec 6, 2021
812d530
Add LUT provenance to database
andrewgait Dec 6, 2021
5693672
Fix structured provenance to use vertex slice attributes, not label
andrewgait Dec 7, 2021
e9a3286
Merge branch 'master' into weight_scale
andrewgait Jan 10, 2022
31aef2a
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Feb 25, 2022
fbba09b
Merge branch 'master' into weight_scale
andrewgait Mar 11, 2022
1c017c0
Merge branch 'master' into weight_scale
andrewgait Mar 28, 2022
b9385d2
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Apr 1, 2022
37d8925
Merge branch 'master' into weight_scale
andrewgait Apr 14, 2022
31db8d0
Merge branch 'master' into weight_scale
andrewgait Apr 20, 2022
475f39e
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Apr 20, 2022
de856ca
Merge branch 'master' into weight_scale
andrewgait May 9, 2022
bdbb44e
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait May 11, 2022
3438aa8
Merge branch 'master' into weight_scale
andrewgait May 19, 2022
3c0dbe2
Merge branch 'master' into weight_scale
andrewgait May 25, 2022
dcf968e
Merge branch 'master' into weight_scale
andrewgait Jun 16, 2022
1cecff0
Merge branch 'master' into weight_scale
andrewgait Jul 11, 2022
70c488f
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Jul 19, 2022
6849555
Merge weirdness
andrewgait Jul 19, 2022
318fb59
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Jul 21, 2022
8be9e9f
Merge branch 'master' into weight_scale
andrewgait Jul 22, 2022
8ca2f04
Rename to label as that's what is being used
andrewgait Jul 22, 2022
dd98f63
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Jul 26, 2022
1683e89
Merge branch 'master' into weight_scale
andrewgait Aug 3, 2022
a6f5ec6
Merge branch 'master' into weight_scale
andrewgait Aug 4, 2022
aa9bb8f
Merge branch 'master' into weight_scale
andrewgait Aug 22, 2022
6e55b9f
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Aug 22, 2022
d5104e7
update structured provenance
andrewgait Aug 22, 2022
c1ade29
Merge branch 'master' into weight_scale
andrewgait Sep 9, 2022
99ad84e
Merge branch 'master' into weight_scale
andrewgait Sep 14, 2022
e0a525c
Merge branch 'master' into weight_scale
andrewgait Sep 15, 2022
1827764
Merge branch 'master' into weight_scale
andrewgait Sep 15, 2022
48a50d1
Merge branch 'master' into weight_scale
andrewgait Sep 16, 2022
92533c6
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Sep 20, 2022
de7abba
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Sep 22, 2022
e301a1c
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Sep 26, 2022
62afeb6
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 26, 2022
cd1eaf4
Merge properly
andrewgait Sep 26, 2022
f5e8634
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Sep 27, 2022
c20ba82
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Sep 29, 2022
6c8cad5
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Sep 30, 2022
e0555d5
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Oct 21, 2022
3ce1a89
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Oct 27, 2022
41a906c
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 18, 2022
741e691
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Nov 24, 2022
f762abd
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Nov 30, 2022
ef8103b
Save ITCM
andrewgait Dec 5, 2022
3a9f5c2
Merge branch 'master' into weight_scale
andrewgait Jan 11, 2023
b11a98f
Merge branch 'master' into weight_scale
andrewgait Jan 11, 2023
a3fb89f
Merge branch 'master' into weight_scale
andrewgait Jan 12, 2023
734d2d1
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Jan 17, 2023
1c41975
pylint rename variable
andrewgait Jan 17, 2023
a8f3777
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jan 24, 2023
b69d547
Merge branch 'master' into weight_scale
andrewgait Feb 10, 2023
a617bc7
Merge branch 'master' into weight_scale
andrewgait Feb 20, 2023
9c4d5e3
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Feb 23, 2023
f7b2532
Missing import
andrewgait Feb 23, 2023
7d7a087
Merge branch 'master' into weight_scale
andrewgait Mar 1, 2023
2b9fd91
Merge branch 'master' into weight_scale
andrewgait Apr 11, 2023
2a45126
Merge branch 'master' into weight_scale
andrewgait Apr 21, 2023
8fd131e
Merge branch 'master' into weight_scale
andrewgait May 17, 2023
283a492
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jun 23, 2023
58dc28a
Fix doc strings
andrewgait Jun 23, 2023
fc27dc6
Merge branch 'master' into weight_scale
andrewgait Jul 6, 2023
8d6c413
Merge remote-tracking branch 'origin/master' into spinncer_update
andrewgait Jul 7, 2023
f57e1f1
Merge branch 'weight_scale' into spinncer_weight_scale
andrewgait Jul 7, 2023
e69bb60
missed in merge
andrewgait Jul 7, 2023
35d85ce
Merge remote-tracking branch 'origin/master' into weight_scale
andrewgait Jul 7, 2023
25cb4e4
Merge remote-tracking branch 'origin/weight_scale' into
andrewgait Jul 7, 2023
079e6a1
Get the merge correct
andrewgait Jul 7, 2023
ebd13d4
Merge remote-tracking branch 'origin/master' into spinncer_weight_scale
andrewgait Aug 3, 2023
ebf93a1
Merge remote-tracking branch 'origin/master' into spinncer_weight_scale
andrewgait Aug 29, 2023
ade9e26
Merge remote-tracking branch 'origin/master' into spinncer_weight_scale
andrewgait Sep 12, 2023
d02e84c
Merge remote-tracking branch 'origin/master' into spinncer_weight_scale
andrewgait Sep 20, 2023
ef1d1d5
Merge remote-tracking branch 'origin/master' into spinncer_weight_scale
andrewgait Sep 26, 2023
1ef085d
Oops - fix tests
andrewgait Sep 26, 2023
5915c62
Merge remote-tracking branch 'origin/master' into spinncer_weight_scale
andrewgait Sep 29, 2023
9609607
flake8 remove blank line
andrewgait Sep 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions c_common/front_end_common_lib/src/recording.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ bool recording_initialize(
sark_heap_max(sv->sdram_heap, 0));
return false;
}
log_info("Allocated %u bytes for recording channel %u at 0x%08x",
space, i, region->data);
// log_info("Allocated %u bytes for recording channel %u at 0x%08x",
// space, i, region->data);
if (recording_flags != NULL) {
*recording_flags = (*recording_flags | (1 << i));
}
Expand Down
10 changes: 5 additions & 5 deletions c_common/front_end_common_lib/src/simulation.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ static void simulation_control_scp_callback(uint mailbox, UNUSED uint port) {
log_info("Calling pre-exit function");
stored_exit_function();
}
log_info("Exiting");
// log_info("Exiting");
spin1_exit(0);
break;

case CMD_RUNTIME:
log_info("Setting the runtime of this model to %d starting at %d",
msg->arg1, msg->arg3);
log_info("Setting the flag of infinite run for this model to %d",
msg->arg2);
log_info("Setting the runtime of this model to %d starting at %d (flag %d)",
msg->arg1, msg->arg3, msg->arg2);
// log_info("Setting the flag of infinite run for this model to %d",
// msg->arg2);

// resetting the simulation time pointer
*pointer_to_simulation_time = msg->arg1;
Expand Down
60 changes: 52 additions & 8 deletions spinn_front_end_common/interface/ds/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
import numpy as np


def _round_to_int(value):
""" Rounds a number to the closest integer
:param float value: The value to round
:rtype: int
"""
if isinstance(value, int):
return value
return int(round(value))


class DataType(Enum):
"""
Supported data types.
Expand Down Expand Up @@ -49,7 +59,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"B",
False,
int,
_round_to_int,
np.uint8,
"8-bit unsigned integer")
#: 16-bit unsigned integer
Expand All @@ -60,7 +70,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"H",
False,
int,
_round_to_int,
np.uint16,
"16-bit unsigned integer")
#: 32-bit unsigned integer
Expand All @@ -71,7 +81,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"I",
False,
int,
_round_to_int,
np.uint32,
"32-bit unsigned integer")
#: 64-bit unsigned integer
Expand All @@ -82,7 +92,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"Q",
False,
int,
_round_to_int,
np.uint64,
"64-bit unsigned integer")
#: 8-bit signed integer
Expand All @@ -93,7 +103,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"b",
False,
int,
_round_to_int,
np.int8,
"8-bit signed integer")
#: 16-bit signed integer
Expand All @@ -104,7 +114,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"h",
False,
int,
_round_to_int,
np.int16,
"16-bit signed integer")
#: 32-bit signed integer
Expand All @@ -115,7 +125,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"i",
False,
int,
_round_to_int,
np.int32,
"32-bit signed integer")
#: 64-bit signed integer
Expand All @@ -126,7 +136,7 @@ class DataType(Enum):
decimal.Decimal("1"),
"q",
False,
int,
_round_to_int,
np.int64,
"64-bit signed integer")
#: 8.8 unsigned fixed point number
Expand Down Expand Up @@ -402,6 +412,31 @@ def numpy_typename(self):
"""
return self._numpy_typename

def closest_representable_value(self, value):
"""
Returns the closest value to the given value that can be represented
by this type

:param value:
:type value: float or in
:rtype: float
"""
return self.decode_from_int(self.encode_as_int(value))

def closest_representable_value_above(self, value):
"""
Returns the closest value above the given value that can be
represented by this type.

:param value:
:type value: float or in
:rtype: float
"""
closest_value = self.decode_from_int(self.encode_as_int(value))
if closest_value >= value:
return closest_value
return self.decode_from_int(self.encode_as_int(value)+1)

def encode_as_int(self, value):
"""
Returns the value as an integer, according to this type.
Expand All @@ -425,6 +460,15 @@ def encode_as_int(self, value):
return self._force_cast(value)
return value

def decode_from_int(self, value):
"""
Decode a single value represented as an int according to this type.

:param int array:
:rtype: float or int
"""
return value / float(self._scale)

def encode_as_numpy_int(self, value):
"""
Returns the value as a numpy integer, according to this type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from spinn_utilities.log import FormatAdapter
from spinn_utilities.progress_bar import ProgressBar
from spinn_front_end_common.interface.provenance import (
AbstractProvidesProvenanceDataFromMachine)
AbstractProvidesProvenanceDataFromMachine, ProvenanceWriter)

logger = FormatAdapter(logging.getLogger(__name__))

Expand All @@ -38,6 +38,7 @@ def placements_provenance_gatherer(n_placements, placements):
# retrieve provenance data from any cores that provide data
for placement in progress.over(placements):
_add_placement_provenance(placement, errors)
_add_structured_provenance(placement, errors)
if errors:
logger.warning("Errors found during provenance gathering:")
for error in errors:
Expand All @@ -50,11 +51,47 @@ def _add_placement_provenance(placement, errors):
:param list(str) errors:
"""
# retrieve provenance data from any cores that provide data
if isinstance(
placement.vertex, AbstractProvidesProvenanceDataFromMachine):
if isinstance(placement.vertex, AbstractProvidesProvenanceDataFromMachine):
# get data
try:
placement.vertex.get_provenance_data_from_machine(placement)

except Exception: # pylint: disable=broad-except
errors.append(traceback.format_exc())


def _add_structured_provenance(placement, errors):
"""
:param ~.Placement placement:
:param list(str) errors:
"""
# Insert structured provenance data to database for cores that have data
if isinstance(placement.vertex, AbstractProvidesProvenanceDataFromMachine):

# Custom provenance presentation from SpiNNCer
# write provenance to file here in a useful way
columns = ['pop', 'label', 'min_atom', 'max_atom', 'no_atoms',
'fixed_sdram', 'sdram_per_timestep']

pop = placement.vertex.label.split(":")[0]
fixed_sdram = placement.vertex.sdram_required.fixed
sdram_per_timestep = placement.vertex.sdram_required.per_timestep

label = placement.vertex.label
vertex_slice = placement.vertex.vertex_slice
max_atom = vertex_slice.hi_atom
min_atom = vertex_slice.lo_atom
no_atoms = vertex_slice.n_atoms

structured_provenance = [
pop, label, min_atom, max_atom, no_atoms,
fixed_sdram, sdram_per_timestep]

# get data
try:
with ProvenanceWriter() as db:
for n in range(len(columns)):
db.insert_core(placement.x, placement.y, placement.p,
columns[n], structured_provenance[n])
except Exception: # pylint: disable=broad-except
errors.append(traceback.format_exc())
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_provenance_for_router(self, x, y):
f"{ row[0] }: { row[1] }"
for row in self.run_query(query, [int(x), int(y)]))

def get_cores_with_provenace(self):
def get_cores_with_provenance(self):
"""
Gets the cores with provenance.

Expand Down Expand Up @@ -233,10 +233,10 @@ def demo():
print(row)
print("\nCORES WITH LATE SPIKES:")
print(pr.cores_with_late_spikes())
print("\nROUETER (0,0) PROVENANCE:")
print("\nROUTER (0,0) PROVENANCE:")
print(pr.get_provenance_for_router(0, 0))
print("\nCORES WITH PROVENACE")
print(pr.get_cores_with_provenace())
print(pr.get_cores_with_provenance())


if __name__ == '__main__':
Expand Down
39 changes: 39 additions & 0 deletions spinn_front_end_common/interface/provenance/provenance_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,42 @@ def insert_board_provenance(self, connections):
VALUES (?, ?, ?)
""", ((x, y, ipaddress)
for ((x, y), ipaddress) in connections.items()))

def insert_app_vertex(
self, label, the_type, description, the_value):
"""
Inserts app level data into the app_vertex_provenance

:param str label: Label of the app_vertex
:param str the_type: Class of the app_vertex
:param str description: type of value
:param float the_value: data
"""
self.execute(
"""
INSERT OR IGNORE INTO app_vertex_provenance(
label, the_type, description, the_value)
VALUES(?, ?, ?, ?)
""",
[label, the_type, description, the_value])

def insert_lut(
self, pre_population, post_population, the_type, description,
the_value):
"""
Inserts edge data into the lut_provenance
:param str pre_population: Name of the pre population / vertex
:param str post_population: Name of the post population / vertex
:param str the_type: Class of the rule of the LUT
:param str description: type of value
:param float the_value: data
"""
self.execute(
"""
INSERT OR IGNORE INTO lut_provenance(
pre_population, post_population, the_type, description,
the_value)
VALUES(?, ?, ?, ?, ?)
""",
[pre_population, post_population, the_type, description,
the_value])
19 changes: 19 additions & 0 deletions spinn_front_end_common/utilities/db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,22 @@ CREATE TABLE IF NOT EXISTS boards_provenance(
ip_addres STRING NOT NULL,
ethernet_x INTEGER NOT NULL,
ethernet_y INTEGER NOT NULL);

---------------------------------------------------------------------
-- A table app vertex provenance
CREATE TABLE IF NOT EXISTS app_vertex_provenance(
app_vertex_id INTEGER PRIMARY KEY AUTOINCREMENT,
label STRING NOT NULL,
the_type STRING NOT NULL,
description STRING NOT NULL,
the_value FLOAT NOT NULL);

---------------------------------------------------------------------
-- A table LUT provenance
CREATE TABLE IF NOT EXISTS lut_provenance(
connector_id INTEGER PRIMARY KEY AUTOINCREMENT,
pre_population STRING NOT NULL,
post_population STRING NOT NULL,
the_type STRING NOT NULL,
description STRING NOT NULL,
the_value FLOAT NOT NULL);
16 changes: 16 additions & 0 deletions unittests/interface/provenance/test_provenance_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ def test_board(self):
with ProvenanceWriter() as db:
db.insert_board_provenance(data)

def test_app_vertex(self):
with ProvenanceWriter() as db:
db.insert_app_vertex("pop", "type", "description", 0.5)
with ProvenanceReader() as db:
data = db.run_query("Select * from app_vertex_provenance")
expected = [(1, 'pop', 'type', 'description', 0.5)]
self.assertListEqual(expected, data)

def test_lut(self):
with ProvenanceWriter() as db:
db.insert_lut("the pre", "A post", "OneToOne", "foo", 0.5)
with ProvenanceReader() as db:
data = db.run_query("Select * from lut_provenance")
expected = [(1, 'the pre', 'A post', 'OneToOne', 'foo', 0.5)]
self.assertListEqual(expected, data)

def test_log(self):
db1 = LogStoreDB()
db2 = LogStoreDB()
Expand Down