167ab875fSJohannes Doerfert //===- Configuration.cpp - OpenMP device configuration interface -- C++ -*-===// 267ab875fSJohannes Doerfert // 367ab875fSJohannes Doerfert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 467ab875fSJohannes Doerfert // See https://llvm.org/LICENSE.txt for license information. 567ab875fSJohannes Doerfert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 667ab875fSJohannes Doerfert // 767ab875fSJohannes Doerfert //===----------------------------------------------------------------------===// 867ab875fSJohannes Doerfert // 967ab875fSJohannes Doerfert // This file contains the data object of the constant device environment and the 1067ab875fSJohannes Doerfert // query API. 1167ab875fSJohannes Doerfert // 1267ab875fSJohannes Doerfert //===----------------------------------------------------------------------===// 1367ab875fSJohannes Doerfert 1467ab875fSJohannes Doerfert #include "Configuration.h" 150c554a47SJon Chesterfield #include "DeviceEnvironment.h" 1667ab875fSJohannes Doerfert #include "State.h" 1767ab875fSJohannes Doerfert #include "Types.h" 1867ab875fSJohannes Doerfert 1967ab875fSJohannes Doerfert using namespace _OMP; 2067ab875fSJohannes Doerfert 21*b4f8443dSJoseph Huber #pragma omp begin declare target device_type(nohost) 2267ab875fSJohannes Doerfert 230870a4f5SJoseph Huber // defined by CGOpenMPRuntimeGPU 240870a4f5SJoseph Huber extern uint32_t __omp_rtl_debug_kind; 250870a4f5SJoseph Huber extern uint32_t __omp_rtl_assume_no_thread_state; 26ec02c34bSJoseph Huber 274d50803cSJon Chesterfield // TODO: We want to change the name as soon as the old runtime is gone. 2826feef08SJoseph Huber // This variable should be visibile to the plugin so we override the default 2926feef08SJoseph Huber // hidden visibility. 3067ab875fSJohannes Doerfert DeviceEnvironmentTy CONSTANT(omptarget_device_environment) 3126feef08SJoseph Huber __attribute__((used, retain, weak, visibility("protected"))); 3267ab875fSJohannes Doerfert getDebugKind()33277b681eSJoseph Huberuint32_t config::getDebugKind() { 34277b681eSJoseph Huber return __omp_rtl_debug_kind & omptarget_device_environment.DebugKind; 3567ab875fSJohannes Doerfert } 3667ab875fSJohannes Doerfert getNumDevices()3767ab875fSJohannes Doerfertuint32_t config::getNumDevices() { 38ec02c34bSJoseph Huber return omptarget_device_environment.NumDevices; 39ec02c34bSJoseph Huber } 40ec02c34bSJoseph Huber getDeviceNum()41ec02c34bSJoseph Huberuint32_t config::getDeviceNum() { 42ec02c34bSJoseph Huber return omptarget_device_environment.DeviceNum; 4367ab875fSJohannes Doerfert } 4467ab875fSJohannes Doerfert getDynamicMemorySize()45f1c821faSJoseph Huberuint64_t config::getDynamicMemorySize() { 46f1c821faSJoseph Huber return omptarget_device_environment.DynamicMemSize; 47f1c821faSJoseph Huber } 48f1c821faSJoseph Huber isDebugMode(config::DebugKind Kind)49277b681eSJoseph Huberbool config::isDebugMode(config::DebugKind Kind) { 50277b681eSJoseph Huber return config::getDebugKind() & Kind; 5167ab875fSJohannes Doerfert } 5267ab875fSJohannes Doerfert mayUseThreadStates()530870a4f5SJoseph Huberbool config::mayUseThreadStates() { return !__omp_rtl_assume_no_thread_state; } 540870a4f5SJoseph Huber 5567ab875fSJohannes Doerfert #pragma omp end declare target 56