question regarding changing souce code

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
biodc172
Posts: 12
Joined: Sat May 07, 2022 2:59 am

question regarding changing souce code

Post by biodc172 »

Hi,

I'm trying to change a little part of the source code so that it might be possible to run with CPU+GPU.
I'm wondering if if want to change the function _compute_cocgb_rhsb_lsq which is wrote in file src/alge/cs_gradient.c , do I need to change the file itself and recompile the whole software?
or just simply put the modified file in the case's SRC subdirectory and let it be autocompiled and lined to the solver, if so , is there anyway I can specify the compile options?

Best regards.
Yvan Fournier
Posts: 4085
Joined: Mon Feb 20, 2012 3:25 pm

Re: question regarding changing souce code

Post by Yvan Fournier »

Hello,

As long as you only need to modify source code and not header code (which is more tricky), you can simply copy the code (Fortran, C, C++, or CUDA) in SRC. You can then pass specific compile flags through cs_user_scripts.py, to be placed in DATA (see the data/user subdirectory in the code sources for the reference file).

In practice, though, I recommend working in a modified git source tree, and working from there. To save the time of the flull install, I usually "cd" to the "src" subdirectory of my build tree, and run "make install" from there. After a first build, updates are pretty fast.

Also, as a remark for GPU code, cs_gradient.c was recently switched to cs_gradient.cxx, so as to allow templates on different scatter and gather algorithms, all implemented for one example (for now). This was done to make it easier to work in GPU implementations, so if you are not up to date on the master branch, now might be a good time.

Regards,

Yvan
Post Reply