int main (int argc, char ** argv){ if (argc < 2){ std::cerr << "Usage:" << argv[0] << " input_bin_file" << std::endl; exit(1); } Kokkos::initialize(argc, argv); MyExecSpace::print_configuration(std::cout); idx nv = 0, ne = 0; idx *xadj, *adj, *half_srcs, *half_dsts; wt *ew; Experimental::KokkosKernels::Graph::Utils::read_graph_bin<idx, wt> (&nv, &ne, &xadj, &adj, &ew, argv[1]); Experimental::KokkosKernels::Graph::Utils::md_malloc<idx>(&half_srcs, ne/2); Experimental::KokkosKernels::Graph::Utils::md_malloc<idx>(&half_dsts, ne/2); Experimental::KokkosKernels::Graph::Utils::convert_crs_to_lower_triangle_edge_list<idx>(nv, xadj, adj, half_srcs, half_dsts); std::cout << "nv:" << nv << " ne:" << ne << std::endl; um_array_type _xadj (xadj, nv + 1); um_edge_array_type _adj (adj, ne); um_edge_array_type _half_srcs (half_srcs, ne/2); um_edge_array_type _half_dests (half_dsts, ne/2); idx_array_type kok_xadj ("xadj", nv + 1); idx_edge_array_type kok_adj("adj", ne); Kokkos::deep_copy (kok_xadj, _xadj); Kokkos::deep_copy (kok_adj, _adj); idx_edge_array_type kok_half_srcs("adj", ne/2), kok_half_dsts("adj", ne/2); Kokkos::deep_copy (kok_half_srcs, _half_srcs); Kokkos::deep_copy (kok_half_dsts, _half_dests); wt_um_edge_array_type _mtx_vals (ew, ne); value_array_type kok_mtx_vals ("MTX_VALS", ne); Kokkos::deep_copy (kok_mtx_vals, _mtx_vals); delete [] xadj; delete [] adj; delete [] half_srcs; delete [] half_dsts; delete [] ew; //fill_experiments(nv, ne, kok_xadj, kok_adj, kok_half_srcs, kok_half_dsts); run_experiment(REPEAT, nv, ne, kok_xadj, kok_adj, kok_mtx_vals); //free_experiments(); Kokkos::finalize(); return 0; }
static void shmc_start(struct bench_binding *b) { run_experiment(); errval_t err; err = b->tx_vtbl.shmc_done(b, NOP_CONT); if (err_is_fail(err)) { USER_PANIC_ERR(err, "sending shmc_done failed"); } }
int main(){ unsigned long max_offset; unsigned long buffer_size=1; int fd = open("10GigFile",O_RDONLY|O_LARGEFILE); if(fd == -1) { perror("file could not be opened for reading\n"); exit(1); } char* buffer; flushcache(); max_offset = (10240*1024/buffer_size)-1; buffer = (char*) malloc(buffer_size*1024); run_experiment(fd,buffer,buffer_size*1024,max_offset); free(buffer); flushcache(); srand(time(NULL)%INT_MAX); }
static void start_experiment(void) { errval_t err; for (int i = 1; i < num_cores; i++) { int count = 0; experiment_flag = false; experiment_count = i; for (int j = 0; j < MAX_CPUS; j++) { if (array[j]) { while(1) { err = array[j]->tx_vtbl.shmc_start(array[j], NOP_CONT); if (err_is_ok(err)) { break; } else if (err_no(err) == FLOUNDER_ERR_TX_BUSY) { messages_wait_and_handle_next(); } else { USER_PANIC_ERR(err, "sending shmc_start failed"); } } count++; if (count == i) { break; } } } run_experiment(); printf("Running on %d cores\n", i + 1); for (int j = 0; j < MAX_COUNT; j++) { printf("page %d took %"PRIuCYCLES"\n", j, timestamps[j].time1 - timestamps[j].time0 - bench_tscoverhead()); } while(!experiment_flag) { messages_wait_and_handle_next(); } } printf("client done\n"); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->actionBackground, SIGNAL(triggered()), this, SLOT(background_file_open())); connect(ui->actionClosed_Aperature, SIGNAL(triggered()), this, SLOT(closedapp_file_open())); connect(ui->actionImage_Stack, SIGNAL(triggered()), this, SLOT(imagelist_file_open())); connect(ui->actionRun_Experiment, SIGNAL(triggered()), this, SLOT(run_experiment())); set_background = false; set_closed = false; set_image_list = false; ui->actionClosed_Aperature->setDisabled(true); ui->actionImage_Stack->setDisabled(true); ui->actionRun_Experiment->setDisabled(true); ui->actionShow_Graph->setDisabled(true); frapmodel = new FrapModel(0); connect(this,SIGNAL(primaset(QString)),frapmodel,SLOT(setPrima(QString))); connect(this,SIGNAL(closedset(QString)),frapmodel,SLOT(setClosed(QString))); connect(this,SIGNAL(doselection()),frapmodel,SLOT(doSelection())); connect(this,SIGNAL(imagelistset(QStringList)),frapmodel,SLOT(setImageList(QStringList))); connect(ui->actionShow_Graph, SIGNAL(triggered()),frapmodel, SLOT(prepareLinearFit())); //connect(frapmodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->tableView,SLOT(dataChanged(QModelIndex,QModelIndex))); connect(frapmodel,SIGNAL(update_result(QString)), this, SLOT(show_result(QString))); connect(frapmodel,SIGNAL(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)), ui->pl_widget, SLOT(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double))); ui->tabWidget->setCurrentIndex(0); starting_dir = "/home/jon/Programming/C/frap-tool-old"; }
int main(int argc, char** argv) { if (argc > 1) { printf("Arg 0: %s\n", argv[0]); ull testsize = atoll(argv[1]); printf("Arg 1: %llu\n", testsize); time_t t0 = time(NULL); for (int i = 0; i < 1000; i++) { run_experiment(testsize); } time_t t1 = time(NULL); double time_delta = difftime(t1, t0); printf("Time Delta: %.2lf\n", time_delta); } else { test1(); } return 0; }
double operator()() { return run_experiment(experiment, generator, n); }
/** * \brief Run a competition experiment with repetitions * \details -- * \param Prng* prng * \param Parameters* parameters * \param Population* evolved_population * \param size_t REPS * \param double Lprop * \return \e void */ void run_competition_experiment( Prng* prng, Parameters* parameters, Population* evolved_population, size_t REPS, double L_prop ) { std::cout << "Running competition experiment with initial S frequency of " << 1-L_prop << " ...\n"; double* A_0 = new double[REPS]; double* A_05 = new double[REPS]; double* A_1 = new double[REPS]; double* A_2 = new double[REPS]; double* A_4 = new double[REPS]; double* B_0 = new double[REPS]; double* B_05 = new double[REPS]; double* B_1 = new double[REPS]; double* B_2 = new double[REPS]; double* B_4 = new double[REPS]; size_t* A_extinction = new size_t[REPS]; size_t* B_extinction = new size_t[REPS]; size_t** nb_1 = new size_t*[REPS]; size_t** nb_2 = new size_t*[REPS]; size_t rep = 0; while (rep < REPS) { std::cout << "> Rep " << rep << " ...\n"; Simulation* simulation = NULL; double initial_n_1 = 0.0; double initial_n_2 = 0.0; nb_1[rep] = new size_t[4*333]; nb_2[rep] = new size_t[4*333]; for (size_t i = 0; i < 4*333; ++i) { nb_1[rep][i] = 0; nb_2[rep][i] = 0; } simulation = create_experiment(parameters, evolved_population, (unsigned long int)prng->uniform(1, 10000000), false, L_prop, initial_n_1, initial_n_2); A_0[rep] = initial_n_1; B_0[rep] = initial_n_2; A_05[rep] = A_1[rep] = A_2[rep] = A_4[rep] = B_05[rep] = B_1[rep] = B_2[rep] = B_4[rep] = 0.0; A_extinction[rep] = B_extinction[rep] = 0; bool extinct = false; /*********************/ /* First half saison */ /*********************/ std::cout << "> to time 167 ...\n"; extinct = run_experiment(simulation, 167, nb_1[rep], nb_2[rep]); assert(simulation->get_population()->get_time() == 167); if (!extinct) { A_05[rep] = (double)simulation->get_trophic_network()->get_nb_level_0_cells()+(double)simulation->get_trophic_network()->get_nb_level_1_cells(); B_05[rep] = (double)simulation->get_trophic_network()->get_nb_level_2_cells()+(double)simulation->get_trophic_network()->get_nb_no_level_cells(); } /**********************/ /* Second half saison */ /**********************/ std::cout << "> to time 333 ...\n"; if (!extinct) { extinct = run_experiment(simulation, 166, nb_1[rep], nb_2[rep]); assert(simulation->get_population()->get_time() == 333); if (!extinct) { A_1[rep] = (double)simulation->get_trophic_network()->get_nb_level_0_cells()+(double)simulation->get_trophic_network()->get_nb_level_1_cells(); B_1[rep] = (double)simulation->get_trophic_network()->get_nb_level_2_cells()+(double)simulation->get_trophic_network()->get_nb_no_level_cells(); } } /*****************/ /* Second saison */ /*****************/ std::cout << "> to time 666 ...\n"; if (!extinct) { extinct = run_experiment(simulation, 333, nb_1[rep], nb_2[rep]); assert(simulation->get_population()->get_time() == 666); if (!extinct) { A_2[rep] = (double)simulation->get_trophic_network()->get_nb_level_0_cells()+(double)simulation->get_trophic_network()->get_nb_level_1_cells(); B_2[rep] = (double)simulation->get_trophic_network()->get_nb_level_2_cells()+(double)simulation->get_trophic_network()->get_nb_no_level_cells(); } } /*****************/ /* Fourth saison */ /*****************/ std::cout << "> to time 1332 ...\n"; if (!extinct) { extinct = run_experiment(simulation, 666, nb_1[rep], nb_2[rep]); assert(simulation->get_population()->get_time() == 1332); if (!extinct) { A_4[rep] = (double)simulation->get_trophic_network()->get_nb_level_0_cells()+(double)simulation->get_trophic_network()->get_nb_level_1_cells(); B_4[rep] = (double)simulation->get_trophic_network()->get_nb_level_2_cells()+(double)simulation->get_trophic_network()->get_nb_no_level_cells(); } } /********************/ /* Extinction dates */ /********************/ if (extinct) { bool A_extinct = false; bool B_extinct = false; for (size_t i = 0; i < 4*333; ++i) { if (!A_extinct && nb_1[rep][i] == 0) { A_extinction[rep] = i+1; A_extinct = true; } if (!B_extinct && nb_2[rep][i] == 0) { B_extinction[rep] = i+1; B_extinct = true; } } } delete simulation; simulation = NULL; rep++; } std::stringstream filename; filename << "./frequency_dependent_fitness_" << (1-L_prop) << ".txt"; std::ofstream results(filename.str().c_str(), std::ios::out | std::ios::trunc); results << "rep A0 A05 A1 A2 A4 B0 B05 B1 B2 b4 Aext Bext\n"; for (size_t rep = 0; rep < REPS; rep++) { results << rep+1 << " " << A_0[rep] << " " << A_05[rep] << " " << A_1[rep] << " " << A_2[rep] << " " << A_4[rep] << " " << B_0[rep] << " " << B_05[rep] << " " << B_1[rep] << " " << B_2[rep] << " " << B_4[rep] << " " << A_extinction[rep] << " " << B_extinction[rep] << "\n"; } results.close(); double* mean_nb_1 = new double[4*333]; double* mean_nb_2 = new double[4*333]; double* var_nb_1 = new double[4*333]; double* var_nb_2 = new double[4*333]; for (size_t t = 0; t < 4*333; ++t) { mean_nb_1[t] = 0.0; mean_nb_2[t] = 0.0; var_nb_1[t] = 0.0; var_nb_2[t] = 0.0; for (size_t rep = 0; rep < REPS; ++rep) { mean_nb_1[t] += nb_1[rep][t]; mean_nb_2[t] += nb_2[rep][t]; var_nb_1[t] += nb_1[rep][t]*nb_1[rep][t]; var_nb_2[t] += nb_2[rep][t]*nb_2[rep][t]; } } for (size_t t = 0; t < 4*333; ++t) { mean_nb_1[t] /= REPS; mean_nb_2[t] /= REPS; var_nb_1[t] /= REPS; var_nb_2[t] /= REPS; var_nb_1[t] -= mean_nb_1[t]*mean_nb_1[t]; var_nb_2[t] -= mean_nb_2[t]*mean_nb_2[t]; } filename.str(""); filename << "./ecotypes_evolution_" << (1-L_prop) << ".txt"; results.open(filename.str().c_str(), std::ios::out | std::ios::trunc); results << "t mean1 mean2 var1 var2\n"; for (size_t t = 0; t < 4*333; ++t) { results << t+1 << " " << mean_nb_1[t] << " " << mean_nb_2[t] << " " << var_nb_1[t] << " " << var_nb_2[t] << "\n"; } results.close(); delete[] A_0; A_0 = NULL; delete[] A_05; A_05 = NULL; delete[] A_1; A_1 = NULL; delete[] A_2; A_2 = NULL; delete[] A_4; A_4 = NULL; delete[] B_0; B_0 = NULL; delete[] B_05; B_05 = NULL; delete[] B_1; B_1 = NULL; delete[] B_2; B_2 = NULL; delete[] B_4; B_4 = NULL; delete[] A_extinction; A_extinction = NULL; delete[] B_extinction; B_extinction = NULL; for (size_t rep = 0; rep < REPS; ++rep) { delete[] nb_1[rep]; nb_1[rep] = NULL; delete[] nb_2[rep]; nb_2[rep] = NULL; } delete nb_1; nb_1 = NULL; delete nb_2; nb_2 = NULL; }