CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   GPU compilation for hybrid vortex/finite volume Method (

Frivole March 22, 2014 04:38

GPU compilation for hybrid vortex/finite volume Method
I am working on a hybrid vortex method/finite volume method. I already have a C++ implementation of the vortex method and I have decided to use OpenFOAM for the FVM part.
In the vortex method, to solve the N-body problem we use a GPU function. To compile it we first compile the cuda part with nvcc and then we link using g++. The makefile is:

INCLUDE = -I/opt/cuda/include -I.
LIBS = -Wl,-rpath,/opt/cuda/lib64 -L/opt/cuda/lib64 -lcuda -lcudart

CXX = g++
LD  = g++     
NVCC = nvcc

SRC= $(wildcard *.C)
SRCU= $(wildcard *.cu)
OBJ= $(SRC:.C=.o) $(
EXE = main

all: $(EXE)

    $(NVCC) $(NVCCFLAGS) -c $< -o $@
    $(CXX) $(CXXFLAGS) -c $< -o $@

main: $(OBJ)
    $(LD) $(LDFLAGS) $(OBJ) $(LIBS) -o $@

So to compile the hybrid method, I was wondering if it was possible to modify wmake to do the same thing.

Thank you

kmooney March 31, 2014 19:38

I've only worked with cuda solvers outside of OF but the latest foam-3.0 has a few nvcc compiled linear solvers coupled with it. You might be able to get a few hints on this here:


And the respective Allwmake, Make/options, Make/files


Frivole April 3, 2014 23:05

Hi Kyle,

Thanks for your answer!!
As you suggested I looked at the foam-extend-3.0 and decided to use it.
The installation went well, however when I run the Allwmake.firstInstall I get:

Cuda compiler detected at /opt/cuda/bin/nvcc;
cudaSolvers will be compiled by default.

$CUDA_ARCH is required by nvcc compiler but not set.
Check section '-gpu-architecture' in 'man nvcc' for details.

People seems to have the same kind of issue in the thread:
extend-3.0 cuda installation
So I will try to look for a solution there.
Thanks again,


kmooney April 4, 2014 13:31

Hi Pierre,

Take a look at this file:


There you can see how $CUDA_ARCH is actually added to the compiler flags. Maybe you know enough about nvcc compilers such that you know what the env variable is supposed to be set as.


Frivole April 7, 2014 04:57

Hi Kyle,

I am sorry for answering so late.
In fact I had an issue with my swak4Foam, and, after reinstalling it, Allmake ran without problems. However when after I try to compile the a solver with cuda I got that kind of error :

Found nvcc  --  enabling CUDA support.
make: *** No rule to make target `fastBiot/fastBiot.dep', needed by `Make/linux64Gcc46DPOpt/dependencies'.  Stop.
make: *** Waiting for unfinished jobs....

So I copy paste the rules/linux64Gcc/nvcc file into rules/linux64Gcc46/nvcc without any success...

All times are GMT -4. The time now is 18:01.