thread
Brett 2024-07-16 03:17:18 -04:00
parent c7bb4a434b
commit 2fcc8369db
4 changed files with 5 additions and 4 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.84) project(blt-gp VERSION 0.0.85)
include(CTest) include(CTest)

View File

@ -506,7 +506,7 @@ namespace blt::gp
operator_storage storage; operator_storage storage;
population_t current_pop; population_t current_pop;
population_stats current_stats; population_stats current_stats {};
population_t next_pop; population_t next_pop;
std::atomic_uint64_t current_generation = 0; std::atomic_uint64_t current_generation = 0;

View File

@ -164,6 +164,7 @@ namespace blt::gp
{ {
using NO_REF_T = std::remove_cv_t<std::remove_reference_t<T>>; using NO_REF_T = std::remove_cv_t<std::remove_reference_t<T>>;
static_assert(std::is_trivially_copyable_v<NO_REF_T> && "Type must be bitwise copyable!"); static_assert(std::is_trivially_copyable_v<NO_REF_T> && "Type must be bitwise copyable!");
static_assert(alignof(NO_REF_T) <= MAX_ALIGNMENT && "Type must not be greater than the max alignment!");
auto ptr = allocate_bytes<NO_REF_T>(); auto ptr = allocate_bytes<NO_REF_T>();
head->metadata.offset = static_cast<blt::u8*>(ptr) + aligned_size<NO_REF_T>(); head->metadata.offset = static_cast<blt::u8*>(ptr) + aligned_size<NO_REF_T>();
new(ptr) NO_REF_T(std::forward<T>(value)); new(ptr) NO_REF_T(std::forward<T>(value));
@ -487,7 +488,7 @@ namespace blt::gp
static block* allocate_block(blt::size_t bytes) static block* allocate_block(blt::size_t bytes)
{ {
auto size = to_nearest_page_size(bytes); auto size = to_nearest_page_size(bytes + sizeof(typename block::block_metadata_t));
auto* data = std::aligned_alloc(PAGE_SIZE, size); auto* data = std::aligned_alloc(PAGE_SIZE, size);
//auto* data = get_allocator().allocate(size); //auto* data = get_allocator().allocate(size);
new(data) block{size}; new(data) block{size};

View File

@ -152,7 +152,7 @@ namespace blt::gp
std::atomic<double> average_fitness = 0; std::atomic<double> average_fitness = 0;
std::atomic<double> best_fitness = 0; std::atomic<double> best_fitness = 0;
std::atomic<double> worst_fitness = 1; std::atomic<double> worst_fitness = 1;
std::vector<double> normalized_fitness; std::vector<double> normalized_fitness{};
void clear() void clear()
{ {