fix allocator block size
parent
14cd473ab1
commit
e134bc0686
2
libs/BLT
2
libs/BLT
|
@ -1 +1 @@
|
||||||
Subproject commit fe9cd9a6efcb4636172bea5940da5071c7ecf1e7
|
Subproject commit be4a61cc8040ffc1f86bd582a7de5d67397cdb16
|
|
@ -20,6 +20,7 @@
|
||||||
#include <blt/std/types.h>
|
#include <blt/std/types.h>
|
||||||
#include "blt/std/ranges.h"
|
#include "blt/std/ranges.h"
|
||||||
#include "blt/std/allocator.h"
|
#include "blt/std/allocator.h"
|
||||||
|
#include "blt/profiling/profiler_v2.h"
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
@ -44,7 +45,7 @@ namespace fb
|
||||||
|
|
||||||
enum class type_t
|
enum class type_t
|
||||||
{
|
{
|
||||||
ADD, SUB, MUL, VALUE
|
ADD, SUB, MUL, DIV, VALUE, END
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr blt::u64 SEED = 691;
|
static constexpr blt::u64 SEED = 691;
|
||||||
|
@ -70,14 +71,14 @@ namespace fb
|
||||||
type_t random_type()
|
type_t random_type()
|
||||||
{
|
{
|
||||||
static std::random_device dev;
|
static std::random_device dev;
|
||||||
static std::uniform_int_distribution dist(0, 3);
|
static std::uniform_int_distribution dist(0, static_cast<int>(type_t::END) - 1);
|
||||||
return static_cast<type_t>(dist(engine.get()));
|
return static_cast<type_t>(dist(engine.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
type_t random_type_sub()
|
type_t random_type_sub()
|
||||||
{
|
{
|
||||||
static std::random_device dev;
|
static std::random_device dev;
|
||||||
static std::uniform_int_distribution dist(0, 2);
|
static std::uniform_int_distribution dist(0, static_cast<int>(type_t::END) - 2);
|
||||||
return static_cast<type_t>(dist(engine.get()));
|
return static_cast<type_t>(dist(engine.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +96,11 @@ namespace fb
|
||||||
return dist(engine.get());
|
return dist(engine.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<blt::i32, 4> arg_c = {2, 2, 2, 0};
|
std::array<blt::i32, static_cast<int>(type_t::END)> arg_c = {2, 2, 2, 2, 0};
|
||||||
blt::size_t t1_add = 0;
|
blt::size_t t1_add = 0;
|
||||||
blt::size_t t1_sub = 0;
|
blt::size_t t1_sub = 0;
|
||||||
blt::size_t t1_mul = 0;
|
blt::size_t t1_mul = 0;
|
||||||
|
blt::size_t t1_div = 0;
|
||||||
blt::size_t t1_val = 0;
|
blt::size_t t1_val = 0;
|
||||||
blt::size_t t2_add = 0;
|
blt::size_t t2_add = 0;
|
||||||
blt::size_t t2_sub = 0;
|
blt::size_t t2_sub = 0;
|
||||||
|
@ -108,7 +110,7 @@ namespace fb
|
||||||
class tree1
|
class tree1
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
blt::bump_allocator<true> alloc{sizeof(node_t) * 32};
|
blt::bump_allocator<true> alloc{sizeof(node_t) * 8192};
|
||||||
private:
|
private:
|
||||||
struct node_t
|
struct node_t
|
||||||
{
|
{
|
||||||
|
@ -134,9 +136,14 @@ namespace fb
|
||||||
case type_t::MUL:
|
case type_t::MUL:
|
||||||
t1_mul++;
|
t1_mul++;
|
||||||
break;
|
break;
|
||||||
|
case type_t::DIV:
|
||||||
|
t1_div++;
|
||||||
|
break;
|
||||||
case type_t::VALUE:
|
case type_t::VALUE:
|
||||||
t1_val++;
|
t1_val++;
|
||||||
break;
|
break;
|
||||||
|
case type_t::END:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +162,14 @@ namespace fb
|
||||||
return;
|
return;
|
||||||
case type_t::VALUE:
|
case type_t::VALUE:
|
||||||
return;
|
return;
|
||||||
|
case type_t::DIV:
|
||||||
|
if (children[1]->value == 0)
|
||||||
|
value = 0;
|
||||||
|
else
|
||||||
|
value = children[0]->value / children[1]->value;
|
||||||
|
break;
|
||||||
|
case type_t::END:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +201,7 @@ namespace fb
|
||||||
evals++;
|
evals++;
|
||||||
node_stack.pop();
|
node_stack.pop();
|
||||||
}
|
}
|
||||||
BLT_INFO("Evaluated %ld times", evals);
|
// BLT_INFO("Evaluated %ld times", evals);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,10 +250,12 @@ namespace fb
|
||||||
}
|
}
|
||||||
//BLT_TRACE0_STREAM << "Size: " << stack.size() << "\n";
|
//BLT_TRACE0_STREAM << "Size: " << stack.size() << "\n";
|
||||||
}
|
}
|
||||||
BLT_INFO("We have %ld adds, %ld subs, %ld mul, %ld val = %ld", t1_add, t1_sub, t1_mul, t1_val, t1_add + t1_sub + t1_mul + t1_val);
|
// BLT_INFO("We have %ld adds, %ld subs, %ld mul, %ld div, %ld val, == %ld", t1_add, t1_sub, t1_mul, t1_div, t1_val,
|
||||||
|
// t1_add + t1_sub + t1_mul + t1_val + t1_div);
|
||||||
t1_add = 0;
|
t1_add = 0;
|
||||||
t1_sub = 0;
|
t1_sub = 0;
|
||||||
t1_mul = 0;
|
t1_mul = 0;
|
||||||
|
t1_div = 0;
|
||||||
t1_val = 0;
|
t1_val = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,10 +273,23 @@ namespace fb
|
||||||
|
|
||||||
void funny()
|
void funny()
|
||||||
{
|
{
|
||||||
|
constexpr auto size = 512;
|
||||||
|
constexpr auto tree_size = 17;
|
||||||
engine.reset();
|
engine.reset();
|
||||||
tree1 love;
|
tree1 love[size];
|
||||||
love.create(17);
|
for (auto& i : love)
|
||||||
BLT_TRACE(love.evaluate());
|
i.create(tree_size);
|
||||||
|
std::string val;
|
||||||
|
val.reserve(size * 128 * 2);
|
||||||
|
BLT_START_INTERVAL("Tree Evaluation", "Single Class Bump Allocated Tree");
|
||||||
|
for (auto& i : love)
|
||||||
|
{
|
||||||
|
val += static_cast<char>(static_cast<long>(i.evaluate()));
|
||||||
|
val += '\n';
|
||||||
|
}
|
||||||
|
BLT_END_INTERVAL("Tree Evaluation", "Single Class Bump Allocated Tree");
|
||||||
|
BLT_TRACE(val);
|
||||||
|
BLT_PRINT_PROFILE("Tree Evaluation");
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute()
|
void execute()
|
||||||
|
|
Loading…
Reference in New Issue