Using OpenMP in CodeWarrior for Stream

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using OpenMP in CodeWarrior for Stream

Jump to solution
2,928 Views
jmtroth
Contributor III

Hello, I am attempting to compile Stream with multithreading support but I can't seem to get it running with OpenMP. Here is the console output:

**** Build of configuration Linux_Application for project stream ****

C:\Freescale\CW_PA_v10.3.3\gnu\bin\mingw32-make -j8 all

'Building file: ../Sources/stream_mc.c'

'Executing target #1 ../Sources/stream_mc.c'

'Invoking: PowerPC LINUX e500mc C Compiler'

"C:/Freescale/CW_PA_v10.3.3/Cross_Tools/gcc-4.7.2-XMe500mc-linux/bin/powerpc-unknown-linux-gnu-gcc" "../Sources/stream_mc.c" -O3 -fopenmp -g -Wall -c -fmessage-length=0 -mcpu=e500mc -MMD -MP -MF"Sources/stream_mc.d" -o"Sources/stream_mc.o"

'Finished building: ../Sources/stream_mc.c'

' '

'Building target: stream.elf'

'Executing target #2 stream.elf'

'Invoking: PowerPC LINUX e500mc C Linker'

"C:/Freescale/CW_PA_v10.3.3/Cross_Tools/gcc-4.7.2-XMe500mc-linux/bin/powerpc-unknown-linux-gnu-gcc"  "./Sources/stream_mc.o"     -o"stream.elf"

../Sources/stream_mc.c: In function 'mysecond':

../Sources/stream_mc.c:426:13: warning: variable 'i' set but not used [-Wunused-but-set-variable]

../Sources/stream_mc.c: In function 'checkSTREAMresults':

../Sources/stream_mc.c:481:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'unsigned int' [-Wformat]

./Sources/stream_mc.o: In function `main._omp_fn.0':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:252: undefined reference to `omp_get_thread_num'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:254: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.2':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:269: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.3':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:288: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.4':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:315: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.5':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:325: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.6':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:335: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.7':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:345: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.4.constprop.8':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:315: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main._omp_fn.6.constprop.9':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:335: undefined reference to `omp_get_num_threads'

./Sources/stream_mc.o: In function `main':

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:250: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:262: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:269: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:288: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:315: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:325: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:335: undefined reference to `GOMP_parallel_start'

C:\Users\john\workspace\stream\Linux_Application/../Sources/stream_mc.c:345: undefined reference to `GOMP_parallel_start'

mingw32-make: *** [stream.elf] Error 1

I have already specified the -fopenmp flag in the Optimization section of the C/C++ Build Settings.

Labels (1)
Tags (3)
0 Kudos
Reply
1 Solution
1,426 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello John,

Please try to build your application as the following.

In main.c

#include <omp.h>

...

#pragma omp parallel

...

Then open the Libraries panel from Project->Properties->C/C++ Build->Settings->PowerPC LINUX * C Linker->Libraries, and add "gomp" in the panel "Libraries(-l)".

If your problem remains, please kindly share your source code.

Have a great day,

Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
Reply
6 Replies
1,426 Views
jmtroth
Contributor III

Any thoughts? I tried using -lgomp and -libgomp with -fopenmp, to no avail. I am trying to find an omp.h file, but I haven't had to use it before.

0 Kudos
Reply
1,426 Views
lunminliang
NXP Employee
NXP Employee

The omp.h is right contained in CodeWarrior installation directory. C:\Freescale\CW_PA_v10.3.3\Cross_Tools\gcc-4.7.2-XMe500mc-linux\lib\gcc\powerpc-unknown-linux-gnu\4.7.2\include.

0 Kudos
Reply
1,427 Views
yipingwang
NXP TechSupport
NXP TechSupport

Hello John,

Please try to build your application as the following.

In main.c

#include <omp.h>

...

#pragma omp parallel

...

Then open the Libraries panel from Project->Properties->C/C++ Build->Settings->PowerPC LINUX * C Linker->Libraries, and add "gomp" in the panel "Libraries(-l)".

If your problem remains, please kindly share your source code.

Have a great day,

Yiping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
1,426 Views
jmtroth
Contributor III

This resolved the issue, thanks!

0 Kudos
Reply
1,426 Views
jmtroth
Contributor III

Linked libgomp? Not sure how to do that. I don't know anything about the omp.h header file, I do understand the script requires one.

0 Kudos
Reply
1,426 Views
lunminliang
NXP Employee
NXP Employee

Have you linked in libgomp and include omp.h header file?

0 Kudos
Reply