int main(int argc, char* argv[]) { boost::mpi::environment env(argc, argv); boost::mpi::communicator world; int delay; std::string time_fname; namespace po = boost::program_options; po::options_description desc("Allowed options"); desc.add_options() ("help,h", "produce help message") ("delay,d", po::value<int>(&delay)->default_value(10), "delay in function eval to test speedup of parallelisation for objective functions of different computational cost (OF eval time in seconds") ("time,t", po::value<std::string>(&time_fname)->default_value("timer.txt"), "File to write elapsed time for optimiser too"); po::variables_map vm; po::store(po::command_line_parser(argc, argv). options(desc).run(), vm); po::notify(vm); DelayFON eval(delay); std::stringstream timer_info; boost::scoped_ptr<boost::timer::auto_cpu_timer> t((boost::timer::auto_cpu_timer *) nullptr); if (world.rank() == 0) { std::ofstream ofs(time_fname.c_str()); if (ofs.is_open()) { t.reset(new boost::timer::auto_cpu_timer(timer_info, 3)); } else { std::cerr << "Error: Could not open file for writing time elapsed for search, using std::cout"; t.reset(new boost::timer::auto_cpu_timer(3)); } //create evaluator server ParallelEvaluatePopServer eval_server(env, world, eval.getProblemDefinitions()); // The random number generator typedef std::mt19937 RNG; unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); RNG rng(seed); // The optimiser int max_gen = 10; NSGAII<RNG> optimiser(rng, eval_server); MaxGenCheckpoint max_gen_stop(max_gen); optimiser.add_checkpoint(max_gen_stop); // optimiser.visualise(); // Initialise population int pop_size = 128 ; PopulationSPtr pop = intialisePopulationRandomDVAssignment(pop_size, eval.getProblemDefinitions(), rng); // Run the optimisation optimiser(pop); t.reset((boost::timer::auto_cpu_timer *) nullptr); if (ofs.is_open()) { ofs << timer_info.str(); ofs.close(); } std::cout << timer_info.str() << std::endl; } else { // create evaluator client ParallelEvaluatePopClient eval_client(env, world, eval.getProblemDefinitions(), eval); eval_client(); } }
int main(int argc, char * argv[]) { boost::mpi::environment env(argc, argv); boost::mpi::communicator world; MetronamicaOF2Parameters params; int err = processOptions(argc, argv, params); if (err != 0) { return EXIT_SUCCESS; } // std::vector<double> real_lowerbounds = {500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, 500, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, -100, -1000, 0.05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // std::vector<double> real_upperbounds = {5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 5000, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 100, 1000, 5, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; // int num_classes = 16; params.evaluator_id = world.rank(); MetronamicaCalibrationObjectiveFunction metro_eval(params); if (world.rank() == 0) { // std::ofstream ofs(time_fname.c_str()); // if (ofs.is_open()) // { // t.reset(new boost::timer::auto_cpu_timer(timer_info, 3)); // } // else // { // std::cerr << "Error: Could not open file for writing time elapsed for search, using std::cout"; // t.reset(new boost::timer::auto_cpu_timer(3)); // } //create evaluator server boost::filesystem::path eval_log = params.save_dir.second / "evaluation_timing.log"; std::ofstream eval_strm(eval_log.c_str()); ParallelEvaluatePopServerNonBlocking eval_server(env, world, metro_eval.getProblemDefinitions()); if (eval_strm.is_open()) { eval_server.log(ParallelEvaluatorBase::LVL1, eval_strm); } // The random number generator typedef std::mt19937 RNG; if (params.search_rand_seed == -1) params.search_rand_seed = std::chrono::system_clock::now().time_since_epoch().count(); RNG rng(params.search_rand_seed); // The optimiser NSGAII<RNG> optimiser(rng, eval_server); if (eval_strm.is_open()) { optimiser.log(eval_strm, eval_log, NSGAII<RNG>::LVL1 ); } std::vector<double> ref_point = {-0.1, 1, -0.1}; std::vector<double> unitise_point = {1,0, 1}; createCheckpoints(optimiser, params, ref_point, unitise_point); // Initialise population PopulationSPtr pop(new Population); if (params.pop_file_xml.first != "none") { pop = restore_population(params.pop_file_xml.second); } else if (params.pop_file_txt.first != "none") { pop.reset(new Population(params.pop_file_txt.second, metro_eval.getProblemDefinitions())); } else { pop = intialisePopulationRandomDVAssignment(params.pop_size, metro_eval.getProblemDefinitions(), rng); } optimiser.getRealMutationOperator().setMutationInverseDVSize(pop->at(0)); // hvol(pop); // std::cout << "Hypervolume: " << hvol.getVal() << std::endl; // Run the optimisation optimiser(pop); postProcessResults(metro_eval, pop, params); } else { std::string log_file_name = "worker_" + std::to_string(world.rank()) + "_timing.log"; boost::filesystem::path eval_log = params.save_dir.second / log_file_name; std::ofstream eval_strm(eval_log.c_str()); ParallelEvaluatePopClientNonBlocking eval_client(env, world, metro_eval.getProblemDefinitions(), metro_eval); if (eval_strm.is_open()) { eval_client.log(ParallelEvaluatorBase::LVL1, eval_strm); } //logging eval_client // std::string log_filename = "evaluation_timing_worker" + std::to_string(world.rank()) + ".log"; // boost::filesystem::path eval_log = working_dir.second / log_filename; // std::ofstream eval_strm(eval_log.c_str()); // if (eval_strm.is_open()) // { // eval_client.log(ParallelEvaluatorBase::LVL1, eval_strm); // } eval_client(); } }
int main(void) { //std::cout << "Generating a time series on device "<< tim.get_nsamps() << std::endl; //DeviceTimeSeries<float> d_tim(8388608); //d_tim.set_tsamp(0.000064); TimeSeries<float> tim; tim.from_file("/lustre/home/ebarr/Soft/peasoup/tmp5.tim"); DeviceTimeSeries<float> d_tim(tim); unsigned int size = d_tim.get_nsamps(); TimeSeriesFolder folder(size); //DeviceTimeSeries<float> d_tim_r(fft_size); //<----for resampled data //TimeDomainResampler resampler; float* folded_buffer; cudaError_t error; cufftResult result; error = cudaMalloc((void**)&folded_buffer, sizeof(float)*size); ErrorChecker::check_cuda_error(error); unsigned nints = 64; unsigned nbins = 32; cufftComplex* fft_out; error = cudaMalloc((void**)&fft_out, sizeof(cufftComplex)*nints*nbins); cufftHandle plan; result = cufftPlan1d(&plan,nbins,CUFFT_R2C, nints); ErrorChecker::check_cufft_error(result); Stopwatch timer; FoldedSubints<float> folded_array(nbins,nints); //folder.fold(d_tim,folded_array,0.007453079228); std::cout << "made it here" << std::endl; FoldOptimiser optimiser(nbins,nints); timer.start(); for (int ii=0;ii<1;ii++){ //FoldedSubints<float> folded_array(nbins,nints); folder.fold(d_tim,folded_array,0.007453099228); Utils::dump_device_buffer<float>(folded_array.get_data(),nints*nbins,"original_fold.bin"); optimiser.optimise(folded_array); } timer.stop(); /* float* temp = new float [nints*nbins]; cudaMemcpy(temp,folded_buffer,nints*nbins*sizeof(float),cudaMemcpyDeviceToHost); ErrorChecker::check_cuda_error(); for (int ii=0;ii<nints*nbins;ii++) std::cout << temp[ii] << std::endl; */ std::cout << "Total execution time (s): " << timer.getTime()<<std::endl; std::cout << "Average execution time (s): " << timer.getTime()/1000.0 << std::endl; return 0; }
int main(int argc, char *argv[]) { // rmsPropTest(); if (argc < 3) { cout << "usage rnnsynth [config_options] config_file" << endl; cout << "config_options syntax: --<variable_name>=<variable_value>" << endl; cout << "whitespace not allowed in variable names or values" << endl; cout << "all config_file variables overwritten by config_options" << endl; cout << "setting <variable_value> = \"\" removes the variable from the " "config" << endl; cout << "repeated variables overwritten by last specified" << endl; exit(0); } ConfigFile conf(argv[argc - 2]); ConfigFile conf_1(argv[argc - 1]); bool autosave = false; string configFilename; #ifdef FAST_LOGISTIC Logistic::fill_lookup(); #endif string task = conf.get<string>("task"); CHECK_STRICT(task == "prediction", "must have prediction task"); if (task == "prediction" && conf.get<int>("predictionSteps", 1) == 1) { task = conf.set_val<string>("task", "window-prediction"); } verbose = true; ostream &out = cout; string dataset = conf.get<string>("dataset", "train"); check(in(validDatasets, dataset), dataset + " given as 'dataset' parameter in config file '" + configFilename + "'\nmust be one of '" + str(validDatasets) + "'"); string dataFileString = dataset + "File"; vector<string> dataFiles = conf.get_list<string>(dataFileString); int dataFileNum = conf.get<int>("dataFileNum", 0); check(dataFiles.size() > dataFileNum, "no " + ordinal(dataFileNum) + " file in size " + str(dataFiles.size()) + " file list " + dataFileString + " in " + configFilename); string datafile = dataFiles[dataFileNum]; DataHeader header(datafile, task, 1); PRINT(task, out); std::unique_ptr<Mdrnn> net; net.reset(new VerticalNet(out, conf, header)); // build weight container after net is created WeightContainer &wc = WeightContainer::instance(); wc.build(); Rmsprop optimiser("weight_optimiser", out, wc.weights, wc.derivatives); int numWeights = WeightContainer::instance().weights.size(); out << "loading dynamic data from " << conf.filename << endl; out << "number of weights to load " << numWeights << endl; DataExportHandler::instance().load(conf, out); Vector<real_t> weights = wc.weights; Vector<real_t> derivatives = wc.derivatives; Vector<real_t> deltas = optimiser.deltas; Vector<real_t> n = optimiser.n; Vector<real_t> g = optimiser.g; out << "loading dynamic data from " << conf_1.filename << endl; DataExportHandler::instance().load(conf_1, out); addVectors(wc.weights, weights); addVectors(wc.derivatives, derivatives); addVectors(optimiser.deltas, deltas); addVectors(optimiser.n, n); addVectors(optimiser.g, g); const std::string filename("agg.save"); ofstream fout(filename.c_str()); if (fout.is_open()) { out << "saving to " << filename << endl; fout << DataExportHandler::instance(); } else { out << "WARNING unable to save to file " << filename << endl; } return 0; }
int main(int argc, char* argv[]) { boost::filesystem::path working_dir = boost::filesystem::initial_path(); boost::mpi::environment env(argc, argv); boost::mpi::communicator world; MinMaxFON test_problem; if (world.rank() == 0) { //create evaluator server //create evaluator server std::string eval_log_fname("mpi_msgs.txt"); std::ofstream eval_strm(eval_log_fname.c_str()); ParallelEvaluatePopServerNonBlocking eval_server(env, world, test_problem.getProblemDefinitions()); if (eval_strm.is_open()) { eval_server.log(ParallelEvaluatorBase::LVL1, eval_strm); } std::stringstream timer_info; boost::scoped_ptr<boost::timer::auto_cpu_timer> t((boost::timer::auto_cpu_timer *) nullptr); std::string time_fname("run_time_fon.txt"); std::ofstream ofs(time_fname.c_str()); if (ofs.is_open()) { t.reset(new boost::timer::auto_cpu_timer(timer_info, 3)); } else { std::cerr << "Error: Could not open file for writing time elapsed for search, using std::cout"; t.reset(new boost::timer::auto_cpu_timer(3)); } // The random number generator typedef std::mt19937 RNG; unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); RNG rng(seed); // The optimiser int max_gen = 100; NSGAII<RNG> optimiser(rng, eval_server); MaxGenCheckpoint max_gen_terminate(max_gen); // SavePopCheckpoint save_pop(1, working_dir); std::vector<double> ref_point = {1, -1}; Hypervolume hvol(ref_point, working_dir, 1, Hypervolume::TERMINATION, 50); // hvol.log(); std::string mail_subj("Hypervolume of front from FON optimiser "); // MailCheckpoint mail(10, hvol, mail_subj); // std::string my_address("*****@*****.**"); // mail.addAddress(my_address); MetricLinePlot hvol_plot(hvol); PlotFrontVTK plotfront; // ResetMutXvrDebugFlags reset_flags; // SerialiseCheckpoint<NSGAII<RNG> > save_state(1, optimiser, working_dir); optimiser.add_checkpoint(max_gen_terminate); // optimiser.add_checkpoint(save_state); // optimiser.add_checkpoint(save_pop); optimiser.add_checkpoint(hvol); optimiser.add_checkpoint(hvol_plot); optimiser.add_checkpoint(plotfront); // optimiser.add_checkpoint(mail); // optimiser.add_checkpoint(reset_flags); // optimiser.visualise(); // Initialise population int pop_size = 1000; PopulationSPtr pop = intialisePopulationRandomDVAssignment(pop_size, test_problem.getProblemDefinitions(), rng); optimiser.getRealMutationOperator().setMutationInverseDVSize(pop->at(0)); // Run the optimisation optimiser(pop); t.reset((boost::timer::auto_cpu_timer *) nullptr); if (ofs.is_open()) { ofs << timer_info.str(); ofs.close(); } std::cout << timer_info.str() << std::endl; } else { // create evaluator client ParallelEvaluatePopClientNonBlocking eval_client(env, world, test_problem.getProblemDefinitions(), test_problem); //logging eval_client std::string log_filename = "evaluation_timing_worker" + std::to_string(world.rank()) + ".log"; std::ofstream eval_strm(log_filename.c_str()); if (eval_strm.is_open()) { eval_client.log(ParallelEvaluatorBase::LVL1, eval_strm); } eval_client(); } return EXIT_SUCCESS; }