- int getDistantDomain(int i)
- {
- if (_domains==0)
- computeNumbers();
-
- return _domains[i];
- }
-
- int getNbDistantElems(int i)
- {
- if (_numbers==0)
- computeNumbers();
- return _numbers[i];
- }
-
- int* serialize(int idproc)
- {
- _comm_buffer=new int[_mapping.size()*2];
- std::vector<int> offsets(_distant_domains.size());
- offsets[0]=0;
- for (int i=1; i<_distant_domains.size();i++)
- offsets[i]=offsets[i-1]+_numbers[i-1];
-
- for (int i=0; i< _mapping.size(); i++)
- {
- int offset= offsets[_mapping[i].first];
- _comm_buffer[offset*2]=idproc;
- _comm_buffer[offset*2+1]=_mapping[i].second;
- offsets[_mapping[i].first]++;
- }
- return _comm_buffer;
- }
-
- void unserialize(int nbprocs, int* sizes,int nbtarget, int* targetrank, int* commbuffer)
- {
- int total_size=0;
- for (int i=0; i< nbprocs; i++)
- total_size+=sizes[i];
-
- _mapping.resize(total_size);
- _buffer_index=new int[total_size];
- int indmap=0;
- for (int i=0; i<nbprocs; i++)
- for (int ielem=0; ielem<sizes[i]; ielem++)
- {
- _mapping[indmap].first=i;
- _mapping[indmap].second=commbuffer[indmap*2+1];
- _buffer_index[indmap]=commbuffer[indmap*2+1];
- indmap++;
- }
- _numbers=new int [nbtarget];
- _domains=new int [nbtarget];
-
- int index=0;
- for (int i=0; i<nbtarget; i++)
- {
- if (sizes[targetrank[i]]>0)
- {
- _numbers[index]=sizes[targetrank[i]];
- _domains[index]=i;
- index++;
- }
- }
- _send_counts=new int[nbprocs];
- for (int i=0; i<nbprocs; i++)
- _send_counts[i]=sizes[i];
- }
-