Exemple #1
0
static void dump_stats(void)
{
	unsigned long now = get_nsecs();
	long dt = now - prev_time;
	int i;

	prev_time = now;

	for (i = 0; i < num_socks; i++) {
		char *fmt = "%-15s %'-11.0f %'-11lu\n";
		double rx_pps, tx_pps;

		rx_pps = (xsks[i]->rx_npkts - xsks[i]->prev_rx_npkts) *
			 1000000000. / dt;
		tx_pps = (xsks[i]->tx_npkts - xsks[i]->prev_tx_npkts) *
			 1000000000. / dt;

		printf("\n sock%d@", i);
		print_benchmark(false);
		printf("\n");

		printf("%-15s %-11s %-11s %-11.2f\n", "", "pps", "pkts",
		       dt / 1000000000.);
		printf(fmt, "rx", rx_pps, xsks[i]->rx_npkts);
		printf(fmt, "tx", tx_pps, xsks[i]->tx_npkts);

		xsks[i]->prev_rx_npkts = xsks[i]->rx_npkts;
		xsks[i]->prev_tx_npkts = xsks[i]->tx_npkts;
	}
}
Exemple #2
0
void print_results(benchmark_t *setup)
{
    printf("benchmark completed\n");
    print_benchmark(setup);
    int user_index, node_index;
    double publish_average = 0;
    double subscribe_average = 0;
    int local_sum;
    for (user_index = 0; user_index < setup -> n_publishers; user_index++)
    {
      local_sum = 0;
      for (node_index = 0; node_index < setup -> publish_factor; node_index++)
      {
        local_sum += publish_count[user_index][node_index];
      }
      printf("Publisher %d published %d messaged\n", user_index, local_sum);
      publish_average += local_sum;
    }
    publish_average = publish_average / (((double) setup -> n_publishers)*(double) setup -> time);

    printf("\n\nPublish Average %f\n\n", publish_average);
    for (user_index = 0; user_index < setup -> n_subscribers; user_index++)
    {
      local_sum = 0;
      for (node_index = 0; node_index < setup -> subscribe_factor; node_index++)
      {
        local_sum += subscribe_count[user_index][node_index];
      }
      printf("Subscriberer %d received %d messages\n", user_index, local_sum);
      subscribe_average += local_sum;
    }
    subscribe_average = subscribe_average / (((double) setup -> n_subscribers) * (double) setup -> time);
    printf("\n\nSubscribe Average %f\n\n", subscribe_average);
}
Exemple #3
0
int main(const int argc, const char* argv[])
{
    InputArgs input_args;
    if (!read_cli_arguments(input_args, argc, argv))
    {
        std::cerr << "usage: " << argv[0] << " CONF OUTPUT NSTEPS\n"
                  << "\n"
                  << "where\n"
                  << "  CONF is an input configuration in .gro format\n"
                  << "  OUTPUT is the final output configuration\n"
                  << "  NSTEPS is the number of steps to run\n";
        return 1;
    }

    std::cout << "Input arguments: "
              << "conf = " << input_args.input_conf
              << ", output = " << input_args.output_conf
              << ", num_steps = " << input_args.num_steps
              << "\n\n";

    const auto& ff = ArgonFF;

    std::cerr << "Reading configuration ... ";
    auto system = read_conf_from_grofile(input_args.input_conf, ff.sigma);
    std::cerr << "done.\n";

    std::cerr << "Setting up system ... ";
    create_cell_lists(system, ff.rcut);
    gen_system_velocities(system, 3.0);
    std::cerr << "done.\n";

    std::cerr << '\n';
    describe_system_config(system, ff);
    std::cerr << '\n';

    Benchmark benchmark;
    Energetics energy;

    std::cerr << "Simulating " << input_args.num_steps << " steps:\n";

    // [WIP] trajectory output
    benchmark.start_traj_output_update();
    std::string fntraj { "traj.gro" };
    {
        std::ofstream reset { fntraj, std::ios::out | std::ios::trunc };
    }
    benchmark.stop_traj_output_update();

    for (unsigned step = 0; step < input_args.num_steps; ++step)
    {
        if ((step % 10) == 0)
        {
            std::cerr << "\rstep " << step;
        }

        run_velocity_verlet(system, benchmark, ff, DefaultOpts);

        benchmark.start_energy_calc_update();
        if (step != 0 && (step % DefaultOpts.energy_calc) == 0)
        {
            calculate_system_energetics(energy, system, ff);
        }
        benchmark.stop_energy_calc_update();

        // [WIP] trajectory output
        benchmark.start_traj_output_update();
        if (step != 0 && (step % 20 == 0))
        {
            write_conf_to_grofile(system, fntraj, ff.sigma, OutputMode::Append);
        }
        benchmark.stop_traj_output_update();
    }

    benchmark.finalize();

    std::cerr << "\r                                                  \r"
              << "Finished.\n\n";

    std::cerr << "Writing final system to disk as '"
        << input_args.output_conf
        << "' ... ";
    write_conf_to_grofile(system, input_args.output_conf, ff.sigma, OutputMode::Replace);
    std::cerr << "done.\n";

    std::cerr << '\n';
    print_energetics(energy, ff);
    std::cerr << '\n';
    print_benchmark(benchmark);

    auto t = std::time(nullptr);
    std::cerr << "\nFinished simulation at "
        << std::put_time(std::localtime(&t), "%c") << ".\n";

    return 0;
}