picongpu icon indicating copy to clipboard operation
picongpu copied to clipboard

Fix dY and dT symmetry scales in twtstight

Open BeyondEspresso opened this issue 1 year ago • 5 comments

The symmetry scales dY and dT are used to maintain longterm numerical stability by exploiting a spatio-temporal symmetry in the twtstight laser pulse. There has been a bug in dY and dT. Since their equations were unnecessarily convoluted, I also refactored them in the fix. The equations now pass the dY-dT-symmetry test.

BeyondEspresso avatar Oct 17 '24 20:10 BeyondEspresso

Without having had much more than a quick glance on it, would it be an option to add that test you were talking about as a unit/end-to-end test?

chillenzer avatar Oct 18 '24 06:10 chillenzer

Yes, that should be quite simple.

BeyondEspresso avatar Oct 18 '24 06:10 BeyondEspresso

Great, thanks!

chillenzer avatar Oct 18 '24 06:10 chillenzer

@chillenzer @steindev The small PR has grown quite a bit. After applying the original updates I noticed that the twtstight-implementation does not work for beta0 != 1.0, which is not the normal usecase, but it is in the interface and actually nice to have. I updated the laser equations to now also include beta0. I tested the new implementation that compared to my model implementation correctly generates the old (beta0=1.0) and now also new results (beta0 != 1.0). While applying the changes, I seized the opportunity for some reductions in boiler plate code that still existed from previous, now outdated, twts implementations.

BeyondEspresso avatar Oct 18 '24 22:10 BeyondEspresso

@chillenzer Please leave the draft-tag for now until Monday. It is late and it is a good idea to have some time pass,

BeyondEspresso avatar Oct 18 '24 22:10 BeyondEspresso

@chillenzer I actually have further minor changes to make the PR more round. I will submit them soon.

BeyondEspresso avatar Oct 25 '24 20:10 BeyondEspresso

@chillenzer @steindev OK, I rebased my PR and completed my generalization and refactoring. Additionally, I successfully tested the code in an actual PIConGPU run. The draft-tag can be removed now.

BeyondEspresso avatar Oct 27 '24 15:10 BeyondEspresso

@BrianMarre should probably follow the developments here after we've done a similar refactoring with his code.

chillenzer avatar Oct 29 '24 14:10 chillenzer

Without having had much more than a quick glance on it, would it be an option to add that test you were talking about as a unit/end-to-end test?

Have you actually added said test yet or is this still on your todo list?

chillenzer avatar Oct 29 '24 14:10 chillenzer

@chillenzer Yes, adding the test is still on my todo list.

BeyondEspresso avatar Oct 29 '24 14:10 BeyondEspresso

@psychocoderHPC @chillenzer Ok, here is the refactored version. To reduce duplicate code I moved the implementation into the new template class TWTSTight and specialized for the respective E- and B-Field implementation. In the math, I also did a separation of complex and float-numbers via reordering and brackets according to @psychocoderHPC suggestions. Due to the new struct, I renamed twtstight.tpp to TWTSTight.tpp. In total this results in a code reduction by almost 600 LOCs.

BeyondEspresso avatar Nov 06 '24 16:11 BeyondEspresso

@chillenzer Before you review the code, I need to review it myself, as there are changes that were not intended.

BeyondEspresso avatar Nov 07 '24 05:11 BeyondEspresso

@chillenzer Should be OK now. In addition to updating attributions and fixing typos, there was a missing ", which failed the CI.

BeyondEspresso avatar Nov 07 '24 07:11 BeyondEspresso

Nice! With this refactoring, the PR actually reduces the lines of code in the repo while still adding new functionality if I understood correctly.

chillenzer avatar Nov 07 '24 07:11 chillenzer

That is correct.

BeyondEspresso avatar Nov 07 '24 08:11 BeyondEspresso

@chillenzer Now I also added the unit test to the PR.

BeyondEspresso avatar Nov 07 '24 12:11 BeyondEspresso

@chillenzer @psychocoderHPC I adressed your comments. There were quite some changes in how the helper variables are handled. Now there are two arrays of variables part of the data members, which makes everything more concise. The test case compiles, runs and passes on Frontier.

BeyondEspresso avatar Nov 08 '24 13:11 BeyondEspresso

@psychocoderHPC @chillenzer The core dump problem has not gone away by changing to CHECK().

/builds/hzdr/crp/picongpu/share/picongpu/unit/TWTSTight.cpp(177): internal error: assertion failed at: "error.c", line 7967 in diagnostic_pragma
1 catastrophic error detected in the compilation of "/builds/hzdr/crp/picongpu/share/picongpu/unit/TWTSTight.cpp".
Compilation aborted.
Aborted (core dumped)
make[2]: *** [CMakeFiles/UnitTest-TWTSTight.cpp-2D.dir/build.make:76: CMakeFiles/UnitTest-TWTSTight.cpp-2D.dir/TWTSTight.cpp.o] Error 134

Other compilers compiled this without any issue.

BeyondEspresso avatar Nov 09 '24 07:11 BeyondEspresso

Okay. I found the offending piece of code using gcc 11.3.0 and CUDA 11.6.0. But I'm not sure if we can do anything about this: The specific combination of compiler and CUDA version fails at the following line:

#pragma nv_diagnostic push

which can be reproduced by putting this anywhere in the code. This line is inserted by Catch2 in thirdParty/catch2/src/catch2/internal/catch_test_macro_impl.hpp which defines INTERNAL_CATCH_TEST (which is more or less what CHECK and REQUIRE etc. compile to) through CATCH_INTERNAL_START_WARNINGS_SUPPRESSION (from thirdParty/catch2/src/catch2/internal/catch_compiler_capabilities.hpp).

Catch2 claims in its changelog that they have fixed warning suppression for NVIDIA in 3.3.0 (and we're using 3.4.0) but apparently that doesn't apply to our compiler/CUDA combination. I tried updating to the latest Catch2 (3.7.1) but that doesn't change anything.

Things that we could do here:

  • Disable this test for this specific combination.
  • Hack/patch/customise our Catch2 to remove this line.
  • Try to make Catch2 believe it's on a different compiler (the host compiler might be an option).

chillenzer avatar Nov 11 '24 11:11 chillenzer

Thanks for investigating it. Can we please disable the test in the source code for this compiler. There are alpaka macros to control the version.

psychocoderHPC avatar Nov 11 '24 12:11 psychocoderHPC

@BeyondEspresso, I've suggested the corresponding patch. Feel free to adopt it. @psychocoderHPC, you should probably have a look if that macro's what you expected. Don't think alpaka has anything like that (except for CI specific macros).

chillenzer avatar Nov 11 '24 13:11 chillenzer

@chillenzer Thanks for the investigation and suggested code change. Let us see whether the updated PR now passes all CI hoops.

BeyondEspresso avatar Nov 11 '24 14:11 BeyondEspresso