Eli
Eli

Reputation: 61

How to enable OpenMP support in the Makefiles / GCC

I am trying to parallelize for loops by using OpenMP for two different projects, but OpenMP has an issue with Makefile: ignoring #pragma omp parallelize for. So I need to change the Makefile so it can support OpenMP but i don't know how.

all: lbm 

lbm: lbm.c main.c 
    gcc -o lbm lbm.c main.c -lm
clean:
    rm -f lbm *.o

all: mcf 

mcf: implicit.c  mcfutil.c  pbeampp.c  pflowup.c   pstart.c   treeup.c mcf.c       output.c   pbla.c     psimplex.c  readmin.c
    gcc -o mcf *.c 
clean:
    rm -f mcf *.o

Upvotes: 4

Views: 12903

Answers (2)

Zulan
Zulan

Reputation: 22670

For gcc, OpenMP is enabled via the -fopenmp flag. Add this to every invocation of gcc. Different compilers may use different flags, in those cases consult the compiler manual. To make sure the changes are effective, run make clean && make all after editing the Makefile.

Upvotes: 6

petrmikheev
petrmikheev

Reputation: 342

Add the -fopenmp option to each call of gcc.

Upvotes: 0

Related Questions