Loading src/TNL/Containers/Algorithms/ArrayOperations.h +7 −10 Original line number Diff line number Diff line Loading @@ -14,8 +14,6 @@ #include <TNL/Devices/Cuda.h> #include <TNL/Devices/MIC.h> #include <iostream> namespace TNL { namespace Containers { namespace Algorithms { Loading @@ -30,11 +28,11 @@ class ArrayOperations< Devices::Host > public: template< typename Element, typename Index > static bool allocateMemory( Element*& data, static void allocateMemory( Element*& data, const Index size ); template< typename Element > static bool freeMemory( Element* data ); static void freeMemory( Element* data ); template< typename Element > static void setMemoryElement( Element* data, Loading Loading @@ -76,11 +74,11 @@ class ArrayOperations< Devices::Cuda > public: template< typename Element, typename Index > static bool allocateMemory( Element*& data, static void allocateMemory( Element*& data, const Index size ); template< typename Element > static bool freeMemory( Element* data ); static void freeMemory( Element* data ); template< typename Element > static void setMemoryElement( Element* data, Loading Loading @@ -163,11 +161,11 @@ class ArrayOperations< Devices::MIC > public: template< typename Element, typename Index > static bool allocateMemory( Element*& data, static void allocateMemory( Element*& data, const Index size ); template< typename Element > static bool freeMemory( Element* data ); static void freeMemory( Element* data ); template< typename Element > static void setMemoryElement( Element* data, Loading Loading @@ -242,7 +240,6 @@ class ArrayOperations< Devices::Host, Devices::MIC > const Index size ); }; } // namespace Algorithms } // namespace Containers } // namespace TNL Loading src/TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h +4 −4 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ namespace Containers { namespace Algorithms { template< typename Element, typename Index > bool void ArrayOperations< Devices::Cuda >:: allocateMemory( Element*& data, const Index size ) Loading @@ -38,14 +38,14 @@ allocateMemory( Element*& data, data = 0; throw Exceptions::CudaBadAlloc(); } return TNL_CHECK_CUDA_DEVICE; TNL_CHECK_CUDA_DEVICE; #else throw Exceptions::CudaSupportMissing(); #endif } template< typename Element > bool void ArrayOperations< Devices::Cuda >:: freeMemory( Element* data ) { Loading @@ -53,7 +53,7 @@ freeMemory( Element* data ) #ifdef HAVE_CUDA TNL_CHECK_CUDA_DEVICE; cudaFree( data ); return TNL_CHECK_CUDA_DEVICE; TNL_CHECK_CUDA_DEVICE; #else throw Exceptions::CudaSupportMissing(); #endif Loading src/TNL/Containers/Algorithms/ArrayOperationsHost_impl.h +2 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ namespace Containers { namespace Algorithms { template< typename Element, typename Index > bool void ArrayOperations< Devices::Host >:: allocateMemory( Element*& data, const Index size ) Loading @@ -32,16 +32,14 @@ allocateMemory( Element*& data, // https://stackoverflow.com/questions/550451/will-new-return-null-in-any-case TNL_ASSERT_TRUE( data, "Operator 'new' returned a nullptr. This should never happen - there is " "either a bug or the compiler does not comply to the standard." ); return true; } template< typename Element > bool void ArrayOperations< Devices::Host >:: freeMemory( Element* data ) { delete[] data; return true; } template< typename Element > Loading src/TNL/Containers/Algorithms/ArrayOperationsMIC_impl.h +188 −195 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #include <TNL/tnlConfig.h> #include <TNL/Math.h> #include <TNL/Exceptions/MICSupportMissing.h> #include <TNL/Exceptions/MICBadAlloc.h> #include <TNL/Containers/Algorithms/ArrayOperations.h> #include <TNL/Containers/Algorithms/Reduction.h> #include <TNL/Containers/Algorithms/reduction-operations.h> Loading @@ -28,35 +30,30 @@ namespace Algorithms { template< typename Element, typename Index > bool void ArrayOperations< Devices::MIC >:: allocateMemory( Element*& data, const Index size ) { #ifdef HAVE_MIC data = (Element*) Devices::MIC::AllocMIC( size * sizeof(Element) ); if(data) return true; else return false; if( ! data ) throw Exceptions::MICBadAlloc(); #else MICSupportMissingMessage; return false; throw Exceptions::MICSupportMissing(); #endif } template< typename Element > bool void ArrayOperations< Devices::MIC >:: freeMemory( Element* data ) { TNL_ASSERT( data, ); #ifdef HAVE_MIC Devices::MIC::FreeMIC( data ); return true; #else MICSupportMissingMessage;; true; throw Exceptions::MICSupportMissing(); #endif } Loading Loading @@ -119,8 +116,7 @@ setMemory( Element* data, } return true; #else MICSupportMissingMessage;; return false; throw Exceptions::MICSupportMissing(); #endif } Loading Loading @@ -163,7 +159,7 @@ copyMemory( DestinationElement* destination, } #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } Loading Loading @@ -214,10 +210,10 @@ compareMemory( const Element1* destination, } return ret; } return false; #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } /**** Loading Loading @@ -297,10 +293,10 @@ copyMemory( DestinationElement* destination, return true; } } return false; #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } Loading Loading @@ -343,8 +339,7 @@ compareMemory( const Element1* destination, } return true; #else MICSupportMissingMessage; return false; throw Exceptions::MICSupportMissing(); #endif } Loading Loading @@ -424,10 +419,10 @@ copyMemory( DestinationElement* destination, return true; } } return false; #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } template< typename Element1, Loading @@ -445,8 +440,6 @@ compareMemory( const Element1* hostData, return ArrayOperations< Devices::Host, Devices::MIC >::compareMemory( deviceData, hostData, size ); } } // namespace Algorithms } // namespace Containers } // namespace TNL src/TNL/Containers/Algorithms/VectorOperationsCuda_impl.h +2 −2 Original line number Diff line number Diff line Loading @@ -608,7 +608,7 @@ computePrefixSum( Vector& v, &v.getData()[ begin ], &v.getData()[ begin ], operation, Algorithms::inclusivePrefixSum ); Algorithms::PrefixSumType::inclusive ); #else throw Exceptions::CudaSupportMissing(); #endif Loading @@ -633,7 +633,7 @@ computeExclusivePrefixSum( Vector& v, &v.getData()[ begin ], &v.getData()[ begin ], operation, Algorithms::exclusivePrefixSum ); Algorithms::PrefixSumType::exclusive ); #endif } Loading Loading
src/TNL/Containers/Algorithms/ArrayOperations.h +7 −10 Original line number Diff line number Diff line Loading @@ -14,8 +14,6 @@ #include <TNL/Devices/Cuda.h> #include <TNL/Devices/MIC.h> #include <iostream> namespace TNL { namespace Containers { namespace Algorithms { Loading @@ -30,11 +28,11 @@ class ArrayOperations< Devices::Host > public: template< typename Element, typename Index > static bool allocateMemory( Element*& data, static void allocateMemory( Element*& data, const Index size ); template< typename Element > static bool freeMemory( Element* data ); static void freeMemory( Element* data ); template< typename Element > static void setMemoryElement( Element* data, Loading Loading @@ -76,11 +74,11 @@ class ArrayOperations< Devices::Cuda > public: template< typename Element, typename Index > static bool allocateMemory( Element*& data, static void allocateMemory( Element*& data, const Index size ); template< typename Element > static bool freeMemory( Element* data ); static void freeMemory( Element* data ); template< typename Element > static void setMemoryElement( Element* data, Loading Loading @@ -163,11 +161,11 @@ class ArrayOperations< Devices::MIC > public: template< typename Element, typename Index > static bool allocateMemory( Element*& data, static void allocateMemory( Element*& data, const Index size ); template< typename Element > static bool freeMemory( Element* data ); static void freeMemory( Element* data ); template< typename Element > static void setMemoryElement( Element* data, Loading Loading @@ -242,7 +240,6 @@ class ArrayOperations< Devices::Host, Devices::MIC > const Index size ); }; } // namespace Algorithms } // namespace Containers } // namespace TNL Loading
src/TNL/Containers/Algorithms/ArrayOperationsCuda_impl.h +4 −4 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ namespace Containers { namespace Algorithms { template< typename Element, typename Index > bool void ArrayOperations< Devices::Cuda >:: allocateMemory( Element*& data, const Index size ) Loading @@ -38,14 +38,14 @@ allocateMemory( Element*& data, data = 0; throw Exceptions::CudaBadAlloc(); } return TNL_CHECK_CUDA_DEVICE; TNL_CHECK_CUDA_DEVICE; #else throw Exceptions::CudaSupportMissing(); #endif } template< typename Element > bool void ArrayOperations< Devices::Cuda >:: freeMemory( Element* data ) { Loading @@ -53,7 +53,7 @@ freeMemory( Element* data ) #ifdef HAVE_CUDA TNL_CHECK_CUDA_DEVICE; cudaFree( data ); return TNL_CHECK_CUDA_DEVICE; TNL_CHECK_CUDA_DEVICE; #else throw Exceptions::CudaSupportMissing(); #endif Loading
src/TNL/Containers/Algorithms/ArrayOperationsHost_impl.h +2 −4 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ namespace Containers { namespace Algorithms { template< typename Element, typename Index > bool void ArrayOperations< Devices::Host >:: allocateMemory( Element*& data, const Index size ) Loading @@ -32,16 +32,14 @@ allocateMemory( Element*& data, // https://stackoverflow.com/questions/550451/will-new-return-null-in-any-case TNL_ASSERT_TRUE( data, "Operator 'new' returned a nullptr. This should never happen - there is " "either a bug or the compiler does not comply to the standard." ); return true; } template< typename Element > bool void ArrayOperations< Devices::Host >:: freeMemory( Element* data ) { delete[] data; return true; } template< typename Element > Loading
src/TNL/Containers/Algorithms/ArrayOperationsMIC_impl.h +188 −195 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ #include <TNL/tnlConfig.h> #include <TNL/Math.h> #include <TNL/Exceptions/MICSupportMissing.h> #include <TNL/Exceptions/MICBadAlloc.h> #include <TNL/Containers/Algorithms/ArrayOperations.h> #include <TNL/Containers/Algorithms/Reduction.h> #include <TNL/Containers/Algorithms/reduction-operations.h> Loading @@ -28,35 +30,30 @@ namespace Algorithms { template< typename Element, typename Index > bool void ArrayOperations< Devices::MIC >:: allocateMemory( Element*& data, const Index size ) { #ifdef HAVE_MIC data = (Element*) Devices::MIC::AllocMIC( size * sizeof(Element) ); if(data) return true; else return false; if( ! data ) throw Exceptions::MICBadAlloc(); #else MICSupportMissingMessage; return false; throw Exceptions::MICSupportMissing(); #endif } template< typename Element > bool void ArrayOperations< Devices::MIC >:: freeMemory( Element* data ) { TNL_ASSERT( data, ); #ifdef HAVE_MIC Devices::MIC::FreeMIC( data ); return true; #else MICSupportMissingMessage;; true; throw Exceptions::MICSupportMissing(); #endif } Loading Loading @@ -119,8 +116,7 @@ setMemory( Element* data, } return true; #else MICSupportMissingMessage;; return false; throw Exceptions::MICSupportMissing(); #endif } Loading Loading @@ -163,7 +159,7 @@ copyMemory( DestinationElement* destination, } #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } Loading Loading @@ -214,10 +210,10 @@ compareMemory( const Element1* destination, } return ret; } return false; #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } /**** Loading Loading @@ -297,10 +293,10 @@ copyMemory( DestinationElement* destination, return true; } } return false; #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } Loading Loading @@ -343,8 +339,7 @@ compareMemory( const Element1* destination, } return true; #else MICSupportMissingMessage; return false; throw Exceptions::MICSupportMissing(); #endif } Loading Loading @@ -424,10 +419,10 @@ copyMemory( DestinationElement* destination, return true; } } return false; #else MICSupportMissingMessage;; throw Exceptions::MICSupportMissing(); #endif return false; } template< typename Element1, Loading @@ -445,8 +440,6 @@ compareMemory( const Element1* hostData, return ArrayOperations< Devices::Host, Devices::MIC >::compareMemory( deviceData, hostData, size ); } } // namespace Algorithms } // namespace Containers } // namespace TNL
src/TNL/Containers/Algorithms/VectorOperationsCuda_impl.h +2 −2 Original line number Diff line number Diff line Loading @@ -608,7 +608,7 @@ computePrefixSum( Vector& v, &v.getData()[ begin ], &v.getData()[ begin ], operation, Algorithms::inclusivePrefixSum ); Algorithms::PrefixSumType::inclusive ); #else throw Exceptions::CudaSupportMissing(); #endif Loading @@ -633,7 +633,7 @@ computeExclusivePrefixSum( Vector& v, &v.getData()[ begin ], &v.getData()[ begin ], operation, Algorithms::exclusivePrefixSum ); Algorithms::PrefixSumType::exclusive ); #endif } Loading