mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-15 10:15:36 +00:00
Optional bounds check debug code
This commit is contained in:
parent
569f78c2cf
commit
e1327e7ea0
@ -52,6 +52,7 @@ public:
|
|||||||
// This will be safe to call from accelerator_for and is trivially copy constructible
|
// This will be safe to call from accelerator_for and is trivially copy constructible
|
||||||
// The copy constructor for this will need to be used by device lambda functions
|
// The copy constructor for this will need to be used by device lambda functions
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef LATTICE_BOUNDS_CHECK
|
||||||
template<class vobj>
|
template<class vobj>
|
||||||
class LatticeView : public LatticeAccelerator<vobj>
|
class LatticeView : public LatticeAccelerator<vobj>
|
||||||
{
|
{
|
||||||
@ -61,14 +62,36 @@ public:
|
|||||||
void * cpu_ptr;
|
void * cpu_ptr;
|
||||||
#ifdef GRID_SIMT
|
#ifdef GRID_SIMT
|
||||||
accelerator_inline const typename vobj::scalar_object operator()(size_t i) const {
|
accelerator_inline const typename vobj::scalar_object operator()(size_t i) const {
|
||||||
|
#ifdef LATTICE_BOUNDS_CHECK
|
||||||
|
assert(i<this->_odata_size);
|
||||||
|
assert(i>=0);
|
||||||
|
#endif
|
||||||
return coalescedRead(this->_odata[i]);
|
return coalescedRead(this->_odata[i]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
accelerator_inline const vobj & operator()(size_t i) const { return this->_odata[i]; }
|
accelerator_inline const vobj & operator()(size_t i) const {
|
||||||
|
#ifdef LATTICE_BOUNDS_CHECK
|
||||||
|
assert(i<this->_odata_size);
|
||||||
|
assert(i>=0);
|
||||||
|
#endif
|
||||||
|
return this->_odata[i];
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
accelerator_inline const vobj & operator[](size_t i) const { return this->_odata[i]; };
|
accelerator_inline const vobj & operator[](size_t i) const {
|
||||||
accelerator_inline vobj & operator[](size_t i) { return this->_odata[i]; };
|
#ifdef LATTICE_BOUNDS_CHECK
|
||||||
|
assert(i<this->_odata_size);
|
||||||
|
assert(i>=0);
|
||||||
|
#endif
|
||||||
|
return this->_odata[i];
|
||||||
|
};
|
||||||
|
accelerator_inline vobj & operator[](size_t i) {
|
||||||
|
#ifdef LATTICE_BOUNDS_CHECK
|
||||||
|
assert(i<this->_odata_size);
|
||||||
|
assert(i>=0);
|
||||||
|
#endif
|
||||||
|
return this->_odata[i];
|
||||||
|
};
|
||||||
|
|
||||||
accelerator_inline uint64_t begin(void) const { return 0;};
|
accelerator_inline uint64_t begin(void) const { return 0;};
|
||||||
accelerator_inline uint64_t end(void) const { return this->_odata_size; };
|
accelerator_inline uint64_t end(void) const { return this->_odata_size; };
|
||||||
|
Loading…
Reference in New Issue
Block a user