void es::evaluate_gen(unsigned int gen_id) { try { run_simulation(gen_id); boost::format nec_output(eap::run_directory + "gen%04d/ind%09da%02d.out"); for (unsigned int i_pop=0; i_pop<m_pop.size(); ++i_pop) { for (unsigned int i_ant=0; i_ant<m_ant_configs.size(); ++i_ant) { evaluation_ptr p_eval(new evaluation); m_pop[i_pop]->m_evals.push_back(p_eval); unsigned int read = read_radiation(str(nec_output % gen_id % i_pop % i_ant), p_eval); if (read != (num_polar() * m_step_freq)) throw eap::InvalidStateException("Problem with output in " + str(nec_output % gen_id % i_pop % i_ant)); m_pop[i_pop]->m_one_ant_on_fitness.push_back(compare(m_free_inds[i_ant]->m_evals[0], m_pop[i_pop]->m_evals[i_ant])); m_pop[i_pop]->m_gain_fitness += m_pop[i_pop]->m_one_ant_on_fitness[i_ant]; } //normalize gain fitness m_pop[i_pop]->m_gain_fitness /= m_max_gain; m_pop[i_pop]->m_coupling_fitness = read_coupling(str(nec_output % gen_id % i_pop % m_ant_configs.size()), m_ant_configs.size()); //normalize coupling fitness m_pop[i_pop]->m_coupling_fitness += std::abs(m_min_coup); m_pop[i_pop]->m_coupling_fitness /= m_max_coup; m_pop[i_pop]->m_fitness = cal_fitness(m_pop[i_pop]); } } catch (...) { throw; } }
int main ( int argc, char *argv[] ) { // turn on data flow tracing and memory dump after load CPUObject::debug |= CPUObject::trace | CPUObject::memload; // make sure we've been given an object file name if( argc != 2 ) { cerr << "Usage: " << argv[0] << " object-file-name\n\n"; exit( 1 ); } cout << hex; // change base for future printing try { make_connections(); run_simulation( argv[1] ); } catch( ArchLibError &err ) { cout << endl << "Simulation aborted - ArchLib runtime error" << endl << "Cause: " << err.what() << endl; return( 1 ); } return( 0 ); }
int main (int argc, char **argv) { Solution *soln = user_get_solution (); int port = 16000; socket_init (); srand ((unsigned) time (NULL)); if (argc > 1) { if (sscanf (argv [1], "%d", &port) != 1) port = 16000; if (port < 1024 || port > 65535) { printf ("Garbage port value. Terminating.\n"); return 1; } } #ifdef __linux__ signal (SIGINT, handle_sigint); #endif if (run_simulation (soln, port)) return 0; printf ("Simulation failed.\n"); return 1; }
int main(int argc, char *argv[]) { init_genrand64(time(NULL)); int x_size = atoi(argv[1]); int y_size = atoi(argv[2]); int iterations = atoi(argv[3]); double wake_up_rate = strtod(argv[4], NULL); double division_rate = strtod(argv[5], NULL); double death_rate = strtod(argv[6], NULL); double occupancy = strtod(argv[7], NULL); int status; status = run_simulation(x_size, y_size, iterations, wake_up_rate, division_rate, death_rate, occupancy); if (status == 1) { printf("Everything has worked fine. The csv has been outputed\n"); } else { printf("Something has gone wrong you may want to check your parameters\n"); } return 0; }
int MRSG_main (const char* plat, const char* depl, const char* conf) { char* argv[] = { "mrsg", "--cfg=tracing:1", "--cfg=tracing/buffer:1", "--cfg=tracing/filename:tracefile.trace", "--cfg=tracing/categorized:1", "--cfg=tracing/uncategorized:1", "--cfg=viva/categorized:cat.plist", "--cfg=viva/uncategorized:uncat.plist" }; int argc = sizeof(argv)/sizeof(argv[0]); msg_error_t res = MSG_OK; config.initialized = 0; check_config (); MSG_init (&argc, argv); res = run_simulation (plat, depl, conf); if (res == MSG_OK) return 0; else return 1; }
int main( int argc, char **argv ) { if( find_option( argc, argv, "-h" ) >= 0 ) { printf( "Options:\n" ); printf( "-h to see this help\n" ); printf( "-n <int> to set the number of particles\n" ); printf( "-o <filename> to specify the output file name\n" ); return 0; } int n = read_int( argc, argv, "-n", 1000 ); char *savename = read_string( argc, argv, "-o", NULL ); FILE *fsave = savename ? fopen( savename, "w" ) : NULL; particle_t *particles = (particle_t*) malloc( n * sizeof(particle_t) ); set_size( n ); init_particles( n, particles ); // // simulate a number of time steps // double simulation_time = read_timer( ); run_simulation(particles, n, fsave); simulation_time = read_timer( ) - simulation_time; printf( "n = %d, simulation time = %g seconds\n", n, simulation_time ); free( particles ); if( fsave ) fclose( fsave ); return 0; }
/* Returns true if the simulation was pauseed, false otherwise */ bool mainwin::toggle_pause_simulation() { #define BREAK_MAIN_LOOP_WHEN_PAUSING 1 try { if (system.is_water_defined()) { if (system.is_paused()) { #if BREAK_MAIN_LOOP_WHEN_PAUSING run_simulation(); #else ui->statusBar->showMessage("Simulating"); system.continue_simulation(); #endif return false; } else { #if BREAK_MAIN_LOOP_WHEN_PAUSING system.pause_simulation(true); #else ui->statusBar->showMessage("Paused"); system.pause_simulation(false); #endif return true; } } } catch (std::exception &e) { message_handler::inform_about_exception("mainwin::start_simulation()", e, true); } #if DEBUG LINE_UNREACHABLE(); #endif return false; // Only to prevent warning }
void physicsactor_update(physicsactor_t *pa, const obstaclemap_t *obstaclemap) { int i; float dt = timer_get_delta(); const obstacle_t *at_U; /* getting hit & winning pose */ if(pa->state == PAS_GETTINGHIT) { input_ignore(pa->input); pa->facing_right = pa->xsp < 0.0f; } else if(pa->winning_pose) { /* brake on level clear */ const float thr = 60.0f; for(i=0; i<IB_MAX; i++) input_simulate_button_up(pa->input, (inputbutton_t)i); pa->gsp = clip(pa->gsp, -1.8f * pa->topspeed, 1.8f * pa->topspeed); if(pa->state == PAS_ROLLING) pa->state = PAS_BRAKING; if(pa->gsp > thr) input_simulate_button_down(pa->input, IB_LEFT); else if(pa->gsp < -thr) input_simulate_button_down(pa->input, IB_RIGHT); else input_ignore(pa->input); } else input_restore(pa->input); /* horizontal control lock timer */ if(pa->horizontal_control_lock_timer > 0.0f) { pa->horizontal_control_lock_timer = max(0.0f, pa->horizontal_control_lock_timer - dt); input_simulate_button_up(pa->input, IB_LEFT); input_simulate_button_up(pa->input, IB_RIGHT); pa->facing_right = pa->gsp > EPSILON; } /* don't bother jumping */ at_U = sensor_check(sensor_U(pa), pa->position, pa->movmode, obstaclemap); if(at_U != NULL && obstacle_is_solid(at_U)) input_simulate_button_up(pa->input, IB_FIRE1); /* face left/right */ if((pa->gsp > EPSILON || pa->in_the_air) && input_button_down(pa->input, IB_RIGHT)) pa->facing_right = TRUE; else if((pa->gsp < -EPSILON || pa->in_the_air) && input_button_down(pa->input, IB_LEFT)) pa->facing_right = FALSE; /* get to the real physics... */ run_simulation(pa, obstaclemap); /* reset input */ for(i=0; i<IB_MAX; i++) input_simulate_button_up(pa->input, (inputbutton_t)i); }
int main(int argc, char *argv[]){ size_t simulations, iterations; sscanf(argv[1], "%zi", &simulations); sscanf(argv[2], "%zi", &iterations); srand(time(0)); for(size_t i = 0; i < simulations; ++i){ printf("%d\n", run_simulation(iterations)); } }
int main(int argc, char **argv) { if(argc < 2) { printf("Usage: %s [filename]\n", argv[0]); return EXIT_FAILURE; } srand(time(NULL)); char *filename = argv[1]; table *data = read_table(filename); run_simulation(data); return EXIT_SUCCESS; }
/* ////////////////////////////////////////////////////////////////////////// */ int main(void) { int rc = FAILURE; int erc = EXIT_FAILURE; simulation_params_t *params = NULL; simulation_t *sim = NULL; /* print application banner */ printf("o %s %s\n", app_name, app_ver); if (SUCCESS != (rc = params_construct(¶ms))) { fprintf(stderr, "params_construct failure @ %s:%d: rc = %d\n", __FILE__, __LINE__, rc); goto cleanup; } if (SUCCESS != (rc = init_params(params, N, THERM_COND, T_MAX))) { fprintf(stderr, "init_params failure @ %s:%d: rc = %d\n", __FILE__, __LINE__, rc); goto cleanup; } if (SUCCESS != (rc = simulation_construct(&sim, params))) { fprintf(stderr, "simulation_construct failure @ %s:%d: rc = %d\n", __FILE__, __LINE__, rc); goto cleanup; } if (SUCCESS != (rc = set_initial_conds(sim->old_mesh))) { fprintf(stderr, "set_initial_conds failure @ %s:%d: rc = %d\n", __FILE__, __LINE__, rc); goto cleanup; } if (SUCCESS != (rc = run_simulation(sim))) { fprintf(stderr, "run_simulation failure @ %s:%d: rc = %d\n", __FILE__, __LINE__, rc); goto cleanup; } if (SUCCESS != dump(sim)) { fprintf(stderr, "dump failure @ %s:%d: rc = %d\n", __FILE__, __LINE__, rc); goto cleanup; } /* all is well */ erc = EXIT_SUCCESS; cleanup: (void)simulation_destruct(sim); (void)params_destruct(params); return erc; }
void mainwin::start_simulation() { try { system.define_water(new fvoctree(0, 0)); system.set_state_updated_callback(do_events, this); system.set_number_of_time_steps_before_resting(NUM_TIME_STEPS_PER_FRAME); ui->visualization_vw->set_system_to_visualize(&system); ui->visualization_vw->set_scalar_property_to_visualize(DEFAULT_SCALAR_PROPERTY_TO_VISUALIZE); run_simulation(); } catch (std::exception &e) { message_handler::inform_about_exception("mainwin::start_simulation()", e, true); } }
free_field_results get_free_field_results() const { auto results = run_simulation( no_wall_, {image_position_, receiver_position_}, wayverb::waveguide::coefficients_canonical{{1}, {1}}); const auto window = wayverb::core::right_hanning(results.front().size()); for (auto& i : results) { wayverb::core::elementwise_multiply(i, window); } return {std::vector<float>(results[0].begin(), results[0].end()), std::vector<float>(results[1].begin(), results[1].end())}; }
int main(void) { srand((unsigned)time(NULL)); int *mem = init_memory(); /* array used to simulate physical memory */ min_heap *event_queue = init_min_heap(); /* priority queue giving preference to events with smallest time */ event root_event = {0,-1}; /* initial event signaling for allocation at simulation time 0 */ insert_node(event_queue, root_event); run_simulation(event_queue, mem); /* simulate dynamic memory management */ free_min_heap(event_queue); free_memory(mem); exit(EXIT_SUCCESS); }
int main(int argc, char **argv){ char *simfile = options(argc,argv); parse_sim(sim = malloc(sizeof(simulation_t)),simfile); gen = gsl_rng_alloc(gsl_rng_mt19937); gsl_rng_set(gen,time(NULL)); run_simulation(sim,outfile); DMSG("free_sim"); finalize_simulation(sim); DMSG("free rng"); gsl_rng_free(gen); DMSG("exit program"); return EXIT_SUCCESS; }
int CombatRunner::get_result() { int p1_num_wins = 0; // run all the simulations while (cur_sim <= total_sims) { // each time p1 wins, tally it if (run_simulation() == P1_WON) ++p1_num_wins; // onto the next simulation ++cur_sim; } return p1_num_wins; }
int main (int argc, char **argv) { int i; process_cmd (argc, argv); for (i = 0; i < sim.runs; i++) { fprintf (sim.fout, "*******running simulation #%d ...\n\n", i+1); run_simulation (); fprintf (sim.fout, "\n*******done with simulation #%d ...\n\n", i+1); } if (sim.fout != stdout) fclose (sim.fout); return 0; }
int main(int argc, char **argv) { int i; /* If there are no arguments then show help */ if (argc <= 1) { show_help(); return 0; } /* Parse the arguments */ for (i = 1; i < argc; i++) { /* show help */ if ((strcmp(argv[i],"-h")==0) || (strcmp(argv[i],"--help")==0)) { show_help(); return 0; } if ((strcmp(argv[i],"-t")==0) || (strcmp(argv[i],"--tests")==0)) { run_tests(); return 0; } if (((strcmp(argv[i],"-r")==0) || (strcmp(argv[i],"--run")==0)) && argc == 4) { char * repos_dir; int generation_max; repos_dir=argv[i+1]; generation_max=atoi(argv[i+2]); run_simulation(repos_dir, generation_max); return 0; } } printf("Error: Unexpected arguments\n\n"); printf("%d passed\n",argc); show_help(); return 0; }
static PyObject * pl_run_simulation(PyObject *self, PyObject *args) { PyObject *result = NULL; char *name = NULL; char format[2]; format[0] = StringFormatUnit; format[1] = '\0'; if (PyArg_ParseTuple(args, format, &name)) { run_simulation(name); result = Py_BuildValue("i", 0); } return result; }
int main(int argc, char *argv[]) { Pior1 = createQueue (10); Pior2 = createQueue (10); Pior3 = createQueue (10); Pior4 = createQueue (10); int i = 0; int algorithm = FCFS; int quantum = 1; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-q") == 0) { i++; quantum = atoi(argv[i]); } else if (strcmp(argv[i], "-a") == 0) { i++; if (strcmp(argv[i], "FCFS") == 0) { algorithm = FCFS; } else if (strcmp(argv[i], "PS") == 0) { algorithm = PS; } else if (strcmp(argv[i], "MLFQ") == 0) { algorithm = MLFQ; } else if (strcmp(argv[i], "STRIDE") == 0) { algorithm = STRIDE; } } } read_task_data(); if (num_tasks == 0) { fprintf(stderr,"%s: no tasks for the simulation\n", argv[0]); exit(1); } init_simulation_data(algorithm); run_simulation(algorithm, quantum); compute_and_print_stats(); exit(0); }
util::aligned::vector<float> run_full_test( const std::string& test_name, const wayverb::waveguide::coefficients_canonical& coefficients) const { auto reflected = run_simulation(wall_, {receiver_position_}, coefficients) .front(); const auto window = wayverb::core::right_hanning(reflected.size()); wayverb::core::elementwise_multiply(reflected, window); auto subbed = reflected; std::transform(begin(reflected), end(reflected), free_field_.direct.begin(), subbed.begin(), [](const auto& i, const auto& j) { return j - i; }); write(util::build_string(output_folder_, "/", test_name, "_windowed_free_field.wav") .c_str(), free_field_.image, out_sr, audio_file::format::wav, bit_depth); write(util::build_string( output_folder_, "/", test_name, "_windowed_subbed.wav") .c_str(), subbed, out_sr, audio_file::format::wav, bit_depth); return subbed; }
int main(int argc, char* argv[]) { int num_checkers, break_duration; if(argc != 5) { cerr << "Error: invalid number of command line arguments." << endl; return 1; } ifstream is(argv[3], ios::in); if(!is) { cerr << "Error: could not open input file <" << argv[3] << ">." << endl; return 1; } ofstream os(argv[4], ios::out); if(!os) { cerr << "Error: could not open output file <" << argv[4] << ">." << endl; return 1; } if(!leg_int(argv[1])) { cerr << "Error: invalid number of checkers specified." << endl; return 1; } num_checkers = atoi(argv[1]); if(num_checkers < 0) { cerr << "invalid number of checkers specified." << endl; return 1; } if(!leg_int(argv[2])) { cerr << "Error: invalid checker break duration specified." << endl; return 1; } break_duration = atoi(argv[2]); if(break_duration < 0) { cerr << "Error: invalid checker break duration specified." << endl; return 1; } Pqueue arrival_q; string name, shopper; int arrival, num_items; bool type; while(is >> name) { is >> shopper >> arrival >> num_items; if(shopper == "shopper") type = true; else type = false; arrival_q.enqueue(new Cust(name, arrival, num_items, type), arrival); } run_simulation(arrival_q, num_checkers, break_duration, os); return 0; }
static int manage_package_mode(const std::string &packagename, bool manager, int processor, const CmdArgs &args) { CmdArgs::const_iterator it = args.begin(); CmdArgs::const_iterator end = args.end(); bool stop = false; if (not init_current_package(packagename, args)) return EXIT_FAILURE; for (; not stop and it != end; ++it) { if (*it == "create") { vle::utils::Package::package().create(); } else if (*it == "configure") { vle::utils::Package::package().configure(); vle::utils::Package::package().wait(std::cerr, std::cerr); stop = not vle::utils::Package::package().isSuccess(); } else if (*it == "build") { vle::utils::Package::package().build(); vle::utils::Package::package().wait(std::cerr, std::cerr); if (vle::utils::Package::package().isSuccess()) { vle::utils::Package::package().install(); vle::utils::Package::package().wait(std::cerr, std::cerr); } stop = not vle::utils::Package::package().isSuccess(); } else if (*it == "test") { vle::utils::Package::package().test(); vle::utils::Package::package().wait(std::cerr, std::cerr); stop = not vle::utils::Package::package().isSuccess(); } else if (*it == "install") { vle::utils::Package::package().install(); vle::utils::Package::package().wait(std::cerr, std::cerr); stop = not vle::utils::Package::package().isSuccess(); } else if (*it == "clean") { vle::utils::Package::package().clean(); vle::utils::Package::package().wait(std::cerr, std::cerr); stop = not vle::utils::Package::package().isSuccess(); } else if (*it == "rclean") { vle::utils::Package::removePackageBinary( vle::utils::Package::package().name()); } else if (*it == "package") { vle::utils::Package::package().pack(); vle::utils::Package::package().wait(std::cerr, std::cerr); stop = not vle::utils::Package::package().isSuccess(); } else if (*it == "all") { std::cerr << "all is not yet implemented\n"; stop = true; } else if (*it == "depends") { std::cerr << "Depends is not yet implemented\n"; stop = true; } else if (*it == "list") { show_package_content(); } else { break; } } int ret = EXIT_SUCCESS; if (stop) ret = EXIT_FAILURE; else if (it != end) { #ifndef NDEBUG vle::devs::ExternalEvent::allocated = 0; vle::devs::ExternalEvent::deallocated = 0; vle::devs::InternalEvent::allocated = 0; vle::devs::InternalEvent::deallocated = 0; vle::value::Value::allocated = 0; vle::value::Value::deallocated = 0; #endif if (manager) ret = run_manager(it, end, processor); else ret = run_simulation(it, end); #ifndef NDEBUG std::cerr << vle::fmt(_("\n - Debug mode:\n" " allocated deallocated\n" " - External events: %=12d/%=12d\n" " - Internal events: %=12d/%=12d\n" " - Values : %=12d/%=12d\n")) % vle::devs::ExternalEvent::allocated % vle::devs::ExternalEvent::deallocated % vle::devs::InternalEvent::allocated % vle::devs::InternalEvent::deallocated % vle::value::Value::allocated % vle::value::Value::deallocated; #endif } return ret; }
int main() { printf("# Random Number Generation & Probability Distributions\n\n"); printf("## Random Number Testing\n\n"); autoseed_old_c_rand(); autoseed_aes(); autoseed_von_neumann(); autoseed_mesrene_twister(); for(int i = 1; i <= MAX_TRIES; i ++) { word32 generated_rand_upper[ARRAY_MAX_SIZE], generated_rand_lower[ARRAY_MAX_SIZE], generated_VN[ARRAY_MAX_SIZE], generated_MT[ARRAY_MAX_SIZE], generated_AES[ARRAY_MAX_SIZE]; printf("### Try %d\n\n", i); printf("#### %d generated numbers\n\n", ARRAY_MAX_SIZE); printf("```\n"); printf(CSV_HEADER); for(int j = 0; j < ARRAY_MAX_SIZE; j ++) { int output_rand = autonext_old_c_rand(); generated_rand_upper[j] = (word32) msb(output_rand); generated_rand_lower[j] = (word32) lsb(output_rand); generated_VN[j] = (word32) autonext_von_neumann(); // Von Neumann generated_MT[j] = (word32) autonext_mesrene_twister(); // Mersenne-Twister generated_AES[j] = (word32) autonext_aes(); // AES printf("%u,", generated_rand_upper[j]); printf("%u,", generated_rand_lower[j]); printf("%u,", generated_VN[j]); printf("%u,", generated_MT[j]); printf("%u\n",generated_AES[j]); } printf("```\n\n"); printf("#### Monobit Frequency Test\n\n"); printf(" - Old C Rand 4 MSBs: %f\n", frequency(ARRAY_MAX_SIZE, 4, generated_rand_upper)); printf(" - Old C Rand 4 LSBs: %f\n", frequency(ARRAY_MAX_SIZE, 4, generated_rand_lower)); printf(" - Von Neumann: %f\n", frequency(ARRAY_MAX_SIZE, 4, generated_VN)); printf(" - Mesrene Twister: %f\n", frequency(ARRAY_MAX_SIZE, 4, generated_MT)); printf(" - AES: %f\n\n", frequency(ARRAY_MAX_SIZE, 4, generated_AES)); printf("#### Runs Length Test\n\n"); printf(" - Old C Rand 4 MSBs: %f\n", run_length(ARRAY_MAX_SIZE, 4, generated_rand_upper)); printf(" - Old C Rand 4 LSBs: %f\n", run_length(ARRAY_MAX_SIZE, 4, generated_rand_lower)); printf(" - Von Neumann: %f\n", run_length(ARRAY_MAX_SIZE, 4, generated_VN)); printf(" - Mesrene Twister: %f\n", run_length(ARRAY_MAX_SIZE, 4, generated_MT)); printf(" - AES: %f\n\n", run_length(ARRAY_MAX_SIZE, 4, generated_AES)); } printf("## M/M/1 queue system\n\n"); run_simulation(12, 20, 180); run_simulation(24, 20, 180); return 0; }
int main (int argc, char **argv) { VectorTable *pvt = NULL ; VTL_RESULT vt_load_result = VTL_OK ; int Nix, Nix1, Nix2 ; DESIGN *design = NULL, *working_design = NULL ; simulation_data *sim_data = NULL ; GRand *rnd = NULL ; EXP_ARRAY *ref_hcs = NULL, *out_hcs = NULL ; HONEYCOMB_DATA *hcdRef = NULL, *hcdOut = NULL ; EXP_ARRAY *icSuccesses = NULL ; int icOutputBuses = 0 ; SIMULATION_OUTPUT *sim_output = NULL ; int single_success = 0 ; gboolean bDie = FALSE ; CMDLINE_ARGS cmdline_args = { .bExitOnFailure = FALSE, .bDisplaceInputs = FALSE, .bDisplaceOutputs = FALSE, .number_of_sims = 1, .sim_engine = COHERENCE_VECTOR, .dTolerance = 0.0, .dThreshLower = -0.5, .dThreshUpper = 0.5, .icAverageSamples = 1, .pszFailureFNamePrefix = NULL, .pszSimOptsFName = NULL, .pszReferenceSimOutputFName = NULL, .pszFName = NULL, .pszVTFName = NULL, .circuit_delay = 0, .ignore_from_end = 0, .n_to_displace = -1, .bNormalDisp = FALSE, .dVariance = 1.0, }; preamble (&argc, &argv) ; parse_cmdline (argc, argv, &cmdline_args) ; flush_fprintf (stderr, _("Simulation engine : %s\n" "Simulation options file : %s\n" "Circuit file : %s\n" "Reference simulation output file: %s\n" "number of simulations : %d\n" "uniform distribution ? : %s\n" "tolerance : %lf\n" "variance : %lf\n" "lower polarization threshold : %lf\n" "upper polarization threshold : %lf\n" "samples for running average : %d\n" "exit on failure ? : %s\n" "failure output file name prefix : %s\n" "initial honeycombs to ignore : %d\n" "trailing honeycombs to ignore : %d\n" "displace input cells also? : %d\n" "displace output cells also? : %d\n" "number of cells to displace : %d\n" ), SIM_ENGINE_TO_STRING(cmdline_args.sim_engine), cmdline_args.pszSimOptsFName, cmdline_args.pszFName, cmdline_args.pszReferenceSimOutputFName, cmdline_args.number_of_sims, cmdline_args.bNormalDisp ? "TRUE" : "FALSE", cmdline_args.dTolerance, cmdline_args.dVariance, cmdline_args.dThreshLower, cmdline_args.dThreshUpper, cmdline_args.icAverageSamples, cmdline_args.bExitOnFailure ? "TRUE" : "FALSE", cmdline_args.pszFailureFNamePrefix, cmdline_args.circuit_delay, cmdline_args.ignore_from_end, cmdline_args.bDisplaceInputs ? "TRUE" : "FALSE", cmdline_args.bDisplaceOutputs ? "TRUE" : "FALSE", cmdline_args.n_to_displace) ; #ifdef GTK_GUI gtk_init (&argc, &argv) ; #else g_type_init () ; #endif /* def GTK_GUI */ if (!open_project_file (cmdline_args.pszFName, &design)) { flush_fprintf (stderr, _("Failed to open file \"%s\"!"), cmdline_args.pszFName) ; return 1 ; } else if (NULL == design) { flush_fprintf (stderr, _("Failed to open file \"%s\"!"), cmdline_args.pszFName) ; return 1 ; } if (NULL == (sim_output = open_simulation_output_file (cmdline_args.pszReferenceSimOutputFName))) { flush_fprintf (stderr, _("Failed to open the reference simulation output file !\n")) ; return 3 ; } if (NULL != cmdline_args.pszVTFName) { pvt = VectorTable_new () ; if (NULL != pvt->pszFName) g_free (pvt->pszFName) ; pvt->pszFName = g_strdup (cmdline_args.pszVTFName) ; VectorTable_add_inputs (pvt, design) ; vt_load_result = VectorTable_load (pvt) ; if (VTL_FILE_FAILED == vt_load_result || VTL_MAGIC_FAILED == vt_load_result) { VectorTable_free (pvt) ; pvt = NULL ; } } if (NULL != pvt) { flush_fprintf (stderr, _("Using the following vector table:\n")) ; VectorTable_dump (pvt, stderr, 0) ; } if (BISTABLE == cmdline_args.sim_engine) { bistable_OP *bo = NULL ; if (NULL == (bo = open_bistable_options_file (cmdline_args.pszSimOptsFName))) { flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ; return 4 ; } bistable_options_dump (bo, stderr) ; memcpy (&bistable_options, bo, sizeof (bistable_OP)) ; } else if (COHERENCE_VECTOR == cmdline_args.sim_engine) { coherence_OP *co = NULL ; if (NULL == (co = open_coherence_options_file (cmdline_args.pszSimOptsFName))) { flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ; return 5 ; } coherence_options_dump (co, stderr) ; memcpy (&coherence_options, co, sizeof (coherence_OP)) ; } #ifdef HAVE_FORTRAN else if (SEMI_COHERENT == cmdline_args.sim_engine) { semi_coherent_OP *sco = NULL ; if (NULL == (sco = open_semi_coherent_options_file (cmdline_args.pszSimOptsFName))) { flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ; return 5 ; } semi_coherent_options_dump (sco, stderr) ; memcpy (&semi_coherent_options, sco, sizeof (semi_coherent_OP)) ; } else if (TS_FIELD_CLOCK == cmdline_args.sim_engine) { ts_fc_OP *sco = NULL ; if (NULL == (sco = open_ts_fc_options_file (cmdline_args.pszSimOptsFName))) { flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ; return 5 ; } ts_fc_options_dump (sco, stderr) ; memcpy (&ts_fc_options, sco, sizeof (ts_fc_OP)) ; } #endif /* HAVE_FORTRAN */ printf (_("Running %d %s with a radial tolerance of %lf\n"), cmdline_args.number_of_sims, 1 == cmdline_args.number_of_sims ? _("simulation") : _("simulations"), cmdline_args.dTolerance) ; ref_hcs = create_honeycombs_from_buses (sim_output->sim_data, sim_output->bus_layout, QCAD_CELL_OUTPUT, cmdline_args.dThreshLower, cmdline_args.dThreshUpper, cmdline_args.icAverageSamples) ; rnd = g_rand_new () ; icSuccesses = exp_array_new (sizeof (int), 1) ; for (Nix = 0 ; Nix < design->bus_layout->buses->icUsed ; Nix++) if (QCAD_CELL_OUTPUT == exp_array_index_1d (design->bus_layout->buses, BUS, Nix).bus_function) icOutputBuses++ ; exp_array_1d_insert_vals (icSuccesses, NULL, icOutputBuses, 0) ; for (Nix = 0 ; Nix < icSuccesses->icUsed ; Nix++) exp_array_index_1d (icSuccesses, int, Nix) = 0 ; for (Nix = 0 ; Nix < cmdline_args.number_of_sims && !bDie ; Nix++) { flush_fprintf (stderr, _("Running %s simulation %d of %d\n"), NULL == pvt ? _("exhaustive") : _("vector table"), Nix + 1, cmdline_args.number_of_sims) ; if (NULL != (working_design = design_copy (design))) { VectorTable_fill (pvt, working_design) ; // Gotta re-load VT from the file, because VectorTable_fill destroys the vectors vt_load_result = VectorTable_load (pvt) ; if (VTL_FILE_FAILED == vt_load_result || VTL_MAGIC_FAILED == vt_load_result) { VectorTable_free (pvt) ; pvt = NULL ; } if (cmdline_args.n_to_displace != 0) { if (cmdline_args.bNormalDisp) { randomize_design_cells (rnd, working_design, 0.0, cmdline_args.dTolerance, cmdline_args.bDisplaceInputs, cmdline_args.bDisplaceOutputs, cmdline_args.n_to_displace, cmdline_args.dVariance, TRUE) ; } else { randomize_design_cells (rnd, working_design, 0.0, cmdline_args.dTolerance, cmdline_args.bDisplaceInputs, cmdline_args.bDisplaceOutputs, cmdline_args.n_to_displace, cmdline_args.dVariance, FALSE) ; } } if (NULL != (sim_data = run_simulation (cmdline_args.sim_engine, (NULL == pvt ? EXHAUSTIVE_VERIFICATION : VECTOR_TABLE), working_design, pvt))) { out_hcs = create_honeycombs_from_buses (sim_data, working_design->bus_layout, QCAD_CELL_OUTPUT, cmdline_args.dThreshLower, cmdline_args.dThreshUpper, cmdline_args.icAverageSamples) ; // Print out the results for comparison for (Nix1 = 0 ; Nix1 < out_hcs->icUsed && !bDie ; Nix1++) { if (Nix1 < ref_hcs->icUsed) { hcdRef = exp_array_index_1d (ref_hcs, HONEYCOMB_DATA *, Nix1) ; hcdOut = exp_array_index_1d (out_hcs, HONEYCOMB_DATA *, Nix1) ; flush_fprintf (stderr, _("Reference output bus is: (0x%08x)\"%s\"\n"), (int)hcdRef, hcdRef->bus->pszName) ; for (Nix2 = 0 ; Nix2 < hcdRef->arHCs->icUsed ; Nix2++) flush_fprintf (stderr, "%llu ", exp_array_index_1d (hcdRef->arHCs, HONEYCOMB, Nix2).value) ; flush_fprintf (stderr, "\n") ; flush_fprintf (stderr, _("Output bus is: (0x%08x)\"%s\"\n"), (int)hcdOut, hcdOut->bus->pszName) ; for (Nix2 = 0 ; Nix2 < hcdOut->arHCs->icUsed ; Nix2++) flush_fprintf (stderr, "%llu ", exp_array_index_1d (hcdOut->arHCs, HONEYCOMB, Nix2).value) ; flush_fprintf (stderr, "\n") ; } } // Compare the output honeycombs to the reference honeycombs for (Nix1 = 0 ; Nix1 < out_hcs->icUsed && !bDie ; Nix1++) { if (Nix1 < ref_hcs->icUsed) { hcdRef = exp_array_index_1d (ref_hcs, HONEYCOMB_DATA *, Nix1) ; hcdOut = exp_array_index_1d (out_hcs, HONEYCOMB_DATA *, Nix1) ; single_success = determine_success (hcdRef, hcdOut, cmdline_args.circuit_delay, cmdline_args.ignore_from_end) ; flush_fprintf (stderr, _("This run[%d] bus[%d] was %s\n"), Nix, Nix1, 0 == single_success ? _("unsuccessful") : _("successful")) ; flush_fprintf (stderr, _("hcdOut->arHCs->icUsed equals %d\n"),hcdOut->arHCs->icUsed); } else { flush_fprintf (stderr, _("Output has more buses than reference !\n")) ; single_success = 0 ; } if (0 == single_success && cmdline_args.bExitOnFailure) { if (NULL != cmdline_args.pszFailureFNamePrefix) { char *psz = NULL ; SIMULATION_OUTPUT failed_sim_output = {sim_data, design->bus_layout, FALSE} ; psz = g_strdup_printf ("%s.sim_output", cmdline_args.pszFailureFNamePrefix) ; fprintf (stderr, _("Creating %s to record the failure.\n"), psz) ; create_simulation_output_file (psz, &failed_sim_output) ; g_free (psz) ; psz = g_strdup_printf ("%s.qca", cmdline_args.pszFailureFNamePrefix) ; fprintf (stderr, _("Creating %s to record the failure.\n"), psz) ; create_file (psz, working_design) ; g_free (psz) ; } bDie = TRUE ; } else exp_array_index_1d (icSuccesses, int, Nix1) += single_success ; }