Commit 98aab282 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Compilation with nvcc is fixed.

parent 08bc688e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
set( headers cuda-reduction.h
set( headers cuda-prefix-sum.h
             cuda-reduction.h
             reduction-operations.h )

INSTALL( FILES ${headers} DESTINATION include/tnl-${tnlVersion}/core/cuda )
 No newline at end of file
+24 −0
Original line number Diff line number Diff line
/***************************************************************************
                          cuda-prefix-sum.h  -  description
                             -------------------
    begin                : Jan 18, 2014
    copyright            : (C) 2014 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CUDA_PREFIX_SUM_H_
#define CUDA_PREFIX_SUM_H_




#endif /* CUDA_PREFIX_SUM_H_ */
+24 −12
Original line number Diff line number Diff line
@@ -166,7 +166,11 @@ bool tnlFile :: read( Type* buffer,
             sizeof( Type ),
             elements,
             file ) != elements )
      {
         cerr << "I am not able to read the data from the file " << fileName << "." << endl;
         perror( "Fread ended with the error code" );
         return false;
      }
      this->readElements = elements;
      return true;
   }
@@ -194,15 +198,18 @@ bool tnlFile :: read( Type* buffer,
      while( readElements < elements )
      {
         int transfer = :: Min( ( Index ) ( elements - readElements ), host_buffer_size );
         if( fread( host_buffer,
                    sizeof( Type ),
                    transfer,
                    file ) != transfer * sizeof( Type ) )
         size_t transfered = fread( host_buffer, sizeof( Type ), transfer, file );
         if( transfered != transfer )
         {
            cerr << "I am not able to read the data from the file " << fileName << "." << endl;
            cerr << transfered << " bytes were transfered. " << endl;
            perror( "Fread ended with the error code" );
            return false;
         }

         if( cudaMemcpy( ( void* ) & ( buffer[ readElements ] ),
                         host_buffer,
                         bytesRead,
                         transfer * sizeof( Type ),
                         cudaMemcpyHostToDevice ) != cudaSuccess )
         {
            cerr << "Transfer of data from the CUDA device to the file " << this -> fileName
@@ -211,7 +218,7 @@ bool tnlFile :: read( Type* buffer,
            free( host_buffer );
            return false;
         }
         readElements += bytesRead / sizeof( Type );
         readElements += transfer;
      }
      free( host_buffer );
      return true;
@@ -250,7 +257,8 @@ bool tnlFile :: write( const Type* buffer,
                  elements,
                  this->file ) != elements )
      {
         cerr << "Writing to the file " << this->fileName << " failed." << endl;
         cerr << "I am not able to write the data to the file " << fileName << "." << endl;
         perror( "Fwrite ended with the error code" );
         return false;
      }
      this->writtenElements = elements;
@@ -275,11 +283,11 @@ bool tnlFile :: write( const Type* buffer,
            return false;
         }

         while( writtenElements < elements )
         while( this->writtenElements < elements )
         {
            Index transfer = :: Min( elements - writtenElements, host_buffer_size );
            Index transfer = :: Min( elements - this->writtenElements, host_buffer_size );
            if( cudaMemcpy( host_buffer,
                            ( void* ) & ( buffer[ writtenElements ] ),
                            ( void* ) & ( buffer[ this->writtenElements ] ),
                            transfer * sizeof( Type ),
                            cudaMemcpyDeviceToHost ) != cudaSuccess )
            {
@@ -291,9 +299,13 @@ bool tnlFile :: write( const Type* buffer,
            if( fwrite( host_buffer,
                        sizeof( Type ),
                        transfer,
                        this->file ) != transfer*sizeof( Type ) )
                        this->file ) != transfer )
            {
               cerr << "I am not able to write the data to the file " << fileName << "." << endl;
               perror( "Fwrite ended with the error code" );
               return false;
            writtenElements += transfer;
            }
            this->writtenElements += transfer;
         }
         free( host_buffer );
         return true;
+21 −0
Original line number Diff line number Diff line
@@ -60,10 +60,17 @@ class tnlExpBumpFunction< 1, Vertex, Device > : public tnlExpBumpFunctionBase< t

   tnlExpBumpFunction();

#ifdef HAVE_NOT_CXX11
   template< int XDiffOrder,
             int YDiffOrder,
             int ZDiffOrder >
   RealType getF( const VertexType& v ) const;
#else
   template< int XDiffOrder = 0,
             int YDiffOrder = 0,
             int ZDiffOrder = 0 >
   RealType getF( const VertexType& v ) const;
#endif   
};

template< typename Vertex, typename Device >
@@ -77,10 +84,17 @@ class tnlExpBumpFunction< 2, Vertex, Device > : public tnlExpBumpFunctionBase< t

   tnlExpBumpFunction();

#ifdef HAVE_NOT_CXX11
   template< int XDiffOrder,
             int YDiffOrder,
             int ZDiffOrder >
   RealType getF( const VertexType& v ) const;
#else
   template< int XDiffOrder = 0,
             int YDiffOrder = 0,
             int ZDiffOrder = 0 >
   RealType getF( const VertexType& v ) const;
#endif   
};

template< typename Vertex, typename Device >
@@ -94,10 +108,17 @@ class tnlExpBumpFunction< 3, Vertex, Device > : public tnlExpBumpFunctionBase< t

   tnlExpBumpFunction();

#ifdef HAVE_NOT_CXX11
   template< int XDiffOrder,
             int YDiffOrder,
             int ZDiffOrder >
   RealType getF( const VertexType& v ) const;
#else
   template< int XDiffOrder = 0,
             int YDiffOrder = 0,
             int ZDiffOrder = 0 >
   RealType getF( const VertexType& v ) const;
#endif   
};

#include <implementation/generators/functions/tnlExpBumpFunction_impl.h>
+10 −0
Original line number Diff line number Diff line
@@ -23,12 +23,22 @@ class tnlFunctionDiscretizer
{
   public:

#ifdef HAVE_NOT_CXX11
   template< int XDiffOrder,
             int YDiffOrder,
             int ZDiffOrder >
   static void discretize( const Mesh& mesh,
                           const Function& function,
                           DiscreteFunction& discreteFunction );
#else
   template< int XDiffOrder = 0,
             int YDiffOrder = 0,
             int ZDiffOrder = 0 >
   static void discretize( const Mesh& mesh,
                           const Function& function,
                           DiscreteFunction& discreteFunction );
#endif   
   
};

#include <implementation/generators/functions/tnlFunctionDiscretizer_impl.h>
Loading