Skip to content
Snippets Groups Projects
Commit 9723c16b authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Moved skipping of synchronization directly into the synchronizeSmartPointersOnDevice function

parent 9615d107
No related branches found
No related tags found
1 merge request!42Refactoring for execution policies
......@@ -37,8 +37,7 @@ 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 >();
Pointers::synchronizeSmartPointersOnDevice< DeviceType >();
Algorithms::ParallelFor< DeviceType >::exec(
(GlobalIndexType) 0, entitiesCount,
kernel,
......@@ -67,8 +66,7 @@ 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 >();
Pointers::synchronizeSmartPointersOnDevice< DeviceType >();
Algorithms::ParallelFor< DeviceType >::exec(
(GlobalIndexType) 0, entitiesCount,
kernel,
......@@ -96,8 +94,7 @@ 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 >();
Pointers::synchronizeSmartPointersOnDevice< DeviceType >();
Algorithms::ParallelFor< DeviceType >::exec(
(GlobalIndexType) 0, entitiesCount,
kernel,
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment