Skip to content

Non-repeatable results when using OpenMP #1

Open
@mancellin

Description

@mancellin

First, thank you very much for sharing your code, it is very helpful to me!

I ran into some issues when using your module in parallel with OpenMP (on Ubuntu 22.04 with gfortran 11).
Here is a minimal example: capytaine@fc0547e
Running this program leads to different results each time:

$ ./test_program
  -16.555834740387333       -15.476963986365671       -14.412503912173607       -13.369515798080531       -7.6451963635261464       -11.375288243750948       -10.437096348107897       -9.5463680118490171       -1.1665022407159018       -7.9295866320209587
$ ./test_program
  -17.991076320788107       -14.013290014374100       -12.149123395809470       -9.0501859811610483       -7.5840537209765362       -5.4395058216609842       -4.2437142185190195       -2.9313920411413523       -6.4453993960240510       -7.3892014684943774E-002

unless, the OpenMP parallelization is turned off:

$ OMP_NUM_THREADS=1 ./test_program
  -20.365766434529149       -15.476963986365671       -12.149123395809470       -9.5052157061777596       -7.2962058749427481       -5.4395058216609842       -3.9409000581548979       -2.9313920411413523       -2.9948334814816207       -9.6354549626564303
$ OMP_NUM_THREADS=1 ./test_program
  -20.365766434529149       -15.476963986365671       -12.149123395809470       -9.5052157061777596       -7.2962058749427481       -5.4395058216609842       -3.9409000581548979       -2.9313920411413523       -2.9948334814816207       -9.6354549626564303

A possible explanation for this issue is the use of global variables (GF_alpha, GF_beta, etc.) which might be shared between OpenMP threads. I will test that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions