Skip to content

Commit

Permalink
there is one region and if empty write to data asap
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-B committed Sep 2, 2024
1 parent fdb1060 commit 93ec756
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,9 @@ private static final class WorkItems {
* theoretically be done in any order... but needs to be processed
* single-threaded anyway.
*/
private final List<List<Region>> regions;
private final List<Region> regions;

WorkItems(Monitor m, List<List<Region>> region) {
WorkItems(Monitor m, List<Region> region) {
this.monitor = m;
this.regions = region;
}
Expand Down Expand Up @@ -257,11 +257,16 @@ private Map<ChipLocation, List<WorkItems>> discoverActualWork(
m.updateTransactionIdFromMachine(txrx);

for (var p : m.getPlacements()) {
var regions = new ArrayList<List<Region>>();
var regions = new ArrayList<Region>();
for (int id : p.getVertex().getRecordedRegionIds()) {
var r = getRegion(p, id);
regions.add(r);
count += r.size();
if (r.size > 0) {
regions.add(r);
count += 1;
} else {
storeData(r, allocate(0));
}

}
workitems.add(new WorkItems(m, regions));
}
Expand Down Expand Up @@ -363,19 +368,17 @@ private void fastDownload(List<WorkItems> work,
log.info("processing fast downloads for {}", conn.getChip());
var dl = new Downloader(conn);
for (var item : work) {
for (var regionsOnCore : item.regions) {
for (var region : item.regions) {
/*
* Once there's something too small, all subsequent
* retrieves for that recording region have to be done the
* same way to get the data in the DB in the right order.
*/
for (var region : regionsOnCore) {
var data = dl.doDownload(item.monitor, region);
if (SPINNAKER_COMPARE_DOWNLOAD != null) {
compareDownloadWithSCP(region, data);
}
storeData(region, data);
var data = dl.doDownload(item.monitor, region);
if (SPINNAKER_COMPARE_DOWNLOAD != null) {
compareDownloadWithSCP(region, data);
}
storeData(region, data);
}
}
}
Expand Down Expand Up @@ -479,7 +482,7 @@ private static List<String> describeChunk(Chunk<Byte> chunk) {
*/
@UsedInJavadocOnly(BufferManagerStorage.class)
@ForOverride
protected abstract List<Region> getRegion(Placement placement, int regionID)
protected abstract Region getRegion(Placement placement, int regionID)
throws IOException, ProcessException, StorageException,
InterruptedException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ private IntBuffer getCoreRegionTable(CoreLocation core, Vertex vertex)
}

@Override
protected List<Region> getRegion(Placement placement, int regionID)
protected Region getRegion(Placement placement, int regionID)
throws IOException, ProcessException, InterruptedException {
var b = getCoreRegionTable(placement.asCoreLocation(),
placement.getVertex());
// TODO This is wrong because of shared regions!
int size = b.get(regionID + 1) - b.get(regionID);
return List.of(new Region(placement, regionID,
new MemoryLocation(b.get(regionID)), size));
return new Region(
placement, regionID, new MemoryLocation(b.get(regionID)), size);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ private List<RecordingRegion> getRegions(Placement placement)
}

@Override
protected List<Region> getRegion(Placement placement, int index)
protected Region getRegion(Placement placement, int index)
throws IOException, ProcessException, InterruptedException {
var region = getRegions(placement).get(index);
log.debug("got region of {} R:{} as {}", placement.asCoreLocation(),
index, region);
return List.of(new Region(placement, index, region.data,
(int) region.size));
return new Region(placement, index, region.data, (int) region.size);
}

@Override
Expand Down

0 comments on commit 93ec756

Please sign in to comment.