[Openmp-commits] [PATCH] D86804: [OpenMP] Consolidate error handling and debug messages in Libomptarget
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Mon Aug 31 05:01:16 PDT 2020
jhuber6 added inline comments.
================
Comment at: openmp/libomptarget/include/Debug.h:43
+// Enables extra runtime information output if env LIBOMPTARGET_INFO > 0
+extern int InfoLevel;
+
----------------
jhuber6 wrote:
> Having these as global variables is irritating. I could replace it with a function called getDebugLevel that returns the value of the environment variable and use that in the debug macros so it wouldn't need to be called manually in the files. Could potentially store a cached result so it doesn't call getenv every time.
Is something like this an acceptable solution? It fixes the weird problems I was getting in the CUDA RTL without a static variable. The variables are still global unless I want to add a source file.
```
static int DebugLevel = -1;
static int InfoLevel = -1;
static int getInfoLevel() {
if (InfoLevel >= 0)
return InfoLevel;
if (char *EnvStr = getenv("LIBOMPTARGET_INFO"))
InfoLevel = std::stoi(EnvStr);
return InfoLevel;
}
static int getDebugLevel() {
if (DebugLevel >= 0)
return DebugLevel;
if (char *EnvStr = getenv("LIBOMPTARGET_DEBUG"))
DebugLevel = std::stoi(EnvStr);
return DebugLevel;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86804/new/
https://reviews.llvm.org/D86804
More information about the Openmp-commits
mailing list