GitLab maintenance scheduled for Today, 2020-08-11, from 17:00 to 18:00 CT - Services will be unavailable during this time.

codes.h 1.53 KB
Newer Older
1
/*
Philip Carns's avatar
Philip Carns committed
2
 * Copyright (C) 2013 University of Chicago.
3
 * See COPYRIGHT notice in top-level directory.
Philip Carns's avatar
Philip Carns committed
4
 *
5 6
 */

Philip Carns's avatar
Philip Carns committed
7

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#ifndef CODES_H
#define CODES_H

#include <ross.h>
#include <assert.h>

#if 0
#define codes_event_new tw_event_new
#else
static inline tw_event * codes_event_new(
    tw_lpid dest_gid, 
    tw_stime offset_ts, 
    tw_lp * sender)
{
    tw_stime abs_ts = offset_ts + tw_now(sender); 
    assert(abs_ts < g_tw_ts_end);
    //printf("codes_event_new() abs_ts: %.9f\n", abs_ts);
    return(tw_event_new(dest_gid, offset_ts, sender));
}
#endif

/* TODO: validate what value we should use here */
/* Modeled latency for communication between local software components and
 * communication between daemons and hardware devices.  Measured in
 * nanoseconds.
33 34 35 36
 * Modified Jul 7: We want to make sure that the event time stamp generated
is always greater than the default g_tw_lookahead value. Multiplying by 1.1
ensures that if tw_rand_exponential generates a zero time-stamped event, we
still have a timestamp that is greater than g_tw_lookahead. 
37 38 39 40
 */
#define CODES_MEAN_LOCAL_LATENCY 0.01
static inline tw_stime codes_local_latency(tw_lp *lp)
{
41
    int r = g_tw_nRNG_per_lp-1;
42 43
    tw_stime tmp;

44
    tmp = (1.1 * g_tw_lookahead) + tw_rand_exponential(&lp->rng[r], CODES_MEAN_LOCAL_LATENCY);
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

    return(tmp);
}

static inline void codes_local_latency_reverse(tw_lp *lp)
{
    tw_rand_reverse_unif(lp->rng);
    return;
}

#endif /* CODES_H */

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ft=c ts=8 sts=4 sw=4 expandtab
 */