CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

OpenFOAM external CUDA code with functionObject

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2022, 04:33
Default OpenFOAM external CUDA code with functionObject
  #1
New Member
 
Lukas Heisler
Join Date: May 2022
Posts: 4
Rep Power: 4
LHeisler is on a distinguished road
Hello everyone,

i am quite new to OpenFOAM. My current task is to implement part of a custom solver in CUDA. Basically some particle cloud is calculated on the GPU, while the CPU solver handles the rest.

Now as a start, I would like to be able to compile a simple .so library with CUDA code as external C and be able to call it with a function object. So basically let the GPU say hello.

I have read probably every thread that covers this or similar problems but was not able to find an answer. This is what my files look right now:
the following is in the folder customLibrary

customLibrary.cu
#include "cuda.h"
#include <iostream>
#include "hello.cu"

hello.cu
void helloWorld()
{
std::cout << "Hello World" << std::endl;
}

hello.H
#ifdef __cplusplus
#include <iostream>
extern "C"
#endif
void helloWorld();

files
hello.H
LIB = $(FOAM_USER_LIBBIN)/libcustomLibrary

options
EXE_INC = \
-I/usr/local/cuda/include
LIB_LIBS =

the following is in the main folder of the solver
Allwmake
cd customLibrary
wclean
nvcc --shared -Xcompiler -fPIC -o $FOAM_LIBBIN/libcustomLibrary.so customLibrary.cu -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcudart
wmake libso
cd ..
wmake

solidParticleInterFoam.C
...
#include "hello.H"
... some code
helloWorld();


this setup seems to compile the library with no visible errors. But when I start a simulation I get the following error:
symbol lookup error: solidParticleInterFoam: undefined symbol: _Z10helloWorldv

If anyone could help me with this or has done something similar, I would highly appreciate any help.

Many thanks and all the best!
LHeisler is offline   Reply With Quote

Old   March 26, 2024, 07:24
Default
  #2
New Member
 
Angel Malaguera
Join Date: May 2016
Location: Florianópolis, SC, Brazil
Posts: 20
Rep Power: 10
AMalaguera is on a distinguished road
Hello Lucas how are you

Did you manage to solve that problem? You use CUDA with which version of OpenFoam?

Angel...
AMalaguera is offline   Reply With Quote

Reply

Tags
functionobject, gpgpu, gpu, openfoam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM, progress in academia and industry, after 13 years' effort sharonyue OpenFOAM 5 March 29, 2018 12:09
Very small job: converting an OpenFOAM mesh to a format needed by another code SFr CFD Freelancers 1 June 24, 2016 05:45
[Other] Comparing OpenFOAM to another code: advice on dealing with meshes? SFr OpenFOAM Meshing & Mesh Conversion 1 June 11, 2016 12:02
Memory protection in OpenFOAM / combinig with FORTRAN botp OpenFOAM Programming & Development 2 February 15, 2016 12:25
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 January 5, 2016 03:18


All times are GMT -4. The time now is 21:37.