Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

omp target variant dispatch

Conditionally calls a procedure offload variant if the specified device is available; otherwise, executes the procedure on the host.

Syntax

#pragma omp target variant dispatch {device(integer-expression) | nowait | subdevice([integer-constant ,] integer-expression [ : integer-expression [ : integer-expression] ] ) | use_device_pointer (ptr-list)}

Arguments

device

Tells the compiler to call the variant only if device n is available.

subdevice

Tells the compiler to call the variant only if the specified tiles or compute slices are available.

nowait

Tells the compiler that calls to the procedure can occur asynchronously. If nowait is not specified, calls occur synchronously.

use_device_ptr

Tells the compiler to use the corresponding device pointer instead of the host pointer when the variant procedure is called.

If both device and subdevice are specified, the variant is called only if the specified tiles or compute slices are available on device n. Otherwise, the base version of the procedure is called on the host.

Description

The omp target variant dispatch pragma causes the compiler to emit conditional dispatch code around the associated procedure call that follows the pragma. If the specified device is available, the variant version is called.

The name of the procedure associated with the omp target variant dispatch pragma must have appeared in an omp declare variant pragma in the specification part of the calling scope. The interface of the variant procedure must be accessible in the base procedure where omp target variant dispatch appears.

The omp target variant dispatch pragma is supported in host code only.

NOTE:

Use pragma omp target variant dispatch when calling Intel® oneAPI Math Kernel Library (oneMKL).

In other cases, we recommend you use the OpenMP* pragma omp dispatch. For more information about pragma omp dispatch, see the OpenMP* documentation.