Example #1
0
def main():
    env = simpy.Environment()

    # pylint: disable=global-statement
    global LOGGER
    LOGGER.add("output/data_{time}.log",
               level='TRACE',
               filter=lambda record: 'by_core' in record['extra'],
               format=("[{extra[component]: <8} c {extra[by_core]: <2}]"
                       " <level>{message}</level> @ {extra[current]}"),
               enqueue=True)
    LOGGER = LOGGER.patch(
        lambda record: record["extra"].update(current=env.now))

    network_fabric = NetworkFabric(env, NetworkFabric.ONE_GBPS)

    host_platform = HostPlatform(env, network_fabric)
    host_platform.start()

    embedded_platform = EmbeddedPlatform(env, network_fabric,
                                         host_platform.submission_queues,
                                         host_platform.completion_queues)
    embedded_platform.start()

    host_platform.run_apps(24, (20, 30))

    # event tracing
    ###############################

    # pylint: disable=global-statement
    global TRACER
    TRACER = EventTracer(env)

    # Uncomment the following line so that you can print
    # the event history with TRACER.print_trace_data() at
    # wherever you want.

    # TRACER.trace()

    ###############################

    shutdown_hook = env.event()
    host_platform.set_shutdown_hook(shutdown_hook)
    env.run(until=shutdown_hook)

    # Or you can print the event history at the end.
    # TRACER.print_trace_data()

    LOGGER.debug("summary: {}".format(host_platform.summary))
    LOGGER.debug("simulation has successfully finished.")