shared
Brett 2024-08-22 02:45:10 -04:00
parent 95460e7bf1
commit ec8153bef0
4 changed files with 22 additions and 18 deletions

View File

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

View File

@ -155,6 +155,7 @@ int main()
// BLT_TRACE("Allocated: %ld", h); // BLT_TRACE("Allocated: %ld", h);
// BLT_TRACE("Deallocated: %ld", u); // BLT_TRACE("Deallocated: %ld", u);
// BLT_TRACE("Ratio: %lf Difference: %ld", static_cast<double>(h) / static_cast<double>(u), std::abs(h - u)); // BLT_TRACE("Ratio: %lf Difference: %ld", static_cast<double>(h) / static_cast<double>(u), std::abs(h - u));
// BLT_TRACE("Total Allocated Bytes: %ld", blt::gp::hello_bytes.load());
return 0; return 0;
} }

View File

@ -44,6 +44,7 @@ namespace blt::gp
} }
// inline std::atomic_uint64_t hello = 0; // inline std::atomic_uint64_t hello = 0;
// inline std::atomic_uint64_t hello_bytes = 0;
// inline std::atomic_uint64_t unhello = 0; // inline std::atomic_uint64_t unhello = 0;
class aligned_allocator class aligned_allocator
@ -52,12 +53,16 @@ namespace blt::gp
void* allocate(blt::size_t bytes) // NOLINT void* allocate(blt::size_t bytes) // NOLINT
{ {
// hello.fetch_add(1, std::memory_order_relaxed); // hello.fetch_add(1, std::memory_order_relaxed);
// hello_bytes += bytes;
// BLT_TRACE("Allocating %ld bytes", bytes); // BLT_TRACE("Allocating %ld bytes", bytes);
return std::aligned_alloc(8, bytes); return std::aligned_alloc(8, bytes);
} }
void deallocate(void* ptr, blt::size_t) // NOLINT void deallocate(void* ptr, blt::size_t) // NOLINT
{ {
// if (ptr == nullptr && bytes != 0) {
// BLT_ABORT(("Nullptr called with non zero bytes! " + std::to_string(bytes)).c_str());
// }
// if (ptr == nullptr) // if (ptr == nullptr)
// return; // return;
// unhello.fetch_add(1, std::memory_order_relaxed); // unhello.fetch_add(1, std::memory_order_relaxed);
@ -116,7 +121,7 @@ namespace blt::gp
} }
stack_allocator(stack_allocator&& move) noexcept: stack_allocator(stack_allocator&& move) noexcept:
data_(std::exchange(move.data_, nullptr)), bytes_stored(move.bytes_stored), size_(move.size_) data_(std::exchange(move.data_, nullptr)), bytes_stored(std::exchange(move.bytes_stored, 0)), size_(std::exchange(move.size_, 0))
{} {}
stack_allocator& operator=(const stack_allocator& copy) = delete; stack_allocator& operator=(const stack_allocator& copy) = delete;

View File

@ -247,22 +247,20 @@ namespace blt::gp
blt::size_t total_produced = 0; blt::size_t total_produced = 0;
blt::size_t total_consumed = 0; blt::size_t total_consumed = 0;
// for (const auto& operation : blt::reverse_iterate(operations.begin(), operations.end())) for (const auto& operation : blt::reverse_iterate(operations.begin(), operations.end()))
// { {
// if (operation.is_value) if (operation.is_value)
// { {
// value_stack.transfer_bytes(values_process, operation.type_size); value_stack.transfer_bytes(values_process, operation.type_size);
// total_produced += stack_allocator::aligned_size(operation.type_size); total_produced += stack_allocator::aligned_size(operation.type_size);
// bitfield.push_back(false); continue;
// continue; }
// } auto& info = program.get_operator_info(operation.id);
// auto& info = program.get_operator_info(operation.id); for (auto& arg : info.argument_types)
// for (auto& arg : info.argument_types) total_consumed += stack_allocator::aligned_size(program.get_typesystem().get_type(arg).size());
// total_consumed += stack_allocator::aligned_size(program.get_typesystem().get_type(arg).size()); program.get_operator_info(operation.id).func(context, values_process, values_process);
// operation.func(context, values_process, values_process, &bitfield); total_produced += stack_allocator::aligned_size(program.get_typesystem().get_type(info.return_type).size());
// bitfield.push_back(true); }
// total_produced += stack_allocator::aligned_size(program.get_typesystem().get_type(info.return_type).size());
// }
auto v1 = results.values.bytes_in_head(); auto v1 = results.values.bytes_in_head();
auto v2 = static_cast<blt::ptrdiff_t>(stack_allocator::aligned_size(operations.front().type_size)); auto v2 = static_cast<blt::ptrdiff_t>(stack_allocator::aligned_size(operations.front().type_size));