Skip to content

Commit

Permalink
Merge pull request #108 from DiamondLightSource/fbp_mem
Browse files Browse the repository at this point in the history
recon methods memory corrections
  • Loading branch information
dkazanc authored Jul 26, 2023
2 parents 9f0a97c + 0b6069b commit 555e934
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions httomolibgpu/recon/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _calc_max_slices_FBP(
astra_out_size = (np.prod(output_dims) * float32().itemsize)

available_memory -= filter_size
slices_max = available_memory // int(in_slice_size + filtered_in_data + freq_slice + fftplan_size + astra_out_size)
slices_max = available_memory // int(2*in_slice_size + filtered_in_data + freq_slice + fftplan_size + 2*astra_out_size)
return (slices_max, float32(), output_dims)


Expand Down Expand Up @@ -137,7 +137,7 @@ def _calc_max_slices_SIRT(
# update_term
C_R_res = C_mat + 2*R_mat
# a guess for astra toolbox memory usage for projection/backprojection
astra_size = 0.5*(x_rec+data_out)
astra_size = 2*(x_rec+data_out)

total_mem = int(data_out + x_rec + R_mat + C_mat + C_R_res + astra_size)
slices_max = available_memory // total_mem
Expand Down Expand Up @@ -224,7 +224,7 @@ def _calc_max_slices_CGLS(
Ad = 2*data_out
s = x_rec
# a guess for astra toolbox memory usage for projection/backprojection
astra_size = 0.5*(x_rec+data_out)
astra_size = 2*(x_rec+data_out)

total_mem = int(data_out + x_rec + d + r + Ad + s + astra_size)
slices_max = available_memory // total_mem
Expand Down
10 changes: 5 additions & 5 deletions tests/test_recon/test_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_reconstruct_FBP_hook(data, flats, darks, ensure_clean_memory):
max_mem,
objsize=objrecon_size)
assert estimated_slices <= actual_slices
assert estimated_slices / actual_slices >= 0.8
assert estimated_slices / actual_slices >= 0.5 # lowering because hook doesn't extend to ASTRA functions

recon_data = recon_data.get()
assert_allclose(np.mean(recon_data), 0.00079770206, rtol=1e-6)
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_reconstruct_SIRT_hook(data, flats, darks, ensure_clean_memory):
max_mem,
objsize=objrecon_size)
assert estimated_slices <= actual_slices
assert estimated_slices / actual_slices >= 0.8
assert estimated_slices / actual_slices >= 0.5 # lowering because hook doesn't extend to ASTRA functions


@cp.testing.gpu
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_reconstruct_SIRT_hook2(ensure_clean_memory):
max_mem,
objsize=objrecon_size)
assert estimated_slices <= actual_slices
assert estimated_slices / actual_slices >= 0.8
assert estimated_slices / actual_slices >= 0.5 # lowering because hook doesn't extend to ASTRA functions


@cp.testing.gpu
Expand Down Expand Up @@ -213,7 +213,7 @@ def test_reconstruct_CGLS_hook(data, flats, darks, ensure_clean_memory):
objsize=objrecon_size)

assert estimated_slices <= actual_slices
assert estimated_slices / actual_slices >= 0.8
assert estimated_slices / actual_slices >= 0.5 # lowering because hook doesn't extend to ASTRA functions


@cp.testing.gpu
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_reconstruct_CGLS_hook2(ensure_clean_memory):
max_mem,
objsize=objrecon_size)
assert estimated_slices <= actual_slices
assert estimated_slices / actual_slices >= 0.8
assert estimated_slices / actual_slices >= 0.5 # lowering because hook doesn't extend to ASTRA functions


@cp.testing.gpu
Expand Down

0 comments on commit 555e934

Please sign in to comment.