-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General plan and layout #42
Comments
In GitLab by @gregorgassner on May 7, 2020, 17:13 Woah!! So somehow your modifications made the code 6 times faster??? That is cool and shocking at the same time 🆒 |
In GitLab by @gregorgassner on May 7, 2020, 17:17 I am very much open to a discussion on structure, layout and changes to Trixi. Also, I personally do not mind to restructure the code a lot and also make it more Julia to use the Julia features as good as possible (and hopefully simplify its usage for us, and also students!) |
In GitLab by @sloede on May 7, 2020, 20:33
I fully support this statement! The main goals of Trixi - which are often in conflict - are that it should be as simple and flexible as possible, such that it remains easy to learn & use (especially for students) but also powerful enough to be used for research. Other than that, I do not feel the need to stick to any fixed paradigm in terms of structure or style, but I am very much in favor of making it as Julian as reasonable. |
In GitLab by @andrewwinters5000 on May 7, 2020, 22:34 I agree with the above statements. My old Fortran habits die hard, though I am adaptable (and willing) to learn and exploit Julia's strengths. I am also shocked that some simple type changes made the code six times faster. |
In GitLab by @ranocha on May 11, 2020, 15:34 mentioned in merge request !43 |
In GitLab by @ranocha on May 14, 2020, 07:34 I'll post a possible structure and approach here to have something that we can discuss later (and update here).
|
In GitLab by @ranocha on May 7, 2020, 17:07
Hi! I'm totally new to this project and haven't been involved in the discussions and the work resulting in the current version. Hence, I hesitate a bit to start discussions that can possibly necessitate huge changes to your workflow and/or the code. On the other hand, I couldn't find such discussions online (since they probably happened in person) and the resulting comments may be of interest for future users of Trixi.
My first impression of Trixi is that it's heavily inspired by monolithic Fortran codes like Flexi/Fluxo, which is totally natural, of course. In my opinion, a different approach might be useful in Julia: Instead of providing a single executable running a parameter file, an approach to create a library of tools might be of interest.
For example, if a student shall run some experiments with a slightly different initial condition, Trixi itself has to be modified, e.g. at https://gitlab.mi.uni-koeln.de/numsim/code/Trixi.jl/-/blob/master/src/equations/linearscalaradvection.jl#L46.
An alternative to parameter files could be to supply the parameters as pure Julia code using the Trixi library. In that case, students could write the initial condition as a Julia function without the need to modify Trixi itself. Since functions are first-class citizens in Julia, they can be passed around as arguments (or as part of structs).
The structure of Trixi using many modules and global variables reminds me of Fortran modules etc. While using constant global variables is okay (type stable) in Julia, passing parameters is more encouraged.
Another reminder of Fortran and co are the type annotations for function arguments. Unless they direct multiple dispatch, they shouldn't be used in Julia.
is compiled to exactly the same machine code as
if the arguments are the same. The first version is more general, since the array type can be exchanged. For example, it is possible to use the same code to run a simulation with
Float32
(or possibly some floating point type with higher accuracy), which can be useful sometimes. I prefer to include the additional kind of documentation provided by the type annotations in docstrings for the functions.The multiple dispatch feature of Julia seems to be abused sometimes in the current version, e.g. in https://gitlab.mi.uni-koeln.de/numsim/code/Trixi.jl/-/blob/master/src/solvers/dg.jl#L1171. Such type-unstable code results in a possibly huge performance impact.
For example, I started from the current master branch with this
git diff
.If I understood the code correctly, the result should be the same since I use
surface_flux_type = "chandrashekar_ec"
inparameters_ec.toml
. (Of course, this code is less general but it serves the purpose to demonstrate type stability in a simple way.)Running the current master with this
parameters_ec.toml
, I getWith the type stable version from
git diff
, I getThat impact is way more than I expected - I hope I didn't code bullshit here...
The additional
git diff
improves the performance for the volume terms to
A general solution to get type stable code in a library like approach could be to use parametric types and supply the fluxes as Julia functions instead of strings or symbols.
I saw the additional repositories Abraxas and trixi-tests but haven't looked at them yet. In Julia, it is pretty common to include some (unit) tests in every package which are triggered for every PR on GitHub (merge request on GitLab). In this way, some additional example code is provided and some basic functionality is guaranteed to work with new changes. While I didn't like that approach at the beginning (since I wasn't used to it), I really started to like it while developing more complex code, in particular if some time has passed between development cycles. I think it would be really nice if some small/basic tests are included here in
test/runtests.jl
etc. They could be triggered for every merge request as GitLab pipeline, I think. If Trixi shall be registered as Julia package (as hinted to in https://gitlab.mi.uni-koeln.de/numsim/code/Trixi.jl/-/issues/20#note_276), running tests and reporting coverage results (e.g. via Travis and Codecov/Coveralls) is usually seen as a requirement and sign of good coding standards.Okay, this grew into a lot of text. I hope we can start a constructive discussion and improve Trixi, building on your nice work :)
The text was updated successfully, but these errors were encountered: