Removing iree/base/logging.h. (#9605)
Besides a few random spots it cropped up in the runtime/python bindings
the C++ logging code was only used in tests and tools where the
features provided for verbosity control aren't meaningful. Instead of
porting it all to C I've just gone and deleted it -
`fprintf(stderr)`/`std::cerr` is almost always what's wanted instead
and is much simpler to understand. As a library we try not to have any
log spew, tests can use gtest logging, and the tools are almost all
LLVM-based and use the logging functionality already available in
that world.
Fixes #2843.
diff --git a/docs/developers/developing_iree/developer_overview.md b/docs/developers/developing_iree/developer_overview.md
index 52d07a5..dc9004b 100644
--- a/docs/developers/developing_iree/developer_overview.md
+++ b/docs/developers/developing_iree/developer_overview.md
@@ -201,13 +201,6 @@
There are a few useful generic flags when working with IREE tools:
-#### `--iree_minloglevel` and `--iree_v`
-
-These flags can control IREE tool output verbosity. `--iree_minloglevel` and
-`--iree_v` set the minimal and maximal verbosity levels respectively. They both
-accept a number where 0, 1, 2, 3 stands for info, warning, error, and fatal
-error respectively.
-
#### Read inputs from a file
All the IREE tools support reading input values from a file. This is quite
diff --git a/runtime/bindings/python/initialize_module.cc b/runtime/bindings/python/initialize_module.cc
index 4e79c99..db9d242 100644
--- a/runtime/bindings/python/initialize_module.cc
+++ b/runtime/bindings/python/initialize_module.cc
@@ -40,9 +40,9 @@
char **argv = &flag_ptrs[0];
int argc = flag_ptrs.size();
- CheckApiStatus(
- iree_flags_parse(IREE_FLAGS_PARSE_MODE_DEFAULT, &argc, &argv),
- "Error parsing flags");
+ CheckApiStatus(iree_flags_parse(IREE_FLAGS_PARSE_MODE_CONTINUE_AFTER_HELP,
+ &argc, &argv),
+ "Error parsing flags");
});
}
diff --git a/runtime/bindings/python/tests/flags_test.py b/runtime/bindings/python/tests/flags_test.py
index 886176a..56309ab 100644
--- a/runtime/bindings/python/tests/flags_test.py
+++ b/runtime/bindings/python/tests/flags_test.py
@@ -12,8 +12,8 @@
class FlagsTest(unittest.TestCase):
def testParse(self):
- # We always have the logging verbose level available so use it.
- rt.flags.parse_flags("--iree_v=1")
+ # --help is always available if flags are.
+ rt.flags.parse_flags("--help")
def testParseError(self):
with self.assertRaisesRegex(ValueError, "flag 'barbar' not recognized"):
diff --git a/runtime/bindings/python/vm.cc b/runtime/bindings/python/vm.cc
index d6a78e5..440732b 100644
--- a/runtime/bindings/python/vm.cc
+++ b/runtime/bindings/python/vm.cc
@@ -98,7 +98,7 @@
CheckApiStatus(status, "Error creating vm context with modules");
}
- IREE_CHECK(context);
+ IREE_ASSERT(context);
return VmContext::StealFromRawPtr(context);
}
diff --git a/runtime/bindings/tflite/java/org/tensorflow/lite/native/CMakeLists.txt b/runtime/bindings/tflite/java/org/tensorflow/lite/native/CMakeLists.txt
index c168a92..afecd0e 100644
--- a/runtime/bindings/tflite/java/org/tensorflow/lite/native/CMakeLists.txt
+++ b/runtime/bindings/tflite/java/org/tensorflow/lite/native/CMakeLists.txt
@@ -19,7 +19,6 @@
target_link_libraries(${_NAME}
PUBLIC
iree::base
- iree::base::logging
iree::runtime::bindings::tflite::shim
)
diff --git a/runtime/bindings/tflite/java/org/tensorflow/lite/native/interpreter_jni.cc b/runtime/bindings/tflite/java/org/tensorflow/lite/native/interpreter_jni.cc
index e347fa8..78d6453 100644
--- a/runtime/bindings/tflite/java/org/tensorflow/lite/native/interpreter_jni.cc
+++ b/runtime/bindings/tflite/java/org/tensorflow/lite/native/interpreter_jni.cc
@@ -6,7 +6,7 @@
#include <jni.h>
-#include "iree/base/logging.h"
+#include "iree/base/assert.h"
// NOTE: we pull in our own copy here in case the tflite API changes upstream.
#define TFL_COMPILE_LIBRARY 1
@@ -21,10 +21,10 @@
// object.
static TfLiteInterpreter* GetInterpreter(JNIEnv* env, jobject obj) {
jclass clazz = env->GetObjectClass(obj);
- IREE_DCHECK(clazz);
+ IREE_ASSERT(clazz);
jfieldID field = env->GetFieldID(clazz, "nativeAddress", "J");
- IREE_DCHECK(field);
+ IREE_ASSERT(field);
if (env->ExceptionCheck()) {
return nullptr; // Failed to get field, returning null.
@@ -59,19 +59,19 @@
JNI_FUNC void JNI_PREFIX(nativeFree)(JNIEnv* env, jobject thiz) {
TfLiteInterpreter* interpreter = GetInterpreter(env, thiz);
- IREE_DCHECK_NE(interpreter, nullptr);
+ IREE_ASSERT_NE(interpreter, nullptr);
TfLiteInterpreterDelete(interpreter);
}
JNI_FUNC jint JNI_PREFIX(nativeInputTensorCount)(JNIEnv* env, jobject thiz) {
TfLiteInterpreter* interpreter = GetInterpreter(env, thiz);
- IREE_DCHECK_NE(interpreter, nullptr);
+ IREE_ASSERT_NE(interpreter, nullptr);
return (jint)TfLiteInterpreterGetInputTensorCount(interpreter);
}
JNI_FUNC jint JNI_PREFIX(nativeOutputTensorCount)(JNIEnv* env, jobject thiz) {
TfLiteInterpreter* interpreter = GetInterpreter(env, thiz);
- IREE_DCHECK_NE(interpreter, nullptr);
+ IREE_ASSERT_NE(interpreter, nullptr);
return (jint)TfLiteInterpreterGetOutputTensorCount(interpreter);
}
diff --git a/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensor_jni.cc b/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensor_jni.cc
index d193a0d..d9be459 100644
--- a/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensor_jni.cc
+++ b/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensor_jni.cc
@@ -6,7 +6,7 @@
#include <jni.h>
-#include "iree/base/logging.h"
+#include "iree/base/assert.h"
// NOTE: we pull in our own copy here in case the tflite API changes upstream.
#define TFL_COMPILE_LIBRARY 1
@@ -21,10 +21,10 @@
// object.
static TfLiteTensor* GetTensor(JNIEnv* env, jobject obj) {
jclass clazz = env->GetObjectClass(obj);
- IREE_DCHECK(clazz);
+ IREE_ASSERT(clazz);
jfieldID field = env->GetFieldID(clazz, "nativeAddress", "J");
- IREE_DCHECK(field);
+ IREE_ASSERT(field);
if (env->ExceptionCheck()) {
return nullptr; // Failed to get field, returning null.
diff --git a/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensorflow_lite_jni.cc b/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensorflow_lite_jni.cc
index 1d635ee..27b75c4 100644
--- a/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensorflow_lite_jni.cc
+++ b/runtime/bindings/tflite/java/org/tensorflow/lite/native/tensorflow_lite_jni.cc
@@ -6,8 +6,6 @@
#include <jni.h>
-#include "iree/base/logging.h"
-
// NOTE: we pull in our own copy here in case the tflite API changes upstream.
#define TFL_COMPILE_LIBRARY 1
#include "runtime/bindings/tflite/include/tensorflow/lite/c/c_api.h"
diff --git a/runtime/src/iree/base/BUILD b/runtime/src/iree/base/BUILD
index 2b36066..ee94ed8 100644
--- a/runtime/src/iree/base/BUILD
+++ b/runtime/src/iree/base/BUILD
@@ -62,7 +62,6 @@
deps = [
":base",
":core_headers",
- ":logging",
],
)
@@ -159,23 +158,6 @@
#===------------------------------------------------------------------------===#
iree_runtime_cc_library(
- name = "logging",
- srcs = ["logging.cc"],
- hdrs = ["logging.h"],
- linkopts = select({
- "//build_tools/bazel:iree_is_android": [
- "-llog",
- ],
- "//conditions:default": [],
- }),
- deps = [
- ":core_headers",
- ":tracing",
- "//runtime/src/iree/base/internal:flags",
- ],
-)
-
-iree_runtime_cc_library(
name = "loop_sync",
srcs = ["loop_sync.c"],
hdrs = ["loop_sync.h"],
diff --git a/runtime/src/iree/base/CMakeLists.txt b/runtime/src/iree/base/CMakeLists.txt
index cc78f01..3a9d1ca 100644
--- a/runtime/src/iree/base/CMakeLists.txt
+++ b/runtime/src/iree/base/CMakeLists.txt
@@ -59,7 +59,6 @@
DEPS
::base
::core_headers
- ::logging
PUBLIC
)
@@ -147,20 +146,6 @@
iree_cc_library(
NAME
- logging
- HDRS
- "logging.h"
- SRCS
- "logging.cc"
- DEPS
- ::core_headers
- ::tracing
- iree::base::internal::flags
- PUBLIC
-)
-
-iree_cc_library(
- NAME
loop_sync
HDRS
"loop_sync.h"
diff --git a/runtime/src/iree/base/internal/BUILD b/runtime/src/iree/base/internal/BUILD
index ecb993f..a03ab01 100644
--- a/runtime/src/iree/base/internal/BUILD
+++ b/runtime/src/iree/base/internal/BUILD
@@ -148,7 +148,6 @@
":file_io",
"//runtime/src/iree/base:cc",
"//runtime/src/iree/base:core_headers",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/testing:gtest",
"//runtime/src/iree/testing:gtest_main",
],
diff --git a/runtime/src/iree/base/internal/CMakeLists.txt b/runtime/src/iree/base/internal/CMakeLists.txt
index fa2c4b9..45a1c53 100644
--- a/runtime/src/iree/base/internal/CMakeLists.txt
+++ b/runtime/src/iree/base/internal/CMakeLists.txt
@@ -146,7 +146,6 @@
::file_io
iree::base::cc
iree::base::core_headers
- iree::base::logging
iree::testing::gtest
iree::testing::gtest_main
)
diff --git a/runtime/src/iree/base/internal/file_io_test.cc b/runtime/src/iree/base/internal/file_io_test.cc
index fd975a6..0651421 100644
--- a/runtime/src/iree/base/internal/file_io_test.cc
+++ b/runtime/src/iree/base/internal/file_io_test.cc
@@ -17,7 +17,6 @@
#include <type_traits>
#include <utility>
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -36,7 +35,10 @@
if (!test_tmpdir) {
test_tmpdir = getenv("TEMP");
}
- IREE_CHECK(test_tmpdir) << "TEST_TMPDIR/TMPDIR/TEMP not defined";
+ if (!test_tmpdir) {
+ std::cerr << "TEST_TMPDIR/TMPDIR/TEMP not defined\n";
+ exit(1);
+ }
return test_tmpdir + std::string("/iree_test_") + unique_name;
}
diff --git a/runtime/src/iree/base/logging.cc b/runtime/src/iree/base/logging.cc
deleted file mode 100644
index b27342f..0000000
--- a/runtime/src/iree/base/logging.cc
+++ /dev/null
@@ -1,189 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed 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
-
-#include "iree/base/logging.h"
-
-#include <cstddef>
-#include <cstdio>
-#include <cstdlib>
-
-#ifdef __ANDROID__
-#include <android/log.h>
-#endif
-
-#include "iree/base/internal/flags.h"
-#include "iree/base/tracing.h"
-
-IREE_FLAG(int32_t, iree_minloglevel, 0,
- "Minimum logging level. 0 = INFO and above.");
-IREE_FLAG(int32_t, iree_v, 0,
- "Verbosity level maximum. 1 = IREE_VLOG(0-1), 2 = IREE_VLOG(0-2).");
-
-namespace iree {
-namespace internal {
-
-namespace {
-
-// Parse log level (int64_t) from environment variable (char*).
-// Returns true if the value was present and parsed successfully.
-bool LogLevelStrToInt(const char* iree_env_var_val, int64_t* out_level) {
- *out_level = 0;
- if (iree_env_var_val == nullptr) {
- return false;
- }
-
- std::string min_log_level(iree_env_var_val);
- std::istringstream ss(min_log_level);
- int64_t level;
- if (!(ss >> level)) {
- // Invalid vlog level setting, set level to default (0).
- return false;
- }
-
- *out_level = level;
- return true;
-}
-
-int64_t MinLogLevelFromEnv() {
- const char* iree_env_var_val = getenv("IREE_MIN_LOG_LEVEL");
- int64_t level = 0;
- if (LogLevelStrToInt(iree_env_var_val, &level)) {
- return level;
- }
- return FLAG_iree_minloglevel;
-}
-
-int64_t MinVLogLevelFromEnv() {
- const char* iree_env_var_val = getenv("IREE_MIN_VLOG_LEVEL");
- int64_t level = 0;
- if (LogLevelStrToInt(iree_env_var_val, &level)) {
- return level;
- }
- return FLAG_iree_v;
-}
-
-} // namespace
-
-LogMessage::LogMessage(const char* file_name, int line, int severity)
- : file_name_(file_name), line_(line), severity_(severity) {}
-
-LogMessage::~LogMessage() {
- // Read the min log level once during the first call to logging.
- static int64_t min_log_level = MinLogLevelFromEnv();
- if (IREE_LIKELY(severity_ >= min_log_level)) {
- EmitLogMessage();
- }
-}
-
-int64_t LogMessage::MinVLogLevel() {
- static int64_t min_vlog_level = MinVLogLevelFromEnv();
- return min_vlog_level;
-}
-
-void LogMessage::EmitLogMessage() {
- // TODO(scotttodd): Include current system time
- fprintf(stderr, "%c %s:%d] %s\n", "IWEF"[severity_], file_name_, line_,
- str().c_str());
-
-#if defined(__ANDROID__)
- // Define equivalent android log levels to map to IREE.
- constexpr int kStatusToAndroidLevel[4] = {
- 4, // Android info
- 5, // Android waring
- 6, // Android error
- 6 // Android fatal (doesn't exist, so reusing error)
- };
-
- // NOTE: this truncates. That's fine for now and stderr is still usable.
- int android_severity = kStatusToAndroidLevel[severity_];
- {
- // NOTE: this truncates. That's fine for now and stderr is still usable.
- char str_buffer[512];
- snprintf(str_buffer, sizeof(str_buffer), "%s:%d] %s\n", file_name_, line_,
- str().c_str());
- __android_log_write(android_severity, "native", str_buffer);
- }
-#endif // !defined(__ANDROID__)
-
-#if IREE_TRACING_FEATURES & IREE_TRACING_FEATURE_LOG_MESSAGES
- constexpr int kLevelColors[4] = {
- IREE_TRACING_MESSAGE_LEVEL_INFO, // INFO
- IREE_TRACING_MESSAGE_LEVEL_WARNING, // WARNING
- IREE_TRACING_MESSAGE_LEVEL_ERROR, // ERROR
- IREE_TRACING_MESSAGE_LEVEL_ERROR, // FATAL
- };
- {
- // NOTE: this truncates. That's fine for now and stderr is still usable.
- char str_buffer[512];
- int str_length = snprintf(str_buffer, sizeof(str_buffer), "%s:%d] %s\n",
- file_name_, line_, str().c_str());
- IREE_TRACE_MESSAGE_DYNAMIC_COLORED(kLevelColors[severity_], str_buffer,
- str_length);
- }
-#endif // IREE_TRACING_FEATURES& IREE_TRACING_FEATURE_LOG_MESSAGES
-}
-
-LogMessageFatal::LogMessageFatal(const char* file, int line)
- : LogMessage(file, line, FATAL) {}
-
-LogMessageFatal::~LogMessageFatal() {
- EmitLogMessage();
-
- // abort() ensures we don't return (as promised via ATTRIBUTE_NORETURN).
- abort();
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const char& v) {
- if (v >= 32 && v <= 126) {
- (*os) << "'" << v << "'";
- } else {
- (*os) << "char value " << static_cast<int16_t>(v);
- }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const int8_t& v) {
- if (v >= 32 && v <= 126) {
- (*os) << "'" << v << "'";
- } else {
- (*os) << "signed char value " << static_cast<int16_t>(v);
- }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const uint8_t& v) {
- if (v >= 32 && v <= 126) {
- (*os) << "'" << v << "'";
- } else {
- (*os) << "unsigned char value " << static_cast<uint16_t>(v);
- }
-}
-
-template <>
-void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v) {
- (*os) << "nullptr";
-}
-
-CheckOpMessageBuilder::CheckOpMessageBuilder(const char* exprtext)
- : stream_(new std::ostringstream) {
- *stream_ << "Check failed: " << exprtext << " (";
-}
-
-CheckOpMessageBuilder::~CheckOpMessageBuilder() { delete stream_; }
-
-std::ostream* CheckOpMessageBuilder::ForVar2() {
- *stream_ << " vs. ";
- return stream_;
-}
-
-std::string* CheckOpMessageBuilder::NewString() {
- *stream_ << ")";
- return new std::string(stream_->str());
-}
-
-} // namespace internal
-} // namespace iree
diff --git a/runtime/src/iree/base/logging.h b/runtime/src/iree/base/logging.h
deleted file mode 100644
index 3051dc3..0000000
--- a/runtime/src/iree/base/logging.h
+++ /dev/null
@@ -1,374 +0,0 @@
-// Copyright 2019 The IREE Authors
-//
-// Licensed 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
-
-//===----------------------------------------------------------------------===//
-// //
-// ( ( ( ( //
-// )\ ) )\ ) )\ ) ( ( * ) )\ ) //
-// (()/( ( (()/( (()/( ( )\ )\ ` ) /( ( (()/( //
-// /(_)) )\ /(_)) /(_)) )\ (((_) ((((_)( ( )(_)) )\ /(_)) //
-// (_))_ ((_) (_)) (_)) ((_) )\___ )\ _ )\ (_(_()) ((_) (_))_ //
-// | \ | __| | _ \ | _ \ | __| ((/ __| (_)_\(_) |_ _| | __| | \ //
-// | |) | | _| | _/ | / | _| | (__ / _ \ | | | _| | |) | //
-// |___/ |___| |_| |_|_\ |___| \___| /_/ \_\ |_| |___| |___/ //
-// //
-//===----------------------------------------------------------------------===//
-// TODO(#2843): replace this file with a C sink API. IREE itself should not
-// perform any logging by default and instead route all logging through a
-// pluggable interface (similar to how we have iree_allocator_t to plug in
-// allocators). This will allow applications to scope their logging (critical
-// in multi-tenant situations where logs need to route back to clients), bring
-// their own logging libraries, and support logging on platforms we otherwise
-// cannot. The code in this file is currently C++ only and not great.
-
-#ifndef IREE_BASE_LOGGING_H_
-#define IREE_BASE_LOGGING_H_
-
-// IREE_LOG(severity) << ...;
-// Logs a message at the given severity.
-// Severity:
-// INFO Logs information text.
-// WARNING Logs a warning.
-// ERROR Logs an error.
-// FATAL Logs an error and exit(1).
-//
-// IREE_DLOG(severity) << ...;
-// Behaves like `IREE_LOG` in debug mode (i.e. `#ifndef NDEBUG`).
-// Otherwise, it compiles away and does nothing.
-//
-// IREE_VLOG(level) << ...;
-// Logs a verbose message at the given verbosity level.
-//
-// IREE_DVLOG(level) << ...;
-// Behaves like `IREE_VLOG` in debug mode (i.e. `#ifndef NDEBUG`).
-// Otherwise, it compiles away and does nothing.
-//
-// IREE_CHECK(condition) << ...;
-// Runtime asserts that the given condition is true even in release builds.
-// It's recommended that IREE_DCHECK is used instead as too many CHECKs
-// can impact performance.
-//
-// IREE_CHECK_EQ|NE|LT|GT|LE|GE(val1, val2) << ...;
-// Runtime assert the specified operation with the given values.
-//
-// IREE_DCHECK(condition) << ...;
-// Runtime asserts that the given condition is true only in non-opt builds.
-//
-// IREE_DCHECK_EQ|NE|LT|GT|LE|GE(val1, val2) << ...;
-// Runtime assert the specified operation with the given values in non-opt
-// builds.
-//
-// IREE_QCHECK(condition) << ...;
-// IREE_QCHECK_EQ|NE|LT|GT|LE|GE(val1, val2) << ...;
-// These behave like `IREE_CHECK` but do not print a full stack trace.
-// They are useful when problems are definitely unrelated to program flow,
-// e.g. when validating user input.
-
-#include <cstddef>
-#include <cstdint>
-#include <ios>
-#include <limits>
-#include <sstream>
-#include <string>
-
-#include "iree/base/attributes.h"
-
-namespace iree {
-
-// ------------------------------------------------------------------------- //
-// | IREE_LOG | //
-// ------------------------------------------------------------------------- //
-
-// Severity levels for IREE_LOG().
-const int INFO = 0;
-const int WARNING = 1;
-const int ERROR = 2;
-const int FATAL = 3;
-
-namespace internal {
-
-class LogMessage : public std::basic_ostringstream<char> {
- public:
- LogMessage(const char* file_name, int line, int severity);
- ~LogMessage();
-
- const char* file_name() const { return file_name_; }
- int line() const { return line_; }
- int severity() const { return severity_; }
-
- // Returns the minimum log level for IREE_VLOG statements.
- // E.g., if MinVLogLevel() is 2, then IREE_VLOG(2) statements will produce
- // output, but IREE_VLOG(3) will not. Defaults to 0.
- static int64_t MinVLogLevel();
-
- protected:
- void EmitLogMessage();
-
- private:
- const char* file_name_;
- int line_;
- int severity_;
-};
-
-// LogMessageFatal ensures the process exits in failure after logging a message.
-class LogMessageFatal : public LogMessage {
- public:
- LogMessageFatal(const char* file, int line) IREE_ATTRIBUTE_COLD;
- IREE_ATTRIBUTE_NORETURN ~LogMessageFatal();
-};
-
-// NullStream implements operator<< but does nothing.
-class NullStream {
- public:
- NullStream& stream() { return *this; }
-};
-template <typename T>
-inline NullStream& operator<<(NullStream& str, const T&) {
- return str;
-}
-inline NullStream& operator<<(NullStream& str,
- std::ostream& (*)(std::ostream& os)) {
- return str;
-}
-inline NullStream& operator<<(NullStream& str,
- std::ios_base& (*)(std::ios_base& os)) {
- return str;
-}
-
-#define _IREE_LOG_INFO \
- ::iree::internal::LogMessage(__FILE__, __LINE__, ::iree::INFO)
-#define _IREE_LOG_WARNING \
- ::iree::internal::LogMessage(__FILE__, __LINE__, ::iree::WARNING)
-#define _IREE_LOG_ERROR \
- ::iree::internal::LogMessage(__FILE__, __LINE__, ::iree::ERROR)
-#define _IREE_LOG_FATAL ::iree::internal::LogMessageFatal(__FILE__, __LINE__)
-
-#define IREE_LOG(severity) _IREE_LOG_##severity
-
-#ifndef NDEBUG
-#define IREE_DLOG IREE_LOG
-#else
-#define IREE_DLOG(severity) \
- switch (0) \
- default: \
- ::iree::internal::NullStream().stream()
-#endif
-
-#define IREE_VLOG_IS_ON(lvl) \
- ((lvl) <= ::iree::internal::LogMessage::MinVLogLevel())
-
-#define IREE_VLOG(lvl) \
- if (IREE_UNLIKELY(IREE_VLOG_IS_ON(lvl))) \
- ::iree::internal::LogMessage(__FILE__, __LINE__, ::iree::INFO)
-
-// `IREE_DVLOG` behaves like `IREE_VLOG` in debug mode (i.e. `#ifndef NDEBUG`).
-// Otherwise, it compiles away and does nothing.
-#ifndef NDEBUG
-#define IREE_DVLOG IREE_VLOG
-#else
-#define IREE_DVLOG(verbose_level) \
- while (false && (verbose_level) > 0) ::iree::internal::NullStream().stream()
-#endif // !NDEBUG
-
-// ------------------------------------------------------------------------- //
-// | IREE_CHECK | //
-// ------------------------------------------------------------------------- //
-
-// IREE_CHECK dies with a fatal error if condition is not true. It is *not*
-// controlled by NDEBUG, so the check will be executed regardless of
-// compilation mode. Therefore, it is safe to do things like:
-// IREE_CHECK(fp->Write(x) == 4)
-#define IREE_CHECK(condition) \
- if (IREE_UNLIKELY(!(condition))) \
- IREE_LOG(FATAL) << "Check failed: " #condition " "
-
-// Function is overloaded for integral types to allow static const
-// integrals declared in classes and not defined to be used as arguments to
-// IREE_CHECK* macros. It's not encouraged though.
-template <typename T>
-inline const T& GetReferenceableValue(const T& t) {
- return t;
-}
-inline char GetReferenceableValue(char t) { return t; }
-inline int8_t GetReferenceableValue(int8_t t) { return t; }
-inline uint8_t GetReferenceableValue(uint8_t t) { return t; }
-inline int16_t GetReferenceableValue(int16_t t) { return t; }
-inline uint16_t GetReferenceableValue(uint16_t t) { return t; }
-inline int32_t GetReferenceableValue(int32_t t) { return t; }
-inline uint32_t GetReferenceableValue(uint32_t t) { return t; }
-inline int64_t GetReferenceableValue(int64_t t) { return t; }
-inline uint64_t GetReferenceableValue(uint64_t t) { return t; }
-
-// This formats a value for a failing IREE_CHECK_XX statement. Ordinarily,
-// it uses the definition for operator<<, with a few special cases below.
-template <typename T>
-inline void MakeCheckOpValueString(std::ostream* os, const T& v) {
- (*os) << v;
-}
-
-// Overrides for char types provide readable values for unprintable
-// characters.
-template <>
-void MakeCheckOpValueString(std::ostream* os, const char& v);
-template <>
-void MakeCheckOpValueString(std::ostream* os, const int8_t& v);
-template <>
-void MakeCheckOpValueString(std::ostream* os, const uint8_t& v);
-// We need an explicit specialization for std::nullptr_t.
-template <>
-void MakeCheckOpValueString(std::ostream* os, const std::nullptr_t& v);
-
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is non-NULL.
-struct CheckOpString {
- CheckOpString(std::string* str) : str_(str) {} // NOLINT
- // No destructor: if str_ is non-NULL, we're about to IREE_LOG(FATAL),
- // so there's no point in cleaning up str_.
- operator bool() const { return IREE_UNLIKELY(str_ != NULL); }
- std::string* str_;
-};
-
-// Build the error message string. Specify no inlining for code size.
-template <typename T1, typename T2>
-std::string* MakeCheckOpString(const T1& v1, const T2& v2,
- const char* exprtext) IREE_ATTRIBUTE_NOINLINE;
-
-// A helper class for formatting "expr (V1 vs. V2)" in a IREE_CHECK_XX
-// statement. See MakeCheckOpString for sample usage.
-class CheckOpMessageBuilder {
- public:
- // Inserts "exprtext" and " (" to the stream.
- explicit CheckOpMessageBuilder(const char* exprtext);
- // Deletes "stream_".
- ~CheckOpMessageBuilder();
- // For inserting the first variable.
- std::ostream* ForVar1() { return stream_; }
- // For inserting the second variable (adds an intermediate " vs. ").
- std::ostream* ForVar2();
- // Get the result (inserts the closing ")").
- std::string* NewString();
-
- private:
- std::ostringstream* stream_;
-};
-
-template <typename T1, typename T2>
-std::string* MakeCheckOpString(const T1& v1, const T2& v2,
- const char* exprtext) {
- CheckOpMessageBuilder comb(exprtext);
- MakeCheckOpValueString(comb.ForVar1(), v1);
- MakeCheckOpValueString(comb.ForVar2(), v2);
- return comb.NewString();
-}
-
-// Helper functions for IREE_CHECK_OP macro.
-// The (int, int) specialization works around the issue that the compiler
-// will not instantiate the template version of the function on values of
-// unnamed enum type - see comment below.
-// The (size_t, int) and (int, size_t) specialization are to handle unsigned
-// comparison errors while still being thorough with the comparison.
-#define _IREE_DEFINE_CHECK_OP_IMPL(name, op) \
- template <typename T1, typename T2> \
- inline std::string* name##Impl(const T1& v1, const T2& v2, \
- const char* exprtext) { \
- if (IREE_LIKELY(v1 op v2)) \
- return NULL; \
- else \
- return ::iree::internal::MakeCheckOpString(v1, v2, exprtext); \
- } \
- inline std::string* name##Impl(int v1, int v2, const char* exprtext) { \
- return name##Impl<int, int>(v1, v2, exprtext); \
- } \
- inline std::string* name##Impl(const size_t v1, const int v2, \
- const char* exprtext) { \
- if (IREE_UNLIKELY(v2 < 0)) { \
- return ::iree::internal::MakeCheckOpString(v1, v2, exprtext); \
- } \
- const size_t uval = (size_t)((unsigned)v1); \
- return name##Impl<size_t, size_t>(uval, v2, exprtext); \
- } \
- inline std::string* name##Impl(const int v1, const size_t v2, \
- const char* exprtext) { \
- if (IREE_UNLIKELY(v2 >= std::numeric_limits<int>::max())) { \
- return ::iree::internal::MakeCheckOpString(v1, v2, exprtext); \
- } \
- const size_t uval = (size_t)((unsigned)v2); \
- return name##Impl<size_t, size_t>(v1, uval, exprtext); \
- }
-
-_IREE_DEFINE_CHECK_OP_IMPL(Check_EQ, ==)
-_IREE_DEFINE_CHECK_OP_IMPL(Check_NE, !=)
-_IREE_DEFINE_CHECK_OP_IMPL(Check_LE, <=)
-_IREE_DEFINE_CHECK_OP_IMPL(Check_LT, <)
-_IREE_DEFINE_CHECK_OP_IMPL(Check_GE, >=)
-_IREE_DEFINE_CHECK_OP_IMPL(Check_GT, >)
-#undef _IREE_DEFINE_CHECK_OP_IMPL
-
-// In optimized mode, use CheckOpString to hint to compiler that
-// the while condition is unlikely.
-#define IREE_CHECK_OP_LOG(name, op, val1, val2) \
- while (::iree::internal::CheckOpString _result = \
- ::iree::internal::name##Impl( \
- ::iree::internal::GetReferenceableValue(val1), \
- ::iree::internal::GetReferenceableValue(val2), \
- #val1 " " #op " " #val2)) \
- ::iree::internal::LogMessageFatal(__FILE__, __LINE__) << *(_result.str_)
-
-#define IREE_CHECK_OP(name, op, val1, val2) \
- IREE_CHECK_OP_LOG(name, op, val1, val2)
-
-// IREE_CHECK_EQ/NE/...
-#define IREE_CHECK_EQ(val1, val2) IREE_CHECK_OP(Check_EQ, ==, val1, val2)
-#define IREE_CHECK_NE(val1, val2) IREE_CHECK_OP(Check_NE, !=, val1, val2)
-#define IREE_CHECK_LE(val1, val2) IREE_CHECK_OP(Check_LE, <=, val1, val2)
-#define IREE_CHECK_LT(val1, val2) IREE_CHECK_OP(Check_LT, <, val1, val2)
-#define IREE_CHECK_GE(val1, val2) IREE_CHECK_OP(Check_GE, >=, val1, val2)
-#define IREE_CHECK_GT(val1, val2) IREE_CHECK_OP(Check_GT, >, val1, val2)
-
-#ifndef NDEBUG
-#define IREE_DCHECK(condition) IREE_CHECK(condition)
-#define IREE_DCHECK_EQ(val1, val2) IREE_CHECK_EQ(val1, val2)
-#define IREE_DCHECK_NE(val1, val2) IREE_CHECK_NE(val1, val2)
-#define IREE_DCHECK_LE(val1, val2) IREE_CHECK_LE(val1, val2)
-#define IREE_DCHECK_LT(val1, val2) IREE_CHECK_LT(val1, val2)
-#define IREE_DCHECK_GE(val1, val2) IREE_CHECK_GE(val1, val2)
-#define IREE_DCHECK_GT(val1, val2) IREE_CHECK_GT(val1, val2)
-
-#else
-
-#define IREE_DCHECK(condition) \
- while (false && (condition)) IREE_LOG(FATAL)
-
-// NDEBUG is defined, so IREE_DCHECK_EQ(x, y) and so on do nothing.
-// However, we still want the compiler to parse x and y, because
-// we don't want to lose potentially useful errors and warnings.
-// _IREE_DCHECK_NOP is a helper, and should not be used outside of this file.
-#define _IREE_DCHECK_NOP(x, y) \
- while (false && ((void)(x), (void)(y), 0)) IREE_LOG(FATAL)
-
-#define IREE_DCHECK_EQ(x, y) _IREE_DCHECK_NOP(x, y)
-#define IREE_DCHECK_NE(x, y) _IREE_DCHECK_NOP(x, y)
-#define IREE_DCHECK_LE(x, y) _IREE_DCHECK_NOP(x, y)
-#define IREE_DCHECK_LT(x, y) _IREE_DCHECK_NOP(x, y)
-#define IREE_DCHECK_GE(x, y) _IREE_DCHECK_NOP(x, y)
-#define IREE_DCHECK_GT(x, y) _IREE_DCHECK_NOP(x, y)
-
-#endif // !NDEBUG
-
-// These are for when you don't want a IREE_CHECK failure to print a verbose
-// stack trace. The implementation of IREE_CHECK* in this file already doesn't.
-#define IREE_QCHECK(condition) IREE_CHECK(condition)
-#define IREE_QCHECK_EQ(x, y) IREE_CHECK_EQ(x, y)
-#define IREE_QCHECK_NE(x, y) IREE_CHECK_NE(x, y)
-#define IREE_QCHECK_LE(x, y) IREE_CHECK_LE(x, y)
-#define IREE_QCHECK_LT(x, y) IREE_CHECK_LT(x, y)
-#define IREE_QCHECK_GE(x, y) IREE_CHECK_GE(x, y)
-#define IREE_QCHECK_GT(x, y) IREE_CHECK_GT(x, y)
-
-} // namespace internal
-} // namespace iree
-
-#endif // IREE_BASE_LOGGING_H_
diff --git a/runtime/src/iree/base/status_cc.cc b/runtime/src/iree/base/status_cc.cc
index edd207c..c5e6e60 100644
--- a/runtime/src/iree/base/status_cc.cc
+++ b/runtime/src/iree/base/status_cc.cc
@@ -11,7 +11,6 @@
#include <ostream>
#include "iree/base/attributes.h"
-#include "iree/base/logging.h"
namespace iree {
@@ -47,16 +46,15 @@
namespace status_impl {
void Helper::HandleInvalidStatusCtorArg(Status* status) {
- const char* kMessage =
- "An OK status is not a valid constructor argument to StatusOr<T>";
- IREE_LOG(ERROR) << kMessage;
- *status = Status(StatusCode::kInternal, kMessage);
+ fprintf(stderr,
+ "An OK status is not a valid constructor argument to StatusOr<T>\n");
abort();
}
void Helper::Crash(const Status& status) {
- IREE_LOG(FATAL) << "Attempting to fetch value instead of handling error "
- << status;
+ std::string message = status.ToString();
+ fprintf(stderr, "Attempting to fetch value instead of handling error:\n%s\n",
+ message.c_str());
abort();
}
diff --git a/runtime/src/iree/base/status_cc.h b/runtime/src/iree/base/status_cc.h
index 4795dda..3170d0c 100644
--- a/runtime/src/iree/base/status_cc.h
+++ b/runtime/src/iree/base/status_cc.h
@@ -20,7 +20,6 @@
#include "iree/base/api.h"
#include "iree/base/attributes.h"
-#include "iree/base/logging.h"
#include "iree/base/target_platform.h"
namespace iree {
diff --git a/runtime/src/iree/base/testing/BUILD b/runtime/src/iree/base/testing/BUILD
index 4f27a46..b7b651e 100644
--- a/runtime/src/iree/base/testing/BUILD
+++ b/runtime/src/iree/base/testing/BUILD
@@ -35,7 +35,6 @@
deps = [
":dynamic_library_test_library",
"//runtime/src/iree/base",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/base/internal:dynamic_library",
"//runtime/src/iree/base/internal:file_io",
"//runtime/src/iree/testing:gtest",
diff --git a/runtime/src/iree/base/testing/CMakeLists.txt b/runtime/src/iree/base/testing/CMakeLists.txt
index 2daa820..ea2b4c1 100644
--- a/runtime/src/iree/base/testing/CMakeLists.txt
+++ b/runtime/src/iree/base/testing/CMakeLists.txt
@@ -40,7 +40,6 @@
iree::base
iree::base::internal::dynamic_library
iree::base::internal::file_io
- iree::base::logging
iree::testing::gtest
iree::testing::gtest_main
)
diff --git a/runtime/src/iree/base/testing/dynamic_library_test.cc b/runtime/src/iree/base/testing/dynamic_library_test.cc
index a63338b..13db81f 100644
--- a/runtime/src/iree/base/testing/dynamic_library_test.cc
+++ b/runtime/src/iree/base/testing/dynamic_library_test.cc
@@ -15,7 +15,6 @@
#include "iree/base/api.h"
#include "iree/base/internal/file_io.h"
-#include "iree/base/logging.h"
#include "iree/base/testing/dynamic_library_test_library_embed.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
@@ -38,7 +37,10 @@
if (!test_tmpdir) {
test_tmpdir = getenv("TEMP");
}
- IREE_CHECK(test_tmpdir) << "TEST_TMPDIR/TMPDIR/TEMP not defined";
+ if (!test_tmpdir) {
+ std::cerr << "TEST_TMPDIR/TMPDIR/TEMP not defined\n";
+ exit(1);
+ }
return test_tmpdir + std::string("/iree_test_") +
std::to_string(unique_id++) + suffix;
}
diff --git a/runtime/src/iree/hal/cts/cts_test_base.h b/runtime/src/iree/hal/cts/cts_test_base.h
index faf6cb7..16792ad 100644
--- a/runtime/src/iree/hal/cts/cts_test_base.h
+++ b/runtime/src/iree/hal/cts/cts_test_base.h
@@ -48,9 +48,8 @@
iree_status_t status = TryGetDriver(driver_name, &driver);
if (iree_status_is_unavailable(status)) {
iree_status_free(status);
- IREE_LOG(WARNING) << "Skipping test as '" << driver_name
- << "' driver is unavailable";
- GTEST_SKIP();
+ GTEST_SKIP() << "Skipping test as '" << driver_name
+ << "' driver is unavailable";
return;
}
IREE_ASSERT_OK(status);
@@ -61,9 +60,8 @@
driver_, iree_allocator_system(), &device);
if (iree_status_is_unavailable(status)) {
iree_status_free(status);
- IREE_LOG(WARNING) << "Skipping test as default device for '"
- << driver_name << "' driver is unavailable";
- GTEST_SKIP();
+ GTEST_SKIP() << "Skipping test as default device for '" << driver_name
+ << "' driver is unavailable";
return;
}
IREE_ASSERT_OK(status);
diff --git a/runtime/src/iree/hal/drivers/vulkan/BUILD b/runtime/src/iree/hal/drivers/vulkan/BUILD
index a2cf679..02f473f 100644
--- a/runtime/src/iree/hal/drivers/vulkan/BUILD
+++ b/runtime/src/iree/hal/drivers/vulkan/BUILD
@@ -74,7 +74,6 @@
"//runtime/src/iree/base",
"//runtime/src/iree/base:cc",
"//runtime/src/iree/base:core_headers",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/base:tracing",
"//runtime/src/iree/base/internal",
"//runtime/src/iree/base/internal:arena",
diff --git a/runtime/src/iree/hal/drivers/vulkan/CMakeLists.txt b/runtime/src/iree/hal/drivers/vulkan/CMakeLists.txt
index 5757d05..96d59d3 100644
--- a/runtime/src/iree/hal/drivers/vulkan/CMakeLists.txt
+++ b/runtime/src/iree/hal/drivers/vulkan/CMakeLists.txt
@@ -72,7 +72,6 @@
iree::base::internal::arena
iree::base::internal::flatcc::parsing
iree::base::internal::synchronization
- iree::base::logging
iree::base::tracing
iree::hal
iree::hal::drivers::vulkan::builtin
diff --git a/runtime/src/iree/hal/drivers/vulkan/debug_reporter.cc b/runtime/src/iree/hal/drivers/vulkan/debug_reporter.cc
index e9c3493..91b7e42 100644
--- a/runtime/src/iree/hal/drivers/vulkan/debug_reporter.cc
+++ b/runtime/src/iree/hal/drivers/vulkan/debug_reporter.cc
@@ -7,9 +7,8 @@
#include "iree/hal/drivers/vulkan/debug_reporter.h"
#include <cstddef>
-#include <ostream>
+#include <cstdio>
-#include "iree/base/logging.h"
#include "iree/base/tracing.h"
#include "iree/hal/drivers/vulkan/status_util.h"
@@ -35,9 +34,9 @@
const VkDebugUtilsMessengerCallbackDataEXT* callback_data,
void* user_data) {
if (message_severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
- IREE_LOG(ERROR) << callback_data->pMessage;
+ fprintf(stderr, "[VULKAN] ! %s\n", callback_data->pMessage);
} else {
- IREE_VLOG(1) << callback_data->pMessage;
+ fprintf(stderr, "[VULKAN] w %s\n", callback_data->pMessage);
}
return VK_FALSE; // VK_TRUE is reserved for future use.
}
diff --git a/runtime/src/iree/hal/drivers/vulkan/descriptor_pool_cache.cc b/runtime/src/iree/hal/drivers/vulkan/descriptor_pool_cache.cc
index ebe1c8c..63cdff4 100644
--- a/runtime/src/iree/hal/drivers/vulkan/descriptor_pool_cache.cc
+++ b/runtime/src/iree/hal/drivers/vulkan/descriptor_pool_cache.cc
@@ -10,7 +10,6 @@
#include <cstdint>
#include <ostream>
-#include "iree/base/logging.h"
#include "iree/base/tracing.h"
#include "iree/hal/drivers/vulkan/status_util.h"
@@ -27,8 +26,8 @@
} // namespace
DescriptorSetGroup::~DescriptorSetGroup() {
- IREE_CHECK(descriptor_pools_.empty())
- << "DescriptorSetGroup must be reset explicitly";
+ IREE_ASSERT_TRUE(descriptor_pools_.empty(),
+ "DescriptorSetGroup must be reset explicitly");
}
iree_status_t DescriptorSetGroup::Reset() {
diff --git a/runtime/src/iree/hal/drivers/vulkan/direct_command_buffer.cc b/runtime/src/iree/hal/drivers/vulkan/direct_command_buffer.cc
index 6a52750..69bf823 100644
--- a/runtime/src/iree/hal/drivers/vulkan/direct_command_buffer.cc
+++ b/runtime/src/iree/hal/drivers/vulkan/direct_command_buffer.cc
@@ -12,7 +12,6 @@
#include "iree/base/api.h"
#include "iree/base/internal/inline_array.h"
#include "iree/base/internal/math.h"
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/base/tracing.h"
#include "iree/hal/drivers/vulkan/descriptor_set_arena.h"
diff --git a/runtime/src/iree/hal/drivers/vulkan/internal_vk_mem_alloc.cc b/runtime/src/iree/hal/drivers/vulkan/internal_vk_mem_alloc.cc
index 9e5e234..5128b3e 100644
--- a/runtime/src/iree/hal/drivers/vulkan/internal_vk_mem_alloc.cc
+++ b/runtime/src/iree/hal/drivers/vulkan/internal_vk_mem_alloc.cc
@@ -9,11 +9,11 @@
#include <ostream>
+#include "iree/base/api.h"
#include "iree/base/internal/synchronization.h"
-#include "iree/base/logging.h"
-#define VMA_ASSERT IREE_DCHECK
-#define VMA_HEAVY_ASSERT IREE_DCHECK
+#define VMA_ASSERT IREE_ASSERT
+#define VMA_HEAVY_ASSERT IREE_ASSERT
// NOTE: logging is disabled by default as unless you are debugging VMA itself
// the information is not useful and just slows things down.
diff --git a/runtime/src/iree/hal/drivers/vulkan/util/BUILD b/runtime/src/iree/hal/drivers/vulkan/util/BUILD
index a5caace..619196d 100644
--- a/runtime/src/iree/hal/drivers/vulkan/util/BUILD
+++ b/runtime/src/iree/hal/drivers/vulkan/util/BUILD
@@ -18,7 +18,6 @@
hdrs = ["arena.h"],
deps = [
"//runtime/src/iree/base:core_headers",
- "//runtime/src/iree/base:logging",
],
)
@@ -39,7 +38,7 @@
"intrusive_list_unique_ptr.inc",
],
deps = [
- "//runtime/src/iree/base:logging",
+ "//runtime/src/iree/base",
],
)
@@ -60,8 +59,7 @@
name = "ref_ptr",
hdrs = ["ref_ptr.h"],
deps = [
- "//runtime/src/iree/base:core_headers",
- "//runtime/src/iree/base:logging",
+ "//runtime/src/iree/base",
"//runtime/src/iree/base/internal",
],
)
diff --git a/runtime/src/iree/hal/drivers/vulkan/util/CMakeLists.txt b/runtime/src/iree/hal/drivers/vulkan/util/CMakeLists.txt
index e78002f..22e70c3 100644
--- a/runtime/src/iree/hal/drivers/vulkan/util/CMakeLists.txt
+++ b/runtime/src/iree/hal/drivers/vulkan/util/CMakeLists.txt
@@ -19,7 +19,6 @@
"arena.cc"
DEPS
iree::base::core_headers
- iree::base::logging
PUBLIC
)
@@ -41,7 +40,7 @@
"intrusive_list.h"
"intrusive_list_unique_ptr.inc"
DEPS
- iree::base::logging
+ iree::base
PUBLIC
)
@@ -63,9 +62,8 @@
HDRS
"ref_ptr.h"
DEPS
- iree::base::core_headers
+ iree::base
iree::base::internal
- iree::base::logging
PUBLIC
)
diff --git a/runtime/src/iree/hal/drivers/vulkan/util/arena.cc b/runtime/src/iree/hal/drivers/vulkan/util/arena.cc
index fa2ed0b..12fce2a 100644
--- a/runtime/src/iree/hal/drivers/vulkan/util/arena.cc
+++ b/runtime/src/iree/hal/drivers/vulkan/util/arena.cc
@@ -9,7 +9,6 @@
#include <cstdlib>
#include "iree/base/attributes.h"
-#include "iree/base/logging.h"
namespace iree {
@@ -78,7 +77,7 @@
// This allocation is larger than an entire block. That's bad.
// We could allocate this with malloc (and then keep track of those to free
// things), but for now let's just die.
- IREE_CHECK(false);
+ abort();
return nullptr;
}
diff --git a/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list.h b/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list.h
index afe7cb0..50825e8 100644
--- a/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list.h
+++ b/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list.h
@@ -50,7 +50,7 @@
#include <limits>
#include <utility>
-#include "iree/base/logging.h"
+#include "iree/base/assert.h"
namespace iree {
@@ -382,16 +382,16 @@
while (link) {
++actual_count;
if (!link->prev) {
- IREE_DCHECK_EQ(link, head_);
+ IREE_ASSERT_EQ(link, head_);
}
if (!link->next) {
- IREE_DCHECK_EQ(link, tail_);
+ IREE_ASSERT_EQ(link, tail_);
}
- IREE_DCHECK_EQ(link->prev, previous);
+ IREE_ASSERT_EQ(link->prev, previous);
previous = link;
link = link->next;
}
- IREE_DCHECK_EQ(actual_count, count_);
+ IREE_ASSERT_EQ(actual_count, count_);
#endif // IREE_PARANOID_INTRUSIVE_LIST
}
@@ -481,10 +481,10 @@
size_t kOffset>
void IntrusiveListBase<T, IteratorT, ReverseIteratorT, kOffset>::push_front(
T* value) {
- IREE_DCHECK(value);
+ IREE_ASSERT(value);
auto* link = impl::TToLink<T, kOffset>(value);
- IREE_DCHECK(!link->next);
- IREE_DCHECK(!link->prev);
+ IREE_ASSERT(!link->next);
+ IREE_ASSERT(!link->prev);
link->next = head_;
link->prev = nullptr;
head_ = link;
@@ -502,7 +502,7 @@
template <typename T, typename IteratorT, typename ReverseIteratorT,
size_t kOffset>
void IntrusiveListBase<T, IteratorT, ReverseIteratorT, kOffset>::pop_front() {
- IREE_DCHECK(head_);
+ IREE_ASSERT(head_);
auto* link = head_;
if (link) {
head_ = head_->next;
@@ -530,10 +530,10 @@
size_t kOffset>
void IntrusiveListBase<T, IteratorT, ReverseIteratorT, kOffset>::push_back(
T* value) {
- IREE_DCHECK(value);
+ IREE_ASSERT(value);
auto* link = impl::TToLink<T, kOffset>(value);
- IREE_DCHECK(!link->next);
- IREE_DCHECK(!link->prev);
+ IREE_ASSERT(!link->next);
+ IREE_ASSERT(!link->prev);
link->prev = tail_;
link->next = nullptr;
tail_ = link;
@@ -551,7 +551,7 @@
template <typename T, typename IteratorT, typename ReverseIteratorT,
size_t kOffset>
void IntrusiveListBase<T, IteratorT, ReverseIteratorT, kOffset>::pop_back() {
- IREE_DCHECK(tail_);
+ IREE_ASSERT(tail_);
auto* link = tail_;
if (link) {
tail_ = tail_->prev;
@@ -572,11 +572,11 @@
size_t kOffset>
void IntrusiveListBase<T, IteratorT, ReverseIteratorT, kOffset>::insert(
T* position, T* value) {
- IREE_DCHECK(value);
+ IREE_ASSERT(value);
auto* link = impl::TToLink<T, kOffset>(value);
auto* position_link = impl::TToLink<T, kOffset>(position);
- IREE_DCHECK(!link->next);
- IREE_DCHECK(!link->prev);
+ IREE_ASSERT(!link->next);
+ IREE_ASSERT(!link->prev);
if (position_link == head_) {
push_front(value);
@@ -601,17 +601,17 @@
}
auto* link = impl::TToLink<T, kOffset>(value);
if (link->prev) {
- IREE_DCHECK_NE(link, head_);
+ IREE_ASSERT_NE(link, head_);
link->prev->next = link->next;
} else {
- IREE_DCHECK_EQ(link, head_);
+ IREE_ASSERT_EQ(link, head_);
head_ = link->next;
}
if (link->next) {
- IREE_DCHECK_NE(link, tail_);
+ IREE_ASSERT_NE(link, tail_);
link->next->prev = link->prev;
} else {
- IREE_DCHECK_EQ(link, tail_);
+ IREE_ASSERT_EQ(link, tail_);
tail_ = link->prev;
}
auto* next = link->next;
@@ -640,9 +640,9 @@
size_t kOffset>
void IntrusiveListBase<T, IteratorT, ReverseIteratorT, kOffset>::replace(
T* old_value, T* new_value) {
- IREE_DCHECK(old_value);
- IREE_DCHECK(new_value);
- IREE_DCHECK_NE(old_value, new_value);
+ IREE_ASSERT(old_value);
+ IREE_ASSERT(new_value);
+ IREE_ASSERT_NE(old_value, new_value);
auto* old_link = impl::TToLink<T, kOffset>(old_value);
auto* new_link = impl::TToLink<T, kOffset>(new_value);
new_link->next = old_link->next;
diff --git a/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list_unique_ptr.inc b/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list_unique_ptr.inc
index 882a4fc..3a44702 100644
--- a/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list_unique_ptr.inc
+++ b/runtime/src/iree/hal/drivers/vulkan/util/intrusive_list_unique_ptr.inc
@@ -12,7 +12,7 @@
#include <cstddef>
#include <memory>
-#include "iree/base/logging.h"
+#include "iree/base/assert.h"
#include "iree/hal/drivers/vulkan/util/intrusive_list.h"
namespace iree {
@@ -90,17 +90,17 @@
}
auto* link = impl::TToLink<T, kOffset>(value);
if (link->prev) {
- IREE_DCHECK_NE(link, head_);
+ IREE_ASSERT_NE(link, head_);
link->prev->next = link->next;
} else {
- IREE_DCHECK_EQ(link, head_);
+ IREE_ASSERT_EQ(link, head_);
head_ = link->next;
}
if (link->next) {
- IREE_DCHECK_NE(link, tail_);
+ IREE_ASSERT_NE(link, tail_);
link->next->prev = link->prev;
} else {
- IREE_DCHECK_EQ(link, tail_);
+ IREE_ASSERT_EQ(link, tail_);
tail_ = link->prev;
}
link->next = link->prev = nullptr;
diff --git a/runtime/src/iree/hal/drivers/vulkan/util/ref_ptr.h b/runtime/src/iree/hal/drivers/vulkan/util/ref_ptr.h
index 32acc86..dbf34b3 100644
--- a/runtime/src/iree/hal/drivers/vulkan/util/ref_ptr.h
+++ b/runtime/src/iree/hal/drivers/vulkan/util/ref_ptr.h
@@ -10,15 +10,17 @@
#include <atomic>
#include <cstddef>
#include <cstdint>
+#include <cstdio>
#include <type_traits>
+#include <typeinfo>
#include <utility>
#include "iree/base/attributes.h"
-#include "iree/base/logging.h"
namespace iree {
-// Use this to get really verbose refptr logging:
+// Use this to get really verbose refptr logging (at the point you need this:
+// I'm sorry):
// #define IREE_VERBOSE_REF_PTR
template <class T>
@@ -247,9 +249,8 @@
auto ref_obj = static_cast<RefObject<V>*>(p);
int previous_count = ref_obj->counter_.fetch_sub(1);
#ifdef IREE_VERBOSE_REF_PTR
- IREE_LOG(INFO) << "ro-- " << typeid(V).name() << " " << p << " now "
- << previous_count - 1
- << (previous_count == 1 ? " DEAD (CUSTOM)" : "");
+ fprintf(stdout, "ro-- %s %p now %d%s", typeid(V).name(), p,
+ previous_count - 1, previous_count == 1 ? " DEAD (CUSTOM)" : "");
#endif // IREE_VERBOSE_REF_PTR
if (previous_count == 1) {
// We delete type T pointer here to avoid the need for a virtual dtor.
@@ -265,9 +266,8 @@
auto ref_obj = static_cast<RefObject<V>*>(p);
int previous_count = ref_obj->counter_.fetch_sub(1);
#ifdef IREE_VERBOSE_REF_PTR
- IREE_LOG(INFO) << "ro-- " << typeid(V).name() << " " << p << " now "
- << previous_count - 1
- << (previous_count == 1 ? " DEAD" : "");
+ fprintf(stdout, "ro-- %s %p now %d%s", typeid(V).name(), p,
+ previous_count - 1, previous_count == 1 ? " DEAD" : "");
#endif // IREE_VERBOSE_REF_PTR
if (previous_count == 1) {
// We delete type T pointer here to avoid the need for a virtual dtor.
@@ -284,8 +284,8 @@
++ref_obj->counter_;
#ifdef IREE_VERBOSE_REF_PTR
- IREE_LOG(INFO) << "ro++ " << typeid(T).name() << " " << p << " now "
- << ref_obj->counter_;
+ fprintf(stdout, "ro++ %s %p now %d", typeid(T).name(), p,
+ ref_obj->counter_.load());
#endif // IREE_VERBOSE_REF_PTR
}
diff --git a/runtime/src/iree/modules/check/check_test.cc b/runtime/src/iree/modules/check/check_test.cc
index 4c4d97d..c925057 100644
--- a/runtime/src/iree/modules/check/check_test.cc
+++ b/runtime/src/iree/modules/check/check_test.cc
@@ -38,8 +38,7 @@
iree_make_cstring_view("local-task"), iree_allocator_system(),
&hal_driver);
if (iree_status_is_not_found(status)) {
- IREE_LOG(WARNING)
- << "Skipping tests as 'local-task' driver was not found:";
+ fprintf(stderr, "Skipping test as 'local-task' driver was not found:\n");
iree_status_fprint(stderr, status);
iree_status_free(status);
return;
diff --git a/runtime/src/iree/tooling/BUILD b/runtime/src/iree/tooling/BUILD
index 75811a2..4cd8f04 100644
--- a/runtime/src/iree/tooling/BUILD
+++ b/runtime/src/iree/tooling/BUILD
@@ -69,7 +69,6 @@
":numpy_io",
"//runtime/src/iree/base",
"//runtime/src/iree/base:cc",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/base:tracing",
"//runtime/src/iree/base/internal:span",
"//runtime/src/iree/hal",
diff --git a/runtime/src/iree/tooling/CMakeLists.txt b/runtime/src/iree/tooling/CMakeLists.txt
index 58af43c..f787b8d 100644
--- a/runtime/src/iree/tooling/CMakeLists.txt
+++ b/runtime/src/iree/tooling/CMakeLists.txt
@@ -80,7 +80,6 @@
iree::base
iree::base::cc
iree::base::internal::span
- iree::base::logging
iree::base::tracing
iree::hal
iree::modules::hal
diff --git a/runtime/src/iree/tooling/numpy_io_test.cc b/runtime/src/iree/tooling/numpy_io_test.cc
index ad1634d..2d00e33 100644
--- a/runtime/src/iree/tooling/numpy_io_test.cc
+++ b/runtime/src/iree/tooling/numpy_io_test.cc
@@ -26,8 +26,7 @@
iree_hal_available_driver_registry(), IREE_SV("local-sync"),
iree_allocator_system(), &device_);
if (iree_status_is_not_found(status)) {
- IREE_LOG(WARNING)
- << "Skipping test as 'local-sync' driver was not found:";
+ fprintf(stderr, "Skipping test as 'local-sync' driver was not found:\n");
iree_status_fprint(stderr, status);
iree_status_free(status);
GTEST_SKIP();
@@ -46,7 +45,10 @@
if (!test_tmpdir) {
test_tmpdir = getenv("TEMP");
}
- IREE_CHECK(test_tmpdir) << "TEST_TMPDIR/TMPDIR/TEMP not defined";
+ if (!test_tmpdir) {
+ std::cerr << "TEST_TMPDIR/TMPDIR/TEMP not defined\n";
+ exit(1);
+ }
return test_tmpdir + std::string("/iree_test_") +
std::to_string(unique_id++) + '_' + suffix;
}
diff --git a/runtime/src/iree/tooling/vm_util.cc b/runtime/src/iree/tooling/vm_util.cc
index 05f7376..909f578 100644
--- a/runtime/src/iree/tooling/vm_util.cc
+++ b/runtime/src/iree/tooling/vm_util.cc
@@ -14,7 +14,6 @@
#include <vector>
#include "iree/base/api.h"
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/base/tracing.h"
#include "iree/hal/api.h"
diff --git a/runtime/src/iree/tooling/vm_util_test.cc b/runtime/src/iree/tooling/vm_util_test.cc
index deacde3..e588e9c 100644
--- a/runtime/src/iree/tooling/vm_util_test.cc
+++ b/runtime/src/iree/tooling/vm_util_test.cc
@@ -26,8 +26,7 @@
iree_hal_available_driver_registry(), IREE_SV("local-sync"),
iree_allocator_system(), &device_);
if (iree_status_is_not_found(status)) {
- IREE_LOG(WARNING)
- << "Skipping test as 'local-sync' driver was not found:";
+ fprintf(stderr, "Skipping test as 'local-sync' driver was not found:\n");
iree_status_fprint(stderr, status);
iree_status_free(status);
GTEST_SKIP();
diff --git a/runtime/src/iree/vm/BUILD b/runtime/src/iree/vm/BUILD
index 2615571..606db40 100644
--- a/runtime/src/iree/vm/BUILD
+++ b/runtime/src/iree/vm/BUILD
@@ -145,7 +145,6 @@
":impl",
":native_module_test_hdrs",
"//runtime/src/iree/base",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/testing:benchmark_main",
"@com_google_benchmark//:benchmark",
],
@@ -241,7 +240,6 @@
":bytecode_module",
":vm",
"//runtime/src/iree/base:cc",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/testing:gtest",
"//runtime/src/iree/testing:gtest_main",
"//runtime/src/iree/vm/test:all_bytecode_modules_c",
@@ -258,7 +256,6 @@
":bytecode_module_benchmark_module_c",
":vm",
"//runtime/src/iree/base",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/testing:benchmark_main",
"@com_google_benchmark//:benchmark",
],
diff --git a/runtime/src/iree/vm/CMakeLists.txt b/runtime/src/iree/vm/CMakeLists.txt
index 50afe3d..e5872fc 100644
--- a/runtime/src/iree/vm/CMakeLists.txt
+++ b/runtime/src/iree/vm/CMakeLists.txt
@@ -136,7 +136,6 @@
::native_module_test_hdrs
benchmark
iree::base
- iree::base::logging
iree::testing::benchmark_main
TESTONLY
)
@@ -204,7 +203,6 @@
::bytecode_module
::vm
iree::base::cc
- iree::base::logging
iree::testing::gtest
iree::testing::gtest_main
iree::vm::test::all_bytecode_modules_c
@@ -222,7 +220,6 @@
::vm
benchmark
iree::base
- iree::base::logging
iree::testing::benchmark_main
TESTONLY
)
diff --git a/runtime/src/iree/vm/bytecode_dispatch_async_test.cc b/runtime/src/iree/vm/bytecode_dispatch_async_test.cc
index 3baab60..775a268 100644
--- a/runtime/src/iree/vm/bytecode_dispatch_async_test.cc
+++ b/runtime/src/iree/vm/bytecode_dispatch_async_test.cc
@@ -10,7 +10,6 @@
// avoid defining the IR inline here so that we can run this test on platforms
// that we can't run the full MLIR compiler stack on.
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/testing/gtest.h"
#include "iree/testing/status_matchers.h"
diff --git a/runtime/src/iree/vm/bytecode_dispatch_test.cc b/runtime/src/iree/vm/bytecode_dispatch_test.cc
index b2d827a..09ffc99 100644
--- a/runtime/src/iree/vm/bytecode_dispatch_test.cc
+++ b/runtime/src/iree/vm/bytecode_dispatch_test.cc
@@ -10,7 +10,6 @@
// avoid defining the IR inline here so that we can run this test on platforms
// that we can't run the full MLIR compiler stack on.
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/testing/gtest.h"
#include "iree/vm/api.h"
diff --git a/runtime/src/iree/vm/bytecode_module_benchmark.cc b/runtime/src/iree/vm/bytecode_module_benchmark.cc
index 00dd7ec..a604963 100644
--- a/runtime/src/iree/vm/bytecode_module_benchmark.cc
+++ b/runtime/src/iree/vm/bytecode_module_benchmark.cc
@@ -9,7 +9,6 @@
#include "benchmark/benchmark.h"
#include "iree/base/api.h"
-#include "iree/base/logging.h"
#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"
#include "iree/vm/bytecode_module_benchmark_module_c.h"
diff --git a/runtime/src/iree/vm/native_module.c b/runtime/src/iree/vm/native_module.c
index 8553435..a3dde14 100644
--- a/runtime/src/iree/vm/native_module.c
+++ b/runtime/src/iree/vm/native_module.c
@@ -257,8 +257,7 @@
return;
}
// No-op in the default implementation.
- // TODO(#2843): IREE_DCHECK_EQ(NULL, module_state);
- assert(!module_state);
+ IREE_ASSERT_EQ(module_state, NULL);
}
static iree_status_t IREE_API_PTR iree_vm_native_module_resolve_import(
diff --git a/runtime/src/iree/vm/native_module_benchmark.cc b/runtime/src/iree/vm/native_module_benchmark.cc
index 14da29b..91a0b02 100644
--- a/runtime/src/iree/vm/native_module_benchmark.cc
+++ b/runtime/src/iree/vm/native_module_benchmark.cc
@@ -6,7 +6,6 @@
#include "benchmark/benchmark.h"
#include "iree/base/api.h"
-#include "iree/base/logging.h"
#include "iree/vm/module.h"
#include "iree/vm/native_module.h"
#include "iree/vm/native_module_test.h"
diff --git a/runtime/src/iree/vm/test/emitc/BUILD b/runtime/src/iree/vm/test/emitc/BUILD
index 03abc98..8328331 100644
--- a/runtime/src/iree/vm/test/emitc/BUILD
+++ b/runtime/src/iree/vm/test/emitc/BUILD
@@ -41,7 +41,6 @@
":shift_ops",
":shift_ops_i64",
"//runtime/src/iree/base:cc",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/testing:gtest",
"//runtime/src/iree/testing:gtest_main",
"//runtime/src/iree/vm",
diff --git a/runtime/src/iree/vm/test/emitc/CMakeLists.txt b/runtime/src/iree/vm/test/emitc/CMakeLists.txt
index 098c4c0..c0f3031 100644
--- a/runtime/src/iree/vm/test/emitc/CMakeLists.txt
+++ b/runtime/src/iree/vm/test/emitc/CMakeLists.txt
@@ -15,7 +15,6 @@
"module_test.cc"
DEPS
iree::base::cc
- iree::base::logging
iree::testing::gtest
iree::testing::gtest_main
iree::vm
diff --git a/runtime/src/iree/vm/test/emitc/module_test.cc b/runtime/src/iree/vm/test/emitc/module_test.cc
index 83bf628..0ce5c89 100644
--- a/runtime/src/iree/vm/test/emitc/module_test.cc
+++ b/runtime/src/iree/vm/test/emitc/module_test.cc
@@ -11,7 +11,6 @@
#include <cmath>
using namespace std;
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/testing/gtest.h"
#include "iree/vm/api.h"
diff --git a/tools/BUILD b/tools/BUILD
index 8111216..0cc77e0 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -69,7 +69,6 @@
"//runtime/src/iree/base",
"//runtime/src/iree/base:cc",
"//runtime/src/iree/base:core_headers",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/base:tracing",
"//runtime/src/iree/base/internal:file_io",
"//runtime/src/iree/base/internal:flags",
@@ -134,7 +133,6 @@
"//compiler/src/iree/compiler/Tools:init_targets",
"//runtime/src/iree/base",
"//runtime/src/iree/base:cc",
- "//runtime/src/iree/base:logging",
"//runtime/src/iree/base:tracing",
"//runtime/src/iree/base/internal:flags",
"//runtime/src/iree/hal",
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 34a7de8..15cf5b1 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -92,7 +92,6 @@
iree::base::core_headers
iree::base::internal::file_io
iree::base::internal::flags
- iree::base::logging
iree::base::tracing
iree::hal
iree::modules::check
@@ -253,7 +252,6 @@
iree::base
iree::base::cc
iree::base::internal::flags
- iree::base::logging
iree::base::tracing
iree::compiler::Dialect::HAL::Target
iree::compiler::Dialect::VM::Target::Bytecode
diff --git a/tools/android/run_module_app/src/main.cc b/tools/android/run_module_app/src/main.cc
index 16a6198..703b339 100644
--- a/tools/android/run_module_app/src/main.cc
+++ b/tools/android/run_module_app/src/main.cc
@@ -9,6 +9,7 @@
#include <array>
#include <chrono>
+#include <sstream>
#include <string>
#include <thread>
diff --git a/tools/iree-check-module-main.cc b/tools/iree-check-module-main.cc
index 566fef2..4dda0fb 100644
--- a/tools/iree-check-module-main.cc
+++ b/tools/iree-check-module-main.cc
@@ -15,7 +15,6 @@
#include "iree/base/api.h"
#include "iree/base/internal/file_io.h"
#include "iree/base/internal/flags.h"
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/base/target_platform.h"
#include "iree/base/tracing.h"
@@ -185,7 +184,7 @@
IREE_FORCE_BINARY_STDIN();
if (argc < 2) {
- IREE_LOG(ERROR)
+ std::cerr
<< "A binary module file path to run (or - for stdin) must be passed";
return -1;
}
diff --git a/tools/iree-run-mlir-main.cc b/tools/iree-run-mlir-main.cc
index e2c0d06..2e6a713 100644
--- a/tools/iree-run-mlir-main.cc
+++ b/tools/iree-run-mlir-main.cc
@@ -40,7 +40,6 @@
#include "iree/base/api.h"
#include "iree/base/internal/flags.h"
-#include "iree/base/logging.h"
#include "iree/base/status_cc.h"
#include "iree/base/tracing.h"
#include "iree/compiler/Dialect/HAL/Target/TargetBackend.h"
@@ -213,8 +212,7 @@
}
// Translate from MLIR to IREE bytecode.
- IREE_LOG(INFO) << "Compiling for target backend '" << target_backend
- << "'...";
+ std::cout << "Compiling for target backend '" << target_backend << "'...";
mlir::PassManager pass_manager(mlir_module->getContext());
pass_manager.enableVerifier(verify_passes_flag);
mlir::applyPassManagerCLOptions(pass_manager);
@@ -343,9 +341,9 @@
device_uri = device_uris[0];
}
- IREE_LOG(INFO) << "Evaluating all functions in module for driver '"
- << driver_name << "' using device '"
- << std::string(device_uri.data, device_uri.size) << "'...";
+ std::cout << "Evaluating all functions in module for driver '" << driver_name
+ << "' using device '"
+ << std::string(device_uri.data, device_uri.size) << "'...";
// Load the bytecode module from the flatbuffer data.
// We do this first so that if we fail validation we know prior to dealing
@@ -506,8 +504,8 @@
llvm::Twine(split_line));
auto sub_failure = EvaluateFile(std::move(sub_buffer), registry);
if (!sub_failure.ok()) {
- IREE_LOG(ERROR) << "Failure for split at line #" << split_line << ": "
- << sub_failure;
+ std::cerr << "Failure for split at line #" << split_line << ": "
+ << sub_failure;
if (any_failure.ok()) {
any_failure = std::move(sub_failure);
}