title: Unable to send Array to correct destination processor in MPI
body: <p>I am trying to send an array to the different processors in the hypercube architecture. The problem is that it either doesn't send to all the processors or it sends to wrong processor. When I try to send a single integer it works correctly.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>void hypercube(int d,int my_id,int X[]){
    mask = (int)pow((double)2,d)-1;
   for(i = d-1;i&gt;=0;i--){
          //printf("before xor mask is %d and power is %d\n",mask,(int)pow((double)2,i));
          mask = xor(mask,(int)pow((double)2,i));
          //printf("After xor rank is %d and mask is %d\n",rank,mask);
          if(and(my_id, mask) == 0){
                  if(and(my_id,(int) pow((double)2,i)) == 0){
                          dest = xor(my_id,(int) pow((double)2,i));
                          printf("rank %d destination %d\n",rank,dest);
                          MPI_Send(&amp;X,8,MPI_INT,dest,tag,MPI_COMM_WORLD);;
                          //MPI_Send(&amp;X,1,MPI_INT,dest,tag,MPI_COMM_WORLD);
                          //printf("After sending from rank %d and destination is %d\n",my_id,dest);
                  }
                  else{
                          //printf("going to receive in a sec...\n");
                          source = xor(my_id,(int)pow((double)2,i));
                          MPI_Recv(&amp;X,8,MPI_INT,source,tag,MPI_COMM_WORLD,&amp;status);
                          //MPI_Recv(&amp;X,1,MPI_INT,source,tag,MPI_COMM_WORLD,&amp;status);
                          //printf("in rank %d with data %d\n",rank,X);
  
                  }
          }
    }
  }
  
  int main(int argc, char **argv){
  
  
    MPI_Init(&amp;argc,&amp;argv);
    MPI_Comm_size(MPI_COMM_WORLD,&amp;world_size);;
    MPI_Comm_rank(MPI_COMM_WORLD,&amp;rank);
  
  
    if(rank == master){
       //a[ARR_SIZE] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
       // q = 4;
    }
  
    hypercube(3,rank,a);
  
  
    return 0;
  }
  </code></pre>
  
  <p>Is there anything that I am not taking care of??</p>