-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Execute benchmarks on aws
- Loading branch information
Showing
12 changed files
with
250 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
# SPDX-License-Identifier: Unlicense | ||
# SPDX-FileCopyrightText: 2023 NeoFOAM authors | ||
# SPDX-FileCopyrightText: 2023-25 NeoFOAM authors | ||
|
||
add_subdirectory(fields) | ||
|
||
add_custom_command( | ||
OUTPUT ${PROJECT_BINARY_DIR}/benchmarks/fields.xml | ||
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/bench_fields -r XML > fields.xml | ||
COMMENT "Execute benchmarks") | ||
function(neofoam_benchmark BENCH) | ||
|
||
find_package( | ||
Python3 | ||
COMPONENTS Interpreter | ||
REQUIRED) | ||
add_executable(bench_${BENCH} "${BENCH}.cpp") | ||
target_link_libraries(bench_${BENCH} PRIVATE Catch2::Catch2 NeoFOAM) | ||
|
||
add_custom_command( | ||
OUTPUT ${PROJECT_BINARY_DIR}/benchmarks/fields.png | ||
COMMAND Python3::Interpreter ${PROJECT_SOURCE_DIR}/scripts/plotBenchmarks.py | ||
${PROJECT_BINARY_DIR}/benchmarks/fields.xml | ||
COMMENT "Plot benchmark results") | ||
if(WIN32) | ||
set_target_properties( | ||
bench_${BENCH} | ||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/ | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/ | ||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/) | ||
else() | ||
set_property(TARGET bench_${BENCH} PROPERTY RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks) | ||
endif() | ||
|
||
add_custom_target( | ||
execute_benchmarks | ||
DEPENDS ${PROJECT_BINARY_DIR}/benchmarks/fields.xml | ||
COMMENT "execute benchmarks") | ||
if(NOT DEFINED "neofoam_WORKING_DIRECTORY") | ||
set(neofoam_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks) | ||
endif() | ||
add_test( | ||
NAME bench_${BENCH} | ||
COMMAND sh -c "./bench_${BENCH} -r xml > ${BENCH}.xml" | ||
WORKING_DIRECTORY ${neofoam_WORKING_DIRECTORY}) | ||
endfunction() | ||
|
||
add_custom_target( | ||
execute_plot_benchmark | ||
DEPENDS ${PROJECT_BINARY_DIR}/benchmarks/fields.png | ||
COMMENT "plot benchmark results") | ||
add_subdirectory(fields) | ||
add_subdirectory(finiteVolume/cellCentred/operator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: MIT | ||
// SPDX-FileCopyrightText: 2025 NeoFOAM authors | ||
#pragma once | ||
|
||
#include <Kokkos_Core.hpp> | ||
#include <catch2/benchmark/catch_benchmark.hpp> | ||
#include <catch2/catch_session.hpp> | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <catch2/catch_test_case_info.hpp> | ||
#include <catch2/generators/catch_generators_all.hpp> | ||
#include <catch2/reporters/catch_reporter_registrars.hpp> | ||
#include <catch2/reporters/catch_reporter_streaming_base.hpp> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
// Initialize Catch2 | ||
Kokkos::ScopeGuard guard(argc, argv); | ||
Catch::Session session; | ||
|
||
// Specify command line options | ||
int returnCode = session.applyCommandLine(argc, argv); | ||
if (returnCode != 0) // Indicates a command line error | ||
return returnCode; | ||
|
||
int result = session.run(); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,4 @@ | ||
# SPDX-License-Identifier: Unlicense | ||
# SPDX-FileCopyrightText: 2023 NeoFOAM authors | ||
|
||
add_executable(bench_fields "bench_fields.cpp") | ||
target_link_libraries(bench_fields PRIVATE Catch2::Catch2 NeoFOAM Kokkos::kokkos) | ||
|
||
if(WIN32) | ||
set_target_properties( | ||
bench_fields | ||
PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/$<0:> | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/$<0:> | ||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks/$<0:>) | ||
else() | ||
set_property(TARGET bench_fields PROPERTY RUNTIME_OUTPUT_DIRECTORY | ||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/benchmarks) | ||
endif() | ||
neofoam_benchmark(field) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-License-Identifier: MIT | ||
// SPDX-FileCopyrightText: 2023 NeoFOAM authors | ||
|
||
#define CATCH_CONFIG_RUNNER // Define this before including catch.hpp to create | ||
// a custom main | ||
|
||
#include "../catch_main.hpp" | ||
#include "NeoFOAM/NeoFOAM.hpp" | ||
|
||
TEST_CASE("Field<scalar>::addition", "[bench]") | ||
{ | ||
auto size = GENERATE(1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20); | ||
NeoFOAM::Executor exec = GENERATE( | ||
NeoFOAM::Executor(NeoFOAM::SerialExecutor {}), | ||
NeoFOAM::Executor(NeoFOAM::CPUExecutor {}), | ||
NeoFOAM::Executor(NeoFOAM::GPUExecutor {}) | ||
); | ||
std::string execName = std::visit([](auto e) { return e.name(); }, exec); | ||
|
||
DYNAMIC_SECTION("" << size) | ||
{ | ||
NeoFOAM::Field<NeoFOAM::scalar> cpuA(exec, size); | ||
NeoFOAM::fill(cpuA, 1.0); | ||
NeoFOAM::Field<NeoFOAM::scalar> cpuB(exec, size); | ||
NeoFOAM::fill(cpuB, 2.0); | ||
NeoFOAM::Field<NeoFOAM::scalar> cpuC(exec, size); | ||
NeoFOAM::fill(cpuC, 0.0); | ||
|
||
BENCHMARK(std::string(execName)) { return (cpuC = cpuA + cpuB); }; | ||
} | ||
} | ||
|
||
TEST_CASE("Field<scalar>::multiplication", "[bench]") | ||
{ | ||
auto size = GENERATE(1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20); | ||
|
||
NeoFOAM::Executor exec = GENERATE( | ||
NeoFOAM::Executor(NeoFOAM::SerialExecutor {}), | ||
NeoFOAM::Executor(NeoFOAM::CPUExecutor {}), | ||
NeoFOAM::Executor(NeoFOAM::GPUExecutor {}) | ||
); | ||
std::string execName = std::visit([](auto e) { return e.name(); }, exec); | ||
|
||
DYNAMIC_SECTION("" << size) | ||
{ | ||
NeoFOAM::Field<NeoFOAM::scalar> cpuA(exec, size); | ||
NeoFOAM::fill(cpuA, 1.0); | ||
NeoFOAM::Field<NeoFOAM::scalar> cpuB(exec, size); | ||
NeoFOAM::fill(cpuB, 2.0); | ||
NeoFOAM::Field<NeoFOAM::scalar> cpuC(exec, size); | ||
NeoFOAM::fill(cpuC, 0.0); | ||
|
||
BENCHMARK(std::string(execName)) { return (cpuC = cpuA * cpuB); }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-License-Identifier: Unlicense | ||
# SPDX-FileCopyrightText: 2025 NeoFOAM authors | ||
|
||
neofoam_benchmark(divOperator) |
Oops, something went wrong.