Thursday, July 28, 2016

Compiling CUDA solvers in Foam Extend v 3.2

Today's computing world is slowly and steadily shifting from CPU to GPU. With the availability of resources at much lower rates then some years ago and the need for faster + efficient computing has resulted computational scientist to broaden their view of using GPU for computation and not see it just for gaming purpose.

The OpenFOAM extend group has contributed to this by adding libraries for solvers to harness the power of GPU. I have an NVIDIA GeForce GTX 650 Ti 2GB Graphics card and first wanted to compile the cudaSolvers in foam-extend.
So some of the basic steps which are required for compilation are as shown below :

1. Install NVIDIA cuda libraries for your system ( https://developer.nvidia.com/cuda-downloads ). 

2. After this before compiling foam-extend source the environment variable for compiling cuda solvers. On the terminal type the command below and hit enter

export CUDA_ARCH=sm_30

3. Compile foam-extend by running the ./Allwmake.firstInstall script

4. Once the compilation is finished we can now compile the CUDA solvers separately by running the Allwmake file inside $FOAM_SRC/cudaSolvers

5. But wait, this might still throw up some errors. So we need to complete a few more steps before compiling cudaSolvers

a ) Set the path for CUDA nvcc. You can save these lines in you etc/bashrc file so you can save time exporting these everytime you need to run the cuda based solvers

export set PATH=/usr/local/cuda-7.5/bin:$PATH

export set LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH


b ) You will also require CUSP for compiling the cuda libraries

cusp library v0.4.0

Download it from : https://github.com/cusplibrary/cusplibrary.git

Rename the zip file as " cusp " .This library needs to be saved inside the cuda directory in /usr/local/cuda-7.5

c ) I had some trouble while compiling the cudaSolvers, but when I checked options file in Make directory my error was solved. Basically we need to set the CUDA_INCLUDE_DIR path to include all the required files for running cudaSolvers.

export CUDA_INCLUDE_DIR=$CUDA_DIR/include

d ) Now compile the cudaSolvers , and once it says that

'libcudaSolvers.so' is up to date

Your work is done

Now my next task would be to work with these solvers and check how fast the cuda libraries work for OpenFOAM extend.


4 comments:

  1. Hallo Rahul,
    thank you for your helpful post, but i have a question, what do you mean in the step 5.C) ....but when I checked options file in Make directory my error was solved.
    thnx in advance

    ReplyDelete
  2. Hi Louay,

    There was an error everytime I compiled cudaSolvers in foam-extend saying that some of the cuda files were missing. So when I actually checked out the "options" file inside he Make directory I found that we need to set the path as CUDA_INCLUDE_DIR and not just as CUDA_DIR as foam-extend searches out for cuda libraries installed in your user directory.

    Regards

    ReplyDelete
  3. Hi Rahul,
    thnx for your fast reply. My CUDA is now 100% complied without Errors, i have to thank you. But i had to put cusplibrary inside CUDA_INCLUDE and not in /usr/local/cuda-7.5 , in order to let the complier find the missing files.
    have a nice weekend :)

    ReplyDelete
  4. Hi Louay,

    Welcome and I hope my posts help you in future as well.

    You too have a nice weekend bud!! :)

    ReplyDelete