[petsc-users] OpenMP doesn't work anymore with PETSc building rules

Satish Balay balay at mcs.anl.gov
Wed Oct 25 10:54:24 CDT 2023


On Wed, 25 Oct 2023, Qiyue Lu wrote:

> Hello,
> I have an in-house code enabled OpenMP and it works. Now I am trying to
> incorporate PETSc as the linear solver and build together using the
> building rules in $PETSC_HOME/lib/petsc/conf/rules. However, I found the
> OpenMP part doesn't work anymore.

If you are looking at building only your sources with openmp - using petsc formatted makefile [using petsc build rules],
you can specify it via CFLAGS - either in makefile - or on command line.

>>>>>>>
For ex: [this example is using src/ksp/ksp/tutorials/makefile - with the corresponding make fules]

[balay at pj01 tutorials]$ make ex2
mpicc -fPIC -Wall -Wwrite-strings -Wno-unknown-pragmas -Wno-lto-type-mismatch -Wno-stringop-overflow -fstack-protector -fvisibility=hidden -g3 -O0  -I/home/balay/petsc/include -I/home/balay/petsc/arch-linux-c-debug/include     -Wl,-export-dynamic ex2.c  -Wl,-rpath,/home/balay/petsc/arch-linux-c-debug/lib -L/home/balay/petsc/arch-linux-c-debug/lib -Wl,-rpath,/software/mpich-4.1.1/lib -L/software/mpich-4.1.1/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/13 -L/usr/lib/gcc/x86_64-redhat-linux/13 -lpetsc -llapack -lblas -lm -lX11 -lmpifort -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -lquadmath -o ex2
[balay at pj01 tutorials]$ make clean
[balay at pj01 tutorials]$ make ex2 CFLAGS=-fopenmp
mpicc -fPIC -Wall -Wwrite-strings -Wno-unknown-pragmas -Wno-lto-type-mismatch -Wno-stringop-overflow -fstack-protector -fvisibility=hidden -g3 -O0 -fopenmp -I/home/balay/petsc/include -I/home/balay/petsc/arch-linux-c-debug/include     -Wl,-export-dynamic ex2.c  -Wl,-rpath,/home/balay/petsc/arch-linux-c-debug/lib -L/home/balay/petsc/arch-linux-c-debug/lib -Wl,-rpath,/software/mpich-4.1.1/lib -L/software/mpich-4.1.1/lib -Wl,-rpath,/usr/lib/gcc/x86_64-redhat-linux/13 -L/usr/lib/gcc/x86_64-redhat-linux/13 -lpetsc -llapack -lblas -lm -lX11 -lmpifort -lmpi -lgfortran -lm -lgfortran -lm -lgcc_s -lquadmath -lstdc++ -lquadmath -o ex2
[balay at pj01 tutorials]$ 
<<<<<

Satish


> Should I re-configure the petsc installation with --with-openmp=1 option? I
> wonder are the building rules affected by this missing option?
> 
> Thanks,
> Qiyue Lu
> 



More information about the petsc-users mailing list