Commit 3e651fc2 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Fixing code formatting.

Implemeting heat equation benchmark.
parent 21b2fc6d
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -15,11 +15,14 @@ set (headers tnlAssert.h
             tnlDynamicTypeTag.h
             tnlFeature.h
             tnlFile.h 
             tnlFile_impl.h
             tnlFlopsCounter.h
             tnlHost.h 
             tnlIndexedSet.h
             tnlList.h
             tnlList_impl.h
             tnlLogger.h
             tnlOmp.h
             tnlObject.h 
             tnlStack.h
             tnlStaticFor.h
@@ -49,7 +52,8 @@ set( common_SOURCES
     ${CURRENT_DIR}/mfilename.cpp 
     ${CURRENT_DIR}/mpi-supp.cpp 
     ${CURRENT_DIR}/tnlCuda.cpp
     ${CURRENT_DIR}/tnlHost.cpp )       
     ${CURRENT_DIR}/tnlHost.cpp
     ${CURRENT_DIR}/tnlOmp.cpp )

IF( BUILD_CUDA )
   set( tnl_core_CUDA__SOURCES
+26 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#include <core/tnlCuda.h>
#include <core/mfuncs.h>
#include <tnlConfig.h>
#include <config/tnlConfigDescription.h>
#include <config/tnlParameterContainer.h>

tnlString tnlCuda :: getDeviceType()
{
@@ -46,3 +48,26 @@ int tnlCuda::getNumberOfGrids( const int blocks,

}*/

void tnlCuda::configSetup( tnlConfigDescription& config, const tnlString& prefix )
{
#ifdef HAVE_CUDA
   config.addEntry<  int >( prefix + "cuda-device", "Choose CUDA device to run the computationon.", 0 );
#else
   config.addEntry<  int >( prefix + "cuda-device", "Choose CUDA device to run the computationon (not supported on this system).", 0 );
#endif
}
      
bool tnlCuda::setup( const tnlParameterContainer& parameters,
                      const tnlString& prefix )
{
#ifdef HAVE_CUDA
   int cudaDevice = parameters.getParameter< int >( "cuda-device" );
   if( cudaSetDevice( cudaDevice ) != cudaSuccess )
   {
      std::cerr << "I cannot activate CUDA device number " << cudaDevice << "." << std::endl;
      return false;
   }
#endif   
   return true;
}
+21 −0
Original line number Diff line number Diff line
@@ -17,6 +17,27 @@

#include <core/tnlCuda.h>

void tnlCuda::configSetup( tnlConfigDescription& config, const tnlString& prefix )
{
#ifdef HAVE_CUDA
   //config.addEntry< bool >( prefix + "omp-enabled", "Enable support of OpenMP.", true );
   //config.addEntry<  int >( prefix + "omp-max-threads", "Set maximum number of OpenMP threads.", omp_get_max_threads() );
#else
   //config.addEntry< bool >( prefix + "omp-enabled", "Enable support of OpenMP (not supported on this system).", false );
   //config.addEntry<  int >( prefix + "omp-max-threads", "Set maximum number of OpenMP threads (not supported on this system).", 0 );
#endif
   
}
      
bool tnlCuda::setup( const tnlParameterContainer& parameters,
                    const tnlString& prefix )
{
   //enable = parameters.getParameter< bool >( prefix + "omp-enabled" );
   //maxThreadsCount = parameters.getParameter< int ( prefix + "omp-max-threads" );
   return true;
}


bool tnlCuda::checkDevice( const char* file_name, int line )
{
   cudaError error = cudaGetLastError();
+9 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@
#include <core/tnlString.h>
#include <core/tnlAssert.h>

class tnlConfigDescription;
class tnlParameterContainer;

#ifdef HAVE_CUDA
#define __cuda_callable__ __device__ __host__
#else
@@ -91,6 +94,12 @@ class tnlCuda
   static bool checkDevice( const char* file_name, int line ) { return false;};
#endif
   
   static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" );
      
   static bool setup( const tnlParameterContainer& parameters,
                      const tnlString& prefix = "" );


};

#define checkCudaDevice tnlCuda::checkDevice( __FILE__, __LINE__ )
+12 −0
Original line number Diff line number Diff line
@@ -68,3 +68,15 @@ bool tnlFile :: close()
   readElements = writtenElements = 0;
   return true;
};

bool fileExists( const tnlString& fileName )
{
  fstream file;
  file.open( fileName. getString(), ios::in );
  bool result( true );
  if( ! file )
     result = false;
  file.close();
  return result;
};
Loading