From 4cbe471a833256d418783cd8e50d3c69c54f0c5d Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Wed, 15 Nov 2023 18:00:07 -0500 Subject: [PATCH] devVector --- Grid/allocator/AlignedAllocator.h | 52 +++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/Grid/allocator/AlignedAllocator.h b/Grid/allocator/AlignedAllocator.h index 91622789..8a27f527 100644 --- a/Grid/allocator/AlignedAllocator.h +++ b/Grid/allocator/AlignedAllocator.h @@ -175,8 +175,56 @@ template using cshiftAllocator = std::allocator; template using Vector = std::vector >; template using stencilVector = std::vector >; -template using commVector = std::vector >; -template using cshiftVector = std::vector >; +template using commVector = std::vector >; +template using deviceVector = std::vector >; +template using cshiftVector = std::vector >; + +/* +template 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 &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 vecView VectorView(std::vector &vec,ViewMode _mode) +{ + vecView ret(vec,_mode); // does the open + return ret; // must be closed +} + +// Little autoscope assister +template +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 _autoView##v_v(v_v); +*/ NAMESPACE_END(Grid);