LCOV - code coverage report
Current view: top level - src/Tools/Buffer_allocator - Buffer_allocator.cpp (source / functions) Hit Total Coverage
Test: streampu_clean.info Lines: 25 33 75.8 %
Date: 2025-07-17 17:04:07 Functions: 6 6 100.0 %

          Line data    Source code
       1             : #include <functional>
       2             : #include <iostream>
       3             : #include <sstream>
       4             : 
       5             : #include "Runtime/Sequence/Sequence.hpp"
       6             : #include "Tools/Buffer_allocator/Buffer_allocator.hpp"
       7             : 
       8             : using namespace spu;
       9             : using namespace spu::tools;
      10             : 
      11             : bool g_task_autoalloc = false;
      12             : 
      13             : void
      14         204 : Buffer_allocator::set_task_autoalloc(bool autoalloc)
      15             : {
      16         204 :     g_task_autoalloc = autoalloc;
      17         204 : }
      18             : 
      19             : bool
      20       86957 : Buffer_allocator::get_task_autoalloc()
      21             : {
      22       86957 :     return g_task_autoalloc;
      23             : }
      24             : 
      25             : void
      26         687 : Buffer_allocator::allocate_one_buffer_per_outsocket(runtime::Sequence* sequence)
      27             : {
      28        6784 :     for (auto thread_tasks : sequence->get_tasks_per_threads())
      29             :     {
      30       56081 :         for (auto task : thread_tasks)
      31             :         {
      32       49984 :             task->allocate_outbuffers();
      33             :         }
      34        6784 :     }
      35         687 : }
      36             : void
      37         373 : Buffer_allocator::deallocate_one_buffer_per_outsocket(runtime::Sequence* sequence)
      38             : {
      39        3574 :     for (auto thread_tasks : sequence->get_tasks_per_threads())
      40             :     {
      41       17962 :         for (auto task : thread_tasks)
      42             :         {
      43       14761 :             task->deallocate_outbuffers();
      44             :         }
      45        3574 :     }
      46         373 : }
      47             : 
      48             : void
      49         687 : Buffer_allocator::allocate_sequence_memory(runtime::Sequence* sequence)
      50             : {
      51         687 :     if (sequence == nullptr)
      52             :     {
      53           0 :         std::stringstream message;
      54             :         message << "The sequence pointer is null"
      55           0 :                 << ", call set_sequence before allocating memory";
      56           0 :         throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());
      57           0 :     }
      58             :     else
      59             :     {
      60         687 :         Buffer_allocator::allocate_one_buffer_per_outsocket(sequence);
      61             :     }
      62         687 : }
      63             : 
      64             : void
      65         373 : Buffer_allocator::deallocate_sequence_memory(runtime::Sequence* sequence)
      66             : {
      67         373 :     if (sequence == nullptr)
      68             :     {
      69           0 :         std::stringstream message;
      70           0 :         message << "The sequence pointer is null";
      71           0 :         throw tools::invalid_argument(__FILE__, __LINE__, __func__, message.str());
      72           0 :     }
      73             :     else
      74             :     {
      75         373 :         Buffer_allocator::deallocate_one_buffer_per_outsocket(sequence);
      76             :     }
      77         373 : }

Generated by: LCOV version 1.14