[go: nahoru, domu]

Skip to content

Commit

Permalink
Multi-threaded reader for PSI iO
Browse files Browse the repository at this point in the history
  • Loading branch information
jlhcrawford committed Nov 11, 2022
1 parent 3b0b9e5 commit fc1dc72
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions misc/psi/io/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ helib::Database<TXT> readDbFromFile(const std::string& databaseFilePath,
}
}
} else { // Ctxt query
for (long i = 0; i < nrow; ++i) {
for (long j = 0; j < ncol; ++j) {
reader.value().readDatum(data(i, j), i, j);
}
NTL_EXEC_RANGE(nrow * ncol, first, last)
Reader<TXT> threadReader(reader.value());
for (long i = first; i < last; ++i) {
long row = i / ncol;
long col = i % ncol;
threadReader.readDatum(data(row, col), row, col);
}
NTL_EXEC_RANGE_END
}

return helib::Database<TXT>(data, contextp);
Expand Down Expand Up @@ -128,11 +131,14 @@ helib::Matrix<TXT> readQueryFromFile(const std::string& queryFilePath,
}
} else { // Ctxt query
// Read in ctxts
for (long i = 0; i < nrow; ++i) {
for (long j = 0; j < ncol; ++j) {
reader.value().readDatum(query(i, j), i, j);
}
NTL_EXEC_RANGE(nrow * ncol, first, last)
Reader<TXT> threadReader(reader.value());
for (long i = first; i < last; ++i) {
long row = i / ncol;
long col = i % ncol;
threadReader.readDatum(query(row, col), row, col);
}
NTL_EXEC_RANGE_END
if (ncol == 1) { // Transpose to make row vector
query.transpose();
}
Expand Down

0 comments on commit fc1dc72

Please sign in to comment.