Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
Nabu
Commits
2331fe1a
Commit
2331fe1a
authored
Jun 10, 2020
by
Pierre Paleo
Browse files
Rework build_sino
parent
65c62fa6
Pipeline
#27044
passed with stages
in 2 minutes and 28 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nabu/app/fullfield.py
View file @
2331fe1a
...
...
@@ -406,6 +406,8 @@ class FullFieldPipeline:
def
_build_sino
(
self
,
radios
=
None
):
if
radios
is
None
:
radios
=
self
.
radios
# Either a new array (previously allocated in "_sinobuilder_output"),
# or a view of "radios"
self
.
sinos
=
self
.
sino_builder
.
radios_to_sinos
(
radios
,
output
=
self
.
_sinobuilder_output
,
...
...
nabu/app/fullfield_cuda.py
View file @
2331fe1a
...
...
@@ -294,22 +294,31 @@ class CudaFullFieldPipelineLimitedMemory(CudaFullFieldPipeline):
# Copy D2H
self
.
_d_radios
[:
transfer_size
,
:,
:].
get
(
ary
=
self
.
_h_radios
[
start_idx
:
end_idx
])
self
.
logger
.
debug
(
"End of processing steps on radios"
)
# release cuda memory
replace_array_memory
(
self
.
_d_radios
,
(
1
,))
self
.
_d_radios
=
None
# Restore original processing steps
self
.
processing_steps
=
self
.
_processing_steps
# Initialize sino builder
if
"build_sino"
in
self
.
processing_steps
:
self
.
_init_sino_builder
()
# release cuda memory of _d_radios if a new array was allocated for sinograms
if
self
.
_sinobuilder_output
is
not
None
:
replace_array_memory
(
self
.
_d_radios
,
(
1
,))
self
.
_d_radios
=
None
# otherwise use the buffer of _d_radios for _d_sinos
else
:
self
.
_d_sinos
=
garray
.
empty
(
self
.
sino_builder
.
output_shape
,
"f"
,
gpudata
=
self
.
_d_radios
.
gpudata
)
self
.
_d_sinos
.
fill
(
0
)
def
_process_chunk_sinos
(
self
):
"""
Perform the processing in the "sinograms space"
"""
self
.
processing_steps
=
self
.
_processing_steps
self
.
logger
.
debug
(
"Initializing processing on sinos"
)
self
.
_init_sino_builder
()
self
.
_tmp_h_sinos
=
np
.
zeros
(
self
.
_d_sinos
.
shape
,
"f"
)
self
.
_sinobuilder_output
=
self
.
_tmp_h_sinos
self
.
_prepare_reconstruction
()
self
.
_init_reconstruction
()
self
.
_init_writer
()
...
...
@@ -324,10 +333,15 @@ class CudaFullFieldPipelineLimitedMemory(CudaFullFieldPipeline):
start_idx
=
i
*
group_size
end_idx
=
min
((
i
+
1
)
*
group_size
,
self
.
delta_z
)
transfer_size
=
end_idx
-
start_idx
# not useful here as delta_z % chunk_size == 0
# Build sinograms on host
. Use a view of
_h_radios
# Build sinograms on host
using
_h_radios
self
.
_build_sino
(
radios
=
self
.
_h_radios
[:,
start_idx
:
end_idx
,
:])
# Copy H2D
self
.
_d_sinos
[:,
:,
:]
=
self
.
_sinobuilder_output
[:,
:,
:]
# pycuda does not support copy where "order" is not the same
# (self.sinos might be a view on self.radios)
if
not
self
.
sinos
.
flags
[
"C_CONTIGUOUS"
]:
self
.
sinos
=
np
.
ascontiguousarray
(
self
.
sinos
)
#
self
.
_d_sinos
[:,
:,
:]
=
self
.
sinos
[:,
:,
:]
# Process stack of sinograms (chunk_size, n_angles, width)
self
.
_reconstruct
(
sinos
=
self
.
_d_sinos
)
# Copy D2H
...
...
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