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

[WIP] Fixing changes in Array.

parent 70372c2e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -66,10 +66,10 @@ benchmarkArrayOperations( Benchmark & benchmark,


   auto compareHost = [&]() {
      resultHost = (int) hostArray == hostArray2;
      resultHost = (int) ( hostArray == hostArray2 );
   };
   auto compareCuda = [&]() {
      resultDevice = (int) deviceArray == deviceArray2;
      resultDevice = (int) ( deviceArray == deviceArray2 );
   };
   benchmark.setOperation( "comparison (operator==)", 2 * datasetSize );
   benchmark.time< Devices::Host >( reset1, "CPU", compareHost );
+5 −5
Original line number Diff line number Diff line
@@ -10,13 +10,13 @@ void export_Object( py::module & m )
{
    py::class_< TNL::Object >( m, "Object" )
        // TODO: make it abstract class in Python
        .def("save", (bool (TNL::Object::*)(const TNL::String &) const) &TNL::Object::save)
        .def("load", (bool (TNL::Object::*)(const TNL::String &)) &TNL::Object::load)
        .def("boundLoad", (bool (TNL::Object::*)(const TNL::String &)) &TNL::Object::boundLoad)
        .def("save", (void (TNL::Object::*)(const TNL::String &) const) &TNL::Object::save)
        .def("load", (void (TNL::Object::*)(const TNL::String &)) &TNL::Object::load)
        .def("boundLoad", (void (TNL::Object::*)(const TNL::String &)) &TNL::Object::boundLoad)
        // FIXME: why does it not work?
//        .def("save", py::overload_cast<TNL::File>(&TNL::Object::save, py::const_))
//        .def("load", py::overload_cast<TNL::File>(&TNL::Object::load))
        .def("save", (bool (TNL::Object::*)(TNL::File &) const) &TNL::Object::save)
        .def("load", (bool (TNL::Object::*)(TNL::File &)) &TNL::Object::load)
        .def("save", (void (TNL::Object::*)(TNL::File &) const) &TNL::Object::save)
        .def("load", (void (TNL::Object::*)(TNL::File &)) &TNL::Object::load)
    ;
}
+5 −3
Original line number Diff line number Diff line
@@ -188,8 +188,9 @@ copySTLList( DestinationElement* destination,
   {
      const auto copySize = std::min( size - copiedElements, copy_buffer_size );
      for( size_t i = 0; i < copySize; i++ )
         copy_buffer[ copiedElements ++ ] = static_cast< DestinationElement >( * it ++ );
      ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( destination, copy_buffer, copySize );
         copy_buffer[ i ] = static_cast< DestinationElement >( * it ++ );
      ArrayOperations< Devices::Cuda, Devices::Host >::copyMemory( &destination[ copiedElements ], &copy_buffer[ 0 ], copySize );
      copiedElements += copySize;
   }
}

@@ -267,7 +268,8 @@ copyMemory( DestinationElement* destination,
   }
   else
   {
      std::unique_ptr< SourceElement[] > buffer{ new SourceElement[ Devices::Cuda::getGPUTransferBufferSize() ] };
      using BaseType = typename std::remove_cv< SourceElement >::type;
      std::unique_ptr< BaseType[] > buffer{ new BaseType[ Devices::Cuda::getGPUTransferBufferSize() ] };
      Index i( 0 );
      while( i < size )
      {
+3 −3
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@ class Array : public Object
      using HostType = Containers::Array< Value, Devices::Host, Index >;
      using CudaType = Containers::Array< Value, Devices::Cuda, Index >;

      /** \brief Basic constructor.
      /**
       * \brief Basic constructor.
       *
       * Constructs an empty array with zero size.
       */
@@ -105,7 +106,6 @@ class Array : public Object
       *
       * \param array is an array to be copied.
       */
      // Deep copy does not work because of EllpackIndexMultiMap - TODO: Fix it
      explicit Array( const Array& array );

      /**
+2 −4
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ Array( const Array< Value, Device, Index >& array )
  allocationPointer( nullptr ),
  referenceCounter( 0 )
{
   // Deep copy does not work because of EllpackIndexMultiMap - TODO: Fix it
   this->setSize( array.getSize() );
   Algorithms::ArrayOperations< Device >::copyMemory( this->getData(), array.getData(), array.getSize() );
}
@@ -524,7 +523,6 @@ Array< Value, Device, Index >&
Array< Value, Device, Index >::
operator = ( const std::list< InValue >& list )
{
   if( this->getSize() != list.size() )
   this->setSize( list.size() );
   Algorithms::ArrayOperations< Device >::copySTLList( this->getData(), list );
}
@@ -539,7 +537,7 @@ operator = ( const std::vector< InValue >& vector )
{
   if( this->getSize() != vector.size() )
      this->setSize( vector.size() );
   Algorithms::ArrayOperations< Device >::copyMemory( this->getData(), vector.data(), vector.size() );
   Algorithms::ArrayOperations< Device, Devices::Host >::copyMemory( this->getData(), vector.data(), vector.size() );
}

template< typename Value,
Loading