The Standard Library #
The standard library of HalideOS is a set of a few abstractions for some common data structures and utility functions that we used to again and again for the kernel as well as the shell programs.
All the classes and the functions are encapsulated in the hldstd
namespace for clarity.
- Files:
include/halidestdlib.h
andsrc/halidestdlib.cpp
- Namespaces:
hldstd
,hldstd::math
Classes
hldstd::string
hltstd::stack<T>
Functions
Refer below for details on return types with accurate namespaces.
hldstd::stringCompare
hldstd::stringLength
hldstd::math::pow
hldstd::math::abs
Classes #
hldstd::string
#
A regular string class to maintain a character array and it’s size, with some conversion functions.
Functions
string(int x);
- Contructor to convertint
tostring
string(double x, int digits_after_point);
- Constructor to convertdouble
tostring
string(char *str);
- Constructor to convert a rawchar*
tostring
string(bool val);
- Constructor to convertbool
tostring
string(string &other);
- Copy Constructorint size();
- Returns size of the stringchar at(int i);
- Returns the character at index i of the stringchar *c_ptr();
- Returns a rawchar *
to the stringint to_int();
- Converts thestring
toint
double to_double();
- Converts thestring
todouble
hldstd::stack<T>
#
A standard stack or LIFO list with the standard operations. This is a template class, the stack
can hold any data-type T
Functions
All functions are template functions with <typename T>
stack(int size, T x);
- Constructor to initialise the stack with size and the first element;bool pop();
-false
for underflow,true
for successful popbool push(T x);
-false
for overflow,true
for successful pushT top();
- Returns the top element of the stackbool isEmpty();
- Check if stack is empty or not.
Functions #
Some simple mathematical functions are declared in the math
namespace.
int hldstd::stringCompare(char *, char *)
- Compare 2 strings from the char pointersint hldstd::stringLength(char *)
- Get length of stringdouble hldstd::math::pow(double x, int y)
- x^yint hldstd::math::abs(int x)
- |x|