/* * Blue Gene/P model * Header file * by Ning Liu */ #include "bgp.h" const tw_optdef app_opt [] = { TWOPT_GROUP("BGP Model"), TWOPT_UINT("memory", opt_mem, "optimistic memory"), TWOPT_UINT("numfs", N_FS_active, "number of file server active"), TWOPT_UINT("numion", N_ION_active, "number of ION active"), TWOPT_UINT("burst", burst_buffer_on, "burst buffer button"), TWOPT_END() }; tw_peid bgp_mapping( tw_lpid gid) { return (tw_peid)gid/g_tw_nlp; //return (tw_peid)gid%tw_nnodes(); } tw_lptype mylps[] = { { (init_f) bgp_cn_init, (event_f) bgp_cn_eventHandler, (revent_f) bgp_cn_eventHandler_rc, (final_f) bgp_cn_finish,
tw_lptype mylps[] = { { (init_f) tmr_init, (event_f) tmr_event_handler, (revent_f) tmr_event_handler_rc, (final_f) tmr_finish, (map_f) tmr_map, sizeof(tmr_state) }, {0}, }; const tw_optdef app_opt[] = { TWOPT_GROUP("TIMER Model"), TWOPT_STIME("remote", percent_remote, "desired remote event rate"), TWOPT_UINT("nlp", nlp_per_pe, "number of LPs per processor"), TWOPT_STIME("mean", mean, "exponential distribution mean for timestamps"), TWOPT_STIME("mult", mult, "multiplier for event memory allocation"), TWOPT_UINT("start-events", g_tmr_start_events, "number of initial messages per LP"), TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"), TWOPT_CHAR("run", run_id, "user supplied run name"), TWOPT_CHAR("verbose", verbose, "verbose statements"), TWOPT_END() }; int main(int argc, char **argv, char **env) { int i;
static void handle_ping_rev_event(node_state *ns, tw_bf *b, node_msg *m, tw_lp *lp); static void handle_pong_rev_event(node_state *ns, tw_bf *b, node_msg *m, tw_lp *lp); static void node_add_lp_type(); static tw_lpid get_next_node(tw_lpid sender_id); static char conf_file_name[256]; const tw_optdef app_opt[] = { TWOPT_GROUP("Torus network sim"), TWOPT_CHAR("codes-config", conf_file_name, "name of conf file"), TWOPT_END() }; extern void fisheryates(int *a, int len); extern int arc4random_uniform(int max); int *node_mappings; void generate_node_mappings(); void free_node_mappings(); int find_node_distance(int src[3], int dst[3]); static tw_stime ns_to_s(tw_stime ns) {
int a = 1; memcpy(buffer, &a, sizeof(a)); return; } st_model_types model_types[] = { {(ev_trace_f) event_trace, 0, (model_stat_f) phold_stats_collect, sizeof(int)}, {0} }; const tw_optdef app_opt[] = { TWOPT_GROUP("PHOLD Model"), TWOPT_STIME("remote", percent_remote, "desired remote event rate"), TWOPT_UINT("nlp", nlp_per_pe, "number of LPs per processor"), TWOPT_STIME("mean", mean, "exponential distribution mean for timestamps"), TWOPT_STIME("mult", mult, "multiplier for event memory allocation"), TWOPT_STIME("lookahead", lookahead, "lookahead for events"), TWOPT_UINT("start-events", g_phold_start_events, "number of initial messages per LP"), TWOPT_UINT("stagger", stagger, "Set to 1 to stagger event uniformly across 0 to end time."), TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"), TWOPT_CHAR("run", run_id, "user supplied run name"), TWOPT_END() }; int main(int argc, char **argv, char **env) {
struct svr_msg { msg_header h; int tag; lsm_return_t ret; int incremented_flag; /* helper for reverse computation */ }; static int magic = 123; static struct codes_cb_info cb_info; char conf_file_name[256] = {0}; const tw_optdef app_opt[] = { TWOPT_GROUP("Simple Network Test Model"), TWOPT_CHAR("conf", conf_file_name, "Name of configuration file"), TWOPT_END() }; static void svr_init( svr_state * ns, tw_lp * lp); static void svr_event( svr_state * ns, tw_bf * b, svr_msg * m, tw_lp * lp); static void svr_rev_event( svr_state * ns,
#include <ip.h> const tw_optdef ip_opts[] = { TWOPT_GROUP("IPv4 Model"), TWOPT_UINT("ip-log", g_ip_log_on, "turn on logging"), TWOPT_END() }; void ip_md_init(int argc, char ** argv, char ** env) { //int i; char log[1024]; g_ip_stats = tw_calloc(TW_LOC, "", sizeof(ip_stats), 1); // in secs.. g_ip_minor_interval = 60; g_ip_major_interval = 86400; tw_opt_add(ip_opts); if(g_ip_log_on) { sprintf(log, "%s/ip.log", g_rn_logs_dir); g_ip_log = fopen(log, "w"); if(!g_ip_log) tw_error(TW_LOC, "Unable to open: %s \n", log);
#include <ross.h> #include "lz4.h" /** * @file tw-setup.c * @brief tw_define_lps is defined here! */ #define VERIFY_MAPPING 0 static tw_pe *setup_pes(void); unsigned int nkp_per_pe = 16; static const tw_optdef kernel_options[] = { TWOPT_GROUP("ROSS Kernel"), TWOPT_UINT("synch", g_tw_synchronization_protocol, "Sychronization Protocol: SEQUENTIAL=1, CONSERVATIVE=2, OPTIMISTIC=3, OPTIMISTIC_DEBUG=4"), TWOPT_UINT("nkp", nkp_per_pe, "number of kernel processes (KPs) per pe"), TWOPT_STIME("end", g_tw_ts_end, "simulation end timestamp"), TWOPT_UINT("batch", g_tw_mblock, "messages per scheduler block"), TWOPT_UINT("extramem", g_tw_events_per_pe_extra, "Number of extra events allocated per PE."), TWOPT_UINT("buddy-size", g_tw_buddy_alloc, "delta encoding buddy system allocation (2^X)"), TWOPT_UINT("lz4-knob", g_tw_lz4_knob, "LZ4 acceleration factor (higher = faster)"), #ifdef AVL_TREE TWOPT_UINT("avl-size", g_tw_avl_node_count, "AVL Tree contains 2^avl-size nodes"), #endif TWOPT_END() }; void tw_init(int *argc, char ***argv) { int i; #if HAVE_CTIME
(map_f) NULL, sizeof(Host_State)}, { (init_f) tcp_router_StartUp, (pre_run_f) NULL, (event_f) tcp_router_EventHandler, (revent_f) tcp_router_rc_EventHandler, (final_f) tcp_router_Statistics_CollectStats, (map_f) NULL, sizeof(Router_State)}, {0}, }; const tw_optdef app_opt[] = { TWOPT_GROUP("TCP Model"), TWOPT_STIME("remote-link", percent_remote, "desired remote TCP connectionsevent rate"), TWOPT_UINT("network-bits", nlp_per_model, "number of 2^bits is number of LPs in whole system"), TWOPT_STIME("mean", mean, "exponential distribution mean for timestamps"), TWOPT_STIME("mult", mult, "multiplier for event memory allocation"), TWOPT_STIME("lookahead", lookahead, "lookahead for links"), TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"), TWOPT_CHAR("run", run_id, "user supplied run name"), TWOPT_END() }; extern tcpStatistics TWAppStats; int main(int argc, char **argv) {
} tw_lptype olsr_lps[] = { { (init_f) olsr_init, (event_f) olsr_event, (revent_f) NULL, (final_f) olsr_final, (map_f) olsr_map, sizeof(node_state) }, { 0 }, }; const tw_optdef olsr_opts[] = { TWOPT_GROUP("OLSR Model"), TWOPT_UINT("lp_per_pe", nlp_per_pe, "number of LPs per processor"), TWOPT_END(), }; int main(int argc, char *argv[]) { int i; g_tw_events_per_pe = nlp_per_pe * nlp_per_pe * 1; tw_opt_add(olsr_opts); tw_init(&argc, &argv); tw_define_lps(nlp_per_pe, sizeof(olsr_msg_data), 0);
total_delays += s->num_delays; total_collectives += s->num_cols; printf("\n LP %ld total sends %ld receives %ld wait_alls %ld waits %ld ", lp->gid, s->num_sends,s->num_recvs, s->num_waitall, s->num_wait); avg_time += s->total_time; avg_compute_time += s->compute_time; avg_comm_time += (s->total_time - s->compute_time); avg_wait_time += s->wait_time; avg_send_time += s->send_time; avg_recv_time += s->recv_time; avg_col_time += s->col_time; } const tw_optdef app_opt [] = { TWOPT_GROUP("Network workload test"), TWOPT_CHAR("workload_type", workload_type, "workload type (either \"scalatrace\" or \"dumpi\")"), TWOPT_CHAR("workload_file", workload_file, "workload file name"), TWOPT_CHAR("offset_file", offset_file, "offset file name"), TWOPT_END() }; tw_lptype nw_lp = { (init_f) nw_test_init, (pre_run_f) NULL, (event_f) nw_test_event_handler, (revent_f) nw_test_event_handler_rc, (final_f) nw_test_finalize, (map_f) codes_mapping, sizeof(nw_state) };
} static tw_lptype s_lp = { (init_f) s_init, (pre_run_f) NULL, (event_f) s_event, (revent_f) s_event_rc, (final_f) s_finalize, (map_f) codes_mapping, sizeof(s_state), }; static char conf_file_name[128] = {'\0'}; static const tw_optdef app_opt [] = { TWOPT_GROUP("codes-mapping test case" ), TWOPT_CHAR("codes-config", conf_file_name, "name of codes configuration file"), TWOPT_END() }; int main(int argc, char *argv[]) { g_tw_ts_end = 1e9*60*60*24*365; /* one year, in nsecs */ tw_opt_add(app_opt); tw_init(&argc, &argv); if (!conf_file_name[0]){ fprintf(stderr, "Expected \"codes-config\" option, please see --help.\n"); MPI_Finalize(); return 1; } if (configuration_load(conf_file_name, MPI_COMM_WORLD, &config)){
unsigned long long station_total_packets=0; printf("LP %llu had %d / %d failed Station to Access Point packets\n", lp->gid, s->failed_packets, s->total_packets); for( i=0; i < WIFI_MAX_STATIONS_PER_ACCESS_POINT; i++) { station_failed_packets += s->stations[i].failed_packets; station_total_packets += s->stations[i].total_packets; } printf("LP %llu had %llu / %llu failed Access Point to Station packets\n", lp->gid, station_failed_packets, station_total_packets); } const tw_optdef app_opt[] = { TWOPT_GROUP("802.11b Model"), TWOPT_UINT("nlp", nlp_per_pe, "number of LPs per processor"), TWOPT_STIME("mean", mean, "exponential distribution mean for timestamps"), TWOPT_STIME("mult", mult, "multiplier for event memory allocation"), TWOPT_STIME("lookahead", lookahead, "lookahead for events"), TWOPT_UINT("start-events", g_wifi_start_events, "number of initial messages per LP"), TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"), TWOPT_CHAR("run", run_id, "user supplied run name"), TWOPT_END() }; int main(int argc, char **argv, char **env) { int i; lookahead = 1.0;
for (req = 1; req < NUM_REQS; req++){ written += sprintf(buf+written, ",%d",ns->req_stat[req]); } sprintf(buf+written, "]\n"); fprintf(f, "%s",buf); free(buf); } /**** END IMPLEMENTATIONS ****/ /**** BEGIN MAIN ****/ char conf_file_name[256] = {0}; const tw_optdef app_opt[] = { TWOPT_GROUP("ROSD mock test model"), TWOPT_CHAR("codes-config", conf_file_name, "Name of codes configuration file"), TWOPT_END() }; tw_stime s_to_ns(tw_stime ns) { return(ns * (1000.0 * 1000.0 * 1000.0)); } int main(int argc, char *argv[]) { int num_nets, *net_ids; g_tw_ts_end = s_to_ns(60*60*24*365); /* one year, in nsecs */ tw_opt_add(app_opt);
static unsigned int g_tw_gvt_no_change = 0; static tw_mutex g_tw_gvt_lck = TW_MUTEX_INIT; static tw_volatile tw_stime sim_gvt; static tw_stime node_lvt; static unsigned int gvt_cnt; static tw_stime secs = 0.1; static tw_stime delta_t = 0.01; static unsigned int CPU = 1998; static int TW_PARALLEL = 0; static int TW_DISTRIBUTED = 0; static const tw_optdef gvt_opts [] = { TWOPT_GROUP("ROSS 7 O'clock GVT"), TWOPT_STIME("report-interval", gvt_print_interval, "percent of runtime to print GVT"), TWOPT_STIME("delta_t", delta_t, "Max event send time (secs)"), TWOPT_STIME("clock-interval", secs, "GVT clock interval (in secs)"), TWOPT_UINT("clock-speed", CPU, "CPU clock speed (in MHz)"), TWOPT_UINT("gvt-interval", g_tw_gvt_interval, "GVT interval (shm only)"), TWOPT_END() }; void tw_gvt_stats(FILE * f) { fprintf(f, "TW GVT Settings: Seven O'clock\n"); fprintf(f, "\t%-50s %11.2lf (secs)\n", "GVT Clock Interval", secs); fprintf(f, "\t%-50s %11d\n", "GVT Interval", g_tw_gvt_interval);
bj_hashlittle2("forwarder", strlen("forwarder"), &h1, &h2); forwarder_magic = h1 + h2; lp_type_register("forwarder", &forwarder_lp); } /**** END IMPLEMENTATIONS ****/ /* arguments to be handled by ROSS - strings passed in are expected to be * pre-allocated */ static char conf_file_name[256] = { 0 }; /* this struct contains default parameters used by ROSS, as well as * user-specific arguments to be handled by the ROSS config sys. Pass it in * prior to calling tw_init */ const tw_optdef app_opt[] = { TWOPT_GROUP("Model net test case" ), TWOPT_CHAR("codes-config", conf_file_name, "name of codes configuration file"), TWOPT_END() }; static tw_stime s_to_ns(tw_stime ns) { //printf("in s_to_ns\n"); return (ns * (1000.0 * 1000.0 * 1000.0)); } static tw_stime ns_to_s(tw_stime ns) { //printf("In ns_to_s\n"); return (ns / (1000.0 * 1000.0 * 1000.0)); } int main(int argc, char *argv[]) { //printf("In main\n");
{ } tw_lptype mylps[] = { {(init_f) init, (event_f) event_handler, (revent_f) event_handler_rc, (final_f) finish, (map_f) map_to_pe, sizeof(ping_pong_state)}, {0}, }; const tw_optdef app_opt[] = { TWOPT_GROUP("Ping Pong Model"), TWOPT_UINT("nlp", nlp_per_pe, "number of LPs per processor"), TWOPT_STIME("lookahead", lookahead, "lookahead for events"), TWOPT_UINT("start-events", g_start_events, "number of initial messages per LP"), TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"), TWOPT_END() }; int main(int argc, char **argv, char **env) { int i; lookahead = 1.0; tw_opt_add(app_opt); tw_init(&argc, &argv);
tw_lptype mylps[] = { { (init_f) mem_init, (event_f) mem_event_handler, (revent_f) mem_event_handler_rc, (final_f) mem_finish, (map_f) mem_map, sizeof(mem_state) }, {0}, }; const tw_optdef app_opt[] = { TWOPT_GROUP("Memory Model"), TWOPT_UINT("nbuffers", nbufs, "number of memory buffers per event"), TWOPT_STIME("remote", percent_remote, "desired remote event rate"), TWOPT_UINT("nlp", nlp_per_pe, "number of LPs per processor"), TWOPT_STIME("mean", mean, "exponential distribution mean for timestamps"), TWOPT_STIME("mult", mult, "multiplier for event memory allocation"), TWOPT_UINT("start-events", g_mem_start_events, "number of initial messages per LP"), TWOPT_UINT("memory", optimistic_memory, "additional memory buffers"), TWOPT_CHAR("run", run_id, "user supplied run name"), TWOPT_END() }; int main(int argc, char **argv, char **env) { int i;
//The main function and command line arguments #include <stdio.h> #include <libgen.h> #include <assert.h> #include "gates-config.h" #include "generic-model.h" #include "routing.h" //#define VERIFY_READ 1 intarrptr routing_table_mpi; const tw_optdef gates_opts[] = { TWOPT_GROUP("Gates Model"), TWOPT_END(), }; tw_lptype gates_lps[] = { { (init_f) gates_init, (pre_run_f) NULL, (event_f) gates_event, (revent_f) gates_event_rc, (commit_f) NULL, (final_f) gates_final, (map_f) gates_custom_mapping_to_pe, sizeof(gate_state) }, { 0 }, };
tw_lp_onpe(i, pe, g_tw_mynode * nlp_nodes_per_pe + i + getRem() ); tw_lp_onkp(g_tw_lp[i], g_tw_kp[kpid]); tw_lp_settype(i, &nodes_lps[0]); } for(i = 0; i < nlp_mpi_procs_per_pe; i++) { kpid = i % g_tw_nkp; pe = tw_getpe(kpid % g_tw_npe); tw_lp_onpe(nlp_nodes_per_pe+i, pe, N_nodes + g_tw_mynode * nlp_mpi_procs_per_pe + i + getRem() ); tw_lp_onkp(g_tw_lp[nlp_nodes_per_pe + i], g_tw_kp[kpid]); tw_lp_settype(nlp_nodes_per_pe + i, &nodes_lps[1]); } } const tw_optdef app_opt [] = { TWOPT_GROUP("Nodes Model"), TWOPT_UINT("memory", opt_mem, "optimistic memory"), TWOPT_UINT("vc_size", vc_size, "VC size"), TWOPT_ULONG("mpi-message-size", mpi_message_size, "mpi-message-size"), TWOPT_UINT("mem_factor", mem_factor, "mem_factor"), TWOPT_CHAR("traffic", traffic_str, "uniform, nearest, diagonal"), TWOPT_STIME("injection_interval", injection_interval, "messages are injected during this interval only "), TWOPT_STIME("link_bandwidth", link_bandwidth, " link bandwidth per channel "), TWOPT_STIME("arrive_rate", MEAN_INTERVAL, "packet arrive rate"), TWOPT_END() }; int main(int argc, char **argv, char **env) {
}; #define EVENT_TAG 1 #define EVENT_SIZE(e) g_tw_event_msg_sz static struct act_q posted_sends; static struct act_q posted_recvs; static tw_eventq outq; static unsigned int read_buffer = 16; static unsigned int send_buffer = 1024; static int world_size = 1; static const tw_optdef mpi_opts[] = { TWOPT_GROUP("ROSS MPI Kernel"), TWOPT_UINT( "read-buffer", read_buffer, "network read buffer size in # of events"), TWOPT_UINT( "send-buffer", send_buffer, "network send buffer size in # of events"), TWOPT_END() }; // Forward declarations of functions used in MPI network message processing static int recv_begin(tw_pe *me); static void recv_finish(tw_pe *me, tw_event *e, char * buffer); static int send_begin(tw_pe *me);
#include <ross.h> #define TW_GVT_NORMAL 0 #define TW_GVT_COMPUTE 1 static unsigned int g_tw_gvt_max_no_change = 10000; static unsigned int g_tw_gvt_no_change = 0; static tw_stat all_reduce_cnt = 0; static unsigned int gvt_cnt = 0; static unsigned int gvt_force = 0; static const tw_optdef gvt_opts [] = { TWOPT_GROUP("ROSS MPI GVT"), TWOPT_UINT("gvt-interval", g_tw_gvt_interval, "GVT Interval"), TWOPT_STIME("report-interval", gvt_print_interval, "percent of runtime to print GVT"), TWOPT_END() }; const tw_optdef * tw_gvt_setup(void) { gvt_cnt = 0; return gvt_opts; } void tw_gvt_start(void) {
g_epi_stats->s_ndead += state->stats->s_ndead; } tw_lptype mylps[] = { {(init_f) epi_init, (event_f) epi_event_handler, (revent_f) epi_rc_event_handler, (final_f) epi_final, (map_f) epi_map, sizeof(epi_state)}, {0}, }; const tw_optdef app_opt[] = { TWOPT_GROUP("EPI Model: "), // output files TWOPT_CHAR("positions", g_epi_position_fn, "Agent position output file"), TWOPT_CHAR("hospital-output", g_epi_hospital_fn, "Hospital output file name"), TWOPT_UINT("report-int", g_epi_mod, "Reporting Interval"), // agent parameters TWOPT_STIME("sick-rate", g_epi_sick_rate, "Probability agents start sick"), TWOPT_CHAR("worried-well", g_epi_ww_rate, "Probability agents are worried well"), TWOPT_STIME("wwell-thresh", g_epi_ww_threshold, "Worried well threshold"), TWOPT_UINT("wwell-dur", g_epi_ww_duration, "Worried well duration"), TWOPT_STIME("work-while-sick", g_epi_wws_rate, "Probability agents work while sick"), // init model algorithmically TWOPT_GROUP("EPI Model: initialize algorithmically (default mode)"),
(init_f) netdmf_srw_init, (event_f) netdmf_srw_event, (revent_f) netdmf_srw_revent, (final_f) netdmf_srw_final, (map_f) netdmf_srw_map, sizeof (srw_state) }, {0}, }; /** Filename of [optional] NetDMF configuration */ char netdmf_config[1024] = ""; /** Various additional options for SRW */ const tw_optdef srw_opts[] = { TWOPT_GROUP("SRW Model"), #ifdef WITH_NETDMF TWOPT_CHAR("netdmf-config", netdmf_config, "NetDMF Configuration file"), #endif /* WITH_NETDMF */ TWOPT_END() }; #ifdef WITH_NETDMF void rn_netdmf_init(); tw_petype srw_pes[] = { { (pe_init_f) 0, (pe_init_f) rn_netdmf_init, (pe_gvt_f) 0, (pe_final_f) 0,
{ KICKOFF, /* initial event */ }; struct svr_state { }; struct svr_msg { enum svr_event_type event_type; tw_lpid src; /* source of this request or ack */ }; const tw_optdef app_opt[] = { TWOPT_GROUP("lp-io Test Model"), TWOPT_END() }; static void svr_init( svr_state * ns, tw_lp * lp); static void svr_event( svr_state * ns, tw_bf * b, svr_msg * m, tw_lp * lp); static void svr_rev_event( svr_state * ns, tw_bf * b, svr_msg * m,
#include <tlm.h> static FILE *g_tlm_output_f = NULL; static const tw_optdef tlm_options [] = { TWOPT_GROUP("Transmission Line Matrix Model"), TWOPT_UINT("memory", g_tlm_optmem, "Additional memory buffers"), TWOPT_STIME("threshold", g_tlm_wave_threshold, "Wave propagation threshold"), TWOPT_END() }; void tlm_md_opts() { tw_opt_add(tlm_options); } void tlm_md_init(int argc, char ** argv, char ** env) { tw_lpid nlp_grid; int i; if(!g_rn_environment) return; g_tlm_stats = tw_calloc(TW_LOC, "", sizeof(*g_tlm_stats), 1); // g_tlm_output_fix up global variables
svr_state * ns, tw_lp * lp); tw_lptype svr_lp = { (init_f) svr_init, (pre_run_f) NULL, (event_f) svr_event, (revent_f) svr_rev_event, (final_f) svr_finalize, (map_f) codes_mapping, sizeof(svr_state), }; const tw_optdef app_opt [] = { TWOPT_GROUP("Model net synthetic traffic " ), TWOPT_UINT("traffic", traffic, "UNIFORM RANDOM=1, NEAREST NEIGHBOR=2 "), TWOPT_STIME("arrival_time", arrival_time, "INTER-ARRIVAL TIME"), TWOPT_END() }; const tw_lptype* svr_get_lp_type() { return(&svr_lp); } static void svr_add_lp_type() { lp_type_register("server", svr_get_lp_type()); }