"README.md" did not exist on "2c25f39873f660fbfa69477dfd4c8578c8e11688"
Newer
Older
/***************************************************************************
-------------------
begin : Jul 11, 2013
copyright : (C) 2013 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#include <TNL/Math.h>
#include <TNL/Config/ConfigDescription.h>
#include <TNL/Config/ParameterContainer.h>
#include <TNL/Devices/CudaDeviceInfo.h>
Jakub Klinkovský
committed
SmartPointersRegister Cuda::smartPointersRegister;
Timer Cuda::smartPointersSynchronizationTimer;
Jakub Klinkovský
committed
int Cuda::getNumberOfBlocks( const int threads,
Jakub Klinkovský
committed
const int blockSize )
{
return roundUpDivision( threads, blockSize );
}
int Cuda::getNumberOfGrids( const int blocks,
Jakub Klinkovský
committed
const int gridSize )
{
return roundUpDivision( blocks, gridSize );
}
Jakub Klinkovský
committed
void Cuda::configSetup( Config::ConfigDescription& config,
const String& prefix )
Jakub Klinkovský
committed
config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computation.", 0 );
Jakub Klinkovský
committed
config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computation (not supported on this system).", 0 );
Jakub Klinkovský
committed
bool Cuda::setup( const Config::ParameterContainer& parameters,
Jakub Klinkovský
committed
const String& prefix )
{
#ifdef HAVE_CUDA
int cudaDevice = parameters.getParameter< int >( "cuda-device" );
if( cudaSetDevice( cudaDevice ) != cudaSuccess )
{
std::cerr << "I cannot activate CUDA device number " << cudaDevice << "." << std::endl;
return false;
}
smartPointersSynchronizationTimer.reset();
smartPointersSynchronizationTimer.stop();
void Cuda::insertSmartPointer( SmartPointer* pointer )
Jakub Klinkovský
committed
smartPointersRegister.insert( pointer, Devices::CudaDeviceInfo::getActiveDevice() );
void Cuda::removeSmartPointer( SmartPointer* pointer )
Jakub Klinkovský
committed
smartPointersRegister.remove( pointer, Devices::CudaDeviceInfo::getActiveDevice() );
Jakub Klinkovský
committed
bool Cuda::synchronizeDevice( int deviceId )
{
Jakub Klinkovský
committed
if( deviceId < 0 )
deviceId = Devices::CudaDeviceInfo::getActiveDevice();
smartPointersSynchronizationTimer.start();
bool b = smartPointersRegister.synchronizeDevice( deviceId );
smartPointersSynchronizationTimer.stop();
return b;