Compare commits

..

No commits in common. "e6ec71da1daf4e6e22216dc8713356cc934405d2" and "d8e67a915cb2c7ed32c2c519b5315691d0c181cd" have entirely different histories.

5 changed files with 19 additions and 1399 deletions

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -286,16 +286,9 @@ namespace blt::gp
if (config.threads == 1)
{
thread_execution_service = new std::function([this, &fitness_function]() {
for (const auto& ind : blt::enumerate(current_pop.get_individuals()))
if (thread_helper.evaluation_left > 0)
{
fitness_function(ind.second.tree, ind.second.fitness, ind.first);
if (ind.second.fitness.adjusted_fitness > current_stats.best_fitness)
current_stats.best_fitness = ind.second.fitness.adjusted_fitness;
if (ind.second.fitness.adjusted_fitness < current_stats.worst_fitness)
current_stats.worst_fitness = ind.second.fitness.adjusted_fitness;
current_stats.overall_fitness = current_stats.overall_fitness + ind.second.fitness.adjusted_fitness;
}
});
} else

View File

@ -73,14 +73,15 @@ namespace blt::gp
if (head->used_bytes_in_block() < static_cast<blt::ptrdiff_t>(aligned_size<T>()))
throw std::runtime_error((std::string("Mismatched Types! Not enough space left in block! Bytes: ") += std::to_string(
head->used_bytes_in_block()) += " Size: " + std::to_string(sizeof(T))).c_str());
if (head->used_bytes_in_block() == 0)
move_back();
// make copy
T t = *reinterpret_cast<T*>(head->metadata.offset - TYPE_SIZE);
// call destructor
reinterpret_cast<T*>(head->metadata.offset - TYPE_SIZE)->~T();
// move offset back
head->metadata.offset -= TYPE_SIZE;
if (head->used_bytes_in_block() == 0)
{
move_back();
}
return t;
}
@ -139,9 +140,9 @@ namespace blt::gp
if (diff <= 0)
{
bytes -= head->used_bytes_in_block();
move_back();
if (diff == 0)
break;
move_back();
} else
{
// otherwise update the offset pointer
@ -163,15 +164,13 @@ namespace blt::gp
throw std::runtime_error("This stack is empty!");
if (head->used_bytes_in_block() < static_cast<blt::ptrdiff_t>(bytes))
BLT_ABORT("This stack doesn't contain enough data for this type! This is an invalid runtime state!");
if (head->used_bytes_in_block() == 0)
move_back();
auto type_size = aligned_size(bytes);
auto ptr = to.allocate_bytes(bytes);
to.head->metadata.offset = static_cast<blt::u8*>(ptr) + type_size;
std::memcpy(ptr, head->metadata.offset - type_size, type_size);
head->metadata.offset -= type_size;
if (head->used_bytes_in_block() == 0)
move_back();
}
template<typename... Args>
@ -219,7 +218,10 @@ namespace blt::gp
stack_allocator() = default;
// TODO: cleanup this allocator!
// it should be possible to remove the complex copy contrusctor along with trasnfer functions
// simply keep track of the start of the stack, aloing with the current pointer and never dealloacted
// it adds another 8 bytes to each block but should prevent the need for copying when you can just reset the stack.
// (read copy)
// if you keep track of type size information you can memcpy between stack allocators as you already only allow trivially copyable types
stack_allocator(const stack_allocator& copy)
{
@ -399,12 +401,11 @@ namespace blt::gp
auto old = head;
head = head->metadata.prev;
if (head == nullptr)
head = old;
//free_chain(old);
free_chain(old);
// required to prevent silly memory :3
// if (head != nullptr)
// head->metadata.next = nullptr;
// std::free(old);
//if (head != nullptr)
// head->metadata.next = nullptr;
//std::free(old);
}
private:

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-SR-playground-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 ./cmake-build-release/blt-SR-playground-example