Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

Score and Match Context Selectors

An OpenMP* context is compatible with a context selector if the following conditions are met:

  • All conditions specified in the USER trait set evaluate to .TRUE.

  • All traits and trait properties defined by IMPLEMENTATION, DEVICE, and CONSTRUCT sets are active in the corresponding trait set of the context.

  • All trait and trait properties defined by the TARGET_DEVICE set are active in the target-device trait set for the device corresponding to the DEVICE_NUM selector.

  • Selectors in the CONSTRUCT set of the selector specify the same construct ordering as the construct trait set of the context.

  • For each selector in the context selector, the properties specified are a subset of the properties of the corresponding trait of the context.

  • No implementation-defined selector specified is ignored by the implementation.

The following additional rules apply to matching certain SIMD selector properties with the SIMD trait:

  • The ALIGNED (list:N) property of the selector matches the ALIGNED (list:M) trait of the context if N is a multiple of M.

  • The SIMDLEN (N) property specified in the selector matches the SIMDLEN (M) property of the context if M is a multiple of N.

The following algorithm is used to score compatible context selectors:

  • Trait selectors that specify a trait-score are given the value of the trait-score expression.

  • Each specified CONSTRUCT trait selector that matches the construct trait in the context is given the value 2p-1, where p is the position of the corresponding trait cp in the context trait set specified by the context selector. The highest valued subset of context traits containing all selectors in the same order is used if the traits that correspond to the construct selector set appear multiple times in the context.

  • If specified, the KIND, ARCH, and ISA selectors are given the values 2n, 2n+1, and 2n+2 respectively, where n is the number of traits in the construct set.

  • Other selectors are given the value of zero.

  • Values given to implementation-defined selectors are defined by the implementation.

  • A context selector that is a strict subset of another context selector is given a score of zero. For other selectors, their final value is the sum of the values of the specified selector plus 1.