Loading src/TNL/Devices/Cuda.h +20 −4 Original line number Diff line number Diff line Loading @@ -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> src/TNL/Devices/Cuda_impl.hdeleted 100644 → 0 +0 −55 Original line number Diff line number Diff line /*************************************************************************** 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 Loading
src/TNL/Devices/Cuda.h +20 −4 Original line number Diff line number Diff line Loading @@ -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>
src/TNL/Devices/Cuda_impl.hdeleted 100644 → 0 +0 −55 Original line number Diff line number Diff line /*************************************************************************** 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