Intel® Fortran Compiler

Developer Guide and Reference

ID 767251
Date 3/31/2025
Public
Document Table of Contents

Compiler Sanitizers

Compiler sanitizers give you tools to detect bugs and/or errors, including buffer overflows, accesses, dangling pointers, uses-of-uninitialized memory and other types of undefined behavior. The compiler sanitizers work with OpenMP* and SYCL*.

System Requirements

  • Platform Support: CPU device and PVC GPU is supported on Linux.
  • GPU Configuration: This feature supports one PVC GPU card. For the Intel® oneAPI Level Zero (Level Zero) runtime, use the ZE_AFFINITY_MASK=0 environment variable to set this configuration.

Device-Side AddressSanitizer

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

Feature OpenMP SYCL

bad-context

n/a

Supported

bad-free

n/a

Supported

double-free

n/a

Supported

invalid argument

Not supported

Supported

kernel filter

Not supported

Supported

memory leak

Supported

Supported

memory overhead statistics

Supported

Supported

misaligned access

Not supported

Supported

multiple error reports

Not supported

Supported

nullpointer access

Supported

Supported

out-of-bounds on device global

Supported

Supported

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

Supported

Supported

out-of-bounds on local

Supported

Supported

out-of-bounds on memory buffer

n/a

Supported

out-of-bounds on private

Supported

Supported

use-after-free

Supported

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

SYCL

Compile a SYCL example with ASan enabled:

icpx -fsycl -Xarch_device -fsanitize=address -g -O2 -o demo demo.cpp

Run on CPU with:

export ONEAPI_DEVICE_SELECTOR=opencl:cpu
./demo

Run on GPU with:

export ONEAPI_DEVICE_SELECTOR=level_zero:gpu
./demo

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:

export UR_LAYER_ASAN_OPTIONS="quarantine_size_mb:1" ./demo
export UR_LAYER_ASAN_OPTIONS=redzone:32 ./demo 
export UR_LAYER_ASAN_OPTIONS=max_redzone:1024 ./demo export 
UR_LAYER_ASAN_OPTIONS="redzone:32;max_redzone:1024" ./demo

Flag Default Value Description
detect_locals

true

Enable runtime support for detecting out-of-bounds errors on local memory and 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.

max_redzone

2048

Maximal size (in bytes) of redzones around USM heap objects.

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.

Limitations

The compiler sanitizers have the following limitations:

  • Kernel execution is sequential. Concurrent execution is forced to into sequential execution when device-side ASan is enabled.
  • A large number of workgroups on a GPU may lead to the device-side ASan skipping an out-of-bound check for private/local memory.
  • OpenMP (Fortran) only supports execution on a GPU device.

See Also