-
Notifications
You must be signed in to change notification settings - Fork 16
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
Discussion: merge gpu and cpu code? #129
Comments
I think this is a great idea. Reducing duplicate code is always good, and I think this isn't "ugly" at all really - seems like the best possible implementation. How/when would you like to implement this? I'm still working on the MONARCH implementation (which is moving pretty well). After that, I can help if needed. |
I can start it on Monday. I will push first the pull request of #126, and then continue with this, since it sounds good for you too. |
Note: Conflict between |
Note: |
Hi @cguzman95 - I think it would be better if we found solutions to these problems now. I don't want to start introducing a lot of patches and work-arounds into the code just to get something to run, even if it takes a little longer in the design phase. For the |
For the |
About the first question: Yes, if a function is declared with About the second question: I will investigate further that and solutions. If I remember well from when I was investigating this, the main problem was the |
Hi @cguzman95 - that sounds great. For the |
for the |
For the For the second: Now that I google a bit, seems there are nice solutions |
That looks like a perfect solution. For the |
Yep, I'm doing first the changes on reactions from CUDA folder, and after having all working (including taking a look on Related to this, can you help me with the compilation of the main reactions to accept CUDA code like |
sure, this seems like a CMake configuration question, right? I'm not an expert, but I can see if I can find something that will work. I'm ok with changing the extension, as long as it doesn't affect the non-GPU build process. Is it ok to work on your branch today? (I have a little time because I'm waiting on MONARCH runs, and the queue times are really long). |
My last branch in GitHub was #126, which is finish with a pull request. It would be better to create another branch. It should be only a change in the extension to .cpp and make some function like |
Another thing, doing this I've noticed that in the future we should reduce model_data in little structs. Explanation: In CPU code of, for example,
What happens if we want to translate this to GPU? Well, since each must have a different pointer to grid_cell_state, they must also have a different model_data object (otherwise, they will point to the same place). So, basically, we are duplicating all the model_data for each thread despite we are only using It shouldn't be a problem at the moment, but it will be when we want to squeeze the GPU. And it will be nice to discuss the design of these little structs when the times come. |
Yeah, sounds like a good plan - seems like this could be related to #99. When would you need this by? Could this be part of the move to c++, or sooner? |
I need first that you check the pull request #126 or we fix #125 to test correctly multi-cells and gpu. If testing the arrhenius I see that this implementation with model_data is taking significantly more time than without it, we can discuss it soon. But I believe it won't be in that way, so probably this would be part of c++ development |
Pending move the dependencies between fortran and rxn.c file (e.g. the call to rxn_update_data is done in fortran instead from camp_solver.c). These dependencies avoid the code translation from .c to .cpp files (since fortran will call a .cpp file instead of a .c file, so some different treatment should be done). This issue also will wait for the finalization of #128, since both issues conflict in the jacobian code. |
Hi @mattldawson
I was wondering about the extra work on modifying the GPU code each time we modify something on the reactions code. CUDA code for reactions are, mostly, a copy of the CPU code (except for the function declaration and the atomicadd to save the results in deriv/Jac). So each time we modify the code on CPU we must copy the changes in CUDA and taking care of don't delete the GPU implementations.
So, I managed to find a possible solution. We can profit from the PMC_USE_GPU flag to choose to compile CPU code or GPU code since we will use only one of the cases. To illustrate the idea, the code will be something like this:
I already tested it and works, so it only left to discuss this. I like the idea if we will be doing changes frequently to the reactions. Also, it is a good idea in order to explain to the user how to add a reaction, since it won't be so "strange" as say to the user if he wants to compute his new reaction on a GPU, he needs to copy/paste the code.
However, I understand that this can be a bit "ugly" , maybe mess up a bit the code and I also like having all the CUDA code in his own folder. So, what do you think?
The text was updated successfully, but these errors were encountered: