Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
74ec73b
updated build workflow
mtygesen Apr 11, 2025
153863f
small change
mtygesen Apr 11, 2025
64c7147
added debug job
mtygesen Apr 11, 2025
73c30fc
cmake fixes
mtygesen Apr 11, 2025
c422024
test
mtygesen Apr 11, 2025
9423f40
update cmake
mtygesen Apr 11, 2025
7defe07
python test gen update
mtygesen Apr 11, 2025
a64d339
path fix
mtygesen Apr 11, 2025
5c68c75
cmake update
mtygesen Apr 11, 2025
d8344ed
updates
mtygesen Apr 11, 2025
238f0fb
Test
mtygesen Apr 11, 2025
6167a22
artifact changes
mtygesen Apr 11, 2025
4a1c118
reorder
mtygesen Apr 11, 2025
e519e22
revert
mtygesen Apr 11, 2025
d2c8fe1
debug
mtygesen Apr 11, 2025
8fbe6bb
test fixg
mtygesen Apr 11, 2025
55e89bf
debug
mtygesen Apr 11, 2025
4bc0f8a
rm
mtygesen Apr 11, 2025
3108cc0
test
mtygesen Apr 11, 2025
f488a77
prepare lin pack
mtygesen Apr 11, 2025
8d067ab
test
mtygesen Apr 11, 2025
080c6fc
test
mtygesen Apr 11, 2025
2c8bf4a
test
mtygesen Apr 11, 2025
2263d81
test
mtygesen Apr 11, 2025
5052ad7
test
mtygesen Apr 11, 2025
7646068
linux test
mtygesen Apr 14, 2025
9c2498a
simplification test
mtygesen Apr 14, 2025
cffc9f2
macos test
mtygesen Apr 14, 2025
95c8971
simplficiation
mtygesen Apr 14, 2025
2dc61f8
lin test
mtygesen Apr 14, 2025
d6caf66
linux test
mtygesen Apr 14, 2025
f2eac51
visibility test
mtygesen Apr 14, 2025
154a6c7
added threads dependency
mtygesen Apr 14, 2025
0d7ff6c
update
mtygesen Apr 14, 2025
94b3e54
g++ on win test
mtygesen Apr 14, 2025
ef98725
static fix
mtygesen Apr 14, 2025
2f6ae56
use mingw 14.2
mtygesen Apr 14, 2025
bfbcf0f
win test
mtygesen Apr 14, 2025
28eed6a
revert to msvc
mtygesen Apr 14, 2025
2e69a1e
revert to msvc
mtygesen Apr 14, 2025
69deb0f
debug log to test output
mtygesen Apr 14, 2025
d51ca53
debug logs
mtygesen Apr 14, 2025
e53b94d
test only linux
mtygesen Apr 14, 2025
617e40c
test
mtygesen Apr 14, 2025
ce82d9e
windows dll fix
mtygesen Apr 14, 2025
21f4dfc
windows dll fix
mtygesen Apr 14, 2025
f6afa39
windows cleanup
mtygesen Apr 14, 2025
2f7b5ff
win updates
mtygesen Apr 14, 2025
e136b20
win subdir test
mtygesen Apr 14, 2025
9f09b00
enable test for win
mtygesen Apr 14, 2025
b169fa9
test fix + exclusion
mtygesen Apr 14, 2025
921cedf
fix broken test
mtygesen Apr 14, 2025
d62c6c5
test fix on win & enable all tests
mtygesen Apr 14, 2025
d379844
enable macos test
mtygesen Apr 14, 2025
1fa36ee
macos config fix
mtygesen Apr 14, 2025
c9a1fc7
fix for linux
mtygesen Apr 14, 2025
bcb0ae7
debug log
mtygesen Apr 14, 2025
eff9841
revert
mtygesen Apr 14, 2025
1ae8850
disable mac for now
mtygesen Apr 14, 2025
c52abd4
rm macos from matrix
mtygesen Apr 14, 2025
c29a338
matrix fix
mtygesen Apr 14, 2025
06c8407
small fix for windows
mtygesen Apr 14, 2025
a14f64e
small updates
mtygesen Apr 14, 2025
ef78f31
removed unused import
mtygesen Apr 14, 2025
0ab2408
win fix
mtygesen Apr 14, 2025
e7bcc74
just to be sure
mtygesen Apr 14, 2025
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
75 changes: 48 additions & 27 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ jobs:
fail-fast: false

matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
os: [windows-latest, ubuntu-latest]
build_type: [Release]
include:
- os: windows-latest
build_type: Release
- os: ubuntu-latest
build_type: Release
cpp_compiler: g++
- os: macos-latest
build_type: Release
cpp_compiler: g++

steps:
Expand All @@ -46,51 +41,77 @@ jobs:
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake (Unix)
if: matrix.os != 'windows-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}

- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-G "Visual Studio 17 2022" -A x64
-DFORCE_TESTS=ON
-S ${{ github.workspace }}

- name: Configure CMake (Unix)
if: matrix.os != 'windows-latest'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DFORCE_TESTS=ON
-S ${{ github.workspace }}

- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Generate Test Data
run: python ${{ github.workspace }}/tests/generate_test_data.py
working-directory: ${{ github.workspace }}

- name: Test
run: ctest --build-config ${{ matrix.build_type }} --output-on-failure --verbose
working-directory: ${{ steps.strings.outputs.build-output-dir }}

- name: Upload Linux
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: palloc-linux
path: build/palloc
if-no-files-found: error

- name: Upload Windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
uses: eXhumer/upload-artifact@0b7d5f5684d3f642f978d2faad9ade64f5b4dd57
with:
name: palloc-win
path: build/Release/palloc.exe
path: |
${{ steps.strings.outputs.build-output-dir }}/palloc-win
!${{ steps.strings.outputs.build-output-dir }}/palloc-win/lib
!${{ steps.strings.outputs.build-output-dir }}/palloc-win/bin/palloc_tests.exe
if-no-files-found: error

- name: Upload Linux
if: matrix.os == 'ubuntu-latest'
uses: eXhumer/upload-artifact@0b7d5f5684d3f642f978d2faad9ade64f5b4dd57
with:
name: palloc-linux
path: |
${{ steps.strings.outputs.build-output-dir }}/palloc-linux
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/examples
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/include
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/Makefile
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/README.md
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/lib/cmake
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/lib/pkgconfig
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/bin
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/share
if-no-files-found: error

- name: Upload macOS
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
uses: eXhumer/upload-artifact@0b7d5f5684d3f642f978d2faad9ade64f5b4dd57
with:
name: palloc-macos
path: build/palloc
path: |
${{ steps.strings.outputs.build-output-dir }}/palloc-macos
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/examples
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/include
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/Makefile
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/README.md
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/lib/cmake
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/lib/pkgconfig
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/bin
!${{ steps.strings.outputs.build-output-dir }}/palloc-linux/lib/or-tools/share
if-no-files-found: error

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ FlameGraph
summary.txt
.progress
.progress_lock
job_list.txt
job_list.txt
*.supp
48 changes: 40 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@ set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Output directory
if(WIN32)
set(PLATFORM_DIR "${CMAKE_BINARY_DIR}/palloc-win")
elseif(LINUX)
set(PLATFORM_DIR "${CMAKE_BINARY_DIR}/palloc-linux")
elseif(APPLE)
set(PLATFORM_DIR "${CMAKE_BINARY_DIR}/palloc-macos")
endif()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PLATFORM_DIR}/bin")
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${PLATFORM_DIR}/bin")
endforeach()

# Project root macro
add_definitions(-DPROJECT_ROOT="${CMAKE_SOURCE_DIR}")

if(WIN32)
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "/W4 /Od /DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "/O2")
set(CMAKE_CXX_FLAGS_PERF "${CMAKE_CXX_FLAGS_RELEASE}")
Expand All @@ -30,12 +43,14 @@ else()
set(CMAKE_CXX_FLAGS_PERF "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-omit-frame-pointer")
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER)
message(STATUS "${CMAKE_BUILD_TYPE} CXX Flags: ${CMAKE_CXX_FLAGS_${BUILD_TYPE_UPPER}}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER)
message(STATUS "${CMAKE_BUILD_TYPE} CXX Flags: ${CMAKE_CXX_FLAGS_${BUILD_TYPE_UPPER}}")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(FetchContent)
Expand Down Expand Up @@ -64,7 +79,7 @@ FetchContent_MakeAvailable(glaze)
set(ORTOOLS_VERSION "9.12")
set(ORTOOLS_BUILD "4544")

if(WIN32)
if(MSVC)
set(ORTOOLS_PACKAGE "or-tools_x64_VisualStudio2022_cpp_v${ORTOOLS_VERSION}.${ORTOOLS_BUILD}")
set(ORTOOLS_ARCHIVE_EXT "zip")
elseif(APPLE)
Expand All @@ -77,8 +92,8 @@ endif()

set(ORTOOLS_URL "https://github.com/google/or-tools/releases/download/v${ORTOOLS_VERSION}/${ORTOOLS_PACKAGE}.${ORTOOLS_ARCHIVE_EXT}")
set(ORTOOLS_DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}/or-tools-download")
set(ORTOOLS_EXTRACT_DIR "${CMAKE_CURRENT_BINARY_DIR}/or-tools")
set(ORTOOLS_ARCHIVE "${ORTOOLS_DOWNLOAD_DIR}/or-tools.${ORTOOLS_ARCHIVE_EXT}")
set(ORTOOLS_EXTRACT_DIR "${PLATFORM_DIR}/lib/or-tools")

if(NOT EXISTS "${ORTOOLS_EXTRACT_DIR}")
file(DOWNLOAD "${ORTOOLS_URL}" "${ORTOOLS_ARCHIVE}" SHOW_PROGRESS)
Expand All @@ -95,10 +110,27 @@ if(NOT EXISTS "${ORTOOLS_EXTRACT_DIR}")
endif()
endif()

if(WIN32)
file(GLOB DLLS "${ORTOOLS_EXTRACT_DIR}/bin/*.dll")
foreach(DLL ${DLLS})
file(COPY "${DLL}" DESTINATION "${PLATFORM_DIR}/bin")
endforeach()
endif()

list(APPEND CMAKE_PREFIX_PATH "${ORTOOLS_EXTRACT_DIR}")

find_package(ortools REQUIRED)

add_subdirectory(src)

# Put test executable in a different directory for Unix
if(UNIX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${CMAKE_BINARY_DIR}/tests")
endforeach()
endif()

enable_testing()
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion include/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct SimulatorSettings {
};

struct OutputSettings {
std::filesystem::path path;
std::filesystem::path outputPath;
uint32_t numberOfRunsToAggregate;
bool prettify;
};
Expand Down
2 changes: 1 addition & 1 deletion scripts/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mkdir -p perf
"$PERF_EXE" record --call-graph dwarf,8192 \
-e cycles:u \
--strict-freq \
./build/palloc -e data.json
./build/palloc-linux/bin/palloc -e data.json

"$PERF_EXE" script -i perf.data | \
${FLAMEGRAPH_DIR}/stackcollapse-perf.pl | \
Expand Down
6 changes: 3 additions & 3 deletions scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ cd build

case "$1" in
"release")
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake -DCMAKE_BUILD_TYPE=Release ..
echo "Release mode enabled"
;;
"perf")
cmake .. -DCMAKE_BUILD_TYPE=Perf
cmake -DCMAKE_BUILD_TYPE=Perf ..
echo "Performance profiling mode enabled"
;;
*)
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
echo "Debug mode enabled"
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion scripts/memcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ valgrind --leak-check=full \
--errors-for-leak-kinds=definite \
--error-exitcode=1 \
--suppressions=./ortools.supp \
./build/palloc -e "$1"
./build/palloc-linux/bin/palloc -e "$1"

# Remove the temporary suppression file
rm ortools.supp
6 changes: 3 additions & 3 deletions scripts/run_experiment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ if [[ "$(pwd)" != "$PROJECT_ROOT" ]]; then
cd "$PROJECT_ROOT"
fi

if [ ! -f "build/palloc" ]; then
echo "Error: build/palloc executable not found."
if [ ! -f "./build/palloc-linux/bin/palloc" ]; then
echo "Error: palloc executable not found."
echo "Compiling the project..."
./scripts/compile.sh release
exit 1
Expand Down Expand Up @@ -374,7 +374,7 @@ while read job_info; do
output=$(echo $job_info | cut -d'|' -f5)

(
./build/palloc -e environment.json -o "$output" -d "$duration" -A "$arrival" -r "$rate" -s "$seed" -a "$AGGREGATIONS" -t "$TIMESTEPS" "$WEIGHTS" > /dev/null 2>&1
./build/palloc-linux/bin/palloc -e environment.json -o "$output" -d "$duration" -A "$arrival" -r "$rate" -s "$seed" -a "$AGGREGATIONS" -t "$TIMESTEPS" "$WEIGHTS" > /dev/null 2>&1

# Log the run
echo "Duration: ${duration}, Arrival: ${arrival}, Rate: ${rate}, Seed: ${seed}" >> "${exp_dir}/summary.txt"
Expand Down
4 changes: 2 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ echo "Generating environment file..."
python3 generate_environment.py

echo "Generating test data file..."
cd ../tests
python3 generate_test_data.py
cd ..
python3 tests/generate_test_data.py

echo "Shutting down OSRM backend..."
sudo docker stop $CONTAINER_ID > /dev/null
Expand Down
32 changes: 25 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
file(GLOB_RECURSE LIB_SOURCES "${PROJECT_SOURCE_DIR}/src/*.cpp")
list(FILTER LIB_SOURCES EXCLUDE REGEX ".*palloc\\.cpp$")

set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE)

add_executable(${PROJECT_NAME} "${PROJECT_SOURCE_DIR}/src/palloc.cpp")
if(LIB_SOURCES)
add_library(libpalloc STATIC ${LIB_SOURCES})
target_include_directories(libpalloc PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(libpalloc PUBLIC ortools::ortools glaze::glaze)
set_target_properties(libpalloc PROPERTIES PREFIX "")
target_link_libraries(${PROJECT_NAME} PRIVATE libpalloc)
add_library(libpalloc STATIC ${LIB_SOURCES})
target_include_directories(libpalloc PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(libpalloc PUBLIC ortools::ortools glaze::glaze)
set_target_properties(libpalloc PROPERTIES PREFIX "")
target_link_libraries(${PROJECT_NAME} PRIVATE libpalloc)

# Stop MSVC from making subdirectories
if(MSVC)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PLATFORM_DIR}/bin")
endif()

if(NOT MSVC)
set_source_files_properties(${PROJECT_NAME}.cpp PROPERTIES COMPILE_FLAGS "-Wno-missing-field-initializers")
endif()

set_source_files_properties(${PROJECT_NAME}.cpp PROPERTIES COMPILE_FLAGS "-Wno-missing-field-initializers")
# Move or-tools license file to lib/or-tools
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory "${PLATFORM_DIR}/licenses/or-tools"
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${PLATFORM_DIR}/lib/or-tools/share/doc/ortools/LICENSE"
"${PLATFORM_DIR}/licenses/or-tools/LICENSE"
COMMENT "Copying OR-Tools license to output directory"
)
10 changes: 5 additions & 5 deletions src/palloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ int main(int argc, char **argv) {
"number of aggregates)"}};

argz::parse(about, opts, argc, argv);
if (environmentPathStr.empty() && !about.printed_help) {
std::println(stderr, "Error: Expected environment file");
return EXIT_FAILURE;
if (about.printed_help || about.printed_version) {
return EXIT_SUCCESS;
}

if (environmentPathStr.empty()) {
return EXIT_SUCCESS;
std::println(stderr, "Error: Expected environment file");
return EXIT_FAILURE;
}

if (simSettings.timesteps < 1) {
Expand Down Expand Up @@ -95,7 +95,7 @@ int main(int argc, char **argv) {

simSettings.seed =
seedOpt.value_or(std::chrono::system_clock::now().time_since_epoch().count());
outputSettings.path = outputPathStr;
outputSettings.outputPath = outputPathStr;

GeneralSettings generalSettings{
.numberOfThreads = numberOfThreadsOpt.value_or(std::min(
Expand Down
4 changes: 2 additions & 2 deletions src/simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ void Simulator::simulate(Environment &env, const SimulatorSettings &simSettings,
std::println("Average objective cost: {}", globalAvgCost);
std::println("Total requests dropped: {}", result.getDroppedRequests());

if (!outputSettings.path.empty()) {
result.saveToFile(outputSettings.path, outputSettings.prettify);
if (!outputSettings.outputPath.empty()) {
result.saveToFile(outputSettings.outputPath, outputSettings.prettify);
}
}

Expand Down
13 changes: 11 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Catch2
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
option(FORCE_TESTS "Force building tests regardless of build type" OFF)

if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR FORCE_TESTS)
set(BUILD_TESTS TRUE)
else()
set(BUILD_TESTS FALSE)
endif()

message(STATUS "Build tests: ${BUILD_TESTS}")
if(BUILD_TESTS)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
Expand All @@ -13,7 +22,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (TEST_SOURCES)
message(STATUS "Found test sources: ${TEST_SOURCES}")
add_executable(palloc_tests ${TEST_SOURCES})
target_link_libraries(palloc_tests PRIVATE libpalloc Catch2::Catch2WithMain)
target_link_libraries(palloc_tests PUBLIC libpalloc Catch2::Catch2WithMain)

include(CTest)
include(Catch)
Expand Down
Loading