LLVM OpenMP* Runtime Library
Loading...
Searching...
No Matches
src
kmp_device_env.h
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
41
extern
"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.
47
int
__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.
52
char
const
*__kmpc_get_device_env(
char
const
*base_name,
int
device_id);
53
54
// Free all storage owned by the registry.
55
void
__kmp_device_env_reset(
void
);
56
57
// Iterate the eligible base-name table; returns NULL once exhausted.
58
char
const
*__kmp_device_env_eligible_name(
int
index);
59
60
#ifdef __cplusplus
61
}
62
#endif
63
64
#endif
// KMP_DEVICE_ENV_H
Generated by
1.15.0