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

Merge branch 'develop' of geraldine.fjfi.cvut.cz:/local/projects/tnl/tnl into develop

parents cb387f1d 74ec4ba3
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -14,8 +14,6 @@
#include <TNL/Devices/Cuda.h>
#include <TNL/Devices/MIC.h>

#include <iostream>

namespace TNL {
namespace Containers {   
namespace Algorithms {
@@ -30,11 +28,11 @@ class ArrayOperations< Devices::Host >
   public:

   template< typename Element, typename Index >
   static bool allocateMemory( Element*& data,
   static void allocateMemory( Element*& data,
                               const Index size );

   template< typename Element >
   static bool freeMemory( Element* data );
   static void freeMemory( Element* data );

   template< typename Element >
   static void setMemoryElement( Element* data,
@@ -76,11 +74,11 @@ class ArrayOperations< Devices::Cuda >
   public:

   template< typename Element, typename Index >
   static bool allocateMemory( Element*& data,
   static void allocateMemory( Element*& data,
                               const Index size );

   template< typename Element >
   static bool freeMemory( Element* data );
   static void freeMemory( Element* data );

   template< typename Element >
   static void setMemoryElement( Element* data,
@@ -163,11 +161,11 @@ class ArrayOperations< Devices::MIC >
   public:

   template< typename Element, typename Index >
   static bool allocateMemory( Element*& data,
   static void allocateMemory( Element*& data,
                               const Index size );

   template< typename Element >
   static bool freeMemory( Element* data );
   static void freeMemory( Element* data );

   template< typename Element >
   static void setMemoryElement( Element* data,
@@ -242,7 +240,6 @@ class ArrayOperations< Devices::Host, Devices::MIC >
                              const Index size );
};


} // namespace Algorithms
} // namespace Containers
} // namespace TNL
+4 −4
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ namespace Containers {
namespace Algorithms {

template< typename Element, typename Index >
bool
void
ArrayOperations< Devices::Cuda >::
allocateMemory( Element*& data,
                const Index size )
@@ -38,14 +38,14 @@ allocateMemory( Element*& data,
      data = 0;
      throw Exceptions::CudaBadAlloc();
   }
   return TNL_CHECK_CUDA_DEVICE;
   TNL_CHECK_CUDA_DEVICE;
#else
   throw Exceptions::CudaSupportMissing();
#endif
}

template< typename Element >
bool
void
ArrayOperations< Devices::Cuda >::
freeMemory( Element* data )
{
@@ -53,7 +53,7 @@ freeMemory( Element* data )
#ifdef HAVE_CUDA
   TNL_CHECK_CUDA_DEVICE;
   cudaFree( data );
   return TNL_CHECK_CUDA_DEVICE;
   TNL_CHECK_CUDA_DEVICE;
#else
   throw Exceptions::CudaSupportMissing();
#endif
+2 −4
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ namespace Containers {
namespace Algorithms {

template< typename Element, typename Index >
bool
void
ArrayOperations< Devices::Host >::
allocateMemory( Element*& data,
                const Index size )
@@ -32,16 +32,14 @@ allocateMemory( Element*& data,
   // https://stackoverflow.com/questions/550451/will-new-return-null-in-any-case
   TNL_ASSERT_TRUE( data, "Operator 'new' returned a nullptr. This should never happen - there is "
                          "either a bug or the compiler does not comply to the standard." );
   return true;
}

template< typename Element >
bool
void
ArrayOperations< Devices::Host >::
freeMemory( Element* data )
{
   delete[] data;
   return true;
}

template< typename Element >
+188 −195
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

#include <TNL/tnlConfig.h>
#include <TNL/Math.h>
#include <TNL/Exceptions/MICSupportMissing.h>
#include <TNL/Exceptions/MICBadAlloc.h>
#include <TNL/Containers/Algorithms/ArrayOperations.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Containers/Algorithms/reduction-operations.h>
@@ -28,35 +30,30 @@ namespace Algorithms {


template< typename Element, typename Index >
bool
void
ArrayOperations< Devices::MIC >::
allocateMemory( Element*& data,
                const Index size )
{
#ifdef HAVE_MIC
   data = (Element*) Devices::MIC::AllocMIC( size * sizeof(Element) );
   if(data)
       return true;
   else
       return false;
   if( ! data )
      throw Exceptions::MICBadAlloc();
#else
   MICSupportMissingMessage;
   return false;
   throw Exceptions::MICSupportMissing();
#endif
}

template< typename Element >
bool
void
ArrayOperations< Devices::MIC >::
freeMemory( Element* data )
{
   TNL_ASSERT( data, );
#ifdef HAVE_MIC
   Devices::MIC::FreeMIC( data );
    return true;
#else
    MICSupportMissingMessage;;
     true;
   throw Exceptions::MICSupportMissing();
#endif
}

@@ -119,8 +116,7 @@ setMemory( Element* data,
   }
   return true;
#else
   MICSupportMissingMessage;;
   return false;
   throw Exceptions::MICSupportMissing();
#endif
}

@@ -163,7 +159,7 @@ copyMemory( DestinationElement* destination,

      }
   #else
      MICSupportMissingMessage;;
      throw Exceptions::MICSupportMissing();
   #endif
      return false;
}
@@ -214,10 +210,10 @@ compareMemory( const Element1* destination,
      }
      return ret;
   }
   return false;
#else
      MICSupportMissingMessage;;
   throw Exceptions::MICSupportMissing();
#endif
   return false;   
}

/****
@@ -297,10 +293,10 @@ copyMemory( DestinationElement* destination,
          return true;
      }
   }
   return false;
#else
      MICSupportMissingMessage;;
   throw Exceptions::MICSupportMissing();
#endif
   return false;
}


@@ -343,8 +339,7 @@ compareMemory( const Element1* destination,
   }
   return true;
#else
      MICSupportMissingMessage;
      return false;
   throw Exceptions::MICSupportMissing();
#endif
}

@@ -424,10 +419,10 @@ copyMemory( DestinationElement* destination,
          return true;
      }
   }
   return false;
#else
      MICSupportMissingMessage;;
   throw Exceptions::MICSupportMissing();
#endif
   return false;
}

template< typename Element1,
@@ -445,8 +440,6 @@ compareMemory( const Element1* hostData,
   return ArrayOperations< Devices::Host, Devices::MIC >::compareMemory( deviceData, hostData, size );
}


} // namespace Algorithms
} // namespace Containers
} // namespace TNL
+2 −2
Original line number Diff line number Diff line
@@ -608,7 +608,7 @@ computePrefixSum( Vector& v,
                                   &v.getData()[ begin ],
                                   &v.getData()[ begin ],
                                   operation,
                                   Algorithms::inclusivePrefixSum );
                                   Algorithms::PrefixSumType::inclusive );
#else
   throw Exceptions::CudaSupportMissing();
#endif
@@ -633,7 +633,7 @@ computeExclusivePrefixSum( Vector& v,
                                   &v.getData()[ begin ],
                                   &v.getData()[ begin ],
                                   operation,
                                   Algorithms::exclusivePrefixSum );
                                   Algorithms::PrefixSumType::exclusive );
#endif
}

Loading