mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 21:29:24 -08:00
This PR: - Introduce per-device runtime options; - Enable flexible setting for default values; - Move AMDGPU queue and SDMA settings into the new options structure to show the usage; - No changes to the existing behaviors and defaults; - Can be extended to support configurations from profiles. RFC can be found: https://discourse.llvm.org/t/rfc-offload-amdgpu-device-specific-runtime-defaults-for-the-openmp-amdgpu-plugin/91613 Assisted by GPT5.6
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
//===- DeviceOptions.h - Per-device plugin options --------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OFFLOAD_PLUGIN_COMMON_DEVICEOPTIONS_H
|
|
#define OFFLOAD_PLUGIN_COMMON_DEVICEOPTIONS_H
|
|
|
|
#include "Shared/EnvironmentVar.h"
|
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
namespace llvm::offload::plugin {
|
|
|
|
/// A runtime option of a device. It holds the device default until the user
|
|
/// overrides it through the environment variable \p EnvName.
|
|
template <typename T> struct DeviceOptionTy {
|
|
DeviceOptionTy(const char *EnvName, T Value)
|
|
: EnvName(EnvName), Value(Value) {}
|
|
|
|
operator T() const { return Value; }
|
|
|
|
DeviceOptionTy &operator=(T NewValue) {
|
|
Value = NewValue;
|
|
return *this;
|
|
}
|
|
|
|
void readFromEnv() {
|
|
Envar<T> Env(EnvName);
|
|
if (!Env.isPresent())
|
|
return;
|
|
Value = Env.get();
|
|
}
|
|
|
|
const char *EnvName;
|
|
T Value;
|
|
};
|
|
|
|
} // namespace llvm::offload::plugin
|
|
|
|
#endif // OFFLOAD_PLUGIN_COMMON_DEVICEOPTIONS_H
|