From 5052968657683639dbf9e84acb61612ef92ec7f1 Mon Sep 17 00:00:00 2001 From: Rahil Doshi <rahil.doshi@fau.de> Date: Fri, 28 Feb 2025 15:45:35 +0100 Subject: [PATCH] Update HeatEquationKernel to use InterpolationArrayContainer with interpolateBS method --- apps/CodegenHeatEquationWithMaterial.cpp | 29 ++++++++++++------------ apps/HeatEquationKernelWithMaterial.py | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/apps/CodegenHeatEquationWithMaterial.cpp b/apps/CodegenHeatEquationWithMaterial.cpp index 9cff394..eddfa2e 100644 --- a/apps/CodegenHeatEquationWithMaterial.cpp +++ b/apps/CodegenHeatEquationWithMaterial.cpp @@ -22,7 +22,7 @@ #include "timeloop/SweepTimeloop.h" #include "gen/HeatEquationKernelWithMaterial.hpp" -#include "interpolate_binary_search_cpp.h" +// #include "interpolate_binary_search_cpp.h" namespace walberla { @@ -168,8 +168,8 @@ int main(int argc, char** argv) void test_performance() { // Configuration parameters - constexpr int warmupSteps = 2; - constexpr int outerIterations = 5; + constexpr int warmupSteps = 5; + constexpr int outerIterations = 10; constexpr int numCells = 64*64*64; // Setup test data @@ -192,13 +192,13 @@ void test_performance() { std::cout << "Performing warmup steps..." << std::endl; for(int i = 0; i < warmupSteps; ++i) { for(const double& E : random_energies) { + // volatile double result = interpolate_double_lookup(E, test); volatile double result = test.interpolateDL(E); } } for(int i = 0; i < warmupSteps; ++i) { for(const double& E : random_energies) { - volatile double result = interpolate_binary_search_cpp( - SS316L::T_eq, E, SS316L::E_neq); + volatile double result = test.interpolateBS(E); } } @@ -217,26 +217,25 @@ void test_performance() { volatile double result = test.interpolateDL(E); } const auto end1 = std::chrono::high_resolution_clock::now(); - const auto duration1 = std::chrono::duration_cast<std::chrono::microseconds>( + const auto duration1 = std::chrono::duration_cast<std::chrono::nanoseconds>( end1 - start1).count(); timings_double_lookup.push_back(static_cast<double>(duration1)); - std::cout << "Double Lookup - Iteration time: " << duration1 << " μs" << std::endl; + std::cout << "Double Lookup - Iteration time: " << duration1 << " ns" << std::endl; } // Binary Search timing { const auto start2 = std::chrono::high_resolution_clock::now(); for(const double& E : random_energies) { - volatile double result = interpolate_binary_search_cpp( - SS316L::T_eq, E, SS316L::E_neq); + volatile double result = test.interpolateBS(E); } const auto end2 = std::chrono::high_resolution_clock::now(); - const auto duration2 = std::chrono::duration_cast<std::chrono::microseconds>( + const auto duration2 = std::chrono::duration_cast<std::chrono::nanoseconds>( end2 - start2).count(); timings_binary.push_back(static_cast<double>(duration2)); - std::cout << "Binary Search - Iteration time: " << duration2 << " μs" << std::endl; + std::cout << "Binary Search - Iteration time: " << duration2 << " ns" << std::endl; } } @@ -256,12 +255,12 @@ void test_performance() { std::cout << "\nPerformance Results (" << numCells << " cells, " << outerIterations << " iterations):" << std::endl; std::cout << "Binary Search:" << std::endl; - std::cout << " Mean time: " << binary_mean << " ± " << binary_stdev << " μs" << std::endl; - std::cout << " Per cell: " << binary_mean/numCells << " μs" << std::endl; + std::cout << " Mean time: " << binary_mean << " ± " << binary_stdev << " ns" << std::endl; + std::cout << " Per cell: " << binary_mean/numCells << " ns" << std::endl; std::cout << "Double Lookup:" << std::endl; - std::cout << " Mean time: " << lookup_mean << " ± " << lookup_stdev << " μs" << std::endl; - std::cout << " Per cell: " << lookup_mean/numCells << " μs" << std::endl; + std::cout << " Mean time: " << lookup_mean << " ± " << lookup_stdev << " ns" << std::endl; + std::cout << " Per cell: " << lookup_mean/numCells << " ns" << std::endl; } diff --git a/apps/HeatEquationKernelWithMaterial.py b/apps/HeatEquationKernelWithMaterial.py index 146242d..17a9bf2 100644 --- a/apps/HeatEquationKernelWithMaterial.py +++ b/apps/HeatEquationKernelWithMaterial.py @@ -9,7 +9,7 @@ from pystencilssfg import SourceFileGenerator from sfg_walberla import Sweep from pymatlib.data.alloys.SS316L import SS316L from pymatlib.core.assignment_converter import assignment_converter -from pymatlib.core.interpolators import DoubleLookupArrayContainer +from pymatlib.core.interpolators import InterpolationArrayContainer from pymatlib.core.yaml_parser import create_alloy_from_yaml with SourceFileGenerator() as sfg: @@ -40,7 +40,7 @@ with SourceFileGenerator() as sfg: # mat1 = create_alloy_from_yaml(str(yaml_path_1), u.center()) # arr_container = DoubleLookupArrayContainer("SS316L", mat.temperature_array, mat.energy_density_array) - arr_container = DoubleLookupArrayContainer.from_material("SS316L", mat) + arr_container = InterpolationArrayContainer.from_material("SS316L", mat) sfg.generate(arr_container) # arr_container = DoubleLookupArrayContainer.from_material("SS316L_1", mat1) # sfg.generate(arr_container) -- GitLab