Skip to content

Commit

Permalink
add ref test for CPUTopology class
Browse files Browse the repository at this point in the history
  • Loading branch information
marenz2569 committed Dec 9, 2024
1 parent 932ed01 commit 912b7e7
Show file tree
Hide file tree
Showing 7 changed files with 2,403 additions and 3 deletions.
17 changes: 14 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
find_package(Python REQUIRED)

# Function to add reference tests
# Argument NAME: The required name of the executable that will be executed in this test. This name is also used for the ref-file if REFNAME is not supplied.
# Argument REFNAME: The optional name of the ref-file that should be used for this test.
function(add_ref_test)
set(oneValueArgs NAME)
set(oneValueArgs NAME REFNAME)
cmake_parse_arguments(TEST "" "${oneValueArgs}"
"" ${ARGN} )

add_test(NAME ${TEST_NAME}
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tooling/ref-test.py $<TARGET_FILE:${TEST_NAME}> ${PROJECT_SOURCE_DIR}/test/refs/${TEST_NAME}.log
if(NOT DEFINED TEST_NAME)
message(FATAL_ERROR "Called add_ref_test without a name.")
endif()

if(NOT DEFINED TEST_REFNAME)
set(TEST_REFNAME ${TEST_NAME})
endif()

add_test(NAME ${TEST_REFNAME}
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/tooling/ref-test.py $<TARGET_FILE:${TEST_NAME}> ${PROJECT_SOURCE_DIR}/test/refs/${TEST_REFNAME}.log
)
endfunction()

add_subdirectory(DumpCPUTopology)
add_subdirectory(DumpPayloads)
add_subdirectory(X86Functions)
15 changes: 15 additions & 0 deletions test/DumpCPUTopology/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
add_executable(DumpCPUTopology Main.cpp)
target_link_libraries(DumpCPUTopology firestartercore)
target_link_libraries_darwin(NAME DumpCPUTopology)

file(GLOB TEST_FILES inputs/*.xml)

foreach(testfile ${TEST_FILES})
get_filename_component(testname ${testfile} NAME_WLE)

add_ref_test(NAME DumpCPUTopology
REFNAME DumpCPUTopology/${testname})

# Set the correct topology xml file for the ref test
set_property(TEST DumpCPUTopology/${testname} PROPERTY ENVIRONMENT "HWLOC_XMLFILE=${testfile}")
endforeach()
66 changes: 66 additions & 0 deletions test/DumpCPUTopology/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/******************************************************************************
* FIRESTARTER - A Processor Stress Test Utility
* Copyright (C) 2024 TU Dresden, Center for Information Services and High
* Performance Computing
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/\>.
*
* Contact: [email protected]
*****************************************************************************/

#include "firestarter/CPUTopology.hpp"
#include "firestarter/Logging/Log.hpp"

#include <sstream>

auto main(int /*argc*/, const char** /*argv*/) -> int {
firestarter::logging::Filter<firestarter::logging::record>::set_severity(nitro::log::severity_level::info);

firestarter::CPUTopology Topology;

{
std::stringstream Ss;
Topology.printCacheSummary(Ss);
firestarter::log::info() << Ss.str();
}

{
auto ICacheSize = Topology.instructionCacheSize();
if (ICacheSize) {
firestarter::log::info() << "InstructionCacheSize: " << *ICacheSize;
}
}

{
auto Resouces = Topology.homogenousResourceCount();
firestarter::log::info() << "NumCoresTotal: " << Resouces.NumCoresTotal;
firestarter::log::info() << "NumPackagesTotal: " << Resouces.NumPackagesTotal;
firestarter::log::info() << "NumThreadsPerCore: " << Resouces.NumThreadsPerCore;
}

{
auto ThreadsInfo = Topology.hardwareThreadsInfo();
firestarter::log::info() << "MaxNumThreads: " << ThreadsInfo.MaxNumThreads;
firestarter::log::info() << "MaxPhysicalIndex: " << ThreadsInfo.MaxPhysicalIndex;

std::stringstream PhysicalIndicies;
PhysicalIndicies << "MaxPhysicalIndex: ";
for (const auto& Index : ThreadsInfo.OsIndices) {
PhysicalIndicies << Index << " ";
}
firestarter::log::info() << PhysicalIndicies.str();
}

return EXIT_SUCCESS;
}
Loading

0 comments on commit 912b7e7

Please sign in to comment.