ROSS
tw-util.c File Reference
#include <ross.h>
#include <stdio.h>
#include <ctype.h>

Go to the source code of this file.

Data Structures

struct  mem_pool

Functions

int tw_output (tw_lp *lp, const char *fmt,...)
void tw_printf (const char *file, int line, const char *fmt,...)
void tw_error (const char *file, int line, const char *fmt,...)
void tw_warning (const char *file, int line, const char *fmt,...)
static void * my_malloc (size_t len)
void tw_calloc_stats (size_t *bytes_alloc, size_t *bytes_wasted)
static void * pool_alloc (size_t len)
void * tw_calloc (const char *file, int line, const char *for_who, size_t e_sz, size_t n)
void tw_fprint_binary_array (FILE *output, char const *prefix, void const *array, size_t size)
 Prints content of memory into hexadecimal.

Variables

static struct mem_poolmain_pool
static const size_t pool_size = (512 * 1024) - 32
static const size_t pool_align = ((sizeof(double)) > (sizeof(void*)) ? (sizeof(double)) : (sizeof(void*)))
static size_t total_allocated
static unsigned malloc_calls

Function Documentation

◆ my_malloc()

void * my_malloc ( size_t len)
static

Definition at line 243 of file tw-util.c.

References malloc_calls.

Referenced by pool_alloc().

◆ pool_alloc()

void * pool_alloc ( size_t len)
static

◆ tw_calloc()

◆ tw_calloc_stats()

void tw_calloc_stats ( size_t * bytes_alloc,
size_t * bytes_wasted )

◆ tw_error()

void tw_error ( const char * file,
int line,
const char * fmt,
... )

Definition at line 77 of file tw-util.c.

References g_tw_mynode, and tw_net_abort().

Referenced by analysis_init(), apply_opt(), avl_alloc(), avlDelete(), avlInsert(), buddy_alloc(), crv_add_custom_state_checkpoint(), does_any_pe(), early_sanity_check(), event_cancel(), io_event_deserialize(), io_load_events(), is_gvt_past_hook_threshold(), late_sanity_check(), main(), map_linear(), parse_args_file(), phold_event_handler(), phold_pre_run(), recv_begin(), recv_finish(), rng_gen_reverse_val(), send_begin(), send_finish(), setup_pes(), st_collect_engine_data_kps(), st_collect_engine_data_lps(), test_q(), tw_calloc(), tw_define_lps(), tw_event_new_user_prio(), tw_event_send(), tw_eventq_debug(), tw_getkp(), tw_getlocal_lp(), tw_getlp(), tw_gvt_hook_step(), tw_gvt_hook_step_seq(), tw_gvt_step2(), tw_hash_create(), tw_hash_remove(), tw_init(), tw_init_lps(), tw_kp_onpe(), tw_kp_rollback_event(), tw_lp_onkp(), tw_lp_onpe(), tw_lp_settype(), tw_lp_setup_types(), tw_lp_suspend(), tw_net_barrier(), tw_net_cancel(), tw_net_init(), tw_net_start(), tw_net_statistics(), tw_net_stop(), tw_opt_parse(), tw_pe_init(), tw_pe_settype(), tw_pq_compare_less_than(), tw_pq_delete_any(), tw_pre_run_lps(), tw_rand_init_streams(), tw_rand_normal01(), tw_run(), tw_sched_batch(), tw_sched_batch_realtime(), tw_sched_cancel_q(), tw_sched_event_q(), tw_scheduler_conservative(), tw_scheduler_optimistic_debug(), tw_scheduler_sequential(), tw_scheduler_sequential_rollback_check(), tw_snapshot_delta(), tw_snapshot_restore(), tw_trigger_gvt_hook_every(), tw_trigger_gvt_hook_now(), and tw_wall_now().

◆ tw_fprint_binary_array()

void tw_fprint_binary_array ( FILE * output,
char const * prefix,
void const * array,
size_t size )

tw_fprint_binary_array

Printing the array "hello world! I'm happy to be here" would produce:

| 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 20 49 27 6d | hello world! I'm | 20 68 61 70 70 79 20 74 6f 20 62 65 20 68 65 72 | happy to be her | 65 | e

Definition at line 261 of file tw-util.c.

Referenced by crv_check_lpstates(), and print_event().

◆ tw_output()

int tw_output ( tw_lp * lp,
const char * fmt,
... )

Rollback-aware printf, i.e. if the event gets rolled back, undo the printf. We can'd do that of course so we store the message in a buffer until GVT.

Definition at line 10 of file tw-util.c.

References CONSERVATIVE, tw_pe::cur_event, g_tw_synchronization_protocol, tw_kp::id, tw_lp::kp, tw_out::message, tw_out::next, tw_event::out_msgs, tw_lp::pe, SEQUENTIAL, SEQUENTIAL_ROLLBACK_CHECK, tw_kp_grab_output_buffer(), TW_LOC, and tw_printf().

◆ tw_printf()

void tw_printf ( const char * file,
int line,
const char * fmt,
... )

Definition at line 64 of file tw-util.c.

Referenced by avlInsert(), buddy_free(), early_sanity_check(), and tw_output().

◆ tw_warning()

void tw_warning ( const char * file,
int line,
const char * fmt,
... )

Definition at line 93 of file tw-util.c.

References g_tw_mynode.

Referenced by apply_opt(), tw_gvt_hook_step_seq(), and tw_trigger_gvt_hook_at().

Variable Documentation

◆ main_pool

struct mem_pool* main_pool
static

Definition at line 113 of file tw-util.c.

Referenced by pool_alloc(), and tw_calloc_stats().

◆ malloc_calls

unsigned malloc_calls
static

Definition at line 119 of file tw-util.c.

Referenced by my_malloc(), and tw_calloc_stats().

◆ pool_align

const size_t pool_align = ((sizeof(double)) > (sizeof(void*)) ? (sizeof(double)) : (sizeof(void*)))
static

Definition at line 117 of file tw-util.c.

Referenced by tw_calloc().

◆ pool_size

const size_t pool_size = (512 * 1024) - 32
static

Definition at line 116 of file tw-util.c.

Referenced by pool_alloc().

◆ total_allocated

size_t total_allocated
static

Definition at line 118 of file tw-util.c.

Referenced by pool_alloc(), tw_calloc(), and tw_calloc_stats().