Compare commits
2 Commits
d8e67a915c
...
e6ec71da1d
Author | SHA1 | Date |
---|---|---|
|
e6ec71da1d | |
|
034071dae3 |
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(blt-gp VERSION 0.0.68)
|
||||
project(blt-gp VERSION 0.0.70)
|
||||
|
||||
include(CTest)
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -286,9 +286,16 @@ namespace blt::gp
|
|||
if (config.threads == 1)
|
||||
{
|
||||
thread_execution_service = new std::function([this, &fitness_function]() {
|
||||
if (thread_helper.evaluation_left > 0)
|
||||
for (const auto& ind : blt::enumerate(current_pop.get_individuals()))
|
||||
{
|
||||
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
|
||||
|
|
|
@ -73,15 +73,14 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -140,9 +139,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
|
||||
|
@ -164,13 +163,15 @@ 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>
|
||||
|
@ -218,10 +219,7 @@ namespace blt::gp
|
|||
|
||||
stack_allocator() = default;
|
||||
|
||||
// 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)
|
||||
// TODO: cleanup this allocator!
|
||||
// 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)
|
||||
{
|
||||
|
@ -401,11 +399,12 @@ namespace blt::gp
|
|||
auto old = head;
|
||||
head = head->metadata.prev;
|
||||
if (head == nullptr)
|
||||
free_chain(old);
|
||||
head = 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:
|
||||
|
|
|
@ -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 ./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,page-faults,page-faults:u,page-faults:k ./cmake-build-release/blt-SR-playground-example
|
||||
|
|
Loading…
Reference in New Issue