# A do concurrent bibliography

**URL:** <https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345>\
**Category:** Uncategorized\
**Created:** [December 1, 2026, 8:46am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345 "2026-12-01T08:46:22Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 3, 2026, 12:21am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/21 "2026-12-03T00:21:30Z")

</div>

> [@jorgeg](#):
>
> Yeah that is also a workaround but I loose performance which is not ideal. that’s the easy patch

Why do you lose performance that way? I don’t want to lose performance.

---

<div class="post-metadata">

**Author:** ![jorgeg](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jorgeg/32/6835_2.png) [@jorgeg](https://fortran-lang.discourse.group/u/jorgeg)\
**Post date:** [December 3, 2026, 12:46am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/22 "2026-12-03T00:46:17Z")

</div>

> [@certik](#):
>
> Why do you lose performance that way? I don’t want to lose performance.

the nvidia compiler seems to be evil to my application when I do this haha I assume it’s that the optimizer is looking first into the `subroutine` and not the whole `do concurrent` + atomics in one single big block and might not be inlining something or eliminating some dependencies. I haven’t looked at the assembly (yet)

---

<div class="post-metadata">

**Author:** ![szaghi](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/szaghi/32/6974_2.png) [@szaghi](https://fortran-lang.discourse.group/u/szaghi)\
**Post date:** [December 3, 2026, 5:48am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/23 "2026-12-03T05:48:19Z")

</div>

Hi Jorge,  
I suspect that Nvidia compiler can lose performances not only because of atomic/inlining, but also for the reduce: it creates private copies that could create a lot of memory overhead depending of kind of reduce.

I have not read all your examples, but if the reduce is done on (even small) array, my first step is investigating the reduce overhead. The “-Minfo=accel” “-gpu=ptxinfo” compiler flags give useful information, generally.

For the inlining, I often pass “-lto” to force the compiler to use more effort in inlining and generating faster executables, but with not negligible increase of compilation time, unfortunately.

My best regards.  
Stefano

---

<div class="post-metadata">

**Author:** ![davidpfister](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/davidpfister/32/3949_2.png) [@davidpfister](https://fortran-lang.discourse.group/u/davidpfister)\
**Post date:** [December 3, 2026, 6:02am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/24 "2026-12-03T06:02:58Z")

</div>

You can hack your compiler to make it believe that the print is pure. The trick is used here: [GitHub - plevold/fortran-debug-utils: Some debug utilities for Fortran · GitHub](https://github.com/plevold/fortran-debug-utils)

It’s probably not very standard compliant though.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 3, 2026, 5:48pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/25 "2026-12-03T17:48:02Z")

</div>

> [@jorgeg](#):
>
> the nvidia compiler seems to be evil to my application when I do this haha I assume it’s that the optimizer is looking first into the `subroutine` and not the whole `do concurrent` + atomics in one single big block and might not be inlining something or eliminating some dependencies. I haven’t looked at the assembly (yet)

My main question is if this is a problem with the language (then let’s fix it!) or it’s a problem in a particular compiler (then let’s fix the compiler!). Or both (then let’s fix both!).

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [December 3, 2026, 8:34pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/26 "2026-12-03T20:34:08Z")

</div>

> [@certik](#):
>
> My main question is if this is a problem with the language (then let’s fix it!) ..

Oh, it definitely is a problem with the language!

Fortran really needs a `do parallel` facility that is a simple, explicit directive by the Fortranner to run in parallel..

Not the compiler vendor saying “may be your executions will run concurrently if you are sitting in an ivory tower and you’re ‘really nice’ to me, I’m in a good mood, and it’s prime time in a galaxy far, far away ..” which is the case with `do concurrent` in the current standard, honestly the standardese on this feature is weasel words.

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [December 3, 2026, 10:59pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/27 "2026-12-03T22:59:07Z")

</div>

> [@FortranFan](#):
>
> Fortran really needs a `do parallel` facility […]

The word “concurrent” as used in the language standard is almost synonymous with “parallel”. So the question I think is what exactly can a high-level language do to make better use of the available hardware?

To me, it seems odd that “concurrent” has come to mean “offload to gpu hardware”. Its original meaning was simply to do things in parallel (i.e. concurrently) with the semantics that the various iterations of the loop can occur in arbitrary order, without being tied tightly to gpu hardware or to any other hardware that might become available in the future while the fortran language is still in use. I think there should have been a new syntax/semantics introduced to allow the programmer to specify gpu hardware if available, or to compile to cpu+vector instructions if not. With the current situation, the programmer has lost some control over the low-level code, not gained it.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 3, 2026, 11:27pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/28 "2026-12-03T23:27:42Z")

</div>

> [@FortranFan](#):
>
> Not the compiler vendor saying “may be your executions will run concurrently if you are sitting in an ivory tower and you’re ‘really nice’ to me, I’m in a good mood, and it’s prime time in a galaxy far, far away ..” which is the case with `do concurrent` in the current standard, honestly the standardese on this feature is weasel words.

LFortran gives you a compiler error if you have do concurrent and use GPU offloading and it cannot be offloaded. So that should fix this particular problem, no?

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [December 3, 2026, 11:33pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/29 "2026-12-03T23:33:37Z")

</div>

I have little to no experience with DO CONCURRENT but do all the compilers that support it at least throw a warning if there are dependencies that will inhibit parallel/out of order execution.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 3, 2026, 11:36pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/30 "2026-12-03T23:36:29Z")

</div>

> [@rwmsu](#):
>
> do all the compilers that support it at least throw a warning if there are dependencies that will inhibit parallel/out of order execution.

LFortran gives an error, but you can override it with a `--gpu-allow-cpu-fallback` compiler flag that will make it run on a CPU instead if it cannot be offloaded.

---

<div class="post-metadata">

**Author:** ![rwmsu](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@rwmsu](https://fortran-lang.discourse.group/u/rwmsu)\
**Post date:** [December 4, 2026, 12:05am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/31 "2026-12-04T00:05:18Z")

</div>

So even if you are telling it to use the CPU, will compilers still give a warning if it has to resort to executing in a serial manner as opposed to executing in parallel. I presume this is the fallback.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 4, 2026, 2:18am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/32 "2026-12-04T02:18:36Z")

</div>

When you ask to run do concurrent using openmp on a CPU, I think we currently always run it. But should introduce a similar error + compiler override option as we do for a GPU. Good point.

---

<div class="post-metadata">

**Author:** ![FortranFan](https://avatars.discourse-cdn.com/v4/letter/f/96bed5/32.png) [@FortranFan](https://fortran-lang.discourse.group/u/FortranFan)\
**Post date:** [December 4, 2026, 3:12am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/33 "2026-12-04T03:12:03Z")

</div>

- Under the current standard, `do concurrent` is merely a semantic assertion by the programmer that loop iterations have no interdependencies and can execute in _any arbitrary order_. A compiler is completely standard-conforming if it executes a `do concurrent` loop purely sequentially on a single thread,
- There is **unpredictability and fragility of compiler auto-parallelization** which impacts `do concurrent`. This causes real-world pain points for Fortranners outside of the “ivory towers” and “national labs”,
- Even when you pass the right compiler flags, whether a `do concurrent` loop actually runs in parallel depends entirely on internal compiler cost-models and heuristics. Minor, seemingly unrelated changes in your code can silently cause the compiler to drop parallelization and fall back to serial execution without warning,
- Each compiler vendor (NVIDIA `nvfortran`, Intel `ifx`, GNU `gfortran`, LLVM `flang`) implements `do concurrent` differently. Code that offloads smoothly to a GPU on one compiler might run serially on another, or require completely different flag combinations,
- Because the standard deliberately avoids dictating hardware execution models (threads, SIMD, GPUs) to preserve broad portability, it uses **weasel** language (“may execute in any order”). To a working scientist or engineer who seeks parallel execution, that is an evasion of responsibility,
- Modern hardware is inherently parallel. Treating parallel execution as a non-binding “hint” rather than a first-class, guaranteed execution model creates a usability gap compared to modern frameworks or directive-based standards like OpenMP. Furthermore, reliance on vendor-specific flags hurts Fortran’s supposed selling point: write-once, run-anywhere portability across decades of hardware,
- Fortran needs a built-in construct that carries an explicit execution mandate - an initial go-by to study and design might be `!$omp parallel do` in OpenMP - thus say `do parallel`. It shall be natively integrated into the core Fortran syntax without relying on external comment directives or vendor-specific compiler flags (`-stdpar`, `-fopenmp`, `-qopenmp`) to wake up the parallelizer,

---

<div class="post-metadata">

**Author:** ![PierU](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/pieru/32/1848_2.png) [@PierU](https://fortran-lang.discourse.group/u/PierU)\
**Post date:** [December 4, 2026, 1:14pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/34 "2026-12-04T13:14:57Z")

</div>

> [@FortranFan](#):
>
> - Because the standard deliberately avoids dictating hardware execution models (threads, SIMD, GPUs) to preserve broad portability, it uses **weasel** language (“may execute in any order”). To a working scientist or engineer who seeks parallel execution, that is an evasion of responsibility,

I tend to disagree. For instance every modern CPU architecture has had vectorised instructions for decades, and in practice all of us almost completely rely on the ability of the compilers to vectorize the simple `do` loops. OpenMP directives can help in difficult cases by telling the compiler “you can vectorize, it’s OK”, and `do concurrent` is supposed to tell the compiler “it’s OK” too. If we rely on the compiler to vectorize, we can as well rely on it to multithread.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [December 4, 2026, 2:23pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/35 "2026-12-04T14:23:40Z")

</div>

Yes, I agree with @PierU on this, I think the jury is still out. We need to actually spend good effort optimizing do concurrent both on CPU and GPUs and see what performance we can reliably get. So far the experience with my prototype is super encouraging, but that was for one code and one specific hardware. Now we need to extend it to all codes (especially large codes) on all hardware. If more is needed to specify more explicitly in the language itself, then we need to extend it, based on the evidence that we’ll uncover.

---

<div class="post-metadata">

**Author:** ![cmaapic](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/cmaapic/32/659_2.png) [@cmaapic](https://fortran-lang.discourse.group/u/cmaapic)\
**Post date:** [December 4, 2026, 6:17pm UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/36 "2026-12-04T18:17:10Z")

</div>

To be fair to the compiler writers I’ve had the same compiler problem with C++ on the parallel front. The 2017 C++ standard introduced parallelisation of the STL. It took a relatively long time to get reasonable cross compiler support for parallel sorting. I’ve had issues with g++ as recently as the 15.2.0 release.

---

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [December 5, 2026, 3:28am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/37 "2026-12-05T03:28:29Z")

</div>

> [@PierU](#):
>
> If we rely on the compiler to vectorize, we can as well rely on it to multithread.

There are various possibilities. There can be a single-thread cpu version, single-thread cpu+vector version, single-thread cpu+gpu version, and then also these same multithread versions. One possibility might be to write a single fortran code, and then direct the compiler to generate some or all of these versions with some kind of hints about which should be used (based on array dimensions, memory requirements, etc.). But a more complicated code might use different algorithms, with different fortran code, for some or all of these cases. Is it reasonable to expect to do this in a high-level language, or is the programmer expected to write low-level code (e.g. cuda) for the various possibilities? A high-level programming language is always going to use some kind of “weasel language” to cover the possibilities in an abstract way, but it might also give the programmer some control. This seems to me like a complicated and difficult language design problem.

---

<div class="post-metadata">

**Author:** ![JohnCampbell](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@JohnCampbell](https://fortran-lang.discourse.group/u/JohnCampbell)\
**Post date:** [December 5, 2026, 3:39am UTC](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345/38 "2026-12-05T03:39:05Z")

</div>

> [@FortranFan](#):
>
> Fortran really needs a `do parallel` facility that is a simple, explicit directive by the Fortranner to run in parallel..

Isn’t this the OpenMP specification ?  
Surely we have to work from what has become a very useful addition to Fortran.

My 12 years of effectively using OpenMP tells me that “do parallel” should not be treated as simple !

My problem with OpenMP is the complexity of off-loading to GPU, which I have found very complex, which is not the OpenMP specification’s fault.

We need to push for a standardisation of the instruction set for use of GPU, which looks to be to be a bit of the “Wild West” of operation. This interface needs a standard for GPU developers to adopt, as at the moment we have different Fortran compilers for each GPU.

A standard interface is required.

My other problem with converting DO CONCURRENT to multi-threading is the need to make it practical. (I recall) Ifort had a test to estimate if the multi-threading would produce a better result. Most of the DO CONCURRENT examples I see appear to fail this test, which shows some ignorance of what is needed. Perhaps the restrictions on DO CONCURRENT should also be reviewed, especially as new locality-spec options are introduced.

[Previous page](https://fortran-lang.discourse.group/t/a-do-concurrent-bibliography/11345.md?page=1)
