diff --git a/tree/phylokernelavx512.cpp b/tree/phylokernelavx512.cpp index 3c1e86a0..8bddf872 100644 --- a/tree/phylokernelavx512.cpp +++ b/tree/phylokernelavx512.cpp @@ -17,8 +17,10 @@ //#include "phylokernelsitemodel.h" #include "phylokernelnew.h" +#include "phylokernelnonrev.h" #define KERNEL_FIX_STATES #include "phylokernelnew.h" +#include "phylokernelnonrev.h" #if !defined ( __AVX512F__ ) && !defined ( __AVX512__ ) @@ -35,85 +37,119 @@ void PhyloTree::setDotProductAVX512() { } void PhyloTree::setLikelihoodKernelAVX512() { + vector_size = 8; + bool site_model = model_factory && model_factory->model->isSiteSpecificModel(); // setParsimonyKernelAVX(); - if (model_factory && model_factory->model->isSiteSpecificModel()) { + computeLikelihoodDervMixlenPointer = NULL; + + if (site_model && safe_numeric) { + // safe site-specific model + switch (aln->num_states) { + case 4: + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + break; + case 20: + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + break; + default: + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD ; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD; + break; + } + return; + } + + if (site_model) { switch (aln->num_states) { case 4: computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; break; case 20: computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; break; default: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD ; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD ; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD ; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD; + ASSERT(0); break; } return; } - if (params->lk_safe_scaling) { - switch(aln->num_states) { - case 2: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + if ((model_factory && !model_factory->model->isReversible()) || params->kernel_nonrev) { + // if nonreversible model + switch (aln->num_states) { + case 4: + computeLikelihoodBranchPointer = &PhyloTree::computeNonrevLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeNonrevLikelihoodDervSIMD ; + computePartialLikelihoodPointer = &PhyloTree::computeNonrevPartialLikelihoodSIMD; + break; + default: + computeLikelihoodBranchPointer = &PhyloTree::computeNonrevLikelihoodBranchGenericSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeNonrevLikelihoodDervGenericSIMD ; + computePartialLikelihoodPointer = &PhyloTree::computeNonrevPartialLikelihoodGenericSIMD; break; + } + computeLikelihoodFromBufferPointer = NULL; + return; + } + + if (safe_numeric) { + switch(aln->num_states) { case 4: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; + computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; break; case 20: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; + computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; break; default: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD; + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD ; + computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenGenericSIMD; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD; break; } return; } switch(aln->num_states) { - case 2: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; - break; case 4: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; + computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; break; case 20: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; + computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD ; + computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD ; + computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD; + computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD ; + computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD; break; default: - computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD; - computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD; - computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD; - computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD; + ASSERT(0); break; } }