4 ms·
The first thing an amateur C++ programmer would notice is that that code isn't standard C++ code, what with its weird "#pragma omp" thing that isn't in the inde
by the_why_of_y 7y ago
The first thing an amateur C++ programmer would notice is that that code isn't standard C++ code, what with its weird "#pragma omp" thing that isn't in the index of the Stroustrup book.
- gpderetta 7y agothe nice thing about those pragmas is that the code has can be understood even if you ignore them. I do not know if this is true for all omp pragmas (IIRC some the newer ones might have some non ignorable semantics) but it is true for this omp for.
- the_why_of_y 7y agoYes, of course - a language extension can often give you better ergonomics than a library interface, both in implementing the code and in diagnostics reporting. The downside is that it's more effort to implement a language extension, it's more difficult to evolve it, and it restricts user's choice of implementation to those that have implemented the extension. For example, Microsoft Visual C++ supports only OpenMP 2.0, from 2002. An interesting question in this context would be, is there anything preventing adding an OpenMP extension to Rust?
- gpderetta 7y agoOf course there is a cost in making something part of the language, and the C++ way has always been to put features in the library whenever possible. Regarding choice of implementation, there are more C++ compilers that support OpenMP than rust compilers.
- pcwalton 7y agoRayon is basically the "OpenMP of Rust" already. OpenMP is designed around C-style for loops, which Rust discourages.
- gpderetta 7y agoFWIW OpenMP supports any C++ random access iterator and c++11 range-for loops. I guess you count any external iterator as C-style loop.
- MauranKilom 7y ago*newer OpenMP versions. MSVC is stuck on OpenMP 2.0 in which you can't even use unsigned integers as loop variable. No, seriously.
- petschge 7y agoMSVC is hilariously bad and not used in HPC code. Not sure how much high performance game code is compiled with it.
- pcwalton 7y agoA lot. I don't think OpenMP is used much in games.
- neutronicus 7y agoYeah OpenMP is mostly for problems with much less data-dependency than games.
- imtringued 7y agoRayon only covers a fraction of OpenMP's features.