1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816
|
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2026, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Knut Reinert or the FU Berlin nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Stefan Budach <budach@molgen.mpg.de>
// ==========================================================================
// DPScout_ specialization for the SIMD alignment implementation.
// ==========================================================================
#ifndef SEQAN_INCLUDE_SEQAN_ALIGN_SIMD_DP_SCOUT_SIMD_H_
#define SEQAN_INCLUDE_SEQAN_ALIGN_SIMD_DP_SCOUT_SIMD_H_
namespace seqan2 {
// ============================================================================
// Forwards
// ============================================================================
// ============================================================================
// Tags, Classes, Enums
// ============================================================================
struct SimdAlignEqualLength_;
typedef Tag<SimdAlignEqualLength_> SimdAlignEqualLength;
template <typename TTraits>
struct SimdAlignVariableLength
{};
template <typename TSpec = SimdAlignEqualLength>
struct SimdAlignmentScout {};
// ----------------------------------------------------------------------------
// Class DPScoutState_
// ----------------------------------------------------------------------------
template <>
class DPScoutState_<SimdAlignEqualLength>
{};
template <typename TTraits>
class DPScoutState_<SimdAlignVariableLength<TTraits> >
{
public:
using TSizeH = typename Size<typename TTraits::TSeqH>::Type;
using TSizeV = typename Size<typename TTraits::TSeqV>::Type;
using TIterator = typename Iterator<String<size_t>, Rooted>::Type;
typename TTraits::TSimdVector endPosVecH;
typename TTraits::TSimdVector endPosVecV;
size_t posH;
size_t posV;
TIterator nextEndsH;
TIterator nextEndsV;
};
// ----------------------------------------------------------------------------
// Class DPScout_
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TSpec>
class DPScout_<TDPCell, SimdAlignmentScout<TSpec> > :
public DPScout_<TDPCell, Default>
{
public:
using TSimdVec = typename Value<TDPCell>::Type;
using TBase = DPScout_<TDPCell, Default>;
using TScoutState = DPScoutState_<TSpec>;
TSimdVec mCurrentColumnPosition{};
TSimdVec mCurrentRowPosition{};
TSimdVec mHorizontalPos{};
TSimdVec mVerticalPos{};
TScoutState * state{nullptr};
unsigned _simdLane{0};
DPScout_(TScoutState & pState) : TBase(), state(&pState)
{}
};
// ============================================================================
// Metafunctions
// ============================================================================
// ----------------------------------------------------------------------------
// Metafunction ScoutSpecForSimdAlignment_
// ----------------------------------------------------------------------------
template<typename TAlignmentAlgorithm>
struct ScoutSpecForAlignmentAlgorithm_<TAlignmentAlgorithm, DPScoutState_<SimdAlignEqualLength> >
{
typedef SimdAlignmentScout<SimdAlignEqualLength> Type;
};
template<typename TAlignmentAlgorithm, typename TTraits>
struct ScoutSpecForAlignmentAlgorithm_<TAlignmentAlgorithm, DPScoutState_<SimdAlignVariableLength<TTraits> > >
{
typedef SimdAlignmentScout<SimdAlignVariableLength<TTraits> > Type;
};
// ============================================================================
// Functions
// ============================================================================
// ----------------------------------------------------------------------------
// Function _copySimdCell()
// ----------------------------------------------------------------------------
template <typename TValue, typename TGapSpec, typename TSpec,
typename TScoreValue,
typename TTraceConfig>
inline void
_copySimdCell(DPScout_<DPCell_<TValue, TGapSpec>, SimdAlignmentScout<TSpec> > & dpScout,
DPCell_<TValue, TGapSpec> const & activeCell,
TScoreValue const & cmp,
DPTraceMatrix<TTraceConfig> const & /**/)
{
dpScout._maxScore._score = blend(dpScout._maxScore._score, activeCell._score, cmp);
}
template <typename TValue, typename TSpec,
typename TScoreValue,
typename TTraceConfig>
inline void
_copySimdCell(DPScout_<DPCell_<TValue, AffineGaps>, SimdAlignmentScout<TSpec> > & dpScout,
DPCell_<TValue, AffineGaps> const & activeCell,
TScoreValue const & cmp,
DPTraceMatrix<TracebackOn<TTraceConfig>> const & /**/)
{
dpScout._maxScore._score = blend(dpScout._maxScore._score, activeCell._score, cmp);
dpScout._maxScore._horizontalScore = blend(dpScout._maxScore._horizontalScore, activeCell._horizontalScore, cmp);
dpScout._maxScore._verticalScore = blend(dpScout._maxScore._verticalScore, activeCell._verticalScore, cmp);
}
template <typename TValue, typename TSpec,
typename TScoreValue,
typename TTraceConfig, typename TGapsPlacement>
inline void
_copySimdCell(DPScout_<DPCell_<TValue, DynamicGaps>, SimdAlignmentScout<TSpec> > & dpScout,
DPCell_<TValue, DynamicGaps> const & activeCell,
TScoreValue const & cmp,
DPTraceMatrix<TracebackOn<TTraceConfig>> const & /**/)
{
dpScout._maxScore._score = blend(dpScout._maxScore._score, activeCell._score, cmp);
dpScout._maxScore._flagMask = blend(dpScout._maxScore._flagMask, activeCell._flagMask, cmp);
}
// ----------------------------------------------------------------------------
// Function _updateHostPositions()
// ----------------------------------------------------------------------------
// No trace needed, hence we do not track the max positions.
template<typename TDPCell, typename TScoutSpec,
typename TMask,
typename TNavigator>
inline void
_updateHostPositions(DPScout_<TDPCell, TScoutSpec> & /*dpScout*/,
TMask const & /*cmp*/,
TNavigator const & /*navi*/,
DPTraceMatrix<TracebackOff> const & /**/)
{}
template<typename TDPCell, typename TScoutSpec,
typename TMask,
typename TNavigator,
typename TTraceConfig>
inline void
_updateHostPositions(DPScout_<TDPCell, TScoutSpec> & dpScout,
TMask const & cmp,
TNavigator const & /*navi*/,
DPTraceMatrix<TTraceConfig> const & /**/)
{
dpScout.mHorizontalPos = blend(dpScout.mHorizontalPos, dpScout.mCurrentColumnPosition, cmp);
dpScout.mVerticalPos = blend(dpScout.mVerticalPos, dpScout.mCurrentRowPosition, cmp);
}
// ----------------------------------------------------------------------------
// Function _scoutBestScore() [SimdAlignEqualLength]
// ----------------------------------------------------------------------------
template <typename TDPCell,
typename TTraceMatrixNavigator,
typename TIsLastColumn,
typename TIsLastRow>
inline void
_scoutBestScore(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > & dpScout,
TDPCell const & activeCell,
TTraceMatrixNavigator const & navigator,
TIsLastColumn const & /**/,
TIsLastRow const & /**/)
{
using TMatrixType = typename MatrixType<TTraceMatrixNavigator>::Type;
auto cmp = cmpGt(_scoreOfCell(activeCell), _scoreOfCell(dpScout._maxScore));
_copySimdCell(dpScout, activeCell, cmp, TMatrixType());
_updateHostPositions(dpScout, cmp, navigator, TMatrixType());
}
// ----------------------------------------------------------------------------
// Function _getCompareMask()
// ----------------------------------------------------------------------------
// Helper functions to resolve the correct tracking of cells for different
// alignment modes.
// Standard global alignment.
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
True const & /*lastCol*/,
True const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, False>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return ((dpScout.state->endPosVecH) == createVector<TSimdVec>(dpScout.state->posH)) &
((dpScout.state->endPosVecV) == createVector<TSimdVec>(dpScout.state->posV));
}
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, False>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// Tracking the last row is enabled
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, False>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) == (dpScout.state->endPosVecV));
}
// ----------------------------------------------------------------------------
// Function _getCompareMask()
// ----------------------------------------------------------------------------
// Helper functions to resolve the correct tracking of cells for different
// alignment modes.
// Standard global alignment.
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
True const & /*lastCol*/,
True const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, False>>,
TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return ((dpScout.state->endPosVecH) == createVector<TSimdVec>(dpScout.state->posH)) &
((dpScout.state->endPosVecV) == createVector<TSimdVec>(dpScout.state->posV));
}
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, False>>,
TGapModel, TTraceConfig> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// Tracking the last row is enabled
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, False>>,
TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) == (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
TIsLastColumn const & /*lastCol*/,
False const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, False>>,
TGapModel, TTraceConfig> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// Tracking if the last column is enabled
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, True>>,
TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) == (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
False const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, True>>,
TGapModel, TTraceConfig> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// Tracking if the last column and last row is enabled
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
True const & /*lastCol*/,
True const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return ((createVector<TSimdVec>(dpScout.state->posH) == (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV))) |
((createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) == (dpScout.state->endPosVecV)));
}
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
False const & /*lastCol*/,
True const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) == (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
True const & /*lastCol*/,
False const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) == (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
False const & /*lastCol*/,
False const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// If local alignment.
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TAlgoSpec, typename TGapModel, typename TTraceConfig>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<LocalAlignment_<TAlgoSpec>, TGapModel, TTraceConfig> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV));
}
// ----------------------------------------------------------------------------
// Function _scoutBestScore() [SimdAlignVariableLength]
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
TIsLastColumn const & /*lastCol*/,
False const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, False>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// Tracking if the last column is enabled
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, True>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) == (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TIsLastRow,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
False const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, False, True>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return createVector<TSimdVec>(0);
}
// Tracking if the last column and last row is enabled
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
True const & /*lastCol*/,
True const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return ((createVector<TSimdVec>(dpScout.state->posH) == (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV))) |
((createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) == (dpScout.state->endPosVecV)));
}
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
False const & /*lastCol*/,
True const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) == (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
True const & /*lastCol*/,
False const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) == (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV));
}
template <typename TDPCell, typename TTraits,
typename TTop, typename TLeft, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & /*dpScout*/,
False const & /*lastCol*/,
False const & /*lastRow*/,
DPProfile_<GlobalAlignment_<FreeEndGaps_<TTop, TLeft, True, True>>,
TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdMaskVec = typename SimdMaskVector<typename TTraits::TSimdVector>::Type;
return createVector<TSimdMaskVec>(0);
}
// If local alignment.
template <typename TDPCell, typename TTraits,
typename TIsLastColumn,
typename TIsLastRow,
typename TAlgoSpec, typename TGapModel, typename TTraceConfig, typename TExecPolicy>
inline auto _getCompareMask(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & dpScout,
TIsLastColumn const & /*lastCol*/,
TIsLastRow const & /*lastRow*/,
DPProfile_<LocalAlignment_<TAlgoSpec>, TGapModel, TTraceConfig, TExecPolicy> const &)
{
using TSimdVec = typename TTraits::TSimdVector;
return (createVector<TSimdVec>(dpScout.state->posH) <= (dpScout.state->endPosVecH)) &
(createVector<TSimdVec>(dpScout.state->posV) <= (dpScout.state->endPosVecV));
}
// ----------------------------------------------------------------------------
// Function _scoutBestScore() [SimdAlignVariableLength]
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TTraits,
typename TTraceMatrixNavigator,
typename TIsLastColumn,
typename TIsLastRow>
inline void
_scoutBestScore(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & dpScout,
TDPCell const & activeCell,
TTraceMatrixNavigator const & navigator,
TIsLastColumn const & /**/,
TIsLastRow const & /**/)
{
using TMatrixType = typename MatrixType<TTraceMatrixNavigator>::Type;
auto mask = cmpGt(_scoreOfCell(activeCell), _scoreOfCell(dpScout._maxScore)) &
_getCompareMask(dpScout, TIsLastColumn{}, TIsLastRow{}, typename TTraits::TDPProfile{});
_copySimdCell(dpScout, activeCell, mask, TMatrixType());
_updateHostPositions(dpScout, mask, navigator, TMatrixType());
}
// ----------------------------------------------------------------------------
// Function maxHostCoordinate()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TScoutSpec,
typename TDimension>
inline auto
maxHostCoordinate(DPScout_<TDPCell, SimdAlignmentScout<TScoutSpec> > const & dpScout,
TDimension const dimension)
{
return (dimension == DPMatrixDimension_::HORIZONTAL) ? dpScout.mHorizontalPos[dpScout._simdLane] :
dpScout.mVerticalPos[dpScout._simdLane];
}
template <typename TDPCell, typename TScoutSpec>
inline auto
maxHostCoordinates(DPScout_<TDPCell, SimdAlignmentScout<TScoutSpec> > const & dpScout)
{
return std::make_pair(maxHostCoordinate(dpScout, DPMatrixDimension_::HORIZONTAL),
maxHostCoordinate(dpScout, DPMatrixDimension_::VERTICAL));
}
// ----------------------------------------------------------------------------
// Function maxScoreAt()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TScoutSpec>
inline auto
maxScoreAt(DPScout_<TDPCell, SimdAlignmentScout<TScoutSpec> > const & dpScout)
{
return maxScore(dpScout)[dpScout._simdLane];
}
// ----------------------------------------------------------------------------
// Function maxHostPosition()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TScoutSpec>
[[deprecated("Use maxHostCoordinate instead!")]] auto
maxHostPosition(DPScout_<TDPCell, SimdAlignmentScout<TScoutSpec> > const & /*unused*/)
{}
// ----------------------------------------------------------------------------
// Function _setSimdLane()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TScoutSpec, typename TPosition>
inline void
_setSimdLane(DPScout_<TDPCell, TScoutSpec> & dpScout, TPosition const pos)
{
dpScout._simdLane = pos;
}
// ----------------------------------------------------------------------------
// Function _preInitScoutHorizontal()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TPosition>
inline void
_preInitScoutHorizontal(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > & scout,
TPosition const offset = 0)
{
using TSimdVec = decltype(scout.mCurrentColumnPosition);
scout.mCurrentColumnPosition = createVector<TSimdVec>(offset);
}
template <typename TDPCell, typename TTraits, typename TPosition>
inline void
_preInitScoutHorizontal(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout,
TPosition const offset = 0)
{
using TSimdVec = decltype(scout.mCurrentColumnPosition);
scout.mCurrentColumnPosition = createVector<TSimdVec>(offset);
goBegin(scout.state->nextEndsH);
scout.state->posH = 0;
}
// ----------------------------------------------------------------------------
// Function _preInitScoutVertical()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TPosition>
inline void
_preInitScoutVertical(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > & scout,
TPosition const offset)
{
using TSimdVec = decltype(scout.mCurrentRowPosition);
scout.mCurrentRowPosition = createVector<TSimdVec>(offset);
}
template <typename TDPCell, typename TTraits, typename TPosition>
inline void
_preInitScoutVertical(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout,
TPosition const offset)
{
using TSimdVec = decltype(scout.mCurrentRowPosition);
scout.mCurrentRowPosition = createVector<TSimdVec>(offset);
// scout.state->updateMasks();
goBegin(scout.state->nextEndsV);
scout.state->posV = 0;
}
// ----------------------------------------------------------------------------
// Function _reachedHorizontalEndPoint()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TTraits, typename TIter>
inline bool
_reachedHorizontalEndPoint(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout,
TIter const & hIt)
{
return *(scout.state->nextEndsH) == position(hIt) + 1;
}
// ----------------------------------------------------------------------------
// Function _reachedVerticalEndPoint()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TTraits, typename TIter>
inline bool
_reachedVerticalEndPoint(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout,
TIter const & vIt)
{
return *(scout.state->nextEndsV) == position(vIt) + 1;
}
// ----------------------------------------------------------------------------
// Function _nextHorizontalEndPos()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TTraits>
inline void
_nextHorizontalEndPos(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout)
{
++scout.state->nextEndsH;
}
// ----------------------------------------------------------------------------
// Function _nextVerticalEndPos()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TTraits>
inline void
_nextVerticalEndPos(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout)
{
++scout.state->nextEndsV;
}
// ----------------------------------------------------------------------------
// Function _incHorizontalPos()
// ----------------------------------------------------------------------------
template <typename TDPCell>
inline void
_incHorizontalPos(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > & scout)
{
using TDPScout = DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> >;
scout.mCurrentColumnPosition += createVector<typename TDPScout::TSimdVec>(1);
}
template <typename TDPCell, typename TTraits>
inline void
_incHorizontalPos(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout)
{
using TDPScout = DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > >;
scout.mCurrentColumnPosition += createVector<typename TDPScout::TSimdVec>(1);
++scout.state->posH;
}
// ----------------------------------------------------------------------------
// Function _incVerticalPos()
// ----------------------------------------------------------------------------
template <typename TDPCell>
inline void
_incVerticalPos(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > & scout)
{
using TDPScout = DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> >;
scout.mCurrentRowPosition += createVector<typename TDPScout::TSimdVec>(1);
}
template <typename TDPCell, typename TTraits>
inline void
_incVerticalPos(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > & scout)
{
using TDPScout = DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > >;
scout.mCurrentRowPosition += createVector<typename TDPScout::TSimdVec>(1);
++scout.state->posV;
}
// ----------------------------------------------------------------------------
// Function _hostLengthH()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TSeqH>
inline auto
_hostLengthH(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > const & /*scout*/,
TSeqH const & seqH)
{
return length(seqH);
}
template <typename TDPCell, typename TTraits, typename TSeqH>
inline auto
_hostLengthH(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & scout,
TSeqH const & /*seqH*/)
{
using TInnerValue = typename Value<typename TTraits::TSimdVector>::Type;
return static_cast<TInnerValue>(scout.state->endPosVecH[scout._simdLane]);
}
// ----------------------------------------------------------------------------
// Function _hostLengthV()
// ----------------------------------------------------------------------------
template <typename TDPCell, typename TSeqV>
inline auto
_hostLengthV(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignEqualLength> > const & /*scout*/,
TSeqV const & seqV)
{
return length(seqV);
}
template <typename TDPCell, typename TTraits, typename TSeqV>
inline auto
_hostLengthV(DPScout_<TDPCell, SimdAlignmentScout<SimdAlignVariableLength<TTraits> > > const & scout,
TSeqV const & /*seqV*/)
{
using TInnerValue = typename Value<typename TTraits::TSimdVector>::Type;
return static_cast<TInnerValue>(scout.state->endPosVecV[scout._simdLane]);
}
} // namespace seqan2
#endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_SIMD_DP_SCOUT_SIMD_H_
|