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

Moved stuff from Logger::writeSystemInformation to Devices::Host and Devices::CudaDeviceInfo

parent 48c346ad
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#ifndef HAVE_CUDA #ifndef HAVE_CUDA
#include <TNL/Devices/CudaDeviceInfo.h> #include <TNL/Devices/CudaDeviceInfo.h>
#include <TNL/Logger.h>
namespace TNL { namespace TNL {
namespace Devices { namespace Devices {
...@@ -106,6 +107,12 @@ getCudaCores( int deviceNum ) ...@@ -106,6 +107,12 @@ getCudaCores( int deviceNum )
return 0; return 0;
} }
void
CudaDeviceInfo::
writeDeviceInfo( Logger& logger )
{
}
} // namespace Devices } // namespace Devices
} // namespace TNL } // namespace TNL
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <unordered_map> #include <unordered_map>
#include <TNL/Devices/CudaDeviceInfo.h> #include <TNL/Devices/CudaDeviceInfo.h>
#include <TNL/Logger.h>
namespace TNL { namespace TNL {
namespace Devices { namespace Devices {
...@@ -158,6 +159,35 @@ getCudaCores( int deviceNum ) ...@@ -158,6 +159,35 @@ getCudaCores( int deviceNum )
CudaDeviceInfo::getCudaCoresPerMultiprocessors( deviceNum ); CudaDeviceInfo::getCudaCoresPerMultiprocessors( deviceNum );
} }
void
CudaDeviceInfo::
writeDeviceInfo( Logger& logger )
{
logger.writeParameter< String >( "CUDA GPU info", String("") );
// TODO: Printing all devices does not make sense until TNL can actually
// use more than one device for computations. Printing only the active
// device for now...
// int devices = getNumberOfDevices();
// writeParameter< int >( "Number of devices", devices, 1 );
// for( int i = 0; i < devices; i++ )
// {
// logger.writeParameter< int >( "Device no.", i, 1 );
int i = getActiveDevice();
logger.writeParameter< String >( "Name", getDeviceName( i ), 2 );
String deviceArch = String( getArchitectureMajor( i ) ) + "." +
String( getArchitectureMinor( i ) );
logger.writeParameter< String >( "Architecture", deviceArch, 2 );
logger.writeParameter< int >( "CUDA cores", getCudaCores( i ), 2 );
double clockRate = ( double ) getClockRate( i ) / 1.0e3;
logger.writeParameter< double >( "Clock rate (in MHz)", clockRate, 2 );
double globalMemory = ( double ) getGlobalMemory( i ) / 1.0e9;
logger.writeParameter< double >( "Global memory (in GB)", globalMemory, 2 );
double memoryClockRate = ( double ) getMemoryClockRate( i ) / 1.0e3;
logger.writeParameter< double >( "Memory clock rate (in Mhz)", memoryClockRate, 2 );
logger.writeParameter< bool >( "ECC enabled", getECCEnabled( i ), 2 );
// }
}
} // namespace Devices } // namespace Devices
} // namespace TNL } // namespace TNL
......
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include <TNL/String.h> #include <TNL/String.h>
namespace TNL { namespace TNL {
class Logger;
namespace Devices { namespace Devices {
class CudaDeviceInfo class CudaDeviceInfo
...@@ -47,8 +50,8 @@ class CudaDeviceInfo ...@@ -47,8 +50,8 @@ class CudaDeviceInfo
static int getCudaCores( int deviceNum ); static int getCudaCores( int deviceNum );
static void writeDeviceInfo( Logger& logger );
}; };
} // namespace Devices } // namespace Devices
} // namespace TNL } // namespace TNL
...@@ -20,9 +20,11 @@ ...@@ -20,9 +20,11 @@
#include <omp.h> #include <omp.h>
#endif #endif
#include <TNL/tnlConfig.h>
#include <TNL/Devices/Host.h> #include <TNL/Devices/Host.h>
#include <TNL/Config/ConfigDescription.h> #include <TNL/Config/ConfigDescription.h>
#include <TNL/Config/ParameterContainer.h> #include <TNL/Config/ParameterContainer.h>
#include <TNL/Logger.h>
namespace TNL { namespace TNL {
namespace Devices { namespace Devices {
...@@ -90,6 +92,8 @@ Host::getCurrentTime( const char* format ) ...@@ -90,6 +92,8 @@ Host::getCurrentTime( const char* format )
int int
Host::getNumberOfProcessors( void ) Host::getNumberOfProcessors( void )
{ {
if( numberOfProcessors == 0 )
parseCPUInfo();
return numberOfProcessors; return numberOfProcessors;
} }
...@@ -103,18 +107,24 @@ Host::getOnlineCPUs( void ) ...@@ -103,18 +107,24 @@ Host::getOnlineCPUs( void )
int int
Host::getNumberOfCores( int cpu_id ) Host::getNumberOfCores( int cpu_id )
{ {
if( CPUCores == 0 )
parseCPUInfo();
return CPUCores; return CPUCores;
} }
int int
Host::getNumberOfThreads( int cpu_id ) Host::getNumberOfThreads( int cpu_id )
{ {
if( CPUThreads == 0 )
parseCPUInfo();
return CPUThreads; return CPUThreads;
} }
String String
Host::getCPUModelName( int cpu_id ) Host::getCPUModelName( int cpu_id )
{ {
if( CPUModelName == "" )
parseCPUInfo();
return CPUModelName; return CPUModelName;
} }
...@@ -157,6 +167,35 @@ Host::getCPUCacheSizes( int cpu_id ) ...@@ -157,6 +167,35 @@ Host::getCPUCacheSizes( int cpu_id )
return sizes; return sizes;
} }
void
Host::
writeDeviceInfo( Logger& logger )
{
logger.writeParameter< String >( "Host name:", getHostname() );
logger.writeParameter< String >( "System:", getSystemName() );
logger.writeParameter< String >( "Release:", getSystemRelease() );
logger.writeParameter< String >( "Architecture:", getArchitecture() );
logger.writeParameter< char* >( "TNL Compiler:", ( char* ) TNL_CPP_COMPILER_NAME );
// FIXME: generalize for multi-socket systems, here we consider only the first found CPU
const int cpu_id = 0;
const int threads = getNumberOfThreads( cpu_id );
const int cores = getNumberOfCores( cpu_id );
int threadsPerCore = 0;
if( cores > 0 )
threadsPerCore = threads / cores;
logger.writeParameter< String >( "CPU info", String("") );
logger.writeParameter< String >( "Model name:", getCPUModelName( cpu_id ), 1 );
logger.writeParameter< int >( "Cores:", cores, 1 );
logger.writeParameter< int >( "Threads per core:", threadsPerCore, 1 );
logger.writeParameter< String >( "Max clock rate (in MHz):", getCPUMaxFrequency( cpu_id ) / 1000, 1 );
CacheSizes cacheSizes = getCPUCacheSizes( cpu_id );
String cacheInfo = String( cacheSizes.L1data ) + ", "
+ String( cacheSizes.L1instruction ) + ", "
+ String( cacheSizes.L2 ) + ", "
+ String( cacheSizes.L3 );
logger.writeParameter< String >( "Cache (L1d, L1i, L2, L3):", cacheInfo, 1 );
}
void void
Host::parseCPUInfo( void ) Host::parseCPUInfo( void )
{ {
......
...@@ -21,6 +21,8 @@ namespace Config { ...@@ -21,6 +21,8 @@ namespace Config {
class ParameterContainer; class ParameterContainer;
} }
class Logger;
namespace Devices { namespace Devices {
struct CacheSizes { struct CacheSizes {
...@@ -50,6 +52,8 @@ class Host ...@@ -50,6 +52,8 @@ class Host
static int getCPUMaxFrequency( int cpu_id ); static int getCPUMaxFrequency( int cpu_id );
static CacheSizes getCPUCacheSizes( int cpu_id ); static CacheSizes getCPUCacheSizes( int cpu_id );
static void writeDeviceInfo( Logger& logger );
static size_t getFreeMemory(); static size_t getFreeMemory();
static void disableOMP(); static void disableOMP();
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <iomanip> #include <iomanip>
#include <TNL/Logger.h> #include <TNL/Logger.h>
#include <TNL/tnlConfig.h>
#include <TNL/Devices/Host.h> #include <TNL/Devices/Host.h>
#include <TNL/Devices/CudaDeviceInfo.h> #include <TNL/Devices/CudaDeviceInfo.h>
...@@ -45,53 +44,9 @@ void Logger :: writeSeparator() ...@@ -45,53 +44,9 @@ void Logger :: writeSeparator()
bool Logger :: writeSystemInformation( const Config::ParameterContainer& parameters ) bool Logger :: writeSystemInformation( const Config::ParameterContainer& parameters )
{ {
writeParameter< String >( "Host name:", Devices::Host::getHostname() ); Devices::Host::writeDeviceInfo( *this );
writeParameter< String >( "Architecture:", Devices::Host::getArchitecture() );
// FIXME: generalize for multi-socket systems, here we consider only the first found CPU
const int cpu_id = 0;
const int threads = Devices::Host::getNumberOfThreads( cpu_id );
const int cores = Devices::Host::getNumberOfCores( cpu_id );
int threadsPerCore = threads / cores;
writeParameter< String >( "CPU info", String("") );
writeParameter< String >( "Model name:", Devices::Host::getCPUModelName( cpu_id ), 1 );
writeParameter< int >( "Cores:", cores, 1 );
writeParameter< int >( "Threads per core:", threadsPerCore, 1 );
writeParameter< String >( "Max clock rate (in MHz):", Devices::Host::getCPUMaxFrequency( cpu_id ) / 1000, 1 );
Devices::CacheSizes cacheSizes = Devices::Host::getCPUCacheSizes( cpu_id );
String cacheInfo = String( cacheSizes.L1data ) + ", "
+ String( cacheSizes.L1instruction ) + ", "
+ String( cacheSizes.L2 ) + ", "
+ String( cacheSizes.L3 );
writeParameter< String >( "Cache (L1d, L1i, L2, L3):", cacheInfo, 1 );
if( parameters.getParameter< String >( "device" ) == "cuda" ) if( parameters.getParameter< String >( "device" ) == "cuda" )
{ Devices::CudaDeviceInfo::writeDeviceInfo( *this );
writeParameter< String >( "CUDA GPU info", String("") );
// TODO: Printing all devices does not make sense, but in the future TNL
// might use more than one device for computations. Printing only
// the active device for now...
// int devices = Devices::CudaDeviceInfo::getNumberOfDevices();
// writeParameter< int >( "Number of devices", devices, 1 );
// for( int i = 0; i < devices; i++ )
// {
// writeParameter< int >( "Device no.", i, 1 );
int i = Devices::CudaDeviceInfo::getActiveDevice();
writeParameter< String >( "Name", Devices::CudaDeviceInfo::getDeviceName( i ), 2 );
String deviceArch = String( Devices::CudaDeviceInfo::getArchitectureMajor( i ) ) + "." +
String( Devices::CudaDeviceInfo::getArchitectureMinor( i ) );
writeParameter< String >( "Architecture", deviceArch, 2 );
writeParameter< int >( "CUDA cores", Devices::CudaDeviceInfo::getCudaCores( i ), 2 );
double clockRate = ( double ) Devices::CudaDeviceInfo::getClockRate( i ) / 1.0e3;
writeParameter< double >( "Clock rate (in MHz)", clockRate, 2 );
double globalMemory = ( double ) Devices::CudaDeviceInfo::getGlobalMemory( i ) / 1.0e9;
writeParameter< double >( "Global memory (in GB)", globalMemory, 2 );
double memoryClockRate = ( double ) Devices::CudaDeviceInfo::getMemoryClockRate( i ) / 1.0e3;
writeParameter< double >( "Memory clock rate (in Mhz)", memoryClockRate, 2 );
writeParameter< bool >( "ECC enabled", Devices::CudaDeviceInfo::getECCEnabled( i ), 2 );
// }
}
writeParameter< String >( "System:", Devices::Host::getSystemName() );
writeParameter< String >( "Release:", Devices::Host::getSystemRelease() );
writeParameter< char* >( "TNL Compiler:", ( char* ) TNL_CPP_COMPILER_NAME );
return true; return true;
} }
...@@ -102,29 +57,28 @@ void Logger :: writeCurrentTime( const char* label ) ...@@ -102,29 +57,28 @@ void Logger :: writeCurrentTime( const char* label )
#ifdef TEMPLATE_EXPLICIT_INSTANTIATION #ifdef TEMPLATE_EXPLICIT_INSTANTIATION
template void Logger::writeParameter< char* >( const String&, template void Logger::writeParameter< char* >( const String&,
const String&, const String&,
const Config::ParameterContainer&, const Config::ParameterContainer&,
int ); int );
template void Logger::writeParameter< double >( const String&, template void Logger::writeParameter< double >( const String&,
const String&,
const Config::ParameterContainer&,
int );
template void Logger::writeParameter< int >( const String&,
const String&, const String&,
const Config::ParameterContainer&, const Config::ParameterContainer&,
int ); int );
template void Logger::writeParameter< int >( const String&,
const String&,
const Config::ParameterContainer&,
int );
// TODO: fix this // TODO: fix this
//template void Logger :: WriteParameter< char* >( const char*, //template void Logger :: WriteParameter< char* >( const char*,
// const char*&, // const char*&,
// int ); // int );
template void Logger::writeParameter< double >( const String&, template void Logger::writeParameter< double >( const String&,
const double&, const double&,
int );
template void Logger::writeParameter< int >( const String&,
const int&,
int ); int );
template void Logger::writeParameter< int >( const String&,
const int&,
int );
#endif #endif
} // namespace TNL } // namespace TNL
...@@ -26,7 +26,6 @@ class Logger ...@@ -26,7 +26,6 @@ class Logger
void writeSeparator(); void writeSeparator();
// TODO: move this to Devices::Host
bool writeSystemInformation( const Config::ParameterContainer& parameters ); bool writeSystemInformation( const Config::ParameterContainer& parameters );
...@@ -59,28 +58,28 @@ namespace TNL { ...@@ -59,28 +58,28 @@ namespace TNL {
#ifdef TEMPLATE_EXPLICIT_INSTANTIATION #ifdef TEMPLATE_EXPLICIT_INSTANTIATION
extern template void Logger::writeParameter< char* >( const String&, extern template void Logger::writeParameter< char* >( const String&,
const String&, const String&,
const Config::ParameterContainer&, const Config::ParameterContainer&,
int ); int );
extern template void Logger::writeParameter< double >( const String&, extern template void Logger::writeParameter< double >( const String&,
const String&,
const Config::ParameterContainer&,
int );
extern template void Logger::writeParameter< int >( const String&,
const String&, const String&,
const Config::ParameterContainer&, const Config::ParameterContainer&,
int ); int );
extern template void Logger::writeParameter< int >( const String&,
const String&,
const Config::ParameterContainer&,
int );
// TODO: fix this // TODO: fix this
//extern template void Logger :: WriteParameter< char* >( const char*, //extern template void Logger :: WriteParameter< char* >( const char*,
// const char*&, // const char*&,
// int ); // int );
extern template void Logger::writeParameter< double >( const String&, extern template void Logger::writeParameter< double >( const String&,
const double&, const double&,
int );
extern template void Logger::writeParameter< int >( const String&,
const int&,
int ); int );
extern template void Logger::writeParameter< int >( const String&,
const int&,
int );
#endif #endif
} // namespace TNL } // namespace TNL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment