Commit 03235b52 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing debugging code to tnlObject and tnlLongVectorCUDA.

parent d678eff9
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -51,13 +51,8 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
   //! Constructor with given size
   tnlLongVectorCUDA( const char* name = 0, int _size = 0 )
#ifdef HAVE_CUDA
    : size( _size ), shared_data( false )
    : tnlObject( name ), size( _size ), shared_data( false )
   {
	   cerr << "X##" << endl;
      if( name )
         SetName( name );
      cout << "Initiating " << GetName() << endl;
      cerr << "X### " << size + 1 << endl;
      if( cudaMalloc( ( void** ) &data, ( size + 1 ) * sizeof( T ) ) != cudaSuccess  )
      {
         cerr << "Unable to allocate new long vector with size "
@@ -66,7 +61,6 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
         data = NULL;
         abort();
      }
      cerr << "X####" << endl;
      //data ++;
   };
#else
@@ -126,7 +120,8 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
   bool SetNewSize( int _size )
#ifdef HAVE_CUDA
   {
	   cerr << "Setting new size to " << _size << " for " << GetName() << endl;
      if( debug )
	   cout << "Setting new size to " << _size << " for " << GetName() << endl;
      if( size == _size ) return true;
      if( ! shared_data )
      {
@@ -260,6 +255,11 @@ template< class T > class tnlLongVectorCUDA : public tnlObject
#endif
   };

   static void setDebug( bool _debug )
   {
      debug = _debug;
   };

   private:

   int size;
@@ -268,6 +268,8 @@ template< class T > class tnlLongVectorCUDA : public tnlObject

   bool shared_data;

   static bool debug;

   //friend class tnlLongVectorCUDATester< T >;
};

@@ -289,4 +291,6 @@ template< class T > bool tnlLongVector< T > :: copyFrom( const tnlLongVectorCUDA

}

template< class T > bool tnlLongVectorCUDA< T > :: debug;

#endif /* TNLLONGVECTORCUDA_H_ */
+15 −1
Original line number Diff line number Diff line
@@ -24,18 +24,27 @@
#include "debug.h"

const char magic_number[] = "SIM33";

bool tnlObject :: debug = false;
//--------------------------------------------------------------------------
tnlObject :: tnlObject( )
{
}
//--------------------------------------------------------------------------
tnlObject :: tnlObject( const char* name )
{
   SetName( name );
   if( debug )
      cout << "Initiating object " << GetName() << endl;
}
//--------------------------------------------------------------------------
tnlObject :: tnlObject( const tnlObject& object )
{
}
//--------------------------------------------------------------------------
tnlString tnlObject :: GetType() const
{
   return tnlString( "mObject" );
   return tnlString( "tnlObject" );
}
//--------------------------------------------------------------------------
void tnlObject :: SetName( const char* _name )
@@ -76,6 +85,11 @@ bool tnlObject :: Load( istream& file )
   return true;
}
//--------------------------------------------------------------------------
void tnlObject :: setDebug( bool _debug )
{
   debug = _debug;
}
//--------------------------------------------------------------------------
bool GetObjectType( istream& file, tnlString& type )
{
   dbgFunctionName( "", "GetObjectType" );
+10 −1
Original line number Diff line number Diff line
@@ -34,7 +34,10 @@ class tnlObject
   public:

   //! Basic constructor
   tnlObject();
   tnlObject(); // TODO: Remove this we want to have only constructor with name

   //! Constructor with name
   tnlObject( const char* name );
   
   //! Copy constructor 
   /*! It does not copy name - name should be unique
@@ -56,6 +59,9 @@ class tnlObject
   //! Method for restoring the object from a file
   virtual bool Load( istream& file );   

   //! Debug moder setter
   static void setDebug( bool );

   //! Destructor
   virtual ~tnlObject(){};

@@ -64,6 +70,9 @@ class tnlObject
   //! Object name
   tnlString name;

   //! Turns on debuging messages
   static bool debug;

};

bool GetObjectType( istream& file, tnlString& type );
+7 −1
Original line number Diff line number Diff line
@@ -130,7 +130,13 @@ template< class GRID, class SCHEME, typename T = double > class tnlMersonSolverC
   public:

   tnlMersonSolverCUDA( const GRID& v )
   : adaptivity( 1.0e-5 )
   : adaptivity( 1.0e-5 ),
     k1( "tnlMersonSolverCUDA:k1" ),
     k2( "tnlMersonSolverCUDA:k2" ),
     k3( "tnlMersonSolverCUDA:k3" ),
     k4( "tnlMersonSolverCUDA:k4" ),
     k5( "tnlMersonSolverCUDA:k5" ),
     k_tmp( "tnlMersonSolverCUDA:k-tmp" )
   {
#ifdef HAVE_CUDA
      k1. SetNewDimensions( v );