atcollab / at

Accelerator Toolbox
Apache License 2.0
48 stars 31 forks source link

AT does not compile with OpenMP=1 #592

Open swhite2401 opened 1 year ago

swhite2401 commented 1 year ago

The C code including random number (QuantdiffPass, *QuantPass, etc...) generation does not compile anymore if OpenMP is activate below the error:

image

It looks like the random generator has to be added to the shared variables. @lfarv do you confirm?

swhite2401 commented 1 year ago

In fact adding rng to the shared variables allows to compile correctly, I have not tested if it runs...

lfarv commented 1 year ago

The rng variable must indeed be added to the shared variables. I then compiles and runs, but there is another problem: the average energy loss from quantum radiation is ~10% too high with OpenMP.

I'm looking at that.

lfarv commented 1 year ago

Update: the test is done looking at the energy loss over one turn of S28F, with 1000 particles and BndMPoleSymplectic4QuantPass compared to BndMPoleSymplectic4RadPass.

The results are in excellent agreement without OpenMP and differ by ~10% with OpenMP

lfarv commented 1 year ago

Results without OpenMP

histo1 curve1

Here is the notebook used for the test (remove the .txt extension): testquantum.ipynb.txt

lfarv commented 1 year ago

Results with OpenMP:

histo2 curve2

I do not understand what may happen with the random generator… It would be interesting to do the same test with MPI.

For the time being, it seems necessary to disable OpenMP for the 2 passmethods BndMPoleSymplectic4QuantPass, StrMPoleSymplectic4QuantPass and QuantDiffPass. What do you think ?

swhite2401 commented 1 year ago

Yes I agree, it has to be disabled. I will check that results are correct with MPI