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

Fixing the code w.r.t the missing support of C++11 in nvcc 5.0.

parent ff2b7679
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ WITH_CUSPARSE=no
CUDA_ARCHITECTURE=2.0
VERBOSE=1

CMAKE="cmake"
CPUS=`grep -c processor /proc/cpuinfo`

echo "Building $TARGET using $CPUS processors."
@@ -21,13 +22,13 @@ then
fi

cd Debug
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR}
${CMAKE} .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR}
make -j${CPUS} #VERBOSE=1
make -j${CPUS} test
make -j${CPUS} install

cd ../Release
cmake .. -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR}
${CMAKE} .. -DCMAKE_INSTALL_PREFIX=${HOME}/local -DCUDA_ARCHITECTURE=${CUDA_ARCHITECTURE} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUSPARSE=${WITH_CUSPARSE} -DPETSC_DIR=${PETSC_DIR}
make -j${CPUS} #VERBOSE=1
make -j${CPUS} test
make -j${CPUS} install
+2 −2
Original line number Diff line number Diff line
@@ -32,10 +32,10 @@ uninstall: $(TARGET)
	rm -f $(CONFIG_FILE) $(INSTALL_DIR)/share

$(TARGET): $(OBJECTS)
	$(CC) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)
	$(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)

%.o: %.cpp $(TARGET)-conf.h $(HEADERS)
	$(CC) -c -o $@ $(CXX_FLAGS) $<
	$(CXX) -c -o $@ $(CXX_FLAGS) $<

$(TARGET)-conf.h:
	echo "#define CONFIG_FILE \"${INSTALL_DIR}/share/${CONFIG_FILE}\" " > $(TARGET)-conf.h 
+2 −2
Original line number Diff line number Diff line
@@ -32,10 +32,10 @@ uninstall: $(TARGET)
	rm -f $(CONFIG_FILE) $(INSTALL_DIR)/share

$(TARGET): $(OBJECTS)
	$(CC) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)
	$(CXX) -o $(TARGET) $(OBJECTS) $(LD_FLAGS)

%.o: %.cpp $(TARGET)-conf.h $(HEADERS)
	$(CC) -c -o $@ $(CXX_FLAGS) $<
	$(CXX) -c -o $@ $(CXX_FLAGS) $<

$(TARGET)-conf.h:
	echo "#define CONFIG_FILE \"${INSTALL_DIR}/share/${CONFIG_FILE}\" " > $(TARGET)-conf.h 
+17 −2
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ class tnlFile
	}

	// TODO: this does not work for constant types
#ifdef HAVE_CXX11        
	template< typename Type, typename Device = tnlHost, typename Index = int >
	bool read( Type* buffer,
	           const Index& elements );
@@ -117,7 +118,21 @@ class tnlFile

	template< typename Type, typename Device = tnlHost >
	bool write( Type* buffer );
#else        
	template< typename Type, typename Device, typename Index >
	bool read( Type* buffer,
	           const Index& elements );

	template< typename Type, typename Device >
	bool read( Type* buffer );

	template< typename Type, typename Device, typename Index >
	bool write( const Type* buffer,
	            const Index elements );

	template< typename Type, typename Device >
	bool write( Type* buffer );
#endif

	bool close();

+36 −2
Original line number Diff line number Diff line
@@ -301,25 +301,41 @@ template< class T > class tnlList
   //! Save the list in binary format
   bool Save( tnlFile& file ) const
   {
#ifdef HAVE_CXX11      
      file. write( &size );
      for( int i = 0; i < size; i ++ )
         if( ! file. write( &operator[]( i ), 1 ) )
            return false;
      return true;
#else
      file. write< const int, tnlHost >( &size );
      for( int i = 0; i < size; i ++ )
         if( ! file. write< int, tnlHost, int >( &operator[]( i ), 1 ) )
            return false;
      return true;
#endif            
   }

   //! Save the list in binary format using method save of type T
   bool DeepSave( tnlFile& file ) const
   {
      file. write( &size, 1 );
#ifdef HAVE_CXX11      
      file. write( &size );
      for( int i = 0; i < size; i ++ )
         if( ! operator[]( i ). save( file ) ) return false;
      return true;
#else
      file. write< const int, tnlHost >( &size );
      for( int i = 0; i < size; i ++ )
         if( ! operator[]( i ). save( file ) ) return false;
      return true;
#endif            
   }

   //! Load the list
   bool Load( tnlFile& file )
   {
#ifdef HAVE_CXX11      
      EraseAll();
      int _size;
      file. read( &_size, 1 );
@@ -336,6 +352,24 @@ template< class T > class tnlList
         Append( t );
      }
      return true;
#else
      EraseAll();
      int _size;
      file. read< int, tnlHost >( &_size );
      if( _size < 0 )
      {
         cerr << "The curve size is negative." << endl;
         return false;
      }
      T t;
      for( int i = 0; i < _size; i ++ )
      {
         if( ! file. read< T, tnlHost >( &t ) )
            return false;
         Append( t );
      }
      return true;
#endif            
   };

   //! Load the list using method Load of the type T
@@ -343,7 +377,7 @@ template< class T > class tnlList
   {
      EraseAll();
      int _size;
      file. read( &_size, 1 );
      file. read( &_size );
      if( _size < 0 )
      {
         cerr << "The list size is negative." << endl;
Loading