feat: Implement a custom MetaAllocator for uLib::Vector to enable GPU memory management and integrate CUDA support into the build system.
This commit is contained in:
@@ -23,62 +23,47 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include <Core/Vector.h>
|
||||
#include "testing-prototype.h"
|
||||
#include <Core/Vector.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
template < typename T >
|
||||
struct __Cmp {
|
||||
bool operator()(const T &data, const float value) {
|
||||
return data <= value;
|
||||
}
|
||||
template <typename T> struct __Cmp {
|
||||
bool operator()(const T &data, const float value) { return data <= value; }
|
||||
};
|
||||
|
||||
template <typename _Tp, typename _CmpT>
|
||||
inline const unsigned long VectorSplice(const _Tp &_it, const _Tp &_end,
|
||||
const float value, _CmpT _comp) {
|
||||
|
||||
|
||||
|
||||
template<typename _Tp, typename _CmpT>
|
||||
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<float> 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<float> 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<float>());
|
||||
|
||||
std::cout << "id: " << id << "\n";
|
||||
std::cout << "vector: ";
|
||||
for (uLib::Vector<float>::Iterator it = v.begin(); it != v.end(); it++)
|
||||
std::cout << *it << " ";
|
||||
std::cout << std::endl;
|
||||
// std::sort(v.begin(),v.end(),LT<float>());
|
||||
|
||||
|
||||
int id = VectorSplice(v.begin(),v.end(),3,__Cmp<float>());
|
||||
|
||||
std::cout << "id: " << id << "\n";
|
||||
std::cout << "vector: ";
|
||||
for(uLib::Vector<float>::Iterator it = v.begin(); it!=v.end(); it++)
|
||||
std::cout << *it <<" ";
|
||||
std::cout << std::endl;
|
||||
// std::sort(v.begin(),v.end(),LT<float>());
|
||||
|
||||
|
||||
END_TESTING;
|
||||
END_TESTING;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user