Loading src/TNL/Pointers/SharedPointerCuda.h +15 −3 Original line number Diff line number Diff line Loading @@ -142,21 +142,25 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Object& operator *() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -176,6 +180,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer __cuda_callable__ const Object& getData() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -183,6 +188,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer __cuda_callable__ Object& modifyData() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading Loading @@ -397,22 +403,26 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); this->pd->maybe_modified = true; return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Object& operator *() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); this->pd->maybe_modified = true; return this->pd->data; } Loading Loading @@ -464,6 +474,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer this->free(); this->pd = (PointerData*) ptr.pd; this->cuda_pointer = ptr.cuda_pointer; if( this->pd != nullptr ) this->pd->counter += 1; #ifdef TNL_DEBUG_SHARED_POINTERS std::cerr << "Copy-assigned shared pointer: counter = " << this->pd->counter << ", type: " << demangle(typeid(ObjectType).name()) << std::endl; Loading @@ -479,6 +490,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer this->free(); this->pd = (PointerData*) ptr.pd; this->cuda_pointer = ptr.cuda_pointer; if( this->pd != nullptr ) this->pd->counter += 1; #ifdef TNL_DEBUG_SHARED_POINTERS std::cerr << "Copy-assigned shared pointer: counter = " << this->pd->counter << ", type: " << demangle(typeid(ObjectType).name()) << std::endl; Loading src/TNL/Pointers/SharedPointerHost.h +6 −0 Original line number Diff line number Diff line Loading @@ -114,21 +114,25 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Object& operator *() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -148,6 +152,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer __cuda_callable__ const Object& getData() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -155,6 +160,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer __cuda_callable__ Object& modifyData() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading src/TNL/Pointers/SharedPointerMic.h +3 −0 Original line number Diff line number Diff line Loading @@ -124,17 +124,20 @@ class SharedPointer< Object, Devices::MIC > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); this->pd->maybe_modified = true; return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading src/UnitTests/Pointers/SharedPointerCudaTest.cu +14 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,20 @@ TEST( SharedPointerCudaTest, getDataArrayTest ) #endif }; TEST( SharedPointerCudaTest, nullptrAssignement ) { #ifdef HAVE_CUDA using TestType = Pointers::SharedPointer< double, Devices::Cuda >; TestType p1( 5 ), p2( nullptr ); // This should not crash p1 = p2; ASSERT_FALSE( p1 ); ASSERT_FALSE( p2 ); #endif } #endif Loading src/UnitTests/Pointers/SharedPointerHostTest.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,19 @@ TEST( SharedPointerHostTest, ConstructorTest ) ASSERT_EQ( ptr1->x(), 1 ); ASSERT_EQ( ptr1->y(), 2 ); }; TEST( SharedPointerCudaTest, nullptrAssignement ) { using TestType = Pointers::SharedPointer< double, Devices::Host >; TestType p1( 5 ), p2( nullptr ); // This should not crash p1 = p2; ASSERT_FALSE( p1 ); ASSERT_FALSE( p2 ); } #endif #include "../GtestMissingError.h" Loading Loading
src/TNL/Pointers/SharedPointerCuda.h +15 −3 Original line number Diff line number Diff line Loading @@ -142,21 +142,25 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Object& operator *() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -176,6 +180,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer __cuda_callable__ const Object& getData() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -183,6 +188,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer __cuda_callable__ Object& modifyData() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading Loading @@ -397,22 +403,26 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); this->pd->maybe_modified = true; return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Object& operator *() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); this->pd->maybe_modified = true; return this->pd->data; } Loading Loading @@ -464,6 +474,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer this->free(); this->pd = (PointerData*) ptr.pd; this->cuda_pointer = ptr.cuda_pointer; if( this->pd != nullptr ) this->pd->counter += 1; #ifdef TNL_DEBUG_SHARED_POINTERS std::cerr << "Copy-assigned shared pointer: counter = " << this->pd->counter << ", type: " << demangle(typeid(ObjectType).name()) << std::endl; Loading @@ -479,6 +490,7 @@ class SharedPointer< Object, Devices::Cuda > : public SmartPointer this->free(); this->pd = (PointerData*) ptr.pd; this->cuda_pointer = ptr.cuda_pointer; if( this->pd != nullptr ) this->pd->counter += 1; #ifdef TNL_DEBUG_SHARED_POINTERS std::cerr << "Copy-assigned shared pointer: counter = " << this->pd->counter << ", type: " << demangle(typeid(ObjectType).name()) << std::endl; Loading
src/TNL/Pointers/SharedPointerHost.h +6 −0 Original line number Diff line number Diff line Loading @@ -114,21 +114,25 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Object& operator *() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -148,6 +152,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer __cuda_callable__ const Object& getData() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading @@ -155,6 +160,7 @@ class SharedPointer< Object, Devices::Host > : public SmartPointer __cuda_callable__ Object& modifyData() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading
src/TNL/Pointers/SharedPointerMic.h +3 −0 Original line number Diff line number Diff line Loading @@ -124,17 +124,20 @@ class SharedPointer< Object, Devices::MIC > : public SmartPointer const Object* operator->() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return &this->pd->data; } Object* operator->() { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); this->pd->maybe_modified = true; return &this->pd->data; } const Object& operator *() const { TNL_ASSERT( this->pd != nullptr, "Attempt of dereferencing of null pointer" ); return this->pd->data; } Loading
src/UnitTests/Pointers/SharedPointerCudaTest.cu +14 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,20 @@ TEST( SharedPointerCudaTest, getDataArrayTest ) #endif }; TEST( SharedPointerCudaTest, nullptrAssignement ) { #ifdef HAVE_CUDA using TestType = Pointers::SharedPointer< double, Devices::Cuda >; TestType p1( 5 ), p2( nullptr ); // This should not crash p1 = p2; ASSERT_FALSE( p1 ); ASSERT_FALSE( p2 ); #endif } #endif Loading
src/UnitTests/Pointers/SharedPointerHostTest.cpp +13 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,19 @@ TEST( SharedPointerHostTest, ConstructorTest ) ASSERT_EQ( ptr1->x(), 1 ); ASSERT_EQ( ptr1->y(), 2 ); }; TEST( SharedPointerCudaTest, nullptrAssignement ) { using TestType = Pointers::SharedPointer< double, Devices::Host >; TestType p1( 5 ), p2( nullptr ); // This should not crash p1 = p2; ASSERT_FALSE( p1 ); ASSERT_FALSE( p2 ); } #endif #include "../GtestMissingError.h" Loading