Util.h File Reference
#include <cassert>
#include <cstdint>
#include <cstring>
#include <functional>
#include <limits>
#include <string>
#include <utility>
#include <vector>
#include "runtime/HalideRuntime.h"

Go to the source code of this file.


struct  Halide::Internal::meta_and< T >
struct  Halide::Internal::meta_and< T1, Args... >
struct  Halide::Internal::meta_or< T >
struct  Halide::Internal::meta_or< T1, Args... >
struct  Halide::Internal::all_are_convertible< To, Args >
struct  Halide::Internal::FileStat
class  Halide::Internal::TemporaryFile
 A simple utility class that creates a temporary file in its ctor and deletes that file in its dtor; this is useful for temporary files that you want to ensure are deleted when exiting a certain scope. More...
struct  Halide::Internal::ScopedValue< T >
 Helper class for saving/restoring variable values on the stack, to allow for early-exit that preserves correctness. More...
struct  Halide::Internal::StaticCast< TO >
struct  Halide::Internal::IsRoundtrippable< TO >


 This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.


#define HALIDE_EXPORT   __attribute__((visibility("default")))
#define HALIDE_TIC   Halide::Internal::halide_tic_impl(__FILE__, __LINE__)
#define HALIDE_TOC   Halide::Internal::halide_toc_impl(__FILE__, __LINE__)


void Halide::load_plugin (const std::string &lib_name)
 Load a plugin in the form of a dynamic library (e.g. More...
template<typename DST , typename SRC , typename std::enable_if< std::is_floating_point< SRC >::value >::type * = nullptr>
DST Halide::Internal::safe_numeric_cast (SRC s)
 Some numeric conversions are UB if the value won't fit in the result; safe_numeric_cast<>() is meant as a drop-in replacement for a C/C++ cast that adds well-defined behavior for the UB cases, attempting to mimic common implementation behavior as much as possible. More...
template<typename DstType , typename SrcType >
DstType Halide::Internal::reinterpret_bits (const SrcType &src)
 An aggressive form of reinterpret cast used for correct type-punning. More...
std::string Halide::Internal::make_entity_name (void *stack_ptr, const std::string &type, char prefix)
 Make a unique name for an object based on the name of the stack variable passed in. More...
std::string Halide::Internal::get_env_variable (char const *env_var_name)
 Get value of an environment variable. More...
std::string Halide::Internal::running_program_name ()
 Get the name of the currently running executable. More...
std::string Halide::Internal::unique_name (char prefix)
 Generate a unique name starting with the given prefix. More...
std::string Halide::Internal::unique_name (const std::string &prefix)
bool Halide::Internal::starts_with (const std::string &str, const std::string &prefix)
 Test if the first string starts with the second string. More...
bool Halide::Internal::ends_with (const std::string &str, const std::string &suffix)
 Test if the first string ends with the second string. More...
std::string Halide::Internal::replace_all (const std::string &str, const std::string &find, const std::string &replace)
 Replace all matches of the second string in the first string with the last string. More...
std::vector< std::string > Halide::Internal::split_string (const std::string &source, const std::string &delim)
 Split the source string using 'delim' as the divider. More...
template<typename T , typename Fn >
Halide::Internal::fold_left (const std::vector< T > &vec, Fn f)
 Perform a left fold of a vector. More...
template<typename T , typename Fn >
Halide::Internal::fold_right (const std::vector< T > &vec, Fn f)
 Returns a right fold of a vector. More...
std::string Halide::Internal::extract_namespaces (const std::string &name, std::vector< std::string > &namespaces)
 Returns base name and fills in namespaces, outermost one first in vector. More...
std::string Halide::Internal::strip_namespaces (const std::string &name)
 Like extract_namespaces(), but strip and discard the namespaces, returning base name only. More...
std::string Halide::Internal::file_make_temp (const std::string &prefix, const std::string &suffix)
 Create a unique file with a name of the form prefixXXXXXsuffix in an arbitrary (but writable) directory; this is typically /tmp, but the specific location is not guaranteed. More...
std::string Halide::Internal::dir_make_temp ()
 Create a unique directory in an arbitrary (but writable) directory; this is typically somewhere inside /tmp, but the specific location is not guaranteed. More...
bool Halide::Internal::file_exists (const std::string &name)
 Wrapper for access(). More...
void Halide::Internal::assert_file_exists (const std::string &name)
 assert-fail if the file doesn't exist. More...
void Halide::Internal::assert_no_file_exists (const std::string &name)
 assert-fail if the file DOES exist. More...
void Halide::Internal::file_unlink (const std::string &name)
 Wrapper for unlink(). More...
void Halide::Internal::ensure_no_file_exists (const std::string &name)
 Ensure that no file with this path exists. More...
void Halide::Internal::dir_rmdir (const std::string &name)
 Wrapper for rmdir(). More...
FileStat Halide::Internal::file_stat (const std::string &name)
 Wrapper for stat(). More...
std::vector< char > Halide::Internal::read_entire_file (const std::string &pathname)
 Read the entire contents of a file into a vector<char>. More...
void Halide::Internal::write_entire_file (const std::string &pathname, const void *source, size_t source_len)
 Create or replace the contents of a file with a given pointer-and-length of memory. More...
void Halide::Internal::write_entire_file (const std::string &pathname, const std::vector< char > &source)
bool Halide::Internal::add_would_overflow (int bits, int64_t a, int64_t b)
 Routines to test if math would overflow for signed integers with the given number of bits. More...
bool Halide::Internal::sub_would_overflow (int bits, int64_t a, int64_t b)
bool Halide::Internal::mul_would_overflow (int bits, int64_t a, int64_t b)
HALIDE_MUST_USE_RESULT bool Halide::Internal::add_with_overflow (int bits, int64_t a, int64_t b, int64_t *result)
 Routines to perform arithmetic on signed types without triggering signed overflow. More...
HALIDE_MUST_USE_RESULT bool Halide::Internal::sub_with_overflow (int bits, int64_t a, int64_t b, int64_t *result)
HALIDE_MUST_USE_RESULT bool Halide::Internal::mul_with_overflow (int bits, int64_t a, int64_t b, int64_t *result)
void Halide::Internal::halide_tic_impl (const char *file, int line)
void Halide::Internal::halide_toc_impl (const char *file, int line)
std::string Halide::Internal::c_print_name (const std::string &name, bool prefix_underscore=true)
 Emit a version of a string that is a valid identifier in C (. More...
int Halide::Internal::get_llvm_version ()
 Return the LLVM_VERSION against which this libHalide is compiled. More...
void Halide::set_compiler_stack_size (size_t)
 Set how much stack the compiler should use for compilation in bytes. More...
size_t Halide::get_compiler_stack_size ()
 Return how much stack size the compiler should use for calls that go through run_with_large_stack below. More...
void Halide::Internal::run_with_large_stack (const std::function< void()> &action)
 Call the given action in a platform-specific context that provides at least the stack space returned by get_compiler_stack_size. More...
int Halide::Internal::popcount64 (uint64_t x)
 Portable versions of popcount, count-leading-zeros, and count-trailing-zeros. More...
int Halide::Internal::clz64 (uint64_t x)
int Halide::Internal::ctz64 (uint64_t x)


constexpr size_t Halide::default_compiler_stack_size = 32 * 1024 * 1024
 The default amount of stack used for lowering and codegen. More...

Detailed Description

Various utility functions used internally Halide.

Definition in file Util.h.

Macro Definition Documentation


#define HALIDE_EXPORT   __attribute__((visibility("default")))

Definition at line 37 of file Util.h.



Definition at line 45 of file Util.h.


#define HALIDE_TIC   Halide::Internal::halide_tic_impl(__FILE__, __LINE__)

Definition at line 396 of file Util.h.


#define HALIDE_TOC   Halide::Internal::halide_toc_impl(__FILE__, __LINE__)

Definition at line 397 of file Util.h.