Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Region downloading #1165

Merged
merged 13 commits into from
Sep 9, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ private Map<ChipLocation, List<WorkItems>> discoverActualWork(
storeData(r, allocate(0));
}
}
for (var dr : p.getVertex().getDownloadRegions()) {
regions.add(new Region(p, dr.getIndex(),
dr.getAddress(), dr.getSize()));
count++;
}
workitems.add(new WorkItems(m, regions));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ public void getDataForPlacements(List<Placement> placements)
.getRecordedRegionIds()) {
getDataForPlacement(placement, recordingRegionId);
}
for (var region : placement.getVertex().getDownloadRegions()) {
var location = new RegionLocation(placement,
region.getIndex());
readSomeData(location, region.getAddress(),
region.getSize());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2024 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
*
* https://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.
*/
package uk.ac.manchester.spinnaker.front_end.download.request;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;

import uk.ac.manchester.spinnaker.machine.MemoryLocation;

/**
* A non-recording region to be downloaded.
*/
@JsonFormat(shape = Shape.OBJECT)
public class DownloadRegion {

private final int index;

private final MemoryLocation address;

private final int size;

public DownloadRegion() {
this.index = 0;
this.address = new MemoryLocation(0);
this.size = 0;
}

/**
* Constructs a new download region.
*
* @param index
* The index of the region.
* @param address
* The address of the region.
* @param size
* The size of the region.
*/
public DownloadRegion(
@JsonProperty(value = "index", required = true) int index,
@JsonProperty(value = "address", required = true) long address,
@JsonProperty(value = "size", required = true) int size) {
this.index = index;
this.address = new MemoryLocation(address);
this.size = size;
}

/**
* @return The index of the region.
*/
public int getIndex() {
return index;
}

/**
* @return The address of the region.
*/
public MemoryLocation getAddress() {
return address;
}

/**
* @return The size of the region.
*/
public int getSize() {
return size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public class Vertex {
@NotNull
private final int[] recordedRegionIds;

/** The non-recording regions to download. */
@NotNull
private final DownloadRegion[] downloadRegions;

/**
* Create a minimal vertex, possibly using an unmarshaller.
*
Expand All @@ -75,16 +79,21 @@ public class Vertex {
* execution process.
* @param recordedRegionIds
* The IDs of the regions doing recording.
* @param downloadRegions
* The non-recording regions to download.
*/
public Vertex(@JsonProperty(value = "label", required = true) String label,
@JsonProperty(value = "recordingRegionBaseAddress", required = true)
long recordingRegionBaseAddress,
@JsonProperty(value = "recordedRegionIds", required = true)
int[] recordedRegionIds) {
int[] recordedRegionIds,
@JsonProperty(value = "downloadRegions", required = true)
DownloadRegion[] downloadRegions) {
this.label = label;
this.recordingRegionBaseAddress = recordingRegionBaseAddress;
this.recordedRegionIds = recordedRegionIds;
this.base = new MemoryLocation(recordingRegionBaseAddress);
this.downloadRegions = downloadRegions;
}

/**
Expand Down Expand Up @@ -123,4 +132,11 @@ public MemoryLocation getBase() {
public String getLabel() {
return label;
}

/**
* @return The non-recording regions to download.
*/
public DownloadRegion[] getDownloadRegions() {
return downloadRegions;
}
}
2 changes: 1 addition & 1 deletion SpiNNaker-front-end/src/test/resources/gather.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"x": 0, "y": 0, "p": 1, "iptag": {"x": 0, "y": 0, "boardAddress": "192.168.240.253", "targetAddress": "localhost", "stripSDP": true, "tagID": 1, "trafficIdentifier": "DATA_SPEED_UP"}, "monitors": [{"x": 0, "y": 0, "p": 2, "placements": [{"x": 0, "y": 0, "p": 3, "vertex": {"label": "pop_1:0:2", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1614021536}}, {"x": 0, "y": 0, "p": 4, "vertex": {"label": "input:0:0", "recordedRegionIds": [], "recordingRegionBaseAddress": 1612972308}}]}]}]
[{"x": 0, "y": 0, "p": 1, "iptag": {"x": 0, "y": 0, "boardAddress": "192.168.240.253", "targetAddress": "localhost", "stripSDP": true, "tagID": 1, "trafficIdentifier": "DATA_SPEED_UP"}, "monitors": [{"x": 0, "y": 0, "p": 2, "placements": [{"x": 0, "y": 0, "p": 3, "vertex": {"label": "pop_1:0:2", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1614021536, "downloadRegions": [{"index": 2, "address": 12345678, "size": 10000}]}}, {"x": 0, "y": 0, "p": 4, "vertex": {"label": "input:0:0", "recordedRegionIds": [], "recordingRegionBaseAddress": 1612972308, "downloadRegions": []}}]}]}]
2 changes: 1 addition & 1 deletion SpiNNaker-front-end/src/test/resources/placement.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{"x": 1, "y": 2, "p": 3, "vertex": {"label": "pop_1:0:0", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1612972372}}
{"x": 1, "y": 2, "p": 3, "vertex": {"label": "pop_1:0:0", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1612972372, "downloadRegions": [{"index": 2, "address": 12345678, "size": 10000}]}}

4 changes: 2 additions & 2 deletions SpiNNaker-front-end/src/test/resources/simple.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[{"x": 0, "y": 0, "p": 1, "vertex": {"label": "pop_1:0:0", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1612972372}},
{"x": 0, "y": 0, "p": 2, "vertex": {"label": "input:0:0", "recordedRegionIds": [], "recordingRegionBaseAddress": 1612972632}}]
[{"x": 0, "y": 0, "p": 1, "vertex": {"label": "pop_1:0:0", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1612972372, "downloadRegions": []}},
{"x": 0, "y": 0, "p": 2, "vertex": {"label": "input:0:0", "recordedRegionIds": [], "recordingRegionBaseAddress": 1612972632, "downloadRegions": [{"index": 2, "address": 12345678, "size": 10000}]}}]
2 changes: 1 addition & 1 deletion SpiNNaker-front-end/src/test/resources/vertex.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"label": "pop_1:0:0", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1612972372}
{"label": "pop_1:0:0", "recordedRegionIds": [0, 1], "recordingRegionBaseAddress": 1612972372, "downloadRegions": [{"index": 2, "address": 12345678, "size": 10000}]}
Loading