Ignore:
Timestamp:
04/22/13 18:03:21 (12 years ago)
Author:
Eric.Larour
Message:

CHG: finished Assemble routine using non-synchronous I/O.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/objects/Bucket.h

    r14685 r14709  
    1010#include "./Object.h"
    1111#include "../../shared/Alloc/alloc.h"
     12#include "../../Container/DataSet.h"
     13#include "../../toolkits/toolkitsenums.h"
    1214/*}}}*/
     15
     16#define BUCKETSIZEOFREQUESTS 6 /*how many MPI_Isend requests does it take to transfer the contents of a bucket to another cpu?*/
    1317
    1418template <class doubletype> class Bucket: public Object{
     
    2529       
    2630                /*constructors, destructors: */
     31                Bucket(){ /*{{{*/
     32                        this->m=0;
     33                        this->n=0;
     34                        this->idxm=NULL;
     35                        this->idxn=NULL;
     36                        this->values=NULL;
     37                        mode=INS_VAL;
     38                } /*}}}*/
    2739                Bucket(int min,int* idxmin,int nin,int* idxnin,doubletype* valuesin,InsMode modein){ /*{{{*/
    2840                        this->m=min;
     
    7991                        _error_("Not implemented yet (similar to Elements)"); };
    8092                /*}}}*/
     93               
     94                /*specific routines of Bucket: */
     95                void SpawnBucketsPerCpu(DataSet* bucketsofcpu_i,int rank_i,int* rowranks){ /*{{{*/
     96
     97                        int i,j;
     98
     99                        /*go through our idxm index of rows this bucket owns, and spawn buckets 
     100                         *if these rows belong to cpu rank_i. Use rowranks to determine this.*/
     101                        for(i=0;i<m;i++){
     102                                if (rowranks[idxm[i]]==rank_i){
     103                                        /*This row belongs to cpu rank_i, so spawn a bucket with this row, and add it to the bucketsofcpu_i dataset: */
     104                                        bucketsofcpu_i->AddObject(new Bucket(1,idxm+i,n,idxn,values+n*i,mode));
     105                                }
     106                        }
     107
     108                };
     109                /*}}}*/
     110                void SetLocalMatrixValues(double* local_matrix,int lower_row,int global_N){ /*{{{*/
     111
     112                        int i,j;
     113                        for(i=0;i<m;i++){
     114                                for(j=0;j<n;j++){
     115                                        *(local_matrix+global_N*(idxm[i]-lower_row)+idxn[j])=*(values+n*i+j);
     116                                }
     117                        }
     118                       
     119                };
     120                /*}}}*/
     121                void Isend(int receiver_rank,MPI_Request* requests,int* pcount,MPI_Comm comm){ /*{{{*/
     122                        int count=0;
     123                        int int_mode;
     124
     125                        /*Recover pointer: */
     126                        count=*pcount;
     127
     128                        /*Send all the information required: */
     129                        MPI_Isend(&m,1,MPI_INT,receiver_rank,2,comm,requests+count); count++;
     130                        if(m){ MPI_Isend(idxm,m,MPI_INT,receiver_rank,3,comm,requests+count); count++; }
     131                        MPI_Isend(&n,1,MPI_INT,receiver_rank,4,comm,requests+count); count++;
     132                        if(n){ MPI_Isend(idxn,n,MPI_INT,receiver_rank,5,comm,requests+count); count++; }
     133                        if(m*n){ MPI_Isend(values,m*n,MPI_DOUBLE,receiver_rank,6,comm,requests+count); count++; }
     134                        int_mode=(int)mode;
     135                        MPI_Isend(&int_mode,1,MPI_INT,receiver_rank,7,comm,requests+count); count++;
     136
     137                        /*Allocate pointers: */
     138                        *pcount=count;
     139
     140                } /*}}}*/
     141                void Recv(int sender_rank, MPI_Comm comm){ /*{{{*/
     142
     143                        MPI_Status status;
     144                        int int_mode;
     145
     146                        MPI_Recv(&m,1, MPI_INT,sender_rank,2, comm, &status);
     147                        if(m){
     148                                idxm=new int[m];
     149                                MPI_Recv(idxm,m, MPI_INT,sender_rank,3, comm, &status);
     150                        }
     151                        MPI_Recv(&n,1, MPI_INT,sender_rank,4, comm, &status);
     152                        if(n){
     153                                idxn=new int[n];
     154                                MPI_Recv(idxn,n, MPI_INT,sender_rank,5, comm, &status);
     155                        }
     156                        if(m*n){
     157                                values=new doubletype[m*n];
     158                                MPI_Recv(values,m*n, MPI_DOUBLE,sender_rank,6, comm, &status);
     159                        }
     160                        MPI_Recv(&int_mode,1, MPI_INT,sender_rank,7, comm, &status);
     161                        mode=(InsMode)int_mode;
     162
     163                } /*}}}*/
    81164};
    82165
Note: See TracChangeset for help on using the changeset viewer.