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

Non-CUDA alternatives #16

Open
AmosEgel opened this issue Apr 26, 2018 · 4 comments
Open

Non-CUDA alternatives #16

AmosEgel opened this issue Apr 26, 2018 · 4 comments
Projects

Comments

@AmosEgel
Copy link
Contributor

AmosEgel commented Apr 26, 2018

Right now, the user needs to have a setup with Matlab, CUDA and C++ compiler available to even test our software.

It would be great to have an alternative Matrix-Vector product that runs on the CPU only. This function will probably be slower than the current, but at least allow the user to test the software.

This could be achieved either by a Matlab script coupling_matrix_multiply_CPU.m or by a c++ file that does what coupling_matrix_multiply_CUDA.cu does (and which is compiled by mex).

@lpattelli lpattelli added this to To do in CELES v3 Apr 26, 2018
@arunoruto
Copy link

arunoruto commented May 11, 2022

I am currently on it to implement a pure C++ variant of the translationMatrixProduct function in coupling_matrix_multiply_CUDA.cu. I wanted to precompute the associated legendre and hankel function values and pass them to the C++ function. But the assocLegendreFunction C++ function defined in coupling_matrix_multiply_CUDA.cu gives different results than the built in function of matlab and python. It looks similar to this expression, but the results still differ to just simply calling legendre(n, cos(theta)) (matlab) or lpmv(m, l, cos(theta)) (python).
I could use your provided function, but I thought maybe it would be simpler to use the already provided matlab and python functions since they are also highly optimized.

@AmosEgel
Copy link
Contributor Author

Hey Mirza, that's good to hear!
With regard to the associated Legendre functions: there exist different normalizations. You could try different input to the normalization argument of Matlab's legendre function. If I recall correctly, one of the normalization options is equivalent to what we use with CELES.
The strategy that we follow in CELES is based on the fact that P_lm is simply a polynomial expression in sin and cos of the polar angle of the relative position vector between two particles. So we precompute the coefficients of these polynoms and then in the fast CUDA kernel we evaluate sin and cos of the angle and get P_lm my evaluating the polynomial expression with the given (precomputed) polynom coefficients.

@arunoruto
Copy link

Hello Amos,
I have been tinkering with a non-CUDA variant of the .cu file and came up with this function here. I did not have time to put it in a mex function, but under python `cffi it works nicely and the result matches with the one obtained using Matlab.

Regarding my question about the normalization, what I was missing, was the c_ml coefficient here. But that has also been resolved nicely.

I am currently trying to implement the code in python just so I can make it easier to deploy on any machine, since I am currently using a weird setup utilizing a docker container with a specific CUDA version and a mounted instance of Matlab and X11 forwarding.

To be also transparent about the project, I have also mentioned you in the credits and your paper to be cited ;)
If someone is motivated to contribute to this implementation, you will be very welcomed. I am planning only to convert the parts I currently need for my own needs, which would be the incidence and scattering coefficients. Everything beyond it isn't in my interest sadly. But I will make my extensions regarding the computation of cross-sections and similar values available here and possible create pull request to your Matlab implementation down the road.

@AmosEgel
Copy link
Contributor Author

Hi Mirza,
wow that is great news. I know that @lpattelli was also thinking about a Python version of CELES. Great that you have done that now.

I am planning only to convert the parts I currently need for my own needs, which would be the incidence and scattering coefficients. Everything beyond it isn't in my interest sadly.

Fair enough. If people need other functionality, they can still fall back to the Matlab version or port the functions to Python themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
CELES v3
  
To do
Development

No branches or pull requests

2 participants