• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / JavaSpiNNaker / 6233274834

19 Sep 2023 08:46AM UTC coverage: 36.409% (-0.6%) from 36.982%
6233274834

Pull #658

github

dkfellows
Merge branch 'master' into java-17
Pull Request #658: Update Java version to 17

1656 of 1656 new or added lines in 260 files covered. (100.0%)

8373 of 22997 relevant lines covered (36.41%)

0.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/SpiNNaker-comms/src/main/java/uk/ac/manchester/spinnaker/transceiver/TransceiverInterface.java
1
/*
2
 * Copyright (c) 2018 The University of Manchester
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package uk.ac.manchester.spinnaker.transceiver;
17

18
import static java.lang.Thread.sleep;
19
import static java.nio.ByteBuffer.wrap;
20
import static java.util.function.Function.identity;
21
import static java.util.stream.Collectors.toList;
22
import static java.util.stream.IntStream.range;
23
import static uk.ac.manchester.spinnaker.messages.Constants.CPU_USER_0_START_ADDRESS;
24
import static uk.ac.manchester.spinnaker.messages.Constants.CPU_USER_1_START_ADDRESS;
25
import static uk.ac.manchester.spinnaker.messages.Constants.CPU_USER_2_START_ADDRESS;
26
import static uk.ac.manchester.spinnaker.messages.Constants.NO_ROUTER_DIAGNOSTIC_FILTERS;
27
import static uk.ac.manchester.spinnaker.messages.Constants.UDP_MESSAGE_MAX_SIZE;
28
import static uk.ac.manchester.spinnaker.messages.Constants.WORD_SIZE;
29
import static uk.ac.manchester.spinnaker.messages.model.AppID.DEFAULT;
30
import static uk.ac.manchester.spinnaker.messages.model.CPUState.READY;
31
import static uk.ac.manchester.spinnaker.messages.model.CPUState.RUN_TIME_EXCEPTION;
32
import static uk.ac.manchester.spinnaker.messages.model.CPUState.WATCHDOG;
33
import static uk.ac.manchester.spinnaker.messages.model.Signal.START;
34
import static uk.ac.manchester.spinnaker.messages.model.SystemVariableDefinition.sdram_heap_address;
35
import static uk.ac.manchester.spinnaker.messages.scp.SCPRequest.BOOT_CHIP;
36
import static uk.ac.manchester.spinnaker.transceiver.CommonMemoryLocations.SYS_VARS;
37
import static uk.ac.manchester.spinnaker.transceiver.FillDataType.WORD;
38
import static uk.ac.manchester.spinnaker.transceiver.Utils.getVcpuAddress;
39
import static uk.ac.manchester.spinnaker.utils.ByteBufferUtils.wordAsBuffer;
40

41
import java.io.File;
42
import java.io.IOException;
43
import java.io.InputStream;
44
import java.net.InetAddress;
45
import java.nio.ByteBuffer;
46
import java.util.Collection;
47
import java.util.EnumSet;
48
import java.util.Formatter;
49
import java.util.List;
50
import java.util.Map;
51
import java.util.Set;
52
import java.util.TreeMap;
53

54
import javax.validation.Valid;
55
import javax.validation.constraints.NotEmpty;
56
import javax.validation.constraints.NotNull;
57
import javax.validation.constraints.Positive;
58
import javax.validation.constraints.PositiveOrZero;
59

60
import com.google.errorprone.annotations.CheckReturnValue;
61
import com.google.errorprone.annotations.MustBeClosed;
62

63
import uk.ac.manchester.spinnaker.connections.ConnectionSelector;
64
import uk.ac.manchester.spinnaker.connections.SCPConnection;
65
import uk.ac.manchester.spinnaker.connections.SDPConnection;
66
import uk.ac.manchester.spinnaker.connections.model.Connection;
67
import uk.ac.manchester.spinnaker.machine.ChipLocation;
68
import uk.ac.manchester.spinnaker.machine.CoreLocation;
69
import uk.ac.manchester.spinnaker.machine.CoreSubsets;
70
import uk.ac.manchester.spinnaker.machine.Direction;
71
import uk.ac.manchester.spinnaker.machine.HasChipLocation;
72
import uk.ac.manchester.spinnaker.machine.HasCoreLocation;
73
import uk.ac.manchester.spinnaker.machine.Machine;
74
import uk.ac.manchester.spinnaker.machine.MachineDimensions;
75
import uk.ac.manchester.spinnaker.machine.MemoryLocation;
76
import uk.ac.manchester.spinnaker.machine.MulticastRoutingEntry;
77
import uk.ac.manchester.spinnaker.machine.Processor;
78
import uk.ac.manchester.spinnaker.machine.RoutingEntry;
79
import uk.ac.manchester.spinnaker.machine.ValidP;
80
import uk.ac.manchester.spinnaker.machine.tags.IPTag;
81
import uk.ac.manchester.spinnaker.machine.tags.ReverseIPTag;
82
import uk.ac.manchester.spinnaker.machine.tags.Tag;
83
import uk.ac.manchester.spinnaker.machine.tags.TagID;
84
import uk.ac.manchester.spinnaker.messages.Constants;
85
import uk.ac.manchester.spinnaker.messages.model.AppID;
86
import uk.ac.manchester.spinnaker.messages.model.CPUInfo;
87
import uk.ac.manchester.spinnaker.messages.model.CPUState;
88
import uk.ac.manchester.spinnaker.messages.model.ChipInfo;
89
import uk.ac.manchester.spinnaker.messages.model.DiagnosticFilter;
90
import uk.ac.manchester.spinnaker.messages.model.ExecutableTargets;
91
import uk.ac.manchester.spinnaker.messages.model.HeapElement;
92
import uk.ac.manchester.spinnaker.messages.model.IOBuffer;
93
import uk.ac.manchester.spinnaker.messages.model.LEDAction;
94
import uk.ac.manchester.spinnaker.messages.model.ReinjectionStatus;
95
import uk.ac.manchester.spinnaker.messages.model.RouterDiagnostics;
96
import uk.ac.manchester.spinnaker.messages.model.RouterTimeout;
97
import uk.ac.manchester.spinnaker.messages.model.Signal;
98
import uk.ac.manchester.spinnaker.messages.model.SystemVariableDefinition;
99
import uk.ac.manchester.spinnaker.messages.model.VersionInfo;
100
import uk.ac.manchester.spinnaker.messages.scp.SCPRequest;
101
import uk.ac.manchester.spinnaker.messages.sdp.SDPMessage;
102
import uk.ac.manchester.spinnaker.storage.BufferManagerStorage;
103
import uk.ac.manchester.spinnaker.storage.StorageException;
104
import uk.ac.manchester.spinnaker.utils.MappableIterable;
105
import uk.ac.manchester.spinnaker.utils.UsedInJavadocOnly;
106

107
/**
108
 * The interface supported by the {@link Transceiver}. Emulates a lot of default
109
 * handling and variant-type handling by Python.
110
 * <p>
111
 * Note that operations on a BMP are <strong>always</strong> thread-unsafe.
112
 *
113
 * @author Donal Fellows
114
 */
115
public interface TransceiverInterface extends BMPTransceiverInterface {
116
        /**
117
         * Delay between starting a program on a core and checking to see if the
118
         * core is ready for operational use. In milliseconds.
119
         */
120
        int LAUNCH_DELAY = 500;
121

122
        /**
123
         * A marker to indicate that no timeout applies.
124
         */
125
        Integer TIMEOUT_DISABLED = null;
×
126

127
        /**
128
         * How often to poll by default.
129
         */
130
        int DEFAULT_POLL_INTERVAL = 100;
131

132
        /**
133
         * The set of states that indicate a core in a failure state.
134
         */
135
        EnumSet<CPUState> DEFAULT_ERROR_STATES =
×
136
                        EnumSet.of(RUN_TIME_EXCEPTION, WATCHDOG);
×
137

138
        /**
139
         * What proportion of checks are to be expensive full checks.
140
         */
141
        int DEFAULT_CHECK_INTERVAL = 100;
142

143
        /** How many times to try booting a board. */
144
        int BOARD_BOOT_RETRIES = 5;
145

146
        /**
147
         * @return The connection selector to use for SCP messages.
148
         */
149
        @ParallelSafe
150
        ConnectionSelector<SCPConnection> getScampConnectionSelector();
151

152
        /**
153
         * Sends an SCP message, without expecting a response.
154
         *
155
         * @param message
156
         *            The message to send
157
         * @param connection
158
         *            The connection to use (omit to pick a random one)
159
         * @throws IOException
160
         *             If anything goes wrong with networking.
161
         */
162
        @ParallelSafe
163
        void sendSCPMessage(@NotNull SCPRequest<?> message,
164
                        @NotNull SCPConnection connection) throws IOException;
165

166
        /**
167
         * Sends an SDP message using one of the connections.
168
         *
169
         * @param message
170
         *            The message to send
171
         * @throws IOException
172
         *             If anything goes wrong with networking.
173
         */
174
        @ParallelSafe
175
        default void sendSDPMessage(@NotNull SDPMessage message)
176
                        throws IOException {
177
                sendSDPMessage(message, null);
×
178
        }
×
179

180
        /**
181
         * Sends an SDP message using one of the connections.
182
         *
183
         * @param message
184
         *            The message to send
185
         * @param connection
186
         *            An optional connection to use
187
         * @throws IOException
188
         *             If anything goes wrong with networking.
189
         */
190
        @ParallelSafe
191
        void sendSDPMessage(@NotNull SDPMessage message, SDPConnection connection)
192
                        throws IOException;
193

194
        /**
195
         * Get the maximum chip x-coordinate and maximum chip y-coordinate of the
196
         * chips in the machine.
197
         * <p>
198
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
199
         * multi-threaded context unless previously called from a parallel-safe
200
         * situation.
201
         *
202
         * @return The dimensions of the machine
203
         * @throws IOException
204
         *             If anything goes wrong with networking.
205
         * @throws ProcessException
206
         *             If SpiNNaker rejects a message.
207
         * @throws InterruptedException
208
         *             If the communications were interrupted.
209
         */
210
        @ParallelSafeWithCare
211
        @CheckReturnValue
212
        MachineDimensions getMachineDimensions()
213
                        throws IOException, ProcessException, InterruptedException;
214

215
        /**
216
         * Get the details of the machine made up of chips on a board and how they
217
         * are connected to each other.
218
         * <p>
219
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
220
         * multi-threaded context unless previously called from a parallel-safe
221
         * situation.
222
         *
223
         * @return A machine description
224
         * @throws IOException
225
         *             If anything goes wrong with networking.
226
         * @throws ProcessException
227
         *             If SpiNNaker rejects a message.
228
         * @throws InterruptedException
229
         *             If the communications were interrupted.
230
         */
231
        @ParallelSafeWithCare
232
        @CheckReturnValue
233
        Machine getMachineDetails()
234
                        throws IOException, ProcessException, InterruptedException;
235

236
        /**
237
         * Determines if the board can be contacted.
238
         *
239
         * @return True if the board can be contacted, False otherwise
240
         */
241
        @ParallelSafe
242
        default boolean isConnected() {
243
                return isConnected(null);
×
244
        }
245

246
        /**
247
         * Determines if the board can be contacted.
248
         *
249
         * @param connection
250
         *            The connection which is to be tested. If {@code null}, all
251
         *            connections will be tested, and the board will be considered
252
         *            to be connected if any one connection works.
253
         * @return True if the board can be contacted, False otherwise
254
         */
255
        @ParallelSafe
256
        boolean isConnected(Connection connection);
257

258
        /**
259
         * Get the version of SCAMP which is running on the board.
260
         *
261
         * @return The version identifier
262
         * @throws IOException
263
         *             If anything goes wrong with networking.
264
         * @throws ProcessException
265
         *             If SpiNNaker rejects a message.
266
         * @throws InterruptedException
267
         *             If the communications were interrupted.
268
         */
269
        @ParallelSafe
270
        @CheckReturnValue
271
        default VersionInfo getScampVersion()
272
                        throws IOException, ProcessException, InterruptedException {
273
                return getScampVersion(BOOT_CHIP, getScampConnectionSelector());
×
274
        }
275

276
        /**
277
         * Get the version of SCAMP which is running on the board.
278
         *
279
         * @param connectionSelector
280
         *            the connection to send the SCAMP version or none (if none then
281
         *            a random SCAMP connection is used).
282
         * @return The version identifier
283
         * @throws IOException
284
         *             If anything goes wrong with networking.
285
         * @throws ProcessException
286
         *             If SpiNNaker rejects a message.
287
         * @throws InterruptedException
288
         *             If the communications were interrupted.
289
         */
290
        @ParallelSafe
291
        @CheckReturnValue
292
        default VersionInfo getScampVersion(
293
                        @NotNull ConnectionSelector<SCPConnection> connectionSelector)
294
                        throws IOException, ProcessException, InterruptedException {
295
                return getScampVersion(BOOT_CHIP, connectionSelector);
×
296
        }
297

298
        /**
299
         * Get the version of SCAMP which is running on the board.
300
         *
301
         * @param chip
302
         *            the coordinates of the chip to query for SCAMP version
303
         * @return The version identifier
304
         * @throws IOException
305
         *             If anything goes wrong with networking.
306
         * @throws ProcessException
307
         *             If SpiNNaker rejects a message.
308
         * @throws InterruptedException
309
         *             If the communications were interrupted.
310
         */
311
        @ParallelSafe
312
        @CheckReturnValue
313
        default VersionInfo getScampVersion(@Valid HasChipLocation chip)
314
                        throws IOException, ProcessException, InterruptedException {
315
                return getScampVersion(chip, getScampConnectionSelector());
×
316
        }
317

318
        /**
319
         * Get the version of SCAMP which is running on the board.
320
         *
321
         * @param connectionSelector
322
         *            the connection to send the SCAMP version or none (if none then
323
         *            a random SCAMP connection is used).
324
         * @param chip
325
         *            the coordinates of the chip to query for SCAMP version
326
         * @return The version identifier
327
         * @throws IOException
328
         *             If anything goes wrong with networking.
329
         * @throws ProcessException
330
         *             If SpiNNaker rejects a message.
331
         * @throws InterruptedException
332
         *             If the communications were interrupted.
333
         */
334
        @ParallelSafe
335
        @CheckReturnValue
336
        VersionInfo getScampVersion(@Valid HasChipLocation chip,
337
                        @NotNull ConnectionSelector<SCPConnection> connectionSelector)
338
                        throws IOException, ProcessException, InterruptedException;
339

340
        /**
341
         * Attempt to boot the board. No check is performed to see if the board is
342
         * already booted.
343
         * <p>
344
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
345
         * multi-threaded context.
346
         *
347
         * @throws IOException
348
         *             If anything goes wrong with networking.
349
         * @throws InterruptedException
350
         *             If the thread is interrupted while waiting.
351
         */
352
        @ParallelUnsafe
353
        default void bootBoard() throws InterruptedException, IOException {
354
                bootBoard(null);
×
355
        }
×
356

357
        /**
358
         * Attempt to boot the board. No check is performed to see if the board is
359
         * already booted.
360
         * <p>
361
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
362
         * multi-threaded context.
363
         *
364
         * @param extraBootValues
365
         *            extra values to set during boot
366
         * @throws IOException
367
         *             If anything goes wrong with networking.
368
         * @throws InterruptedException
369
         *             If the thread is interrupted while waiting.
370
         */
371
        @ParallelUnsafe
372
        void bootBoard(Map<SystemVariableDefinition, Object> extraBootValues)
373
                        throws InterruptedException, IOException;
374

375
        /**
376
         * Ensure that the board is ready to interact with this version of the
377
         * transceiver. Boots the board if not already booted and verifies that the
378
         * version of SCAMP running is compatible with this transceiver.
379
         * <p>
380
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
381
         * multi-threaded context.
382
         *
383
         * @return The version identifier
384
         * @throws IOException
385
         *             If anything goes wrong with networking.
386
         * @throws ProcessException
387
         *             If SpiNNaker rejects a message.
388
         * @throws InterruptedException
389
         *             If the thread is interrupted while waiting.
390
         */
391
        @ParallelUnsafe
392
        @CheckReturnValue
393
        default VersionInfo ensureBoardIsReady()
394
                        throws IOException, ProcessException, InterruptedException {
395
                return ensureBoardIsReady(BOARD_BOOT_RETRIES, null);
×
396
        }
397

398
        /**
399
         * Ensure that the board is ready to interact with this version of the
400
         * transceiver. Boots the board if not already booted and verifies that the
401
         * version of SCAMP running is compatible with this transceiver.
402
         * <p>
403
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
404
         * multi-threaded context.
405
         *
406
         * @param extraBootValues
407
         *            Any additional values to set during boot
408
         * @return The version identifier
409
         * @throws IOException
410
         *             If anything goes wrong with networking.
411
         * @throws ProcessException
412
         *             If SpiNNaker rejects a message.
413
         * @throws InterruptedException
414
         *             If the thread is interrupted while waiting.
415
         */
416
        @ParallelUnsafe
417
        @CheckReturnValue
418
        default VersionInfo ensureBoardIsReady(
419
                        Map<SystemVariableDefinition, Object> extraBootValues)
420
                        throws IOException, ProcessException, InterruptedException {
421
                return ensureBoardIsReady(BOARD_BOOT_RETRIES, extraBootValues);
×
422
        }
423

424
        /**
425
         * Ensure that the board is ready to interact with this version of the
426
         * transceiver. Boots the board if not already booted and verifies that the
427
         * version of SCAMP running is compatible with this transceiver.
428
         * <p>
429
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
430
         * multi-threaded context.
431
         *
432
         * @param numRetries
433
         *            The number of times to retry booting
434
         * @return The version identifier
435
         * @throws IOException
436
         *             If anything goes wrong with networking.
437
         * @throws ProcessException
438
         *             If SpiNNaker rejects a message.
439
         * @throws InterruptedException
440
         *             If the thread is interrupted while waiting.
441
         */
442
        @ParallelUnsafe
443
        default VersionInfo ensureBoardIsReady(@PositiveOrZero int numRetries)
444
                        throws IOException, ProcessException, InterruptedException {
445
                return ensureBoardIsReady(numRetries, null);
×
446
        }
447

448
        /**
449
         * Ensure that the board is ready to interact with this version of the
450
         * transceiver. Boots the board if not already booted and verifies that the
451
         * version of SCAMP running is compatible with this transceiver.
452
         * <p>
453
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
454
         * multi-threaded context.
455
         *
456
         * @param numRetries
457
         *            The number of times to retry booting
458
         * @param extraBootValues
459
         *            Any additional values to set during boot
460
         * @return The version identifier
461
         * @throws IOException
462
         *             If anything goes wrong with networking.
463
         * @throws ProcessException
464
         *             If SpiNNaker rejects a message.
465
         * @throws InterruptedException
466
         *             If the thread is interrupted while waiting.
467
         */
468
        @ParallelUnsafe
469
        VersionInfo ensureBoardIsReady(@PositiveOrZero int numRetries,
470
                        Map<SystemVariableDefinition, Object> extraBootValues)
471
                        throws IOException, ProcessException, InterruptedException;
472

473
        /**
474
         * Get information about the processors on the board.
475
         * <p>
476
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
477
         * multi-threaded context.
478
         *
479
         * @return An iterable of the CPU information for all cores.
480
         * @throws IOException
481
         *             If anything goes wrong with networking.
482
         * @throws ProcessException
483
         *             If SpiNNaker rejects a message.
484
         * @throws InterruptedException
485
         *             If the communications were interrupted.
486
         */
487
        @ParallelUnsafe
488
        @CheckReturnValue
489
        default MappableIterable<CPUInfo> getCPUInformation()
490
                        throws IOException, ProcessException, InterruptedException {
491
                return getCPUInformation((CoreSubsets) null);
×
492
        }
493

494
        /**
495
         * Get information about a specific processor on the board.
496
         *
497
         * @param core
498
         *            The coordinates of the core to get the information about
499
         * @return The CPU information for the selected core
500
         * @throws IOException
501
         *             If anything goes wrong with networking.
502
         * @throws ProcessException
503
         *             If SpiNNaker rejects a message.
504
         * @throws InterruptedException
505
         *             If the communications were interrupted.
506
         */
507
        @ParallelSafe
508
        @CheckReturnValue
509
        default CPUInfo getCPUInformation(@Valid HasCoreLocation core)
510
                        throws IOException, ProcessException, InterruptedException {
511
                return getCPUInformation(new CoreSubsets(core)).first().orElseThrow();
×
512
        }
513

514
        /**
515
         * Get information about some processors on the board.
516
         * <p>
517
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
518
         * multi-threaded context unless the {@code coreSubsets} only contains cores
519
         * on a single board.
520
         *
521
         * @param coreSubsets
522
         *            A set of chips and cores from which to get the information. If
523
         *            {@code null}, the information from all of the cores on all of
524
         *            the chips on the board are obtained.
525
         * @return An iterable of the CPU information for the selected cores, or all
526
         *         cores if {@code coreSubsets} is {@code null}.
527
         * @throws IOException
528
         *             If anything goes wrong with networking.
529
         * @throws ProcessException
530
         *             If SpiNNaker rejects a message.
531
         * @throws InterruptedException
532
         *             If the communications were interrupted.
533
         */
534
        @ParallelSafeWithCare
535
        @CheckReturnValue
536
        MappableIterable<CPUInfo> getCPUInformation(@Valid CoreSubsets coreSubsets)
537
                        throws IOException, ProcessException, InterruptedException;
538

539
        /**
540
         * Get the full information about the chip. This is obtained by reading the
541
         * full system variable block for the chip. <em>This is an operation that
542
         * takes a bit of time; the view is not guaranteed to be internally
543
         * consistent though most values are very unlikely to change during the
544
         * read.</em>
545
         *
546
         * @param chip
547
         *            Which chip are we getting information about?
548
         * @return A full description of the chip.
549
         * @throws IOException
550
         *             If anything goes wrong with networking.
551
         * @throws ProcessException
552
         *             If SpiNNaker rejects a message.
553
         * @throws InterruptedException
554
         *             If the communications were interrupted.
555
         */
556
        @ParallelSafeWithCare
557
        @CheckReturnValue
558
        default ChipInfo getFullChipInformation(HasChipLocation chip)
559
                        throws IOException, ProcessException, InterruptedException {
560
                var buffer = readMemory(chip, SYS_VARS, UDP_MESSAGE_MAX_SIZE);
×
561
                return new ChipInfo(buffer);
×
562
        }
563

564
        /**
565
         * Get the address of user<sub>0</sub> for a given processor on the board.
566
         * <i>This does not read from the processor.</i>
567
         *
568
         * @param core
569
         *            the coordinates of the core to get the user<sub>0</sub>
570
         *            address for
571
         * @return The address for user<sub>0</sub> register for this processor
572
         */
573
        @ParallelSafe
574
        default MemoryLocation getUser0RegisterAddress(
575
                        @Valid HasCoreLocation core) {
576
                return getVcpuAddress(core).add(CPU_USER_0_START_ADDRESS);
×
577
        }
578

579
        /**
580
         * Get the address of user<sub>0</sub> for a given processor on the board.
581
         * <i>This does not read from the processor.</i>
582
         *
583
         * @param p
584
         *            the processor ID to get the user<sub>0</sub> address for
585
         * @return The address for user<sub>0</sub> register for this processor
586
         */
587
        @ParallelSafe
588
        default MemoryLocation getUser0RegisterAddress(@ValidP int p) {
589
                return getVcpuAddress(p).add(CPU_USER_0_START_ADDRESS);
×
590
        }
591

592
        /**
593
         * Get the address of user<sub>0</sub> for a given processor on the board.
594
         * <i>This does not read from the processor.</i>
595
         *
596
         * @param processor
597
         *            the processor to get the user<sub>0</sub> address for
598
         * @return The address for user<sub>0</sub> register for this processor
599
         */
600
        @ParallelSafe
601
        default MemoryLocation getUser0RegisterAddress(@Valid Processor processor) {
602
                return getVcpuAddress(processor.processorId)
×
603
                                .add(CPU_USER_0_START_ADDRESS);
×
604
        }
605

606
        /**
607
         * Get the address of user<sub>1</sub> for a given processor on the board.
608
         * <i>This does not read from the processor.</i>
609
         *
610
         * @param core
611
         *            the coordinates of the core to get the user<sub>1</sub>
612
         *            address for
613
         * @return The address for user<sub>1</sub> register for this processor
614
         */
615
        @ParallelSafe
616
        default MemoryLocation getUser1RegisterAddress(
617
                        @Valid HasCoreLocation core) {
618
                return getVcpuAddress(core).add(CPU_USER_1_START_ADDRESS);
×
619
        }
620

621
        /**
622
         * Get the address of user<sub>1</sub> for a given processor on the board.
623
         * <i>This does not read from the processor.</i>
624
         *
625
         * @param p
626
         *            the processor ID to get the user<sub>1</sub> address for
627
         * @return The address for user<sub>1</sub> register for this processor;
628
         *         this will be in System RAM and be accessible from any core of the
629
         *         chip.
630
         */
631
        @ParallelSafe
632
        default MemoryLocation getUser1RegisterAddress(@ValidP int p) {
633
                return getVcpuAddress(p).add(CPU_USER_1_START_ADDRESS);
×
634
        }
635

636
        /**
637
         * Get the address of user<sub>1</sub> for a given processor on the board.
638
         * <i>This does not read from the processor.</i>
639
         *
640
         * @param processor
641
         *            the processor to get the user<sub>1</sub> address for
642
         * @return The address for user<sub>1</sub> register for this processor;
643
         *         this will be in System RAM and be accessible from any core of the
644
         *         chip.
645
         */
646
        @ParallelSafe
647
        default MemoryLocation getUser1RegisterAddress(@Valid Processor processor) {
648
                return getVcpuAddress(processor.processorId)
×
649
                                .add(CPU_USER_1_START_ADDRESS);
×
650
        }
651

652
        /**
653
         * Get the address of user<sub>2</sub> for a given processor on the board.
654
         * <i>This does not read from the processor.</i>
655
         *
656
         * @param core
657
         *            the coordinates of the core to get the user<sub>2</sub>
658
         *            address for
659
         * @return The address for user<sub>2</sub> register for this processor;
660
         *         this will be in System RAM and be accessible from any core of the
661
         *         chip.
662
         */
663
        @ParallelSafe
664
        default MemoryLocation getUser2RegisterAddress(
665
                        @Valid HasCoreLocation core) {
666
                return getVcpuAddress(core).add(CPU_USER_2_START_ADDRESS);
×
667
        }
668

669
        /**
670
         * Get the address of user<sub>2</sub> for a given processor on the board.
671
         * <i>This does not read from the processor.</i>
672
         *
673
         * @param p
674
         *            the processor ID to get the user<sub>2</sub> address for
675
         * @return The address for user<sub>0</sub> register for this processor
676
         */
677
        @ParallelSafe
678
        default MemoryLocation getUser2RegisterAddress(@ValidP int p) {
679
                return getVcpuAddress(p).add(CPU_USER_2_START_ADDRESS);
×
680
        }
681

682
        /**
683
         * Get the address of user<sub>2</sub> for a given processor on the board.
684
         * <i>This does not read from the processor.</i>
685
         *
686
         * @param processor
687
         *            the processor to get the user<sub>2</sub> address for
688
         * @return The address for user<sub>0</sub> register for this processor
689
         */
690
        @ParallelSafe
691
        default MemoryLocation getUser2RegisterAddress(@Valid Processor processor) {
692
                return getVcpuAddress(processor.processorId)
×
693
                                .add(CPU_USER_2_START_ADDRESS);
×
694
        }
695

696
        /**
697
         * Get the contents of the IOBUF buffer for all processors.
698
         *
699
         * @return An iterable of the buffers, order undetermined.
700
         * @throws IOException
701
         *             If anything goes wrong with networking.
702
         * @throws ProcessException
703
         *             If SpiNNaker rejects a message.
704
         * @throws InterruptedException
705
         *             If the communications were interrupted.
706
         */
707
        @ParallelUnsafe
708
        @CheckReturnValue
709
        default MappableIterable<IOBuffer> getIobuf()
710
                        throws IOException, ProcessException, InterruptedException {
711
                return getIobuf((CoreSubsets) null);
×
712
        }
713

714
        /**
715
         * Get the contents of IOBUF for a given core.
716
         *
717
         * @param core
718
         *            The coordinates of the processor to get the IOBUF for
719
         * @return An IOBUF buffer
720
         * @throws IOException
721
         *             If anything goes wrong with networking.
722
         * @throws ProcessException
723
         *             If SpiNNaker rejects a message.
724
         * @throws InterruptedException
725
         *             If the communications were interrupted.
726
         */
727
        @ParallelSafe
728
        @CheckReturnValue
729
        default IOBuffer getIobuf(@Valid HasCoreLocation core)
730
                        throws IOException, ProcessException, InterruptedException {
731
                return getIobuf(new CoreSubsets(core)).first().orElseThrow();
×
732
        }
733

734
        /**
735
         * Get the contents of the IOBUF buffer for a collection of processors.
736
         *
737
         * @param coreSubsets
738
         *            A set of chips and cores from which to get the buffers.
739
         * @return An iterable of the buffers, which may not be in the order of
740
         *         {@code coreSubsets}
741
         * @throws IOException
742
         *             If anything goes wrong with networking.
743
         * @throws ProcessException
744
         *             If SpiNNaker rejects a message.
745
         * @throws InterruptedException
746
         *             If the communications were interrupted.
747
         */
748
        @ParallelSafeWithCare
749
        @CheckReturnValue
750
        MappableIterable<IOBuffer> getIobuf(@Valid CoreSubsets coreSubsets)
751
                        throws IOException, ProcessException, InterruptedException;
752

753
        /**
754
         * Clear the contents of the IOBUF buffer for all processors.
755
         *
756
         * @throws IOException
757
         *             If anything goes wrong with networking.
758
         * @throws ProcessException
759
         *             If SpiNNaker rejects a message.
760
         * @throws InterruptedException
761
         *             If the communications were interrupted.
762
         */
763
        @ParallelUnsafe
764
        default void clearIobuf()
765
                        throws IOException, ProcessException, InterruptedException {
766
                clearIobuf((CoreSubsets) null);
×
767
        }
×
768

769
        /**
770
         * Clear the contents of the IOBUF buffer for a given core.
771
         *
772
         * @param core
773
         *            The coordinates of the processor to clear the IOBUF on.
774
         * @throws IOException
775
         *             If anything goes wrong with networking.
776
         * @throws ProcessException
777
         *             If SpiNNaker rejects a message.
778
         * @throws InterruptedException
779
         *             If the communications were interrupted.
780
         */
781
        @ParallelSafe
782
        default void clearIobuf(@Valid HasCoreLocation core)
783
                        throws IOException, ProcessException, InterruptedException {
784
                clearIobuf(new CoreSubsets(core));
×
785
        }
×
786

787
        /**
788
         * Clear the contents of the IOBUF buffer for a collection of processors.
789
         *
790
         * @param coreSubsets
791
         *            A set of chips and cores on which to clear the buffers.
792
         * @throws IOException
793
         *             If anything goes wrong with networking.
794
         * @throws ProcessException
795
         *             If SpiNNaker rejects a message.
796
         * @throws InterruptedException
797
         *             If the communications were interrupted.
798
         */
799
        @ParallelSafeWithCare
800
        void clearIobuf(@Valid CoreSubsets coreSubsets)
801
                        throws IOException, ProcessException, InterruptedException;
802

803
        /**
804
         * Set the value of the watch dog timer on a specific chip.
805
         *
806
         * @param chip
807
         *            coordinates of the chip to write new watchdog parameter to
808
         * @param watchdog
809
         *            value to set the timer count to
810
         * @throws IOException
811
         *             If anything goes wrong with networking.
812
         * @throws ProcessException
813
         *             If SpiNNaker rejects a message.
814
         * @throws InterruptedException
815
         *             If the communications were interrupted.
816
         */
817
        @ParallelSafe
818
        void setWatchDogTimeoutOnChip(@Valid HasChipLocation chip, int watchdog)
819
                        throws IOException, ProcessException, InterruptedException;
820

821
        /**
822
         * Enable or disable the watch dog timer on a specific chip.
823
         *
824
         * @param chip
825
         *            coordinates of the chip to write new watchdog parameter to
826
         * @param watchdog
827
         *            whether to enable (True) or disable (False) the watchdog timer
828
         * @throws IOException
829
         *             If anything goes wrong with networking.
830
         * @throws ProcessException
831
         *             If SpiNNaker rejects a message.
832
         * @throws InterruptedException
833
         *             If the communications were interrupted.
834
         */
835
        @ParallelSafe
836
        void enableWatchDogTimerOnChip(@Valid HasChipLocation chip,
837
                        boolean watchdog)
838
                        throws IOException, ProcessException, InterruptedException;
839

840
        /**
841
         * Set the value of the watch dog timer.
842
         *
843
         * @param watchdog
844
         *            value to set the timer count to.
845
         * @throws IOException
846
         *             If anything goes wrong with networking.
847
         * @throws ProcessException
848
         *             If SpiNNaker rejects a message.
849
         * @throws InterruptedException
850
         *             If the communications were interrupted.
851
         */
852
        @ParallelUnsafe
853
        default void setWatchDogTimeout(int watchdog)
854
                        throws IOException, ProcessException, InterruptedException {
855
                for (var chip : getMachineDetails().chipCoordinates()) {
×
856
                        setWatchDogTimeoutOnChip(chip, watchdog);
×
857
                }
×
858
        }
×
859

860
        /**
861
         * Enable or disable the watch dog timer.
862
         *
863
         * @param watchdog
864
         *            whether to enable (True) or disable (False) the watch dog
865
         *            timer
866
         * @throws IOException
867
         *             If anything goes wrong with networking.
868
         * @throws ProcessException
869
         *             If SpiNNaker rejects a message.
870
         * @throws InterruptedException
871
         *             If the communications were interrupted.
872
         */
873
        @ParallelUnsafe
874
        default void enableWatchDogTimer(boolean watchdog)
875
                        throws IOException, ProcessException, InterruptedException {
876
                for (var chip : getMachineDetails().chipCoordinates()) {
×
877
                        enableWatchDogTimerOnChip(chip, watchdog);
×
878
                }
×
879
        }
×
880

881
        /**
882
         * Get a count of the number of cores which have a given state.
883
         * <p>
884
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
885
         * multi-threaded context.
886
         *
887
         * @param appID
888
         *            The ID of the application from which to get the count.
889
         * @param state
890
         *            The state count to get
891
         * @return A count of the cores with the given status
892
         * @throws IOException
893
         *             If anything goes wrong with networking.
894
         * @throws ProcessException
895
         *             If SpiNNaker rejects a message.
896
         * @throws InterruptedException
897
         *             If the communications were interrupted.
898
         */
899
        @ParallelUnsafe
900
        @CheckReturnValue
901
        int getCoreStateCount(@NotNull AppID appID, @NotNull CPUState state)
902
                        throws IOException, ProcessException, InterruptedException;
903

904
        /**
905
         * Start an executable running on a single core.
906
         *
907
         * @param core
908
         *            The coordinates of the core on which to run the executable
909
         * @param executable
910
         *            The data that is to be executed.
911
         * @param numBytes
912
         *            The number of bytes to read from the input stream.
913
         * @param appID
914
         *            The ID of the application with which to associate the
915
         *            executable
916
         * @throws IOException
917
         *             If anything goes wrong with networking or with reading from
918
         *             the input stream.
919
         * @throws ProcessException
920
         *             If SpiNNaker rejects a message.
921
         * @throws InterruptedException
922
         *             If the thread is interrupted while waiting.
923
         */
924
        @ParallelSafe
925
        default void execute(@Valid HasCoreLocation core,
926
                        @NotNull InputStream executable, @Positive int numBytes,
927
                        @NotNull AppID appID)
928
                        throws IOException, ProcessException, InterruptedException {
929
                execute(core, Set.of(core.getP()), executable, numBytes, appID);
×
930
        }
×
931

932
        /**
933
         * Start an executable running on a single chip.
934
         *
935
         * @param chip
936
         *            The coordinates of the chip on which to run the executable
937
         * @param processors
938
         *            The cores on the chip on which to run the application
939
         * @param executable
940
         *            The data that is to be executed.
941
         * @param numBytes
942
         *            The number of bytes to read from the input stream.
943
         * @param appID
944
         *            The ID of the application with which to associate the
945
         *            executable
946
         * @throws IOException
947
         *             If anything goes wrong with networking or with reading from
948
         *             the input stream.
949
         * @throws ProcessException
950
         *             If SpiNNaker rejects a message.
951
         * @throws InterruptedException
952
         *             If the thread is interrupted while waiting.
953
         */
954
        @ParallelSafe
955
        default void execute(@Valid HasChipLocation chip,
956
                        Collection<@ValidP Integer> processors,
957
                        @NotNull InputStream executable, @Positive int numBytes,
958
                        @NotNull AppID appID)
959
                        throws IOException, ProcessException, InterruptedException {
960
                execute(chip, processors, executable, numBytes, appID, false);
×
961
        }
×
962

963
        /**
964
         * Start an executable running on a single core.
965
         *
966
         * @param core
967
         *            The coordinates of the core on which to run the executable
968
         * @param executable
969
         *            The data that is to be executed.
970
         * @param numBytes
971
         *            The number of bytes to read from the input stream.
972
         * @param appID
973
         *            The ID of the application with which to associate the
974
         *            executable
975
         * @param wait
976
         *            True if the binary should enter a "wait" state on loading
977
         * @throws IOException
978
         *             If anything goes wrong with networking or with reading from
979
         *             the input stream.
980
         * @throws ProcessException
981
         *             If SpiNNaker rejects a message.
982
         * @throws InterruptedException
983
         *             If the thread is interrupted while waiting.
984
         */
985
        @ParallelSafe
986
        default void execute(@Valid HasCoreLocation core,
987
                        @NotNull InputStream executable, @Positive int numBytes,
988
                        @NotNull AppID appID, boolean wait)
989
                        throws IOException, ProcessException, InterruptedException {
990
                execute(core, Set.of(core.getP()), executable, numBytes, appID,
×
991
                                wait);
992
        }
×
993

994
        /**
995
         * Start an executable running on a single chip.
996
         *
997
         * @param chip
998
         *            The coordinates of the chip on which to run the executable
999
         * @param processors
1000
         *            The cores on the chip on which to run the application
1001
         * @param executable
1002
         *            The data that is to be executed.
1003
         * @param numBytes
1004
         *            The number of bytes to read from the input stream.
1005
         * @param appID
1006
         *            The ID of the application with which to associate the
1007
         *            executable
1008
         * @param wait
1009
         *            True if the binary should enter a "wait" state on loading
1010
         * @throws IOException
1011
         *             If anything goes wrong with networking or with reading from
1012
         *             the input stream.
1013
         * @throws ProcessException
1014
         *             If SpiNNaker rejects a message.
1015
         * @throws InterruptedException
1016
         *             If the thread is interrupted while waiting.
1017
         */
1018
        @ParallelSafe
1019
        void execute(@Valid HasChipLocation chip,
1020
                        Collection<@ValidP Integer> processors,
1021
                        @NotNull InputStream executable, @Positive int numBytes,
1022
                        @NotNull AppID appID, boolean wait)
1023
                        throws IOException, ProcessException, InterruptedException;
1024

1025
        /**
1026
         * Start an executable running on a single core.
1027
         *
1028
         * @param core
1029
         *            The coordinates of the core on which to run the executable
1030
         * @param executable
1031
         *            The data that is to be executed.
1032
         * @param appID
1033
         *            The ID of the application with which to associate the
1034
         *            executable
1035
         * @throws IOException
1036
         *             If anything goes wrong with networking or with reading from
1037
         *             the file.
1038
         * @throws ProcessException
1039
         *             If SpiNNaker rejects a message.
1040
         * @throws InterruptedException
1041
         *             If the thread is interrupted while waiting.
1042
         */
1043
        @ParallelSafe
1044
        default void execute(@Valid HasCoreLocation core, @NotNull File executable,
1045
                        @NotNull AppID appID)
1046
                        throws IOException, ProcessException, InterruptedException {
1047
                execute(core, Set.of(core.getP()), executable, appID, false);
×
1048
        }
×
1049

1050
        /**
1051
         * Start an executable running on a single chip.
1052
         *
1053
         * @param chip
1054
         *            The coordinates of the chip on which to run the executable
1055
         * @param processors
1056
         *            The cores on the chip on which to run the application
1057
         * @param executable
1058
         *            The data that is to be executed.
1059
         * @param appID
1060
         *            The ID of the application with which to associate the
1061
         *            executable
1062
         * @throws IOException
1063
         *             If anything goes wrong with networking or with reading from
1064
         *             the file.
1065
         * @throws ProcessException
1066
         *             If SpiNNaker rejects a message.
1067
         * @throws InterruptedException
1068
         *             If the thread is interrupted while waiting.
1069
         */
1070
        @ParallelSafe
1071
        default void execute(@Valid HasChipLocation chip,
1072
                        Collection<@ValidP Integer> processors, @NotNull File executable,
1073
                        @NotNull AppID appID)
1074
                        throws IOException, ProcessException, InterruptedException {
1075
                execute(chip, processors, executable, appID, false);
×
1076
        }
×
1077

1078
        /**
1079
         * Start an executable running on a single core.
1080
         *
1081
         * @param core
1082
         *            The coordinates of the core on which to run the executable
1083
         * @param executable
1084
         *            The data that is to be executed.
1085
         * @param appID
1086
         *            The ID of the application with which to associate the
1087
         *            executable
1088
         * @param wait
1089
         *            True if the binary should enter a "wait" state on loading
1090
         * @throws IOException
1091
         *             If anything goes wrong with networking or with reading from
1092
         *             the file.
1093
         * @throws ProcessException
1094
         *             If SpiNNaker rejects a message.
1095
         * @throws InterruptedException
1096
         *             If the thread is interrupted while waiting.
1097
         */
1098
        @ParallelSafe
1099
        default void execute(@Valid HasCoreLocation core, @NotNull File executable,
1100
                        @NotNull AppID appID, boolean wait)
1101
                        throws IOException, ProcessException, InterruptedException {
1102
                execute(core, Set.of(core.getP()), executable, appID, wait);
×
1103
        }
×
1104

1105
        /**
1106
         * Start an executable running on a single chip.
1107
         *
1108
         * @param chip
1109
         *            The coordinates of the chip on which to run the executable
1110
         * @param processors
1111
         *            The cores on the chip on which to run the application
1112
         * @param executable
1113
         *            The data that is to be executed.
1114
         * @param appID
1115
         *            The ID of the application with which to associate the
1116
         *            executable
1117
         * @param wait
1118
         *            True if the binary should enter a "wait" state on loading
1119
         * @throws IOException
1120
         *             If anything goes wrong with networking or with reading from
1121
         *             the file.
1122
         * @throws ProcessException
1123
         *             If SpiNNaker rejects a message.
1124
         * @throws InterruptedException
1125
         *             If the thread is interrupted while waiting.
1126
         */
1127
        @ParallelSafe
1128
        void execute(@Valid HasChipLocation chip,
1129
                        Collection<@ValidP Integer> processors, @NotNull File executable,
1130
                        @NotNull AppID appID, boolean wait)
1131
                        throws IOException, ProcessException, InterruptedException;
1132

1133
        /**
1134
         * Start an executable running on a single core.
1135
         *
1136
         * @param core
1137
         *            The coordinates of the core on which to run the executable
1138
         * @param executable
1139
         *            The data that is to be executed.
1140
         * @param appID
1141
         *            The ID of the application with which to associate the
1142
         *            executable
1143
         * @throws IOException
1144
         *             If anything goes wrong with networking.
1145
         * @throws ProcessException
1146
         *             If SpiNNaker rejects a message.
1147
         * @throws InterruptedException
1148
         *             If the thread is interrupted while waiting.
1149
         */
1150
        @ParallelSafe
1151
        default void execute(@Valid HasCoreLocation core,
1152
                        @NotNull ByteBuffer executable, @NotNull AppID appID)
1153
                        throws IOException, ProcessException, InterruptedException {
1154
                execute(core, Set.of(core.getP()), executable, appID, false);
×
1155
        }
×
1156

1157
        /**
1158
         * Start an executable running on a single chip.
1159
         *
1160
         * @param chip
1161
         *            The coordinates of the chip on which to run the executable
1162
         * @param processors
1163
         *            The cores on the chip on which to run the application
1164
         * @param executable
1165
         *            The data that is to be executed.
1166
         * @param appID
1167
         *            The ID of the application with which to associate the
1168
         *            executable
1169
         * @throws IOException
1170
         *             If anything goes wrong with networking.
1171
         * @throws ProcessException
1172
         *             If SpiNNaker rejects a message.
1173
         * @throws InterruptedException
1174
         *             If the thread is interrupted while waiting.
1175
         */
1176
        @ParallelSafe
1177
        default void execute(@Valid HasChipLocation chip,
1178
                        Collection<@ValidP Integer> processors,
1179
                        @NotNull ByteBuffer executable, @NotNull AppID appID)
1180
                        throws IOException, ProcessException, InterruptedException {
1181
                execute(chip, processors, executable, appID, false);
×
1182
        }
×
1183

1184
        /**
1185
         * Start an executable running on a single core.
1186
         *
1187
         * @param core
1188
         *            The coordinates of the core on which to run the executable
1189
         * @param executable
1190
         *            The data that is to be executed.
1191
         * @param appID
1192
         *            The ID of the application with which to associate the
1193
         *            executable
1194
         * @param wait
1195
         *            True if the binary should enter a "wait" state on loading
1196
         * @throws IOException
1197
         *             If anything goes wrong with networking.
1198
         * @throws ProcessException
1199
         *             If SpiNNaker rejects a message.
1200
         * @throws InterruptedException
1201
         *             If the thread is interrupted while waiting.
1202
         */
1203
        @ParallelSafe
1204
        default void execute(@Valid HasCoreLocation core,
1205
                        @NotNull ByteBuffer executable, @NotNull AppID appID, boolean wait)
1206
                        throws IOException, ProcessException, InterruptedException {
1207
                execute(core, Set.of(core.getP()), executable, appID, wait);
×
1208
        }
×
1209

1210
        /**
1211
         * Start an executable running on a single chip.
1212
         *
1213
         * @param chip
1214
         *            The coordinates of the chip on which to run the executable
1215
         * @param processors
1216
         *            The cores on the chip on which to run the application
1217
         * @param executable
1218
         *            The data that is to be executed.
1219
         * @param appID
1220
         *            The ID of the application with which to associate the
1221
         *            executable
1222
         * @param wait
1223
         *            True if the binary should enter a "wait" state on loading
1224
         * @throws IOException
1225
         *             If anything goes wrong with networking.
1226
         * @throws ProcessException
1227
         *             If SpiNNaker rejects a message.
1228
         * @throws InterruptedException
1229
         *             If the thread is interrupted while waiting.
1230
         */
1231
        @ParallelSafe
1232
        void execute(HasChipLocation chip, Collection<Integer> processors,
1233
                        ByteBuffer executable, AppID appID, boolean wait)
1234
                        throws IOException, ProcessException, InterruptedException;
1235

1236
        /**
1237
         * Start an executable running on multiple places on the board. This will be
1238
         * optimised based on the selected cores, but it may still require a number
1239
         * of communications with the board to execute.
1240
         * <p>
1241
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1242
         * multi-threaded context.
1243
         *
1244
         * @param coreSubsets
1245
         *            Which cores on which chips to start the executable
1246
         * @param executable
1247
         *            The data that is to be executed.
1248
         * @param numBytes
1249
         *            The size of the executable data in bytes.
1250
         * @param appID
1251
         *            The ID of the application with which to associate the
1252
         *            executable
1253
         * @throws IOException
1254
         *             If anything goes wrong with networking or with reading from
1255
         *             the input stream.
1256
         * @throws ProcessException
1257
         *             If SpiNNaker rejects a message.
1258
         * @throws InterruptedException
1259
         *             If the thread is interrupted while waiting.
1260
         */
1261
        @ParallelSafeWithCare
1262
        default void executeFlood(@Valid CoreSubsets coreSubsets,
1263
                        @NotNull InputStream executable, @Positive int numBytes,
1264
                        @NotNull AppID appID)
1265
                        throws IOException, ProcessException, InterruptedException {
1266
                executeFlood(coreSubsets, executable, numBytes, appID, false);
×
1267
        }
×
1268

1269
        /**
1270
         * Start an executable running on multiple places on the board. This will be
1271
         * optimised based on the selected cores, but it may still require a number
1272
         * of communications with the board to execute.
1273
         * <p>
1274
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1275
         * multi-threaded context.
1276
         *
1277
         * @param coreSubsets
1278
         *            Which cores on which chips to start the executable
1279
         * @param executable
1280
         *            The data that is to be executed.
1281
         * @param numBytes
1282
         *            The size of the executable data in bytes.
1283
         * @param appID
1284
         *            The ID of the application with which to associate the
1285
         *            executable
1286
         * @param wait
1287
         *            True if the processors should enter a "wait" state on loading
1288
         * @throws IOException
1289
         *             If anything goes wrong with networking or with reading from
1290
         *             the input stream.
1291
         * @throws ProcessException
1292
         *             If SpiNNaker rejects a message.
1293
         * @throws InterruptedException
1294
         *             If the thread is interrupted while waiting.
1295
         */
1296
        @ParallelSafeWithCare
1297
        void executeFlood(@Valid CoreSubsets coreSubsets,
1298
                        @NotNull InputStream executable, @Positive int numBytes,
1299
                        @NotNull AppID appID, boolean wait)
1300
                        throws IOException, ProcessException, InterruptedException;
1301

1302
        /**
1303
         * Start an executable running on multiple places on the board. This will be
1304
         * optimised based on the selected cores, but it may still require a number
1305
         * of communications with the board to execute.
1306
         * <p>
1307
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1308
         * multi-threaded context.
1309
         *
1310
         * @param coreSubsets
1311
         *            Which cores on which chips to start the executable
1312
         * @param executable
1313
         *            The data that is to be executed.
1314
         * @param appID
1315
         *            The ID of the application with which to associate the
1316
         *            executable
1317
         * @throws IOException
1318
         *             If anything goes wrong with networking or with reading from
1319
         *             the file.
1320
         * @throws ProcessException
1321
         *             If SpiNNaker rejects a message.
1322
         * @throws InterruptedException
1323
         *             If the thread is interrupted while waiting.
1324
         */
1325
        @ParallelSafeWithCare
1326
        default void executeFlood(@Valid CoreSubsets coreSubsets,
1327
                        @NotNull File executable, @NotNull AppID appID)
1328
                        throws IOException, ProcessException, InterruptedException {
1329
                executeFlood(coreSubsets, executable, appID, false);
×
1330
        }
×
1331

1332
        /**
1333
         * Start an executable running on multiple places on the board. This will be
1334
         * optimised based on the selected cores, but it may still require a number
1335
         * of communications with the board to execute.
1336
         * <p>
1337
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1338
         * multi-threaded context.
1339
         *
1340
         * @param coreSubsets
1341
         *            Which cores on which chips to start the executable
1342
         * @param executable
1343
         *            The data that is to be executed.
1344
         * @param appID
1345
         *            The ID of the application with which to associate the
1346
         *            executable
1347
         * @param wait
1348
         *            True if the processors should enter a "wait" state on loading
1349
         * @throws IOException
1350
         *             If anything goes wrong with networking or with reading from
1351
         *             the file.
1352
         * @throws ProcessException
1353
         *             If SpiNNaker rejects a message.
1354
         * @throws InterruptedException
1355
         *             If the thread is interrupted while waiting.
1356
         */
1357
        @ParallelSafeWithCare
1358
        void executeFlood(@Valid CoreSubsets coreSubsets, @NotNull File executable,
1359
                        @NotNull AppID appID, boolean wait)
1360
                        throws IOException, ProcessException, InterruptedException;
1361

1362
        /**
1363
         * Start an executable running on multiple places on the board. This will be
1364
         * optimised based on the selected cores, but it may still require a number
1365
         * of communications with the board to execute.
1366
         * <p>
1367
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1368
         * multi-threaded context.
1369
         *
1370
         * @param coreSubsets
1371
         *            Which cores on which chips to start the executable
1372
         * @param executable
1373
         *            The data that is to be executed.
1374
         * @param appID
1375
         *            The ID of the application with which to associate the
1376
         *            executable
1377
         * @throws IOException
1378
         *             If anything goes wrong with networking.
1379
         * @throws ProcessException
1380
         *             If SpiNNaker rejects a message.
1381
         * @throws InterruptedException
1382
         *             If the thread is interrupted while waiting.
1383
         */
1384
        @ParallelSafeWithCare
1385
        default void executeFlood(@Valid CoreSubsets coreSubsets,
1386
                        @NotNull ByteBuffer executable, @NotNull AppID appID)
1387
                        throws IOException, ProcessException, InterruptedException {
1388
                executeFlood(coreSubsets, executable, appID, false);
×
1389
        }
×
1390

1391
        /**
1392
         * Start an executable running on multiple places on the board. This will be
1393
         * optimised based on the selected cores, but it may still require a number
1394
         * of communications with the board to execute.
1395
         * <p>
1396
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1397
         * multi-threaded context.
1398
         *
1399
         * @param coreSubsets
1400
         *            Which cores on which chips to start the executable
1401
         * @param executable
1402
         *            The data that is to be executed.
1403
         * @param appID
1404
         *            The ID of the application with which to associate the
1405
         *            executable
1406
         * @param wait
1407
         *            True if the processors should enter a "wait" state on loading
1408
         * @throws IOException
1409
         *             If anything goes wrong with networking.
1410
         * @throws ProcessException
1411
         *             If SpiNNaker rejects a message.
1412
         * @throws InterruptedException
1413
         *             If the thread is interrupted while waiting.
1414
         */
1415
        @ParallelSafeWithCare
1416
        void executeFlood(@Valid CoreSubsets coreSubsets,
1417
                        @NotNull ByteBuffer executable, @NotNull AppID appID, boolean wait)
1418
                        throws IOException, ProcessException, InterruptedException;
1419

1420
        /**
1421
         * Execute a set of binaries that make up a complete application on
1422
         * specified cores, wait for them to be ready and then start all of the
1423
         * binaries. Note this will get the binaries into {@code c_main()} but will
1424
         * not signal the barrier.
1425
         * <p>
1426
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
1427
         * multi-threaded context.
1428
         *
1429
         * @param executableTargets
1430
         *            The binaries to be executed and the cores to execute them on
1431
         * @param appID
1432
         *            The application ID to give this application
1433
         * @throws IOException
1434
         *             If anything goes wrong with networking.
1435
         * @throws ProcessException
1436
         *             If SpiNNaker rejects a message.
1437
         * @throws InterruptedException
1438
         *             If the thread is interrupted while waiting.
1439
         * @throws SpinnmanException
1440
         *             If some cores enter an unexpected state.
1441
         */
1442
        @ParallelUnsafe
1443
        default void executeApplication(@Valid ExecutableTargets executableTargets,
1444
                        @NotNull AppID appID) throws IOException, ProcessException,
1445
                        InterruptedException, SpinnmanException {
1446
                // Execute each of the binaries and get them in to a "wait" state
1447
                for (var binary : executableTargets.getBinaries()) {
×
1448
                        executeFlood(executableTargets.getCoresForBinary(binary),
×
1449
                                        new File(binary), appID, true);
1450
                }
×
1451

1452
                // Sleep to allow cores to get going
1453
                sleep(LAUNCH_DELAY);
×
1454

1455
                // Check that the binaries have reached a wait state
1456
                int count = getCoreStateCount(appID, READY);
×
1457
                if (count < executableTargets.getTotalProcessors()) {
×
1458
                        var coresNotReady = getCoresNotInState(
×
1459
                                        executableTargets.getAllCoreSubsets(), READY);
×
1460
                        if (!coresNotReady.isEmpty()) {
×
1461
                                try (var f = new Formatter()) {
×
1462
                                        f.format("Only %d of %d cores reached ready state:", count,
×
1463
                                                        executableTargets.getTotalProcessors());
×
1464
                                        for (var info : coresNotReady.values()) {
×
1465
                                                f.format("\n%s", info.getStatusDescription());
×
1466
                                        }
×
1467
                                        throw new SpinnmanException(f.toString());
×
1468
                                }
1469
                        }
1470
                }
1471

1472
                // Send a signal telling the application to start
1473
                sendSignal(appID, START);
×
1474
        }
×
1475

1476
        /**
1477
         * Set the running time information for all processors.
1478
         *
1479
         * @param runTimesteps
1480
         *            How many machine timesteps will the run last. {@code null} is
1481
         *            used to indicate an infinite (unbounded until explicitly
1482
         *            stopped) run.
1483
         * @param currentTime
1484
         *            The current simulation time.
1485
         * @param syncTimesteps
1486
         *            The number of timesteps before we pause to synchronise.
1487
         * @throws IOException
1488
         *             If anything goes wrong with networking.
1489
         * @throws ProcessException
1490
         *             If SpiNNaker rejects a message.
1491
         * @throws InterruptedException
1492
         *             If the communications were interrupted.
1493
         */
1494
        @ParallelUnsafe
1495
        default void updateRuntime(@PositiveOrZero Integer runTimesteps,
1496
                        @PositiveOrZero int currentTime, @PositiveOrZero int syncTimesteps)
1497
                        throws IOException, ProcessException, InterruptedException {
1498
                updateRuntime(runTimesteps, currentTime, syncTimesteps,
×
1499
                                (CoreSubsets) null);
1500
        }
×
1501

1502
        /**
1503
         * Set the running time information for a given core.
1504
         *
1505
         * @param runTimesteps
1506
         *            How many machine timesteps will the run last. {@code null} is
1507
         *            used to indicate an infinite (unbounded until explicitly
1508
         *            stopped) run.
1509
         * @param currentTime
1510
         *            The current simulation time.
1511
         * @param syncTimesteps
1512
         *            The number of timesteps before we pause to synchronise.
1513
         * @param core
1514
         *            The coordinates of the processor to clear the IOBUF on.
1515
         * @throws IOException
1516
         *             If anything goes wrong with networking.
1517
         * @throws ProcessException
1518
         *             If SpiNNaker rejects a message.
1519
         * @throws InterruptedException
1520
         *             If the communications were interrupted.
1521
         */
1522
        @ParallelSafe
1523
        default void updateRuntime(@PositiveOrZero Integer runTimesteps,
1524
                        @PositiveOrZero int currentTime, @PositiveOrZero int syncTimesteps,
1525
                        @Valid HasCoreLocation core)
1526
                        throws IOException, ProcessException, InterruptedException {
1527
                updateRuntime(runTimesteps, currentTime, syncTimesteps,
×
1528
                                new CoreSubsets(core));
1529
        }
×
1530

1531
        /**
1532
         * Set the running time information for a collection of processors.
1533
         *
1534
         * @param runTimesteps
1535
         *            How many machine timesteps will the run last. {@code null} is
1536
         *            used to indicate an infinite (unbounded until explicitly
1537
         *            stopped) run.
1538
         * @param currentTime
1539
         *            The current simulation time.
1540
         * @param syncTimesteps
1541
         *            The number of timesteps before we pause to synchronise.
1542
         * @param coreSubsets
1543
         *            A set of chips and cores on which to set the running time.
1544
         * @throws IOException
1545
         *             If anything goes wrong with networking.
1546
         * @throws ProcessException
1547
         *             If SpiNNaker rejects a message.
1548
         * @throws InterruptedException
1549
         *             If the communications were interrupted.
1550
         */
1551
        @ParallelSafeWithCare
1552
        void updateRuntime(@PositiveOrZero Integer runTimesteps,
1553
                        @PositiveOrZero int currentTime, @PositiveOrZero int syncTimesteps,
1554
                        @Valid CoreSubsets coreSubsets)
1555
                        throws IOException, ProcessException, InterruptedException;
1556

1557
        /**
1558
         * Tell all running application cores to write their provenance data to a
1559
         * location where it can be read back, and then to go into the
1560
         * {@link CPUState#FINISHED FINISHED} state.
1561
         *
1562
         * @throws IOException
1563
         *             If anything goes wrong with networking.
1564
         * @throws ProcessException
1565
         *             If SpiNNaker rejects a message.
1566
         * @throws InterruptedException
1567
         *             If the communications were interrupted.
1568
         */
1569
        @ParallelUnsafe
1570
        default void updateProvenanceAndExit()
1571
                        throws IOException, ProcessException, InterruptedException {
1572
                updateProvenanceAndExit((CoreSubsets) null);
×
1573
        }
×
1574

1575
        /**
1576
         * Tell a running application core to write its provenance data to a
1577
         * location where it can be read back, and then to go into the
1578
         * {@link CPUState#FINISHED FINISHED} state.
1579
         *
1580
         * @param core
1581
         *            The core to tell to finish.
1582
         * @throws IOException
1583
         *             If anything goes wrong with networking.
1584
         * @throws ProcessException
1585
         *             If SpiNNaker rejects a message.
1586
         * @throws InterruptedException
1587
         *             If the communications were interrupted.
1588
         */
1589
        @ParallelSafe
1590
        default void updateProvenanceAndExit(@Valid HasCoreLocation core)
1591
                        throws IOException, ProcessException, InterruptedException {
1592
                updateProvenanceAndExit(new CoreSubsets(core));
×
1593
        }
×
1594

1595
        /**
1596
         * Tell some running application cores to write their provenance data to a
1597
         * location where it can be read back, and then to go into their
1598
         * {@link CPUState#FINISHED FINISHED} state.
1599
         *
1600
         * @param coreSubsets
1601
         *            A set of cores tell to finish.
1602
         * @throws IOException
1603
         *             If anything goes wrong with networking.
1604
         * @throws ProcessException
1605
         *             If SpiNNaker rejects a message.
1606
         * @throws InterruptedException
1607
         *             If the communications were interrupted.
1608
         */
1609
        @ParallelSafeWithCare
1610
        void updateProvenanceAndExit(@Valid CoreSubsets coreSubsets)
1611
                        throws IOException, ProcessException, InterruptedException;
1612

1613
        /**
1614
         * Write to the SDRAM on the board.
1615
         *
1616
         * @param chip
1617
         *            The coordinates of the chip where the memory is that is to be
1618
         *            written to
1619
         * @param baseAddress
1620
         *            The address in SDRAM where the region of memory is to be
1621
         *            written
1622
         * @param dataStream
1623
         *            The stream of data that is to be written.
1624
         * @param numBytes
1625
         *            The amount of data to be written in bytes.
1626
         * @throws IOException
1627
         *             If anything goes wrong with networking or reading from the
1628
         *             input stream.
1629
         * @throws ProcessException
1630
         *             If SpiNNaker rejects a message.
1631
         * @throws InterruptedException
1632
         *             If the communications were interrupted.
1633
         */
1634
        @ParallelSafe
1635
        default void writeMemory(@Valid HasChipLocation chip,
1636
                        @NotNull MemoryLocation baseAddress,
1637
                        @NotNull InputStream dataStream, @Positive int numBytes)
1638
                        throws IOException, ProcessException, InterruptedException {
1639
                writeMemory(chip.getScampCore(), baseAddress, dataStream, numBytes);
×
1640
        }
×
1641

1642
        /**
1643
         * Write to the SDRAM on the board.
1644
         *
1645
         * @param core
1646
         *            The coordinates of the core where the memory is that is to be
1647
         *            written to
1648
         * @param baseAddress
1649
         *            The address in SDRAM where the region of memory is to be
1650
         *            written
1651
         * @param dataStream
1652
         *            The stream of data that is to be written.
1653
         * @param numBytes
1654
         *            The amount of data to be written in bytes.
1655
         * @throws IOException
1656
         *             If anything goes wrong with networking or reading from the
1657
         *             input stream.
1658
         * @throws ProcessException
1659
         *             If SpiNNaker rejects a message.
1660
         * @throws InterruptedException
1661
         *             If the communications were interrupted.
1662
         */
1663
        @ParallelSafe
1664
        void writeMemory(@Valid HasCoreLocation core,
1665
                        @NotNull MemoryLocation baseAddress,
1666
                        @NotNull InputStream dataStream, @Positive int numBytes)
1667
                        throws IOException, ProcessException, InterruptedException;
1668

1669
        /**
1670
         * Write to the SDRAM on the board.
1671
         *
1672
         * @param chip
1673
         *            The coordinates of the chip where the memory is that is to be
1674
         *            written to
1675
         * @param baseAddress
1676
         *            The address in SDRAM where the region of memory is to be
1677
         *            written
1678
         * @param dataFile
1679
         *            The file holding the data that is to be written.
1680
         * @throws IOException
1681
         *             If anything goes wrong with networking or reading from the
1682
         *             file.
1683
         * @throws ProcessException
1684
         *             If SpiNNaker rejects a message.
1685
         * @throws InterruptedException
1686
         *             If the communications were interrupted.
1687
         */
1688
        @ParallelSafe
1689
        default void writeMemory(@Valid HasChipLocation chip,
1690
                        @NotNull MemoryLocation baseAddress, @NotNull File dataFile)
1691
                        throws IOException, ProcessException, InterruptedException {
1692
                writeMemory(chip.getScampCore(), baseAddress, dataFile);
×
1693
        }
×
1694

1695
        /**
1696
         * Write to the SDRAM on the board.
1697
         *
1698
         * @param core
1699
         *            The coordinates of the core where the memory is that is to be
1700
         *            written to
1701
         * @param baseAddress
1702
         *            The address in SDRAM where the region of memory is to be
1703
         *            written
1704
         * @param dataFile
1705
         *            The file holding the data that is to be written.
1706
         * @throws IOException
1707
         *             If anything goes wrong with networking or reading from the
1708
         *             file.
1709
         * @throws ProcessException
1710
         *             If SpiNNaker rejects a message.
1711
         * @throws InterruptedException
1712
         *             If the communications were interrupted.
1713
         */
1714
        @ParallelSafe
1715
        void writeMemory(@Valid HasCoreLocation core,
1716
                        @NotNull MemoryLocation baseAddress, @NotNull File dataFile)
1717
                        throws IOException, ProcessException, InterruptedException;
1718

1719
        /**
1720
         * Write to the SDRAM on the board.
1721
         *
1722
         * @param chip
1723
         *            The coordinates of the chip where the memory is that is to be
1724
         *            written to
1725
         * @param baseAddress
1726
         *            The address in SDRAM where the region of memory is to be
1727
         *            written
1728
         * @param dataWord
1729
         *            The word that is to be written (as 4 bytes).
1730
         * @throws IOException
1731
         *             If anything goes wrong with networking.
1732
         * @throws ProcessException
1733
         *             If SpiNNaker rejects a message.
1734
         * @throws InterruptedException
1735
         *             If the communications were interrupted.
1736
         */
1737
        @ParallelSafe
1738
        default void writeMemory(@Valid HasChipLocation chip,
1739
                        @NotNull MemoryLocation baseAddress, int dataWord)
1740
                        throws IOException, ProcessException, InterruptedException {
1741
                writeMemory(chip.getScampCore(), baseAddress, dataWord);
×
1742
        }
×
1743

1744
        /**
1745
         * Write to the SDRAM (or System RAM) on the board.
1746
         *
1747
         * @param core
1748
         *            The coordinates of the core where the memory is that is to be
1749
         *            written to
1750
         * @param baseAddress
1751
         *            The address in SDRAM where the region of memory is to be
1752
         *            written
1753
         * @param dataWord
1754
         *            The word that is to be written (as 4 bytes).
1755
         * @throws IOException
1756
         *             If anything goes wrong with networking.
1757
         * @throws ProcessException
1758
         *             If SpiNNaker rejects a message.
1759
         * @throws InterruptedException
1760
         *             If the communications were interrupted.
1761
         */
1762
        @ParallelSafe
1763
        default void writeMemory(@Valid HasCoreLocation core,
1764
                        @NotNull MemoryLocation baseAddress, int dataWord)
1765
                        throws IOException, ProcessException, InterruptedException {
1766
                writeMemory(core, baseAddress, wordAsBuffer(dataWord));
×
1767
        }
×
1768

1769
        /**
1770
         * Write to the SDRAM on the board.
1771
         *
1772
         * @param chip
1773
         *            The coordinates of the core where the memory is that is to be
1774
         *            written to
1775
         * @param baseAddress
1776
         *            The address in SDRAM where the region of memory is to be
1777
         *            written
1778
         * @param data
1779
         *            The data that is to be written.
1780
         * @throws IOException
1781
         *             If anything goes wrong with networking.
1782
         * @throws ProcessException
1783
         *             If SpiNNaker rejects a message.
1784
         * @throws InterruptedException
1785
         *             If the communications were interrupted.
1786
         */
1787
        @ParallelSafe
1788
        default void writeMemory(@Valid HasChipLocation chip,
1789
                        @NotNull MemoryLocation baseAddress, @NotEmpty byte[] data)
1790
                        throws IOException, ProcessException, InterruptedException {
1791
                writeMemory(chip.getScampCore(), baseAddress, wrap(data));
×
1792
        }
×
1793

1794
        /**
1795
         * Write to the SDRAM on the board.
1796
         *
1797
         * @param core
1798
         *            The coordinates of the core where the memory is that is to be
1799
         *            written to
1800
         * @param baseAddress
1801
         *            The address in SDRAM where the region of memory is to be
1802
         *            written
1803
         * @param data
1804
         *            The data that is to be written.
1805
         * @throws IOException
1806
         *             If anything goes wrong with networking.
1807
         * @throws ProcessException
1808
         *             If SpiNNaker rejects a message.
1809
         * @throws InterruptedException
1810
         *             If the communications were interrupted.
1811
         */
1812
        @ParallelSafe
1813
        default void writeMemory(@Valid HasCoreLocation core,
1814
                        @NotNull MemoryLocation baseAddress, @NotEmpty byte[] data)
1815
                        throws IOException, ProcessException, InterruptedException {
1816
                writeMemory(core, baseAddress, wrap(data));
×
1817
        }
×
1818

1819
        /**
1820
         * Write to the SDRAM on the board.
1821
         *
1822
         * @param chip
1823
         *            The coordinates of the core where the memory is that is to be
1824
         *            written to
1825
         * @param baseAddress
1826
         *            The address in SDRAM where the region of memory is to be
1827
         *            written
1828
         * @param data
1829
         *            The data that is to be written. The data should be from the
1830
         *            <i>position</i> to the <i>limit</i>.
1831
         * @throws IOException
1832
         *             If anything goes wrong with networking.
1833
         * @throws ProcessException
1834
         *             If SpiNNaker rejects a message.
1835
         * @throws InterruptedException
1836
         *             If the communications were interrupted.
1837
         */
1838
        @ParallelSafe
1839
        default void writeMemory(@Valid HasChipLocation chip,
1840
                        @NotNull MemoryLocation baseAddress, @NotNull ByteBuffer data)
1841
                        throws IOException, ProcessException, InterruptedException {
1842
                writeMemory(chip.getScampCore(), baseAddress, data);
×
1843
        }
×
1844

1845
        /**
1846
         * Write to the SDRAM (or System RAM) on the board.
1847
         *
1848
         * @param core
1849
         *            The coordinates of the core where the memory is that is to be
1850
         *            written to
1851
         * @param baseAddress
1852
         *            The address in SDRAM where the region of memory is to be
1853
         *            written
1854
         * @param data
1855
         *            The data that is to be written. The data should be from the
1856
         *            <i>position</i> to the <i>limit</i>.
1857
         * @throws IOException
1858
         *             If anything goes wrong with networking.
1859
         * @throws ProcessException
1860
         *             If SpiNNaker rejects a message.
1861
         * @throws InterruptedException
1862
         *             If the communications were interrupted.
1863
         */
1864
        @ParallelSafe
1865
        void writeMemory(@Valid HasCoreLocation core,
1866
                        @NotNull MemoryLocation baseAddress, @NotNull ByteBuffer data)
1867
                        throws IOException, ProcessException, InterruptedException;
1868

1869
        /**
1870
         * Write to the user<sub>0</sub> register of a core.
1871
         *
1872
         * @param core
1873
         *            The coordinates of the core whose register is to be
1874
         *            written to
1875
         * @param value
1876
         *            The word of data that is to be written.
1877
         * @throws IOException
1878
         *             If anything goes wrong with networking.
1879
         * @throws ProcessException
1880
         *             If SpiNNaker rejects a message.
1881
         * @throws InterruptedException
1882
         *             If the communications were interrupted.
1883
         */
1884
        default void writeUser0(@Valid HasCoreLocation core, int value)
1885
                        throws ProcessException, IOException, InterruptedException {
1886
                writeMemory(core.getScampCore(), getUser0RegisterAddress(core), value);
×
1887
        }
×
1888

1889
        /**
1890
         * Write to the user<sub>0</sub> register of a core.
1891
         *
1892
         * @param core
1893
         *            The coordinates of the core whose register is to be
1894
         *            written to
1895
         * @param pointer
1896
         *            The pointer/address that is to be written to the register.
1897
         * @throws IOException
1898
         *             If anything goes wrong with networking.
1899
         * @throws ProcessException
1900
         *             If SpiNNaker rejects a message.
1901
         * @throws InterruptedException
1902
         *             If the communications were interrupted.
1903
         */
1904
        default void writeUser0(@Valid HasCoreLocation core,
1905
                        @NotNull MemoryLocation pointer)
1906
                        throws ProcessException, IOException, InterruptedException {
1907
                writeMemory(core.getScampCore(), getUser0RegisterAddress(core),
×
1908
                                pointer.address());
×
1909
        }
×
1910

1911
        /**
1912
         * Write to the user<sub>1</sub> register of a core.
1913
         *
1914
         * @param core
1915
         *            The coordinates of the core whose register is to be
1916
         *            written to
1917
         * @param value
1918
         *            The word of data that is to be written.
1919
         * @throws IOException
1920
         *             If anything goes wrong with networking.
1921
         * @throws ProcessException
1922
         *             If SpiNNaker rejects a message.
1923
         * @throws InterruptedException
1924
         *             If the communications were interrupted.
1925
         */
1926
        default void writeUser1(@Valid HasCoreLocation core, int value)
1927
                        throws ProcessException, IOException, InterruptedException {
1928
                writeMemory(core.getScampCore(), getUser1RegisterAddress(core), value);
×
1929
        }
×
1930

1931
        /**
1932
         * Write to the user<sub>1</sub> register of a core.
1933
         *
1934
         * @param core
1935
         *            The coordinates of the core whose register is to be written to
1936
         * @param pointer
1937
         *            The pointer/address that is to be written to the register.
1938
         * @throws IOException
1939
         *             If anything goes wrong with networking.
1940
         * @throws ProcessException
1941
         *             If SpiNNaker rejects a message.
1942
         * @throws InterruptedException
1943
         *             If the communications were interrupted.
1944
         */
1945
        default void writeUser1(@Valid HasCoreLocation core,
1946
                        @NotNull MemoryLocation pointer)
1947
                        throws ProcessException, IOException, InterruptedException {
1948
                writeMemory(core.getScampCore(), getUser1RegisterAddress(core),
×
1949
                                pointer.address());
×
1950
        }
×
1951

1952
        /**
1953
         * Write to the user<sub>2</sub> register of a core.
1954
         *
1955
         * @param core
1956
         *            The coordinates of the core whose register is to be
1957
         *            written to
1958
         * @param value
1959
         *            The word of data that is to be written.
1960
         * @throws IOException
1961
         *             If anything goes wrong with networking.
1962
         * @throws ProcessException
1963
         *             If SpiNNaker rejects a message.
1964
         * @throws InterruptedException
1965
         *             If the communications were interrupted.
1966
         */
1967
        default void writeUser2(@Valid HasCoreLocation core, int value)
1968
                        throws ProcessException, IOException, InterruptedException {
1969
                writeMemory(core.getScampCore(), getUser2RegisterAddress(core), value);
×
1970
        }
×
1971

1972
        /**
1973
         * Write to the user<sub>2</sub> register of a core.
1974
         *
1975
         * @param core
1976
         *            The coordinates of the core whose register is to be written to
1977
         * @param pointer
1978
         *            The pointer/address that is to be written to the register.
1979
         * @throws IOException
1980
         *             If anything goes wrong with networking.
1981
         * @throws ProcessException
1982
         *             If SpiNNaker rejects a message.
1983
         * @throws InterruptedException
1984
         *             If the communications were interrupted.
1985
         */
1986
        default void writeUser2(@Valid HasCoreLocation core,
1987
                        @NotNull MemoryLocation pointer)
1988
                        throws ProcessException, IOException, InterruptedException {
1989
                writeMemory(core.getScampCore(), getUser2RegisterAddress(core),
×
1990
                                pointer.address());
×
1991
        }
×
1992

1993
        /**
1994
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
1995
         * command. If sent to a BMP, this command can be used to communicate with
1996
         * the FPGAs' debug registers; in that case, the link must be the direction
1997
         * with the same ID as the ID of the FPGA to communicate with.
1998
         * <p>
1999
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2000
         * multi-threaded context if the link leaves the current board.
2001
         *
2002
         * @param chip
2003
         *            The coordinates of the chip whose neighbour is to be written
2004
         *            to
2005
         * @param link
2006
         *            The link direction to send the request along
2007
         * @param baseAddress
2008
         *            The address in SDRAM where the region of memory is to be
2009
         *            written
2010
         * @param dataStream
2011
         *            The stream of data that is to be written.
2012
         * @param numBytes
2013
         *            The amount of data to be written in bytes.
2014
         * @throws IOException
2015
         *             If anything goes wrong with networking or with reading from
2016
         *             the input stream.
2017
         * @throws ProcessException
2018
         *             If SpiNNaker rejects a message.
2019
         * @throws InterruptedException
2020
         *             If the communications were interrupted.
2021
         */
2022
        @ParallelSafeWithCare
2023
        default void writeNeighbourMemory(@Valid HasChipLocation chip,
2024
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2025
                        @NotNull InputStream dataStream, @Positive int numBytes)
2026
                        throws IOException, ProcessException, InterruptedException {
2027
                writeNeighbourMemory(chip.getScampCore(), link, baseAddress, dataStream,
×
2028
                                numBytes);
2029
        }
×
2030

2031
        /**
2032
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2033
         * command. If sent to a BMP, this command can be used to communicate with
2034
         * the FPGAs' debug registers; in that case, the link must be the direction
2035
         * with the same ID as the ID of the FPGA to communicate with.
2036
         * <p>
2037
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2038
         * multi-threaded context if the link leaves the current board.
2039
         *
2040
         * @param core
2041
         *            The coordinates of the core whose neighbour is to be written
2042
         *            to; the CPU to use is typically 0 (or if a BMP, the slot
2043
         *            number)
2044
         * @param link
2045
         *            The link direction to send the request along
2046
         * @param baseAddress
2047
         *            The address in SDRAM where the region of memory is to be
2048
         *            written
2049
         * @param dataStream
2050
         *            The stream of data that is to be written.
2051
         * @param numBytes
2052
         *            The amount of data to be written in bytes.
2053
         * @throws IOException
2054
         *             If anything goes wrong with networking or with reading from
2055
         *             the input stream.
2056
         * @throws ProcessException
2057
         *             If SpiNNaker rejects a message.
2058
         * @throws InterruptedException
2059
         *             If the communications were interrupted.
2060
         */
2061
        @ParallelSafeWithCare
2062
        void writeNeighbourMemory(@Valid HasCoreLocation core,
2063
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2064
                        @NotNull InputStream dataStream, @Positive int numBytes)
2065
                        throws IOException, ProcessException, InterruptedException;
2066

2067
        /**
2068
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2069
         * command. If sent to a BMP, this command can be used to communicate with
2070
         * the FPGAs' debug registers; in that case, the link must be the direction
2071
         * with the same ID as the ID of the FPGA to communicate with.
2072
         * <p>
2073
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2074
         * multi-threaded context if the link leaves the current board.
2075
         *
2076
         * @param chip
2077
         *            The coordinates of the chip whose neighbour is to be written
2078
         *            to
2079
         * @param link
2080
         *            The link direction to send the request along
2081
         * @param baseAddress
2082
         *            The address in SDRAM where the region of memory is to be
2083
         *            written
2084
         * @param dataFile
2085
         *            The file holding the data that is to be written.
2086
         * @throws IOException
2087
         *             If anything goes wrong with networking or with reading from
2088
         *             the file.
2089
         * @throws ProcessException
2090
         *             If SpiNNaker rejects a message.
2091
         * @throws InterruptedException
2092
         *             If the communications were interrupted.
2093
         */
2094
        @ParallelSafeWithCare
2095
        default void writeNeighbourMemory(@Valid HasChipLocation chip,
2096
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2097
                        @NotNull File dataFile)
2098
                        throws IOException, ProcessException, InterruptedException {
2099
                writeNeighbourMemory(chip.getScampCore(), link, baseAddress, dataFile);
×
2100
        }
×
2101

2102
        /**
2103
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2104
         * command. If sent to a BMP, this command can be used to communicate with
2105
         * the FPGAs' debug registers; in that case, the link must be the direction
2106
         * with the same ID as the ID of the FPGA to communicate with.
2107
         * <p>
2108
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2109
         * multi-threaded context if the link leaves the current board.
2110
         *
2111
         * @param core
2112
         *            The coordinates of the core whose neighbour is to be written
2113
         *            to; the CPU to use is typically 0 (or if a BMP, the slot
2114
         *            number)
2115
         * @param link
2116
         *            The link direction to send the request along
2117
         * @param baseAddress
2118
         *            The address in SDRAM where the region of memory is to be
2119
         *            written
2120
         * @param dataFile
2121
         *            The name of the file holding the data that is to be written.
2122
         * @throws IOException
2123
         *             If anything goes wrong with networking or with reading from
2124
         *             the file.
2125
         * @throws ProcessException
2126
         *             If SpiNNaker rejects a message.
2127
         * @throws InterruptedException
2128
         *             If the communications were interrupted.
2129
         */
2130
        @ParallelSafeWithCare
2131
        void writeNeighbourMemory(@Valid HasCoreLocation core,
2132
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2133
                        @NotNull File dataFile)
2134
                        throws IOException, ProcessException, InterruptedException;
2135

2136
        /**
2137
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2138
         * command. If sent to a BMP, this command can be used to communicate with
2139
         * the FPGAs' debug registers; in that case, the link must be the direction
2140
         * with the same ID as the ID of the FPGA to communicate with.
2141
         * <p>
2142
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2143
         * multi-threaded context if the link leaves the current board.
2144
         *
2145
         * @param chip
2146
         *            The coordinates of the chip whose neighbour is to be written
2147
         *            to
2148
         * @param link
2149
         *            The link direction to send the request along
2150
         * @param baseAddress
2151
         *            The address in SDRAM where the region of memory is to be
2152
         *            written
2153
         * @param dataWord
2154
         *            The word that is to be written.
2155
         * @throws IOException
2156
         *             If anything goes wrong with networking.
2157
         * @throws ProcessException
2158
         *             If SpiNNaker rejects a message.
2159
         * @throws InterruptedException
2160
         *             If the communications were interrupted.
2161
         */
2162
        @ParallelSafeWithCare
2163
        default void writeNeighbourMemory(@Valid HasChipLocation chip,
2164
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2165
                        int dataWord)
2166
                        throws IOException, ProcessException, InterruptedException {
2167
                writeNeighbourMemory(chip.getScampCore(), link, baseAddress, dataWord);
×
2168
        }
×
2169

2170
        /**
2171
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2172
         * command. If sent to a BMP, this command can be used to communicate with
2173
         * the FPGAs' debug registers; in that case, the link must be the direction
2174
         * with the same ID as the ID of the FPGA to communicate with.
2175
         * <p>
2176
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2177
         * multi-threaded context if the link leaves the current board.
2178
         *
2179
         * @param core
2180
         *            The coordinates of the core whose neighbour is to be written
2181
         *            to; the CPU to use is typically 0 (or if a BMP, the slot
2182
         *            number)
2183
         * @param link
2184
         *            The link direction to send the request along
2185
         * @param baseAddress
2186
         *            The address in SDRAM where the region of memory is to be
2187
         *            written
2188
         * @param dataWord
2189
         *            The word that is to be written.
2190
         * @throws IOException
2191
         *             If anything goes wrong with networking.
2192
         * @throws ProcessException
2193
         *             If SpiNNaker rejects a message.
2194
         * @throws InterruptedException
2195
         *             If the communications were interrupted.
2196
         */
2197
        @ParallelSafeWithCare
2198
        default void writeNeighbourMemory(@Valid HasCoreLocation core,
2199
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2200
                        int dataWord)
2201
                        throws IOException, ProcessException, InterruptedException {
2202
                writeNeighbourMemory(core, link, baseAddress, wordAsBuffer(dataWord));
×
2203
        }
×
2204

2205
        /**
2206
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2207
         * command. If sent to a BMP, this command can be used to communicate with
2208
         * the FPGAs' debug registers; in that case, the link must be the direction
2209
         * with the same ID as the ID of the FPGA to communicate with.
2210
         * <p>
2211
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2212
         * multi-threaded context if the link leaves the current board.
2213
         *
2214
         * @param chip
2215
         *            The coordinates of the chip whose neighbour is to be written
2216
         *            to
2217
         * @param link
2218
         *            The link direction to send the request along
2219
         * @param baseAddress
2220
         *            The address in SDRAM where the region of memory is to be
2221
         *            written
2222
         * @param data
2223
         *            The data that is to be written.
2224
         * @throws IOException
2225
         *             If anything goes wrong with networking.
2226
         * @throws ProcessException
2227
         *             If SpiNNaker rejects a message.
2228
         * @throws InterruptedException
2229
         *             If the communications were interrupted.
2230
         */
2231
        @ParallelSafeWithCare
2232
        default void writeNeighbourMemory(@Valid HasChipLocation chip,
2233
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2234
                        @NotEmpty byte[] data)
2235
                        throws IOException, ProcessException, InterruptedException {
2236
                writeNeighbourMemory(chip.getScampCore(), link, baseAddress, data);
×
2237
        }
×
2238

2239
        /**
2240
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2241
         * command. If sent to a BMP, this command can be used to communicate with
2242
         * the FPGAs' debug registers; in that case, the link must be the direction
2243
         * with the same ID as the ID of the FPGA to communicate with.
2244
         * <p>
2245
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2246
         * multi-threaded context if the link leaves the current board.
2247
         *
2248
         * @param core
2249
         *            The coordinates of the core whose neighbour is to be written
2250
         *            to; the CPU to use is typically 0 (or if a BMP, the slot
2251
         *            number)
2252
         * @param link
2253
         *            The link direction to send the request along
2254
         * @param baseAddress
2255
         *            The address in SDRAM where the region of memory is to be
2256
         *            written
2257
         * @param data
2258
         *            The data that is to be written.
2259
         * @throws IOException
2260
         *             If anything goes wrong with networking.
2261
         * @throws ProcessException
2262
         *             If SpiNNaker rejects a message.
2263
         * @throws InterruptedException
2264
         *             If the communications were interrupted.
2265
         */
2266
        @ParallelSafeWithCare
2267
        default void writeNeighbourMemory(@Valid HasCoreLocation core,
2268
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2269
                        @NotEmpty byte[] data)
2270
                        throws IOException, ProcessException, InterruptedException {
2271
                writeNeighbourMemory(core, link, baseAddress, wrap(data));
×
2272
        }
×
2273

2274
        /**
2275
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2276
         * command. If sent to a BMP, this command can be used to communicate with
2277
         * the FPGAs' debug registers; in that case, the link must be the direction
2278
         * with the same ID as the ID of the FPGA to communicate with.
2279
         * <p>
2280
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2281
         * multi-threaded context if the link leaves the current board.
2282
         *
2283
         * @param chip
2284
         *            The coordinates of the chip whose neighbour is to be written
2285
         *            to
2286
         * @param link
2287
         *            The link direction to send the request along
2288
         * @param baseAddress
2289
         *            The address in SDRAM where the region of memory is to be
2290
         *            written
2291
         * @param data
2292
         *            The data that is to be written. The data should be from the
2293
         *            <i>position</i> to the <i>limit</i>.
2294
         * @throws IOException
2295
         *             If anything goes wrong with networking.
2296
         * @throws ProcessException
2297
         *             If SpiNNaker rejects a message.
2298
         * @throws InterruptedException
2299
         *             If the communications were interrupted.
2300
         */
2301
        @ParallelSafeWithCare
2302
        default void writeNeighbourMemory(@Valid HasChipLocation chip,
2303
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2304
                        @NotNull ByteBuffer data)
2305
                        throws IOException, ProcessException, InterruptedException {
2306
                writeNeighbourMemory(chip.getScampCore(), link, baseAddress, data);
×
2307
        }
×
2308

2309
        /**
2310
         * Write to the memory of a neighbouring chip using a LINK_WRITE SCP
2311
         * command. If sent to a BMP, this command can be used to communicate with
2312
         * the FPGAs' debug registers; in that case, the link must be the direction
2313
         * with the same ID as the ID of the FPGA to communicate with.
2314
         * <p>
2315
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2316
         * multi-threaded context if the link leaves the current board.
2317
         *
2318
         * @param core
2319
         *            The coordinates of the core whose neighbour is to be written
2320
         *            to; the CPU to use is typically 0 (or if a BMP, the slot
2321
         *            number)
2322
         * @param link
2323
         *            The link direction to send the request along
2324
         * @param baseAddress
2325
         *            The address in SDRAM where the region of memory is to be
2326
         *            written
2327
         * @param data
2328
         *            The data that is to be written. The data should be from the
2329
         *            <i>position</i> to the <i>limit</i>.
2330
         * @throws IOException
2331
         *             If anything goes wrong with networking.
2332
         * @throws ProcessException
2333
         *             If SpiNNaker rejects a message.
2334
         * @throws InterruptedException
2335
         *             If the communications were interrupted.
2336
         */
2337
        @ParallelSafeWithCare
2338
        void writeNeighbourMemory(@Valid HasCoreLocation core,
2339
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2340
                        @NotNull ByteBuffer data)
2341
                        throws IOException, ProcessException, InterruptedException;
2342

2343
        /**
2344
         * Write to the SDRAM of all chips.
2345
         * <p>
2346
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2347
         * multi-threaded context. It has interlocking, but you should not rely on
2348
         * it.
2349
         *
2350
         * @param baseAddress
2351
         *            The address in SDRAM where the region of memory is to be
2352
         *            written
2353
         * @param dataStream
2354
         *            The stream of data that is to be written.
2355
         * @param numBytes
2356
         *            The amount of data to be written in bytes.
2357
         * @throws IOException
2358
         *             If anything goes wrong with networking or with reading from
2359
         *             the input stream.
2360
         * @throws ProcessException
2361
         *             If SpiNNaker rejects a message.
2362
         * @throws InterruptedException
2363
         *             If the communications were interrupted.
2364
         */
2365
        @ParallelUnsafe
2366
        void writeMemoryFlood(@NotNull MemoryLocation baseAddress,
2367
                        @NotNull InputStream dataStream, @Positive int numBytes)
2368
                        throws IOException, ProcessException, InterruptedException;
2369

2370
        /**
2371
         * Write to the SDRAM of all chips.
2372
         * <p>
2373
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2374
         * multi-threaded context. It has interlocking, but you should not rely on
2375
         * it.
2376
         *
2377
         * @param baseAddress
2378
         *            The address in SDRAM where the region of memory is to be
2379
         *            written
2380
         * @param dataFile
2381
         *            The name of the file holding the data that is to be written.
2382
         * @throws IOException
2383
         *             If anything goes wrong with networking or with reading from
2384
         *             the file.
2385
         * @throws ProcessException
2386
         *             If SpiNNaker rejects a message.
2387
         * @throws InterruptedException
2388
         *             If the communications were interrupted.
2389
         */
2390
        @ParallelUnsafe
2391
        void writeMemoryFlood(@NotNull MemoryLocation baseAddress,
2392
                        @NotNull File dataFile)
2393
                        throws IOException, ProcessException, InterruptedException;
2394

2395
        /**
2396
         * Write to the SDRAM of all chips.
2397
         * <p>
2398
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2399
         * multi-threaded context. It has interlocking, but you should not rely on
2400
         * it.
2401
         *
2402
         * @param baseAddress
2403
         *            The address in SDRAM where the region of memory is to be
2404
         *            written
2405
         * @param dataWord
2406
         *            The word that is to be written.
2407
         * @throws IOException
2408
         *             If anything goes wrong with networking.
2409
         * @throws ProcessException
2410
         *             If SpiNNaker rejects a message.
2411
         * @throws InterruptedException
2412
         *             If the communications were interrupted.
2413
         */
2414
        @ParallelUnsafe
2415
        default void writeMemoryFlood(@NotNull MemoryLocation baseAddress,
2416
                        int dataWord)
2417
                        throws IOException, ProcessException, InterruptedException {
2418
                writeMemoryFlood(baseAddress, wordAsBuffer(dataWord));
×
2419
        }
×
2420

2421
        /**
2422
         * Write to the SDRAM of all chips.
2423
         * <p>
2424
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2425
         * multi-threaded context. It has interlocking, but you should not rely on
2426
         * it.
2427
         *
2428
         * @param baseAddress
2429
         *            The address in SDRAM where the region of memory is to be
2430
         *            written
2431
         * @param data
2432
         *            The data that is to be written.
2433
         * @throws IOException
2434
         *             If anything goes wrong with networking.
2435
         * @throws ProcessException
2436
         *             If SpiNNaker rejects a message.
2437
         * @throws InterruptedException
2438
         *             If the communications were interrupted.
2439
         */
2440
        @ParallelUnsafe
2441
        default void writeMemoryFlood(@NotNull MemoryLocation baseAddress,
2442
                        @NotEmpty byte[] data)
2443
                        throws IOException, ProcessException, InterruptedException {
2444
                writeMemoryFlood(baseAddress, wrap(data));
×
2445
        }
×
2446

2447
        /**
2448
         * Write to the SDRAM of all chips.
2449
         * <p>
2450
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2451
         * multi-threaded context. It has interlocking, but you should not rely on
2452
         * it.
2453
         *
2454
         * @param baseAddress
2455
         *            The address in SDRAM where the region of memory is to be
2456
         *            written
2457
         * @param data
2458
         *            The data that is to be written. The data should be from the
2459
         *            <i>position</i> to the <i>limit</i>.
2460
         * @throws IOException
2461
         *             If anything goes wrong with networking.
2462
         * @throws ProcessException
2463
         *             If SpiNNaker rejects a message.
2464
         * @throws InterruptedException
2465
         *             If the communications were interrupted.
2466
         */
2467
        @ParallelUnsafe
2468
        void writeMemoryFlood(@NotNull MemoryLocation baseAddress,
2469
                        @NotNull ByteBuffer data)
2470
                        throws IOException, ProcessException, InterruptedException;
2471

2472
        /**
2473
         * Read some areas of SDRAM from the board.
2474
         *
2475
         * @param chip
2476
         *            The coordinates of the chip where the memory is to be read
2477
         *            from
2478
         * @param baseAddress
2479
         *            The address in SDRAM where the region of memory to be read
2480
         *            starts
2481
         * @param length
2482
         *            The length of the data to be read in bytes
2483
         * @return A little-endian buffer of data read, positioned at the start of
2484
         *         the data
2485
         * @throws IOException
2486
         *             If anything goes wrong with networking.
2487
         * @throws ProcessException
2488
         *             If SpiNNaker rejects a message.
2489
         * @throws InterruptedException
2490
         *             If the communications were interrupted.
2491
         */
2492
        @ParallelSafe
2493
        @CheckReturnValue
2494
        default ByteBuffer readMemory(@Valid HasChipLocation chip,
2495
                        @NotNull MemoryLocation baseAddress, @Positive int length)
2496
                        throws IOException, ProcessException, InterruptedException {
2497
                return readMemory(chip.getScampCore(), baseAddress, length);
×
2498
        }
2499

2500
        /**
2501
         * Read some areas of SDRAM (or System RAM) from the board.
2502
         *
2503
         * @param core
2504
         *            The coordinates of the core where the memory is to be read
2505
         *            from
2506
         * @param baseAddress
2507
         *            The address in SDRAM where the region of memory to be read
2508
         *            starts
2509
         * @param length
2510
         *            The length of the data to be read in bytes
2511
         * @return A little-endian buffer of data read, positioned at the start of
2512
         *         the data
2513
         * @throws IOException
2514
         *             If anything goes wrong with networking.
2515
         * @throws ProcessException
2516
         *             If SpiNNaker rejects a message.
2517
         * @throws InterruptedException
2518
         *             If the communications were interrupted.
2519
         */
2520
        @ParallelSafe
2521
        @CheckReturnValue
2522
        ByteBuffer readMemory(@Valid HasCoreLocation core,
2523
                        @NotNull MemoryLocation baseAddress, @Positive int length)
2524
                        throws IOException, ProcessException, InterruptedException;
2525

2526
        /**
2527
         * Read the contents of an allocated block on the heap from the board. The
2528
         * SDRAM heap can be read from any core of that chip; the DTCM heap can only
2529
         * be read from one particular core.
2530
         *
2531
         * @param core
2532
         *            The coordinates of the core where the memory is to be read
2533
         *            from
2534
         * @param element
2535
         *            The heap element to read the contents of
2536
         * @return A little-endian buffer of data read, positioned at the start of
2537
         *         the data, or {@code null} if the heap element is free.
2538
         * @throws IOException
2539
         *             If anything goes wrong with networking.
2540
         * @throws ProcessException
2541
         *             If SpiNNaker rejects a message.
2542
         * @throws InterruptedException
2543
         *             If the communications were interrupted.
2544
         */
2545
        @ParallelSafe
2546
        @CheckReturnValue
2547
        default ByteBuffer readMemory(@Valid HasCoreLocation core,
2548
                        @NotNull HeapElement element)
2549
                        throws IOException, ProcessException, InterruptedException {
2550
                if (element.isFree()) {
×
2551
                        return null;
×
2552
                }
2553
                return readMemory(core, element.dataAddress(), element.size());
×
2554
        }
2555

2556
        /**
2557
         * Read an area associated with a <em>recording region</em> from SDRAM from
2558
         * a core of a chip on the board.
2559
         *
2560
         * @param region
2561
         *            The recording region that is being read. Describes which core
2562
         *            produced the data, what <em>DSE index</em> the data came from,
2563
         *            and where in memory to actually read.
2564
         * @param storage
2565
         *            The database to write to.
2566
         * @throws IOException
2567
         *             If anything goes wrong with networking.
2568
         * @throws ProcessException
2569
         *             If SpiNNaker rejects a message.
2570
         * @throws StorageException
2571
         *             If anything goes wrong with access to the database.
2572
         * @throws InterruptedException
2573
         *             If the communications were interrupted.
2574
         */
2575
        @ParallelSafe
2576
        void readRegion(@Valid BufferManagerStorage.Region region,
2577
                        @NotNull BufferManagerStorage storage) throws IOException,
2578
                        ProcessException, StorageException, InterruptedException;
2579

2580
        /**
2581
         * Read the user<sub>0</sub> register of a core.
2582
         *
2583
         * @param core
2584
         *            The coordinates of the core to read the register of
2585
         * @return The contents of the register
2586
         * @throws IOException
2587
         *             If anything goes wrong with networking.
2588
         * @throws ProcessException
2589
         *             If SpiNNaker rejects a message.
2590
         * @throws InterruptedException
2591
         *             If the communications were interrupted.
2592
         */
2593
        @CheckReturnValue
2594
        default int readUser0(@Valid HasCoreLocation core)
2595
                        throws ProcessException, IOException, InterruptedException {
2596
                var user0 = getUser0RegisterAddress(core);
×
2597
                return readMemory(core.getScampCore(), user0, WORD_SIZE).getInt();
×
2598
        }
2599

2600
        /**
2601
         * Read the user<sub>1</sub> register of a core.
2602
         *
2603
         * @param core
2604
         *            The coordinates of the core to read the register of
2605
         * @return The contents of the register
2606
         * @throws IOException
2607
         *             If anything goes wrong with networking.
2608
         * @throws ProcessException
2609
         *             If SpiNNaker rejects a message.
2610
         * @throws InterruptedException
2611
         *             If the communications were interrupted.
2612
         */
2613
        @CheckReturnValue
2614
        default int readUser1(@Valid HasCoreLocation core)
2615
                        throws ProcessException, IOException, InterruptedException {
2616
                var user1 = getUser1RegisterAddress(core);
×
2617
                return readMemory(core.getScampCore(), user1, WORD_SIZE).getInt();
×
2618
        }
2619

2620
        /**
2621
         * Read the user<sub>2</sub> register of a core.
2622
         *
2623
         * @param core
2624
         *            The coordinates of the core to read the register of
2625
         * @return The contents of the register
2626
         * @throws IOException
2627
         *             If anything goes wrong with networking.
2628
         * @throws ProcessException
2629
         *             If SpiNNaker rejects a message.
2630
         * @throws InterruptedException
2631
         *             If the communications were interrupted.
2632
         */
2633
        @CheckReturnValue
2634
        default int readUser2(@Valid HasCoreLocation core)
2635
                        throws ProcessException, IOException, InterruptedException {
2636
                var user2 = getUser2RegisterAddress(core);
×
2637
                return readMemory(core.getScampCore(), user2, WORD_SIZE).getInt();
×
2638
        }
2639

2640
        /**
2641
         * Read some areas of memory on a neighbouring chip using a LINK_READ SCP
2642
         * command. If sent to a BMP, this command can be used to communicate with
2643
         * the FPGAs' debug registers; in that case, the link must be the direction
2644
         * with the same ID as the ID of the FPGA to communicate with.
2645
         * <p>
2646
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2647
         * multi-threaded context if the link leaves the current board.
2648
         *
2649
         * @param chip
2650
         *            The coordinates of the chip whose neighbour is to be read from
2651
         * @param link
2652
         *            The link direction to send the request along
2653
         * @param baseAddress
2654
         *            The address in SDRAM where the region of memory to be read
2655
         *            starts
2656
         * @param length
2657
         *            The length of the data to be read in bytes
2658
         * @return A little-endian buffer of data that has been read, positioned at
2659
         *         the start of the data
2660
         * @throws IOException
2661
         *             If anything goes wrong with networking.
2662
         * @throws ProcessException
2663
         *             If SpiNNaker rejects a message.
2664
         * @throws InterruptedException
2665
         *             If the communications were interrupted.
2666
         */
2667
        @ParallelSafeWithCare
2668
        default ByteBuffer readNeighbourMemory(@Valid HasChipLocation chip,
2669
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2670
                        @Positive int length)
2671
                        throws IOException, ProcessException, InterruptedException {
2672
                return readNeighbourMemory(chip.getScampCore(), link, baseAddress,
×
2673
                                length);
2674
        }
2675

2676
        /**
2677
         * Read some areas of memory on a neighbouring chip using a LINK_READ SCP
2678
         * command. If sent to a BMP, this command can be used to communicate with
2679
         * the FPGAs' debug registers; in that case, the link must be the direction
2680
         * with the same ID as the ID of the FPGA to communicate with.
2681
         * <p>
2682
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2683
         * multi-threaded context if the link leaves the current board.
2684
         *
2685
         * @param core
2686
         *            The coordinates of the chip whose neighbour is to be read
2687
         *            from, plus the CPU to use (typically 0, or if a BMP, the slot
2688
         *            number)
2689
         * @param link
2690
         *            The link direction to send the request along
2691
         * @param baseAddress
2692
         *            The address in SDRAM where the region of memory to be read
2693
         *            starts
2694
         * @param length
2695
         *            The length of the data to be read in bytes
2696
         * @return A little-endian buffer of data that has been read, positioned at
2697
         *         the start of the data
2698
         * @throws IOException
2699
         *             If anything goes wrong with networking.
2700
         * @throws ProcessException
2701
         *             If SpiNNaker rejects a message.
2702
         * @throws InterruptedException
2703
         *             If the communications were interrupted.
2704
         */
2705
        @ParallelSafeWithCare
2706
        ByteBuffer readNeighbourMemory(@Valid HasCoreLocation core,
2707
                        @NotNull Direction link, @NotNull MemoryLocation baseAddress,
2708
                        @Positive int length)
2709
                        throws IOException, ProcessException, InterruptedException;
2710

2711
        /**
2712
         * Sends a stop request for an application ID.
2713
         * <p>
2714
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2715
         * multi-threaded context.
2716
         *
2717
         * @param appID
2718
         *            The ID of the application to send to
2719
         * @throws IOException
2720
         *             If anything goes wrong with networking.
2721
         * @throws ProcessException
2722
         *             If SpiNNaker rejects a message.
2723
         * @throws InterruptedException
2724
         *             If the communications were interrupted.
2725
         */
2726
        @ParallelUnsafe
2727
        void stopApplication(@NotNull AppID appID)
2728
                        throws IOException, ProcessException, InterruptedException;
2729

2730
        /**
2731
         * Waits for the specified cores running the given application to be in some
2732
         * target state or states. Handles failures.
2733
         * <p>
2734
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2735
         * multi-threaded context if the cores are over more than a single board.
2736
         *
2737
         * @param coreSubsets
2738
         *            the cores to check are in a given sync state
2739
         * @param appID
2740
         *            the application ID that being used by the simulation
2741
         * @param cpuStates
2742
         *            The expected states once the applications are ready; success
2743
         *            is when each application is in one of these states
2744
         * @throws IOException
2745
         *             If anything goes wrong with networking.
2746
         * @throws InterruptedException
2747
         *             If the thread is interrupted while waiting.
2748
         * @throws SpinnmanException
2749
         *             If some cores enter an error state or SpiNNaker rejects a
2750
         *             message.
2751
         */
2752
        @ParallelSafeWithCare
2753
        default void waitForCoresToBeInState(@Valid CoreSubsets coreSubsets,
2754
                        @NotNull AppID appID, EnumSet<@NotNull CPUState> cpuStates)
2755
                        throws IOException, InterruptedException, SpinnmanException {
2756
                waitForCoresToBeInState(coreSubsets, appID, cpuStates, TIMEOUT_DISABLED,
×
2757
                                DEFAULT_POLL_INTERVAL, DEFAULT_ERROR_STATES,
2758
                                DEFAULT_CHECK_INTERVAL);
2759
        }
×
2760

2761
        /**
2762
         * Waits for the specified cores running the given application to be in some
2763
         * target state or states. Handles failures.
2764
         * <p>
2765
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2766
         * multi-threaded context if the cores are over more than a single board.
2767
         *
2768
         * @param allCoreSubsets
2769
         *            the cores to check are in a given sync state
2770
         * @param appID
2771
         *            the application ID that being used by the simulation
2772
         * @param cpuStates
2773
         *            The expected states once the applications are ready; success
2774
         *            is when each application is in one of these states
2775
         * @param timeout
2776
         *            The amount of time to wait in milliseconds for the cores to
2777
         *            reach one of the states, or {@code null} to wait for an
2778
         *            unbounded amount of time.
2779
         * @param timeBetweenPolls
2780
         *            Time between checking the state, in milliseconds
2781
         * @param errorStates
2782
         *            Set of states that the application can be in that indicate an
2783
         *            error, and so should raise an exception
2784
         * @param countsBetweenFullCheck
2785
         *            The number of times to use the count signal before instead
2786
         *            using the full CPU state check
2787
         * @throws IOException
2788
         *             If anything goes wrong with networking.
2789
         * @throws InterruptedException
2790
         *             If the thread is interrupted while waiting.
2791
         * @throws SpinnmanException
2792
         *             If some cores enter an error state or SpiNNaker rejects a
2793
         *             message.
2794
         */
2795
        @ParallelSafeWithCare
2796
        void waitForCoresToBeInState(@Valid CoreSubsets allCoreSubsets,
2797
                        @NotNull AppID appID, EnumSet<@NotNull CPUState> cpuStates,
2798
                        @PositiveOrZero Integer timeout, @Positive int timeBetweenPolls,
2799
                        EnumSet<@NotNull CPUState> errorStates,
2800
                        @Positive int countsBetweenFullCheck)
2801
                        throws IOException, InterruptedException, SpinnmanException;
2802

2803
        /**
2804
         * Get all cores that are in a given state.
2805
         * <p>
2806
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2807
         * multi-threaded context unless the {@code allCoreSubsets} only contains
2808
         * cores on a single board.
2809
         *
2810
         * @param allCoreSubsets
2811
         *            The cores to filter
2812
         * @param state
2813
         *            The states to filter on
2814
         * @return Core subsets object containing cores in the given state
2815
         * @throws IOException
2816
         *             If anything goes wrong with networking.
2817
         * @throws ProcessException
2818
         *             If SpiNNaker rejects a message.
2819
         * @throws InterruptedException
2820
         *             If the communications were interrupted.
2821
         */
2822
        @ParallelSafeWithCare
2823
        @CheckReturnValue
2824
        default CoreSubsets getCoresInState(@Valid CoreSubsets allCoreSubsets,
2825
                        @NotNull CPUState state)
2826
                        throws IOException, ProcessException, InterruptedException {
2827
                return getCoresInState(allCoreSubsets, EnumSet.of(state));
×
2828
        }
2829

2830
        /**
2831
         * Get all cores that are in a given set of states.
2832
         * <p>
2833
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2834
         * multi-threaded context unless the {@code allCoreSubsets} only contains
2835
         * cores on a single board.
2836
         *
2837
         * @param allCoreSubsets
2838
         *            The cores to filter
2839
         * @param states
2840
         *            The states to filter on
2841
         * @return Core subsets object containing cores in the given states
2842
         * @throws IOException
2843
         *             If anything goes wrong with networking.
2844
         * @throws ProcessException
2845
         *             If SpiNNaker rejects a message.
2846
         * @throws InterruptedException
2847
         *             If the communications were interrupted.
2848
         */
2849
        @ParallelSafeWithCare
2850
        @CheckReturnValue
2851
        default CoreSubsets getCoresInState(@Valid CoreSubsets allCoreSubsets,
2852
                        EnumSet<@NotNull CPUState> states)
2853
                        throws IOException, ProcessException, InterruptedException {
2854
                return new CoreSubsets(getCPUInformation(allCoreSubsets)
×
2855
                                .filter(info -> states.contains(info.getState()))
×
2856
                                .map(CPUInfo::asCoreLocation));
×
2857
        }
2858

2859
        /**
2860
         * Get all cores that are not in a given state.
2861
         * <p>
2862
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2863
         * multi-threaded context unless the {@code allCoreSubsets} only contains
2864
         * cores on a single board.
2865
         *
2866
         * @param allCoreSubsets
2867
         *            The cores to filter
2868
         * @param state
2869
         *            The state to filter on
2870
         * @return Core subsets object containing cores not in the given state
2871
         * @throws IOException
2872
         *             If anything goes wrong with networking.
2873
         * @throws ProcessException
2874
         *             If SpiNNaker rejects a message.
2875
         * @throws InterruptedException
2876
         *             If the communications were interrupted.
2877
         */
2878
        @ParallelSafeWithCare
2879
        @CheckReturnValue
2880
        default Map<CoreLocation, CPUInfo> getCoresNotInState(
2881
                        @Valid CoreSubsets allCoreSubsets, @NotNull CPUState state)
2882
                        throws IOException, ProcessException, InterruptedException {
2883
                return getCoresNotInState(allCoreSubsets, EnumSet.of(state));
×
2884
        }
2885

2886
        /**
2887
         * Get all cores that are not in a given set of states.
2888
         * <p>
2889
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2890
         * multi-threaded context unless the {@code allCoreSubsets} only contains
2891
         * cores on a single board.
2892
         *
2893
         * @param allCoreSubsets
2894
         *            The cores to filter
2895
         * @param states
2896
         *            The states to filter on
2897
         * @return Core subsets object containing cores not in the given states
2898
         * @throws IOException
2899
         *             If anything goes wrong with networking.
2900
         * @throws ProcessException
2901
         *             If SpiNNaker rejects a message.
2902
         * @throws InterruptedException
2903
         *             If the communications were interrupted.
2904
         */
2905
        @ParallelSafeWithCare
2906
        @CheckReturnValue
2907
        default Map<CoreLocation, CPUInfo> getCoresNotInState(
2908
                        @Valid CoreSubsets allCoreSubsets,
2909
                        EnumSet<@NotNull CPUState> states)
2910
                        throws IOException, ProcessException, InterruptedException {
2911
                return getCPUInformation(allCoreSubsets)
×
2912
                                .filter(info -> !states.contains(info.getState()))
×
2913
                                .toMap(TreeMap::new, CPUInfo::asCoreLocation, identity());
×
2914
        }
2915

2916
        /**
2917
         * Send a signal to an application.
2918
         * <p>
2919
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
2920
         * multi-threaded context.
2921
         *
2922
         * @param appID
2923
         *            The ID of the application to send to
2924
         * @param signal
2925
         *            The signal to send
2926
         * @throws IOException
2927
         *             If anything goes wrong with networking.
2928
         * @throws ProcessException
2929
         *             If SpiNNaker rejects a message.
2930
         * @throws InterruptedException
2931
         *             If the communications were interrupted.
2932
         */
2933
        @ParallelUnsafe
2934
        void sendSignal(@NotNull AppID appID, @NotNull Signal signal)
2935
                        throws IOException, ProcessException, InterruptedException;
2936

2937
        /**
2938
         * Set LED states.
2939
         *
2940
         * @param chip
2941
         *            The coordinates of the chip on which to set the LEDs
2942
         * @param ledStates
2943
         *            A map from LED index to state with 0 being off, 1 on and 2
2944
         *            inverted.
2945
         * @throws IOException
2946
         *             If anything goes wrong with networking.
2947
         * @throws ProcessException
2948
         *             If SpiNNaker rejects a message.
2949
         * @throws InterruptedException
2950
         *             If the communications were interrupted.
2951
         */
2952
        @ParallelSafe
2953
        default void setLEDs(@Valid HasChipLocation chip,
2954
                        Map<Integer, LEDAction> ledStates)
2955
                        throws IOException, ProcessException, InterruptedException {
2956
                setLEDs(chip.getScampCore(), ledStates);
×
2957
        }
×
2958

2959
        /**
2960
         * Set LED states.
2961
         *
2962
         * @param core
2963
         *            The coordinates of the core on which to set the LEDs
2964
         * @param ledStates
2965
         *            A map from LED index to state with 0 being off, 1 on and 2
2966
         *            inverted.
2967
         * @throws IOException
2968
         *             If anything goes wrong with networking.
2969
         * @throws ProcessException
2970
         *             If SpiNNaker rejects a message.
2971
         * @throws InterruptedException
2972
         *             If the communications were interrupted.
2973
         */
2974
        @ParallelSafe
2975
        void setLEDs(@Valid HasCoreLocation core, Map<Integer, LEDAction> ledStates)
2976
                        throws IOException, ProcessException, InterruptedException;
2977

2978
        /**
2979
         * Find a connection that matches the given board IP address.
2980
         *
2981
         * @param boardAddress
2982
         *            The IP address of the Ethernet connection on the board
2983
         * @return A connection for the given IP address, or {@code null} if no such
2984
         *         connection exists
2985
         */
2986
        @ParallelSafe
2987
        SCPConnection locateSpinnakerConnection(@NotNull InetAddress boardAddress);
2988

2989
        /**
2990
         * Set up an IP tag.
2991
         *
2992
         * @param tag
2993
         *            The tag to set up; note its board address can be {@code null},
2994
         *            in which case, the tag will be assigned to all boards.
2995
         * @throws IOException
2996
         *             If anything goes wrong with networking.
2997
         * @throws ProcessException
2998
         *             If SpiNNaker rejects a message.
2999
         * @throws InterruptedException
3000
         *             If the communications were interrupted.
3001
         */
3002
        @ParallelSafeWithCare
3003
        void setIPTag(@Valid IPTag tag)
3004
                        throws IOException, ProcessException, InterruptedException;
3005

3006
        /**
3007
         * Set up an IP tag to deliver messages to a particular connection.
3008
         *
3009
         * @param tag
3010
         *            The tag to set up.
3011
         * @param connection
3012
         *            The connection to deliver messages to, which must already be
3013
         *            set up to talk to the correct board.
3014
         * @throws IOException
3015
         *             If anything goes wrong with networking.
3016
         * @throws ProcessException
3017
         *             If SpiNNaker rejects a message.
3018
         * @throws InterruptedException
3019
         *             If the communications were interrupted.
3020
         */
3021
        @ParallelSafeWithCare
3022
        void setIPTag(@Valid IPTag tag, @NotNull SDPConnection connection)
3023
                        throws IOException, ProcessException, InterruptedException;
3024

3025
        /**
3026
         * Set up a reverse IP tag.
3027
         *
3028
         * @param tag
3029
         *            The reverse tag to set up; note its board address can be
3030
         *            {@code null}, in which case, the tag will be assigned to all
3031
         *            boards
3032
         * @throws IOException
3033
         *             If anything goes wrong with networking.
3034
         * @throws ProcessException
3035
         *             If SpiNNaker rejects a message.
3036
         * @throws InterruptedException
3037
         *             If the communications were interrupted.
3038
         */
3039
        @ParallelSafe
3040
        void setReverseIPTag(@Valid ReverseIPTag tag)
3041
                        throws IOException, ProcessException, InterruptedException;
3042

3043
        /**
3044
         * Clear the setting of an IP tag.
3045
         *
3046
         * @param tag
3047
         *            The tag
3048
         * @throws IOException
3049
         *             If anything goes wrong with networking.
3050
         * @throws ProcessException
3051
         *             If SpiNNaker rejects a message.
3052
         * @throws InterruptedException
3053
         *             If the communications were interrupted.
3054
         */
3055
        @ParallelSafe
3056
        default void clearIPTag(@Valid Tag tag)
3057
                        throws IOException, ProcessException, InterruptedException {
3058
                clearIPTag(tag.getTag(), tag.getBoardAddress());
×
3059
        }
×
3060

3061
        /**
3062
         * Clear the setting of an IP tag.
3063
         * <p>
3064
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
3065
         * multi-threaded context.
3066
         *
3067
         * @param tag
3068
         *            The tag ID
3069
         * @throws IOException
3070
         *             If anything goes wrong with networking.
3071
         * @throws ProcessException
3072
         *             If SpiNNaker rejects a message.
3073
         * @throws InterruptedException
3074
         *             If the communications were interrupted.
3075
         */
3076
        @ParallelUnsafe
3077
        default void clearIPTag(@TagID int tag)
3078
                        throws IOException, ProcessException, InterruptedException {
3079
                clearIPTag(tag, null);
×
3080
        }
×
3081

3082
        /**
3083
         * Clear the setting of an IP tag.
3084
         *
3085
         * @param tag
3086
         *            The tag ID
3087
         * @param boardAddress
3088
         *            Board address where the tag should be cleared. If
3089
         *            {@code null}, all SCPSender connections will send the message
3090
         *            to clear the tag
3091
         * @throws IOException
3092
         *             If anything goes wrong with networking.
3093
         * @throws ProcessException
3094
         *             If SpiNNaker rejects a message.
3095
         * @throws InterruptedException
3096
         *             If the communications were interrupted.
3097
         */
3098
        @ParallelSafe
3099
        void clearIPTag(@TagID int tag, InetAddress boardAddress)
3100
                        throws IOException, ProcessException, InterruptedException;
3101

3102
        /**
3103
         * Get the current set of tags that have been set on the board using all
3104
         * SCPSender connections.
3105
         * <p>
3106
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
3107
         * multi-threaded context.
3108
         *
3109
         * @return An iterable of tags
3110
         * @throws IOException
3111
         *             If anything goes wrong with networking.
3112
         * @throws ProcessException
3113
         *             If SpiNNaker rejects a message.
3114
         * @throws InterruptedException
3115
         *             If the communications were interrupted.
3116
         */
3117
        @ParallelUnsafe
3118
        @CheckReturnValue
3119
        default List<Tag> getTags()
3120
                        throws IOException, ProcessException, InterruptedException {
3121
                return getTags(null);
×
3122
        }
3123

3124
        /**
3125
         * Get the current set of tags that have been set on the board.
3126
         *
3127
         * @param connection
3128
         *            Connection from which the tags should be received.
3129
         * @return An iterable of tags
3130
         * @throws IOException
3131
         *             If anything goes wrong with networking.
3132
         * @throws ProcessException
3133
         *             If SpiNNaker rejects a message.
3134
         * @throws InterruptedException
3135
         *             If the communications were interrupted.
3136
         */
3137
        @ParallelSafe
3138
        @CheckReturnValue
3139
        List<Tag> getTags(SCPConnection connection)
3140
                        throws IOException, ProcessException, InterruptedException;
3141

3142
        /**
3143
         * Get the number of times each tag has had a message sent via it using all
3144
         * SCPSender connections.
3145
         * <p>
3146
         * <strong>WARNING!</strong> This operation is <em>unsafe</em> in a
3147
         * multi-threaded context.
3148
         *
3149
         * @return A map from the tags to their usage.
3150
         * @throws IOException
3151
         *             If anything goes wrong with networking.
3152
         * @throws ProcessException
3153
         *             If SpiNNaker rejects a message.
3154
         * @throws InterruptedException
3155
         *             If the communications were interrupted.
3156
         */
3157
        @ParallelUnsafe
3158
        @CheckReturnValue
3159
        default Map<Tag, Integer> getTagUsage()
3160
                        throws IOException, ProcessException, InterruptedException {
3161
                return getTagUsage(null);
×
3162
        }
3163

3164
        /**
3165
         * Get the number of times each tag has had a message sent via it for a
3166
         * connection.
3167
         *
3168
         * @param connection
3169
         *            Connection from which the tag usage should be retrieved.
3170
         * @return A map from the tags to their usage.
3171
         * @throws IOException
3172
         *             If anything goes wrong with networking.
3173
         * @throws ProcessException
3174
         *             If SpiNNaker rejects a message.
3175
         * @throws InterruptedException
3176
         *             If the communications were interrupted.
3177
         */
3178
        @ParallelSafe
3179
        @CheckReturnValue
3180
        Map<Tag, Integer> getTagUsage(@NotNull SCPConnection connection)
3181
                        throws IOException, ProcessException, InterruptedException;
3182

3183
        /**
3184
         * Allocates a chunk of SDRAM on a chip on the machine.
3185
         *
3186
         * @param chip
3187
         *            The coordinates of the chip onto which to allocate memory
3188
         * @param size
3189
         *            The amount of memory to allocate in bytes
3190
         * @return the base address of the allocated memory
3191
         * @throws IOException
3192
         *             If anything goes wrong with networking.
3193
         * @throws ProcessException
3194
         *             If SpiNNaker rejects a message.
3195
         * @throws InterruptedException
3196
         *             If the communications were interrupted.
3197
         */
3198
        @ParallelSafe
3199
        @CheckReturnValue
3200
        default MemoryLocation mallocSDRAM(@Valid HasChipLocation chip,
3201
                        @Positive int size)
3202
                        throws IOException, ProcessException, InterruptedException {
3203
                return mallocSDRAM(chip, size, DEFAULT, 0);
×
3204
        }
3205

3206
        /**
3207
         * Allocates a chunk of SDRAM on a chip on the machine.
3208
         *
3209
         * @param chip
3210
         *            The coordinates of the chip onto which to allocate memory
3211
         * @param size
3212
         *            The amount of memory to allocate in bytes
3213
         * @param appID
3214
         *            The ID of the application with which to associate the routes.
3215
         * @return the base address of the allocated memory
3216
         * @throws IOException
3217
         *             If anything goes wrong with networking.
3218
         * @throws ProcessException
3219
         *             If SpiNNaker rejects a message.
3220
         * @throws InterruptedException
3221
         *             If the communications were interrupted.
3222
         */
3223
        @ParallelSafe
3224
        @CheckReturnValue
3225
        default MemoryLocation mallocSDRAM(@Valid HasChipLocation chip,
3226
                        @Positive int size, @NotNull AppID appID)
3227
                        throws IOException, ProcessException, InterruptedException {
3228
                return mallocSDRAM(chip, size, appID, 0);
×
3229
        }
3230

3231
        /**
3232
         * Allocates a chunk of SDRAM on a chip on the machine.
3233
         *
3234
         * @param chip
3235
         *            The coordinates of the chip onto which to allocate memory
3236
         * @param size
3237
         *            The amount of memory to allocate in bytes
3238
         * @param appID
3239
         *            The ID of the application with which to associate the routes.
3240
         * @param tag
3241
         *            The tag for the SDRAM, a 8-bit (chip-wide) tag that can be
3242
         *            looked up by a SpiNNaker application to discover the address
3243
         *            of the allocated block.
3244
         * @return the base address of the allocated memory
3245
         * @throws IOException
3246
         *             If anything goes wrong with networking.
3247
         * @throws ProcessException
3248
         *             If SpiNNaker rejects a message.
3249
         * @throws InterruptedException
3250
         *             If the communications were interrupted.
3251
         */
3252
        @ParallelSafe
3253
        MemoryLocation mallocSDRAM(@Valid HasChipLocation chip, @Positive int size,
3254
                        @NotNull AppID appID, int tag)
3255
                        throws IOException, ProcessException, InterruptedException;
3256

3257
        /**
3258
         * Free allocated SDRAM.
3259
         *
3260
         * @param chip
3261
         *            The coordinates of the chip onto which to free memory
3262
         * @param baseAddress
3263
         *            The base address of the allocated memory
3264
         * @throws IOException
3265
         *             If anything goes wrong with networking.
3266
         * @throws ProcessException
3267
         *             If SpiNNaker rejects a message.
3268
         * @throws InterruptedException
3269
         *             If the communications were interrupted.
3270
         */
3271
        @ParallelSafe
3272
        void freeSDRAM(@Valid HasChipLocation chip,
3273
                        @NotNull MemoryLocation baseAddress)
3274
                        throws IOException, ProcessException, InterruptedException;
3275

3276
        /**
3277
         * Free all SDRAM allocated to a given application ID.
3278
         *
3279
         * @param chip
3280
         *            The coordinates of the chip onto which to free memory
3281
         * @param appID
3282
         *            The app ID of the owner of the allocated memory
3283
         * @return The number of blocks freed
3284
         * @throws IOException
3285
         *             If anything goes wrong with networking.
3286
         * @throws ProcessException
3287
         *             If SpiNNaker rejects a message.
3288
         * @throws InterruptedException
3289
         *             If the communications were interrupted.
3290
         */
3291
        @ParallelSafe
3292
        int freeSDRAM(@Valid HasChipLocation chip, @NotNull AppID appID)
3293
                        throws IOException, ProcessException, InterruptedException;
3294

3295
        /**
3296
         * Load a set of multicast routes on to a chip associated with the default
3297
         * application ID.
3298
         *
3299
         * @param chip
3300
         *            The coordinates of the chip onto which to load the routes
3301
         * @param routes
3302
         *            An iterable of multicast routes to load
3303
         * @throws IOException
3304
         *             If anything goes wrong with networking.
3305
         * @throws ProcessException
3306
         *             If SpiNNaker rejects a message.
3307
         * @throws InterruptedException
3308
         *             If the communications were interrupted.
3309
         */
3310
        @ParallelSafe
3311
        default void loadMulticastRoutes(@Valid HasChipLocation chip,
3312
                        Collection<@NotNull MulticastRoutingEntry> routes)
3313
                        throws IOException, ProcessException, InterruptedException {
3314
                loadMulticastRoutes(chip, routes, DEFAULT);
×
3315
        }
×
3316

3317
        /**
3318
         * Load a set of multicast routes on to a chip.
3319
         *
3320
         * @param chip
3321
         *            The coordinates of the chip onto which to load the routes
3322
         * @param routes
3323
         *            An iterable of multicast routes to load
3324
         * @param appID
3325
         *            The ID of the application with which to associate the routes.
3326
         * @throws IOException
3327
         *             If anything goes wrong with networking.
3328
         * @throws ProcessException
3329
         *             If SpiNNaker rejects a message.
3330
         * @throws InterruptedException
3331
         *             If the communications were interrupted.
3332
         */
3333
        @ParallelSafe
3334
        void loadMulticastRoutes(@Valid HasChipLocation chip,
3335
                        Collection<@NotNull MulticastRoutingEntry> routes,
3336
                        @NotNull AppID appID)
3337
                        throws IOException, ProcessException, InterruptedException;
3338

3339
        /**
3340
         * Loads a fixed route routing table entry onto a chip's router.
3341
         *
3342
         * @param chip
3343
         *            The coordinates of the chip onto which to load the route
3344
         * @param fixedRoute
3345
         *            the route for the fixed route entry on this chip
3346
         * @throws IOException
3347
         *             If anything goes wrong with networking.
3348
         * @throws ProcessException
3349
         *             If SpiNNaker rejects a message.
3350
         * @throws InterruptedException
3351
         *             If the communications were interrupted.
3352
         */
3353
        @ParallelSafe
3354
        default void loadFixedRoute(@Valid HasChipLocation chip,
3355
                        @Valid RoutingEntry fixedRoute)
3356
                        throws IOException, ProcessException, InterruptedException {
3357
                loadFixedRoute(chip, fixedRoute, DEFAULT);
×
3358
        }
×
3359

3360
        /**
3361
         * Loads a fixed route routing table entry onto a chip's router.
3362
         *
3363
         * @param chip
3364
         *            The coordinates of the chip onto which to load the route
3365
         * @param fixedRoute
3366
         *            the route for the fixed route entry on this chip
3367
         * @param appID
3368
         *            The ID of the application with which to associate the route.
3369
         * @throws IOException
3370
         *             If anything goes wrong with networking.
3371
         * @throws ProcessException
3372
         *             If SpiNNaker rejects a message.
3373
         * @throws InterruptedException
3374
         *             If the communications were interrupted.
3375
         */
3376
        @ParallelSafe
3377
        void loadFixedRoute(@Valid HasChipLocation chip,
3378
                        @Valid RoutingEntry fixedRoute, @NotNull AppID appID)
3379
                        throws IOException, ProcessException, InterruptedException;
3380

3381
        /**
3382
         * Reads a fixed route routing table entry from a chip's router.
3383
         *
3384
         * @param chip
3385
         *            The coordinate of the chip from which to read the route.
3386
         * @return the route as a fixed route entry
3387
         * @throws IOException
3388
         *             If anything goes wrong with networking.
3389
         * @throws ProcessException
3390
         *             If SpiNNaker rejects a message.
3391
         * @throws InterruptedException
3392
         *             If the communications were interrupted.
3393
         */
3394
        @ParallelSafe
3395
        @CheckReturnValue
3396
        default RoutingEntry readFixedRoute(@Valid HasChipLocation chip)
3397
                        throws IOException, ProcessException, InterruptedException {
3398
                return readFixedRoute(chip, DEFAULT);
×
3399
        }
3400

3401
        /**
3402
         * Reads a fixed route routing table entry from a chip's router.
3403
         *
3404
         * @param chip
3405
         *            The coordinate of the chip from which to read the route.
3406
         * @param appID
3407
         *            The ID of the application associated the route.
3408
         * @return the route as a fixed route entry
3409
         * @throws IOException
3410
         *             If anything goes wrong with networking.
3411
         * @throws ProcessException
3412
         *             If SpiNNaker rejects a message.
3413
         * @throws InterruptedException
3414
         *             If the communications were interrupted.
3415
         */
3416
        @ParallelSafe
3417
        @CheckReturnValue
3418
        RoutingEntry readFixedRoute(@Valid HasChipLocation chip,
3419
                        @NotNull AppID appID)
3420
                        throws IOException, ProcessException, InterruptedException;
3421

3422
        /**
3423
         * Get the current multicast routes set up on a chip.
3424
         *
3425
         * @param chip
3426
         *            The coordinates of the chip from which to get the routes
3427
         * @return An iterable of multicast routes
3428
         * @throws IOException
3429
         *             If anything goes wrong with networking.
3430
         * @throws ProcessException
3431
         *             If SpiNNaker rejects a message.
3432
         * @throws InterruptedException
3433
         *             If the communications were interrupted.
3434
         */
3435
        @ParallelSafe
3436
        @CheckReturnValue
3437
        default List<MulticastRoutingEntry> getMulticastRoutes(
3438
                        @Valid HasChipLocation chip)
3439
                        throws IOException, ProcessException, InterruptedException {
3440
                return getMulticastRoutes(chip, null);
×
3441
        }
3442

3443
        /**
3444
         * Get the current multicast routes set up on a chip.
3445
         *
3446
         * @param chip
3447
         *            The coordinates of the chip from which to get the routes
3448
         * @param appID
3449
         *            The ID of the application to filter the routes for.
3450
         *            {@code null} means "don't filter".
3451
         * @return An iterable of multicast routes
3452
         * @throws IOException
3453
         *             If anything goes wrong with networking.
3454
         * @throws ProcessException
3455
         *             If SpiNNaker rejects a message.
3456
         * @throws InterruptedException
3457
         *             If the communications were interrupted.
3458
         */
3459
        @ParallelSafe
3460
        @CheckReturnValue
3461
        List<MulticastRoutingEntry> getMulticastRoutes(@Valid HasChipLocation chip,
3462
                        AppID appID)
3463
                        throws IOException, ProcessException, InterruptedException;
3464

3465
        /**
3466
         * Remove all the multicast routes on a chip.
3467
         *
3468
         * @param chip
3469
         *            The coordinates of the chip on which to clear the routes
3470
         * @throws IOException
3471
         *             If anything goes wrong with networking.
3472
         * @throws ProcessException
3473
         *             If SpiNNaker rejects a message.
3474
         * @throws InterruptedException
3475
         *             If the communications were interrupted.
3476
         */
3477
        @ParallelSafe
3478
        void clearMulticastRoutes(@Valid HasChipLocation chip)
3479
                        throws IOException, ProcessException, InterruptedException;
3480

3481
        /**
3482
         * Get router diagnostic information from a chip.
3483
         *
3484
         * @param chip
3485
         *            The coordinates of the chip from which to get the information
3486
         * @return The router diagnostic information
3487
         * @throws IOException
3488
         *             If anything goes wrong with networking.
3489
         * @throws ProcessException
3490
         *             If SpiNNaker rejects a message.
3491
         * @throws InterruptedException
3492
         *             If the communications were interrupted.
3493
         */
3494
        @ParallelSafe
3495
        @CheckReturnValue
3496
        RouterDiagnostics getRouterDiagnostics(@Valid HasChipLocation chip)
3497
                        throws IOException, ProcessException, InterruptedException;
3498

3499
        /**
3500
         * Sets a router diagnostic filter in a router.
3501
         *
3502
         * @param chip
3503
         *            the address of the router in which this filter is being set
3504
         * @param position
3505
         *            the position in the list of filters where this filter is to be
3506
         *            added, between 0 and 15 (note that positions 0 to 11 are used
3507
         *            by the default filters, and setting these positions will
3508
         *            result in a warning).
3509
         * @param diagnosticFilter
3510
         *            the diagnostic filter being set in the position.
3511
         * @throws IOException
3512
         *             If anything goes wrong with networking.
3513
         * @throws ProcessException
3514
         *             If SpiNNaker rejects a message.
3515
         * @throws InterruptedException
3516
         *             If the communications were interrupted.
3517
         */
3518
        @ParallelSafe
3519
        void setRouterDiagnosticFilter(@Valid HasChipLocation chip, int position,
3520
                        @NotNull DiagnosticFilter diagnosticFilter)
3521
                        throws IOException, ProcessException, InterruptedException;
3522

3523
        /**
3524
         * Gets a router diagnostic filter from a router.
3525
         *
3526
         * @param chip
3527
         *            the address of the router from which this filter is being
3528
         *            retrieved
3529
         * @param position
3530
         *            the position in the list of filters where this filter is to be
3531
         *            read from
3532
         * @return The diagnostic filter read
3533
         * @throws IOException
3534
         *             If anything goes wrong with networking.
3535
         * @throws ProcessException
3536
         *             If SpiNNaker rejects a message.
3537
         * @throws InterruptedException
3538
         *             If the communications were interrupted.
3539
         */
3540
        @ParallelSafe
3541
        @CheckReturnValue
3542
        DiagnosticFilter getRouterDiagnosticFilter(@Valid HasChipLocation chip,
3543
                        @PositiveOrZero int position)
3544
                        throws IOException, ProcessException, InterruptedException;
3545

3546
        /**
3547
         * Clear router diagnostic information on a chip. Resets and enables all
3548
         * diagnostic counters.
3549
         *
3550
         * @param chip
3551
         *            The coordinates of the chip
3552
         * @throws IOException
3553
         *             If anything goes wrong with networking.
3554
         * @throws ProcessException
3555
         *             If SpiNNaker rejects a message.
3556
         * @throws InterruptedException
3557
         *             If the communications were interrupted.
3558
         */
3559
        @ParallelSafe
3560
        default void clearRouterDiagnosticCounters(@Valid HasChipLocation chip)
3561
                        throws IOException, ProcessException, InterruptedException {
3562
                clearRouterDiagnosticCounters(chip, false,
×
3563
                                range(0, NO_ROUTER_DIAGNOSTIC_FILTERS).boxed()
×
3564
                                                .collect(toList()));
×
3565
        }
×
3566

3567
        /**
3568
         * Clear router diagnostic information on a chip. Resets all diagnostic
3569
         * counters.
3570
         *
3571
         * @param chip
3572
         *            The coordinates of the chip
3573
         * @param enable
3574
         *            True (default) if the counters should be enabled
3575
         * @throws IOException
3576
         *             If anything goes wrong with networking.
3577
         * @throws ProcessException
3578
         *             If SpiNNaker rejects a message.
3579
         * @throws InterruptedException
3580
         *             If the communications were interrupted.
3581
         */
3582
        @ParallelSafe
3583
        default void clearRouterDiagnosticCounters(@Valid HasChipLocation chip,
3584
                        boolean enable)
3585
                        throws IOException, ProcessException, InterruptedException {
3586
                clearRouterDiagnosticCounters(chip, enable,
×
3587
                                range(0, NO_ROUTER_DIAGNOSTIC_FILTERS).boxed()
×
3588
                                                .collect(toList()));
×
3589
        }
×
3590

3591
        /**
3592
         * Clear router diagnostic information on a chip. Resets and enables all the
3593
         * numbered counters.
3594
         *
3595
         * @param chip
3596
         *            The coordinates of the chip
3597
         * @param counterIDs
3598
         *            The IDs of the counters to reset and enable; each must be
3599
         *            between 0 and 15
3600
         * @throws IOException
3601
         *             If anything goes wrong with networking.
3602
         * @throws ProcessException
3603
         *             If SpiNNaker rejects a message.
3604
         * @throws InterruptedException
3605
         *             If the communications were interrupted.
3606
         */
3607
        @ParallelSafe
3608
        default void clearRouterDiagnosticCounters(@Valid HasChipLocation chip,
3609
                        Iterable<@NotNull Integer> counterIDs)
3610
                        throws IOException, ProcessException, InterruptedException {
3611
                clearRouterDiagnosticCounters(chip, false, counterIDs);
×
3612
        }
×
3613

3614
        /**
3615
         * Clear router diagnostic information on a chip.
3616
         *
3617
         * @param chip
3618
         *            The coordinates of the chip
3619
         * @param enable
3620
         *            True (default) if the counters should be enabled
3621
         * @param counterIDs
3622
         *            The IDs of the counters to reset and enable if enable is True;
3623
         *            each must be between 0 and 15
3624
         * @throws IOException
3625
         *             If anything goes wrong with networking.
3626
         * @throws ProcessException
3627
         *             If SpiNNaker rejects a message.
3628
         * @throws InterruptedException
3629
         *             If the communications were interrupted.
3630
         */
3631
        @ParallelSafe
3632
        void clearRouterDiagnosticCounters(@Valid HasChipLocation chip,
3633
                        boolean enable, Iterable<@NotNull Integer> counterIDs)
3634
                        throws IOException, ProcessException, InterruptedException;
3635

3636
        /**
3637
         * Get the contents of the SDRAM heap on a given chip.
3638
         *
3639
         * @param chip
3640
         *            The coordinates of the chip
3641
         * @return the list of chunks in the heap
3642
         * @throws IOException
3643
         *             If anything goes wrong with networking.
3644
         * @throws ProcessException
3645
         *             If SpiNNaker rejects a message.
3646
         * @throws InterruptedException
3647
         *             If the communications were interrupted.
3648
         */
3649
        @ParallelSafe
3650
        @CheckReturnValue
3651
        default List<HeapElement> getHeap(@Valid HasChipLocation chip)
3652
                        throws IOException, ProcessException, InterruptedException {
3653
                return getHeap(chip, sdram_heap_address);
×
3654
        }
3655

3656
        /**
3657
         * Get the contents of the given heap on a given chip.
3658
         *
3659
         * @param chip
3660
         *            The coordinates of the chip
3661
         * @param heap
3662
         *            The SystemVariableDefinition which is the heap to read
3663
         * @return the list of chunks in the heap
3664
         * @throws IOException
3665
         *             If anything goes wrong with networking.
3666
         * @throws ProcessException
3667
         *             If SpiNNaker rejects a message.
3668
         * @throws InterruptedException
3669
         *             If the communications were interrupted.
3670
         */
3671
        @ParallelSafe
3672
        @CheckReturnValue
3673
        List<HeapElement> getHeap(@Valid HasChipLocation chip,
3674
                        @NotNull SystemVariableDefinition heap)
3675
                        throws IOException, ProcessException, InterruptedException;
3676

3677
        /**
3678
         * Fill some memory with repeated data.
3679
         *
3680
         * @param chip
3681
         *            The coordinates of the chip
3682
         * @param baseAddress
3683
         *            The address at which to start the fill
3684
         * @param repeatValue
3685
         *            The data to repeat
3686
         * @param size
3687
         *            The number of bytes to fill. Must be compatible with the data
3688
         *            type i.e. if the data type is WORD, the number of bytes must
3689
         *            be divisible by 4
3690
         * @throws IOException
3691
         *             If anything goes wrong with networking.
3692
         * @throws ProcessException
3693
         *             If SpiNNaker rejects a message.
3694
         * @throws InterruptedException
3695
         *             If the communications were interrupted.
3696
         */
3697
        @ParallelSafe
3698
        default void fillMemory(@Valid HasChipLocation chip,
3699
                        @NotNull MemoryLocation baseAddress, int repeatValue,
3700
                        @Positive int size)
3701
                        throws ProcessException, IOException, InterruptedException {
3702
                fillMemory(chip, baseAddress, repeatValue, size, WORD);
×
3703
        }
×
3704

3705
        /**
3706
         * Fill some memory with repeated data.
3707
         *
3708
         * @param chip
3709
         *            The coordinates of the chip
3710
         * @param baseAddress
3711
         *            The address at which to start the fill
3712
         * @param repeatValue
3713
         *            The data to repeat
3714
         * @param size
3715
         *            The number of bytes to fill. Must be compatible with the data
3716
         *            type i.e. if the data type is WORD, the number of bytes must
3717
         *            be divisible by 4
3718
         * @param dataType
3719
         *            The type of data to fill.
3720
         * @throws IOException
3721
         *             If anything goes wrong with networking.
3722
         * @throws ProcessException
3723
         *             If SpiNNaker rejects a message.
3724
         * @throws InterruptedException
3725
         *             If the communications were interrupted.
3726
         */
3727
        @ParallelSafe
3728
        void fillMemory(@Valid HasChipLocation chip,
3729
                        @NotNull MemoryLocation baseAddress, int repeatValue,
3730
                        @Positive int size, @NotNull FillDataType dataType)
3731
                        throws ProcessException, IOException, InterruptedException;
3732

3733
        /**
3734
         * Clear the packet reinjection queues in a monitor process.
3735
         *
3736
         * @param monitorCore
3737
         *            The coordinates of the monitor core.
3738
         * @throws IOException
3739
         *             If anything goes wrong with networking.
3740
         * @throws ProcessException
3741
         *             If SpiNNaker rejects a message.
3742
         * @throws InterruptedException
3743
         *             If the communications were interrupted.
3744
         */
3745
        @ParallelSafe
3746
        void clearReinjectionQueues(@Valid HasCoreLocation monitorCore)
3747
                        throws IOException, ProcessException, InterruptedException;
3748

3749
        /**
3750
         * Clear the packet reinjection queues in some monitor processes.
3751
         *
3752
         * @param monitorCores
3753
         *            The coordinates of the monitor cores.
3754
         * @throws IOException
3755
         *             If anything goes wrong with networking.
3756
         * @throws ProcessException
3757
         *             If SpiNNaker rejects a message.
3758
         * @throws InterruptedException
3759
         *             If the communications were interrupted.
3760
         */
3761
        @ParallelSafe
3762
        void clearReinjectionQueues(@Valid CoreSubsets monitorCores)
3763
                        throws IOException, ProcessException, InterruptedException;
3764

3765
        /**
3766
         * Get the packet reinjection status of a monitor process.
3767
         *
3768
         * @param monitorCore
3769
         *            The coordinates of the monitor core.
3770
         * @return The reinjection status.
3771
         * @throws IOException
3772
         *             If anything goes wrong with networking.
3773
         * @throws ProcessException
3774
         *             If SpiNNaker rejects a message.
3775
         * @throws InterruptedException
3776
         *             If the communications were interrupted.
3777
         */
3778
        @ParallelSafe
3779
        @CheckReturnValue
3780
        ReinjectionStatus getReinjectionStatus(@Valid HasCoreLocation monitorCore)
3781
                        throws IOException, ProcessException, InterruptedException;
3782

3783
        /**
3784
         * Get the packet reinjection status of some monitor processes.
3785
         *
3786
         * @param monitorCores
3787
         *            The coordinates of the monitor cores.
3788
         * @return The reinjection statuses of the cores.
3789
         * @throws IOException
3790
         *             If anything goes wrong with networking.
3791
         * @throws ProcessException
3792
         *             If SpiNNaker rejects a message.
3793
         * @throws InterruptedException
3794
         *             If the communications were interrupted.
3795
         */
3796
        @ParallelSafe
3797
        @CheckReturnValue
3798
        Map<CoreLocation, ReinjectionStatus> getReinjectionStatus(
3799
                        @Valid CoreSubsets monitorCores)
3800
                        throws IOException, ProcessException, InterruptedException;
3801

3802
        /**
3803
         * Reset the packet reinjection counters of a monitor process.
3804
         *
3805
         * @param monitorCore
3806
         *            The coordinates of the monitor core.
3807
         * @throws IOException
3808
         *             If anything goes wrong with networking.
3809
         * @throws ProcessException
3810
         *             If SpiNNaker rejects a message.
3811
         * @throws InterruptedException
3812
         *             If the communications were interrupted.
3813
         */
3814
        @ParallelSafe
3815
        void resetReinjectionCounters(@Valid HasCoreLocation monitorCore)
3816
                        throws IOException, ProcessException, InterruptedException;
3817

3818
        /**
3819
         * Reset the packet reinjection counters of some monitor processes.
3820
         *
3821
         * @param monitorCores
3822
         *            The coordinates of the monitor cores.
3823
         * @throws IOException
3824
         *             If anything goes wrong with networking.
3825
         * @throws ProcessException
3826
         *             If SpiNNaker rejects a message.
3827
         * @throws InterruptedException
3828
         *             If the communications were interrupted.
3829
         */
3830
        @ParallelSafeWithCare
3831
        void resetReinjectionCounters(@Valid CoreSubsets monitorCores)
3832
                        throws IOException, ProcessException, InterruptedException;
3833

3834
        /**
3835
         * Set whether packets (of all types) are to be reinjected.
3836
         *
3837
         * @param monitorCore
3838
         *            The coordinates of the monitor core.
3839
         * @param reinject
3840
         *            True if all packets are to be reinjected.
3841
         * @throws IOException
3842
         *             If anything goes wrong with networking.
3843
         * @throws ProcessException
3844
         *             If SpiNNaker rejects a message.
3845
         * @throws InterruptedException
3846
         *             If the communications were interrupted.
3847
         * @throws InterruptedException
3848
         *             If the communications were interrupted.
3849
         */
3850
        @ParallelSafe
3851
        default void setReinjection(@Valid HasCoreLocation monitorCore,
3852
                        boolean reinject)
3853
                        throws IOException, ProcessException, InterruptedException {
3854
                setReinjectionTypes(monitorCore, reinject, reinject, reinject,
×
3855
                                reinject);
3856
        }
×
3857

3858
        /**
3859
         * Set whether packets (of all types) are to be reinjected.
3860
         *
3861
         * @param monitorCores
3862
         *            The coordinates of some monitor cores.
3863
         * @param reinject
3864
         *            True if all packets are to be reinjected.
3865
         * @throws IOException
3866
         *             If anything goes wrong with networking.
3867
         * @throws ProcessException
3868
         *             If SpiNNaker rejects a message.
3869
         * @throws InterruptedException
3870
         *             If the communications were interrupted.
3871
         */
3872
        @ParallelSafe
3873
        default void setReinjection(@Valid CoreSubsets monitorCores,
3874
                        boolean reinject)
3875
                        throws IOException, ProcessException, InterruptedException {
3876
                setReinjectionTypes(monitorCores, reinject, reinject, reinject,
×
3877
                                reinject);
3878
        }
×
3879

3880
        /**
3881
         * Restore whether packets are to be reinjected to a previously saved state.
3882
         *
3883
         * @param monitorCore
3884
         *            The coordinates of the monitor core.
3885
         * @param status
3886
         *            The saved reinjection status to restore.
3887
         * @throws IOException
3888
         *             If anything goes wrong with networking.
3889
         * @throws ProcessException
3890
         *             If SpiNNaker rejects a message.
3891
         * @throws InterruptedException
3892
         *             If the communications were interrupted.
3893
         */
3894
        @ParallelSafe
3895
        default void setReinjection(@Valid HasCoreLocation monitorCore,
3896
                        @NotNull ReinjectionStatus status)
3897
                        throws IOException, ProcessException, InterruptedException {
3898
                setReinjectionTypes(monitorCore, status.isReinjectingMulticast(),
×
3899
                                status.isReinjectingPointToPoint(),
×
3900
                                status.isReinjectingFixedRoute(),
×
3901
                                status.isReinjectingNearestNeighbour());
×
3902
        }
×
3903

3904
        /**
3905
         * Restore whether packets are to be reinjected to a previously saved state.
3906
         *
3907
         * @param monitorCores
3908
         *            The coordinates of some monitor cores.
3909
         * @param status
3910
         *            The saved reinjection status to restore.
3911
         * @throws IOException
3912
         *             If anything goes wrong with networking.
3913
         * @throws ProcessException
3914
         *             If SpiNNaker rejects a message.
3915
         * @throws InterruptedException
3916
         *             If the communications were interrupted.
3917
         */
3918
        @ParallelSafe
3919
        default void setReinjection(@Valid CoreSubsets monitorCores,
3920
                        @NotNull ReinjectionStatus status)
3921
                        throws IOException, ProcessException, InterruptedException {
3922
                setReinjectionTypes(monitorCores, status.isReinjectingMulticast(),
×
3923
                                status.isReinjectingPointToPoint(),
×
3924
                                status.isReinjectingFixedRoute(),
×
3925
                                status.isReinjectingNearestNeighbour());
×
3926
        }
×
3927

3928
        /**
3929
         * Set what types of packets are to be reinjected.
3930
         *
3931
         * @param monitorCore
3932
         *            The coordinates of the monitor core.
3933
         * @param multicast
3934
         *            True if multicast packets are to be reinjected.
3935
         * @param pointToPoint
3936
         *            True if point-to-point packets are to be reinjected.
3937
         * @param fixedRoute
3938
         *            True if fixed-route packets are to be reinjected.
3939
         * @param nearestNeighbour
3940
         *            True if nearest-neighbour packets are to be reinjected.
3941
         * @throws IOException
3942
         *             If anything goes wrong with networking.
3943
         * @throws ProcessException
3944
         *             If SpiNNaker rejects a message.
3945
         * @throws InterruptedException
3946
         *             If the communications were interrupted.
3947
         */
3948
        @ParallelSafe
3949
        void setReinjectionTypes(@Valid HasCoreLocation monitorCore,
3950
                        boolean multicast, boolean pointToPoint, boolean fixedRoute,
3951
                        boolean nearestNeighbour)
3952
                        throws IOException, ProcessException, InterruptedException;
3953

3954
        /**
3955
         * Set what types of packets are to be reinjected.
3956
         *
3957
         * @param monitorCores
3958
         *            The coordinates of some monitor cores.
3959
         * @param multicast
3960
         *            True if multicast packets are to be reinjected.
3961
         * @param pointToPoint
3962
         *            True if point-to-point packets are to be reinjected.
3963
         * @param fixedRoute
3964
         *            True if fixed-route packets are to be reinjected.
3965
         * @param nearestNeighbour
3966
         *            True if nearest-neighbour packets are to be reinjected.
3967
         * @throws IOException
3968
         *             If anything goes wrong with networking.
3969
         * @throws ProcessException
3970
         *             If SpiNNaker rejects a message.
3971
         * @throws InterruptedException
3972
         *             If the communications were interrupted.
3973
         */
3974
        @ParallelSafeWithCare
3975
        void setReinjectionTypes(@Valid CoreSubsets monitorCores, boolean multicast,
3976
                        boolean pointToPoint, boolean fixedRoute, boolean nearestNeighbour)
3977
                        throws IOException, ProcessException, InterruptedException;
3978

3979
        /**
3980
         * Set the emergency packet reinjection timeout.
3981
         *
3982
         * @param monitorCore
3983
         *            The coordinates of the monitor core.
3984
         * @param timeoutMantissa
3985
         *            The mantissa of the timeout value, between 0 and 15.
3986
         * @param timeoutExponent
3987
         *            The exponent of the timeout value, between 0 and 15.
3988
         * @throws IOException
3989
         *             If anything goes wrong with networking.
3990
         * @throws ProcessException
3991
         *             If SpiNNaker rejects a message.
3992
         * @throws InterruptedException
3993
         *             If the communications were interrupted.
3994
         */
3995
        @ParallelSafe
3996
        void setReinjectionEmergencyTimeout(@Valid HasCoreLocation monitorCore,
3997
                        int timeoutMantissa, int timeoutExponent)
3998
                        throws IOException, ProcessException, InterruptedException;
3999

4000
        /**
4001
         * Set the emergency packet reinjection timeout.
4002
         *
4003
         * @param monitorCore
4004
         *            The coordinates of the monitor core.
4005
         * @param timeout
4006
         *            The timeout value.
4007
         * @throws IOException
4008
         *             If anything goes wrong with networking.
4009
         * @throws ProcessException
4010
         *             If SpiNNaker rejects a message.
4011
         * @throws InterruptedException
4012
         *             If the communications were interrupted.
4013
         */
4014
        @ParallelSafe
4015
        default void setReinjectionEmergencyTimeout(
4016
                        @Valid HasCoreLocation monitorCore, @NotNull RouterTimeout timeout)
4017
                        throws IOException, ProcessException, InterruptedException {
4018
                setReinjectionEmergencyTimeout(monitorCore, timeout.mantissa(),
×
4019
                                timeout.exponent());
×
4020
        }
×
4021

4022
        /**
4023
         * Set the emergency packet reinjection timeout.
4024
         *
4025
         * @param monitorCores
4026
         *            The coordinates of some monitor cores.
4027
         * @param timeoutMantissa
4028
         *            The mantissa of the timeout value, between 0 and 15.
4029
         * @param timeoutExponent
4030
         *            The exponent of the timeout value, between 0 and 15.
4031
         * @throws IOException
4032
         *             If anything goes wrong with networking.
4033
         * @throws ProcessException
4034
         *             If SpiNNaker rejects a message.
4035
         * @throws InterruptedException
4036
         *             If the communications were interrupted.
4037
         */
4038
        @ParallelSafeWithCare
4039
        void setReinjectionEmergencyTimeout(@Valid CoreSubsets monitorCores,
4040
                        int timeoutMantissa, int timeoutExponent)
4041
                        throws IOException, ProcessException, InterruptedException;
4042

4043
        /**
4044
         * Set the emergency packet reinjection timeout.
4045
         *
4046
         * @param monitorCores
4047
         *            The coordinates of some monitor cores.
4048
         * @param timeout
4049
         *            The timeout value.
4050
         * @throws IOException
4051
         *             If anything goes wrong with networking.
4052
         * @throws ProcessException
4053
         *             If SpiNNaker rejects a message.
4054
         * @throws InterruptedException
4055
         *             If the communications were interrupted.
4056
         */
4057
        @ParallelSafeWithCare
4058
        default void setReinjectionEmergencyTimeout(@Valid CoreSubsets monitorCores,
4059
                        @NotNull RouterTimeout timeout)
4060
                        throws IOException, ProcessException, InterruptedException {
4061
                setReinjectionEmergencyTimeout(monitorCores, timeout.mantissa(),
×
4062
                                timeout.exponent());
×
4063
        }
×
4064

4065
        /**
4066
         * Set the emergency packet reinjection timeout.
4067
         *
4068
         * @param monitorCores
4069
         *            The coordinates of some monitor cores.
4070
         * @param status
4071
         *            The saved core status.
4072
         * @throws IOException
4073
         *             If anything goes wrong with networking.
4074
         * @throws ProcessException
4075
         *             If SpiNNaker rejects a message.
4076
         * @throws InterruptedException
4077
         *             If the communications were interrupted.
4078
         */
4079
        @ParallelSafeWithCare
4080
        default void setReinjectionEmergencyTimeout(@Valid CoreSubsets monitorCores,
4081
                        @NotNull ReinjectionStatus status)
4082
                        throws IOException, ProcessException, InterruptedException {
4083
                setReinjectionEmergencyTimeout(monitorCores,
×
4084
                                status.emergencyTimeout());
×
4085
        }
×
4086

4087
        /**
4088
         * Set the packet reinjection timeout.
4089
         *
4090
         * @param monitorCore
4091
         *            The coordinates of the monitor core.
4092
         * @param timeoutMantissa
4093
         *            The mantissa of the timeout value, between 0 and 15.
4094
         * @param timeoutExponent
4095
         *            The exponent of the timeout value, between 0 and 15.
4096
         * @throws IOException
4097
         *             If anything goes wrong with networking.
4098
         * @throws ProcessException
4099
         *             If SpiNNaker rejects a message.
4100
         * @throws InterruptedException
4101
         *             If the communications were interrupted.
4102
         */
4103
        @ParallelSafe
4104
        void setReinjectionTimeout(@Valid HasCoreLocation monitorCore,
4105
                        int timeoutMantissa, int timeoutExponent)
4106
                        throws IOException, ProcessException, InterruptedException;
4107

4108
        /**
4109
         * Set the packet reinjection timeout.
4110
         *
4111
         * @param monitorCore
4112
         *            The coordinates of the monitor core.
4113
         * @param timeout
4114
         *            The timeout value.
4115
         * @throws IOException
4116
         *             If anything goes wrong with networking.
4117
         * @throws ProcessException
4118
         *             If SpiNNaker rejects a message.
4119
         * @throws InterruptedException
4120
         *             If the communications were interrupted.
4121
         */
4122
        @ParallelSafe
4123
        default void setReinjectionTimeout(@Valid HasCoreLocation monitorCore,
4124
                        @NotNull RouterTimeout timeout)
4125
                        throws IOException, ProcessException, InterruptedException {
4126
                setReinjectionTimeout(monitorCore, timeout.mantissa(),
×
4127
                                timeout.exponent());
×
4128
        }
×
4129

4130
        /**
4131
         * Set the packet reinjection timeout.
4132
         *
4133
         * @param monitorCores
4134
         *            The coordinates of some monitor cores.
4135
         * @param timeoutMantissa
4136
         *            The mantissa of the timeout value, between 0 and 15.
4137
         * @param timeoutExponent
4138
         *            The exponent of the timeout value, between 0 and 15.
4139
         * @throws IOException
4140
         *             If anything goes wrong with networking.
4141
         * @throws ProcessException
4142
         *             If SpiNNaker rejects a message.
4143
         * @throws InterruptedException
4144
         *             If the communications were interrupted.
4145
         */
4146
        @ParallelSafeWithCare
4147
        void setReinjectionTimeout(@Valid CoreSubsets monitorCores,
4148
                        int timeoutMantissa, int timeoutExponent)
4149
                        throws IOException, ProcessException, InterruptedException;
4150

4151
        /**
4152
         * Set the packet reinjection timeout.
4153
         *
4154
         * @param monitorCores
4155
         *            The coordinates of some monitor cores.
4156
         * @param timeout
4157
         *            The timeout value.
4158
         * @throws IOException
4159
         *             If anything goes wrong with networking.
4160
         * @throws ProcessException
4161
         *             If SpiNNaker rejects a message.
4162
         * @throws InterruptedException
4163
         *             If the communications were interrupted.
4164
         */
4165
        @ParallelSafeWithCare
4166
        default void setReinjectionTimeout(@Valid CoreSubsets monitorCores,
4167
                        @NotNull RouterTimeout timeout)
4168
                        throws IOException, ProcessException, InterruptedException {
4169
                setReinjectionTimeout(monitorCores, timeout.mantissa(),
×
4170
                                timeout.exponent());
×
4171
        }
×
4172

4173
        /**
4174
         * Set the packet reinjection timeout.
4175
         *
4176
         * @param monitorCores
4177
         *            The coordinates of some monitor cores.
4178
         * @param status
4179
         *            The saved core status.
4180
         * @throws IOException
4181
         *             If anything goes wrong with networking.
4182
         * @throws ProcessException
4183
         *             If SpiNNaker rejects a message.
4184
         * @throws InterruptedException
4185
         *             If the communications were interrupted.
4186
         */
4187
        @ParallelSafeWithCare
4188
        default void setReinjectionTimeout(@Valid CoreSubsets monitorCores,
4189
                        @NotNull ReinjectionStatus status)
4190
                        throws IOException, ProcessException, InterruptedException {
4191
                setReinjectionTimeout(monitorCores, status.timeout());
×
4192
        }
×
4193

4194
        /**
4195
         * Save the application's multicast router tables.
4196
         *
4197
         * @param monitorCores
4198
         *            The coordinates of some monitor cores; the routers on those
4199
         *            chips will have their (current) multicast router tables saved.
4200
         * @throws IOException
4201
         *             If anything goes wrong with networking.
4202
         * @throws ProcessException
4203
         *             If SpiNNaker rejects a message.
4204
         * @throws InterruptedException
4205
         *             If the communications were interrupted.
4206
         */
4207
        @ParallelSafeWithCare
4208
        void saveApplicationRouterTables(@Valid CoreSubsets monitorCores)
4209
                        throws IOException, ProcessException, InterruptedException;
4210

4211
        /**
4212
         * Load the (previously saved) application's multicast router tables. The
4213
         * router tables <em>must</em> have been previously
4214
         * {@linkplain #saveApplicationRouterTables(CoreSubsets) saved}.
4215
         *
4216
         * @param monitorCores
4217
         *            The coordinates of some monitor cores; the routers on those
4218
         *            chips will have their multicast router tables loaded.
4219
         * @throws IOException
4220
         *             If anything goes wrong with networking.
4221
         * @throws ProcessException
4222
         *             If SpiNNaker rejects a message.
4223
         * @throws InterruptedException
4224
         *             If the communications were interrupted.
4225
         */
4226
        @ParallelSafeWithCare
4227
        void loadApplicationRouterTables(@Valid CoreSubsets monitorCores)
4228
                        throws IOException, ProcessException, InterruptedException;
4229

4230
        /**
4231
         * Load the (previously configured) system multicast router tables. The
4232
         * application's router tables <em>must</em> have been previously
4233
         * {@linkplain #saveApplicationRouterTables(CoreSubsets) saved}.
4234
         *
4235
         * @param monitorCores
4236
         *            The coordinates of some monitor cores; the routers on those
4237
         *            chips will have their multicast router tables loaded.
4238
         * @throws IOException
4239
         *             If anything goes wrong with networking.
4240
         * @throws ProcessException
4241
         *             If SpiNNaker rejects a message.
4242
         * @throws InterruptedException
4243
         *             If the communications were interrupted.
4244
         */
4245
        @ParallelSafeWithCare
4246
        void loadSystemRouterTables(@Valid CoreSubsets monitorCores)
4247
                        throws IOException, ProcessException, InterruptedException;
4248

4249
        /**
4250
         * Create a connection to a particular instance of SCAMP. Note that this
4251
         * connection is a new connection; it is not a previously existing
4252
         * connection.
4253
         *
4254
         * @param chip
4255
         *            The location of the chip on the board with this remoteHost
4256
         * @param addr
4257
         *            The IP address of the SpiNNaker board to send messages to.
4258
         * @return The SCP connection to use. It is up to the caller to arrange for
4259
         *         this to be closed at the right time.
4260
         * @throws IOException
4261
         *             If anything goes wrong with socket setup.
4262
         */
4263
        @ParallelSafe
4264
        @MustBeClosed
4265
        @UsedInJavadocOnly(Constants.class)
4266
        SCPConnection createScpConnection(ChipLocation chip, InetAddress addr)
4267
                        throws IOException;
4268
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc