Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Fix compilation with AVX-512 KNL
Browse files Browse the repository at this point in the history
  • Loading branch information
bqminh committed Jun 7, 2017
1 parent 76d49fd commit d231343
Showing 1 changed file with 80 additions and 44 deletions.
124 changes: 80 additions & 44 deletions tree/phylokernelavx512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__ )
Expand All @@ -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 <Vec8d, SAFE_LH, 4, true, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, SAFE_LH, 4, true, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, SAFE_LH, 4, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 4, true, true>;
break;
case 20:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, SAFE_LH, 20, true, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, SAFE_LH, 20, true, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, SAFE_LH, 20, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 20, true, true>;
break;
default:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD <Vec8d, SAFE_LH, true, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD <Vec8d, SAFE_LH, true, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD <Vec8d, SAFE_LH, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD<Vec8d, true, true>;
break;
}
return;
}

if (site_model) {
switch (aln->num_states) {
case 4:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, NORM_LH, 4, true, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, NORM_LH, 4, true, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, NORM_LH, 4, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, NORM_LH, 4, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 4, true, true>;
break;
case 20:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, NORM_LH, 20, true, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, NORM_LH, 20, true, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, NORM_LH, 20, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, NORM_LH, 20, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 20, true, true>;
break;
default:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD <Vec8d, NORM_LH, true, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD <Vec8d, NORM_LH, true, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD <Vec8d, NORM_LH, true, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD<Vec8d, NORM_LH, true, true>;
ASSERT(0);
break;
}
return;
}

if (params->lk_safe_scaling) {
switch(aln->num_states) {
case 2:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD<Vec8d, SAFE_LH, 2, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD<Vec8d, SAFE_LH, 2, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD<Vec8d, SAFE_LH, 2, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, SAFE_LH, 2, true>;
if ((model_factory && !model_factory->model->isReversible()) || params->kernel_nonrev) {
// if nonreversible model
switch (aln->num_states) {
case 4:
computeLikelihoodBranchPointer = &PhyloTree::computeNonrevLikelihoodBranchSIMD <Vec8d, 4, true>;
computeLikelihoodDervPointer = &PhyloTree::computeNonrevLikelihoodDervSIMD <Vec8d, 4, true>;
computePartialLikelihoodPointer = &PhyloTree::computeNonrevPartialLikelihoodSIMD<Vec8d, 4, true>;
break;
default:
computeLikelihoodBranchPointer = &PhyloTree::computeNonrevLikelihoodBranchGenericSIMD <Vec8d>;
computeLikelihoodDervPointer = &PhyloTree::computeNonrevLikelihoodDervGenericSIMD <Vec8d>;
computePartialLikelihoodPointer = &PhyloTree::computeNonrevPartialLikelihoodGenericSIMD<Vec8d>;
break;
}
computeLikelihoodFromBufferPointer = NULL;
return;
}

if (safe_numeric) {
switch(aln->num_states) {
case 4:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD<Vec8d, SAFE_LH, 4, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD<Vec8d, SAFE_LH, 4, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD<Vec8d, SAFE_LH, 4, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, SAFE_LH, 4, true>;
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, SAFE_LH, 4, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, SAFE_LH, 4, true>;
computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD<Vec8d, SAFE_LH, 4, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, SAFE_LH, 4, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 4, true>;
break;
case 20:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD<Vec8d, SAFE_LH, 20, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD<Vec8d, SAFE_LH, 20, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD<Vec8d, SAFE_LH, 20, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, SAFE_LH, 20, true>;
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, SAFE_LH, 20, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, SAFE_LH, 20, true>;
computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD<Vec8d, SAFE_LH, 20, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, SAFE_LH, 20, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 20, true>;
break;
default:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD<Vec8d, SAFE_LH, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD<Vec8d, SAFE_LH, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD<Vec8d, SAFE_LH, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD<Vec8d, SAFE_LH, true>;
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD <Vec8d, SAFE_LH, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD <Vec8d, SAFE_LH, true>;
computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenGenericSIMD<Vec8d, SAFE_LH, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD <Vec8d, SAFE_LH, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD<Vec8d, true>;
break;
}
return;
}

switch(aln->num_states) {
case 2:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD<Vec8d, NORM_LH, 2, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD<Vec8d, NORM_LH, 2, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD<Vec8d, NORM_LH, 2, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, NORM_LH, 2, true>;
break;
case 4:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD<Vec8d, NORM_LH, 4, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD<Vec8d, NORM_LH, 4, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD<Vec8d, NORM_LH, 4, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, NORM_LH, 4, true>;
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, NORM_LH, 4, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, NORM_LH, 4, true>;
computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD<Vec8d, NORM_LH, 4, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, NORM_LH, 4, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 4, true>;
break;
case 20:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD<Vec8d, NORM_LH, 20, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD<Vec8d, NORM_LH, 20, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD<Vec8d, NORM_LH, 20, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, NORM_LH, 20, true>;
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchSIMD <Vec8d, NORM_LH, 20, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervSIMD <Vec8d, NORM_LH, 20, true>;
computeLikelihoodDervMixlenPointer = &PhyloTree::computeLikelihoodDervMixlenSIMD<Vec8d, NORM_LH, 20, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodSIMD <Vec8d, NORM_LH, 20, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferSIMD<Vec8d, 20, true>;
break;
default:
computeLikelihoodBranchPointer = &PhyloTree::computeLikelihoodBranchGenericSIMD<Vec8d, NORM_LH, true>;
computeLikelihoodDervPointer = &PhyloTree::computeLikelihoodDervGenericSIMD<Vec8d, NORM_LH, true>;
computePartialLikelihoodPointer = &PhyloTree::computePartialLikelihoodGenericSIMD<Vec8d, NORM_LH, true>;
computeLikelihoodFromBufferPointer = &PhyloTree::computeLikelihoodFromBufferGenericSIMD<Vec8d, NORM_LH, true>;
ASSERT(0);
break;
}
}
Expand Down

0 comments on commit d231343

Please sign in to comment.