sys/vector.hpp
sys/hash_map.hpp
sys/map.hpp
+ sys/set.hpp
+ sys/exception.hpp
+ sys/assert.cpp
+ sys/assert.hpp
sys/string.cpp
sys/string.hpp
- sys/filename.cpp
- sys/filename.hpp
- sys/library.cpp
- sys/library.hpp
sys/alloc.cpp
sys/alloc.hpp
sys/sysinfo.cpp
sys/sysinfo.hpp
- sys/ref.hpp
sys/mutex.cpp
sys/mutex.hpp
sys/condition.cpp
sys/condition.hpp
sys/platform.cpp
sys/platform.hpp
- ir/ir_context.cpp
- ir/ir_context.hpp
- ir/ir_unit.cpp
- ir/ir_unit.hpp
- ir/ir_constant.cpp
- ir/ir_constant.hpp
- ir/ir_instruction.cpp
- ir/ir_instruction.hpp
- ir/ir_register.cpp
- ir/ir_register.hpp
- ir/ir_function.cpp
- ir/ir_function.hpp)
+ ir/context.cpp
+ ir/context.hpp
+ ir/unit.cpp
+ ir/unit.hpp
+ ir/constant.cpp
+ ir/constant.hpp
+ ir/instruction.cpp
+ ir/instruction.hpp
+ ir/register.cpp
+ ir/register.hpp
+ ir/function.cpp
+ ir/function.hpp)
set (COMPILE_UTEST false CACHE bool "Compile or not the unit tests")
if (COMPILE_UTEST)
set (GBE_SRC ${GBE_SRC})
endif (COMPILE_UTEST)
-if (UNIX)
- set (EXEC_DEPENDENCIES pthread dl)
-else (UNIX)
- set (EXEC_DEPENDENCIES)
-endif (UNIX)
-
include_directories (.)
add_library (gbe SHARED ${GBE_SRC})
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "ir_constant.hpp"
+/**
+ * \file constant.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "constant.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
void ConstantSet::append(const char *data,
const std::string &name,
for (uint32_t i = 0; i < size; ++i) this->data.push_back(data[i]);
}
+} /* namespace ir */
} /* namespace gbe */
+
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file constant.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_CONSTANT_HPP__
#define __GBE_IR_CONSTANT_HPP__
#include "sys/vector.hpp"
-namespace gbe
-{
- /*! We */
+namespace gbe {
+namespace ir {
+
+ /*! Describe one constant (may be a scalar or an array) */
class Constant
{
public:
vector<Constant> constants;//!< Each constant description
};
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_CONSTANT_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "ir_context.hpp"
-#include "ir_unit.hpp"
+/**
+ * \file context.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/context.hpp"
+#include "ir/unit.hpp"
+
+namespace gbe {
+namespace ir {
-namespace gbe
-{
Context::Context(Unit &unit) : unit(unit), fn(NULL), bb(NULL) {}
void Context::startFunction(const std::string &name) {
GBE_ASSERT(fn != NULL);
fnStack.push_back(fn);
}
+
+} /* namespace ir */
} /* namespace gbe */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file context.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_CONTEXT_HPP__
#define __GBE_IR_CONTEXT_HPP__
-#include "ir_instruction.hpp"
-#include "ir_function.hpp"
-#include "ir_register.hpp"
+#include "ir/instruction.hpp"
+#include "ir/function.hpp"
+#include "ir/register.hpp"
#include "sys/vector.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
// We compile a unit
class Unit;
vector<Function*> fnStack;//!< Stack of functions still to finish
};
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_CONTEXT_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "ir_function.hpp"
-namespace gbe
-{
+/**
+ * \file function.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/function.hpp"
+
+namespace gbe {
+namespace ir {
+
Function::Function(void) {}
Function::~Function(void) {
for (auto it = bb.begin(); it != bb.end(); ++it) GBE_DELETE(*it);
}
+
+} /* namespace ir */
} /* namespace gbe */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file function.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_FUNCTION_HPP__
#define __GBE_IR_FUNCTION_HPP__
-#include "ir_value.hpp"
-#include "ir_register.hpp"
-#include "ir_instruction.hpp"
+#include "ir/value.hpp"
+#include "ir/register.hpp"
+#include "ir/instruction.hpp"
#include "sys/vector.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
/*! A function is no more that a set of declared registers and a set of
* basic blocks
*/
RegisterFile file; //!< All the registers used in the instructions
};
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_FUNCTION_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "ir_instruction.hpp"
-#include "ir_function.hpp"
+/**
+ * \file instruction.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/instruction.hpp"
+#include "ir/function.hpp"
+
+namespace gbe {
+namespace ir {
-namespace gbe
-{
///////////////////////////////////////////////////////////////////////////
// Implements the concrete implementations of the instruction classes. We just
// cast an instruction to an internal class to run the given member function
STATIC_ASSERT(offsetof(internal::CLASS, opcode) == 0);
START_INTROSPECTION(UnaryInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(UnaryInstruction)
START_INTROSPECTION(BinaryInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(BinaryInstruction)
START_INTROSPECTION(TernaryInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(TernaryInstruction)
START_INTROSPECTION(ConvertInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(ConvertInstruction)
START_INTROSPECTION(BranchInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(BranchInstruction)
START_INTROSPECTION(TextureInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(TextureInstruction)
START_INTROSPECTION(LoadImmInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(LoadImmInstruction)
START_INTROSPECTION(LoadInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(LoadInstruction)
START_INTROSPECTION(StoreInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(StoreInstruction)
START_INTROSPECTION(FenceInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(FenceInstruction)
START_INTROSPECTION(LabelInstruction)
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_INTROSPECTION(LabelInstruction)
#undef END_INTROSPECTION
#define CALL getSrcNum()
START_FUNCTION(Instruction, uint32_t, getSrcNum(void))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_FUNCTION(Instruction, uint32_t)
#undef CALL
#define CALL getDstNum()
START_FUNCTION(Instruction, uint32_t, getDstNum(void))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_FUNCTION(Instruction, uint32_t)
#undef CALL
#define CALL getDstIndex(fn, ID)
START_FUNCTION(Instruction, RegisterIndex, getDstIndex(const Function &fn, uint32_t ID))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_FUNCTION(Instruction, RegisterIndex)
#undef CALL
#define CALL getSrcIndex(fn, ID)
START_FUNCTION(Instruction, RegisterIndex, getSrcIndex(const Function &fn, uint32_t ID))
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
END_FUNCTION(Instruction, RegisterIndex)
#undef CALL
return *reinterpret_cast<Instruction*>(&insn);
}
+} /* namespace ir */
} /* namespace gbe */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file instruction.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_INSTRUCTION_HPP__
#define __GBE_IR_INSTRUCTION_HPP__
#include "sys/platform.hpp"
-#include "ir_register.hpp"
-#include "ir_value.hpp"
-#include "ir_type.hpp"
+#include "ir/register.hpp"
+#include "ir/value.hpp"
+#include "ir/type.hpp"
+
+namespace gbe {
+namespace ir {
-namespace gbe
-{
/*! All opcodes */
enum Opcode : uint8_t {
#define DECL_INSN(INSN, FAMILY) OP_##INSN,
-#include "ir_instruction.hxx"
+#include "ir/instruction.hxx"
#undef DECL_INSN
};
/*! label labelIndex */
Instruction label(LabelIndex labelIndex);
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_INSTRUCTION_HPP__ */
--- /dev/null
+/*
+ * Copyright 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file instruction.hxx
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+DECL_INSN(MOV, UnaryInstruction)
+DECL_INSN(COS, UnaryInstruction)
+DECL_INSN(SIN, UnaryInstruction)
+DECL_INSN(TAN, UnaryInstruction)
+DECL_INSN(LOG, UnaryInstruction)
+DECL_INSN(SQR, UnaryInstruction)
+DECL_INSN(RSQ, UnaryInstruction)
+DECL_INSN(POW, BinaryInstruction)
+DECL_INSN(MUL, BinaryInstruction)
+DECL_INSN(ADD, BinaryInstruction)
+DECL_INSN(SUB, BinaryInstruction)
+DECL_INSN(DIV, BinaryInstruction)
+DECL_INSN(REM, BinaryInstruction)
+DECL_INSN(SHL, BinaryInstruction)
+DECL_INSN(SHR, BinaryInstruction)
+DECL_INSN(ASR, BinaryInstruction)
+DECL_INSN(BSF, BinaryInstruction)
+DECL_INSN(BSB, BinaryInstruction)
+DECL_INSN(OR, BinaryInstruction)
+DECL_INSN(XOR, BinaryInstruction)
+DECL_INSN(AND, BinaryInstruction)
+DECL_INSN(MAD, TernaryInstruction)
+DECL_INSN(CVT, ConvertInstruction)
+DECL_INSN(BRA, BranchInstruction)
+DECL_INSN(TEX, TextureInstruction)
+DECL_INSN(LOADI, LoadImmInstruction)
+DECL_INSN(LOAD, LoadInstruction)
+DECL_INSN(STORE, StoreInstruction)
+DECL_INSN(FENCE, FenceInstruction)
+DECL_INSN(LABEL, LabelInstruction)
+
+++ /dev/null
-// ======================================================================== //
-// Copyright (C) 2012 Benjamin Segovia //
-// //
-// Licensed under the Apache License, Version 2.0 (the "License"); //
-// you may not use this file except in compliance with the License. //
-// You may obtain a copy of the License at //
-// //
-// http://www.apache.org/licenses/LICENSE-2.0 //
-// //
-// Unless required by applicable law or agreed to in writing, software //
-// distributed under the License is distributed on an "AS IS" BASIS, //
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
-// See the License for the specific language governing permissions and //
-// limitations under the License. //
-// ======================================================================== //
-
-DECL_INSN(MOV, UnaryInstruction)
-DECL_INSN(COS, UnaryInstruction)
-DECL_INSN(SIN, UnaryInstruction)
-DECL_INSN(TAN, UnaryInstruction)
-DECL_INSN(LOG, UnaryInstruction)
-DECL_INSN(SQR, UnaryInstruction)
-DECL_INSN(RSQ, UnaryInstruction)
-DECL_INSN(POW, BinaryInstruction)
-DECL_INSN(MUL, BinaryInstruction)
-DECL_INSN(ADD, BinaryInstruction)
-DECL_INSN(SUB, BinaryInstruction)
-DECL_INSN(DIV, BinaryInstruction)
-DECL_INSN(REM, BinaryInstruction)
-DECL_INSN(SHL, BinaryInstruction)
-DECL_INSN(SHR, BinaryInstruction)
-DECL_INSN(ASR, BinaryInstruction)
-DECL_INSN(BSF, BinaryInstruction)
-DECL_INSN(BSB, BinaryInstruction)
-DECL_INSN(OR, BinaryInstruction)
-DECL_INSN(XOR, BinaryInstruction)
-DECL_INSN(AND, BinaryInstruction)
-DECL_INSN(MAD, TernaryInstruction)
-DECL_INSN(CVT, ConvertInstruction)
-DECL_INSN(BRA, BranchInstruction)
-DECL_INSN(TEX, TextureInstruction)
-DECL_INSN(LOADI, LoadImmInstruction)
-DECL_INSN(LOAD, LoadInstruction)
-DECL_INSN(STORE, StoreInstruction)
-DECL_INSN(FENCE, FenceInstruction)
-DECL_INSN(LABEL, LabelInstruction)
-
+++ /dev/null
-/*
- * 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>
- */
-
-#include "ir_scope.hpp"
-
+++ /dev/null
-/*
- * 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>
- */
-
-#ifndef __GBE_IR_SCOPE_HPP__
-#define __GBE_IR_SCOPE_HPP__
-
-#endif /* __GBE_IR_SCOPE_HPP__ */
-
-
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "ir_register.hpp"
-
-namespace gbe
-{
+/**
+ * \file register.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/register.hpp"
+namespace gbe {
+namespace ir {
+} /* namespace ir */
} /* namespace gbe */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file register.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_REGISTER_HPP__
#define __GBE_IR_REGISTER_HPP__
#include "sys/vector.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
/*! A register can be either a byte, a word, a dword or a qword. It can be
* either scalar or a vector. Everything is packed in 32 bits
*/
GBE_CLASS(RegisterFile);
};
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_REGISTER_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file type.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_TYPE_HPP__
#define __GBE_IR_TYPE_HPP__
#include "sys/platform.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
/*! All types possibly supported by the instruction */
enum Type : uint8_t {
TYPE_S8 = 0, //!< signed 8 bits integer
TYPE_FLOAT, //!< 32 bits floating point value
TYPE_DOUBLE //!< 64 bits floating point value
};
+
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_TYPE_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#include "ir_unit.hpp"
-#include "ir_function.hpp"
+/**
+ * \file unit.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#include "ir/unit.hpp"
+#include "ir/function.hpp"
+
+namespace gbe {
+namespace ir {
-namespace gbe
-{
Unit::Unit(void) {}
Unit::~Unit(void) {
for (auto it = functions.begin(); it != functions.end(); ++it)
constantSet.append(data, name, size, alignment);
}
+} /* namespace ir */
} /* namespace gbe */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file unit.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_UNIT_HPP__
#define __GBE_IR_UNIT_HPP__
-#include "ir_constant.hpp"
+#include "ir/constant.hpp"
#include "sys/hash_map.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
// A unit contains a set of functions
class Function;
hash_map<std::string, Function*> functions; //!< All the defined functions
ConstantSet constantSet; //!< All the constants defined in the unit
};
+
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_UNIT_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file value.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_IR_VALUE_HPP__
#define __GBE_IR_VALUE_HPP__
-#include "ir_type.hpp"
+#include "ir/type.hpp"
#include "sys/platform.hpp"
-namespace gbe
-{
+namespace gbe {
+namespace ir {
+
/*! The value as stored in the instruction */
class Value
{
#undef DECL_CONSTRUCTOR
};
+} /* namespace ir */
} /* namespace gbe */
#endif /* __GBE_IR_VALUE_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_MATH_HPP__
#define __GBE_MATH_HPP__
#include <cmath>
#include <cfloat>
-#define DECL template <typename T> INLINE
-
namespace gbe
{
#if defined(__WIN32__)
INLINE double fmod (double x, double y) {return ::fmod (x, y);}
INLINE double pow (double x, double y) {return ::pow (x, y);}
+#define DECL template <typename T> INLINE
+
DECL T max (T a, T b) {return a<b? b:a;}
DECL T min (T a, T b) {return a<b? a:b;}
DECL T min (T a, T b, T c) {return min(min(a,b),c);}
DECL T rad2deg (T x) {return x * T(5.72957795130823208768e1f);}
DECL T sin2cos (T x) {return sqrt(max(T(zero),T(one)-x*x));}
DECL T cos2sin (T x) {return sin2cos(x);}
-}
#undef DECL
+}
+
#endif /* __GBE_MATH_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file alloc.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#include "sys/alloc.hpp"
#include "sys/atomic.hpp"
#include "sys/mutex.hpp"
Lock<MutexSys> lock(mutex);
const uintptr_t iptr = (uintptr_t) ptr;
FATAL_IF(allocMap.find(iptr) == allocMap.end(), "Pointer not referenced");
- //if(allocMap.find(iptr) == allocMap.end()) debugbreak();
allocMap.erase(iptr);
unfreedNum--;
}
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file alloc.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_ALLOC_HPP__
#define __GBE_ALLOC_HPP__
+++ /dev/null
-/*
- * 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>
- */
-
-#ifndef __GBE_ARRAY_HPP__
-#define __GBE_ARRAY_HPP__
-
-#include "sys/platform.hpp"
-#include <vector>
-
-namespace gbe
-{
- /*! Non resizable array with no checking. We make it non-copiable right now
- * since we do not want to implement an expensive deep copy
- */
- template<class T>
- class array
- {
- public:
- /*! Create an empty array */
- INLINE array(void) : elem(NULL), elemNum(0) {}
- /*! Allocate an array with elemNum allocated elements */
- INLINE array(size_t elemNum) : elem(NULL), elemNum(0) { this->resize(elemNum); }
- /*! Copy constructor */
- INLINE array(const array &other) {
- this->elemNum = other.elemNum;
- if (this->elemNum) {
- this->elem = GBE_NEW_ARRAY(T, this->elemNum);
- for (size_t i = 0; i < this->elemNum; ++i) this->elem[i] = other.elem[i];
- } else
- this->elem = NULL;
- }
- /*! Assignment operator */
- INLINE array& operator= (const array &other) {
- if (this->elem != NULL && this->elemNum != other->elemNum) {
- GBE_DELETE_ARRAY(this->elem);
- this->elem = NULL;
- this->elemNum = 0;
- }
- this->elemNum = other.elemNum;
- if (this->elemNum) {
- if (this->elem == NULL)
- this->elem = GBE_NEW_ARRAY(T, this->elemNum);
- for (size_t i = 0; i < this->elemNum; ++i) this->elem[i] = other.elem[i];
- } else
- this->elem = NULL;
- return *this;
- }
- /*! Delete the allocated elements */
- INLINE ~array(void) { GBE_SAFE_DELETE_ARRAY(elem); }
- /*! Free the already allocated elements and allocate a new array */
- INLINE void resize(size_t elemNum_) {
- if (elemNum_ != this->elemNum) {
- GBE_SAFE_DELETE_ARRAY(elem);
- if (elemNum_)
- this->elem = GBE_NEW_ARRAY(T, elemNum_);
- else
- this->elem = NULL;
- this->elemNum = elemNum_;
- }
- }
- /*! Steal the pointer. The array becomes emtpy */
- INLINE T *steal(void) {
- T *stolen = this->elem;
- this->elem = NULL;
- this->elemNum = 0;
- return stolen;
- }
- /*! First element */
- INLINE T *begin(void) { return this->elem; }
- /*! First non-valid element */
- INLINE T *end(void) { return this->elem + elemNum; }
- /*! Get element at position index (with a bound check) */
- INLINE T &operator[] (size_t index) {
- GBE_ASSERT(elem && index < elemNum);
- return elem[index];
- }
- /*! Get element at position index (with bound check) */
- INLINE const T &operator[] (size_t index) const {
- GBE_ASSERT(elem && index < elemNum);
- return elem[index];
- }
- /*! Return the number of elements */
- INLINE size_t size(void) const { return this->elemNum; }
- private:
- T *elem; //!< Points to the elements
- size_t elemNum; //!< Number of elements in the array
- GBE_CLASS(array);
- };
-} /* namespace gbe */
-
-#endif /* __GBE_ARRAY_HPP__ */
-
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file assert.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_ATOMIC_HPP__
#define __GBE_ATOMIC_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#ifndef __GBE_BARRIER_H__
-#define __GBE_BARRIER_H__
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GBE_BARRIER_HPP__
+#define __GBE_BARRIER_HPP__
#include "sys/condition.hpp"
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#include "sys/condition.hpp"
#if defined(__WIN32__)
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_CONDITION_HPP__
#define __GBE_CONDITION_HPP__
};
}
-#endif
+#endif /* __GBE_CONDITION_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_CONSTANTS_HPP__
#define __GBE_CONSTANTS_HPP__
static const size_t GB = KB*MB;
}
-#endif
+#endif /* __GBE_CONSTANTS_HPP__ */
+
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file exception.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_EXCEPTION_HPP__
#define __GBE_EXCEPTION_HPP__
+#if defined(GBE_COMPILE_UTEST)
+
+#include "string.hpp"
+#include <exception>
+
+namespace gbe
+{
+ /*! Exception are only used while using unit tests */
+ class Exception : public std::exception
+ {
+ public:
+ Exception(const std::string &msg) throw() : msg(msg) {}
+ Exception(const Exception &other) throw() : msg(other.msg) {}
+ ~Exception(void) throw() {}
+ Exception &operator= (const Exception &other) throw() {
+ this->msg = other.msg;
+ return *this;
+ }
+ const char *what(void) const throw() { return msg.c_str(); }
+ private:
+ std::string msg; //!< String message
+ };
+
+} /* namespace gbe */
+
+#endif /* GBE_COMPILE_UTEST */
#endif /* __GBE_EXCEPTION_HPP__ */
+++ /dev/null
-/*
- * 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>
- */
-
-#include "sys/platform.hpp"
-#include "sys/filename.hpp"
-
-namespace gbe
-{
-#ifdef __WIN32__
- const char path_sep = '\\';
-#else
- const char path_sep = '/';
-#endif
-
- /*! little helper to not depend on math */
- static size_t maxInt(size_t a, size_t b) { return index_t(a) < index_t(b) ? b : a; }
-
- /*! create an empty filename */
- FileName::FileName () {}
-
- /*! create a valid filename from a string */
- FileName::FileName (const char* in) {
- filename = in;
- for (size_t i=0; i<filename.size(); i++)
- if (filename[i] == '\\' || filename[i] == '/')
- filename[i] = path_sep;
- while (!filename.empty() && filename[filename.size()-1] == path_sep)
- filename.resize(filename.size()-1);
- }
-
- /*! create a valid filename from a string */
- FileName::FileName (const std::string& in) {
- filename = in;
- for (size_t i=0; i<filename.size(); i++)
- if (filename[i] == '\\' || filename[i] == '/')
- filename[i] = path_sep;
- while (!filename.empty() && filename[filename.size()-1] == path_sep)
- filename.resize(filename.size()-1);
- }
-
- /*! returns the path */
- FileName FileName::path() const {
- size_t pos = maxInt(filename.find_last_of('\\'),filename.find_last_of('/'));
- if (pos == std::string::npos) return FileName();
- return filename.substr(0,pos);
- }
-
- /*! returns the basename */
- std::string FileName::base() const {
- size_t pos = maxInt(filename.find_last_of('\\'),filename.find_last_of('/'));
- if (pos == std::string::npos) return filename;
- return filename.substr(pos+1);
- }
-
- /*! returns the extension */
- std::string FileName::ext() const {
- size_t pos = filename.find_last_of('.');
- if (pos == std::string::npos) return "";
- return filename.substr(pos+1);
- }
-
- /*! returns the basename without extension */
- std::string FileName::name() const {
- size_t start = maxInt(filename.find_last_of('\\'),filename.find_last_of('/')) + 1;
- if (start == std::string::npos) start = 0;
- size_t end = filename.find_last_of('.');
- if (end == std::string::npos || end < start) end = filename.size();
- return filename.substr(start, end - start);
- }
-
- /*! replaces the extension */
- FileName FileName::setExt(const std::string& ext) const {
- size_t start = maxInt(filename.find_last_of('\\'),filename.find_last_of('/')) + 1;
- if (start == std::string::npos) start = 0;
- size_t end = filename.find_last_of('.');
- if (end == std::string::npos || end < start) return FileName(filename+ext);
- return FileName(filename.substr(0,end)+ext);
- }
-
- /*! adds the extension */
- FileName FileName::addExt(const std::string& ext) const {
- return FileName(filename+ext);
- }
-
- /*! concatenates two filenames to this/other */
- FileName FileName::operator +( const FileName& other ) const {
- if (filename == "") return FileName(other);
- else return FileName(filename + path_sep + other.filename);
- }
-
- /*! concatenates two filenames to this/other */
- FileName FileName::operator +( const std::string& other ) const {
- return operator+(FileName(other));
- }
-
- /*! removes the base from a filename (if possible) */
- FileName FileName::operator -( const FileName& base ) const {
- size_t pos = filename.find_first_of(base);
- if (pos == std::string::npos) return *this;
- return FileName(filename.substr(pos+1));
- }
-
- /*! output operator */
- std::ostream& operator<<(std::ostream& cout, const FileName& filename) {
- return cout << filename.filename;
- }
-}
+++ /dev/null
-/*
- * 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>
- */
-
-#ifndef __GBE_FILENAME_HPP__
-#define __GBE_FILENAME_HPP__
-
-#include "platform.hpp"
-#include <string>
-#include <cstdio>
-
-namespace gbe
-{
- /*! Convenience class for handling file names and paths. */
- class FileName
- {
- public:
- /*! create an empty filename */
- FileName ();
- /*! create a valid filename from a string */
- FileName (const char* filename);
- /*! create a valid filename from a string */
- FileName (const std::string& filename);
- /*! auto convert into a string */
- operator std::string() const { return filename; }
- /*! returns a string of the filename */
- const std::string str() const { return filename; }
- /*! returns a c-string of the filename */
- const char* c_str() const { return filename.c_str(); }
- /*! returns the path of a filename */
- FileName path() const;
- /*! returns the file of a filename */
- std::string base() const;
- /*! returns the base of a filename without extension */
- std::string name() const;
- /*! returns the file extension */
- std::string ext() const;
- /*! replaces the file extension */
- FileName setExt(const std::string& ext = "") const;
- /*! adds file extension */
- FileName addExt(const std::string& ext = "") const;
- /*! concatenates two filenames to this/other */
- FileName operator +( const FileName& other ) const;
- /*! concatenates two filenames to this/other */
- FileName operator +( const std::string& other ) const;
- /*! removes the base from a filename (if possible) */
- FileName operator -( const FileName& base ) const;
- /*! output operator */
- friend std::ostream& operator<<(std::ostream& cout, const FileName& filename);
- private:
- std::string filename;
- GBE_CLASS(FileName);
- };
-}
-
-#endif /* __GBE_FILENAME_HPP__ */
-
--- /dev/null
+/*
+ * 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 fixed_array.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+#ifndef __GBE_FIXED_ARRAY_HPP__
+#define __GBE_FIXED_ARRAY_HPP__
+
+#include "platform.hpp"
+#include <cstring>
+
+namespace gbe
+{
+ /*! Regular C array but with bound checks */
+ template<typename T, size_t N>
+ class fixed_array
+ {
+ public:
+ /*! Do not initialize the data */
+ fixed_array(void) {}
+ /*! Copy the input array */
+ fixed_array(const T array[N]) { std::memcpy(elem, array, N * sizeof(T)); }
+ /*! First element (non const) */
+ T* begin(void) { return &elem[0]; }
+ /*! First non-valid element (non const) */
+ T* end(void) { return begin() + N; }
+ /*! First element (const) */
+ const T* begin(void) const { return &elem[0]; }
+ /*! First non-valid element (const) */
+ const T* end(void) const { return begin() + N; }
+ /*! Number of elements in the array */
+ size_t size(void) const { return N; }
+ /*! Get the pointer to the data (non-const) */
+ T* data(void) { return &elem[0]; }
+ /*! Get the pointer to the data (const) */
+ const T* data(void) const { return &elem[0]; }
+ /*! First element (const) */
+ const T& front(void) const { return *begin(); }
+ /*! Last element (const) */
+ const T& back(void) const { return *(end() - 1); }
+ /*! First element (non-const) */
+ T& front(void) { return *begin(); }
+ /*! Last element (non-const) */
+ T& back(void) { return *(end() - 1); }
+ /*! Get element at position index (with bound check) */
+ INLINE T& operator[] (size_t index) {
+ GBE_ASSERT(index < size());
+ return elem[index];
+ }
+ /*! Get element at position index (with bound check) */
+ INLINE const T& operator[] (size_t index) const {
+ GBE_ASSERT(index < size());
+ return elem[index];
+ }
+ private:
+ T elem[N]; //!< Store the elements
+ STATIC_ASSERT(N > 0); //!< zero element is not allowed
+ GBE_CLASS(fixed_array);
+ };
+
+} /* namespace gbe */
+
+#endif /* __GBE_FIXED_ARRAY_HPP__ */
+
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file hash_map.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_HASH_MAP_HPP__
#define __GBE_HASH_MAP_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#ifndef __GBE_INTRINSICS_H__
-#define __GBE_INTRINSICS_H__
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GBE_INTRINSICS_HPP__
+#define __GBE_INTRINSICS_HPP__
#include "sys/platform.hpp"
#include <xmmintrin.h>
*ptr = x; // for x86, store == store_release
GBE_COMPILER_READ_WRITE_BARRIER;
}
-#endif /* __GBE_INTRINSICS_H__ */
+#endif /* __GBE_INTRINSICS_HPP__ */
+++ /dev/null
-/*
- * 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>
- */
-
-#include "sys/library.hpp"
-#include "sys/sysinfo.hpp"
-#include "sys/filename.hpp"
-
-////////////////////////////////////////////////////////////////////////////////
-/// Windows Platform
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(__WIN32__)
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-namespace gbe
-{
- /* opens a shared library */
- lib_t openLibrary(const std::string& file)
- {
- std::string fullName = file+".dll";
- HMODULE handle = LoadLibraryA(fullName.c_str());
- if (handle) return lib_t(handle);
- handle = LoadLibrary((getExecutableFileName() + fullName).c_str());
- return lib_t(handle);
- }
-
- /* returns address of a symbol from the library */
- void* getSymbol(lib_t lib, const std::string& sym) {
- return (void*) GetProcAddress(HMODULE(lib),sym.c_str());
- }
-
- /* closes the shared library */
- void closeLibrary(lib_t lib) {
- FreeLibrary(HMODULE(lib));
- }
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-/// Unix Platform
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(__UNIX__)
-
-#include <dlfcn.h>
-
-namespace gbe
-{
- /* opens a shared library */
- lib_t openLibrary(const std::string& file)
- {
-#if defined(__MACOSX__)
- std::string fullName = "lib"+file+".dylib";
-#else
- std::string fullName = "lib"+file+".so";
-#endif
- void* lib = dlopen(fullName.c_str(),RTLD_NOW);
- if (lib) return lib_t(lib);
- lib = dlopen((getExecutableFileName() + fullName).c_str(),RTLD_NOW);
- return lib_t(lib);
- }
-
- /* returns address of a symbol from the library */
- void* getSymbol(lib_t lib, const std::string& sym) {
- return dlsym(lib,sym.c_str());
- }
-
- /* closes the shared library */
- void closeLibrary(lib_t lib) {
- dlclose(lib);
- }
-}
-#endif
+++ /dev/null
-/*
- * 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>
- */
-
-#ifndef __GBE_LIBRARY_HPP__
-#define __GBE_LIBRARY_HPP__
-
-#include <string>
-
-#include "sys/platform.hpp"
-
-namespace gbe
-{
- /*! type for shared library */
- typedef struct opaque_lib_t* lib_t;
- /*! loads a shared library */
- lib_t openLibrary(const std::string& file);
- /*! returns address of a symbol from the library */
- void* getSymbol(lib_t lib, const std::string& sym);
- /*! unloads a shared library */
- void closeLibrary(lib_t lib);
-} /* namespace gbe */
-
-#endif /* __GBE_LIBRARY_HPP__ */
-
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file list.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_LIST_HPP__
#define __GBE_LIST_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file map.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_MAP_HPP__
#define __GBE_MAP_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#include "sys/mutex.hpp"
#if defined(__WIN32__)
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
-#ifndef __GBE_MUTEX_H__
-#define __GBE_MUTEX_H__
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
+#ifndef __GBE_MUTEX_HPP__
+#define __GBE_MUTEX_HPP__
#include "platform.hpp"
#include "atomic.hpp"
};
}
-#endif
+#endif /* __GBE_MUTEX_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#include "sys/platform.hpp"
#include "sys/intrinsics.hpp"
#include <string>
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_PLATFORM_HPP__
#define __GBE_PLATFORM_HPP__
#define THREAD __declspec(thread)
#define ALIGNED(...) __declspec(align(__VA_ARGS__))
//#define __FUNCTION__ __FUNCTION__
-#define debugbreak() __debugbreak()
+#define DEBUGBREAK() __debugbreak()
#else
#undef NOINLINE
#undef INLINE
#define THREAD __thread
#define ALIGNED(...) __attribute__((aligned(__VA_ARGS__)))
#define __FUNCTION__ __PRETTY_FUNCTION__
-#define debugbreak() asm ("int $3")
+#define DEBUGBREAK() asm ("int $3")
#endif
/*! Modern x86 processors */
+++ /dev/null
-/*
- * 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>
- */
-
-#ifndef __GBE_REF_HPP__
-#define __GBE_REF_HPP__
-
-#include "sys/atomic.hpp"
-#include "sys/alloc.hpp"
-
-namespace gbe
-{
- class RefCount
- {
- public:
- RefCount() : refCounter(0) {}
- virtual ~RefCount() {}
- INLINE void refInc() { refCounter++; }
- INLINE bool refDec() { return !(--refCounter); }
- Atomic32 refCounter;
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- /// Reference to single object
- ////////////////////////////////////////////////////////////////////////////////
-
- template<typename Type>
- class Ref {
- public:
- Type* const ptr;
-
- ////////////////////////////////////////////////////////////////////////////////
- /// Constructors, Assignment & Cast Operators
- ////////////////////////////////////////////////////////////////////////////////
-
- INLINE Ref(void) : ptr(NULL) {}
- INLINE Ref(NullTy) : ptr(NULL) {}
- INLINE Ref(const Ref& input) : ptr(input.ptr) { if ( ptr ) ptr->refInc(); }
- INLINE Ref(Type* const input) : ptr(input) { if (ptr) ptr->refInc(); }
- INLINE ~Ref(void) { if (ptr && ptr->refDec()) GBE_DELETE(ptr); }
-
- INLINE Ref& operator= (const Ref &input) {
- if (input.ptr) input.ptr->refInc();
- if (ptr && ptr->refDec()) GBE_DELETE(ptr);
- *(Type**)&ptr = input.ptr;
- return *this;
- }
-
- INLINE Ref& operator= (NullTy) {
- if (ptr && ptr->refDec()) DELETE(ptr);
- *(Type**)&ptr = NULL;
- return *this;
- }
-
- INLINE operator bool(void) const { return ptr != NULL; }
- INLINE operator Type*(void) const { return ptr; }
-
- ////////////////////////////////////////////////////////////////////////////////
- /// Properties
- ////////////////////////////////////////////////////////////////////////////////
-
- INLINE const Type& operator* (void) const { return *ptr; }
- INLINE const Type* operator-> (void) const { return ptr; }
- INLINE Type& operator* (void) { return *ptr; }
- INLINE Type* operator-> (void) { return ptr; }
-
- template<typename TypeOut>
- INLINE Ref<TypeOut> cast() { return Ref<TypeOut>(static_cast<TypeOut*>(ptr)); }
- template<typename TypeOut>
- INLINE const Ref<TypeOut> cast() const { return Ref<TypeOut>(static_cast<TypeOut*>(ptr)); }
- GBE_CLASS(Ref);
- };
-
- template<typename Type> INLINE bool operator< ( const Ref<Type>& a, const Ref<Type>& b ) { return a.ptr < b.ptr ; }
- template<typename Type> INLINE bool operator== ( const Ref<Type>& a, NullTy ) { return a.ptr == NULL ; }
- template<typename Type> INLINE bool operator== ( NullTy , const Ref<Type>& b ) { return NULL == b.ptr ; }
- template<typename Type> INLINE bool operator== ( const Ref<Type>& a, const Ref<Type>& b ) { return a.ptr == b.ptr ; }
- template<typename Type> INLINE bool operator!= ( const Ref<Type>& a, NullTy ) { return a.ptr != NULL ; }
- template<typename Type> INLINE bool operator!= ( NullTy , const Ref<Type>& b ) { return NULL != b.ptr ; }
- template<typename Type> INLINE bool operator!= ( const Ref<Type>& a, const Ref<Type>& b ) { return a.ptr != b.ptr ; }
-}
-
-#endif /* __GBE_REF_HPP__ */
-
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file set.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_SET_HPP__
#define __GBE_SET_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file string.cpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#include "sys/string.hpp"
-#include "sys/filename.hpp"
#include <cstdio>
#include <cctype>
if (strstr(haystack, needle) == NULL) return false;
return true;
}
-
- std::string loadFile(const FileName &path)
- {
- std::ifstream stream(path.c_str(), std::istream::in);
- if (stream.is_open() == false)
- return std::string();
- std::string str = loadFile(stream);
- stream.close();
- return str;
- }
-
- std::string loadFile(std::ifstream &stream)
- {
- GBE_ASSERT(stream.is_open() == true);
- std::string line;
- std::stringstream text;
- while (std::getline(stream, line))
- text << "\n" << line;
- stream.close();
- return text.str();
- }
}
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_STRING_HPP__
#define __GBE_STRING_HPP__
#include "sys/platform.hpp"
-#include "sys/filename.hpp"
#include <cstring>
#include <string>
bool contains(const char *haystack, const char *needle);
/*! Tokenize a string (like strtok_r does) */
char* tokenize(char *s1, const char *s2, char **lasts);
- /*! Load a file from its path and copies it into a string */
- std::string loadFile(const FileName &path);
- /*! Load a file from a stream and copies it into a string */
- std::string loadFile(std::ifstream &stream);
} /* namespace gbe */
#endif /* __GBE_STRING_HPP__ */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#include "sys/sysinfo.hpp"
////////////////////////////////////////////////////////////////////////////////
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+//////////////////////////////////////////////////////////////////////////////////////////
+// Part of this file is taken from the Apache licensed Intel Embree project here: //
+// http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/ //
+//////////////////////////////////////////////////////////////////////////////////////////
+
#ifndef __GBE_SYSINFO_HPP__
#define __GBE_SYSINFO_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file vector.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
+
#ifndef __GBE_VECTOR_HPP__
#define __GBE_VECTOR_HPP__
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file utest.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#include "utest.hpp"
#include "sys/string.hpp"
-namespace pf
+namespace gbe
{
std::vector<UTest> *UTest::utestList = NULL;
void releaseUTestList(void) { if (UTest::utestList) delete UTest::utestList; }
(utest.fn)();
}
}
-} /* namespace pf */
+} /* namespace gbe */
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
+/**
+ * \file utest.hpp
+ *
+ * \author Benjamin Segovia <benjamin.segovia@intel.com>
+ */
#ifndef __GBE_UTEST_HPP__
#define __GBE_UTEST_HPP__