Segmentation fault with OpenMP

General discussion about Elmer
Post Reply
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Segmentation fault with OpenMP

Post by spacedout »

Hi to all

Of course one needs to have compiled Elmer with the option -DWITH_OpenMP:BOOL=TRUE in the cmake to experience this problem.

I added a call to a new subroutine Test() inside the body of BulkAssembly() of StatElecSolver between

!$omp parallel shared(Solver, Model, dim, at0, &
!$omp PermittivityOfVacuum, Message, DummyforLGetLog) &
!$omp private(t, CurrentElement, i, j, k, n, ntot, NodeIndexes,&
!$omp bf_id, gotIt, Var, TID) default(none)
TID = 1
!$ TID = omp_get_thread_num()+1
!$omp do

and

!$omp end do
!$omp end parallel

the body of Test() is defined after
CONTAINS
and before
END SUBROUTINE StatElecSolver

The contents of the body of Test() are immaterial except that it must contain at least a line that refers to any variable defined in the local variables section of

StatElecSolver( Model,Solver,dt,TransientSimulation )

When I run ElmerSolver, I get a segmentation fault (or illlegal instruction or illegal operand) at the very first such line I just described above inside the body of Test().

Is this behaviour normal or expected ?
spacedout
Posts: 177
Joined: 30 Mar 2020, 23:27
Antispam: Yes

Re: Segmentation fault with OpenMP

Post by spacedout »

I realize that the answer to this problem might require a thorough understanding of the OpenMP documentation and maybe even its code in order to figure out exactly what those !$omp directives actually do.

But by trial and error, I think I found a potential fix! I replaced the call to Test() by its body and, I have added the problematic local variable to the list in !$omp parallel shared(...). It got rid of the segmentation fault.

Does it anybody approve of this modification ?

At any rate, thanks for viewing
Post Reply