-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial testing for the memory cache.
- Loading branch information
Francesco Biscani
authored and
Francesco Biscani
committed
Aug 20, 2023
1 parent
361fd7b
commit b2913e5
Showing
2 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2020, 2021, 2022, 2023 Francesco Biscani ([email protected]), Dario Izzo ([email protected]) | ||
// | ||
// This file is part of the heyoka library. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#include <heyoka/llvm_state.hpp> | ||
#include <heyoka/model/pendulum.hpp> | ||
#include <heyoka/taylor.hpp> | ||
|
||
#include "catch.hpp" | ||
|
||
using namespace heyoka; | ||
|
||
TEST_CASE("basic") | ||
{ | ||
REQUIRE(llvm_state::get_memcache_size() == 0u); | ||
REQUIRE(llvm_state::get_memcache_limit() > 0u); | ||
|
||
auto ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}}; | ||
|
||
auto cache_size = llvm_state::get_memcache_size(); | ||
REQUIRE(cache_size > 0u); | ||
|
||
ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}}; | ||
|
||
REQUIRE(llvm_state::get_memcache_size() == cache_size); | ||
|
||
ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}, kw::opt_level = 2u}; | ||
|
||
REQUIRE(llvm_state::get_memcache_size() > cache_size); | ||
cache_size = llvm_state::get_memcache_size(); | ||
|
||
ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}, kw::opt_level = 2u, kw::tol = 1e-12}; | ||
REQUIRE(llvm_state::get_memcache_size() > cache_size); | ||
|
||
llvm_state::clear_memcache(); | ||
REQUIRE(llvm_state::get_memcache_size() == 0u); | ||
|
||
ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}}; | ||
cache_size = llvm_state::get_memcache_size(); | ||
|
||
llvm_state::set_memcache_limit(cache_size); | ||
ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}, kw::tol = 1e-12}; | ||
|
||
REQUIRE(llvm_state::get_memcache_size() < cache_size); | ||
|
||
llvm_state::set_memcache_limit(0); | ||
|
||
ta = taylor_adaptive<double>{model::pendulum(), {1., 0.}, kw::tol = 1e-11}; | ||
|
||
REQUIRE(llvm_state::get_memcache_size() == 0u); | ||
} |