Commit e2ac7194 authored by Jakub Klinkovský's avatar Jakub Klinkovský

Cleaned up Devices::Cuda

parent a1a054bf
......@@ -20,13 +20,29 @@ namespace Devices {
class Cuda
{
public:
static inline void configSetup( Config::ConfigDescription& config, const String& prefix = "" );
static inline void configSetup( Config::ConfigDescription& config, const String& prefix = "" )
{
#ifdef HAVE_CUDA
config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computation.", 0 );
#else
config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computation (not supported on this system).", 0 );
#endif
}
static inline bool setup( const Config::ParameterContainer& parameters,
const String& prefix = "" );
const String& prefix = "" )
{
#ifdef HAVE_CUDA
int cudaDevice = parameters.getParameter< int >( prefix + "cuda-device" );
if( cudaSetDevice( cudaDevice ) != cudaSuccess )
{
std::cerr << "I cannot activate CUDA device number " << cudaDevice << "." << std::endl;
return false;
}
#endif
return true;
}
};
} // namespace Devices
} // namespace TNL
#include <TNL/Devices/Cuda_impl.h>
/***************************************************************************
Cuda_impl.h - description
-------------------
begin : Jan 21, 2014
copyright : (C) 2014 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#pragma once
#include <iostream>
#include <TNL/Math.h>
#include <TNL/Devices/Cuda.h>
#include <TNL/Cuda/DeviceInfo.h>
#include <TNL/Exceptions/CudaBadAlloc.h>
#include <TNL/Exceptions/CudaSupportMissing.h>
#include <TNL/Exceptions/CudaRuntimeError.h>
#include <TNL/Pointers/SmartPointersRegister.h>
namespace TNL {
namespace Devices {
inline void
Cuda::configSetup( Config::ConfigDescription& config,
const String& prefix )
{
#ifdef HAVE_CUDA
config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computation.", 0 );
#else
config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computation (not supported on this system).", 0 );
#endif
}
inline bool
Cuda::setup( const Config::ParameterContainer& parameters,
const String& prefix )
{
#ifdef HAVE_CUDA
int cudaDevice = parameters.getParameter< int >( prefix + "cuda-device" );
if( cudaSetDevice( cudaDevice ) != cudaSuccess )
{
std::cerr << "I cannot activate CUDA device number " << cudaDevice << "." << std::endl;
return false;
}
Pointers::getSmartPointersSynchronizationTimer< Devices::Cuda >().reset();
Pointers::getSmartPointersSynchronizationTimer< Devices::Cuda >().stop();
#endif
return true;
}
} // namespace Devices
} // namespace TNL
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment