summaryrefslogtreecommitdiff
path: root/backend/src/sys
diff options
context:
space:
mode:
authorBenjamin Segovia <segovia.benjamin@gmail.com>2012-04-13 18:41:56 +0000
committerKeith Packard <keithp@keithp.com>2012-08-10 16:16:23 -0700
commita217fd38d20d8ce8bdb4ac653238c7b885556233 (patch)
tree7bf80fcde6f9fdce0ae392954a821ce96067f7f1 /backend/src/sys
parent9f14b353dcf998ef93526d278870132811c84166 (diff)
Made the first kernels work with the simulators Added some debug variables
Diffstat (limited to 'backend/src/sys')
-rw-r--r--backend/src/sys/debug.cpp66
-rw-r--r--backend/src/sys/debug.hpp33
-rw-r--r--backend/src/sys/debug.hxx3
3 files changed, 102 insertions, 0 deletions
diff --git a/backend/src/sys/debug.cpp b/backend/src/sys/debug.cpp
new file mode 100644
index 00000000..b892737a
--- /dev/null
+++ b/backend/src/sys/debug.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+/**
+ * \file debug.cpp
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+#include "debug.hpp"
+#include <cstdio>
+#include <sstream>
+#include <string>
+
+namespace gbe
+{
+#define DECL_DEBUG_VAR(TYPE, NAME) TYPE NAME;
+ #include "debug.hxx"
+#undef DECL_DEBUG_VAR
+} /* namespace gbe */
+
+namespace
+{
+ template <typename VarType>
+ static VarType getValue(const char *str) {
+ VarType value;
+ std::stringstream ss;
+ ss << std::string(str);
+ ss >> value;
+ return value;
+ }
+
+ struct DebugVarInitializer
+ {
+ DebugVarInitializer(void) {
+#define DECL_DEBUG_VAR(TYPE, NAME) gbe::NAME = TYPE(0);
+#include "debug.hxx"
+#undef DECL_DEBUG_VAR
+
+#define DECL_DEBUG_VAR(TYPE, NAME) do { \
+ const char *str = getenv(#NAME); \
+ if (str != NULL) gbe::NAME = getValue<TYPE>(str); \
+} while (0);
+#include "debug.hxx"
+#undef DECL_DEBUG_VAR
+ }
+ };
+
+ static DebugVarInitializer debugVarInitializer;
+} /* namespace */
+
diff --git a/backend/src/sys/debug.hpp b/backend/src/sys/debug.hpp
new file mode 100644
index 00000000..1abbfca2
--- /dev/null
+++ b/backend/src/sys/debug.hpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+/**
+ * \file debug.hpp
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ *
+ * shitloads of debug variables (set on pre-main) that the user can set
+ */
+
+namespace gbe
+{
+#define DECL_DEBUG_VAR(TYPE, NAME) extern TYPE NAME;
+ #include "debug.hxx"
+#undef DECL_DEBUG_VAR
+} /* namespace gbe */
+
diff --git a/backend/src/sys/debug.hxx b/backend/src/sys/debug.hxx
new file mode 100644
index 00000000..1f9a66ad
--- /dev/null
+++ b/backend/src/sys/debug.hxx
@@ -0,0 +1,3 @@
+DECL_DEBUG_VAR(bool, OCL_OUTPUT_GEN_IR)
+DECL_DEBUG_VAR(bool, OCL_OUTPUT_LLVM)
+