-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CUDARelativeDifferencePrior #1408
Merged
Merged
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
5745b8c
first attempt at integration with stir
Imraj-Singh 2c4fa32
attempting to add to registry
Imraj-Singh 52c4943
registry add and cmake cuda package/include dirs
Imraj-Singh f41728e
changes to cudarelativedifference prior const etc
Imraj-Singh d3f3732
updated Cmakelists
Imraj-Singh 063633e
attempting to get the registries to work...
Imraj-Singh 483cc13
update cuda error
Imraj-Singh 7e26bd4
Merge branch 'UCL:master' into cuda_stir
Imraj-Singh 0249e93
Register errors
Imraj-Singh 843cd13
Merge branch 'UCL:master' into cuda_stir
Imraj-Singh 5eec80b
error handling in cmake
Imraj-Singh 2e90b17
Merge branch 'UCL:master' into cuda_stir
Imraj-Singh 13def4f
Not working, but added the functionality and the registery works than…
Imraj-Singh 5ddce33
Added small test, constructors not inheriting correctly causing an error
Imraj-Singh 1a7d4d4
Merge branch 'UCL:master' into cuda_stir
Imraj-Singh 1c61543
using parent constructors in RegisteredParsingObject
KrisThielemans 5b3f768
fix CUDARDP constructors and set_up etc
KrisThielemans 8cc358f
fix set_up() signature for both RDP versions
KrisThielemans 08d0f81
run clang-format on .cu files
KrisThielemans 227c48e
[recon_test_pack] add a test for parallelproj and CUDARDP
KrisThielemans 95e8428
minor clean-up of CUDA RDP
KrisThielemans aed4a1d
[CMake] use check_language(CUDA)
KrisThielemans f163578
run dos2unix
KrisThielemans f79f95b
[CMake] only compile cuda_rdptest if CUDA is enabled
KrisThielemans 35937dd
disable using constructors for SWIG
KrisThielemans 9e8daae
[recon_test_pack] remove set -e to avoid early exit
KrisThielemans 2e45fdc
[SWIG] reduce some SWIG warnings
KrisThielemans 304f121
fix CUDA error handling
KrisThielemans 8825485
create helper functions for Arrays <-> CUDA device
KrisThielemans 50ae299
more *Prior::set_* functions require set_up()
KrisThielemans 51ef4fc
CudaRDP: move weights and kappa to set_up
KrisThielemans 06ec3de
CudaRDP: use float in kernel for value
KrisThielemans 3e04184
don't run CUDA tests on GHA
KrisThielemans a5ccc4c
CudaRDP: minor clean-up
KrisThielemans d2f6d6d
correct check for kappa
KrisThielemans c31953e
CudaRDP: more checks and document 3x3x3 limitation
KrisThielemans a0114ab
CudaRDP: put cppdim3 type in the class definition
KrisThielemans ef66303
add CudaRDP to test_priors (but fails)
KrisThielemans c634a0d
Cuda RDP fixes
KrisThielemans 165da28
decrease verbosity of SeperableGaussianFilter
KrisThielemans 7ac03fd
correct array_to_device for non-contiguous case
KrisThielemans fa4d7fe
correct test on kappa characteristics in all priors
KrisThielemans ccc962a
add and correct tests for priors with kappa (still fails on RDP)
KrisThielemans dcd3b86
reduce eps for numerical Hessian test
KrisThielemans 3e43ca7
make running of CUDA tests optional
KrisThielemans 66c082b
skip CUDA test if nvidia-smi not found
KrisThielemans 7a2cf76
CudaRDP: honour elemT template argument
KrisThielemans 44dad5a
update release notes on the CUDA RDP [ci skip]
KrisThielemans d4f2c9b
added ctest for CUDA vs non-CUDA RDP
KrisThielemans 05cdfaf
added RDP timings to stir_timings
KrisThielemans 1f0d692
disable CUDA RDP tests if no CUDA found
KrisThielemans File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/include/stir/recon_buildblock/CUDA_stir/CudaRelativeDifferencePrior.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef CUDA_RELATIVE_DIFFERENCE_PRIOR_CLASS_H | ||
#define CUDA_RELATIVE_DIFFERENCE_PRIOR_CLASS_H | ||
|
||
#include "stir/recon_buildblock/RelativeDifferencePrior.h" | ||
#include "stir/DiscretisedDensity.h" | ||
#include <cuda_runtime.h> | ||
#include "stir/Succeeded.h" | ||
|
||
START_NAMESPACE_STIR | ||
|
||
template <typename elemT> | ||
class CudaRelativeDifferencePrior : public RelativeDifferencePrior<elemT> { | ||
public: | ||
using RelativeDifferencePrior<elemT>::RelativeDifferencePrior; | ||
// Name which will be used when parsing a GeneralisedPrior object | ||
static const char* const registered_name; | ||
|
||
// Constructors | ||
CudaRelativeDifferencePrior(); | ||
CudaRelativeDifferencePrior(const bool only_2D, float penalization_factor, float gamma, float epsilon); | ||
|
||
// Overridden methods | ||
double compute_value(const DiscretisedDensity<3, elemT>& current_image_estimate) override; | ||
void compute_gradient(DiscretisedDensity<3, elemT>& prior_gradient, const DiscretisedDensity<3, elemT>& current_image_estimate) override; | ||
|
||
// New methods | ||
Succeeded set_up_cuda(shared_ptr<DiscretisedDensity<3, elemT>> const& target_sptr); | ||
protected: | ||
int z_dim, y_dim, x_dim; | ||
dim3 grid_dim, block_dim; | ||
bool cuda_set_up = false; | ||
}; | ||
|
||
END_NAMESPACE_STIR | ||
|
||
#endif // CUDA_RELATIVE_DIFFERENCE_PRIOR_CLASS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the other way around. I'd probably use https://cmake.org/cmake/help/latest/module/CheckLanguage.html#module:CheckLanguage first, if present, then
enable_language
, thenfind_package(CUDAToolkit)
which probably needs aREQUIRED
.Before all this, I'd do a check on CMAKE_VERSION. Certainly at least 3.18, but 3.23 if we want to use
"all" for [CMAKE_CUDA_ARCHITECTURES](https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html#prop_tgt:CUDA_ARCHITECTURES) (which we do). If the CMake version is too old, generate FATAL_ERROR with the message to set
DISABLE_STIR_CUDA=ON`.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, don't use
include_directories
buttarget_include_directories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done here: d3f3732
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's this line: