LCOV - code coverage report
Current view: top level - core/src/gvt - fossil.c Hit Total Coverage
Test: ROOT-Sim master Documentation Coverage Lines: 1 5 20.0 %
Date: 2021-03-25 15:11:55

          Line data    Source code
       1           1 : /**
       2             :  * @file gvt/fossil.c
       3             :  *
       4             :  * @brief Housekeeping operations
       5             :  *
       6             :  * SPDX-FileCopyrightText: 2008-2021 HPDCS Group <rootsim@googlegroups.com>
       7             :  * SPDX-License-Identifier: GPL-3.0-only
       8             :  */
       9             : 
      10             : #include <gvt/fossil.h>
      11             : 
      12             : #include <gvt/gvt.h>
      13             : #include <lp/lp.h>
      14             : #include <lp/process.h>
      15             : #include <mm/model_allocator.h>
      16             : #include <mm/msg_allocator.h>
      17             : 
      18             : #include <memory.h>
      19             : 
      20           0 : #define cant_discard_ref_i(ref_i) \
      21             :         array_get_at(proc_p->past_msgs, ref_i)->dest_t >= current_gvt
      22             : 
      23           0 : static inline array_count_t first_discardable_ref(simtime_t current_gvt,
      24             :         struct process_data *proc_p)
      25             : {
      26             :         array_count_t j = array_count(proc_p->past_msgs) - 1;
      27             :         while (cant_discard_ref_i(j))
      28             :                 --j;
      29             : 
      30             :         return j;
      31             : }
      32             : 
      33           0 : static inline void fossil_lp_collect(simtime_t current_gvt)
      34             : {
      35             :         struct process_data *proc_p = &current_lp->p;
      36             :         array_count_t past_i = first_discardable_ref(current_gvt, proc_p);
      37             :         past_i = model_allocator_fossil_lp_collect(past_i);
      38             :         array_count_t sent_i = array_count(proc_p->sent_msgs);
      39             :         array_count_t j = array_count(proc_p->past_msgs);
      40             :         do {
      41             :                 --sent_i;
      42             :                 j -= (array_get_at(proc_p->sent_msgs, sent_i) == NULL);
      43             :         } while (j > past_i);
      44             :         array_truncate_first(proc_p->sent_msgs, sent_i);
      45             : 
      46             :         while (j--)
      47             :                 msg_allocator_free(array_get_at(proc_p->past_msgs, j));
      48             : 
      49             :         array_truncate_first(proc_p->past_msgs, past_i);
      50             : }
      51             : 
      52           0 : void fossil_collect(simtime_t current_gvt)
      53             : {
      54             : #ifdef ROOTSIM_MPI
      55             :         msg_allocator_fossil_collect(current_gvt);
      56             : #endif
      57             :         for (uint64_t i = lid_thread_first; i < lid_thread_end; ++i) {
      58             :                 current_lp = &lps[i];
      59             :                 fossil_lp_collect(current_gvt);
      60             :         }
      61             : }

Generated by: LCOV version 1.14