-
Notifications
You must be signed in to change notification settings - Fork 60
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
V1.1.0 alpha #34
Merged
Merged
V1.1.0 alpha #34
Conversation
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
1. Fixed the #defines in project_kernel.cu to solve the PyCuda compilation errors of "expected an expression" 2. Edited a docstring to match the filename in its function 3. Ad hoc implemented Volume.spacing(). This is not meant to be a correct implementation, just -some- value to return so that example_projector.py runs 4. Completed the "wire box" in example_projector.py so match the description of the simple phantom
Working on folding the mass_attenuation Python code into the projectKernel function. What I have NOT yet finished for this "folding" is implemented the get_absorbtion_coefs(energy, mat) call in CUDA. Added mat_coefs_for_kernel.cu to hold constant material_coefficient values, but won't need that file later. The insight is that get_absorbtion_coefs(energy, mat) is NOT a function of the pixel--accordingly, we can pre-compute the values and store them in a [n_bins x NUM_MATERIALS] table, where n_bins is the number of different energy values ("spectral bins"). This prec-computed table will be a field of the projector.py:Projector class, and can be passed in as an argument to project_kernel.cu:project_kernel(...) via the projector.py:Projector._project(self, ...) method.
Allocated a bunch of stuff in projector.py:Projector.initialize(self). Changed projector.py:Projector.project(...) to bypass the deprecated mass_attenuation function I haven't tested it (not for accuracy, not even to see if it runs), but it's late, and tomorrow exists.
Images are visually VERY similar to before CUDA optimization. The difference seems to be the intensity of the black pixels in the output image. I think that might have something to do with the conversion of attenuation_gpu = cumath.exp(attenuation_gpu) * energy * p to CUDA code
Parameter *output was unnecessary. Each pixel can store its material channels privately. Still having an issue with the "phi={30,60,120}" images -- those for which phi != 90. The cube at the center of the volume appears a bit ephemeral, when I think it's supposed to look very solid. I will check out how the alpha branch (non-CUDA mass attenuation) treats it.
Decided to use expf(...) to modify intensity_tmp in projectKernel(...), rather than exp10f(...). From the PyCuda documentation: "The pycuda.cumath module contains elementwise workalikes for the functions contained in [the Python math module]." The math module's exp(...) function uses base e, hence I now selected the expf(...) function.
Methinks I was missing a division by 1000 -- this is now handled by the "noncont_energies" I also had missed normalizing the pdf before copying it to the GPU. This is now handled by "noncont_pdf"
Now, the pixel diff image appears to be solely the farther-away square face of the wire mesh
Whether or not I normalize noncont_pdf (by dividing it by its sum), the output image is the same. Accordingly, the diff image is the same whether or not I normalize the pdf. That the code behaves the same if pdf is changed by a factor f_1 versus f_2 is very interesting. Could that be the source of my bug?
Faster mass attenuation using CUDA not pycuda, ~20% speedup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
making alpha release for v1.1