You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since `partdiff++` uses some C++20 (`std::format`, `std::numbers`) and C++23 (`std::print`, 3d-`operator[]`) features, you need a reasonably recent C++ compiler. I tested it with `g++14 14.2.0`.
13
10
14
-
See https://github.com/mblesel/rust_partdiff for a Rust implementation. 🙂
15
-
16
-
## Building and Testing
17
-
18
-
`partdiff++` uses C++20 features (at the moment just `std::numbers`).
19
-
Therefore, to build it, you need a compiler that supports C++20.
20
-
I tested it with `g++ 10.2.0`.
21
-
22
-
I am currently also relying on the [{fmt} library](https://github.com/fmtlib/fmt)
23
-
which implements the [C++20 std::format library](https://en.cppreference.com/w/cpp/utility/format)
24
-
which is sadly not supported by compilers at the time of writing.
25
-
Running `make` will automatically both clone and build `{fmt}` (there is no need
26
-
to manually update the git submodule), this will take a moment.
27
-
I will try to switch to `std::format` as soon as it becomes available.
28
-
29
-
You can build and test `partdiff++` by running `make`.
30
-
This will…
31
-
* build `partdiff`
32
-
* beautify `partdiff++`' source code with `clang-format`
33
-
* build `partdiff++` in [legacy mode](#legacy-mode)
34
-
* check whether the resulting matrix of `partdiff{,++}` in `{batch,interactive}` mode is correct
35
-
* check whether the help screens of `partdiff{,++}` are identical
36
-
* check whether the outputs of `partdiff{,++}` in {batch,interactive} mode are identical (this ignores the line with the calculation time, because that can vary a lot, but you can check for yourself that the format is correct)
37
-
* check whether `partdiff++` is leak-free
38
-
39
-
## Legacy Mode
40
-
41
-
`partdiff` is mostly in English, but two methods (`displayStatistics` and `allocateMemory`)
42
-
are in German.
43
-
44
-
`partdiff++` offers a full English translation which is enabled by default, but,
45
-
to retain comparability between `partdiff`'s and `partdiff++`' output, you can also
46
-
compile `partdiff++` in legacy mode to keep the German parts among a few other details:
This project uses [partdiff_tester](https://github.com/parcio/partdiff_tester) via CI to ensure that the output matches the reference implementation.
21
+
It passes the correctness tests with `--strictness=4` (exact match) and with `--valgrind` (i.e. it has no memory leaks).
22
+
57
23
## Performance
58
24
59
25
`partdiff++` is a bit faster than `partdiff`.
@@ -70,7 +36,7 @@ and `partdiff++`' runtime is `(715.90 ± 0.82) s`,
70
36
which makes `partdiff++``(7.36 ± 0.5) %` faster.
71
37
72
38
This is probably to a large part because of the custom Matrix / Tensor
73
-
implementation that uses an overloaded `operator()` for element access, so we
39
+
implementation that uses an overloaded `operator[]` for element access, so we
74
40
can save a bit of pointer arithmetic and do the index computation directly.
75
41
76
42
However,
@@ -83,8 +49,9 @@ the runtime projected onto 0 iterations is also smaller for `partdiff++`.
83
49
84
50
This means, that `partdiff++`' startup time is also smaller which is a bit
85
51
surprising, considering that I did not care for performance in the startup
86
-
code at all and used many sophisticated but expensive techniques. However,
87
-
I am using the `{fmt}` library for printing which claims to be faster than `printf`.
52
+
code at all and used many sophisticated but expensive techniques.
53
+
However, it is claimed that the new C++ string printing (`std::print`) is faster
54
+
than `printf`.
88
55
Maybe a bit of modern C++ compiler magic is involved as well.
89
56
90
57
#### Figure 1: [1,1024] iterations
@@ -98,13 +65,3 @@ Maybe a bit of modern C++ compiler magic is involved as well.
98
65
#### Figure 3: [1,8] iterations with best-fit line
99
66
100
67
[](benchmark/pde_vs_pdepp_iter/Runtimes%20[1%2C8].pdf)
101
-
102
-
## Coding Style
103
-
104
-
This is not just a minimal port that makes `partdiff` work with a C++ compiler.
105
-
`partdiff++` is written in modern C++20 and uses no C headers.
106
-
107
-
I tried to keep most identifier names intact, but I converted all identifiers to
108
-
the standard `snake_case` of the standard library and changed a few details.
109
-
110
-
The comments have been removed for now, but will return at some point.
0 commit comments