Loading src/core/tnlLongVectorCUDATester.cu +31 −2 Original line number Diff line number Diff line #include <cuda.h> #include <core/tnlString.h> #include <core/tnlLongVector.h> #include <core/tnlLongVectorCUDA.h> #include <core/tnlLongVectorCUDATester.h> __global__ void setZeros( float* A ) __global__ void setNumber( float* A, float c ) { int i = threadIdx. x; A[ i ] = 0.0; A[ i ] = c; } void testKernel() { tnlLongVectorCUDA< float > device_vector( 500 ); tnlLongVector< float > host_vector( 500 ); float* data = device_vector. Data(); setNumber<<< 1, 500 >>>( data, 0.0 ); host_vector. copyFrom( device_vector ); int errors( 0 ); for( int i = 0; i < 500; i ++ ) { if( host_vector[ i ] != 0.0 ) errors ++; cout << host_vector[ i ] << "-"; } CPPUNIT_ASSERT( ! errors ); setNumber<<< 1, 500 >>>( data, 1.0 ); host_vector. copyFrom( device_vector ); errors = 0; for( int i = 0; i < 500; i ++ ) { if( host_vector[ i ] != 1.0 ) errors ++; cout << host_vector[ i ] << "-"; } CPPUNIT_ASSERT( ! errors ); } No newline at end of file src/core/tnlLongVectorCUDATester.h +5 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ #include <core/tnlLongVector.h> #ifdef HAVE_CUDA __global__ void setZeros( float* A ); void testKernel(); #endif Loading Loading @@ -63,7 +63,10 @@ template< class T > class tnlLongVectorCUDATester : public CppUnit :: TestCase void testKernel() { #ifdef HAVE_CUDA :: testKernel(); #else cout << "CUDA is not supported." << endl; CPPUNIT_ASSERT( true ); #endif }; Loading Loading
src/core/tnlLongVectorCUDATester.cu +31 −2 Original line number Diff line number Diff line #include <cuda.h> #include <core/tnlString.h> #include <core/tnlLongVector.h> #include <core/tnlLongVectorCUDA.h> #include <core/tnlLongVectorCUDATester.h> __global__ void setZeros( float* A ) __global__ void setNumber( float* A, float c ) { int i = threadIdx. x; A[ i ] = 0.0; A[ i ] = c; } void testKernel() { tnlLongVectorCUDA< float > device_vector( 500 ); tnlLongVector< float > host_vector( 500 ); float* data = device_vector. Data(); setNumber<<< 1, 500 >>>( data, 0.0 ); host_vector. copyFrom( device_vector ); int errors( 0 ); for( int i = 0; i < 500; i ++ ) { if( host_vector[ i ] != 0.0 ) errors ++; cout << host_vector[ i ] << "-"; } CPPUNIT_ASSERT( ! errors ); setNumber<<< 1, 500 >>>( data, 1.0 ); host_vector. copyFrom( device_vector ); errors = 0; for( int i = 0; i < 500; i ++ ) { if( host_vector[ i ] != 1.0 ) errors ++; cout << host_vector[ i ] << "-"; } CPPUNIT_ASSERT( ! errors ); } No newline at end of file
src/core/tnlLongVectorCUDATester.h +5 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ #include <core/tnlLongVector.h> #ifdef HAVE_CUDA __global__ void setZeros( float* A ); void testKernel(); #endif Loading Loading @@ -63,7 +63,10 @@ template< class T > class tnlLongVectorCUDATester : public CppUnit :: TestCase void testKernel() { #ifdef HAVE_CUDA :: testKernel(); #else cout << "CUDA is not supported." << endl; CPPUNIT_ASSERT( true ); #endif }; Loading