Changeset 1155


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

test_remap OK with openmp

Location:
XIOS/dev/branch_yushan_merged
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.cpp

    r688 r1155  
    1111 
    1212CRemapGrid srcGrid; 
     13#pragma omp threadprivate(srcGrid) 
     14 
    1315CRemapGrid tgtGrid; 
     16#pragma omp threadprivate(tgtGrid) 
    1417 
    1518} 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/gridRemap.hpp

    r688 r1155  
    1414Coord readPole(std::istream&); 
    1515 
    16 extern CRemapGrid srcGrid; 
    17 extern CRemapGrid tgtGrid; 
     16 
    1817 
    1918} 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/intersect.cpp

    r1153 r1155  
    1616 
    1717using namespace std; 
     18 
     19extern CRemapGrid srcGrid; 
     20#pragma omp threadprivate(srcGrid) 
     21 
     22extern CRemapGrid tgtGrid; 
     23#pragma omp threadprivate(tgtGrid) 
    1824 
    1925/** returns index of edge of a that is shared with b, 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/intersection_ym.cpp

    r849 r1155  
    1616using namespace std; 
    1717using namespace ClipperLib ; 
     18 
     19extern CRemapGrid srcGrid; 
     20#pragma omp threadprivate(srcGrid) 
     21 
     22extern CRemapGrid tgtGrid; 
     23#pragma omp threadprivate(tgtGrid) 
    1824 
    1925double intersect_ym(Elt *a, Elt *b) 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/libmapper.cpp

    r694 r1155  
    1414#include "mapper.hpp" 
    1515#include "cputime.hpp" // cputime 
     16#include "gridRemap.hpp" 
    1617 
    1718using namespace sphereRemap ; 
     19 
     20extern CRemapGrid srcGrid; 
     21#pragma omp threadprivate(srcGrid) 
     22 
     23extern CRemapGrid tgtGrid; 
     24#pragma omp threadprivate(tgtGrid) 
     25 
    1826 
    1927/* mapper is a ponter to a global class instance whoes members are allocated in the first step (finding the sizes of the weight arrays) 
    2028   and deallocated during the second step (computing the weights) */ 
    2129Mapper *mapper; 
    22  
     30#pragma omp threadprivate(mapper) 
    2331 
    2432/** xxx_bounds_yyy is of length n_vert_per_cell_xxx*n_cell_xxx 
     
    148156        char **argv = NULL; 
    149157        MPI_Init(&argc, &argv);*/ 
    150         MPI_Init(NULL, NULL); 
     158        //MPI_Init(NULL, NULL); 
     159        int provided; 
     160        MPI_Init_thread(NULL, NULL, 3, &provided); 
     161        assert(provided >= 3); 
    151162} 
    152163 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/mapper.cpp

    r1153 r1155  
    1414 
    1515namespace sphereRemap { 
     16 
     17extern CRemapGrid srcGrid; 
     18#pragma omp threadprivate(srcGrid) 
     19 
     20extern CRemapGrid tgtGrid; 
     21#pragma omp threadprivate(tgtGrid) 
    1622 
    1723/* A subdivition of an array into N sub-arays 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/node.cpp

    r923 r1155  
    254254NodePtr insert(NodePtr thIs, NodePtr node) 
    255255{ 
    256         int la = thIs->level; // node to be inserted 
    257         int lb = node->level; // node where insertation 
    258         assert(la < lb); // node to be inserted must have lower level then parent 
    259         //if (thIs->parent) assert(find_in_tree1(thIs) == true); 
    260         NodePtr q = NULL; 
    261         NodePtr chd = NULL; 
    262         node->move(thIs); 
    263         if (la == lb - 1) 
    264         { 
     256  int la = thIs->level; // node to be inserted 
     257  int lb = node->level; // node where insertation 
     258  assert(la < lb); // node to be inserted must have lower level then parent 
     259  //if (thIs->parent) assert(find_in_tree1(thIs) == true); 
     260  NodePtr q = NULL; 
     261  NodePtr chd = NULL; 
     262  node->move(thIs); 
     263  if (la == lb - 1) 
     264  { 
    265265    node->child.push_back(thIs); 
    266                 thIs->parent = node; 
    267                 if (node->child.size() > MAX_NODE_SZ &&  node->tree->canSplit() ) // with us as additional child `node` is now too large :( 
    268                         return (node->reinserted || node->parent == NULL) ? split(node) : reinsert(node); 
    269         } 
    270         else // la < lb - 1 
    271         { 
    272                 chd = thIs->closest(node->child); 
    273                 q = insert(thIs, chd); 
    274         } 
    275         if ((node->updateCount + 1) % UPDATE_EVERY == 0) 
    276                 node->update(); 
    277         else 
    278         { 
    279                 if (q) node->remove(q); 
    280                 node->inflate(chd); 
    281         } 
    282  
     266    thIs->parent = node; 
     267    if (node->child.size() > MAX_NODE_SZ &&  node->tree->canSplit() ) // with us as additional child `node` is now too large :( 
     268    return (node->reinserted || node->parent == NULL) ? split(node) : reinsert(node); 
     269  } 
     270  else // la < lb - 1 
     271  { 
     272    chd = thIs->closest(node->child); 
     273    q = insert(thIs, chd); 
     274  } 
     275  if ((node->updateCount + 1) % UPDATE_EVERY == 0) 
     276    node->update(); 
     277  else 
     278  { 
     279    if (q) node->remove(q); 
     280    node->inflate(chd); 
     281  } 
    283282 
    284283  return q; 
  • XIOS/dev/branch_yushan_merged/extern/remap/src/parallel_tree.cpp

    r923 r1155  
    1616 
    1717static const int assignLevel = 2; 
     18 
     19extern CRemapGrid srcGrid; 
     20#pragma omp threadprivate(srcGrid) 
     21 
     22extern CRemapGrid tgtGrid; 
     23#pragma omp threadprivate(tgtGrid) 
    1824 
    1925// only the circle is packed, rest of node will be initialized on unpacking 
  • XIOS/dev/branch_yushan_merged/inputs/REMAP/iodef.xml

    r1076 r1155  
    6767      </file_group> 
    6868     <file_group id="read_then_write_files" enabled=".TRUE."> 
    69        <file id="output_regular_pole" name="output_dst_regular" > 
     69       <file id="output_regular_pole" name="output_dst_regular" enabled=".FALSE." > 
    7070          <field field_ref="tmp_field_0" name="field_regular_0" /> 
    7171          <field field_ref="dst_field_regular" name="field_regular" /> 
  • XIOS/dev/branch_yushan_merged/src/node/field.cpp

    r1153 r1155  
    292292    while (currentDate >= lastDataRequestedFromServer) 
    293293    { 
    294       info(20) << "currentDate : " << currentDate << endl ; 
    295       info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ; 
    296       info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ; 
    297       info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ; 
    298  
     294      #pragma omp critical (_output) 
     295      { 
     296        info(20) << "currentDate : " << currentDate << endl ; 
     297        info(20) << "lastDataRequestedFromServer : " << lastDataRequestedFromServer << endl ; 
     298        info(20) << "file->output_freq.getValue() : " << file->output_freq.getValue() << endl ; 
     299        info(20) << "lastDataRequestedFromServer + file->output_freq.getValue() : " << lastDataRequestedFromServer + file->output_freq << endl ; 
     300      } 
    299301      dataRequested |= sendReadDataRequest(lastDataRequestedFromServer + file->output_freq); 
    300302    } 
  • 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.