void back_trace(string &s, int index, vector<list<int> > &lookup, vector<string> &path, vector<string> &result) { if (0 == index) { string str; int size = path.size(); for (int i = size - 1; i >= 0; --i) { str.append(path[i]); if (i != 0) { str.append(" "); } } result.push_back(str); } else { for (list<int>::iterator it = lookup[index].begin(); it != lookup[index].end(); ++it) { int prev = *it; path.push_back(s.substr(prev, index - prev)); back_trace(s, prev, lookup, path, result); path.pop_back(); } } }
vector<string> wordBreak(string s, unordered_set<string> &dict) { vector<string> result; vector<string> path; int len = s.length(); vector<bool> match(len + 1, false); vector<list<int> > lookup(len + 1); match[0] = true; for (int i = 1; i <= len; ++i) { for (int prev = 0; prev < i; ++prev) { if (match[prev] && (dict.find(s.substr(prev, i - prev)) != dict.end())) { // 找到一个匹配的单词 match[i] = true; lookup[i].push_back(prev); } } } if (!match[len]) { return result; } back_trace(s, len, lookup, path, result); }
HPX_EXPORT std::exception_ptr get_exception(Exception const& e, std::string const& func, std::string const& file, long line, std::string const& auxinfo) { if (is_of_lightweight_hpx_category(e)) return construct_lightweight_exception(e, func, file, line); std::int64_t pid = ::getpid(); std::string back_trace(backtrace()); std::string state_name("not running"); std::string hostname; hpx::runtime* rt = get_runtime_ptr(); if (rt) { state rts_state = rt->get_state(); state_name = get_runtime_state_name(rts_state); if (rts_state >= state_initialized && rts_state < state_stopped) { std::ostringstream strm; strm << get_runtime().here(); hostname = strm.str(); } } // if this is not a HPX thread we do not need to query neither for // the shepherd thread nor for the thread id error_code ec(lightweight); std::uint32_t node = get_locality_id(ec); std::size_t shepherd = std::size_t(-1); threads::thread_id_type thread_id; util::thread_description thread_name; threads::thread_self* self = threads::get_self_ptr(); if (nullptr != self) { if (threads::threadmanager_is(state_running)) shepherd = hpx::get_worker_thread_num(); thread_id = threads::get_self_id(); thread_name = threads::get_thread_description(thread_id); } std::string env(get_execution_environment()); std::string config(configuration_string()); return construct_exception(e, func, file, line, back_trace, node, hostname, pid, shepherd, reinterpret_cast<std::size_t>(thread_id.get()), util::as_string(thread_name), env, config, state_name, auxinfo); }
void eagle_xiu_timeout_interrupt(void) { #ifdef CONFIG_HANG_ISSUE_DEBUG char * ptr= NULL; #endif printk("XIU Time Out Occurred!\n"); printk("Address is 0x%x\n",*(volatile short*)(0xfd200224)); #ifdef CONFIG_HANG_ISSUE_DEBUG back_trace(); *ptr = 1; #endif }
static irqreturn_t chip_xiu_timeout_interrupt(int irq, void *dev_id) { #ifdef CONFIG_HANG_ISSUE_DEBUG char * ptr= NULL; #endif printk("XIU Time Out Occurred!\n"); printk("Address is 0x%x\n",*(volatile short*)(0xfd200224)); #ifdef CONFIG_HANG_ISSUE_DEBUG back_trace(); #endif #ifdef CONFIG_HANG_ISSUE_DEBUG *ptr = 1; #endif return IRQ_HANDLED; }
HPX_EXPORT void throw_exception(Exception const& e, std::string const& func, std::string const& file, long line) { boost::int64_t pid_ = ::getpid(); std::string back_trace(backtrace()); std::string hostname_ = ""; if (get_runtime_ptr()) { util::osstream strm; strm << get_runtime().here(); hostname_ = util::osstream_get_string(strm); } // if this is not a HPX thread we do not need to query neither for // the shepherd thread nor for the thread id boost::uint32_t node = 0; std::size_t shepherd = std::size_t(-1); std::size_t thread_id = 0; std::string thread_name(""); threads::thread_self* self = threads::get_self_ptr(); if (NULL != self) { if (threads::threadmanager_is(running)) { node = get_locality_id(); shepherd = threads::threadmanager_base::get_worker_thread_num(); } thread_id = reinterpret_cast<std::size_t>(self->get_thread_id()); thread_name = threads::get_thread_description(self->get_thread_id()); } rethrow_exception(e, func, file, line, back_trace, node, hostname_, pid_, shepherd, thread_id, thread_name); }
// verify that no locks are held by this HPX-thread void verify_no_locks() { if (register_locks::lock_detection_enabled_ && 0 != threads::get_self_ptr()) { register_locks::held_locks_map const& held_locks = register_locks::get_lock_map(); // we create a log message if there are still registered locks for // this OS-thread if (!held_locks.empty()) { std::string back_trace(hpx::detail::backtrace_direct()); if (back_trace.empty()) { LERR_(debug) << "suspending thread while at least one lock is being held " "(stack backtrace was disabled at compile time)"; } else { LERR_(debug) << "suspending thread while at least one lock is being held, " << "stack backtrace: " << back_trace; } } } }
int aln_splice_local_core(uchar *gen, int gen_len, uchar *est, int est_len, AlnParam *ap, path_t *path, int *path_len) { register dpcell_t *q; register int i; register dpscore_t *s; int **s_array, *score_array; dpcell_t **dpcell; dpscore_t *dpscore; int *donor, *acceptor; int j, mi, mj, max_g; int last_g, curr_g, curr_last_g; int ins, del, n; uchar dtmp, atmp; int gap_open, gap_ext, gap_oe, good_splice, bad_splice, *sc_matrix; gap_open = ap->gap_open; gap_ext = ap->gap_ext; gap_oe = gap_open - gap_ext; good_splice = ap->good_splice; bad_splice = ap->bad_splice; sc_matrix = ap->matrix; if (*sc_donor != ap->bad_splice) est_genome_init(ap); if (gen_len < 5) return MINOR_INF; /* memory allocation */ s_array = (int**)MYALLOC(sizeof(int*) * ap->row); for (i = 0; i != ap->row; ++i) s_array[i] = (int*)MYALLOC(sizeof(int) * gen_len); dpcell = (dpcell_t**)MYALLOC(sizeof(dpcell_t*) * (est_len + 1)); for (j = 0; j <= est_len; ++j) dpcell[j] = (dpcell_t*)MYALLOC(sizeof(dpcell_t) * (gen_len + 1)); donor = (int*)MYALLOC(sizeof(int) * (gen_len + 2)); acceptor = (int*)MYALLOC(sizeof(int) * (gen_len + 2)); dpscore = (dpscore_t*)MYALLOC(sizeof(dpscore_t) * (gen_len + 1)); aln_init_score_array(gen, gen_len, ap->row, sc_matrix, s_array); for (i = 0; i != ap->row; ++i) --s_array[i]; --est; --gen; /* set donor-acceptor array */ donor[gen_len - 1] = donor[gen_len] = sc_donor[0xf]; dtmp = gen[1] & 0x3; for (i = 1; i <= gen_len - 1; ++i) { if (gen[i+1] > 3 || gen[i] > 3) donor[i] = bad_splice; /* N is encountered */ else { dtmp = ((dtmp<<2) | gen[i+1]) & 0xf; donor[i] = sc_donor[dtmp]; } } acceptor[gen_len+1] = acceptor[0] = acceptor[1] = acceptor[2] = sc_acceptor[0xf]; atmp = gen[1] & 0x3; for (i = 3; i <= gen_len; ++i) { if (gen[i] > 3 || gen[i-1] > 3) acceptor[i] = bad_splice; else { atmp = ((atmp<<2) | gen[i-1]) & 0xf; acceptor[i] = sc_acceptor[atmp]; } } /* first row */ max_g = 0; mi = mj = 0; for (i = 0, q = dpcell[0], s = dpscore; i <= gen_len; ++i, ++q, ++s) { s->G = s->I = 0; q->Gt = FROM_0; } /* core dynamic programming */ for (j = 1; j <= est_len; ++j) { last_g = del = n = 0; score_array = s_array[est[j]]; q = dpcell[j]; q->Gt = SL_FROM_0; ++q; for (i = 1, s = dpscore; i <= gen_len; ++i, ++s, ++q) { curr_g = s->G + score_array[i]; if (curr_g < 0) { curr_g = 0; q->Gt = SL_FROM_0; } else q->Gt = SL_FROM_M; if (last_g > donor[i]) { if (last_g - donor[i] > n) { n = last_g - donor[i]; q->Nt = SL_FROM_G; } else q->Nt = SL_FROM_N; if (curr_g < n - acceptor[i+1]) { curr_g = n - acceptor[i+1]; q->Gt = SL_FROM_N; } } else q->Nt = SL_FROM_N; if (last_g > gap_open) { if (del > last_g - gap_oe) { del -= gap_ext; q->Dt = SL_FROM_D; } else { del = last_g - gap_open; q->Dt = SL_FROM_G; } if (curr_g < del) { curr_g = del; q->Gt = SL_FROM_D; } } curr_last_g = (s+1)->G; if (curr_last_g > gap_open) { if (s->I > curr_last_g - gap_oe) { ins = s->I - gap_ext; q->It = SL_FROM_I; } else { ins = curr_last_g - gap_open; q->It = SL_FROM_G; } if (curr_g < ins) { curr_g = ins; q->Gt = SL_FROM_I; } s->I = ins; } else s->I = 0; s->G = last_g; last_g = curr_g; if (curr_g > max_g) { max_g = curr_g; mi = i; mj = j; } } s->G = last_g; } back_trace(dpcell, mi, mj, path, path_len); /* free */ MYFREE(dpscore); MYFREE(acceptor); MYFREE(donor); for (j = 0; j <= est_len; ++j) MYFREE(dpcell[j]); for (i = 0; i != ap->row; ++i) MYFREE(s_array[i] + 1); MYFREE(s_array); MYFREE(dpcell); return max_g; }