OMP_TARGET_OFFLOAD (GNU libgomp)

### 4.17 `OMP_TARGET_OFFLOAD` – Controls offloading behavior ¶

ICV: target-offload-var
Scope: global
Description:

  Specifies the behavior with regard to offloading code to a device. This variable can be set to one of three values - `MANDATORY`, `DISABLED` or `DEFAULT`.

  If set to `MANDATORY`, the program terminates with an error if any device construct or device memory routine uses a device that is unavailable or not supported by the implementation, or uses a non-conforming device number. If set to `DISABLED`, then offloading is disabled and all code runs on the host. If set to `DEFAULT`, the program tries offloading to the device first, then falls back to running code on the host if it cannot.

  If undefined, then the program behaves as if `DEFAULT` was set.

  Note: Even with `MANDATORY`, no run-time termination is performed when the device number in a `device` clause or argument to a device memory routine is for host, which includes using the device number in the default-device-var ICV. However, the initial value of the default-device-var ICV is affected by `MANDATORY`.

See also:

  `OMP_DEFAULT_DEVICE` – Set the device used in target regions

Reference:

  OpenMP specification v5.2, Section 21.2.8