ROOT-Sim core  3.0.0-rc.2
A General-Purpose Multi-threaded Parallel/Distributed Simulation Library
Macros | Functions | Variables
lp.c File Reference

LP construction functions. More...

#include <lp/lp.h>
#include <datatypes/msg_queue.h>
#include <core/sync.h>
#include <gvt/termination.h>
Include dependency graph for lp.c:

Macros

#define partition_start(part_id, part_cnt, part_fnc, start_i, tot_i)
 Compute the first index of a partition in a linear space of indexes. More...
 

Functions

void lp_global_init (void)
 Initialize the global data structures for the LPs.
 
void lp_global_fini (void)
 Finalize the global data structures for the LPs.
 
void lp_init (void)
 Initialize the data structures of the LPs hosted in the calling thread.
 
void lp_fini (void)
 Finalize the data structures of the LPs hosted in the calling thread.
 
void SetState (void *state)
 Set the LP simulation state main pointer. More...
 

Variables

uint64_t lid_node_first
 The lowest LP id between the ones hosted on this node.
 
__thread uint64_t lid_thread_first
 The lowest LP id between the ones hosted on this thread.
 
__thread uint64_t lid_thread_end
 One plus the highest LP id between the ones hosted on this thread.
 
__thread struct lp_ctxcurrent_lp
 A pointer to the currently processed LP context.
 
struct lp_ctxlps
 A pointer to the LP contexts array. More...
 
lp_id_t n_lps_node
 The number of LPs hosted on this node. More...
 
bool lp_initialized
 

Detailed Description

LP construction functions.

LP construction functions

Macro Definition Documentation

◆ partition_start

#define partition_start (   part_id,
  part_cnt,
  part_fnc,
  start_i,
  tot_i 
)
Value:
__extension__({ \
lp_id_t _g = (part_id) * (tot_i) / (part_cnt) + (start_i); \
while(_g > (start_i) && part_fnc(_g) >= (part_id)) \
--_g; \
while(part_fnc(_g) < (part_id)) \
++_g; \
_g; \
})

Compute the first index of a partition in a linear space of indexes.

Parameters
part_idthe id of the requested partition
part_cntthe number of requested partitions
part_fncthe function which computes the partition id from an index
start_ithe first valid index of the space to partition
tot_ithe size of the index space to partition

The description is somewhat confusing but this does a simple thing. Each LP has an integer id and we want each node/processing unit to have more or less the same number of LPs assigned to it; this macro computes the first index of the LP to assign to a node/processing unit.

Function Documentation

◆ SetState()

void SetState ( void *  state)

Set the LP simulation state main pointer.

Parameters
stateThe state pointer to be passed to ProcessEvent() for the invoker LP

Variable Documentation

◆ lps

struct lp_ctx* lps

A pointer to the LP contexts array.

Valid entries are contained between lid_node_first and lid_node_first + n_lps_node - 1, limits included

◆ n_lps_node

lp_id_t n_lps_node

The number of LPs hosted on this node.

The total number of LPs hosted in the node.