Commit 47da23bd authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixing tnlLongVectorCUDA and constructors of CUDA grids and fields.

parent 03235b52
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -399,7 +399,7 @@ bool tnlCUDAReduction( const int size,
    * If one calls the CUDA reduction more then once then one can provide
    * auxiliary array by passing it via the parameter deviceAux.
    */
   tnlLongVectorCUDA< T > deviceAuxVct;
   tnlLongVectorCUDA< T > deviceAuxVct( "tnlCUDAReduction:deviceAuxVct" );
   if( ! deviceAux )
   {
      int sizeAlloc = :: Max( 1, size / desBlockSize );
@@ -644,7 +644,7 @@ bool tnlCUDASimpleReduction5( const int size,
    * If one calls the CUDA reduction more then once then one can provide
    * auxiliary array by passing it via the parameter deviceAux.
    */
   tnlLongVectorCUDA< T > deviceAuxVct;
   tnlLongVectorCUDA< T > deviceAuxVct( "tnlCUDAReduction:deviceAuxVct" );
   if( ! deviceAux )
   {
      int sizeAlloc = :: Max( 1, size / desBlockSize );
@@ -870,7 +870,7 @@ bool tnlCUDASimpleReduction4( const int size,
    * If one calls the CUDA reduction more then once then one can provide
    * auxiliary array by passing it via the parameter deviceAux.
    */
   tnlLongVectorCUDA< T > deviceAuxVct;
   tnlLongVectorCUDA< T > deviceAuxVct( "tnlCUDAReduction:deviceAuxVct" );
   if( ! deviceAux )
   {
      int sizeAlloc = :: Max( 1, size / desBlockSize );
@@ -1081,7 +1081,7 @@ bool tnlCUDASimpleReduction3( const int size,
    * If one calls the CUDA reduction more then once then one can provide
    * auxiliary array by passing it via the parameter deviceAux.
    */
   tnlLongVectorCUDA< T > deviceAuxVct;
   tnlLongVectorCUDA< T > deviceAuxVct( "tnlCUDAReduction:deviceAuxVct" );
   if( ! deviceAux )
   {
      int sizeAlloc = :: Max( 1, size / desBlockSize );
@@ -1257,7 +1257,7 @@ bool tnlCUDASimpleReduction2( const int size,
    * If one calls the CUDA reduction more then once then one can provide
    * auxiliary array by passing it via the parameter deviceAux.
    */
   tnlLongVectorCUDA< T > deviceAuxVct;
   tnlLongVectorCUDA< T > deviceAuxVct( "tnlCUDAReduction:deviceAuxVct" );
   if( ! deviceAux )
   {
      int sizeAlloc = :: Max( 1, size / desBlockSize );
@@ -1416,7 +1416,7 @@ bool tnlCUDASimpleReduction1( const int size,
    * If one calls the CUDA reduction more then once then one can provide
    * auxiliary array by passing it via the parameter deviceAux.
    */
   tnlLongVectorCUDA< T > deviceAuxVct;
   tnlLongVectorCUDA< T > deviceAuxVct( "tnlCUDAReduction:deviceAuxVct" );
   if( ! deviceAux )
   {
      int sizeAlloc = :: Max( 1, size / desBlockSize );
+1 −3
Original line number Diff line number Diff line
@@ -28,10 +28,8 @@ template< class T > class tnlFieldCUDA2D : public tnlLongVectorCUDA< T >
   public:

   tnlFieldCUDA2D( const char* name = 0 )
   : tnlLongVectorCUDA< T >( 0 )
   : tnlLongVectorCUDA< T >( name )
   {
      if( name )
         tnlLongVectorCUDA< T > :: SetName( name );
   };

   tnlFieldCUDA2D( const char* name,
+2 −2
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ template< class T > class tnlFieldCUDA3D : public tnlLongVectorCUDA< T >
{
   public:

   tnlFieldCUDA3D()
   : tnlLongVectorCUDA< T >( 0 )
   tnlFieldCUDA3D( const char* name = 0 )
   : tnlLongVectorCUDA< T >( name )
   { };

   tnlFieldCUDA3D( int _x_size,
+14 −19
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
   //! Constructor with given size
   tnlLongVectorCUDA( const char* name = 0, int _size = 0 )
#ifdef HAVE_CUDA
    : tnlObject( name ), size( _size ), shared_data( false )
    : tnlObject( name ), size( _size ), data( NULL ), shared_data( false )
   {
      if( cudaMalloc( ( void** ) &data, ( size + 1 ) * sizeof( T ) ) != cudaSuccess  )
      if( size && cudaMalloc( ( void** ) &data, ( size ) * sizeof( T ) ) != cudaSuccess  )
      {
         cerr << "Unable to allocate new long vector with size "
         cerr << "Unable to allocate new long vector '" << GetName() << "' with size "
              << size << " on CUDA device for "
              << GetName() << "." << endl;
         data = NULL;
@@ -72,12 +72,12 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
   //! Constructor with another long vector as template
   tnlLongVectorCUDA( const tnlLongVectorCUDA& v )
#ifdef HAVE_CUDA
    : tnlObject( v ), size( v. size ), shared_data( false )
    : tnlObject( v ), size( v. size ), data( NULL ), shared_data( false )
   {

      if( cudaMalloc( ( void** ) &data, ( size + 1 ) * sizeof( T ) ) != cudaSuccess )
	  if( size )
		  if( cudaMalloc( ( void** ) &data, size * sizeof( T ) ) != cudaSuccess )
		  {
         cerr << "Unable to allocate new long vector with size " << size << " on CUDA device." << endl;
			  cerr << "Unable to allocate new long vector '" << GetName() << "' with size " << size << " on CUDA device." << endl;
			  data = NULL;
			  abort();
		  }
@@ -92,10 +92,9 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
   //! Constructor with another long vector as template
   tnlLongVectorCUDA( const tnlLongVector< T >& v )
#ifdef HAVE_CUDA
    : tnlObject( v ), size( v. GetSize() ), shared_data( false )
    : tnlObject( v ), size( v. GetSize() ), data( NULL ), shared_data( false )
   {

      if( cudaMalloc( ( void** ) &data, ( size + 1 ) * sizeof( T ) ) != cudaSuccess )
      if( size && cudaMalloc( ( void** ) &data, size * sizeof( T ) ) != cudaSuccess )
      {
         cerr << "Unable to allocate new long vector with size " << size << " on CUDA device." << endl;
         data = NULL;
@@ -123,7 +122,7 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
      if( debug )
	   cout << "Setting new size to " << _size << " for " << GetName() << endl;
      if( size == _size ) return true;
      if( ! shared_data )
      if( data && ! shared_data )
      {
         cudaFree( data );
         data = NULL;
@@ -178,16 +177,12 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
    */
   const T* Data() const
   {
	   if( ! size )
		   return NULL;
      return data;
   };

   //! Returns pointer to data
   T* Data()
   {
	  if( ! size )
		  return NULL;
      return data;
   }

+1 −2
Original line number Diff line number Diff line
@@ -27,9 +27,8 @@ template< class T = double > class tnlGridCUDA2D :
   public:

   tnlGridCUDA2D( const char* name = 0 )
   : tnlFieldCUDA2D< T >( name )
   {
      if( name )
         tnlFieldCUDA2D< T > :: SetName( name );
   };

   //! Constructor with the grid and the domain dimensions
Loading