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

Working on heat equation benchmark.

parent c1f16827
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <core/tnlCuda.h>
#include <core/vectors/tnlStaticVector.h>
#include <mesh/tnlGrid.h>
#include <functions/tnlMeshFunction.h>
#include "pure-c-rhs.h"

using namespace std;
@@ -373,6 +374,20 @@ bool solveHeatEquationCuda( const tnlParameterContainer& parameters,
   cudaMemcpy( u, cuda_u, dofsCount * sizeof( Real ), cudaMemcpyDeviceToHost );
   writeFunction( "final", u, gridXSize, gridYSize, hx, hy );

   /****
    * Saving the result
    */
   typedef tnlGrid< 2, Real, tnlCuda, Index > GridType;
   typedef typename GridType::VertexType VertexType;
   GridType grid;
   grid.setDimensions( gridXSize, gridYSize );
   grid.setDomain( VertexType( 0.0, 0.0 ), VertexType( domainXSize, domainYSize ) );
   tnlVector< Real, tnlCuda, Index > vecU;
   vecU.bind( u, gridXSize * gridYSize );
   tnlMeshFunction< GridType > meshFunction;
   meshFunction.bind( grid, vecU );
   meshFunction.save( "simple-heat-equation-result.tnl" );
   
   /***
    * Freeing allocated memory
    */
@@ -510,6 +525,20 @@ bool solveHeatEquationHost( const tnlParameterContainer& parameters,
   }
   timer.stop();
   
   /****
    * Saving the result
    */
   typedef tnlGrid< 2, Real, tnlHost, Index > GridType;
   typedef typename GridType::VertexType VertexType;
   GridType grid;
   grid.setDimensions( gridXSize, gridYSize );
   grid.setDomain( VertexType( 0.0, 0.0 ), VertexType( domainXSize, domainYSize ) );
   tnlVector< Real, tnlHost, Index > vecU;
   vecU.bind( u, gridXSize * gridYSize );
   tnlMeshFunction< GridType > meshFunction;
   meshFunction.bind( grid, vecU );
   meshFunction.save( "simple-heat-equation-result.tnl" );
   
   /***
    * Freeing allocated memory
    */
+18 −16
Original line number Diff line number Diff line
#!/bin/bash

device="cuda"
dofSize=2000
device="host"
dofSize=256
dimension=2;
proportions=2
finalTime=10.e-3
timeStep=1.0e-6
finalTime=1.0e-1
timeStep=1.0e-5

analyticFunction="exp-bump"
sigma=1.0

#tnl-heat-equation --device cuda --time-discretisation explicit --boundary-conditions-type neumann --boundary-conditions-constant 0 --discrete-solver euler --snapshot-period 1.0e-2 --final-time 1.0e-2 --time-step 1.0e-5 --refresh-rate 1000

#tnl-benchmark-simple-heat-equation --device cuda --domain-x-size 2 --domain-y-size 2 --grid-x-size 100 --grid-y-size 100 --sigma 1.0 --time-step 1.0e-5 --final-time 1.0e-2


#nvcc -std=c++11 -O3 $(tnl-compile --cuda) $(tnl-link --cuda) -lcusparse ~/workspace/tnl/examples/heat-equation/tnl-heat-equation.cu

tnl-grid-setup --dimensions ${dimension} \
               --proportions-x ${proportions} \
               --proportions-y ${proportions} \
@@ -30,9 +23,10 @@ tnl-grid-setup --dimensions ${dimension} \
               
tnl-init --mesh mesh.tnl \
         --test-function ${analyticFunction} \
         --output-file initial.tnl \
         --output-file init.tnl \
         --sigma ${sigma}

#valgrind --tool=memcheck \
tnl-heat-equation --device ${device} \
                  --time-discretisation explicit \
                  --boundary-conditions-type neumann \
@@ -41,9 +35,11 @@ tnl-heat-equation --device ${device} \
                  --snapshot-period ${finalTime} \
                  --final-time ${finalTime} \
                  --time-step ${timeStep} \
                  --refresh-rate 1000
                  --max-iterations 100000000 \
                  --refresh-rate 1000 \
                  --omp-enabled false

./a.out --device ${device} \
tnl-benchmark-heat-equation --device ${device} \
                  --time-discretisation explicit \
                  --boundary-conditions-type neumann \
                  --boundary-conditions-constant 0 \
@@ -51,7 +47,9 @@ tnl-heat-equation --device ${device} \
                  --snapshot-period ${finalTime} \
                  --final-time ${finalTime} \
                  --time-step ${timeStep} \
                  --refresh-rate 1000
                  --max-iterations 100000000 \
                  --refresh-rate 1000 \
                  --omp-enabled false
              
tnl-benchmark-simple-heat-equation --device ${device} \
                                   --domain-x-size 2 \
@@ -61,3 +59,7 @@ tnl-benchmark-simple-heat-equation --device ${device} \
                                   --sigma ${sigma} \
                                   --time-step ${timeStep} \
                                   --final-time ${finalTime}       
                                   
tnl-diff --input-files simple-heat-equation-result.tnl u-00001.tnl

cat tnl-diff.log