Commit 4863455a authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Prettified markings of methods in tnlStaticArray and tnlStaticVector

Used shorter __cuda_callable__ instead of __host__ __device__ and
testing if HAVE_CUDA is defined.
parent 3b9dc73e
Loading
Loading
Loading
Loading
+50 −150
Original line number Diff line number Diff line
@@ -33,53 +33,35 @@ class tnlStaticArray
   typedef int     IndexType;
   enum { size = Size };

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element v[ Size ] );

   //! This sets all vector components to v
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element& v );

   //! Copy constructor
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const tnlStaticArray< Size, Element >& v );

   static tnlString getType();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   int getSize() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element* getData();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element* getData() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& operator[]( int i ) const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& operator[]( int i );

   tnlStaticArray< Size, Element >& operator = ( const tnlStaticArray< Size, Element >& array );
@@ -114,64 +96,42 @@ class tnlStaticArray< 1, Element >
   typedef int     IndexType;
   enum { size = 1 };

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element v[ size ] );

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element& v );

   //! Copy constructor
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const tnlStaticArray< size, Element >& v );

   static tnlString getType();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   int getSize() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element* getData();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element* getData() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& operator[]( int i ) const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& operator[]( int i );

   //! Returns the first coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& x();

   //! Returns the first coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& x() const;

   tnlStaticArray< 1, Element >& operator = ( const tnlStaticArray< 1, Element >& array );
@@ -205,82 +165,54 @@ class tnlStaticArray< 2, Element >
   typedef int     IndexType;
   enum { size = 2 };

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element v[ size ] );

   //! This sets all vector components to v
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element& v );

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element& v1, const Element& v2 );

   //! Copy constructor
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const tnlStaticArray< size, Element >& v );

   static tnlString getType();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   int getSize() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element* getData();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element* getData() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& operator[]( int i ) const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& operator[]( int i );

   //! Returns the first coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& x();

   //! Returns the first coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& x() const;

   //! Returns the second coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& y();

   //! Returns the second coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& y() const;

   tnlStaticArray< 2, Element >& operator = ( const tnlStaticArray< 2, Element >& array );
@@ -314,94 +246,62 @@ class tnlStaticArray< 3, Element >
   typedef int     IndexType;
   enum { size = 3 };

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element v[ size ] );

   //! This sets all vector components to v
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element& v );

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const Element& v1, const Element& v2, const Element& v3 );

   //! Copy constructor
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   tnlStaticArray( const tnlStaticArray< size, Element >& v );

   static tnlString getType();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   int getSize() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element* getData();

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element* getData() const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& operator[]( int i ) const;

#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& operator[]( int i );

   //! Returns the first coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& x();

   //! Returns the first coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& x() const;

   //! Returns the second coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& y();

   //! Returns the second coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& y() const;

   //! Returns the third coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   Element& z();

   //! Returns the third coordinate
#ifdef HAVE_CUDA
   __host__ __device__
#endif
   __cuda_callable__
   const Element& z() const;

   tnlStaticArray< 3, Element >& operator = ( const tnlStaticArray< 3, Element >& array );
+11 −33
Original line number Diff line number Diff line
@@ -21,35 +21,27 @@
#include <core/param-types.h>

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 1, Element >::tnlStaticArray()
{
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 1, Element >::tnlStaticArray( const Element v[ size ] )
{
   data[ 0 ] = v[ 0 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 1, Element >::tnlStaticArray( const Element& v )
{
   data[ 0 ] = v;
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 1, Element >::tnlStaticArray( const tnlStaticArray< size, Element >& v )
{
   data[ 0 ] = v[ 0 ];
@@ -66,36 +58,28 @@ tnlString tnlStaticArray< 1, Element >::getType()
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
int tnlStaticArray< 1, Element >::getSize() const
{
   return size;
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
Element* tnlStaticArray< 1, Element >::getData()
{
   return data;
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
const Element* tnlStaticArray< 1, Element >::getData() const
{
   return data;
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 1, Element >::operator[]( int i ) const
{
   tnlAssert( i >= 0 && i < size,
@@ -104,9 +88,7 @@ const Element& tnlStaticArray< 1, Element >::operator[]( int i ) const
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 1, Element >::operator[]( int i )
{
   tnlAssert( i >= 0 && i < size,
@@ -115,18 +97,14 @@ Element& tnlStaticArray< 1, Element >::operator[]( int i )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 1, Element >::x()
{
   return data[ 0 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 1, Element >::x() const
{
   return data[ 0 ];
+14 −42
Original line number Diff line number Diff line
@@ -21,17 +21,13 @@
#include <core/param-types.h>

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 2, Element >::tnlStaticArray()
{
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 2, Element >::tnlStaticArray( const Element v[ size ] )
{
   data[ 0 ] = v[ 0 ];
@@ -39,9 +35,7 @@ tnlStaticArray< 2, Element >::tnlStaticArray( const Element v[ size ] )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 2, Element >::tnlStaticArray( const Element& v )
{
   data[ 0 ] = v;
@@ -49,9 +43,7 @@ tnlStaticArray< 2, Element >::tnlStaticArray( const Element& v )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 2, Element >::tnlStaticArray( const Element& v1, const Element& v2 )
{
   data[ 0 ] = v1;
@@ -59,9 +51,7 @@ tnlStaticArray< 2, Element >::tnlStaticArray( const Element& v1, const Element&
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 2, Element >::tnlStaticArray( const tnlStaticArray< size, Element >& v )
{
   data[ 0 ] = v[ 0 ];
@@ -79,36 +69,28 @@ tnlString tnlStaticArray< 2, Element >::getType()
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
int tnlStaticArray< 2, Element >::getSize() const
{
   return size;
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
Element* tnlStaticArray< 2, Element >::getData()
{
   return data;
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
const Element* tnlStaticArray< 2, Element >::getData() const
{
   return data;
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 2, Element >::operator[]( int i ) const
{
   tnlAssert( i >= 0 && i < size,
@@ -117,9 +99,7 @@ const Element& tnlStaticArray< 2, Element >::operator[]( int i ) const
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 2, Element >::operator[]( int i )
{
   tnlAssert( i >= 0 && i < size,
@@ -128,36 +108,28 @@ Element& tnlStaticArray< 2, Element >::operator[]( int i )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 2, Element >::x()
{
   return data[ 0 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 2, Element >::x() const
{
   return data[ 0 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 2, Element >::y()
{
   return data[ 1 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 2, Element >::y() const
{
   return data[ 1 ];
+16 −48
Original line number Diff line number Diff line
@@ -21,17 +21,13 @@
#include <core/param-types.h>

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 3, Element >::tnlStaticArray()
{
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 3, Element >::tnlStaticArray( const Element v[ size ] )
{
   data[ 0 ] = v[ 0 ];
@@ -40,9 +36,7 @@ tnlStaticArray< 3, Element >::tnlStaticArray( const Element v[ size ] )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 3, Element >::tnlStaticArray( const Element& v )
{
   data[ 0 ] = v;
@@ -51,9 +45,7 @@ tnlStaticArray< 3, Element >::tnlStaticArray( const Element& v )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 3, Element >::tnlStaticArray( const Element& v1, const Element& v2, const Element& v3 )
{
   data[ 0 ] = v1;
@@ -62,9 +54,7 @@ tnlStaticArray< 3, Element >::tnlStaticArray( const Element& v1, const Element&
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< 3, Element >::tnlStaticArray( const tnlStaticArray< size, Element >& v )
{
   data[ 0 ] = v[ 0 ];
@@ -83,36 +73,28 @@ tnlString tnlStaticArray< 3, Element >::getType()
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
int tnlStaticArray< 3, Element >::getSize() const
{
   return size;
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
Element* tnlStaticArray< 3, Element >::getData()
{
   return data;
}

template< typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
const Element* tnlStaticArray< 3, Element >::getData() const
{
   return data;
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 3, Element >::operator[]( int i ) const
{
   tnlAssert( i >= 0 && i < size,
@@ -121,9 +103,7 @@ const Element& tnlStaticArray< 3, Element >::operator[]( int i ) const
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 3, Element >::operator[]( int i )
{
   tnlAssert( i >= 0 && i < size,
@@ -132,54 +112,42 @@ Element& tnlStaticArray< 3, Element >::operator[]( int i )
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 3, Element >::x()
{
   return data[ 0 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 3, Element >::x() const
{
   return data[ 0 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 3, Element >::y()
{
   return data[ 1 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 3, Element >::y() const
{
   return data[ 1 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< 3, Element >::z()
{
   return data[ 2 ];
}

template< typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< 3, Element >::z() const
{
   return data[ 2 ];
+9 −27
Original line number Diff line number Diff line
@@ -21,17 +21,13 @@
#include <core/param-types.h>

template< int Size, typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< Size, Element >::tnlStaticArray()
{
};

template< int Size, typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< Size, Element >::tnlStaticArray( const Element v[ Size ] )
{
   for( int i = 0; i < Size; i++ )
@@ -39,9 +35,7 @@ tnlStaticArray< Size, Element >::tnlStaticArray( const Element v[ Size ] )
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< Size, Element >::tnlStaticArray( const Element& v )
{
   for( int i = 0; i < Size; i++ )
@@ -49,9 +43,7 @@ tnlStaticArray< Size, Element >::tnlStaticArray( const Element& v )
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
tnlStaticArray< Size, Element >::tnlStaticArray( const tnlStaticArray< Size, Element >& v )
{
   for( int i = 0; i < Size; i++ )
@@ -69,36 +61,28 @@ tnlString tnlStaticArray< Size, Element >::getType()
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
int tnlStaticArray< Size, Element >::getSize() const
{
   return size;
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
Element* tnlStaticArray< Size, Element >::getData()
{
   return data;
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
   __host__ __device__
#endif
__cuda_callable__
const Element* tnlStaticArray< Size, Element >::getData() const
{
   return data;
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
const Element& tnlStaticArray< Size, Element >::operator[]( int i ) const
{
   tnlAssert( i >= 0 && i < size,
@@ -107,9 +91,7 @@ const Element& tnlStaticArray< Size, Element >::operator[]( int i ) const
}

template< int Size, typename Element >
#ifdef HAVE_CUDA
__host__ __device__
#endif
__cuda_callable__
Element& tnlStaticArray< Size, Element >::operator[]( int i )
{
   tnlAssert( i >= 0 && i < size,
Loading