Compare commits
2 Commits
d8e67a915c
...
e6ec71da1d
Author | SHA1 | Date |
---|---|---|
|
e6ec71da1d | |
|
034071dae3 |
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(blt-gp VERSION 0.0.68)
|
project(blt-gp VERSION 0.0.70)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -286,9 +286,16 @@ namespace blt::gp
|
||||||
if (config.threads == 1)
|
if (config.threads == 1)
|
||||||
{
|
{
|
||||||
thread_execution_service = new std::function([this, &fitness_function]() {
|
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
|
} else
|
||||||
|
|
|
@ -73,15 +73,14 @@ namespace blt::gp
|
||||||
if (head->used_bytes_in_block() < static_cast<blt::ptrdiff_t>(aligned_size<T>()))
|
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(
|
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());
|
head->used_bytes_in_block()) += " Size: " + std::to_string(sizeof(T))).c_str());
|
||||||
|
if (head->used_bytes_in_block() == 0)
|
||||||
|
move_back();
|
||||||
// make copy
|
// make copy
|
||||||
T t = *reinterpret_cast<T*>(head->metadata.offset - TYPE_SIZE);
|
T t = *reinterpret_cast<T*>(head->metadata.offset - TYPE_SIZE);
|
||||||
// call destructor
|
// call destructor
|
||||||
reinterpret_cast<T*>(head->metadata.offset - TYPE_SIZE)->~T();
|
reinterpret_cast<T*>(head->metadata.offset - TYPE_SIZE)->~T();
|
||||||
|
// move offset back
|
||||||
head->metadata.offset -= TYPE_SIZE;
|
head->metadata.offset -= TYPE_SIZE;
|
||||||
if (head->used_bytes_in_block() == 0)
|
|
||||||
{
|
|
||||||
move_back();
|
|
||||||
}
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,9 +139,9 @@ namespace blt::gp
|
||||||
if (diff <= 0)
|
if (diff <= 0)
|
||||||
{
|
{
|
||||||
bytes -= head->used_bytes_in_block();
|
bytes -= head->used_bytes_in_block();
|
||||||
move_back();
|
|
||||||
if (diff == 0)
|
if (diff == 0)
|
||||||
break;
|
break;
|
||||||
|
move_back();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// otherwise update the offset pointer
|
// otherwise update the offset pointer
|
||||||
|
@ -164,13 +163,15 @@ namespace blt::gp
|
||||||
throw std::runtime_error("This stack is empty!");
|
throw std::runtime_error("This stack is empty!");
|
||||||
if (head->used_bytes_in_block() < static_cast<blt::ptrdiff_t>(bytes))
|
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!");
|
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 type_size = aligned_size(bytes);
|
||||||
auto ptr = to.allocate_bytes(bytes);
|
auto ptr = to.allocate_bytes(bytes);
|
||||||
to.head->metadata.offset = static_cast<blt::u8*>(ptr) + type_size;
|
to.head->metadata.offset = static_cast<blt::u8*>(ptr) + type_size;
|
||||||
std::memcpy(ptr, head->metadata.offset - type_size, type_size);
|
std::memcpy(ptr, head->metadata.offset - type_size, type_size);
|
||||||
head->metadata.offset -= type_size;
|
head->metadata.offset -= type_size;
|
||||||
if (head->used_bytes_in_block() == 0)
|
|
||||||
move_back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
@ -218,10 +219,7 @@ namespace blt::gp
|
||||||
|
|
||||||
stack_allocator() = default;
|
stack_allocator() = default;
|
||||||
|
|
||||||
// it should be possible to remove the complex copy contrusctor along with trasnfer functions
|
// TODO: cleanup this allocator!
|
||||||
// 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
|
// 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)
|
stack_allocator(const stack_allocator& copy)
|
||||||
{
|
{
|
||||||
|
@ -401,11 +399,12 @@ namespace blt::gp
|
||||||
auto old = head;
|
auto old = head;
|
||||||
head = head->metadata.prev;
|
head = head->metadata.prev;
|
||||||
if (head == nullptr)
|
if (head == nullptr)
|
||||||
free_chain(old);
|
head = old;
|
||||||
|
//free_chain(old);
|
||||||
// required to prevent silly memory :3
|
// required to prevent silly memory :3
|
||||||
//if (head != nullptr)
|
// if (head != nullptr)
|
||||||
// head->metadata.next = nullptr;
|
// head->metadata.next = nullptr;
|
||||||
//std::free(old);
|
// std::free(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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