Skip to content

Commit

Permalink
add comment describing why a locale's region of a file should be skip…
Browse files Browse the repository at this point in the history
…ped if it's size is one

Signed-off-by: Jeremiah Corrado <[email protected]>
  • Loading branch information
jeremiah-corrado committed Sep 24, 2024
1 parent 03e5621 commit 64ac575
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/packages/ParallelIO.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ module ParallelIO {
const byteOffsets = try! findDelimChunks(fMeta, delim, tld.size, fileBounds, header);
coforall (loc, id) in zip(targetLocales, 0..) do on loc {
const locBounds = byteOffsets[id]..byteOffsets[id+1];

// if byteOffsets looks like [0, 10, 10, 14, 21], then don't try to read 10..10 (locale 1)
if locBounds.size > 1 {
const locFile = try! open(filePath, ioMode.r),
locByteOffsets = try! findDelimChunks(locFile, delim, nTasks, locBounds, headerPolicy.noHeader);
Expand Down Expand Up @@ -261,6 +263,8 @@ module ParallelIO {
const byteOffsets = try! findDelimChunks(fMeta, delim, tld.size, fileBounds, header);
coforall (loc, id) in zip(targetLocales, 0..) do on loc {
const locBounds = byteOffsets[id]..<byteOffsets[id+1];

// if byteOffsets looks like [0, 10, 10, 14, 21], then don't try to read 10..10 (locale 1)
if locBounds.size > 1 {
const locFile = try! open(filePath, ioMode.r),
locByteOffsets = try! findDelimChunks(locFile, delim, nTasks, locBounds, headerPolicy.noHeader);
Expand Down
2 changes: 2 additions & 0 deletions modules/standard/IO.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -7171,6 +7171,8 @@ iter fileReader.lines(
const byteOffsets = findFileChunks(f, targetLocales.size, myBounds);
coforall lid in 0..<targetLocales.size do on targetLocales[tld.orderToIndex(lid)] {
const locBounds = byteOffsets[lid]..byteOffsets[lid+1];

// if byteOffsets looks like [0, 10, 10, 14, 21], then don't try to read 10..10 (locale 1)
if locBounds.size > 1 {
const locFile = try! open(fpath, ioMode.r),
nTasks = if dataParTasksPerLocale>0 then dataParTasksPerLocale
Expand Down

0 comments on commit 64ac575

Please sign in to comment.