void test_my_glog() { std::cout << "----test my glog begin--------------" << std::endl; // google::InitGoogleLogging(argv[0]); // google::ParseCommandLineFlags(&argc, &argv, true); // FLAGS_log_dir = "./log"; // FLAGS_logtostderr=1; // FLAGS_colorlogtostderr=true; LOG(INFO)<< "info: hello world!"; LOG(WARNING)<< "warning: hello world!"; LOG(ERROR)<< "error: hello world!"; // LOG(FATAL) << "fatal: hello world!"; VLOG(0) << "vlog0: hello world!"; VLOG(1) << "vlog1: hello world!"; VLOG(2) << "vlog2: hello world!"; VLOG(3) << "vlog3: hello world!"; DLOG(INFO)<< "DLOG: hello world!"; for (int i = 1; i <= 100; i++) { LOG_IF(INFO, i ==100) << "LOG_IF(INFO,i==100) google::COUNTER=" << google::COUNTER << " i=" << i; LOG_EVERY_N(INFO, 10) << "LOG_EVERY_N(INFO,10) google::COUNTER=" << google::COUNTER << " i=" << i; LOG_IF_EVERY_N(WARNING, (i > 50), 10) << "LOG_IF_EVERY_N(INFO,(i>50),10) google::COUNTER=" << google::COUNTER << " i=" << i; LOG_FIRST_N(ERROR, 5) << "LOG_FIRST_N(INFO,5) google::COUNTER=" << google::COUNTER << " i=" << i; } // CHECK_NE(2, 2) << ": The world must be ending!"; // google::ShutDownCommandLineFlags(); // google::ShutdownGoogleLogging(); std::cout << "---------------------test my glog end---------------------" << std::endl; }
_INITIALIZE_EASYLOGGINGPP int main(int argc, char** argv) { _START_EASYLOGGINGPP(argc, argv); for (int i = 1;i < 1000; ++i) { LOG_EVERY_N(20, INFO) << "LOG_EVERY_N i = " << i; LOG_EVERY_N(100, INFO) << "LOG_EVERY_N Current position is " << ELPP_COUNTER_POS; } for (int i = 1;i <= 10; ++i) { LOG_AFTER_N(6, INFO) << "LOG_AFTER_N i = " << i; } for (int i = 1;i < 100; ++i) { LOG_N_TIMES(50, INFO) << "LOG_N_TIMES i = " << i; } return 0; }
bool BeringeiConfigurationLoader::isValidConfiguration( const ConfigurationInfo& configuration) const { if (configuration.shardCount <= 0) { return logInvalidAndReturn("Shard Count must be greater than 0"); } if (!configuration.serviceMap.size()) { return logInvalidAndReturn("No Beringei services in configuration"); } for (auto& service : configuration.serviceMap) { if (service.serviceName.empty()) { return logInvalidAndReturn("ServiceName cannot be empty"); } if (service.location.empty()) { return logInvalidAndReturn("Location cannot be empty"); } if (service.shardMap.size() != configuration.shardCount) { // not an error. Just warning and continue LOG(WARNING) << "Shard Map does not match the shard count." << " Some shards are owned."; } bool shardList[configuration.shardCount]; for (auto& shard : shardList) { shard = false; } for (auto& shard : service.shardMap) { if (shard.port <= 0) { return logInvalidAndReturn("Port # has to be greater than 0"); } if (shard.hostAddress.empty()) { return logInvalidAndReturn("HostAddress cannot be empty"); } if (shard.shardId < 0 || shard.shardId >= configuration.shardCount) { return logInvalidAndReturn("Invalid Shard Id"); } if (shardList[shard.shardId]) { return logInvalidAndReturn( folly::format( "Shard Map contains conflicting shard information for shard {0}", shard.shardId) .str()); } shardList[shard.shardId] = true; } } LOG_EVERY_N(INFO, 5000) << "Beringei Configuration is Valid"; return true; }
void *write(void* thrId){ char* threadId = (char*)thrId; // Following line will be logged with every thread LOG(INFO) << "This standard log is written by [Thread #" << threadId << "]"; // Following line will be logged with every thread only when --v=2 argument // is provided, i.e, ./bin/multithread_test.cpp.bin --v=2 VLOG(2) << "This is verbose level 2 logging from [Thread #" << threadId << "]"; // Following line will be logged only once from second running thread (which every runs second into // this line because of interval 2) LOG_EVERY_N(2, WARNING) << "This will be logged only once from thread who every reaches this line first. Currently running from [Thread #" << threadId << "]"; for (int i = 1; i <= 10; ++i) { VLOG_IF(true, 2) << "Verbose condition [Thread #" << threadId << "]"; VLOG_EVERY_N(2, 3) << "Verbose level 3 log every 4th time. This is at " << i << " from [Thread #" << threadId << "]"; } // Following line will be logged once with every thread because of interval 1 LOG_EVERY_N(1, INFO) << "This interval log will be logged with every thread, this one is from [Thread #" << threadId << "]"; LOG_IF(strcmp(threadId, "2") == 0, INFO) << "This log is only for thread 2 and is ran by [Thread #" << threadId << "]"; // Register 5 vague loggers for (int i = 1; i <= 5; ++i) { std::stringstream ss; ss << "logger" << i; el::Logger* logger = el::Loggers::getLogger(ss.str()); LOG(INFO) << "Registered logger [" << *logger << "] [Thread #" << threadId << "]"; CLOG(INFO, "default", "network") << "Triggering network log from default and network"; } CLOG(INFO, "logger1") << "Logging using new logger [Thread #" << threadId << "]"; CLOG(INFO, "no-logger") << "THIS SHOULD SAY LOGGER NOT REGISTERED YET [Thread #" << threadId << "]"; // << -- NOTE THIS! CLOG(INFO, "default", "network") << "Triggering network log from default and network"; el::Logger* logger = el::Loggers::getLogger("default"); logger->info("Info log from [Thread #%v]", threadId); // Check for log counters positions for (int i = 1; i <= 50; ++i) { LOG_EVERY_N(2, INFO) << "Counter pos: " << ELPP_COUNTER_POS << " [Thread #" << threadId << "]"; } LOG_EVERY_N(2, INFO) << "Counter pos: " << ELPP_COUNTER_POS << " [Thread #" << threadId << "]"; return NULL; }
T BlockingQueue<T>::pop(const string& log_waiting_msg){ boost::mutex::scoped_lock lock(sync->mutex); while (Q.empty()){ if (!log_waiting_msg.empty()){ LOG_EVERY_N(INFO, 1000) << log_waiting_msg; } sync->condition.wait(lock); //suspend, spare CPU clock } T t = Q.front(); Q.pop(); return t; }
T BlockingQueue<T>::pop(const string& log_on_wait) { boost::mutex::scoped_lock lock(sync_->mutex_); while (queue_.empty()) { if (!log_on_wait.empty()) { LOG_EVERY_N(INFO, 1000)<< log_on_wait; } sync_->condition_.wait(lock); } T t = queue_.front(); queue_.pop(); return t; }
INITIALIZE_EASYLOGGINGPP int main(int argc, char** argv) { START_EASYLOGGINGPP(argc, argv); el::Loggers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog); el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput); // You can uncomment following lines to take advantage of hierarchical logging // el::Loggers::addFlag(el::LoggingFlag::HierarchicalLogging); // el::Loggers::setLoggingLevel(el::Level::Global); LOG(INFO); LOG(DEBUG); LOG(WARNING); LOG(ERROR); LOG(TRACE); VLOG(1); LOG(FATAL); DLOG(INFO); DLOG(DEBUG); DLOG(WARNING); DLOG(ERROR); DLOG(TRACE); DVLOG(1); DLOG(FATAL); LOG(INFO) << "Turning off colored output"; el::Loggers::removeFlag(el::LoggingFlag::ColoredTerminalOutput); LOG_IF(true, INFO); LOG_IF(true, DEBUG); LOG_IF(true, WARNING); LOG_IF(true, ERROR); LOG_IF(true, TRACE); VLOG_IF(true, 1); LOG_IF(true, FATAL); LOG_EVERY_N(1, INFO); LOG_EVERY_N(1, DEBUG); LOG_EVERY_N(1, WARNING); LOG_EVERY_N(1, ERROR); LOG_EVERY_N(1, TRACE); VLOG_EVERY_N(1, 1); LOG_EVERY_N(1, FATAL); CHECK(1 == 1); CCHECK(1 == 1, "default"); return 0; }
int GBDT::fit() { int samples = _m_train_data.size(); if (_m_sample_ratio < 1) { samples = samples * _m_sample_ratio; } init_fit(); for (int iter = 0; iter < _m_iterations; iter++) { LOG_EVERY_N(INFO, 10) << "iteration: " << iter; if (_m_sample_ratio < 1) { _m_train_data.random(); } if (_m_thread_num > 1 && iter > 100) { for (int i = 0; i < _m_thread_num; i++) { _m_multi_data[i].max_tree_num = iter; pthread_create(&_m_multi_thread[i], NULL, multi_predict, (void*)(&_m_multi_data[i])); } for (int i = 0; i < _m_thread_num; i++) { pthread_join(_m_multi_thread[i], NULL); } } else { for (int s_idx = 0; s_idx < samples; s_idx++) { GBDTValue p; predict(_m_train_data[s_idx], iter, p); update_target(s_idx, p); } } _m_trees[iter].fit(&_m_train_data, samples); if ((iter + 1) % _m_save_tmp == 0) { LOG(INFO) << iter << " " << _m_save_tmp; save_tmp(iter + 1); } } _m_cur_iterations = _m_iterations; cal_gain(); return 0; }
_INITIALIZE_EASYLOGGINGPP int main(int argc, char** argv) { _START_EASYLOGGINGPP(argc, argv); el::Helpers::addFlag(el::LoggingFlag::DisableApplicationAbortOnFatalLog); LOG(INFO); LOG(DEBUG); LOG(WARNING); LOG(ERROR); LOG(TRACE); VLOG(1); LOG(FATAL); DLOG(INFO); DLOG(DEBUG); DLOG(WARNING); DLOG(ERROR); DLOG(TRACE); DVLOG(1); DLOG(FATAL); LOG_IF(true, INFO); LOG_IF(true, DEBUG); LOG_IF(true, WARNING); LOG_IF(true, ERROR); LOG_IF(true, TRACE); VLOG_IF(true, 1); LOG_IF(true, FATAL); LOG_EVERY_N(1, INFO); LOG_EVERY_N(1, DEBUG); LOG_EVERY_N(1, WARNING); LOG_EVERY_N(1, ERROR); LOG_EVERY_N(1, TRACE); VLOG_EVERY_N(1, 1); LOG_EVERY_N(1, FATAL); CHECK(1 == 1); CCHECK(1 == 1, "default"); return 0; }
/// @brief DEPRECATED; use Forward() instead. const vector<Blob<Dtype>*>& ForwardPrefilled(Dtype* loss = NULL) { LOG_EVERY_N(WARNING, 1000) << "DEPRECATED: ForwardPrefilled() " << "will be removed in a future version. Use Forward()."; return Forward(loss); }
/// Uses Block-CG to solve Hx = k where H is the sum of projectors /// and k is \sum A_i^+ b_i /// /// The block-size is defined in icntl[Controls::block_size] /// \param b The right-hand side void abcd::bcg(MV_ColMat_double &b) { std::streamsize oldprec = std::cout.precision(); double t1_total, t2_total; const double threshold = dcntl[Controls::threshold]; const int block_size = icntl[Controls::block_size]; const int itmax = icntl[Controls::itmax]; // s is the block size of the current run int s = std::max<int>(block_size, nrhs); if (itmax < 0) { info[Controls::status] = -11; mpi::broadcast(intra_comm, info[Controls::status], 0); throw std::runtime_error("Max iter number should be at least zero (0)"); } if(!use_xk) { Xk = MV_ColMat_double(n, nrhs, 0); } MV_ColMat_double u(m, nrhs, 0); // get a reference to the nrhs first columns u = b(MV_VecIndex(0, b.dim(0)-1), MV_VecIndex(0,nrhs-1)); MV_ColMat_double p(n, s, 0); MV_ColMat_double qp(n, s, 0); MV_ColMat_double r(n, s, 0); MV_ColMat_double gammak(s, s, 0); MV_ColMat_double betak(s, s, 0); MV_ColMat_double lambdak(s, nrhs, 0); MV_ColMat_double prod_gamma(nrhs, nrhs, 0); MV_ColMat_double e1(s, nrhs, 0); MV_ColMat_double gu, bu, pl; double thresh = threshold; double *qp_ptr = qp.ptr(); double *betak_ptr = betak.ptr(); double *l_ptr = lambdak.ptr(); nrmB = std::vector<double>(nrhs, 0); for(int j = 0; j < nrhs; ++j) { VECTOR_double u_j = u(j); double lnrmBs = infNorm(u_j); // Sync B norm : mpi::all_reduce(inter_comm, &lnrmBs, 1, &nrmB[0] + j, mpi::maximum<double>()); } mpi::broadcast(inter_comm, nrmMtx, 0); for(int k =0; k < e1.dim(1); k++) e1(0,k) = 1; char up = 'U'; char left = 'L'; char right = 'R'; char tr = 'T'; char notr = 'N'; double alpha = 1; // ************************************************** // ITERATION k = 0 * // ************************************************** t1_total = MPI_Wtime(); if(use_xk) { MV_ColMat_double sp = sumProject(1e0, b, -1e0, Xk); r.setCols(sp, 0, s); } else { MV_ColMat_double sp = sumProject(1e0, b, 0, Xk); r.setCols(sp, 0, s); } t1_total = MPI_Wtime() - t1_total; // orthogonalize // r = r*gamma^-1 #ifdef WIP if(icntl[Controls::use_gmgs2] != 0){ gmgs2(r, r, gammak, s, false); } else #endif //WIP if(gqr(r, r, gammak, s, false) != 0){ gmgs2(r, r, gammak, s, false); } p = r; { MV_ColMat_double gu = gammak(MV_VecIndex(0, nrhs -1), MV_VecIndex(0, nrhs -1)); prod_gamma = upperMat(gu); } int it = 0; double rho = 1; std::vector<double> grho(inter_comm.size()); double ti = MPI_Wtime(); t2_total = MPI_Wtime(); rho = compute_rho(Xk, u); t2_total = MPI_Wtime() - t2_total; if(comm.rank() == 0) { LINFO2 << "ITERATION 0 rho = " << scientific << rho << setprecision(oldprec); } while(true) { it++; double t = MPI_Wtime(); // qp = Hp qp = sumProject(0e0, b, 1e0, p); double t1 = MPI_Wtime() - t; // betak^T betak = chol(p^Tqp) #ifdef WIP if(icntl[Controls::use_gmgs2] != 0){ gmgs2(p, qp, betak, s, true); } else #endif //WIP if(gqr(p, qp, betak, s, true) != 0){ gmgs2(p, qp, betak, s, true); } lambdak = e1; dtrsm_(&left, &up, &tr, ¬r, &s, &nrhs, &alpha, betak_ptr, &s, l_ptr, &s); // pl = p * lambda_k * prod_gamma lambdak = gemmColMat(lambdak, prod_gamma); pl = gemmColMat(p, lambdak); // x = x + pl Xk(MV_VecIndex(0, Xk.dim(0) - 1), MV_VecIndex(0, nrhs -1)) += pl(MV_VecIndex(0, pl.dim(0)-1), MV_VecIndex(0, nrhs - 1)); double t2 = MPI_Wtime(); rho = abcd::compute_rho(Xk, u); t2 = MPI_Wtime() - t2; normres.push_back(rho); if((rho < thresh) || (it >= itmax)) break; // R = R - QP * B^-T dtrsm_(&right, &up, &tr, ¬r, &n, &s, &alpha, betak_ptr, &s, qp_ptr, &n); r = r - qp; #ifdef WIP if(icntl[Controls::use_gmgs2] != 0){ gmgs2(r, r, gammak, s, false); } else #endif //WIP if(gqr(r, r, gammak, s, false) != 0){ gmgs2(r, r, gammak, s, false); } gu = gammak(MV_VecIndex(0, nrhs -1), MV_VecIndex(0, nrhs -1)); gu = upperMat(gu); prod_gamma = gemmColMat(gu, prod_gamma); gammak = upperMat(gammak); bu = upperMat(betak); // bu * gammak^T betak = gemmColMat(bu, gammak, false, true); p = r + gemmColMat(p, betak); //mpi::all_gather(inter_comm, rho, grho); //mrho = *std::max_element(grho.begin(), grho.end()); // t = MPI_Wtime() - t; if(comm.rank() == 0 && icntl[Controls::verbose_level] >= 2) { int ev = icntl[Controls::verbose_level] >= 3 ? 1 : 10; LOG_EVERY_N(ev, INFO) << "ITERATION " << it << " rho = " << scientific << rho << " Timings: " << setprecision(2) << t << setprecision(oldprec); // put precision back to what it was before } t1_total += t1; t2_total += t2; } if(inter_comm.rank() == 0) { LINFO2 << "BCG Rho: " << scientific << rho ; LINFO2 << "BCG Iterations : " << setprecision(2) << it ; LINFO2 << "BCG TIME : " << MPI_Wtime() - ti ; LINFO2 << "SumProject time : " << t1_total ; LINFO2 << "Rho Computation time : " << t2_total ; } if (icntl[Controls::aug_type] != 0) return; info[Controls::nb_iter] = it; if(IRANK == 0) { solution = MV_ColMat_double(n_o, nrhs, 0); sol = solution.ptr(); } centralizeVector(sol, n_o, nrhs, Xk.ptr(), n, nrhs, glob_to_local_ind, &dcol_[0]); }