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

GPU operation doesn't help for GratingGSM #2

Open
Samson-Ming opened this issue Nov 4, 2024 · 2 comments
Open

GPU operation doesn't help for GratingGSM #2

Samson-Ming opened this issue Nov 4, 2024 · 2 comments

Comments

@Samson-Ming
Copy link

Hi Professor Shcherbakov,

I tried to convert all the variables in GratingGSM for GPU operation to accelerate the algorythm by A=gpuArray(single(A)), but unfortunatelly,it seems not work very well, in fact the simulation time increase about 10 times compared with those on CPU.

In principle, the algorythm involves large amount of matrix mulplication, and GPU operation should have effect, and I'm not sure what the problem is, could you please share some of your experience? Thank you so much.

Best regards

Xianshun

@aashcher
Copy link
Owner

Dear Xianshun,

I think the direct transfer to GPU using high-level matlab or python functions will not help much, since the computations are sensitive to memory transfers and code organization. For GPU calculations I wrote a separate C++ CUDA code.

And btw, 10 times for double-precision simulations may be a good result depending on the model of your GPU. Please, look carefully at graphic card specifications and note a huge performance difference for different data types.

Best,
Alexey.

@Samson-Ming
Copy link
Author

Dear Professor Shcherbakov,

Thank you so much for your instruction. Well, advanced technique like GPU operation is really complicated for primary users like me unfamiliar with C++ CUDA code. But I also tried matlab code with single precision (no GPU involved), the algorithm can be speeded up a little with little impact on the diffraction efficiencies.

Best regards

Xianshun

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

No branches or pull requests

2 participants