Skip to content

Commit

Permalink
Improvements in overall behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed Mar 2, 2023
1 parent 87077cf commit f52b64a
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 57 deletions.
29 changes: 25 additions & 4 deletions link_test/link_test_vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class EXTRA_PROVENANCE_DATA_ENTRIES(IntEnum):
LINK_COUNT_OK = 0
LINK_FAILS_OK = 1
LINKS_FROM_SCAMP = 2
UNKNOWN_KEYS = 3


#: Number of links on the machine
Expand Down Expand Up @@ -94,11 +95,19 @@ def __init__(self, x, y, sends_per_ts, drops_per_ts_allowed, run_time,
self.__drops_per_ts_allowed = drops_per_ts_allowed
self.__run_time = run_time
self.__neighbours = [None] * 6
self.__sources = set()
self.__repeat_sources = set()

self.__failed = False

def set_neighbour(self, link, neighbour):
self.__neighbours[link] = neighbour
if neighbour in self.__sources:
print(f"Warning: {self.__x}, {self.__y} won't receive over link"
f" {link} as already receiving from elsewhere")
self.__repeat_sources.add(link)
else:
self.__sources.add(neighbour)
self.__neighbours[link] = neighbour

@overrides(SimulatorVertex.get_fixed_location)
def get_fixed_location(self):
Expand Down Expand Up @@ -154,27 +163,39 @@ def _provenance_region_id(self):
@overrides(ProvidesProvenanceDataFromMachineImpl.
parse_extra_provenance_items)
def parse_extra_provenance_items(self, label, x, y, p, provenance_data):
link_count_ok, link_fail_ok, links_from_scamp = provenance_data
link_count_ok, link_fail_ok, links_from_scamp, unknown_keys = (
provenance_data)

with ProvenanceWriter() as db:
for i in range(N_LINKS):
this_link_count_ok = bool(link_count_ok & (1 << i))
this_link_fail_ok = bool(link_fail_ok & (1 << i))
this_link_enabled = bool(links_from_scamp & (1 << i))
this_link_used = i not in self.__repeat_sources
db.insert_core(
x, y, p, f"Link {i} count ok", this_link_count_ok)
db.insert_core(
x, y, p, f"Link {i} fail ok", this_link_fail_ok)
db.insert_core(
x, y, p, f"Link {i} enabled", this_link_enabled)
if this_link_enabled and not this_link_count_ok:
db.insert_core(
x, y, p, f"Link {i} used", this_link_used)
if (this_link_used and this_link_enabled and
not this_link_count_ok):
db.insert_report(f"Link {i} on {x}, {y} failed to receive"
" enough packets")
self.__failed = True
if this_link_enabled and not this_link_fail_ok:
if (this_link_used and this_link_enabled and
not this_link_fail_ok):
db.insert_report(f"Link {i} on {x}, {y} received"
" unexpected data at least once")
self.__failed = True
db.insert_core(
x, y, p, "Unknown keys", unknown_keys)
if unknown_keys:
db.insert_report(
f"Chip {x}, {y} received {unknown_keys} unknown keys")
self.__failed = True

@property
@overrides(ProvidesProvenanceDataFromMachineImpl._n_additional_data_items)
Expand Down
52 changes: 52 additions & 0 deletions link_test/link_tester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) 2023 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from pacman.model.graphs.machine.machine_edge import MachineEdge
import spinnaker_graph_front_end as front_end
from link_test.link_test_vertex import LinkTestVertex, PARTITION_NAME


def run():
front_end.setup(model_binary_folder=os.path.dirname(__file__))

machine = front_end.machine()

run_time = 10000

# Put link test on all chips
chips = dict()
for c_x, c_y in machine.chip_coordinates:
chips[c_x, c_y] = LinkTestVertex(c_x, c_y, 100, 1, run_time)
front_end.add_machine_vertex_instance(chips[c_x, c_y])

# Connect links together
for chip in machine.chips:
for link in chip.router.links:
opposite_link = (link.source_link_id + 3) % 6
target = chips[link.destination_x, link.destination_y]
source = chips[chip.x, chip.y]
target.set_neighbour(opposite_link, source)
front_end.add_machine_edge_instance(
MachineEdge(source, target), PARTITION_NAME)

front_end.run(run_time)
front_end.stop()

# Check the vertices for failure
for vertex in chips.values():
vertex.check_failure()


if __name__ == "__main__":
run()
53 changes: 12 additions & 41 deletions link_test/run_link_test.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,34 @@
# Copyright (c) 2017-2019 The University of Manchester
# Copyright (c) 2023 The University of Manchester
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# http://www.apache.org/licenses/LICENSE-2.0
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from time import sleep
import os
import tempfile
import sys
import traceback
import pytest
from pacman.model.graphs.machine.machine_edge import MachineEdge
from spalloc.job import Job
from spalloc.states import JobState
import spinnaker_graph_front_end as front_end
from link_test.link_test_vertex import LinkTestVertex, PARTITION_NAME
from _pytest.outcomes import Skipped
from link_test.link_tester import run


class LinkTest(object):

def do_run(self):
front_end.setup(model_binary_folder=os.path.dirname(__file__))

machine = front_end.machine()

run_time = 10000

# Put link test on all chips
chips = dict()
for c_x, c_y in machine.chip_coordinates:
chips[c_x, c_y] = LinkTestVertex(c_x, c_y, 100, 1, run_time)
front_end.add_machine_vertex_instance(chips[c_x, c_y])

# Connect links together
for chip in machine.chips:
for link in chip.router.links:
opposite_link = (link.source_link_id + 3) % 6
target = chips[link.destination_x, link.destination_y]
source = chips[chip.x, chip.y]
target.set_neighbour(opposite_link, source)
front_end.add_machine_edge_instance(
MachineEdge(source, target), PARTITION_NAME)

front_end.run(run_time)
front_end.stop()

# Check the vertices for failure
for vertex in chips.values():
vertex.check_failure()
run()


boards = [(x, y, b) for x in range(20) for y in range(20) for b in range(3)]
Expand Down
34 changes: 22 additions & 12 deletions link_test/src/link_test.c
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
/*
* Copyright (c) 2017-2019 The University of Manchester
* Copyright (c) 2023 The University of Manchester
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* http://www.apache.org/licenses/LICENSE-2.0
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

//! imports
#include "spin1_api.h"
#include "common-typedefs.h"
Expand Down Expand Up @@ -56,6 +54,9 @@ typedef struct {

// Flags for links which are available from SCAMP
uint32_t known_links;

// Count of unknown keys
uint32_t unknown_keys;
} provenance_data_t;

//! human readable definitions of each region in SDRAM
Expand Down Expand Up @@ -106,21 +107,29 @@ static uint32_t fails_received[N_LINKS];
// Expected data from adjacent chips, based on sv data for this chip
static uint32_t expected_data[N_LINKS];

// The number of unknown keys received
static uint32_t unknown_keys = 0;

// The data to send to adjacent chips
static p2p_data_t data_to_send;

// -------------------------------------------------------------------

static void receive_data(uint key, uint payload) {
uint32_t key_found = 0;
for (uint32_t i = 0; i < N_LINKS; i++) {
if (key == config.receive_keys[i]) {
packets_received[i]++;
if (payload != expected_data[i]) {
fails_received[i]++;
}
key_found = 1;
break;
}
}
if (!key_found) {
unknown_keys++;
}
}

//! \brief Writes the provenance data
Expand All @@ -145,6 +154,7 @@ static void store_provenance_data(address_t provenance_region) {
prov->known_links = sv->link_en;
prov->links_count_ok = links_ok;
prov->links_fails_ok = fails_ok;
prov->unknown_keys = unknown_keys;
}

/****f*
Expand Down

0 comments on commit f52b64a

Please sign in to comment.