# DO CONCURRENT: compiler flags to enable parallelization

**URL:** <https://fortran-lang.discourse.group/t/do-concurrent-compiler-flags-to-enable-parallelization/4300>\
**Category:** Help\
**Created:** [September 12, 2022, 9:09pm UTC](https://fortran-lang.discourse.group/t/do-concurrent-compiler-flags-to-enable-parallelization/4300 "2022-09-12T21:09:52Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [January 3, 2024, 12:53am UTC](https://fortran-lang.discourse.group/t/do-concurrent-compiler-flags-to-enable-parallelization/4300/6 "2024-01-03T00:53:27Z")

</div>

I summarized some do concurrent related information in [this thread](https://fortran-lang.discourse.group/t/simplify-loop-on-an-array-of-derived-type/7095/9) and thought it is worth reposting here:

## Multi-threaded do concurrent (CPU)

| Compiler | Parallel flag | Information | Number of threads | Underlying implementation |
| --- | --- | --- | --- | --- |
| `gfortran` | `-ftree-parallelize-loops=n` | `-fopt-info-loop` | using the parallel flag | OpenMP/pthreads |
| `nvfortran` | `-stdpar=multicore` | `-Minfo=stdpar,accel` | `ACC_NUM_CORES` | OpenACC |
| `ifort` (deprecated) | `-parallel` | `-qopt-report -qopt-report-phase=par` | `OMP_NUM_THREADS`, `-par-num-threads=n` | OpenMP |
| `ifx` | `-qopenmp` | `-qopt-report` | `OMP_NUM_THREADS` | OpenMP |
| CCE `ftn` (Cray/HPE) | `-h thread_do_concurrent` | ? | ? | ? |
| AMD `flang` | `-fopenmp` | ? | `OMP_NUM_THREADS` | OpenMP |

The OpenMP [environment variables](https://www.openmp.org/spec-html/5.0/openmpch6.html) can also be used to control processor affinity. This is also the case for nvfortran, which responds to `OMP_PROC_BIND` and `OMP_PLACES`, because OpenACC doesn’t have variables for thread-to-core binding.

## Resources

- [Number of threads in `do concurrent` loops | NVIDIA](https://forums.developer.nvidia.com/t/number-of-threads-in-do-concurrent-loops/252639)
- [Accelerating Fortran DO CONCURRENT with GPUs and the NVIDIA HPC SDK | NVIDIA](https://developer.nvidia.com/blog/accelerating-fortran-do-concurrent-with-gpus-and-the-nvidia-hpc-sdk/)
- [Does gfortran take advantage of DO CONCURRENT? | Stack Overflow](https://stackoverflow.com/questions/29928293/does-gfortran-take-advantage-of-do-concurrent)
- [When should I use DO CONCURRENT and when OpenMP? | Stack Overflow](https://stackoverflow.com/questions/38549666/when-should-i-use-do-concurrent-and-when-openmp?noredirect=1&lq=1)
- [Using Fortran DO CONCURRENT for Accelerator Offload | Intel](https://www.intel.com/content/www/us/en/developer/articles/technical/using-fortran-do-current-for-accelerator-offload.html#gs.2h91al)
- [The Case for OpenMP\* Target Offloading: Why ISO Fortran Is Not Enough for Heterogeneous Computing | Intel](https://www.intel.com/content/www/us/en/developer/articles/technical/the-case-for-openmp-target-offloading.html#gs.2ha5eo)
- [Transition to the Intel (R) Fortran Compiler | Intel](https://www.openmp.org/wp-content/uploads/IFX_update_apr2023.pdf)
- [DO CONCURRENT isn’t necessarily concurrent | LLVM (flang)](https://flang.llvm.org/docs/DoConcurrent.html)
- [Benchmarking Fortran DO CONCURRENT on CPUs and GPUs Using BabelStream | SC22](https://www.dcs.warwick.ac.uk/pmbs/pmbs22/PMBS/talk12.pdf)
- [Can Fortran’s `do concurrent’ replace directives for accelerated computing? | SC21](https://waccpd.org/wp-content/uploads/2021/11/ws_waccpd102s3-file5.pdf)
- [Clarification on DO CONCURRENT | Fortran Discourse](https://fortran-lang.discourse.group/t/clarification-on-do-concurrent/1647/29)

PS: I’ve made this a Wiki post, so feel free to add missing information.

---

_[View the full topic](https://fortran-lang.discourse.group/t/do-concurrent-compiler-flags-to-enable-parallelization/4300)._
