Skip to content

Commit

Permalink
Merge pull request #1165 from SpiNNakerManchester/region_downloading
Browse files Browse the repository at this point in the history
Region downloading
  • Loading branch information
Christian-B authored Sep 9, 2024
2 parents 4d8a3be + ec1d680 commit 0143c79
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 6 deletions.
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}]}

0 comments on commit 0143c79

Please sign in to comment.