Skip to content
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 90 commits into from
Apr 16, 2021
Merged

V1.1.0 alpha #34

merged 90 commits into from
Apr 16, 2021

Conversation

benjamindkilleen
Copy link
Member

making alpha release for v1.1

mmjudish and others added 30 commits January 12, 2021 10:09
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
Lots of comments outlining details of what the mass_attentuation code is doing and how I can attack the problem of parallelizing it using the GPU
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?
The bug was actually in the test--the mesh box tested on the master branch was missing four of its twelve edges.  Accordingly, the mass-attenuation branch was projecting a different object than the master branch, so OF COURSE the resulting images would differ.
Faster mass attenuation using CUDA not pycuda, ~20% speedup
@benjamindkilleen benjamindkilleen merged commit 766a10f into master Apr 16, 2021
@benjamindkilleen benjamindkilleen deleted the v1.1.0-alpha branch April 16, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants