Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
Special Functionality

Check build mode

This example shows how to check the build mode of the ogdf and user programs.

int main() {
#ifdef OGDF_DEBUG
bool debugMode = true;
#else
bool debugMode = false;
#endif
std::cout << "This user program is compiled in " << (debugMode ? "Debug" : "Release") << " mode." << std::endl;
std::cout << "The OGDF is compiled in " << (ogdf::debugMode ? "Debug" : "Release") << " mode." << std::endl;
if (debugMode != ogdf::debugMode) {
std::cout << "Check your configuration!" << std::endl;
return 1;
}
std::cout << "Everything is fine!" << std::endl;
return 0;
}
Basic declarations, included by all source files.
int main()
bool debugMode
Set to true iff debug mode is used during compilation of the OGDF.

As hinted at in this example the internal differentiation between Debug and Release build mode in the OGDF is handled via the preprocessor macro OGDF_DEBUG. Also, any compiled instance of the ogdf will expose the build mode it was compiled in via the flag ogdf::debugMode. This allows users to make sure the build configuration of their user code matches that of the ogdf library.

Displaying information about the system

This example shows how to query information about the system.

using namespace ogdf;
const char *yn(bool b)
{
return b ? "yes" : "no";
}
int main()
{
std::cout
<< "---------------------------------------" << std::endl
<< " System-specific information " << std::endl
<< "---------------------------------------" << std::endl
<< std::endl
<< "Cache / processors:" << std::endl
<< "-------------------" << std::endl
<< "Processors: " << System::numberOfProcessors() << std::endl
<< "L2-Cache: " << System::cacheSizeKBytes() << " KBytes" << std::endl
<< "Cache-Line: " << System::cacheLineBytes() << " Bytes" << std::endl
<< std::endl
<< "Supported technologies:" << std::endl
<< "-----------------------" << std::endl
<< "MMX: " << yn(System::cpuSupports(CPUFeature::MMX)) << std::endl
<< "SSE: " << yn(System::cpuSupports(CPUFeature::SSE)) << std::endl
<< "SSE2: " << yn(System::cpuSupports(CPUFeature::SSE2)) << std::endl
<< "SSE3: " << yn(System::cpuSupports(CPUFeature::SSE3)) << std::endl
<< "SSSE3: " << yn(System::cpuSupports(CPUFeature::SSSE3)) << std::endl
<< "SSE4.1: " << yn(System::cpuSupports(CPUFeature::SSE4_1)) << std::endl
<< "SSE4.2: " << yn(System::cpuSupports(CPUFeature::SSE4_2)) << std::endl
<< "VMX: " << yn(System::cpuSupports(CPUFeature::VMX)) << std::endl
<< "SMX: " << yn(System::cpuSupports(CPUFeature::SMX)) << std::endl
<< "EST: " << yn(System::cpuSupports(CPUFeature::EST)) << std::endl
<< std::endl
<< "Memory management:" << std::endl
<< "------------------" << std::endl
<< "Total physical memory: " << System::physicalMemory() / 1024 / 1024 << " MBytes" << std::endl
<< " available: " << System::availablePhysicalMemory() / 1024 / 1024 << " MBytes" << std::endl
<< " used by process: " << System::memoryUsedByProcess() / 1024 << " KBytes" << std::endl
#if defined(OGDF_SYSTEM_WINDOWS) || defined(__CYGWIN__)
<< " peak amount: " << System::peakMemoryUsedByProcess() / 1024 << " KBytes" << std::endl
#endif
<< std::endl
<< "allocated by malloc: " << System::memoryAllocatedByMalloc() / 1024 << " KBytes" << std::endl
<< " in freelist: " << System::memoryInFreelistOfMalloc() / 1024 << " KBytes" << std::endl
<< std::endl
<< "allocated by OGDF: " << System::memoryAllocatedByMemoryManager() / 1024 << " KBytes" << std::endl
<< " in global freelist: " << System::memoryInGlobalFreeListOfMemoryManager() / 1024 << " KBytes" << std::endl
<< " in thread freelist: " << System::memoryInThreadFreeListOfMemoryManager() / 1024 << " KBytes" << std::endl;
return 0;
}
Decalration of System class which provides unified access to system information.
The namespace for all OGDF objects.
const char * yn(bool b)

The ogdf::System interface enables you to query information about the system at runtime, including CPU thread count, cache sizes and supported technologies as well as some basic statistics about memory usage on the system. While most of this should probably not concern the average user, it might still be useful to know for more experienced users that by default the ogdf comes with and uses its own memory manager ogdf::PoolMemoryAllocator which will allocate memory in chunks for better runtime at the cost of some (minor) memory overhead. To compile with standard free/malloc memory management using ogdf::MallocMemoryAllocator you can define the preprocessor macro OGDF_MEMORY_MALLOC_TS via cmake. Note also that all ogdf algorithms will run sequentially unless multithreading is explicitly requested.