Loading src/core/CMakeLists.txt +6 −2 Original line number Diff line number Diff line Loading @@ -15,11 +15,14 @@ set (headers tnlAssert.h tnlDynamicTypeTag.h tnlFeature.h tnlFile.h tnlFile_impl.h tnlFlopsCounter.h tnlHost.h tnlIndexedSet.h tnlList.h tnlList_impl.h tnlLogger.h tnlOmp.h tnlObject.h tnlStack.h tnlStaticFor.h Loading Loading @@ -49,7 +52,8 @@ set( common_SOURCES ${CURRENT_DIR}/mfilename.cpp ${CURRENT_DIR}/mpi-supp.cpp ${CURRENT_DIR}/tnlCuda.cpp ${CURRENT_DIR}/tnlHost.cpp ) ${CURRENT_DIR}/tnlHost.cpp ${CURRENT_DIR}/tnlOmp.cpp ) IF( BUILD_CUDA ) set( tnl_core_CUDA__SOURCES Loading src/core/tnlCuda.cpp +26 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include <core/tnlCuda.h> #include <core/mfuncs.h> #include <tnlConfig.h> #include <config/tnlConfigDescription.h> #include <config/tnlParameterContainer.h> tnlString tnlCuda :: getDeviceType() { Loading Loading @@ -46,3 +48,26 @@ int tnlCuda::getNumberOfGrids( const int blocks, }*/ void tnlCuda::configSetup( tnlConfigDescription& config, const tnlString& prefix ) { #ifdef HAVE_CUDA config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computationon.", 0 ); #else config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computationon (not supported on this system).", 0 ); #endif } bool tnlCuda::setup( const tnlParameterContainer& parameters, const tnlString& 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; } #endif return true; } src/core/tnlCuda.cu +21 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,27 @@ #include <core/tnlCuda.h> void tnlCuda::configSetup( tnlConfigDescription& config, const tnlString& prefix ) { #ifdef HAVE_CUDA //config.addEntry< bool >( prefix + "omp-enabled", "Enable support of OpenMP.", true ); //config.addEntry< int >( prefix + "omp-max-threads", "Set maximum number of OpenMP threads.", omp_get_max_threads() ); #else //config.addEntry< bool >( prefix + "omp-enabled", "Enable support of OpenMP (not supported on this system).", false ); //config.addEntry< int >( prefix + "omp-max-threads", "Set maximum number of OpenMP threads (not supported on this system).", 0 ); #endif } bool tnlCuda::setup( const tnlParameterContainer& parameters, const tnlString& prefix ) { //enable = parameters.getParameter< bool >( prefix + "omp-enabled" ); //maxThreadsCount = parameters.getParameter< int ( prefix + "omp-max-threads" ); return true; } bool tnlCuda::checkDevice( const char* file_name, int line ) { cudaError error = cudaGetLastError(); Loading src/core/tnlCuda.h +9 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,9 @@ #include <core/tnlString.h> #include <core/tnlAssert.h> class tnlConfigDescription; class tnlParameterContainer; #ifdef HAVE_CUDA #define __cuda_callable__ __device__ __host__ #else Loading Loading @@ -91,6 +94,12 @@ class tnlCuda static bool checkDevice( const char* file_name, int line ) { return false;}; #endif static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" ); static bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ); }; #define checkCudaDevice tnlCuda::checkDevice( __FILE__, __LINE__ ) Loading src/core/tnlFile.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -68,3 +68,15 @@ bool tnlFile :: close() readElements = writtenElements = 0; return true; }; bool fileExists( const tnlString& fileName ) { fstream file; file.open( fileName. getString(), ios::in ); bool result( true ); if( ! file ) result = false; file.close(); return result; }; Loading
src/core/CMakeLists.txt +6 −2 Original line number Diff line number Diff line Loading @@ -15,11 +15,14 @@ set (headers tnlAssert.h tnlDynamicTypeTag.h tnlFeature.h tnlFile.h tnlFile_impl.h tnlFlopsCounter.h tnlHost.h tnlIndexedSet.h tnlList.h tnlList_impl.h tnlLogger.h tnlOmp.h tnlObject.h tnlStack.h tnlStaticFor.h Loading Loading @@ -49,7 +52,8 @@ set( common_SOURCES ${CURRENT_DIR}/mfilename.cpp ${CURRENT_DIR}/mpi-supp.cpp ${CURRENT_DIR}/tnlCuda.cpp ${CURRENT_DIR}/tnlHost.cpp ) ${CURRENT_DIR}/tnlHost.cpp ${CURRENT_DIR}/tnlOmp.cpp ) IF( BUILD_CUDA ) set( tnl_core_CUDA__SOURCES Loading
src/core/tnlCuda.cpp +26 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ #include <core/tnlCuda.h> #include <core/mfuncs.h> #include <tnlConfig.h> #include <config/tnlConfigDescription.h> #include <config/tnlParameterContainer.h> tnlString tnlCuda :: getDeviceType() { Loading Loading @@ -46,3 +48,26 @@ int tnlCuda::getNumberOfGrids( const int blocks, }*/ void tnlCuda::configSetup( tnlConfigDescription& config, const tnlString& prefix ) { #ifdef HAVE_CUDA config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computationon.", 0 ); #else config.addEntry< int >( prefix + "cuda-device", "Choose CUDA device to run the computationon (not supported on this system).", 0 ); #endif } bool tnlCuda::setup( const tnlParameterContainer& parameters, const tnlString& 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; } #endif return true; }
src/core/tnlCuda.cu +21 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,27 @@ #include <core/tnlCuda.h> void tnlCuda::configSetup( tnlConfigDescription& config, const tnlString& prefix ) { #ifdef HAVE_CUDA //config.addEntry< bool >( prefix + "omp-enabled", "Enable support of OpenMP.", true ); //config.addEntry< int >( prefix + "omp-max-threads", "Set maximum number of OpenMP threads.", omp_get_max_threads() ); #else //config.addEntry< bool >( prefix + "omp-enabled", "Enable support of OpenMP (not supported on this system).", false ); //config.addEntry< int >( prefix + "omp-max-threads", "Set maximum number of OpenMP threads (not supported on this system).", 0 ); #endif } bool tnlCuda::setup( const tnlParameterContainer& parameters, const tnlString& prefix ) { //enable = parameters.getParameter< bool >( prefix + "omp-enabled" ); //maxThreadsCount = parameters.getParameter< int ( prefix + "omp-max-threads" ); return true; } bool tnlCuda::checkDevice( const char* file_name, int line ) { cudaError error = cudaGetLastError(); Loading
src/core/tnlCuda.h +9 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,9 @@ #include <core/tnlString.h> #include <core/tnlAssert.h> class tnlConfigDescription; class tnlParameterContainer; #ifdef HAVE_CUDA #define __cuda_callable__ __device__ __host__ #else Loading Loading @@ -91,6 +94,12 @@ class tnlCuda static bool checkDevice( const char* file_name, int line ) { return false;}; #endif static void configSetup( tnlConfigDescription& config, const tnlString& prefix = "" ); static bool setup( const tnlParameterContainer& parameters, const tnlString& prefix = "" ); }; #define checkCudaDevice tnlCuda::checkDevice( __FILE__, __LINE__ ) Loading
src/core/tnlFile.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -68,3 +68,15 @@ bool tnlFile :: close() readElements = writtenElements = 0; return true; }; bool fileExists( const tnlString& fileName ) { fstream file; file.open( fileName. getString(), ios::in ); bool result( true ); if( ! file ) result = false; file.close(); return result; };