diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f6bb1e..c090c3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,10 @@ if(USE_CUDA) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe \"--diag_suppress=20012\"") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe \"--diag_suppress=20014\"") set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe \"--diag_suppress=20015\"") + find_package(CUDAToolkit REQUIRED) enable_language(CUDA) set(CMAKE_CUDA_ARCHITECTURES 61) + include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}) add_compile_definitions(USE_CUDA) endif() diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index a1988fa..586f2ef 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -1,5 +1,5 @@ -set(HEADERS Archives.h Array.h Collection.h Debug.h Export.h Function.h Macros.h Mpl.h Object.h Options.h Serializable.h Signal.h Singleton.h SmartPointer.h StaticInterface.h StringReader.h Types.h Uuid.h Vector.h) +set(HEADERS Archives.h Array.h Collection.h DataAllocator.h Debug.h Export.h Function.h Macros.h Mpl.h Object.h Options.h Serializable.h Signal.h Singleton.h SmartPointer.h StaticInterface.h StringReader.h Types.h Uuid.h Vector.h) set(SOURCES Archives.cpp Debug.cpp Object.cpp Options.cpp Serializable.cpp Signal.cpp Uuid.cpp) @@ -13,6 +13,10 @@ add_library(${libname} SHARED ${SOURCES}) set_target_properties(${libname} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_SOVERSION}) +if(USE_CUDA) + set(LIBRARIES ${LIBRARIES} CUDA::cudart) +endif() + target_link_libraries(${libname} ${LIBRARIES}) install(TARGETS ${libname} diff --git a/src/Math/DataAllocator.h b/src/Core/DataAllocator.h similarity index 80% rename from src/Math/DataAllocator.h rename to src/Core/DataAllocator.h index a5ff43b..147dd9f 100644 --- a/src/Math/DataAllocator.h +++ b/src/Core/DataAllocator.h @@ -42,20 +42,26 @@ enum class MemoryDevice { RAM, VRAM }; template class DataAllocator { public: - DataAllocator() - : m_Size(0), m_RamData(nullptr), m_VramData(nullptr), - m_Device(MemoryDevice::RAM) {} - - DataAllocator(size_t size) - : m_Size(size), m_RamData(new T[size]()), m_VramData(nullptr), - m_Device(MemoryDevice::RAM) {} + DataAllocator(size_t size = 0, bool owns_objects = true) + : m_Size(size), m_RamData(nullptr), m_VramData(nullptr), + m_Device(MemoryDevice::RAM), m_OwnsObjects(owns_objects) { + if (m_Size > 0) { + if (m_OwnsObjects) + m_RamData = new T[m_Size](); + else + m_RamData = static_cast(::operator new(m_Size * sizeof(T))); + } + } DataAllocator(const DataAllocator &other) : m_Size(other.m_Size), m_RamData(nullptr), m_VramData(nullptr), - m_Device(other.m_Device) { + m_Device(other.m_Device), m_OwnsObjects(other.m_OwnsObjects) { if (m_Size > 0) { if (other.m_RamData) { - m_RamData = new T[m_Size]; + if (m_OwnsObjects) + m_RamData = new T[m_Size]; + else + m_RamData = static_cast(::operator new(m_Size * sizeof(T))); std::memcpy(m_RamData, other.m_RamData, m_Size * sizeof(T)); } #ifdef USE_CUDA @@ -70,7 +76,10 @@ public: ~DataAllocator() { if (m_RamData) { - delete[] m_RamData; + if (m_OwnsObjects) + delete[] m_RamData; + else + ::operator delete(m_RamData); } #ifdef USE_CUDA if (m_VramData) { @@ -81,11 +90,16 @@ public: DataAllocator &operator=(const DataAllocator &other) { if (this != &other) { + m_OwnsObjects = other.m_OwnsObjects; resize(other.m_Size); m_Device = other.m_Device; if (other.m_RamData) { - if (!m_RamData) - m_RamData = new T[m_Size]; + if (!m_RamData) { + if (m_OwnsObjects) + m_RamData = new T[m_Size]; + else + m_RamData = static_cast(::operator new(m_Size * sizeof(T))); + } std::memcpy(m_RamData, other.m_RamData, m_Size * sizeof(T)); } #ifdef USE_CUDA @@ -103,8 +117,12 @@ public: void MoveToRAM() { if (m_Device == MemoryDevice::RAM) return; - if (!m_RamData && m_Size > 0) - m_RamData = new T[m_Size](); + if (!m_RamData && m_Size > 0) { + if (m_OwnsObjects) + m_RamData = new T[m_Size](); + else + m_RamData = static_cast(::operator new(m_Size * sizeof(T))); + } #ifdef USE_CUDA if (m_VramData && m_Size > 0) { cudaMemcpy(m_RamData, m_VramData, m_Size * sizeof(T), @@ -137,7 +155,11 @@ public: T *newVram = nullptr; if (size > 0) { - newRam = new T[size](); + if (m_OwnsObjects) + newRam = new T[size](); + else + newRam = static_cast(::operator new(size * sizeof(T))); + if (m_RamData) { std::memcpy(newRam, m_RamData, std::min(m_Size, size) * sizeof(T)); } @@ -151,8 +173,12 @@ public: #endif } - if (m_RamData) - delete[] m_RamData; + if (m_RamData) { + if (m_OwnsObjects) + delete[] m_RamData; + else + ::operator delete(m_RamData); + } #ifdef USE_CUDA if (m_VramData) cudaFree(m_VramData); @@ -225,6 +251,7 @@ private: T *m_RamData; T *m_VramData; MemoryDevice m_Device; + bool m_OwnsObjects; }; } // namespace uLib diff --git a/src/Core/Vector.h b/src/Core/Vector.h index 04d6342..0bd1944 100644 --- a/src/Core/Vector.h +++ b/src/Core/Vector.h @@ -23,156 +23,386 @@ //////////////////////////////////////////////////////////////////////////////*/ - - #ifndef U_CORE_VECTOR_H #define U_CORE_VECTOR_H -#include #include +#include +#include +#include + +#include -#include -#include #include - +#include +#include namespace uLib { -// Vector Implemetation ... wraps std::vector -template -class Vector : public std::vector > -{ - typedef std::vector< T,std::allocator > BaseClass; - typedef std::allocator Allocator; -public: - typedef T TypeData; - typedef __gnu_cxx::__normal_iterator Iterator; - typedef __gnu_cxx::__normal_iterator ConstIterator; - - typedef CommaInitializer< Vector , T > VectorCommaInit; - - Vector(unsigned int size) : BaseClass(size) {} - Vector(unsigned int size, T &value) : BaseClass(size,value) {} - Vector() : BaseClass(0) {} - - inline VectorCommaInit operator <<(T scalar) { - return VectorCommaInit(this, scalar); - } - - inline void PrintSelf(std::ostream &o); - - void remove_element(unsigned int index) { - std::swap(this->at(index),this->back()); - this->pop_back(); - } - - void remove_element(T &t) { - std::swap(t, this->back()); - this->pop_back(); - } - -}; - -template -void Vector::PrintSelf(std::ostream &o) -{ - o << " *** uLib Vector *** \n"; - o << " n. of items = " << this->size() << "\n"; - for(int i=0; i< this->size(); ++i) - o << (T)this->at(i) << " "; - o << "\n"; -} - -template -std::ostream & operator << (std::ostream &o, const Vector &v) { - for(int i=0; i< v.size(); ++i) - o << (T)v.at(i) << " "; - o << "\n"; - return o; -} - -template -std::ofstream & operator << (std::ofstream &o, const Vector &v) { - for(int i=0; i< v.size(); ++i) - o << (T)v.at(i) << " "; - return o; -} - - -template < typename T > -std::istream & operator >> (std::istream &is, Vector &v) { - T value; - while( is >> value ) { - if(is.fail()) v.push_back(0); - else v.push_back( value ); - } - return is; -} - - - -// Smart pointer Vector Implementation // - - -template -class SmartVector : public SmartPointer< Vector > { - typedef SmartPointer< Vector > Base; +// MetaAllocator Implementation ... +template class MetaAllocator { public: + using value_type = T; + using pointer = T *; + using const_pointer = const T *; + using reference = T &; + using const_reference = const T &; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; - SmartVector() : Base(new Vector()) { } - SmartVector( const SmartVector ©) : Base(copy) { } - SmartVector(unsigned int size) : Base(new Vector((int)size)) { } + template struct rebind { + using other = MetaAllocator; + }; - virtual ~SmartVector() {} + MetaAllocator() noexcept = default; - T& operator[](int p) { - return Base::get()->at(p); + template + constexpr MetaAllocator(const MetaAllocator &) noexcept {} + + T *allocate(std::size_t n) { + if (n == 0) + return nullptr; + + DataAllocator *da = new DataAllocator(n, false); + T *ptr = da->GetRAMData(); + + std::lock_guard lock(GetMutex()); + GetAllocationMap()[ptr] = da; + return ptr; } - void swap_elements(unsigned int first, unsigned int second) { - std::swap(Base::get()->at(first),Base::get()->at(second)); + void deallocate(T *p, std::size_t /*n*/) noexcept { + if (!p) + return; + + std::lock_guard lock(GetMutex()); + auto &map = GetAllocationMap(); + auto it = map.find(p); + if (it != map.end()) { + delete it->second; + map.erase(it); + } + } + + static DataAllocator *GetDataAllocator(T *p) { + if (!p) + return nullptr; + std::lock_guard lock(GetMutex()); + auto &map = GetAllocationMap(); + auto it = map.find(p); + if (it != map.end()) { + return it->second; + } + return nullptr; + } + +private: + static std::map *> &GetAllocationMap() { + static std::map *> allocMap; + return allocMap; + } + + static std::mutex &GetMutex() { + static std::mutex mtx; + return mtx; + } +}; + +template +bool operator==(const MetaAllocator &, const MetaAllocator &) { + return true; +} +template +bool operator!=(const MetaAllocator &, const MetaAllocator &) { + return false; +} + +// Vector Implemetation ... wraps std::vector +template class Vector : public std::vector> { + typedef std::vector> BaseClass; + typedef MetaAllocator Allocator; + +public: + typedef T TypeData; + typedef __gnu_cxx::__normal_iterator Iterator; + typedef __gnu_cxx::__normal_iterator ConstIterator; + + typedef CommaInitializer, T> VectorCommaInit; + typedef typename BaseClass::iterator iterator; + typedef typename BaseClass::const_iterator const_iterator; + typedef typename BaseClass::size_type size_type; + typedef typename BaseClass::reference reference; + + Vector(unsigned int size) : BaseClass(size) {} + Vector(unsigned int size, T &value) : BaseClass(size, value) {} + Vector() : BaseClass(0) {} + + inline VectorCommaInit operator<<(T scalar) { + return VectorCommaInit(this, scalar); + } + + void MoveToVRAM() { + if (auto alloc = MetaAllocator::GetDataAllocator(BaseClass::data())) { + alloc->MoveToVRAM(); + } + } + + void MoveToRAM() { + if (auto alloc = MetaAllocator::GetDataAllocator(BaseClass::data())) { + alloc->MoveToRAM(); + } + } + + T *GetVRAMData() { + if (auto alloc = MetaAllocator::GetDataAllocator(BaseClass::data())) { + return alloc->GetVRAMData(); + } + return nullptr; + } + + const T *GetVRAMData() const { + if (auto alloc = MetaAllocator::GetDataAllocator( + const_cast(BaseClass::data()))) { + return alloc->GetVRAMData(); + } + return nullptr; + } + + inline void PrintSelf(std::ostream &o); + + // Overrides for auto-sync // + T &operator[](size_t i) { + this->MoveToRAM(); + return BaseClass::operator[](i); + } + const T &operator[](size_t i) const { + const_cast(this)->MoveToRAM(); + return BaseClass::operator[](i); + } + T &at(size_t i) { + this->MoveToRAM(); + return BaseClass::at(i); + } + const T &at(size_t i) const { + const_cast(this)->MoveToRAM(); + return BaseClass::at(i); + } + T &front() { + this->MoveToRAM(); + return BaseClass::front(); + } + const T &front() const { + const_cast(this)->MoveToRAM(); + return BaseClass::front(); + } + T &back() { + this->MoveToRAM(); + return BaseClass::back(); + } + const T &back() const { + const_cast(this)->MoveToRAM(); + return BaseClass::back(); + } + T *data() noexcept { + this->MoveToRAM(); + return BaseClass::data(); + } + const T *data() const noexcept { + const_cast(this)->MoveToRAM(); + return BaseClass::data(); + } + Iterator begin() noexcept { + this->MoveToRAM(); + return BaseClass::begin(); + } + ConstIterator begin() const noexcept { + const_cast(this)->MoveToRAM(); + return BaseClass::begin(); + } + Iterator end() noexcept { + this->MoveToRAM(); + return BaseClass::end(); + } + ConstIterator end() const noexcept { + const_cast(this)->MoveToRAM(); + return BaseClass::end(); + } + auto rbegin() noexcept { + this->MoveToRAM(); + return BaseClass::rbegin(); + } + auto rbegin() const noexcept { + const_cast(this)->MoveToRAM(); + return BaseClass::rbegin(); + } + auto rend() noexcept { + this->MoveToRAM(); + return BaseClass::rend(); + } + auto rend() const noexcept { + const_cast(this)->MoveToRAM(); + return BaseClass::rend(); + } + + void push_back(const T &x) { + this->MoveToRAM(); + BaseClass::push_back(x); + } + void push_back(T &&x) { + this->MoveToRAM(); + BaseClass::push_back(std::move(x)); + } + template reference emplace_back(Args &&...args) { + this->MoveToRAM(); + return BaseClass::emplace_back(std::forward(args)...); + } + void pop_back() { + this->MoveToRAM(); + BaseClass::pop_back(); + } + + template + iterator emplace(const_iterator pos, Args &&...args) { + this->MoveToRAM(); + return BaseClass::emplace(pos, std::forward(args)...); + } + iterator insert(const_iterator pos, const T &x) { + this->MoveToRAM(); + return BaseClass::insert(pos, x); + } + iterator insert(const_iterator pos, T &&x) { + this->MoveToRAM(); + return BaseClass::insert(pos, std::move(x)); + } + iterator erase(const_iterator pos) { + this->MoveToRAM(); + return BaseClass::erase(pos); + } + iterator erase(const_iterator first, const_iterator last) { + this->MoveToRAM(); + return BaseClass::erase(first, last); + } + + void resize(size_t n) { + this->MoveToRAM(); + BaseClass::resize(n); + } + void resize(size_t n, const T &x) { + this->MoveToRAM(); + BaseClass::resize(n, x); + } + void reserve(size_t n) { + this->MoveToRAM(); + BaseClass::reserve(n); + } + void clear() noexcept { + this->MoveToRAM(); + BaseClass::clear(); + } + template void assign(InputIt first, InputIt last) { + this->MoveToRAM(); + BaseClass::assign(first, last); + } + void assign(size_type count, const T &value) { + this->MoveToRAM(); + BaseClass::assign(count, value); } void remove_element(unsigned int index) { - std::swap(Base::get()->at(index),Base::get()->back()); - Base::get()->pop_back(); + this->MoveToRAM(); + std::swap(this->at(index), this->back()); + this->pop_back(); + } + + void remove_element(T &t) { + this->MoveToRAM(); + std::swap(t, this->back()); + this->pop_back(); + } +}; + +template void Vector::PrintSelf(std::ostream &o) { + o << " *** uLib Vector *** \n"; + o << " n. of items = " << this->size() << "\n"; + for (int i = 0; i < this->size(); ++i) + o << (T)this->at(i) << " "; + o << "\n"; +} + +template +std::ostream &operator<<(std::ostream &o, const Vector &v) { + for (int i = 0; i < v.size(); ++i) + o << (T)v.at(i) << " "; + o << "\n"; + return o; +} + +template +std::ofstream &operator<<(std::ofstream &o, const Vector &v) { + for (int i = 0; i < v.size(); ++i) + o << (T)v.at(i) << " "; + return o; +} + +template std::istream &operator>>(std::istream &is, Vector &v) { + T value; + while (is >> value) { + if (is.fail()) + v.push_back(0); + else + v.push_back(value); + } + return is; +} + +// Smart pointer Vector Implementation // + +template class SmartVector : public SmartPointer> { + typedef SmartPointer> Base; + +public: + SmartVector() : Base(new Vector()) {} + SmartVector(const SmartVector ©) : Base(copy) {} + SmartVector(unsigned int size) : Base(new Vector((int)size)) {} + + virtual ~SmartVector() {} + + T &operator[](int p) { return Base::get()->at(p); } + + void swap_elements(unsigned int first, unsigned int second) { + std::swap(Base::get()->at(first), Base::get()->at(second)); + } + + void remove_element(unsigned int index) { + std::swap(Base::get()->at(index), Base::get()->back()); + Base::get()->pop_back(); } void remove_element(T &t) { std::swap(t, Base::get()->back()); Base::get()->pop_back(); - } + } }; - - - // ------ Utils ------------------------------------------------------------- // - - // RIFARE con iteratore ! template -inline const unsigned long -VectorSplice(const _Tp &_it, const _Tp &_end, const float value, _CmpT _comp) -{ - _Tp it = _it; - _Tp end = _end-1; - for(it; it != end;) - { - if (_comp(*it,value)) ++it; - else if(_comp(*end,value)) std::swap(*it,*end--); - else --end; - } - return it - _it; +inline unsigned long VectorSplice(const _Tp &_it, const _Tp &_end, + const float value, _CmpT _comp) { + _Tp it = _it; + _Tp end = _end - 1; + for (; it != end;) { + if (_comp(*it, value)) + ++it; + else if (_comp(*end, value)) + std::swap(*it, *end--); + else + --end; + } + return it - _it; } - - -} // uLib - - - - +} // namespace uLib #endif // VECTOR_H diff --git a/src/Core/test_meta_allocator.cpp b/src/Core/test_meta_allocator.cpp new file mode 100644 index 0000000..07571ac --- /dev/null +++ b/src/Core/test_meta_allocator.cpp @@ -0,0 +1,31 @@ +#include +#include + +int main() { + uLib::Vector v; + v.push_back(1); + v.push_back(2); + v.push_back(3); + + std::cout << "RAM Vector elements: "; + for (int i = 0; i < v.size(); ++i) { + std::cout << v[i] << " "; + } + std::cout << std::endl; + +#ifdef USE_CUDA + std::cout << "Moving to VRAM..." << std::endl; + v.MoveToVRAM(); + int *vram_ptr = v.GetVRAMData(); + if (vram_ptr) { + std::cout << "Successfully got VRAM pointer!" << std::endl; + } else { + std::cout << "Failed to get VRAM pointer!" << std::endl; + } + + std::cout << "Moving back to RAM..." << std::endl; + v.MoveToRAM(); +#endif + + return 0; +} diff --git a/src/Core/testing/CMakeLists.txt b/src/Core/testing/CMakeLists.txt index ef61f24..82dc679 100644 --- a/src/Core/testing/CMakeLists.txt +++ b/src/Core/testing/CMakeLists.txt @@ -20,6 +20,7 @@ set( TESTS TypeIntrospectionTraversal OptionsTest PingPongTest + VectorMetaAllocatorTest ) set(LIBRARIES diff --git a/src/Core/testing/VectorMetaAllocatorTest.cpp b/src/Core/testing/VectorMetaAllocatorTest.cpp new file mode 100644 index 0000000..c75a643 --- /dev/null +++ b/src/Core/testing/VectorMetaAllocatorTest.cpp @@ -0,0 +1,71 @@ +/*////////////////////////////////////////////////////////////////////////////// +// CMT Cosmic Muon Tomography project ////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova + All rights reserved + + Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it > + +//////////////////////////////////////////////////////////////////////////////*/ + +#include "testing-prototype.h" +#include + +int main() { + BEGIN_TESTING(VectorMetaAllocator); + + uLib::Vector v; + std::cout << "Pushing elements...\n"; + v << 1, 2, 3, 4, 5; + + std::cout << "Initial RAM contents: "; + for (size_t i = 0; i < v.size(); ++i) { + std::cout << v[i] << " "; + if (v[i] != (int)(i + 1)) { + std::cout << "\nError: Value mismatch at index " << i << "\n"; + exit(1); + } + } + std::cout << "\n"; + +#ifdef USE_CUDA + std::cout << "Moving to VRAM...\n"; + v.MoveToVRAM(); + + int *vram_ptr = v.GetVRAMData(); + if (vram_ptr) { + std::cout << "Successfully obtained VRAM pointer: " << vram_ptr << "\n"; + } else { + std::cout << "Error: Failed to obtain VRAM pointer!\n"; + exit(1); + } + + std::cout << "Moving back to RAM...\n"; + v.MoveToRAM(); + + std::cout << "RAM contents after VRAM trip: "; + for (size_t i = 0; i < v.size(); ++i) { + std::cout << v[i] << " "; + if (v[i] != (int)(i + 1)) { + std::cout << "\nError: Data corrupted after RAM->VRAM->RAM trip at index " + << i << "\n"; + exit(1); + } + } + std::cout << "\n"; +#else + std::cout << "USE_CUDA not defined, skipping VRAM tests.\n"; +#endif + + std::cout << "Scaling vector...\n"; + for (size_t i = 0; i < v.size(); ++i) + v[i] *= 10; + + std::cout << "Final contents: "; + for (size_t i = 0; i < v.size(); ++i) + std::cout << v[i] << " "; + std::cout << "\n"; + + END_TESTING; +} diff --git a/src/Core/testing/VectorTest.cpp b/src/Core/testing/VectorTest.cpp index 6fee192..14324f4 100644 --- a/src/Core/testing/VectorTest.cpp +++ b/src/Core/testing/VectorTest.cpp @@ -23,62 +23,47 @@ //////////////////////////////////////////////////////////////////////////////*/ - - -#include #include "testing-prototype.h" +#include #include -template < typename T > -struct __Cmp { - bool operator()(const T &data, const float value) { - return data <= value; - } +template struct __Cmp { + bool operator()(const T &data, const float value) { return data <= value; } }; +template +inline const unsigned long VectorSplice(const _Tp &_it, const _Tp &_end, + const float value, _CmpT _comp) { - - -template -inline const unsigned long -VectorSplice(const _Tp &_it, const _Tp &_end, const float value, _CmpT _comp) - { - - _Tp it = _it; - _Tp end = _end-1; - for(it; it != end; ) - { - if ( _comp(*it, value) ) it++; - else if( _comp(*end, value) ) - { - std::swap(*it,*end--); - } - else --end; - } - return it - _it; + _Tp it = _it; + _Tp end = _end - 1; + for (it; it != end;) { + if (_comp(*it, value)) + it++; + else if (_comp(*end, value)) { + std::swap(*it, *end--); + } else + --end; + } + return it - _it; } +int main() { + BEGIN_TESTING(Vector); -int main() -{ - BEGIN_TESTING(Vector); + uLib::Vector v; + v << 5, 4, 3, 2, 6, 1, 2, 3, 65, 7, 32, 23, 4, 3, 45, 4, 34, 3, 4, 4, 3, 3, 4, + 2, 2, 3; - uLib::Vector v; - v << 5,4,3,2,6,1,2,3,65,7,32,23,4,3,45,4,34,3,4,4,3,3,4,2,2,3; + int id = ::VectorSplice(v.begin(), v.end(), 3, __Cmp()); + std::cout << "id: " << id << "\n"; + std::cout << "vector: "; + for (uLib::Vector::Iterator it = v.begin(); it != v.end(); it++) + std::cout << *it << " "; + std::cout << std::endl; + // std::sort(v.begin(),v.end(),LT()); - - int id = VectorSplice(v.begin(),v.end(),3,__Cmp()); - - std::cout << "id: " << id << "\n"; - std::cout << "vector: "; - for(uLib::Vector::Iterator it = v.begin(); it!=v.end(); it++) - std::cout << *it <<" "; - std::cout << std::endl; -// std::sort(v.begin(),v.end(),LT()); - - - END_TESTING; + END_TESTING; } - diff --git a/src/Math/VoxImage.h b/src/Math/VoxImage.h index 7c98d89..7edd3c4 100644 --- a/src/Math/VoxImage.h +++ b/src/Math/VoxImage.h @@ -34,7 +34,7 @@ #include #include -#include "Math/DataAllocator.h" +#include namespace uLib { diff --git a/src/Math/VoxRaytracer.h b/src/Math/VoxRaytracer.h index 39e8ea7..098c7da 100644 --- a/src/Math/VoxRaytracer.h +++ b/src/Math/VoxRaytracer.h @@ -26,7 +26,8 @@ #ifndef VOXRAYTRACER_H #define VOXRAYTRACER_H -#include "Math/DataAllocator.h" +#include +#include #include #include @@ -56,9 +57,9 @@ public: void AppendRay(const RayData &in); - inline DataAllocator &Data() { return this->m_Data; } + inline uLib::Vector &Data() { return this->m_Data; } - inline const DataAllocator &Data() const { return this->m_Data; } + inline const uLib::Vector &Data() const { return this->m_Data; } inline size_t Count() const { return this->m_Count; } @@ -71,7 +72,7 @@ public: void PrintSelf(std::ostream &o); private: - DataAllocator m_Data; + uLib::Vector m_Data; Scalarf m_TotalLength; size_t m_Count; };