SPECTGPU:starting point; created SPECTGPU_projector folder and schel… - #1687
danieldeidda wants to merge 17 commits into
Conversation
…eton classe, atm a lot of copy from niftyGPU
…calls the kernels; we need to double check that the kernel can write into the sino but probably we need to dodevice_to_host(stir_sino,cuda_array_created_by_forward)
… that calls the kernels; we need to double check that the kernel can write into the sino but probably we need to dodevice_to_host(stir_sino,cuda_array_created_by_forward)
| float* dev_image; | ||
| cudaMalloc(&dev_image, stir_image.size_all() * sizeof(float)); |
There was a problem hiding this comment.
could use
CuVec<float> dev_image(stir_image.size_all());
then you don't need to free at the end. If so, you can pass it to a kernel as dev_image.data().
Also, you probably want to have this out of the loop.
There was a problem hiding this comment.
ignoring Cuvec for now
addition of wrappers for actual_FP/BP removal of most of helper currently FP and BP work pretty well and are very close to spectUB rough speed estimate on debug mode were: SPECTUB 3min36s SPECTGPU 20s 3x3x3 gaussian kernel was fine for FP but introduced holes artifact in BP it was necessary to change the kernel to a 5x5x7 with sigma 2 to make a BPimage very close to SPECTUB. Speed above is related to 5x5x7.
addition of wrappers for actual_FP/BP removal of most of helper currently FP and BP work pretty well and are very close to spectUB rough speed estimate on debug mode were: SPECTUB 3min36s SPECTGPU 20s 3x3x3 gaussian kernel was fine for FP but introduced holes artifact in BP it was necessary to change the kernel to a 5x5x7 with sigma 2 to make a BPimage very close to SPECTUB. Speed above is related to 5x5x7.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 65 |
| Duplication | 15 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
adapted PairProjectorByBinUsingSPECTGPU to be able to run reconstruction
|
Hi. looks like great progress! Obviously, I'm interested to know some timings :-)
no, we don't. The SPECTUB projector backprojector is adjoint (as it uses the matrix), so has the correct scale. |
|
I thought there was some scaling in SPECTUB as I always need to multiply by the number of views to get images in the right scale. Anyway in debug mode with no OMP around 300s 2 iterations fully 3D PSF and AC I am reconstructing with SPECTUB now but it's been running for a while and not finished the first iter yet. GPU recon with no correction is 90 s and 160s only AC |
Added Hei Yin Jowett Chan as an author to the file.
pdate authorship
Jowett: Revert authorship added to the wrong file
|
interesting. only with OMP? I think it's indeed the case that the There's various issues here:
I guess the last one is the main one. |
|
Yes that's it! I think that is because the image needs to be updated as the function is called for every view. But then I should copy outside of this call maybe in start_accumulating and free in get_output? so that the BP just updates the output image |
|
Definitely try to do as much of allocation/transfer as you can upfront, or at the back, e.g. For the forward projector, you'd still run into trouble I think with the output viewgrams, not sure. For this reason, the parallelprojand NiftyPET interface do all the work upfront/at the end. This however creates trouble as well, as it means we'll be forward projecting all of the data, even if we only do a subset. There's considerably overhead there. |
fix problem with OMP by allocating images outside of the kernel
|
Update on release comparison (8 subsets, 16 iterations): |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 65 |
| Duplication | 15 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
KrisThielemans
left a comment
There was a problem hiding this comment.
Looks good, but some comments (mostly house-keeping)
- add SPECTGPU in doxygengroups.h
indeces->indices- run
pre-commit - I strongly recommend to use CuVeC for all your pointers. No more need for
cudaFree, no memory leaks. - It'd be nice to have more
const int var = .... could even speed things up (probably not though) - If you copied code from NiftyRec, you need to adapt your copyright header.
| void copy_im_to_stir( | ||
| DiscretisedDensity<3,float>& image, | ||
| const float* dev_image); | ||
|
|
||
| void copy_stir_im_to_dev( | ||
| float* dev_image, | ||
| const DiscretisedDensity<3,float>& image); |
There was a problem hiding this comment.
there's no reason for these. Just directly call array_to_host etc.
|
|
||
| void run_backward_projection_cuda( | ||
| const RelatedViewgrams<float>& stir_sino, | ||
| float* dev_image, |
There was a problem hiding this comment.
This is the output arg,so in STIR convention it needs to come first.
| std::vector<float> _crs; | ||
| std::vector<short> _s2c; |
There was a problem hiding this comment.
I'd prefer less cryptic variable names
| See STIR/LICENSE.txt for details | ||
| */ | ||
|
|
||
| #pragma once |
There was a problem hiding this comment.
surprising, but this is not portable. Use the usual #ifdef stuff
|
|
||
| #pragma once | ||
|
|
||
| #include <cuda_runtime.h> |
There was a problem hiding this comment.
doesn't seem to be needed to include it here
|
|
||
| if (o1!=o2) | ||
| { | ||
| std::cout << "image origin: " |
There was a problem hiding this comment.
can't use std::cout.I suppose put them all in a string, but better to use has_same_characteristics()
| std::fabs(this->spacing_x - tg_spacing> 1e-5f) ) | ||
| { | ||
| error( | ||
| "SPECTGPU: expected axial and tangential dimensions/spacings " |
| _slope(-1), | ||
| _sigma0(-1), |
There was a problem hiding this comment.
strange defaults. might be ok, but dangerous?
| // array_to_device(dev_image, stir_image); | ||
|
|
||
|
|
||
| float3 spacing = make_float3(spacing_x, |
There was a problem hiding this comment.
I find it somewhat confusing to switch from STIR's z,y,x to x,y,z
| // << " stir view = " << vg.get_view_num() | ||
| // << std::endl; | ||
| //the following sign is introduced to match SPECTUB | ||
| float angle_rad = -vg.get_view_num() * 2.f * M_PI / num_views; |
There was a problem hiding this comment.
I would vastly prefer to use the STIR function to get the angle (vg.get_phi() I guess)







…eton classe, atm a lot of copy from niftyGPU
Changes in this pull request
Testing performed
Related issues
Checklist before requesting a review
documentation/release_XXX.mdhas been updated with any functionality change (if applicable)Contribution Notes
Please tick the following: