OpenMP and OpenACC Options (Using the GNU Compiler Collection (GCC))

### 3.7 Options Controlling OpenMP and OpenACC ¶

GCC supports OpenMP extensions to the C, C++, and Fortran languages with the `-fopenmp` option. Similarly, OpenACC extensions are supported in all three languages with `-fopenacc`. See OpenMP and OpenACC for an overview of these extensions.

`-foffload=disable` ¶
`-foffload=default`
`-foffload=target-list`

  Specify for which OpenMP and OpenACC offload targets code should be generated. The default behavior, equivalent to `-foffload=default`, is to generate code for all supported offload targets. The `-foffload=disable` form generates code only for the host fallback, while `-foffload=target-list` generates code only for the specified comma-separated list of offload targets.

  Offload targets are specified in GCC’s internal target-triplet format. You can run the compiler with `-v` to show the list of configured offload targets under `OFFLOAD_TARGET_NAMES`.

`-foffload-options=options` ¶
`-foffload-options=target-triplet-list=options`

  With `-foffload-options=options`, GCC passes the specified options to the compilers for all enabled offloading targets. You can specify options that apply only to a specific target or targets by using the `-foffload-options=target-list=options` form. The target-list is a comma-separated list in the same format as for the `-foffload=` option.

  Typical command lines are

      -foffload-options='-fno-math-errno -ffinite-math-only' \
              -foffload-options=nvptx-none=-latomic
      -foffload-options=amdgcn-amdhsa=-march=gfx906

`-fopenacc` ¶

  Enable handling of OpenACC directives ‘`#pragma acc`’ in C/C++ and ‘`!$acc`’ in free-form Fortran and ‘`!$acc`’, ‘`c$acc`’ and ‘`*$acc`’ in fixed-form Fortran. This option implies `-pthread`, and thus is only supported on targets that have support for `-pthread`.

`-fopenacc-dim=geom` ¶

  Specify default compute dimensions for parallel offload regions that do not explicitly specify them. The geom value is a triple of ‘`:`’-separated sizes, in order gang, worker, and vector. A size can be omitted, to use a target-specific default value.

`-fopenmp` ¶

  Enable handling of OpenMP directives ‘`#pragma omp`’, ‘`[[omp::decl(...)]]`’, ‘`[[omp::directive(...)]]`’, and ‘`[[omp::sequence(...)]]`’ in C/C++. In Fortran, it enables ‘`!$omp`’ and the conditional compilation sentinel ‘`!$`’. In fixed source form Fortran, the sentinels can also start with ‘`c`’ or ‘`*`’.

  This option implies `-pthread`, and thus is only supported on targets that have support for `-pthread`. `-fopenmp` implies `-fopenmp-simd`.

`-fopenmp-simd` ¶

  Enable handling of OpenMP’s `simd`, `declare simd`, `declare reduction`, `assume`, `ordered`, `scan` and `loop` directive, and of combined or composite directives with `simd` as constituent with `#pragma omp`, `[[omp::directive(...)]]`, `[[omp::sequence(...)]]` and `[[omp::decl(...)]]` in C/C++ and `!$omp` in Fortran. It additionally enables the conditional compilation sentinel ‘`!$`’ in Fortran. In fixed source form Fortran, the sentinels can also start with ‘`c`’ or ‘`*`’. Other OpenMP directives are ignored. Unless `-fopenmp` is additionally specified, the `loop` region binds to the current task region, independent of the specified `bind` clause.

`-fopenmp-target-simd-clone` ¶
`-fopenmp-target-simd-clone=device-type`

  In addition to generating SIMD clones for functions marked with the `declare simd` directive, GCC also generates clones for functions marked with the OpenMP `declare target` directive that are suitable for vectorization when this option is in effect. The device-type may be one of `none`, `host`, `nohost`, and `any`, which correspond to keywords for the `device_type` clause of the `declare target` directive; clones are generated for the intersection of devices specified. `-fopenmp-target-simd-clone` is equivalent to `-fopenmp-target-simd-clone=any` and `-fno-openmp-target-simd-clone` is equivalent to `-fopenmp-target-simd-clone=none`.

  At `-O2` and higher (but not `-Os` or `-Og`) this optimization defaults to `-fopenmp-target-simd-clone=nohost`; otherwise it is disabled by default.