Commit 9723c16b authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Moved skipping of synchronization directly into the synchronizeSmartPointersOnDevice function

parent 9615d107
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ processBoundaryEntities( const MeshPointer& meshPointer,
      // TODO: if the Mesh::IdType is void, then we should also pass the entityIndex
      EntitiesProcessor::processEntity( *mesh, userData, entity );
   };
   if( std::is_same< DeviceType, Devices::Cuda >::value )
   Pointers::synchronizeSmartPointersOnDevice< DeviceType >();
   Algorithms::ParallelFor< DeviceType >::exec(
         (GlobalIndexType) 0, entitiesCount,
@@ -67,7 +66,6 @@ processInteriorEntities( const MeshPointer& meshPointer,
      // TODO: if the Mesh::IdType is void, then we should also pass the entityIndex
      EntitiesProcessor::processEntity( *mesh, userData, entity );
   };
   if( std::is_same< DeviceType, Devices::Cuda >::value )
   Pointers::synchronizeSmartPointersOnDevice< DeviceType >();
   Algorithms::ParallelFor< DeviceType >::exec(
         (GlobalIndexType) 0, entitiesCount,
@@ -96,7 +94,6 @@ processAllEntities( const MeshPointer& meshPointer,
      // TODO: if the Mesh::IdType is void, then we should also pass the entityIndex
      EntitiesProcessor::processEntity( *mesh, userData, entity );
   };
   if( std::is_same< DeviceType, Devices::Cuda >::value )
   Pointers::synchronizeSmartPointersOnDevice< DeviceType >();
   Algorithms::ParallelFor< DeviceType >::exec(
         (GlobalIndexType) 0, entitiesCount,
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
#include <TNL/Pointers/SmartPointer.h>
#include <TNL/Timer.h>
#include <TNL/Cuda/DeviceInfo.h>
#include <TNL/Devices/Sequential.h>
#include <TNL/Devices/Host.h>

namespace TNL {
namespace Pointers {
@@ -109,6 +111,10 @@ Timer& getSmartPointersSynchronizationTimer()
template< typename Device >
bool synchronizeSmartPointersOnDevice( int deviceId = -1 )
{
   // TODO: better way to skip synchronization of host-only smart pointers
   if( std::is_same< Device, Devices::Sequential >::value || std::is_same< Device, Devices::Host >::value )
      return true;

   getSmartPointersSynchronizationTimer< Device >().start();
   bool b = getSmartPointersRegister< Device >().synchronizeDevice( deviceId );
   getSmartPointersSynchronizationTimer< Device >().stop();