mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
feat(tests): add function for increasing the stack limit and use for benchmark overflow.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "llvm/Support/Path.h"
|
||||
#include <benchmark/benchmark.h>
|
||||
|
||||
#include "tests_tools/StackSize.h"
|
||||
#include "tests_tools/keySetCache.h"
|
||||
|
||||
/// Benchmark time of the compilation
|
||||
@@ -100,7 +101,8 @@ static void BM_Evaluate(benchmark::State &state, EndToEndDesc description,
|
||||
}
|
||||
}
|
||||
|
||||
static int registerEndToEndTestFromFile(std::string prefix, std::string path) {
|
||||
static int registerEndToEndTestFromFile(std::string prefix, std::string path,
|
||||
size_t stackSizeRequirement = 0) {
|
||||
auto registe = [&](std::string optionsName,
|
||||
mlir::concretelang::CompilationOptions options) {
|
||||
llvm::for_each(loadEndToEndDesc(path), [&](EndToEndDesc &description) {
|
||||
@@ -131,6 +133,7 @@ static int registerEndToEndTestFromFile(std::string prefix, std::string path) {
|
||||
return;
|
||||
});
|
||||
};
|
||||
setCurrentStackLimit(stackSizeRequirement);
|
||||
mlir::concretelang::CompilationOptions defaul;
|
||||
registe("default", defaul);
|
||||
mlir::concretelang::CompilationOptions loop;
|
||||
@@ -152,6 +155,7 @@ auto _ = {
|
||||
registerEndToEndTestFromFile(
|
||||
"FHELinalg", "tests/end_to_end_fixture/end_to_end_fhelinalg.yaml"),
|
||||
registerEndToEndTestFromFile(
|
||||
"FHELinalg", "tests/end_to_end_fixture/end_to_end_programs.yaml")};
|
||||
"FHELinalg", "tests/end_to_end_fixture/end_to_end_programs.yaml",
|
||||
0x8000000)};
|
||||
|
||||
BENCHMARK_MAIN();
|
||||
|
||||
26
compiler/tests/tests_tools/StackSize.h
Normal file
26
compiler/tests/tests_tools/StackSize.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef TEST_TOOLS_STACK_SIZE_H
|
||||
#define TEST_TOOLS_STACK_SIZE_H
|
||||
|
||||
#include <iostream>
|
||||
#include <sys/resource.h>
|
||||
|
||||
void setCurrentStackLimit(size_t size) {
|
||||
rlim_t stack_size_target = size;
|
||||
struct rlimit rl;
|
||||
|
||||
int res = getrlimit(RLIMIT_STACK, &rl);
|
||||
if (!res) {
|
||||
if (rl.rlim_cur < stack_size_target) {
|
||||
rl.rlim_cur = stack_size_target;
|
||||
res = setrlimit(RLIMIT_STACK, &rl);
|
||||
if (res)
|
||||
std::cerr << "Unable to set the requiresd stack size ("
|
||||
<< stack_size_target << " Bytes) - setrlimit returned " << res
|
||||
<< std::endl;
|
||||
else
|
||||
std::cerr << "Stack limit increased to " << rl.rlim_cur << " Bytes\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user