Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrastructure for Reference Tests #94

Open
wants to merge 36 commits into
base: code-style-enforcing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2347a4a
Payload: enable functionality to print the generated assembler
marenz2569 Nov 23, 2024
cbf8dd5
CMake:: make two static libraries available that are used in the build
marenz2569 Nov 23, 2024
121ac17
add ref test infrastructure and add first ref test
marenz2569 Nov 24, 2024
e6b7166
Move compile flag that is used in header file to toplevel cmake
marenz2569 Nov 24, 2024
978e660
add ref test for functions in firestarter
marenz2569 Nov 24, 2024
9fa50dd
add ci workflow for ctest
marenz2569 Nov 25, 2024
5a73928
cmake: add nlohmann_json depedency to firestarterlinux
marenz2569 Nov 25, 2024
0539cb4
cmake: add nlohmann_json depedency to firestartercore
marenz2569 Nov 25, 2024
53d5975
move cmake cxx standard definition up in hierarchy
marenz2569 Nov 25, 2024
d388a19
run ctest correctly in ci
marenz2569 Nov 25, 2024
6eca93b
run ctest correctly in ci
marenz2569 Nov 25, 2024
278604f
link correctly on darwin
marenz2569 Nov 25, 2024
6e1b752
enable position independant code on linux
marenz2569 Nov 25, 2024
dacec9d
refactor cmake
marenz2569 Nov 25, 2024
fe4d5e9
fix icx build
marenz2569 Nov 25, 2024
44119f8
add FIRESTARTER_HIP to the available build types
marenz2569 Nov 25, 2024
930e84b
add debug prints to cmake
marenz2569 Nov 26, 2024
5ae3e40
use hipcc to compile hip build
marenz2569 Nov 26, 2024
0ba17e0
fix assert in cuda wrapper code
marenz2569 Nov 26, 2024
8df365f
rewrite cuda exception in cuda/hip compat header
marenz2569 Nov 26, 2024
1a4ab9f
ci: refactor oneapi build
marenz2569 Nov 26, 2024
ae664c2
fix setting icx/icpx compiler
marenz2569 Nov 26, 2024
d46d9fc
ci: refactor cuda/nvhpc build
marenz2569 Nov 26, 2024
fbf1ca7
oneapi: link to threads
marenz2569 Nov 26, 2024
da4a1f0
make cmake find nvcc
marenz2569 Nov 26, 2024
bfcf5c3
fix cuda 8 and 11 builds
marenz2569 Nov 26, 2024
2d32c38
add comment to ci build yaml. fix cuda builds
marenz2569 Nov 26, 2024
d04125d
cmake: do not use dependent options as they do not work for our inten…
marenz2569 Nov 26, 2024
2e34ebb
rocm ci update upload artifact condition to the one that is used in a…
marenz2569 Nov 26, 2024
116194c
ci: fix rocm build configure
marenz2569 Nov 26, 2024
03d6099
ci: set CC variable in build correctly
marenz2569 Nov 26, 2024
6233237
ci: fix dependencies in build
marenz2569 Nov 26, 2024
00ebd7f
ci: fix type in comment
marenz2569 Nov 26, 2024
57776ea
ci: fix type in comment
marenz2569 Nov 26, 2024
049b627
Revert "add debug prints to cmake"
marenz2569 Nov 27, 2024
10e1572
Update readme section for HIP and ONEAPI compilers
marenz2569 Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
319 changes: 171 additions & 148 deletions .github/workflows/cmake.yml

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions .github/workflows/ctest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ctest

on: [push, pull_request]

env:
PYTHONUNBUFFERED: 1

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Install python3
run: |
sudo apt update
sudo apt install python3

- name: Create build directory
run: |
mkdir build

- name: Run CMake configure (default)
run: |
cd build
cmake ..

- name: Build
run: |
cd build
make -j4

- name: Ctest
run: |
cd build
ctest
41 changes: 7 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.22)
project(FIRESTARTER)
enable_testing()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)

include(cmake/GitSubmoduleUpdate.cmake)

Expand Down Expand Up @@ -55,41 +57,10 @@ endif()
include(cmake/GitSubmoduleUpdate.cmake)
git_submodule_update()

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2 -fdata-sections -ffunction-sections")
endif()
include(cmake/BuildOptions.cmake)
include(cmake/BuildSettings.cmake)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
else()
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
endif()

# enable debug features on linux
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
option(FIRESTARTER_DEBUG_FEATURES "Enable debug features" ON)
if (FIRESTARTER_DEBUG_FEATURES)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_DEBUG_FEATURES")
endif()
endif()

set(FIRESTARTER_BUILD_TYPE "FIRESTARTER" CACHE STRING "FIRESTARTER_BUILD_TYPE can be any of FIRESTARTER, FIRESTARTER_CUDA, FIRESTARTER_ONEAPI, or FIRESTARTER_HIP.")
set_property(CACHE FIRESTARTER_BUILD_TYPE PROPERTY STRINGS FIRESTARTER FIRESTARTER_CUDA FIRESTARTER_ONEAPI)
if (${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
option(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA or OneAPI enabled." ON)
endif()
if (${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_CUDA")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_ONEAPI")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER_HIP")
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)
endif()
option(FIRESTARTER_THREAD_AFFINITY "Enable FIRESTARTER to set affinity to hardware threads." ON)
include(cmake/DarwinBuild.cmake)

if(NOT DEFINED ASMJIT_STATIC)
set(ASMJIT_STATIC TRUE)
Expand All @@ -111,3 +82,5 @@ find_package(Threads REQUIRED)
include(cmake/InstallHwloc.cmake)

add_subdirectory(src)

add_subdirectory(test)
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,12 @@ CMake option | Description
`FIRESTARTER_BUILD_HWLOC` | Build hwloc dependency. Default `ON`
`FIRESTARTER_THREAD_AFFINITY` | Enable FIRESTARTER to set affinity to hardware threads. Default `ON`

When building `FIRESTARTER_ONEAPI` make sure that the Intel Math Kernel Library (MKL) and the complier `icx` can be found. These will be used to build `FIRESTARTER`, while dependencies will be build with `$CC` and `$CXX` respectively.
When building `FIRESTARTER_ONEAPI` make sure that the Intel Math Kernel
Library (MKL) and the complier `icx` and `icpx` can be found. Please provide
them through the `CC` and `CXX` environment variables.

When building `FIRESTARTER_HIP` make sure that the complier `hipcc` can be
found. Please provide it through the `CC` and `CXX` environment variables.

## Metrics

Expand Down
26 changes: 26 additions & 0 deletions cmake/BuildOptions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include(CMakeDependentOption)

# Set the different available FIRESTARTER builds.
set(FIRESTARTER_BUILD_TYPE "FIRESTARTER" CACHE STRING "FIRESTARTER_BUILD_TYPE can be any of FIRESTARTER, FIRESTARTER_CUDA, FIRESTARTER_ONEAPI, or FIRESTARTER_HIP.")
set_property(CACHE FIRESTARTER_BUILD_TYPE PROPERTY STRINGS FIRESTARTER FIRESTARTER_CUDA FIRESTARTER_ONEAPI FIRESTARTER_HIP)

# Static linking is not supported with GPU devices or MacOS.
if(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA, OneAPI or HIP enabled." ON)
endif()


# We vendor hwloc per default.
option(FIRESTARTER_BUILD_HWLOC "Build hwloc dependency." ON)


# Use of thread affinity is enabled on linux per default.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(FIRESTARTER_THREAD_AFFINITY "Enable FIRESTARTER to set affinity to hardware threads." ON)
endif()


# Debug feature are enabled on linux per default.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(FIRESTARTER_DEBUG_FEATURES "Enable debug features" ON)
endif()
69 changes: 69 additions & 0 deletions cmake/BuildSettings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Dependent Linux features
if(FIRESTARTER_LINK_STATIC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_LINK_STATIC")
endif()

if (FIRESTARTER_DEBUG_FEATURES)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_DEBUG_FEATURES")
endif()

if (FIRESTARTER_THREAD_AFFINITY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_THREAD_AFFINITY")
endif()


# Not MSVC
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -O2 -fdata-sections -ffunction-sections")
endif()


# Darwin
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip")
endif()


# Not (Darwin or MSVC)
# equivalent to Linux and Windows with mingw
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"))
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
endif()


# Linux
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# enable position independant code on linux
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()


# Find packages, set the compiler and compile flags specific to the selected FIRESTARTER build.
if(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
# No specific compiler selected
elseif ("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_CUDA")
find_package(CUDAToolkit REQUIRED)
include_directories(${CUDAToolkit_INCLUDE_DIRS})

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_BUILD_CUDA")
elseif ("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_ONEAPI")
find_program(ICX_PATH icx REQUIRED)

message(STATUS "Path of icx executable is: ${ICX_PATH}")

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -DFIRESTARTER_BUILD_ONEAPI")
elseif("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_HIP")
if (NOT DEFINED ROCM_PATH )
set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." )
endif ()

# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}/lib ${ROCM_PATH})
find_package(HIP REQUIRED)
find_package(rocblas REQUIRED)
find_package(rocrand REQUIRED)
find_package(hiprand REQUIRED)
find_package(hipblas REQUIRED)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFIRESTARTER_BUILD_HIP")
endif()
18 changes: 18 additions & 0 deletions cmake/DarwinBuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
find_library( COREFOUNDATION_LIBRARY CoreFoundation )
find_library( IOKIT_LIBRARY IOKit )
endif()

# Function to link against the correct libraries on darwin
function(target_link_libraries_darwin)
set(oneValueArgs NAME)
cmake_parse_arguments(TARGET "" "${oneValueArgs}"
"" ${ARGN} )

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_link_libraries(${TARGET_NAME}
${COREFOUNDATION_LIBRARY}
${IOKIT_LIBRARY}
)
endif()
endfunction()
4 changes: 4 additions & 0 deletions cmake/InstallHwloc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if (FIRESTARTER_BUILD_HWLOC)
BUILD_IN_SOURCE 1
BUILD_COMMAND make -j
INSTALL_COMMAND make install
BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libhwloc.a
)

SET(HWLOC_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/Hwloc/install")
Expand All @@ -36,6 +37,7 @@ if (FIRESTARTER_BUILD_HWLOC)
CONFIGURE_COMMAND ""
BUILD_COMMAND cd <SOURCE_DIR>\\contrib\\windows && MSBuild /p:Configuration=Release /p:Platform=x64 hwloc.sln
INSTALL_COMMAND ""
BUILD_BYPRODUCTS <SOURCE_DIR>/contrib/windows/x64/Release/libhwloc.lib
)

SET(HWLOC_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/Hwloc/sources")
Expand All @@ -55,6 +57,7 @@ if (FIRESTARTER_BUILD_HWLOC)
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_BYPRODUCTS <SOURCE_DIR>/lib/libhwloc.a
)

SET(HWLOC_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/Hwloc/sources")
Expand All @@ -66,4 +69,5 @@ if (FIRESTARTER_BUILD_HWLOC)
endif()

include_directories(${HWLOC_INCLUDE_DIR}/include)
add_dependencies(hwloc HwlocInstall)
endif()
18 changes: 6 additions & 12 deletions include/firestarter/Cuda/CudaHipCompat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,6 @@ auto getErrorString(CUresult Result) -> const char* {
accellSafeCall(cuGetErrorName(Result, &ErrorString), __FILE__, __LINE__);
return ErrorString;
}
#else
// define types to not run into compile errors with if constexpr

enum class CUresult {};
// NOLINTBEGIN(readability-identifier-naming)
constexpr const int CUDA_SUCCESS = 0;
// NOLINTEND(readability-identifier-naming)
#endif

template <typename T> void accellSafeCall(T TVal, const char* File, const int Line, std::optional<int> DeviceIndex) {
Expand All @@ -368,14 +361,15 @@ template <typename T> void accellSafeCall(T TVal, const char* File, const int Li
if (TVal == RandStatusT::RAND_STATUS_SUCCESS) {
return;
}
} else if constexpr (std::is_same_v<T, CUresult>) {
#ifndef FIRESTARTER_BUILD_CUDA
static_assert(false, "Tried to call accellSafeCall with CUresult, but not building for CUDA.");
#endif
}
#ifdef FIRESTARTER_BUILD_CUDA
else if constexpr (std::is_same_v<T, CUresult>) {
if (TVal == CUDA_SUCCESS) {
return;
}
} else {
}
#endif
else {
assert(false && "Tried to call accellSafeCall with an unknown type.");
}

Expand Down
3 changes: 2 additions & 1 deletion include/firestarter/Environment/Environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class Environment {
virtual void printSelectedCodePathSummary() = 0;

/// Print a list of available high-load function and if they are available on the current system.
virtual void printFunctionSummary() = 0;
/// \arg ForceYes Force all functions to be shown as avaialable
virtual void printFunctionSummary(bool ForceYes) = 0;

/// Get the number of threads FIRESTARTER will run with.
[[nodiscard]] auto requestedNumThreads() const -> uint64_t { return RequestedNumThreads; }
Expand Down
5 changes: 3 additions & 2 deletions include/firestarter/Environment/Payload/Payload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ class Payload {
/// compiled payload.
/// \arg ErrorDetection Should the code to support error detection between thread be baked into the high load routine
/// of the compiled payload.
/// \arg PrintAssembler Should the generated assembler code be logged.
/// \returns The compiled payload that provides access to the init and load functions.
[[nodiscard]] virtual auto compilePayload(const PayloadSettings& Settings, bool DumpRegisters,
bool ErrorDetection) const -> CompiledPayload::UniquePtr = 0;
[[nodiscard]] virtual auto compilePayload(const PayloadSettings& Settings, bool DumpRegisters, bool ErrorDetection,
bool PrintAssembler) const -> CompiledPayload::UniquePtr = 0;

/// Get the available instruction items that are supported by this payload.
/// \returns The available instruction items that are supported by this payload.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ class AVX512Payload final : public X86Payload {
/// compiled payload.
/// \arg ErrorDetection Should the code to support error detection between thread be baked into the high load routine
/// of the compiled payload.
/// \arg PrintAssembler Should the generated assembler code be logged.
/// \returns The compiled payload that provides access to the init and load functions.
[[nodiscard]] auto compilePayload(const environment::payload::PayloadSettings& Settings, bool DumpRegisters,
bool ErrorDetection) const
bool ErrorDetection, bool PrintAssembler) const
-> environment::payload::CompiledPayload::UniquePtr override;

private:
Expand Down
3 changes: 2 additions & 1 deletion include/firestarter/Environment/X86/Payload/AVXPayload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class AVXPayload final : public X86Payload {
/// compiled payload.
/// \arg ErrorDetection Should the code to support error detection between thread be baked into the high load routine
/// of the compiled payload.
/// \arg PrintAssembler Should the generated assembler code be logged.
/// \returns The compiled payload that provides access to the init and load functions.
[[nodiscard]] auto compilePayload(const environment::payload::PayloadSettings& Settings, bool DumpRegisters,
bool ErrorDetection) const
bool ErrorDetection, bool PrintAssembler) const
-> environment::payload::CompiledPayload::UniquePtr override;

private:
Expand Down
3 changes: 2 additions & 1 deletion include/firestarter/Environment/X86/Payload/FMA4Payload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class FMA4Payload final : public X86Payload {
/// compiled payload.
/// \arg ErrorDetection Should the code to support error detection between thread be baked into the high load routine
/// of the compiled payload.
/// \arg PrintAssembler Should the generated assembler code be logged.
/// \returns The compiled payload that provides access to the init and load functions.
[[nodiscard]] auto compilePayload(const environment::payload::PayloadSettings& Settings, bool DumpRegisters,
bool ErrorDetection) const
bool ErrorDetection, bool PrintAssembler) const
-> environment::payload::CompiledPayload::UniquePtr override;

private:
Expand Down
3 changes: 2 additions & 1 deletion include/firestarter/Environment/X86/Payload/FMAPayload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ class FMAPayload final : public X86Payload {
/// compiled payload.
/// \arg ErrorDetection Should the code to support error detection between thread be baked into the high load routine
/// of the compiled payload.
/// \arg PrintAssembler Should the generated assembler code be logged.
/// \returns The compiled payload that provides access to the init and load functions.
[[nodiscard]] auto compilePayload(const environment::payload::PayloadSettings& Settings, bool DumpRegisters,
bool ErrorDetection) const
bool ErrorDetection, bool PrintAssembler) const
-> environment::payload::CompiledPayload::UniquePtr override;

private:
Expand Down
3 changes: 2 additions & 1 deletion include/firestarter/Environment/X86/Payload/SSE2Payload.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class SSE2Payload final : public X86Payload {
/// compiled payload.
/// \arg ErrorDetection Should the code to support error detection between thread be baked into the high load routine
/// of the compiled payload.
/// \arg PrintAssembler Should the generated assembler code be logged.
/// \returns The compiled payload that provides access to the init and load functions.
[[nodiscard]] auto compilePayload(const environment::payload::PayloadSettings& Settings, bool DumpRegisters,
bool ErrorDetection) const
bool ErrorDetection, bool PrintAssembler) const
-> environment::payload::CompiledPayload::UniquePtr override;

private:
Expand Down
Loading
Loading