Loading src/TNL/DevicePointer.h +10 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Object* operator->() { this->pd->maybe_modified = true; return this->pointer; } Loading @@ -280,6 +281,7 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Object& operator *() { this->pd->maybe_modified = true; return *( this->pointer ); } Loading Loading @@ -311,7 +313,10 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Assert( this->pd, ); Assert( this->cuda_pointer, ); if( std::is_same< Device, Devices::Host >::value ) { this->pd->maybe_modified = true; return *( this->pointer ); } if( std::is_same< Device, Devices::Cuda >::value ) return *( this->cuda_pointer ); } Loading Loading @@ -402,6 +407,7 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer { char data_image[ sizeof(Object) ]; int counter = 1; bool maybe_modified = false; }; bool allocate( ObjectType& obj ) Loading @@ -425,12 +431,16 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Assert( this->pointer, ); Assert( this->pd, ); std::memcpy( (void*) &this->pd->data_image, (void*) this->pointer, sizeof( Object ) ); this->pd->maybe_modified = false; } bool modified() { Assert( this->pointer, ); Assert( this->pd, ); // optimization: skip bitwise comparison if we're sure that the data is the same if( ! this->pd->maybe_modified ) return false; return std::memcmp( (void*) &this->pd->data_image, (void*) this->pointer, sizeof( Object ) ) != 0; } Loading src/TNL/SharedPointer.h +12 −1 Original line number Diff line number Diff line Loading @@ -387,6 +387,7 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Object* operator->() { this->pd->maybe_modified = true; return &this->pd->data; } Loading @@ -397,6 +398,7 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Object& operator *() { this->pd->maybe_modified = true; return this->pd->data; } Loading Loading @@ -426,7 +428,10 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Assert( this->pd, ); Assert( this->cuda_pointer, ); if( std::is_same< Device, Devices::Host >::value ) { this->pd->maybe_modified = true; return this->pd->data; } if( std::is_same< Device, Devices::Cuda >::value ) return *( this->cuda_pointer ); } Loading Loading @@ -527,11 +532,13 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Object data; char data_image[ sizeof(Object) ]; int counter; bool maybe_modified; template< typename... Args > explicit PointerData( Args... args ) : data( args... ), counter( 1 ) counter( 1 ), maybe_modified( false ) {} }; Loading @@ -558,11 +565,15 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer { Assert( this->pd, ); std::memcpy( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( Object ) ); this->pd->maybe_modified = false; } bool modified() { Assert( this->pd, ); // optimization: skip bitwise comparison if we're sure that the data is the same if( ! this->pd->maybe_modified ) return false; return std::memcmp( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( Object ) ) != 0; } Loading src/TNL/UniquePointer.h +12 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer Object* operator->() { this->pd->maybe_modified = true; return &this->pd->data; } Loading @@ -148,6 +149,7 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer Object& operator *() { this->pd->maybe_modified = true; return this->pd->data; } Loading Loading @@ -175,7 +177,10 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer Assert( this->pd, ); Assert( this->cuda_pointer, ); if( std::is_same< Device, Devices::Host >::value ) { this->pd->maybe_modified = true; return this->pd->data; } if( std::is_same< Device, Devices::Cuda >::value ) return *( this->cuda_pointer ); } Loading Loading @@ -226,10 +231,12 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer { Object data; char data_image[ sizeof(Object) ]; bool maybe_modified; template< typename... Args > explicit PointerData( Args... args ) : data( args... ) : data( args... ), maybe_modified( false ) {} }; Loading @@ -253,11 +260,15 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer { Assert( this->pd, ); std::memcpy( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( ObjectType ) ); this->pd->maybe_modified = false; } bool modified() { Assert( this->pd, ); // optimization: skip bitwise comparison if we're sure that the data is the same if( ! this->pd->maybe_modified ) return false; return std::memcmp( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( ObjectType ) ) != 0; } Loading Loading
src/TNL/DevicePointer.h +10 −0 Original line number Diff line number Diff line Loading @@ -270,6 +270,7 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Object* operator->() { this->pd->maybe_modified = true; return this->pointer; } Loading @@ -280,6 +281,7 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Object& operator *() { this->pd->maybe_modified = true; return *( this->pointer ); } Loading Loading @@ -311,7 +313,10 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Assert( this->pd, ); Assert( this->cuda_pointer, ); if( std::is_same< Device, Devices::Host >::value ) { this->pd->maybe_modified = true; return *( this->pointer ); } if( std::is_same< Device, Devices::Cuda >::value ) return *( this->cuda_pointer ); } Loading Loading @@ -402,6 +407,7 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer { char data_image[ sizeof(Object) ]; int counter = 1; bool maybe_modified = false; }; bool allocate( ObjectType& obj ) Loading @@ -425,12 +431,16 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer Assert( this->pointer, ); Assert( this->pd, ); std::memcpy( (void*) &this->pd->data_image, (void*) this->pointer, sizeof( Object ) ); this->pd->maybe_modified = false; } bool modified() { Assert( this->pointer, ); Assert( this->pd, ); // optimization: skip bitwise comparison if we're sure that the data is the same if( ! this->pd->maybe_modified ) return false; return std::memcmp( (void*) &this->pd->data_image, (void*) this->pointer, sizeof( Object ) ) != 0; } Loading
src/TNL/SharedPointer.h +12 −1 Original line number Diff line number Diff line Loading @@ -387,6 +387,7 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Object* operator->() { this->pd->maybe_modified = true; return &this->pd->data; } Loading @@ -397,6 +398,7 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Object& operator *() { this->pd->maybe_modified = true; return this->pd->data; } Loading Loading @@ -426,7 +428,10 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Assert( this->pd, ); Assert( this->cuda_pointer, ); if( std::is_same< Device, Devices::Host >::value ) { this->pd->maybe_modified = true; return this->pd->data; } if( std::is_same< Device, Devices::Cuda >::value ) return *( this->cuda_pointer ); } Loading Loading @@ -527,11 +532,13 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer Object data; char data_image[ sizeof(Object) ]; int counter; bool maybe_modified; template< typename... Args > explicit PointerData( Args... args ) : data( args... ), counter( 1 ) counter( 1 ), maybe_modified( false ) {} }; Loading @@ -558,11 +565,15 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer { Assert( this->pd, ); std::memcpy( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( Object ) ); this->pd->maybe_modified = false; } bool modified() { Assert( this->pd, ); // optimization: skip bitwise comparison if we're sure that the data is the same if( ! this->pd->maybe_modified ) return false; return std::memcmp( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( Object ) ) != 0; } Loading
src/TNL/UniquePointer.h +12 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer Object* operator->() { this->pd->maybe_modified = true; return &this->pd->data; } Loading @@ -148,6 +149,7 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer Object& operator *() { this->pd->maybe_modified = true; return this->pd->data; } Loading Loading @@ -175,7 +177,10 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer Assert( this->pd, ); Assert( this->cuda_pointer, ); if( std::is_same< Device, Devices::Host >::value ) { this->pd->maybe_modified = true; return this->pd->data; } if( std::is_same< Device, Devices::Cuda >::value ) return *( this->cuda_pointer ); } Loading Loading @@ -226,10 +231,12 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer { Object data; char data_image[ sizeof(Object) ]; bool maybe_modified; template< typename... Args > explicit PointerData( Args... args ) : data( args... ) : data( args... ), maybe_modified( false ) {} }; Loading @@ -253,11 +260,15 @@ class UniquePointer< Object, Devices::Cuda > : public SmartPointer { Assert( this->pd, ); std::memcpy( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( ObjectType ) ); this->pd->maybe_modified = false; } bool modified() { Assert( this->pd, ); // optimization: skip bitwise comparison if we're sure that the data is the same if( ! this->pd->maybe_modified ) return false; return std::memcmp( (void*) &this->pd->data_image, (void*) &this->pd->data, sizeof( ObjectType ) ) != 0; } Loading