LLVM OpenMP
kmp_device_env.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// Implements parsing, storage and precedence resolution for the OpenMP 6.0
10// device-scope environment variable extensions described in OpenMP 6.0
11// Section 3.2 (ICV initialization) and Chapter 4 (Environment Variables):
12//
13// <ENV> -- sets the host device ICV.
14// <ENV>_ALL -- sets the host and non-host device ICVs that are not
15// overridden by a more specific form.
16// <ENV>_DEV -- sets all non-host device ICVs that are not overridden
17// by an `<ENV>_DEV_<d>` form.
18// <ENV>_DEV_<d> -- sets the ICV for non-host device with id `d` (a
19// non-negative integer).
20//
21// Precedence:
22// Host: <ENV> > <ENV>_ALL > default
23// Device d: <ENV>_DEV_<d> > <ENV>_DEV > <ENV>_ALL > default
24//
25// Restrictions enforced:
26// * Device-specific environment variables are only accepted for env vars
27// listed in `__kmp_device_env_eligible_names` (i.e. those that initialize
28// device-scope ICVs and are not global-scope or `OMP_DEFAULT_DEVICE`).
29// Suffix forms applied to other env vars are ignored with a warning.
30// * `<ENV>_DEV_<token>` where <token> is not a non-negative integer is
31// rejected with a warning. The spec requires that device-specific
32// environment variables must not specify the host device; we accept only
33// non-negative integer non-host device ids.
34// * Conflicting settings of `<ENV>_DEV_<d>` (same d) follow last-parsed-wins
35// semantics, mirroring existing libomp env handling.
36
37#ifndef KMP_DEVICE_ENV_H
38#define KMP_DEVICE_ENV_H
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44// Consume `full_name=value` if it is a device-scope variant. Returns:
45// 1 -- consumed (stored, OR rejected with a warning); caller must skip it.
46// 0 -- not a device-scope variant; caller continues normal processing.
47int __kmp_device_env_record(char const *full_name, char const *value);
48
49// Resolve the effective string for `base_name` on a non-host device:
50// <ENV>_DEV_<d> > <ENV>_DEV > <ENV>_ALL > NULL.
51// `device_id` is 0-based and must be >= 0.
52char const *__kmpc_get_device_env(char const *base_name, int device_id);
53
54// Free all storage owned by the registry.
55void __kmp_device_env_reset(void);
56
57// Iterate the eligible base-name table; returns NULL once exhausted.
58char const *__kmp_device_env_eligible_name(int index);
59
60#ifdef __cplusplus
61}
62#endif
63
64#endif // KMP_DEVICE_ENV_H
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
char const * __kmp_device_env_eligible_name(int index)
void __kmp_device_env_reset(void)
int __kmp_device_env_record(char const *full_name, char const *value)
char const * __kmpc_get_device_env(char const *base_name, int device_id)