void calc_block( hpxla::local_matrix_view<boost::int64_t>& H , hpxla::local_matrix_view<hpx::future<void> >& C // Control matrix. , coords start // The start of our cell block. , coords end // The end of our cell block. , coords control // Our location in the control matrix. , std::string const& a , std::string const& b ) { // TODO: Handle this with hpx::wait_all? C(control.i, control.j-1).get(); C(control.i-1, control.j-1).get(); C(control.i-1, control.j ).get(); winner local_best = H_best.load(); // Generate scores. for (boost::uint32_t i = start.i; i < end.i; ++i) { for (boost::uint32_t j = start.j; j < end.j; ++j) { H(i, j) = calc_cell(i, j, a[i-1], b[j-1] , H(i, j-1) // left , H(i-1, j-1) // diagonal , H(i-1, j ) // up ); if (H(i, j) > local_best.value) { local_best.value = H(i, j); local_best.i = i; local_best.j = j; } } } winner H_best_old = H_best.load(); while (true) { if (local_best.value > H_best_old.value) { if (H_best.compare_exchange_weak(H_best_old, local_best)) break; } else break; } }
boost::int64_t calc_cell( boost::uint32_t i , boost::uint32_t j , char ai , char bj , hpx::future<boost::int64_t> const& left // H(i, j-1) , hpx::future<boost::int64_t> const& diagonal // H(i-1, j-1) , hpx::future<boost::int64_t> const& up // H(i-1, j) ) { boost::int64_t match_mismatch = 0; if (ai == bj) { match_mismatch = diagonal.get() + match; } else { match_mismatch = diagonal.get() + mismatch; } boost::int64_t deletion = up.get() + gap; boost::int64_t insertion = left.get() + gap; boost::int64_t ij_value = maximum(boost::int64_t(0), match_mismatch, deletion, insertion); winner H_best_old = H_best.load(); while (true) { winner H_best_new(ij_value, i, j); if (H_best_new.value > H_best_old.value) { if (H_best.compare_exchange_weak(H_best_old, H_best_new)) break; } else break; } return ij_value; }