How to Run OpenMP application Using "lli"

Hi;

Both -fplugin-arg-dragonegg-emit-ir and -flto works for creating llvm bitcode that can be run with lli. Thanks to Nick for the suggestion.

Now, trying to run an OpenMP hello world program.

llvm-gcc -fopenmp p_hello.c -flto -S -o p_hello.ll

lli p_hello.ll

output: LLVM ERROR: Program used external function ‘GOMP_parallel_start’ which could not be resolved!

I am guessing that I have to link libgomp.a somehow but want to know the correct way to do it.

Other way around using gcc:

llvm-gcc -fopenmp p_hello.c -flto -S -o p_hello.ll
llc p_hello.ll

gcc -fopenmp p_hello.s -o p_hello

./p_hello

output:

Hello World
Hello World
Hello World
Hello World

I guess this is not the (only) way to run OpenMP programs. I can guess that compiling the libgomp into LLVM IR and then linking it with the hello.ll will allow me to run it with lli?
Any other suggestion on how to run them?

Hi Arnamoy,

Now, trying to run an OpenMP hello world program.

llvm-gcc -fopenmp p_hello.c -flto -S -o p_hello.ll
lli p_hello.ll

output: LLVM ERROR: Program used external function 'GOMP_parallel_start' which
could not be resolved!

I am guessing that I have to link libgomp.a somehow but want to know the correct
way to do it.

you can load shared libraries into lli using -load, so if you have libgomp.so
then try
   lli -load=libgomp.so p_hello.ll

Ciao, Duncan.