Skip to content

Commit 4036d12

Browse files
committed
Avoid asking for the size of the machine after configuring for no drop
1 parent e1b09d6 commit 4036d12

File tree

7 files changed

+62
-31
lines changed

7 files changed

+62
-31
lines changed

SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/protocols/FastDataIn.java

+3-22
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,6 @@ public class FastDataIn implements AutoCloseable {
9797
/** Sequence number that marks the end of a sequence number stream. */
9898
private static final int MISSING_SEQS_END = -1;
9999

100-
private final int maxChipX;
101-
102-
private final int maxChipY;
103-
104100
private final HasCoreLocation gathererCore;
105101

106102
private final ThrottledConnection connection;
@@ -130,13 +126,11 @@ public class FastDataIn implements AutoCloseable {
130126
*/
131127
@MustBeClosed
132128
@SuppressWarnings("MustBeClosed")
133-
public FastDataIn(int maxChipX, int maxChipY, CoreLocation gathererCore,
129+
public FastDataIn(CoreLocation gathererCore,
134130
TransceiverInterface transceiver, ChipLocation ethernetChip,
135131
String ethernetAddress, IPTag iptag)
136132
throws ProcessException, IOException, InterruptedException {
137133
this.gathererCore = gathererCore;
138-
this.maxChipX = maxChipX;
139-
this.maxChipY = maxChipY;
140134
this.connection = new ThrottledConnection(transceiver, ethernetChip,
141135
ethernetAddress, iptag);
142136
}
@@ -146,19 +140,6 @@ public void close() throws IOException {
146140
connection.close();
147141
}
148142

149-
private HasChipLocation getBoardLocalDestination(
150-
HasChipLocation monitorChip) {
151-
int boardLocalX = monitorChip.getX() - gathererCore.getX();
152-
if (boardLocalX < 0) {
153-
boardLocalX += maxChipX + 1;
154-
}
155-
int boardLocalY = monitorChip.getY() - gathererCore.getY();
156-
if (boardLocalY < 0) {
157-
boardLocalY += maxChipY + 1;
158-
}
159-
return new ChipLocation(boardLocalX, boardLocalY);
160-
}
161-
162143
/**
163144
* Write data to a given memory location.
164145
*
@@ -173,7 +154,7 @@ private HasChipLocation getBoardLocalDestination(
173154
* @throws InterruptedException
174155
* If communications are interrupted.
175156
*/
176-
public void fastWrite(HasChipLocation destination,
157+
public void fastWrite(HasChipLocation boardLocalDestination,
177158
MemoryLocation baseAddress, ByteBuffer data)
178159
throws IOException, InterruptedException {
179160
int timeoutCount = 0;
@@ -182,7 +163,7 @@ public void fastWrite(HasChipLocation destination,
182163

183164
outerLoop: while (true) {
184165
// Do the initial blast of data
185-
sendInitialPackets(getBoardLocalDestination(destination),
166+
sendInitialPackets(boardLocalDestination,
186167
baseAddress, data, transactionId, numPackets);
187168
/*
188169
* Don't create a missing buffer until at least one packet has

SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/transceiver/Transceiver.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -2640,16 +2640,15 @@ public void loadSystemRouterTables(CoreSubsets monitorCores)
26402640
@Override
26412641
@SuppressWarnings("MustBeClosed")
26422642
public void writeMemoryFast(CoreLocation gathererCore,
2643-
ChipLocation ethernetChip, String ethernetAddress, IPTag iptag,
2644-
HasChipLocation chip, MemoryLocation baseAddress, ByteBuffer data)
2643+
ChipLocation ethernetChip,
2644+
String ethernetAddress, IPTag iptag, HasChipLocation chip,
2645+
MemoryLocation baseAddress, ByteBuffer data)
26452646
throws IOException, ProcessException, InterruptedException {
26462647
FastDataIn controller = null;
26472648
synchronized (cachedDataIn) {
26482649
if (!cachedDataIn.containsKey(ethernetChip)) {
2649-
var dims = getMachineDimensions();
26502650
cachedDataIn.put(ethernetChip,
2651-
new FastDataIn(dims.width + 1, dims.height + 1,
2652-
gathererCore, this, ethernetChip,
2651+
new FastDataIn(gathererCore, this, ethernetChip,
26532652
ethernetAddress, iptag));
26542653
}
26552654
controller = cachedDataIn.get(ethernetChip);

SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/dse/BoardWorker.java

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.LinkedHashMap;
2727

2828
import uk.ac.manchester.spinnaker.machine.HasCoreLocation;
29+
import uk.ac.manchester.spinnaker.machine.MachineDimensions;
2930
import uk.ac.manchester.spinnaker.machine.MemoryLocation;
3031
import uk.ac.manchester.spinnaker.messages.model.AppID;
3132
import uk.ac.manchester.spinnaker.storage.DSEStorage;
@@ -48,6 +49,9 @@ abstract class BoardWorker {
4849
/** The system wide app id.*/
4950
private final int appId;
5051

52+
/** The dimensions of the machine.*/
53+
protected final MachineDimensions machineDimensions;
54+
5155
/** Application data magic number. */
5256
private static final int APPDATA_MAGIC_NUM = 0xAD130AD6;
5357

@@ -100,6 +104,7 @@ protected BoardWorker(TransceiverInterface txrx, Ethernet board,
100104
this.board = board;
101105
this.storage = storage;
102106
this.appId = storage.getAppId();
107+
this.machineDimensions = storage.getMachineDimensions();
103108
this.txrx = txrx;
104109
}
105110

SpiNNaker-front-end/src/main/java/uk/ac/manchester/spinnaker/front_end/dse/FastExecuteDataSpecification.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import uk.ac.manchester.spinnaker.front_end.download.request.Monitor;
3535
import uk.ac.manchester.spinnaker.machine.ChipLocation;
3636
import uk.ac.manchester.spinnaker.machine.CoreSubsets;
37+
import uk.ac.manchester.spinnaker.machine.HasChipLocation;
3738
import uk.ac.manchester.spinnaker.machine.HasCoreLocation;
3839
import uk.ac.manchester.spinnaker.machine.Machine;
3940
import uk.ac.manchester.spinnaker.machine.MemoryLocation;
@@ -221,14 +222,27 @@ private class FastBoardWorker extends BoardWorker {
221222
this.gather = gather;
222223
}
223224

225+
private HasChipLocation getBoardLocalDestination(
226+
HasChipLocation monitorChip) {
227+
int boardLocalX = monitorChip.getX() - gather.getX();
228+
if (boardLocalX < 0) {
229+
boardLocalX += machineDimensions.width;
230+
}
231+
int boardLocalY = monitorChip.getY() - gather.getY();
232+
if (boardLocalY < 0) {
233+
boardLocalY += machineDimensions.height;
234+
}
235+
return new ChipLocation(boardLocalX, boardLocalY);
236+
}
237+
224238
@Override
225239
protected int writeRegion(HasCoreLocation core, ByteBuffer content,
226240
MemoryLocation baseAddress)
227241
throws IOException, ProcessException, InterruptedException {
228242
int toWrite = content.remaining();
229243
txrx.writeMemoryFast(gather.asCoreLocation(), board.location,
230-
board.ethernetAddress, gather.getIptag(), core, baseAddress,
231-
content);
244+
board.ethernetAddress, gather.getIptag(),
245+
getBoardLocalDestination(core), baseAddress, content);
232246
return toWrite;
233247
}
234248
}

SpiNNaker-storage/src/main/java/uk/ac/manchester/spinnaker/storage/DSEStorage.java

+9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import uk.ac.manchester.spinnaker.machine.ChipLocation;
2525
import uk.ac.manchester.spinnaker.machine.CoreLocation;
26+
import uk.ac.manchester.spinnaker.machine.MachineDimensions;
2627
import uk.ac.manchester.spinnaker.machine.MemoryLocation;
2728
import uk.ac.manchester.spinnaker.utils.validation.IPAddress;
2829

@@ -103,6 +104,14 @@ void setStartAddress(CoreLocation xyp, MemoryLocation start)
103104
*/
104105
int getAppId() throws StorageException;
105106

107+
/**
108+
* Get the machine dimensions.
109+
*
110+
* @return The machine dimensions.
111+
* @throws StorageException If the database access fails.
112+
*/
113+
MachineDimensions getMachineDimensions() throws StorageException;
114+
106115
/**
107116
* Set the pointer for where to write the region data to.
108117
*

SpiNNaker-storage/src/main/java/uk/ac/manchester/spinnaker/storage/sqlite/SQL.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,10 @@ private SQL() {
258258
/** Get the app_id. */
259259
@ResultColumn("app_id")
260260
static final String GET_APP_ID =
261-
"SELECT app_id "
262-
+ "FROM app_id ";
261+
"SELECT app_id FROM info";
262+
263+
static final String GET_MACHINE_DIMENSIONS =
264+
"SELECT width, height FROM info";
263265

264266
/**
265267
* The name of the result containing the spalloc URI.

SpiNNaker-storage/src/main/java/uk/ac/manchester/spinnaker/storage/sqlite/SQLiteDataSpecStorage.java

+21
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
import java.util.List;
2626

2727
import uk.ac.manchester.spinnaker.machine.CoreLocation;
28+
import uk.ac.manchester.spinnaker.machine.MachineDimensions;
2829
import uk.ac.manchester.spinnaker.machine.MemoryLocation;
2930

3031
import static uk.ac.manchester.spinnaker.storage.sqlite.SQL.GET_APP_ID;
32+
import static uk.ac.manchester.spinnaker.storage.sqlite.SQL.GET_MACHINE_DIMENSIONS;
3133
import static uk.ac.manchester.spinnaker.storage.sqlite.SQL.GET_REGION_POINTER_AND_CONTEXT;
3234
import static uk.ac.manchester.spinnaker.storage.sqlite.SQL.GET_REGION_SIZES;
3335
import static uk.ac.manchester.spinnaker.storage.sqlite.SQL.GET_START_ADDRESS;
@@ -239,6 +241,25 @@ private int getAppId(Connection conn)
239241
throw new IllegalStateException("could not ge app id");
240242
}
241243

244+
@Override
245+
public MachineDimensions getMachineDimensions() throws StorageException {
246+
return callR(conn -> getMachineDimensions(conn),
247+
"getting machine dimensions");
248+
}
249+
250+
private MachineDimensions getMachineDimensions(Connection conn)
251+
throws SQLException {
252+
try (var s = conn.prepareStatement(GET_MACHINE_DIMENSIONS)) {
253+
try (var rs = s.executeQuery()) {
254+
while (rs.next()) {
255+
return new MachineDimensions(rs.getInt("width"),
256+
rs.getInt("height"));
257+
}
258+
}
259+
}
260+
throw new IllegalStateException("could not get machine dimensions");
261+
}
262+
242263
private static final class EthernetImpl extends Ethernet {
243264
private EthernetImpl(int etherx, int ethery, String addr) {
244265
super(etherx, ethery, addr);

0 commit comments

Comments
 (0)