Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Seismic
Open ZGY
Commits
25cb6976
Commit
25cb6976
authored
May 27, 2021
by
Paal Kvamme
Browse files
Prepare for adjusting the genlod chunk size.
parent
5b07a597
Changes
1
Hide whitespace changes
Inline
Side-by-side
native/src/impl/genlod.cpp
View file @
25cb6976
...
...
@@ -403,7 +403,6 @@ GenLodImpl::_accumulate(const std::shared_ptr<const DataBuffer>& data)
* enough and the decimation late enough that the chunk of data being
* decimated has already been added to the histogram.
*
* TODO-@@@: if (_incremental) may want to reduce the block size.
*/
std
::
shared_ptr
<
DataBuffer
>
GenLodImpl
::
_calculate
(
const
std
::
array
<
std
::
int64_t
,
3
>&
readpos_in
,
std
::
int32_t
readlod
)
...
...
@@ -414,11 +413,21 @@ GenLodImpl::_calculate(const std::array<std::int64_t,3>& readpos_in, std::int32_
const
std
::
array
<
std
::
int64_t
,
3
>
readpos
{
readpos_in
[
0
],
readpos_in
[
1
],
0
};
if
(
readpos
[
0
]
>=
surveysize
[
0
]
||
readpos
[
1
]
>=
surveysize
[
1
])
return
nullptr
;
const
std
::
array
<
std
::
int64_t
,
3
>
readsize
{
std
::
min
(
2
*
this
->
_bricksize
[
0
],
(
surveysize
[
0
]
-
readpos
[
0
])),
std
::
min
(
2
*
this
->
_bricksize
[
1
],
(
surveysize
[
1
]
-
readpos
[
1
])),
// Amount of data to read. The method is allowed to return less,
// or even nothing, but only due to going past the survey edge.
// The choice is currently always the same so it is hard coded
// here instead of being passed as a parameter.
// TODO-@@@: if (_incremental) may want to reduce the block size.
const
std
::
array
<
std
::
int64_t
,
3
>
chunksize
{
this
->
_bricksize
[
0
]
*
2
,
this
->
_bricksize
[
1
]
*
2
,
surveysize
[
2
]};
// always read full traces.
const
std
::
array
<
std
::
int64_t
,
3
>
writesize
=
(
readsize
+
std
::
int64_t
(
1
))
/
std
::
int64_t
(
2
);
const
std
::
array
<
std
::
int64_t
,
3
>
readsize
{
std
::
min
(
chunksize
[
0
],
(
surveysize
[
0
]
-
readpos
[
0
])),
std
::
min
(
chunksize
[
1
],
(
surveysize
[
1
]
-
readpos
[
1
])),
chunksize
[
2
]};
// Size of the in-memory buffer of decimated data returned to the caller.
const
std
::
array
<
std
::
int64_t
,
3
>
returnsize
=
(
readsize
+
std
::
int64_t
(
1
))
/
std
::
int64_t
(
2
);
if
(
_verbose
)
std
::
cout
<<
"@"
<<
_prefix
(
readlod
)
...
...
@@ -446,12 +455,11 @@ GenLodImpl::_calculate(const std::array<std::int64_t,3>& readpos_in, std::int32_
wasread
=
true
;
}
else
{
const
std
::
array
<
std
::
int64_t
,
3
>
bs
=
this
->
_bricksize
;
std
::
array
<
std
::
int64_t
,
3
>
offsets
[
4
]
=
{{
0
,
0
,
0
},
{
0
,
bs
[
1
],
0
},
{
bs
[
0
],
0
,
0
},
{
bs
[
0
],
bs
[
1
],
0
}};
{{
0
,
0
,
0
},
{
0
,
chunksize
[
1
],
0
},
{
chunksize
[
0
],
0
,
0
},
{
chunksize
[
0
],
chunksize
[
1
],
0
}};
std
::
shared_ptr
<
DataBuffer
>
hires
[
4
]{
nullptr
,
nullptr
,
nullptr
,
nullptr
};
// TODO-Performance: If algorithm "C" and readlod==1 it should be
...
...
@@ -473,7 +481,7 @@ GenLodImpl::_calculate(const std::array<std::int64_t,3>& readpos_in, std::int32_
// Also, carefully analyze how this affects total memory usage.
for
(
int
ii
=
0
;
ii
<
4
;
++
ii
)
hires
[
ii
]
=
this
->
_calculate
(
readpos
*
std
::
int64_t
(
2
)
+
offsets
[
ii
]
*
std
::
int64_t
(
2
)
,
readlod
-
1
);
hires
[
ii
]
=
this
->
_calculate
(
readpos
*
std
::
int64_t
(
2
)
+
offsets
[
ii
],
readlod
-
1
);
data
=
this
->
_paste4
(
hires
[
0
],
hires
[
1
],
hires
[
2
],
hires
[
3
]);
}
...
...
@@ -500,7 +508,7 @@ GenLodImpl::_calculate(const std::array<std::int64_t,3>& readpos_in, std::int32_
}
else
if
(
data
->
isScalar
())
{
result
=
DataBuffer
::
makeScalarBuffer3d
(
data
->
scalarAsDouble
(),
write
size
,
data
->
datatype
());
(
data
->
scalarAsDouble
(),
return
size
,
data
->
datatype
());
}
else
{
// TODO-Performance: Enable parallelization (in genlod.cpp) of this call.
...
...
@@ -509,14 +517,19 @@ GenLodImpl::_calculate(const std::array<std::int64_t,3>& readpos_in, std::int32_
// parallelize this low level loop. // omp_set_nested(1) or better, use
// omp_set_max_active_levels(...).
result
=
this
->
_decimate
(
data
,
readlod
+
1
);
if
(
result
->
size3d
()
!=
writesize
)
throw
OpenZGY
::
Errors
::
ZgyInternalError
(
"GenLodImpl: Wrong writesize."
);
if
(
result
->
size3d
()
!=
returnsize
)
{
std
::
cout
<<
"Decimation returned "
<<
result
->
size3d
()
<<
", expected "
<<
returnsize
<<
", start "
<<
readpos
<<
", size="
<<
readsize
<<
"
\n
"
;
throw
OpenZGY
::
Errors
::
ZgyInternalError
(
"GenLodImpl: Wrong returnsize."
);
}
}
if
(
this
->
_verbose
)
std
::
cout
<<
"@"
<<
_prefix
(
readlod
)
<<
"calculate returns(lod="
<<
readlod
+
1
<<
", pos="
<<
readpos
<<
" / 2"
<<
", size="
<<
write
size
<<
", size="
<<
return
size
<<
", data="
<<
data
->
toString
()
<<
")
\n
"
;
return
result
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment