Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 6/30/2025
Public
Document Table of Contents

Device-Side Compiler Sanitizers

Device-Side AddressSanitizer

The device-side AddressSanitizer (ASan) supports the error checks in the following table for OpenMP device code.

Feature OpenMP

bad-context

n/a

bad-free

n/a

double-free

n/a

invalid argument

Not supported

kernel filter

Not supported

memory leak

Supported

memory overhead statistics

Supported

misaligned access

Not supported

multiple error reports

Not supported

nullpointer access

Supported

out-of-bounds on device global

Supported

out-of-bounds on global unified shared memory (USM)

Supported

out-of-bounds on local

Supported

out-of-bounds on memory buffer

n/a

out-of-bounds on private

Supported

use-after-free

Supported

OpenMP

Compile your OpenMP Fortran application and execute it with ASan enabled (only supported on GPU), for example:

ifx –fiopenmp -fopenmp-targets=spir64 -Xarch_device -fsanitize=address -g -o demo demo.f90

Run on GPU with:

export LIBOMPTARGET_PLUGIN=unified_runtime 
export UR_ENABLE_LAYERS=UR_LAYER_ASAN 
./demo

Compiler Flags
Flag Default Value Description
-mllvm -asan-spir-locals=0 | 1

1

Enable ASan detection for local memory. Set the value to 0 to disable this check. Use the runtime flag: detect_locals.

-mllvm -asan-spir-privates=0 | 1

1

Enable ASan detection for private memory. Set the value to 0 to disable this check. Use the runtime flag: detect_privates

Runtime Flags

Runtime flags can be passed to the device-side ASan with the UR_LAYER_ASAN_OPTIONS environment variable, shown in the following example:

UR_LAYER_ASAN_OPTIONS=redzone:32 ./demo
UR_LAYER_ASAN_OPTIONS="quarantine_size_mb:0; print_stats:1" ./demo 

Flag Default Value Description
detect_kernel_arguments

true

Enable runtime support for detecting invalid kernel arguments, such as using pointers from different context or device.

detect_leaks

true

Enable memory leak detection.

detect_locals

true

Enable runtime support for detecting out-of-bounds errors on local memory, such as shared local memory (SLM).

detect_privates

true

Enable runtime support for detecting out-of-bounds errors on private memory.

halt_on_error

true

Crash the program after printing the first error report. The flag is only effective if your code was compiled with the -fsanitize-recover=address compile option.

print_stats

false

Print memory overhead statistics after printing an error message.

quarantine_size_mb

0

The size (in MB) of quarantine used to detect use-after-free errors. Lower values may reduce memory usage, but increase the chance of false negatives. The default value is 0, indicating that while the sanitizer continues to detect use-after-free errors, it does not employ quarantine to minimize false negatives, thereby reducing memory overhead.

redzone

16

Minimal size (in bytes) of redzones around USM heap objects. Requirement: redzone >= 16, is a power of two.

NOTE:
A larger redzone size may help capture out-of-bounds errors with a large offset, but may exhaust your device memory.

Device-Side MemorySanitizer

The device-side MemorySanitizer (MSan), a tool in LLVM used to detect the use of uninitialized memory (UUM), supports OpenMP device code starting with the 2025.1 release. To activate this feature for device code, use the -Xarch_device -fsanitize=memory options when compiling your source code. This SYCL accelerator extension provides a device-side MSan, focusing on device USM to address common use cases.

Support was extended in 2025.2 release to include a local and private memory check. You can enable this feature by configuring the following compiler options. OpenMP Fortran offload support is also included in this release.

NOTE:
The local and private memory check will increase the runtime overhead.

OpenMP

Compiling and running OpenMPFortran code with MSan enabled:

  1. Compile your OpenMPFortran example with device-side MSan enabled:
    ifx -fiopenmp -fopenmp-targets=spir64 -Xarch_device -fsanitize=memory -g -o demo ompf-demo.f90 
  2. Run your example on GPU:
    export LIBOMPTARGET_PLUGIN=unified_runtime     
    export UR_ENABLE_LAYERS=UR_LAYER_MSAN
    export ZE_AFFINITY_MASK=0
    ./demo

NOTE:
Setting the ONEAPI_DEVICE_SELECTOR=level_zero:gpu environment variable for OpenMP offload on GPU device will cause errors.

Compiler Flags
Flag Default Value Description
-mllvm -msan-spir-locals=0 | 1

1

Enable MSan detection for local memory. Set the value to 0 to disable this check.

-mllvm -msan-spir-privates=0 | 1

1

Enable MSan detection for private memory. Set the value to 0 to disable this check.

Runtime Flags

Runtime flags can be passed to the device-side MSan with the UR_LAYER_MSAN_OPTIONS environment variable, shown in the following example:

UR_LAYER_MSAN_OPTIONS=recover:true ./demo

Flag Default Value Description
recover

false

Terminate the kernel execution after detecting the first error. If its value is true, the kernel will continue executing even after an error is detected.

See Also