Ignore:
Timestamp:
06/06/17 15:12:34 (7 years ago)
Author:
yushan
Message:

test_remap OK with openmp

Location:
XIOS/dev/branch_yushan_merged/src/transformation
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.cpp

    r1153 r1155  
    1111//std::map<StdString,EReductionType> CReductionAlgorithm::ReductionOperations = std::map<StdString,EReductionType>(); 
    1212std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr = 0;  
    13  
    14 bool CReductionAlgorithm::initReductionOperation(std::map<StdString,EReductionType>& m) 
    15 { 
    16   // So so stupid way to intialize operation but it works ... 
    17   m["sum"] = TRANS_REDUCE_SUM; 
    18   CSumReductionAlgorithm::registerTrans(); 
    19  
    20   m["min"] = TRANS_REDUCE_MIN; 
    21   CMinReductionAlgorithm::registerTrans(); 
    22  
    23   m["max"] = TRANS_REDUCE_MAX; 
    24   CMaxReductionAlgorithm::registerTrans(); 
    25  
    26   m["extract"] = TRANS_REDUCE_EXTRACT; 
    27   CExtractReductionAlgorithm::registerTrans(); 
    28  
    29   m["average"] = TRANS_REDUCE_AVERAGE; 
    30   CAverageReductionAlgorithm::registerTrans(); 
    31 } 
     13//#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr) 
    3214 
    3315 
    3416bool CReductionAlgorithm::initReductionOperation() 
    3517{ 
    36   if(CReductionAlgorithm::ReductionOperations_ptr == NULL) CReductionAlgorithm::ReductionOperations_ptr = new std::map<StdString,EReductionType>(); 
     18  CReductionAlgorithm::ReductionOperations_ptr = new std::map<StdString,EReductionType>(); 
    3719  // So so stupid way to intialize operation but it works ... 
    3820  (*CReductionAlgorithm::ReductionOperations_ptr)["sum"] = TRANS_REDUCE_SUM; 
     
    5032  (*CReductionAlgorithm::ReductionOperations_ptr)["average"] = TRANS_REDUCE_AVERAGE; 
    5133  CAverageReductionAlgorithm::registerTrans(); 
    52  
    53   printf("*CReductionAlgorithm::ReductionOperations_ptr = %p\t %p\n", *CReductionAlgorithm::ReductionOperations_ptr, &(*CReductionAlgorithm::ReductionOperations_ptr)); 
    5434} 
    5535 
    5636//bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(CReductionAlgorithm::ReductionOperations); 
    57 bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 
     37//bool CReductionAlgorithm::_dummyInit = CReductionAlgorithm::initReductionOperation(); 
    5838 
    5939CReductionAlgorithm* CReductionAlgorithm::createOperation(EReductionType reduceType) 
    6040{ 
    6141  int reduceTypeInt = reduceType; 
    62   //if (0 == reductionCreationCallBacks_) 
    63   //  reductionCreationCallBacks_ = new CallBackMap(); 
    6442 
    6543  CallBackMap::const_iterator it = (*reductionCreationCallBacks_).find(reduceType); 
  • XIOS/dev/branch_yushan_merged/src/transformation/Functions/reduction.hpp

    r1134 r1155  
    2828 
    2929public: 
    30   CReductionAlgorithm() {} 
     30  CReductionAlgorithm() { } 
    3131 
    3232  /*! 
  • XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.cpp

    r1134 r1155  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
    15 #include "reduction.hpp" 
    1615 
    1716namespace xios { 
     
    6261 
    6362  pos_ = algo->position; 
     63 
     64  if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     65    CReductionAlgorithm::initReductionOperation(); 
     66 
    6467  reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
    6568} 
  • XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_extract_domain.hpp

    r1076 r1155  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
     14#include "reduction.hpp" 
    1415 
    1516namespace xios { 
     
    2526  Extract a domain to an axis 
    2627*/ 
    27 class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation 
     28class CAxisAlgorithmExtractDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm 
    2829{ 
    2930public: 
  • XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.cpp

    r1134 r1155  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
    15 #include "reduction.hpp" 
    1615 
    1716namespace xios { 
     
    7069 
    7170  dir_ = (CReduceDomainToAxis::direction_attr::iDir == algo->direction)  ? iDir : jDir; 
     71 
     72  if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     73    CReductionAlgorithm::initReductionOperation(); 
     74 
    7275  reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
    7376} 
  • XIOS/dev/branch_yushan_merged/src/transformation/axis_algorithm_reduce_domain.hpp

    r1076 r1155  
    1212#include "axis_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
     14#include "reduction.hpp" 
    1415 
    1516namespace xios { 
     
    2425  Reduce a domain to an axis 
    2526*/ 
    26 class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation 
     27class CAxisAlgorithmReduceDomain : public CAxisAlgorithmTransformation, public CReductionAlgorithm 
    2728{ 
    2829public: 
  • XIOS/dev/branch_yushan_merged/src/transformation/domain_algorithm_interpolate.cpp

    r1149 r1155  
    111111  const int constNVertex = 4; // Value by default number of vertex for rectangular domain 
    112112  int nVertexSrc, nVertexDest; 
    113   nVertexSrc = nVertexDest = constNVertex; 
     113  nVertexSrc = constNVertex; 
     114  nVertexDest = constNVertex; 
    114115 
    115116  // First of all, try to retrieve the boundary values of domain source and domain destination 
  • XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.cpp

    r1134 r1155  
    1414#include "grid_transformation_factory_impl.hpp" 
    1515 
    16 #include "reduction.hpp" 
     16 
    1717 
    1818namespace xios { 
     
    4949  StdString op = "extract"; 
    5050  pos_ = algo->position; 
     51   
     52  if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     53    CReductionAlgorithm::initReductionOperation(); 
     54   
    5155  reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
    5256} 
  • XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_extract_axis.hpp

    r1076 r1155  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
     14#include "reduction.hpp" 
    1415 
    1516namespace xios { 
     
    2425  Extract a scalar from an axis 
    2526*/ 
    26 class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation 
     27class CScalarAlgorithmExtractAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
    2728{ 
    2829public: 
  • XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.cpp

    r1153 r1155  
    1313#include "grid.hpp" 
    1414#include "grid_transformation_factory_impl.hpp" 
    15 #include "reduction.hpp" 
    16  
    17 #include "reduction.hpp" 
    1815 
    1916namespace xios { 
     17 
     18//extern std::map<StdString,EReductionType> *CReductionAlgorithm::ReductionOperations_ptr;  
     19//#pragma omp threadprivate(CReductionAlgorithm::ReductionOperations_ptr) 
     20 
    2021CGenericAlgorithmTransformation* CScalarAlgorithmReduceAxis::create(CGrid* gridDst, CGrid* gridSrc, 
    2122                                                                     CTransformation<CScalar>* transformation, 
     
    7576  } 
    7677   
    77   //if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
    78   //  if ((CReductionAlgorithm::ReductionOperations_ptr)->end() == (CReductionAlgorithm::ReductionOperations_ptr)->find(op)) 
    79   //  ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
    80   //     << "Operation '" << op << "' not found. Please make sure to use a supported one" 
    81   //     << "Axis source " <<axisSource->getId() << std::endl 
    82   //     << "Scalar destination " << scalarDestination->getId()); 
     78  if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     79    CReductionAlgorithm::initReductionOperation(); 
     80   
     81  if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
     82    ERROR("CScalarAlgorithmReduceAxis::CScalarAlgorithmReduceAxis(CAxis* axisDestination, CAxis* axisSource, CReduceAxisToScalar* algo)", 
     83       << "Operation '" << op << "' not found. Please make sure to use a supported one" 
     84       << "Axis source " <<axisSource->getId() << std::endl 
     85       << "Scalar destination " << scalarDestination->getId()); 
    8386 
    8487  reduction_ = CReductionAlgorithm::createOperation((*CReductionAlgorithm::ReductionOperations_ptr)[op]); 
  • XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_axis.hpp

    r1082 r1155  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
     14#include "reduction.hpp" 
    1415 
    1516namespace xios { 
     
    2425  Reducing an axis to a scalar 
    2526*/ 
    26 class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation 
     27class CScalarAlgorithmReduceAxis : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
    2728{ 
    2829public: 
  • XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.cpp

    r1134 r1155  
    1414#include "grid_transformation_factory_impl.hpp" 
    1515 
    16 #include "reduction.hpp" 
     16 
    1717 
    1818namespace xios { 
     
    6868 
    6969  } 
    70    
     70 
     71  if(CReductionAlgorithm::ReductionOperations_ptr == 0)  
     72    CReductionAlgorithm::initReductionOperation(); 
     73 
    7174  if ((*CReductionAlgorithm::ReductionOperations_ptr).end() == (*CReductionAlgorithm::ReductionOperations_ptr).find(op)) 
    7275    ERROR("CScalarAlgorithmReduceDomain::CScalarAlgorithmReduceDomain(CDomain* domainDestination, CDomain* domainSource, CReduceDomainToScalar* algo)", 
  • XIOS/dev/branch_yushan_merged/src/transformation/scalar_algorithm_reduce_domain.hpp

    r1076 r1155  
    1212#include "scalar_algorithm_transformation.hpp" 
    1313#include "transformation.hpp" 
     14#include "reduction.hpp" 
    1415 
    1516namespace xios { 
     
    2425  Reducing an DOMAIN to a scalar 
    2526*/ 
    26 class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation 
     27class CScalarAlgorithmReduceDomain : public CScalarAlgorithmTransformation, public CReductionAlgorithm 
    2728{ 
    2829public: 
Note: See TracChangeset for help on using the changeset viewer.