mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-14 01:35:36 +00:00
devVector
This commit is contained in:
parent
8bece1f861
commit
4cbe471a83
@ -176,8 +176,56 @@ template<class T> using cshiftAllocator = std::allocator<T>;
|
|||||||
template<class T> using Vector = std::vector<T,uvmAllocator<T> >;
|
template<class T> using Vector = std::vector<T,uvmAllocator<T> >;
|
||||||
template<class T> using stencilVector = std::vector<T,alignedAllocator<T> >;
|
template<class T> using stencilVector = std::vector<T,alignedAllocator<T> >;
|
||||||
template<class T> using commVector = std::vector<T,devAllocator<T> >;
|
template<class T> using commVector = std::vector<T,devAllocator<T> >;
|
||||||
|
template<class T> using deviceVector = std::vector<T,devAllocator<T> >;
|
||||||
template<class T> using cshiftVector = std::vector<T,cshiftAllocator<T> >;
|
template<class T> using cshiftVector = std::vector<T,cshiftAllocator<T> >;
|
||||||
|
|
||||||
|
/*
|
||||||
|
template<class T> class vecView
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
T * data;
|
||||||
|
uint64_t size;
|
||||||
|
ViewMode mode;
|
||||||
|
void * cpu_ptr;
|
||||||
|
public:
|
||||||
|
accelerator_inline T & operator[](size_t i) const { return this->data[i]; };
|
||||||
|
vecView(std::vector<T> &refer_to_me,ViewMode _mode)
|
||||||
|
{
|
||||||
|
cpu_ptr = &refer_to_me[0];
|
||||||
|
size = refer_to_me.size();
|
||||||
|
mode = _mode;
|
||||||
|
data =(T *) MemoryManager::ViewOpen(cpu_ptr,
|
||||||
|
size*sizeof(T),
|
||||||
|
mode,
|
||||||
|
AdviseDefault);
|
||||||
|
}
|
||||||
|
void ViewClose(void)
|
||||||
|
{ // Inform the manager
|
||||||
|
MemoryManager::ViewClose(this->cpu_ptr,this->mode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T> vecView<T> VectorView(std::vector<T> &vec,ViewMode _mode)
|
||||||
|
{
|
||||||
|
vecView<T> ret(vec,_mode); // does the open
|
||||||
|
return ret; // must be closed
|
||||||
|
}
|
||||||
|
|
||||||
|
// Little autoscope assister
|
||||||
|
template<class View>
|
||||||
|
class VectorViewCloser
|
||||||
|
{
|
||||||
|
View v; // Take a copy of view and call view close when I go out of scope automatically
|
||||||
|
public:
|
||||||
|
VectorViewCloser(View &_v) : v(_v) {};
|
||||||
|
~VectorViewCloser() { auto ptr = v.cpu_ptr; v.ViewClose(); MemoryManager::NotifyDeletion(ptr);}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define autoVecView(v_v,v,mode) \
|
||||||
|
auto v_v = VectorView(v,mode); \
|
||||||
|
ViewCloser<decltype(v_v)> _autoView##v_v(v_v);
|
||||||
|
*/
|
||||||
|
|
||||||
NAMESPACE_END(Grid);
|
NAMESPACE_END(Grid);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user