Ignore:
Timestamp:
Apr 10, 2012, 1:55:49 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
a40eea
Parents:
d24c2f
Message:

Merge recent changes of the vmg library into ScaFaCos.

Includes a fix for the communication problems on Jugene.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1666 5161e1c8-67bf-11de-9fd5-51895aff932f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/comm/mpi/datatype.hpp

    rd24c2f rac6d04  
    11#ifndef DATATYPE_HPP_
    22#define DATATYPE_HPP_
     3
     4#include <vector>
    35
    46#include "base/index.hpp"
     
    2931    _rank(rank),
    3032    _tag_send(tag_send),
    31     _tag_recv(tag_receive)
     33    _tag_recv(tag_receive),
     34    _buffer(subsizes.Product())
    3235  {
    33     if (_sizes.Product() > 0 && _subsizes.Product() > 0) {
    34       MPI_Type_create_subarray(3, _sizes.vec(), _subsizes.vec(), _starts.vec(), MPI_ORDER_C, MPI_DOUBLE, &_type);
    35       MPI_Type_commit(&_type);
    36     }else {
    37       _type = MPI_DATATYPE_NULL;
    38     }
     36    InitDatatype();
    3937  }
    4038
     
    4644    _rank(rank),
    4745    _tag_send(tag_send),
    48     _tag_recv(tag_receive)
     46    _tag_recv(tag_receive),
     47    _buffer(_subsizes.Product())
    4948  {
    50     if (_sizes.Product() > 0 && _subsizes.Product() > 0) {
    51       MPI_Type_create_subarray(3, _sizes.vec(), _subsizes.vec(), _starts.vec(), MPI_ORDER_C, MPI_DOUBLE, &_type);
    52       MPI_Type_commit(&_type);
    53     }else {
    54       _type = MPI_DATATYPE_NULL;
    55     }
     49    InitDatatype();
    5650  }
    5751
     
    6256    _rank(other._rank),
    6357    _tag_send(other._tag_send),
    64     _tag_recv(other._tag_recv)
     58    _tag_recv(other._tag_recv),
     59    _buffer(_subsizes.Product())
    6560  {
    66     if (_sizes.Product() > 0 && _subsizes.Product() > 0) {
    67       MPI_Type_create_subarray(3, _sizes.vec(), _subsizes.vec(), _starts.vec(), MPI_ORDER_C, MPI_DOUBLE, &_type);
    68       MPI_Type_commit(&_type);
    69     }else {
    70       _type = MPI_DATATYPE_NULL;
    71     }
    72   }
    73 
    74   void Set(const GridIteratorSet& bounds, const Grid& grid, const int& rank,
    75            const int& tag_send, const int& tag_receive)
    76   {
    77     _sizes = grid.Local().SizeTotal();
    78     _subsizes = bounds.Begin().GetEnd() - bounds.Begin().GetBegin();
    79     _starts = bounds.Begin().GetBegin();
    80     _rank = rank;
    81     _tag_send = tag_send;
    82     _tag_recv = tag_receive;
    83 
    84     if (_sizes.Product() > 0 && _subsizes.Product() > 0) {
    85       MPI_Type_create_subarray(3, _sizes.vec(), _subsizes.vec(), _starts.vec(), MPI_ORDER_C, MPI_DOUBLE, &_type);
    86       MPI_Type_commit(&_type);
    87     }else {
    88       _type = MPI_DATATYPE_NULL;
    89     }
    90   }
    91 
    92   void Set(const Index& sizes, const Index& subsizes, const Index& starts, const int& rank,
    93            const int& tag_send, const int& tag_receive)
    94   {
    95     _sizes = sizes;
    96     _subsizes = subsizes;
    97     _starts = starts;
    98     _rank = rank;
    99     _tag_send = tag_send;
    100     _tag_recv = tag_receive;
    101 
    102     if (_sizes.Product() > 0 && _subsizes.Product() > 0) {
    103       MPI_Type_create_subarray(3, _sizes.vec(), _subsizes.vec(), _starts.vec(), MPI_ORDER_C, MPI_DOUBLE, &_type);
    104       MPI_Type_commit(&_type);
    105     }else {
    106       _type = MPI_DATATYPE_NULL;
    107     }
     61    InitDatatype();
    10862  }
    10963
     
    11468  }
    11569
    116   Index& Sizes() {return _sizes;}
    117   Index& Subsizes() {return _subsizes;}
    118   Index& Starts() {return _starts;}
     70  void Set(const GridIteratorSet& bounds, const Grid& grid, const int& rank,
     71           const int& tag_send, const int& tag_receive);
     72
     73  void Set(const Index& sizes, const Index& subsizes, const Index& starts, const int& rank,
     74           const int& tag_send, const int& tag_receive);
     75
     76  const Index& Sizes() const {return _sizes;}
     77  const Index& Subsizes() const {return _subsizes;}
     78  const Index& Starts() const {return _starts;}
     79
    11980  const int& Rank() const {return _rank;}
    12081  const int& TagSend() const {return _tag_send;}
    12182  const int& TagReceive() const {return _tag_recv;}
    122   MPI_Datatype Type() const {return _type;}
     83
     84  const MPI_Datatype& Type() const {return _type;}
     85
     86  const std::vector<vmg_float>& Buffer() const {return _buffer;}
     87
     88  void Send(Grid& grid, const int& tag, const MPI_Comm& comm) const;
     89  void Isend(Grid& grid, const int& tag, const MPI_Comm& comm, MPI_Request& request) const;
     90  void Recv(Grid& grid, const int& tag, const MPI_Comm& comm) const;
     91  void Irecv(Grid& grid, const int& tag, const MPI_Comm& comm, MPI_Request& request) const;
     92
     93  void SendBuffered(const Grid& grid, const int& tag, const MPI_Comm& comm);
     94  void IsendBuffered(const Grid& grid, const int& tag, const MPI_Comm& comm, MPI_Request& request);
     95  void RecvBuffered(const int& tag, const MPI_Comm& comm);
     96  void IrecvBuffered(const int& tag, const MPI_Comm& comm, MPI_Request& request);
     97
     98  void GridReplace(Grid& grid) const;
     99  void GridSum(Grid& grid) const;
    123100
    124101  bool Feasible() const
     
    127104  }
    128105
    129   int Size() const
    130   {
    131     return _subsizes.Product();
    132   }
     106private:
     107  void InitDatatype();
    133108
    134 private:
    135109  Index _sizes, _subsizes, _starts;
    136110  int _rank, _tag_send, _tag_recv;
    137111  MPI_Datatype _type;
     112  std::vector<vmg_float> _buffer;
    138113};
    139114
Note: See TracChangeset for help on using the changeset viewer.