10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
19 #include "../shared/shared.h"
28 this->common_recv = NULL;
29 this->common_recv_ids = NULL;
30 this->common_send = NULL;
31 this->common_send_ids = NULL;
32 this->numberofvertices = -1;
33 this->numberofvertices_local = -1;
34 this->numberofmasters_local = -1;
42 if(this->common_recv) xDelete<int>(common_recv);
43 if(this->common_send) xDelete<int>(common_send);
44 if(this->common_recv_ids){
45 for(
int i=0;i<num_proc;i++) if(common_recv_ids[i]) xDelete<int>(common_recv_ids[i]);
46 xDelete<int*>(common_recv_ids);
48 if(this->common_send_ids){
49 for(
int i=0;i<num_proc;i++) if(common_send_ids[i]) xDelete<int>(common_send_ids[i]);
50 xDelete<int*>(common_send_ids);
63 output->
sorted = this->sorted;
66 for(vector<Object*>::iterator obj=this->objects.begin() ; obj < this->objects.end(); obj++ ) output->
AddObject((*obj)->copy());
71 int objsize = this->numsorted;
72 if(this->sorted && objsize>0 && this->id_offsets){
74 xMemCpy<int>(output->
id_offsets,this->id_offsets,objsize);
76 if(this->sorted && objsize>0 && this->sorted_ids){
78 xMemCpy<int>(output->
sorted_ids,this->sorted_ids,objsize);
86 if(this->common_recv){
88 for(
int i=0;i<num_proc;i++) output->
common_recv[i]=this->common_recv[i];
90 if(this->common_send){
92 for(
int i=0;i<num_proc;i++) output->
common_send[i]=this->common_send[i];
94 if(this->common_recv_ids){
96 for(
int i=0;i<num_proc;i++){
98 for(
int j=0;j<this->common_recv[i];j++) output->
common_recv_ids[i][j]=this->common_recv_ids[i][j];
101 if(this->common_send_ids){
103 for(
int i=0;i<num_proc;i++){
105 for(
int j=0;j<this->common_send[i];j++) output->
common_send_ids[i][j]=this->common_send_ids[i][j];
115 int test = num_procs;
121 if(test!=num_procs)
_error_(
"number of cores is not the same as before");
125 this->common_recv_ids = xNew<int*>(num_procs);
126 this->common_send_ids = xNew<int*>(num_procs);
128 for(
int i=0;i<num_procs;i++){
144 int num_vertices=this->NumberOfVertices();
151 for(
int i=0;i<this->Size();i++){
152 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
188 this->numberofvertices_local=this->Size();
189 this->numberofmasters_local=0;
190 for(
int i=0;i<this->Size();i++){
191 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
192 if(!vertex->
clone) this->numberofmasters_local++;
198 for(
int i=0;i<this->numberofvertices;i++) iomodel->
my_vertices_lids[i] = -1;
201 for(
int i=0;i<this->Size();i++){
202 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
209 for(
int i=0;i<this->Size();i++){
210 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
219 int* all_num_masters=xNew<int>(num_procs);
223 for(
int i=0;i<my_rank;i++) offset+=all_num_masters[i];
224 xDelete<int>(all_num_masters);
226 for(
int i=0;i<this->Size();i++){
227 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
228 vertex->
pid = vertex->
lid+offset;
232 int* truepids = xNew<int>(this->Size());
233 for(
int rank=0;rank<num_procs;rank++){
234 if(this->common_send[rank]){
235 int numids = this->common_send[rank];
236 for(
int i=0;i<numids;i++){
237 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(this->common_send_ids[rank][i]));
238 truepids[i] = vertex->
pid;
243 for(
int rank=0;rank<num_procs;rank++){
244 if(this->common_recv[rank]){
245 int numids = this->common_recv[rank];
247 for(
int i=0;i<numids;i++){
248 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(this->common_recv_ids[rank][i]));
249 vertex->
pid = truepids[i];
253 xDelete<int>(truepids);
256 return this->numberofvertices;
259 return this->numberofmasters_local;
262 return this->numberofvertices_local;