Commit 5910a5e8 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Reimplemented getType() function using typeid operator and removed useless getType() methods

Fixes #46
parent 203ee514
Loading
Loading
Loading
Loading
+7 −20
Original line number Diff line number Diff line
#include <iostream>
#include <TNL/param-types.h>
#include <TNL/TypeInfo.h>
#include <TNL/Object.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
@@ -13,24 +13,12 @@ class MyArray : public Object
{
   public:

      using HostType = MyArray< Value, Devices::Host >;
      
      static String getType()
      {
         return "MyArray< " + TNL::getType< Value >() + ", " + TNL::getType< Device >() + " >";
      }

      String getTypeVirtual() const
      {
         return getType();
      }

      static String getSerializationType()
      {
         return HostType::getType();
         return "MyArray< " + TNL::getType< Value >() + ", " + getType< Devices::Host >() + " >";
      }

      String getSerializationTypeVirtual() const
      virtual String getSerializationTypeVirtual() const override
      {
         return getSerializationType();
      }
@@ -47,11 +35,11 @@ int main()
   Object* cudaArrayPtr = &cudaArray;

   // Object types
   cout << "HostArray type is                  " << HostArray::getType() << endl;
   cout << "hostArrayPtr type is               " << hostArrayPtr->getTypeVirtual() << endl;
   cout << "HostArray type is                  " << getType< HostArray >() << endl;
   cout << "hostArrayPtr type is               " << getType( *hostArrayPtr ) << endl;

   cout << "CudaArray type is                  " << CudaArray::getType() << endl;
   cout << "cudaArrayPtr type is               " << cudaArrayPtr->getTypeVirtual() << endl;
   cout << "CudaArray type is                  " << getType< CudaArray >() << endl;
   cout << "cudaArrayPtr type is               " << getType( *cudaArrayPtr ) << endl;

   // Object serialization types
   cout << "HostArray serialization type is    " << HostArray::getSerializationType() << endl;
@@ -60,4 +48,3 @@ int main()
   cout << "CudaArray serialization type is    " << CudaArray::getSerializationType() << endl;
   cout << "cudaArrayPtr serialization type is " << cudaArrayPtr->getSerializationTypeVirtual() << endl;
}
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ benchmarkSpMV( Benchmark & benchmark,
   CudaVector deviceVector, deviceVector2;

   // create benchmark group
   const std::vector< String > parsedType = parseObjectType( HostMatrix::getType() );
   const std::vector< String > parsedType = parseObjectType( getType< HostMatrix >() );
#ifdef HAVE_CUDA
   benchmark.createHorizontalGroup( parsedType[ 0 ], 2 );
#else
+0 −6
Original line number Diff line number Diff line
@@ -33,8 +33,6 @@ class BenchmarkLaplace< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In
      typedef Functions::MeshFunction< MeshType > MeshFunctionType;
      enum { Dimension = MeshType::getMeshDimension() };

      static String getType();

      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      Real operator()( const MeshFunction& u,
@@ -81,8 +79,6 @@ class BenchmarkLaplace< Meshes::Grid< 2,MeshReal, Device, MeshIndex >, Real, Ind
      typedef Functions::MeshFunction< MeshType > MeshFunctionType;
      enum { Dimension = MeshType::getMeshDimension() };

      static String getType();

      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      Real operator()( const MeshFunction& u,
@@ -144,8 +140,6 @@ class BenchmarkLaplace< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind
      typedef Functions::MeshFunction< MeshType > MeshFunctionType;
      enum { Dimension = MeshType::getMeshDimension() };

      static String getType();

      template< typename MeshFunction, typename MeshEntity >
      __cuda_callable__
      Real operator()( const MeshFunction& u,
+0 −45
Original line number Diff line number Diff line
@@ -4,21 +4,6 @@
/****
 * 1D problem
 */
template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index >
String
BenchmarkLaplace< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index >::
getType()
{
   return String( "BenchmarkLaplace< " ) +
          MeshType::getType() + ", " +
         TNL::getType< Real >() + ", " +
         TNL::getType< Index >() + " >";
}

template< typename MeshReal,
          typename Device,
          typename MeshIndex,
@@ -108,21 +93,6 @@ setMatrixElements( const RealType& time,
/****
 * 2D problem
 */
template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index >
String
BenchmarkLaplace< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index >::
getType()
{
   return String( "BenchmarkLaplace< " ) +
          MeshType::getType() + ", " +
         TNL::getType< Real >() + ", " +
         TNL::getType< Index >() + " >";
}

template< typename MeshReal,
          typename Device,
          typename MeshIndex,
@@ -288,21 +258,6 @@ setMatrixElements( const RealType& time,
/****
 * 3D problem
 */
template< typename MeshReal,
          typename Device,
          typename MeshIndex,
          typename Real,
          typename Index >
String
BenchmarkLaplace< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index >::
getType()
{
   return String( "BenchmarkLaplace< " ) +
          MeshType::getType() + ", " +
         TNL::getType< Real >() + ", " +
         TNL::getType< Index >() + " >";
}

template< typename MeshReal,
          typename Device,
          typename MeshIndex,
+0 −2
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ class HeatEquationBenchmarkProblem:

      HeatEquationBenchmarkProblem();

      static String getType();

      String getPrologHeader() const;

      void writeProlog( Logger& logger,
Loading