CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   GPU compilation for hybrid vortex/finite volume Method (https://www.cfd-online.com/Forums/openfoam-programming-development/131891-gpu-compilation-hybrid-vortex-finite-volume-method.html)

Frivole March 22, 2014 03:38

GPU compilation for hybrid vortex/finite volume Method
 
Hello,
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:
Code:

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

CXX = g++
LD  = g++     
CXXFLAGS = -O2 -Wall $(INCLUDE)
LDFLAGS = -O2
NVCC = nvcc
NVCCFLAGS = $(INCLUDE)

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

all: $(EXE)

.SUFFIXES: .cu
.cu.o:
    $(NVCC) $(NVCCFLAGS) -c $< -o $@
.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:

foam-extend-3.0/src/cudaSolvers/

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

Cheers!
Kyle

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:
Code:

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,

Pierre

kmooney April 4, 2014 13:31

Hi Pierre,

Take a look at this file:

/foam-extend-3.0/wmake/rules/linux64Gcc/nvcc


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.

Cheers!
Kyle

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 :
Code:

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 06:09.