mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-10-12 17:02:02 -05:00
convertSats(): Transpose loop nest for locality of data
This commit is contained in:
1 parent
d7e098bccd
commit
e174e32c44
1 file changed
+13
-5
@@ -780,14 +780,22 @@ namespace Opm
|
|||||||
inline std::vector<double>
|
inline std::vector<double>
|
||||||
convertSats(const std::vector< std::vector<double> >& sat)
|
convertSats(const std::vector< std::vector<double> >& sat)
|
||||||
{
|
{
|
||||||
const int np = sat.size();
|
const auto np = sat.size();
|
||||||
const int nc = sat[0].size();
|
const auto nc = sat[0].size();
|
||||||
|
|
||||||
std::vector<double> s(np * nc);
|
std::vector<double> s(np * nc);
|
||||||
for (int c = 0; c < nc; ++c) {
|
|
||||||
for (int p = 0; p < np; ++p) {
|
for (decltype(sat.size()) p = 0; p < np; ++p) {
|
||||||
s[np*c + p] = sat[p][c];
|
const auto& sat_p = sat[p];
|
||||||
|
double* sp = & s[0*nc + p];
|
||||||
|
|
||||||
|
for (decltype(sat[0].size()) c = 0;
|
||||||
|
c < nc; ++c, sp += np)
|
||||||
|
{
|
||||||
|
*sp = sat_p[c];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
} // namespace Details
|
} // namespace Details
|
||||||
|
|||||||
Reference in new issue
Block a user