Compare commits

..

No commits in common. "6972a30696f211159b52739541264125ac73e342" and "58b68b70bb1d3086124b688f477544c3f94fb606" have entirely different histories.

5 changed files with 11 additions and 93 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
project(blt-gp VERSION 0.0.103) project(blt-gp VERSION 0.0.100)
include(CTest) include(CTest)

View File

@ -34,7 +34,7 @@ std::array<context, 200> fitness_cases;
blt::gp::prog_config_t config = blt::gp::prog_config_t() blt::gp::prog_config_t config = blt::gp::prog_config_t()
.set_initial_min_tree_size(2) .set_initial_min_tree_size(2)
.set_initial_max_tree_size(6) .set_initial_max_tree_size(6)
.set_elite_count(2) .set_elite_count(10)
.set_crossover_chance(0.9) .set_crossover_chance(0.9)
.set_mutation_chance(0.1) .set_mutation_chance(0.1)
.set_reproduction_chance(0.1) .set_reproduction_chance(0.1)
@ -106,10 +106,10 @@ int main()
builder.add_operator(sub); builder.add_operator(sub);
builder.add_operator(mul); builder.add_operator(mul);
builder.add_operator(pro_div); builder.add_operator(pro_div);
builder.add_operator(op_sin); //builder.add_operator(op_sin);
builder.add_operator(op_cos); //builder.add_operator(op_cos);
builder.add_operator(op_exp); //builder.add_operator(op_exp);
builder.add_operator(op_log); //builder.add_operator(op_log);
builder.add_operator(lit, true); builder.add_operator(lit, true);
builder.add_operator(op_x); builder.add_operator(op_x);
@ -124,8 +124,7 @@ int main()
{ {
BLT_TRACE("------------{Begin Generation %ld}------------", program.get_current_generation()); BLT_TRACE("------------{Begin Generation %ld}------------", program.get_current_generation());
BLT_START_INTERVAL("Symbolic Regression", "Gen"); BLT_START_INTERVAL("Symbolic Regression", "Gen");
auto sel = blt::gp::select_fitness_proportionate_t{}; program.create_next_generation(blt::gp::select_fitness_proportionate_t{}, blt::gp::select_fitness_proportionate_t{}, blt::gp::select_fitness_proportionate_t{});
program.create_next_generation(sel, sel, sel);
BLT_END_INTERVAL("Symbolic Regression", "Gen"); BLT_END_INTERVAL("Symbolic Regression", "Gen");
BLT_TRACE("Move to next generation"); BLT_TRACE("Move to next generation");
BLT_START_INTERVAL("Symbolic Regression", "Fitness"); BLT_START_INTERVAL("Symbolic Regression", "Fitness");

View File

@ -64,8 +64,7 @@ namespace blt::gp
stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_size_bytes) * 100) << "%), "; stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_size_bytes) * 100) << "%), ";
stream << data.total_used_bytes << "/"; stream << data.total_used_bytes << "/";
stream << data.total_no_meta_bytes << "("; stream << data.total_no_meta_bytes << "(";
stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_no_meta_bytes) * 100) stream << (static_cast<double>(data.total_used_bytes) / static_cast<double>(data.total_no_meta_bytes) * 100) << "%), (empty space: ";
<< "%), (empty space: ";
stream << data.total_remaining_bytes << ") blocks: " << data.blocks << " || unallocated space: "; stream << data.total_remaining_bytes << ") blocks: " << data.blocks << " || unallocated space: ";
stream << data.total_dealloc_used << "/"; stream << data.total_dealloc_used << "/";
stream << data.total_dealloc; stream << data.total_dealloc;
@ -75,8 +74,7 @@ namespace blt::gp
stream << data.total_dealloc_used << "/"; stream << data.total_dealloc_used << "/";
stream << data.total_dealloc_no_meta; stream << data.total_dealloc_no_meta;
if (data.total_dealloc_no_meta > 0) if (data.total_dealloc_no_meta > 0)
stream << "(" << (static_cast<double>(data.total_dealloc_used) / static_cast<double>(data.total_dealloc_no_meta * 100)) stream << "(" << (static_cast<double>(data.total_dealloc_used) / static_cast<double>(data.total_dealloc_no_meta * 100)) << "%)";
<< "%)";
stream << ", (empty space: " << data.total_dealloc_remaining << ")]"; stream << ", (empty space: " << data.total_dealloc_remaining << ")]";
return stream; return stream;
} }
@ -178,6 +176,7 @@ namespace blt::gp
#endif #endif
#endif #endif
auto diff = head->used_bytes_in_block() - bytes; auto diff = head->used_bytes_in_block() - bytes;
BLT_TRACE(diff);
// if there is not enough room left to pop completely off the block, then move to the next previous block // if there is not enough room left to pop completely off the block, then move to the next previous block
// and pop from it, update the amount of bytes to reflect the amount removed from the current block // and pop from it, update the amount of bytes to reflect the amount removed from the current block
if (diff < 0) if (diff < 0)
@ -348,31 +347,6 @@ namespace blt::gp
return (size + (MAX_ALIGNMENT - 1)) & ~(MAX_ALIGNMENT - 1); return (size + (MAX_ALIGNMENT - 1)) & ~(MAX_ALIGNMENT - 1);
} }
inline static constexpr auto metadata_size()
{
return sizeof(typename block::block_metadata_t);
}
inline static constexpr auto block_size()
{
return sizeof(block);
}
inline static constexpr auto page_size()
{
return PAGE_SIZE;
}
inline static constexpr auto page_size_no_meta()
{
return page_size() - metadata_size();
}
inline static constexpr auto page_size_no_block()
{
return page_size() - block_size();
}
private: private:
struct block struct block
{ {

View File

@ -1 +1 @@
perf stat -d -d -d -r 30 -e branches,branch-misses,cache-misses,cache-references,cycles,instructions,alignment-faults,cgroup-switches,faults,duration_time,user_time,system_time,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-prefetches,L1-icache-loads,L1-icache-load-misses,dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,l2_request_g1.all_no_prefetch,page-faults,page-faults:u,page-faults:k ./cmake-build-release/blt-symbolic-regression-example perf stat -d -d -d -r 30 -e branches,branch-misses,cache-misses,cache-references,cycles,instructions,alignment-faults,cgroup-switches,faults,duration_time,user_time,system_time,L1-dcache-loads,L1-dcache-load-misses,L1-dcache-prefetches,L1-icache-loads,L1-icache-load-misses,dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,l2_request_g1.all_no_prefetch,page-faults,page-faults:u,page-faults:k ./cmake-build-release/blt-SR-playground-example

View File

@ -280,59 +280,6 @@ void test_basic()
auto val = stack.pop<float>(); auto val = stack.pop<float>();
RUN_TEST(val != 60.000000f, stack, "Basic 2 Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val); RUN_TEST(val != 60.000000f, stack, "Basic 2 Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val);
BLT_TRACE_STREAM << stack.size() << "\n"; BLT_TRACE_STREAM << stack.size() << "\n";
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation.");
}
BLT_INFO("Testing basic with stack over boundary");
{
blt::gp::stack_allocator stack;
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>{});
stack.push(50.0f);
stack.push(10.0f);
auto size = stack.size();
BLT_TRACE_STREAM << size << "\n";
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
basic_2.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
auto val = stack.pop<float>();
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
RUN_TEST(val != 60.000000f, stack, "Basic 2 Boundary Test Passed", "Basic 2 Test Failed. Unexpected value produced '%lf'", val);
BLT_TRACE_STREAM << stack.size() << "\n";
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation over stack boundary");
}
}
void test_mixed()
{
BLT_INFO("Testing mixed with stack");
{
blt::gp::stack_allocator stack;
stack.push(50.0f);
stack.push(10.0f);
stack.push(true);
stack.push(false);
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
BLT_TRACE_STREAM << stack.size() << "\n";
auto val = stack.pop<float>();
RUN_TEST(val != 50.000000f, stack, "Mixed 4 Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
BLT_TRACE_STREAM << stack.size() << "\n";
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation.");
}
BLT_INFO("Testing mixed with stack over boundary");
{
blt::gp::stack_allocator stack;
stack.push(std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>{});
stack.push(50.0f);
stack.push(10.0f);
stack.push(false);
stack.push(true);
auto size = stack.size();
BLT_TRACE_STREAM << size << "\n";
BLT_ASSERT(size.blocks > 1 && "Stack doesn't have more than one block!");
basic_mixed_4.make_callable<blt::gp::detail::empty_t>()(nullptr, stack, stack);
auto val = stack.pop<float>();
stack.pop<std::array<blt::u8, blt::gp::stack_allocator::page_size_no_block() - sizeof(float)>>();
RUN_TEST(val != 10.000000f, stack, "Mixed 4 Boundary Test Passed", "Mixed 4 Test Failed. Unexpected value produced '%lf'", val);
BLT_TRACE_STREAM << stack.size() << "\n";
BLT_ASSERT(stack.empty() && "Stack was not empty after basic evaluation over stack boundary");
} }
} }
@ -340,8 +287,6 @@ void test_operators()
{ {
log_box box("-----------------------{Operator Testing}-----------------------", BLT_INFO_STREAM); log_box box("-----------------------{Operator Testing}-----------------------", BLT_INFO_STREAM);
test_basic(); test_basic();
BLT_NEWLINE();
test_mixed();
} }
int main() int main()