operator()(const OLattice<T1> & l)
operator()(const OScalar<T1> & l)
  operator()(const OLattice<T1> & l)    {      QDP_info("Map()");      OLattice<T1> d;//    fprintf(stderr,"Here a\n");//    fprintf(stderr,"Here c: offnodeP = %d\n",offnodeP);      if (offnodeP)      {	// Off-node communications required	QDP_info("Map: off-node communications required");	// Eventually these declarations should move into d - the return object	typedef T1 * T1ptr;	T1 **dest = new T1ptr[Layout::subgridVol()];	QMP_msgmem_t msg[2];	QMP_msghandle_t mh_a[2], mh;	// For now, will assume there is only 1 destination node 	// and receive from only 1 node	if (srcenodes.size() != 1)	  QMP_error_exit("Map: for now only allow 1 destination node");      	if (destnodes.size() != 1)	  QMP_error_exit("Map: for now only allow receives from 1 node");      	int dstnum = destnodes_num[0]*sizeof(T1);	int srcnum = srcenodes_num[0]*sizeof(T1);	T1 *send_buf = (T1 *)(QMP_allocate_aligned_memory(dstnum)); // packed data to send	T1 *recv_buf = (T1 *)(QMP_allocate_aligned_memory(srcnum)); // packed receive data	// Gather the face of data to send	// For now, use the all subset	const int my_node = Layout::nodeNumber();	for(int i=0, si=0, ri=0; i < Layout::subgridVol(); ++i) 	{	  if (dstnode[i] != my_node)	    send_buf[si++] = l.elem(i);	  if (srcnode[i] != my_node)	  {//	    QDP_info("Map_gather_send(olattice[%d],olattice[%d])",i,ri);	    dest[i] = &(recv_buf[ri++]);	  }	  else	  {//	    QDP_info("Map_gather_onnode(olattice[%d],olattice[%d])",i,soffsets[i]);	    dest[i] = &(const_cast<T1&>(l.elem(soffsets[i])));	  }	}	QMP_status_t err;	QDP_info("Map: send = 0x%x  recv = 0x%x",send_buf,recv_buf);	msg[0]  = QMP_declare_msgmem(recv_buf, srcnum);	msg[1]  = QMP_declare_msgmem(send_buf, dstnum);	mh_a[0] = QMP_declare_receive_from(msg[0], srcenodes[0], 0);	mh_a[1] = QMP_declare_send_to(msg[1], destnodes[0], 0);	mh      = QMP_declare_multiple(mh_a, 2);	QDP_info("Map: calling start send=%d recv=%d",destnodes[0],srcenodes[0]);	// Launch the faces	if ((err = QMP_start(mh)) != QMP_SUCCESS)	  QMP_error_exit(QMP_error_string(err));	QDP_info("Map: calling wait");	// Wait on the faces	if ((err = QMP_wait(mh)) != QMP_SUCCESS)	  QMP_error_exit(QMP_error_string(err));	QDP_info("Map: calling free msgs");	QMP_free_msghandle(mh_a[1]);	QMP_free_msghandle(mh_a[0]);	QMP_free_msghandle(mh);	QMP_free_msgmem(msg[1]);	QMP_free_msgmem(msg[0]);	// Scatter the data into the destination	// Some of the data maybe in receive buffers	// For now, use the all subset	for(int i=0; i < Layout::subgridVol(); ++i) 	{//	  QDP_info("Map_scatter(olattice[%d],olattice[0x%x])",i,dest[i]);	  d.elem(i) = *(dest[i]);	}	QDP_info("finished scatter");	// Cleanup	QMP_free_aligned_memory(recv_buf);	QMP_free_aligned_memory(send_buf);	delete dest;	QDP_info("finished cleanup");      }      else       {	// No off-node communications - copy on node	QDP_info("Map: copy on node - no communications");	// For now, use the all subset	for(int i=0; i < Layout::subgridVol(); ++i) 	{//	  QDP_info("Map(olattice[%d],olattice[%d])",i,soffsets[i]);	  d.elem(i) = l.elem(soffsets[i]);	}      }      QDP_info("exiting Map()");      return d;    }