From 790594f18cc64d4b436193b828a0326df367efc3 Mon Sep 17 00:00:00 2001 From: wcancino Date: Wed, 4 Mar 2009 14:21:19 +0000 Subject: [PATCH] FIrst intents of OpenMP implementation of the likelihood function git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1471 331e1502-861f-0410-8da2-ba01fb791d7f --- .../PhyloMOEA/PhyloMOEA/CMakeLists.txt | 18 ++++++++++++++ .../PhyloMOEA/likelihoodcalculator.cpp | 24 ++++++++++--------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/contribution/branches/PhyloMOEA/PhyloMOEA/CMakeLists.txt b/contribution/branches/PhyloMOEA/PhyloMOEA/CMakeLists.txt index 58858bef8..b1c5cc324 100644 --- a/contribution/branches/PhyloMOEA/PhyloMOEA/CMakeLists.txt +++ b/contribution/branches/PhyloMOEA/PhyloMOEA/CMakeLists.txt @@ -32,8 +32,26 @@ SET( PHYLOMOEA_SOURCES eigensolver.cpp utils.cpp PhyloMOEO_packunpack.cpp) +SET( TESTOMP_SOURCES eigensolver.cpp + likelihoodcalculator.cpp + matrixutils.cpp + probmatrixcontainer.cpp + ProbMatrix.cpp + RandomNr.cpp + Sequences.cpp + SubsModel.cpp + phylotreeIND.cpp + treeIterator.cpp + utils.cpp + likoptimizer.cpp + testomp.cpp +) + + ADD_EXECUTABLE( PhyloMOEA ${PHYLOMOEA_SOURCES} ) +ADD_EXECUTABLE( testomp ${TESTOMP_SOURCES} ) TARGET_LINK_LIBRARIES(PhyloMOEA gsl gslcblas GTL eo eoutils ga moeo cma peo rmc_mpi xml2) +TARGET_LINK_LIBRARIES(testomp gsl gslcblas GTL eo eoutils ga moeo cma peo rmc_mpi xml2 gomp) INSTALL( TARGETS PhyloMOEA RUNTIME DESTINATION bin) \ No newline at end of file diff --git a/contribution/branches/PhyloMOEA/PhyloMOEA/likelihoodcalculator.cpp b/contribution/branches/PhyloMOEA/PhyloMOEA/likelihoodcalculator.cpp index 5cb035476..b570997b9 100644 --- a/contribution/branches/PhyloMOEA/PhyloMOEA/likelihoodcalculator.cpp +++ b/contribution/branches/PhyloMOEA/PhyloMOEA/likelihoodcalculator.cpp @@ -449,23 +449,25 @@ double LikelihoodCalculator::sum_partials_a_to_b_notaxon( int pos) void LikelihoodCalculator::calculate_node_partial( node father, node son, edge edgeaux) { register double sum; - double corr_factor; - long index; - double len; - + int r,i,j; + //unsigned char l; + ProbMatrix *p; register int seqlen = tree_ptr->number_of_positions(); + #pragma omp parallel for private(p) schedule(dynamic) num_threads(2) for(int k=0; kget_branch_length(edgeaux) * rates_prob[r]; + double len = tree_ptr->get_branch_length(edgeaux) * rates_prob[r]; len = (len < BL_MIN ? BL_MIN : len); - ProbMatrix &p = (*probmatrixs)[ len ]; + double sum = 0; + #pragma omp critical + p = &((*probmatrixs)[ len ]); for(int i=0; i < 4; i++) { @@ -473,12 +475,12 @@ void LikelihoodCalculator::calculate_node_partial( node father, node son, edge e if(tree_ptr->istaxon( son)) { unsigned char l=SeqData->pattern_pos( k, tree_ptr->taxon_id( son)); - if(SeqData->is_defined( l) ) sum = p.p_ij_t( i, l ); + if(SeqData->is_defined( l) ) sum = p->p_ij_t( i, l ); else if(SeqData->is_ambiguous( l)) { unsigned char *meaning = SeqData->ambiguos_meaning( l); for(int j=0; j < 4; j++) - sum +=meaning[j]* p.p_ij_t( i, j ); + sum +=meaning[j]* p->p_ij_t( i, j ); //sum +=Partials[son][k*4+j]* p.p_ij_t( i, j ); } else sum = 1; @@ -486,7 +488,7 @@ void LikelihoodCalculator::calculate_node_partial( node father, node son, edge e else{ for(int j=0; j < 4; j++) { - sum +=Partials[son][index+ r*4 +j]* p.p_ij_t( i, j ); + sum +=Partials[son][index+ r*4 +j]* p->p_ij_t( i, j ); } }