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

Fixing the function adapter.

parent 28b6782f
Loading
Loading
Loading
Loading
+12 −18
Original line number Diff line number Diff line
@@ -32,17 +32,10 @@ if( WITH_TEMPLATE_EXPLICIT_INSTANTIATION STREQUAL "yes" )
   AddCompilerFlag( "-DTEMPLATE_EXPLICIT_INSTANTIATION " )
endif()   

if( WITH_CUDA STREQUAL "yes" )
   AddCompilerFlag( "-DHAVE_NOT_CXX11 -U_GLIBCXX_ATOMIC_BUILTINS -U_GLIBCXX_USE_INT128" )
   set( CUDA_LINKER_OPTIONS "-arch sm_20 -shared" )
else()
   AddCompilerFlag( "-std=gnu++0x" )
endif()      

#####
# Check for CUDA
#
if( NOT WITH_CUDA STREQUAL "no" )
if( WITH_CUDA STREQUAL "yes" )
    find_package( CUDA )
    if( CUDA_FOUND )
        set( BUILD_CUDA TRUE)
@@ -50,14 +43,11 @@ if( NOT WITH_CUDA STREQUAL "no" )
        set(BUILD_SHARED_LIBS ON)
        set(CUDA_SEPARABLE_COMPILATION ON)
        set(CUSPARSE_LIBRARY /usr/local/cuda/lib64/libcusparse.so) # TODO: fix this              
        
        set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-DHAVE_CUDA)
            
       #set( CUDA_ADD_EXECUTABLE_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" )
       #set( CUDA_ADD_LIBRARY_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" -shared )
        AddCompilerFlag( "-DHAVE_NOT_CXX11 -U_GLIBCXX_ATOMIC_BUILTINS -U_GLIBCXX_USE_INT128" )          
        set( CUDA_ADD_EXECUTABLE_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 )
        set( CUDA_ADD_LIBRARY_OPTIONS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -shared )
       
        set( CUDA_LINKER_OPTIONS "-arch sm_20 -shared" )
        ####
        # Check for CUSP
        #
@@ -91,8 +81,12 @@ if( NOT WITH_CUDA STREQUAL "no" )
           endif()            
        endif( NOT WITH_CUSPARSE STREQUAL "no" )
   
    else( CUDA_FOUND )
      AddCompilerFlag( "-std=gnu++0x" )         
    endif( CUDA_FOUND )
endif( NOT WITH_CUDA STREQUAL "no" )    
else( WITH_CUDA STREQUAL "yes" )
   AddCompilerFlag( "-std=gnu++0x" )       
endif( WITH_CUDA STREQUAL "yes" )    

####
# Check for OpenMP
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <operators/tnlAnalyticNeumannBoundaryConditions.h>
#include <operators/tnlNeumannBoundaryConditions.h>
#include <functions/tnlConstantFunction.h>
#include <functions/tnlAnalyticFunctionAdapter.h>
#include "heatEquationSolver.h"

//typedef tnlDefaultConfigTag BuildConfig;
+27 −27
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class tnlFunctionAdapter
#ifdef HAVE_CUDA
   __device__ __host__
#endif
      RealType getValue( const MeshType& mesh,
      static RealType getValue( const MeshType& mesh,
                                const FunctionType& function,
                                const IndexType index,
                                const RealType& time = 0.0 )
@@ -67,7 +67,7 @@ class tnlFunctionAdapter< Mesh, tnlConstantFunction< FunctionDimensions, Real >
#ifdef HAVE_CUDA
   __device__ __host__
#endif
      RealType getValue( const MeshType& mesh,
      static RealType getValue( const MeshType& mesh,
                                const FunctionType& function,
                                const IndexType index,
                                const RealType& time = 0.0 )
@@ -100,7 +100,7 @@ class tnlFunctionAdapter< tnlGrid< Dimensions, Real, Device, Index >, Function >
#ifdef HAVE_CUDA
   __device__ __host__
#endif
      RealType getValue( const MeshType& mesh,
      static RealType getValue( const MeshType& mesh,
                                const FunctionType& function,
                                const IndexType index,
                                const CoordinatesType& coordinates,
@@ -134,7 +134,7 @@ class tnlFunctionAdapter< tnlGrid< Dimensions, Real, Device, Index >,
#ifdef HAVE_CUDA
   __device__ __host__
#endif
      RealType getValue( const MeshType& mesh,
      static RealType getValue( const MeshType& mesh,
                                const FunctionType& function,
                                const IndexType index,
                                const CoordinatesType& coordinates,
@@ -163,7 +163,7 @@ class tnlFunctionAdapter< Mesh, tnlVector< Real, Device, Index > >
#ifdef HAVE_CUDA
   __device__ __host__
#endif
      RealType getValue( const MeshType& mesh,
      static RealType getValue( const MeshType& mesh,
                                const FunctionType& function,
                                const IndexType index,
                                const RealType& time = 0.0 )
@@ -206,7 +206,7 @@ class tnlFunctionAdapter< tnlGrid< Dimensions, Real, Device, Index >,
#ifdef HAVE_CUDA
   __device__ __host__
#endif
      RealType getValue( const MeshType& mesh,
      static RealType getValue( const MeshType& mesh,
                                const FunctionType& function,
                                const IndexType index,
                                const CoordinatesType& coordinates,
+12 −8
Original line number Diff line number Diff line
@@ -150,8 +150,10 @@ class tnlLinearSystemAssembler
                             TraversalUserData& userData,
                             const IndexType index )
         {
            typedef tnlFunctionAdapter< MeshType, RightHandSide > FunctionAdapter;
            userData.b[ index ] = userData.u[ index ] +
                                  userData.tau * userData.rightHandSide.getValue( mesh,
                                  FunctionAdapter::getValue( mesh,
                                                             userData.rightHandSide,
                                                             index,
                                                             userData.time );
            typename MatrixType::IndexType rowLength;
@@ -257,12 +259,14 @@ class tnlLinearSystemAssembler< tnlGrid< Dimensions, Real, Device, Index >,
                           const IndexType index,
                           const CoordinatesType& coordinates )
         {
            typedef typename MeshType::VertexType VertexType;
            typedef tnlFunctionAdapter< MeshType, RightHandSide > FunctionAdapter;
            userData.b[ index ] = userData.u[ index ] +
                                  userData.tau * userData.rightHandSide.template getValue< VertexType >( mesh,
                                  FunctionAdapter::getValue( mesh,
                                                             userData.rightHandSide,
                                                             index,
                                                             coordinates,
                                                             userData.time );
            
            typename MatrixType::IndexType rowLength;
            userData.differentialOperator.updateLinearSystem( userData.time,
                                                              userData.tau,