コード例 #1
0
ファイル: glb_sum.C プロジェクト: DeanHowarth/QUDA-CPS
//---------------------------------------------------------------------- 
void glb_sum(Float * float_p)
{
  int NP[4] = {GJP.Xnodes(), GJP.Ynodes(), GJP.Znodes(), GJP.Tnodes()};

  gsum_buf = *float_p;

  for(int i = 0; i < 4; ++i) {

      transmit_buf = gsum_buf;

      for (int itmp = 1; itmp < NP[i]; itmp++) {
// If we are using the non-Tartan setup then GLOBALSUM_TYPE will be properly
// defined as a float or double native type:
#ifdef GLOBALSUM_TYPE
	SCUDirArg send(&transmit_buf, gjp_scu_dir[2*i], SCU_SEND, (sizeof(Double64)/COMMS_DATASIZE) );
	SCUDirArg rcv(&receive_buf, gjp_scu_dir[2*i+1], SCU_REC, (sizeof(Double64)/COMMS_DATASIZE) );
// If not, then sizeof(Double64) will break because it returns the pointer
// size (?, 4 bytes instead of 8??).
// FIXME:  There should be a more elegant solution to this problem.
#else
	SCUDirArg send(&transmit_buf, gjp_scu_dir[2*i], SCU_SEND, 2 );
	SCUDirArg rcv(&receive_buf, gjp_scu_dir[2*i+1], SCU_REC, 2 );
#endif

	SCUTrans(&send);
	SCUTrans(&rcv);

	SCUTransComplete();

        gsum_buf += receive_buf;
        transmit_buf = receive_buf;
      }
  }
  *float_p = gsum_buf;
}
コード例 #2
0
ファイル: glb_sum_five.C プロジェクト: DeanHowarth/QUDA-CPS
void glb_sum_five(Float * float_p)
{
  int NP[5] = {GJP.Xnodes(), GJP.Ynodes(), GJP.Znodes(), GJP.Tnodes(), GJP.Snodes()};


  // Sum over the "virtual" 5-dimensional mesh
  //------------------------------------------------------------
  gsum_buf = *float_p;

  int i;
  for(i = 0; i < 5; ++i) {

      transmit_buf = gsum_buf;

      for (int itmp = 1; itmp < NP[i]; itmp++) {
	SCUDirArg send(&transmit_buf, gjp_scu_dir[2*i], SCU_SEND, 2);
	SCUDirArg rcv(&receive_buf, gjp_scu_dir[2*i+1], SCU_REC, 2);

	SCUTrans(&send);
	SCUTrans(&rcv);

	SCUTransComplete();

        gsum_buf += receive_buf;
        transmit_buf = receive_buf;
      }
  }

  // Broadcast the result of node (0,0,0,0,0)
  //------------------------------------------------------------
  if(GJP.XnodeCoor() != 0 || 
     GJP.YnodeCoor() != 0 || 
     GJP.ZnodeCoor() != 0 || 
     GJP.TnodeCoor() != 0 || 
     GJP.SnodeCoor() != 0 ) {
    gsum_buf = 0;
  }

  for(i = 0; i < 5; ++i) {
    
      transmit_buf = gsum_buf;

      for (int itmp = 1; itmp < NP[i]; itmp++) {
	SCUDirArg send(&transmit_buf, gjp_scu_dir[2*i], SCU_SEND, 2);
	SCUDirArg rcv(&receive_buf, gjp_scu_dir[2*i+1], SCU_REC, 2);

	SCUTrans(&send);
	SCUTrans(&rcv);

	SCUTransComplete();

        gsum_buf += receive_buf;
        transmit_buf = receive_buf;
      }
  }

  *float_p = gsum_buf;
}
コード例 #3
0
void dummy_operations::run_collective_dummy_operations() {
        int rank, size;
        MPI_Comm_rank( MPI_COMM_WORLD, &rank);
        MPI_Comm_size( MPI_COMM_WORLD, &size);
        
        // Run Broadcast
        {
                int x;
                MPI_Comm_rank( MPI_COMM_WORLD, &x);
                MPI_Bcast(&x, 1, MPI_INT, 0, MPI_COMM_WORLD);
        }
        // Run Allgather.
        {
                int x, size;
                MPI_Comm_rank( MPI_COMM_WORLD, &x);
                MPI_Comm_size( MPI_COMM_WORLD, &size);
                
                std::vector<int> rcv(size);
                MPI_Allgather(&x, 1, MPI_INT, &rcv[0], 1, MPI_INT, MPI_COMM_WORLD);
        }

        // Run Allreduce.
        {
                int x;
                MPI_Comm_rank( MPI_COMM_WORLD, &x);
                
                int y = 0;
                MPI_Allreduce(&x, &y, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
        }

        // Dummy Prefix Sum
        {
                int x  = 1;
                int y  = 0;

                MPI_Scan(&x, &y, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); 
        }

        // Run Alltoallv.
        {
                std::vector<int> snd(size);
                std::vector<int> rcv(size);
                std::vector<int> scounts(size, 1);
                std::vector<int> rcounts(size, 1);
                std::vector<int> sdispls(size);
                std::vector<int> rdispls(size);
                for (int i = 0, iend = sdispls.size(); i < iend; ++i) {
                        sdispls[i] = rdispls[i] = i;
                }
                MPI_Alltoallv(&snd[0], &scounts[0], &sdispls[0], MPI_INT,
                              &rcv[0], &rcounts[0], &rdispls[0], MPI_INT, MPI_COMM_WORLD);
        }
        

}
コード例 #4
0
	bool task_acquire_tile(Device *device, RenderTile& tile)
	{
		thread_scoped_lock acquire_lock(acquire_mutex);

		bool result = false;

		RPCSend snd(socket, "acquire_tile");
		snd.write();

		while(1) {
			RPCReceive rcv(socket);

			if(rcv.name == "acquire_tile") {
				rcv.read(tile);

				if(tile.buffer) tile.buffer = ptr_map[tile.buffer];
				if(tile.rng_state) tile.rng_state = ptr_map[tile.rng_state];

				result = true;
				break;
			}
			else if(rcv.name == "acquire_tile_none")
				break;
			else
				process(rcv);
		}

		return result;
	}
コード例 #5
0
ファイル: attribute_mapping.hpp プロジェクト: AKinanS/Server
 /*!
  * Extraction operator
  *
  * \param values A set of attribute values attached to a logging record
  * \return An extracted attribute value
  */
 mapped_type operator() (values_view_type const& values) const
 {
     mapped_type res = m_DefaultValue;
     receiver rcv(res);
     m_Extractor(values, rcv);
     return res;
 }
コード例 #6
0
ファイル: glb_min_max.C プロジェクト: DeanHowarth/QUDA-CPS
//---------------------------------------------------------------------- 
void glb_min(Float * float_p)
{
  int NP[4] = {GJP.Xnodes(), GJP.Ynodes(), GJP.Znodes(), GJP.Tnodes()};
  if (transmit_buf == NULL) 
      transmit_buf = (Float *)qalloc(QFAST|QNONCACHE,sizeof(Float));
  if (receive_buf == NULL) 
      receive_buf = (Float *)qalloc(QFAST|QNONCACHE,sizeof(Float));
  if (gsum_buf == NULL) 
      gsum_buf = (Float *)qalloc(QFAST|QNONCACHE,sizeof(Float));

  *gsum_buf = *float_p;

  for(int i = 0; i < 4; ++i) {

      *transmit_buf = *gsum_buf;

      for (int itmp = 1; itmp < NP[i]; itmp++) {
	SCUDirArg send(transmit_buf, dir[2*i], SCU_SEND, sizeof(Float));
	SCUDirArg rcv(receive_buf, dir[2*i+1], SCU_REC, sizeof(Float));

	send.StartTrans();
	rcv.StartTrans();
	send.TransComplete();
	rcv.TransComplete();

        *gsum_buf = min(*gsum_buf, *receive_buf) ;
        *transmit_buf = *receive_buf;
      }
  }
  *float_p = *gsum_buf;
}
コード例 #7
0
ファイル: mailbox.cpp プロジェクト: HappySky2046/gce
///------------------------------------------------------------------------------
void mailbox::push(exit_t ex, message const& msg)
{
  recv_t rcv(ex);
  scope scp(boost::bind(&recv_queue_t::pop_back, &recv_que_));
  add_match_msg(rcv, ex.get_aid(), msg);
  scp.reset();
}
コード例 #8
0
ファイル: main.c プロジェクト: shattered/dmd-dev5620
main()
{
	register got;
	request(KBD|MOUSE|RCV|SEND);
	newlnsz=defont.height;
	init();
	strzero(&snarfbuf);
	waitunix(&diagdone);	/* when menu is loaded */
	for(got=0; ; got=wait(MOUSE|KBD|RCV)){
		if(P->state&RESHAPED){
			rectf(&display, Drect, F_CLR);
			closeall();
			init();
			P->state&=~RESHAPED;
		}
		/* NOTE: cursor is OFF at all times... */
		if((got&RCV) && rcv()){
			curse(current->frame);
			(void)message();
			curse(current->frame);
		}
		if((got&MOUSE) && bttn123() && ptinrect(mouse.xy, display.rect)){
			curse(current->frame);
			buttonhit(mouse.xy, mouse.buttons);
			curse(current->frame);
		}
		if((got&KBD) && current)	/* ...except in type */
			type(current);	/* manages cursor itself */
	}
}
コード例 #9
0
ファイル: mailbox.cpp プロジェクト: HappySky2046/gce
///------------------------------------------------------------------------------
void mailbox::push(aid_t sender, message const& msg)
{
  recv_t rcv(sender);
  scope scp(boost::bind(&recv_queue_t::pop_back, &recv_que_));
  add_match_msg(rcv, sender, msg);
  scp.reset();
}
コード例 #10
0
receiver session::open_receiver(const std::string &addr, const receiver_options &ro)
{
    std::string name = ro.get_name() ? *ro.get_name() : next_link_name(connection());
    pn_link_t *lnk = pn_receiver(pn_object(), name.c_str());
    pn_terminus_set_address(pn_link_source(lnk), addr.c_str());
    receiver rcv(make_wrapper<receiver>(lnk));
    rcv.open(ro);
    return rcv;
}
コード例 #11
0
ファイル: mailbox.cpp プロジェクト: HappySky2046/gce
///------------------------------------------------------------------------------
void mailbox::push(request_t req, message const& msg)
{
  scope scp(boost::bind(&recv_queue_t::pop_back, &recv_que_));
  recv_t rcv(req);
  add_match_msg(rcv, aid_t(), msg);
  std::pair<wait_reply_list_t::iterator, bool> pr =
    wait_reply_list_.insert(std::make_pair(req.get_aid(), dummy_));
  pr.first->second.push_back(req);
  scp.reset();
}
コード例 #12
0
	void listen_step()
	{
		thread_scoped_lock lock(rpc_lock);
		RPCReceive rcv(socket, &error_func);

		if(rcv.name == "stop")
			stop = true;
		else
			process(rcv, lock);
	}
コード例 #13
0
	void listen()
	{
		/* receive remote function calls */
		for(;;) {
			RPCReceive rcv(socket);

			if(rcv.name == "stop")
				break;

			process(rcv);
		}
	}
コード例 #14
0
	void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
	{
		RPCSend snd(socket, "mem_copy_from");

		snd.add(mem);
		snd.add(y);
		snd.add(w);
		snd.add(h);
		snd.add(elem);
		snd.write();

		RPCReceive rcv(socket);
		rcv.read_buffer((void*)mem.data_pointer, mem.memory_size());
	}
コード例 #15
0
ファイル: get_data.C プロジェクト: DeanHowarth/QUDA-CPS
void getMinusData(IFloat* rcv_buf, IFloat* send_buf, int len, int mu)
{
  if(gjp_local_axis[mu] == 0) {
    SCUDirArg send(send_buf, gjp_scu_dir[2*mu], SCU_SEND, len);
    SCUDirArg rcv(rcv_buf, gjp_scu_dir[2*mu+1], SCU_REC, len);
    SCUTrans(&send);
    SCUTrans(&rcv);
    SCUTransComplete();
  }
  else {
    for(int i = 0; i < len; ++i) {
      *rcv_buf++ = *send_buf++;
    }
  }
}
コード例 #16
0
	void task_wait()
	{
		RPCSend snd(socket, "task_wait");
		snd.write();

		list<RenderTile> the_tiles;

		/* todo: run this threaded for connecting to multiple clients */
		for(;;) {
			RPCReceive rcv(socket);
			RenderTile tile;

			if(rcv.name == "acquire_tile") {
				/* todo: watch out for recursive calls! */
				if(the_task.acquire_tile(this, tile)) { /* write return as bool */
					the_tiles.push_back(tile);

					RPCSend snd(socket, "acquire_tile");
					snd.add(tile);
					snd.write();
				}
				else {
					RPCSend snd(socket, "acquire_tile_none");
					snd.write();
				}
			}
			else if(rcv.name == "release_tile") {
				rcv.read(tile);

				for(list<RenderTile>::iterator it = the_tiles.begin(); it != the_tiles.end(); it++) {
					if(tile.x == it->x && tile.y == it->y && tile.start_sample == it->start_sample) {
						tile.buffers = it->buffers;
						the_tiles.erase(it);
						break;
					}
				}

				assert(tile.buffers != NULL);

				the_task.release_tile(tile);

				RPCSend snd(socket, "release_tile");
				snd.write();
			}
			else if(rcv.name == "task_wait_done")
				break;
		}
	}
コード例 #17
0
ファイル: mesg.c プロジェクト: siebenmann/sam
void
outflush(void)
{
    if(outmsg == outdata)
        return;
    noflush = 0;
    outT0(Hack);
    waitack = 1;
    do
        if(rcv() == 0) {
            rescue();
            exits("eof");
        }
    while(waitack);
    outmsg = outdata;
    noflush = 1;
}
コード例 #18
0
	bool load_kernels(bool experimental)
	{
		if(error_func.have_error())
			return false;

		thread_scoped_lock lock(rpc_lock);

		RPCSend snd(socket, &error_func, "load_kernels");
		snd.add(experimental);
		snd.write();

		bool result;
		RPCReceive rcv(socket, &error_func);
		rcv.read(result);

		return result;
	}
コード例 #19
0
ファイル: cmd.c プロジェクト: grobe0ba/plan9front
int
inputc(void)
{
	int n, nbuf;
	char buf[UTFmax];
	Rune r;

    Again:
	nbuf = 0;
	if(cmdbufpos > cmdbuf.nc && cmdbuf.nc > 0){
		cmdbufpos = 0;
		bufreset(&cmdbuf);
	}
	if(cmdbufpos < cmdbuf.nc && cmdbuf.nc > 0)
		bufread(&cmdbuf, cmdbufpos++, &r, 1);
	else if(downloaded){
		while(termoutp == terminp){
			cmdupdate();
			if(patset)
				tellpat();
			while(termlocked > 0){
				outT0(Hunlock);
				termlocked--;
			}
			if(rcv() == 0)
				return -1;
		}
		r = *termoutp++;
		if(termoutp == terminp)
			terminp = termoutp = termline;
	}else{
   		do{
			n = read(0, buf+nbuf, 1);
			if(n <= 0)
				return -1;
			nbuf += n;
		}while(!fullrune(buf, nbuf));
		chartorune(&r, buf);
	}
	if(r == 0){
		warn(Wnulls);
		goto Again;
	}
	return r;
}
コード例 #20
0
	void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
	{
		thread_scoped_lock lock(rpc_lock);

		size_t data_size = mem.memory_size();

		RPCSend snd(socket, &error_func, "mem_copy_from");

		snd.add(mem);
		snd.add(y);
		snd.add(w);
		snd.add(h);
		snd.add(elem);
		snd.write();

		RPCReceive rcv(socket, &error_func);
		rcv.read_buffer((void*)mem.data_pointer, data_size);
	}
コード例 #21
0
ファイル: mesg.c プロジェクト: rennis250/sam
void
outflush(void)
{
	if(outmsg == outdata)
		return;
	outbuffered = 0;
	/* flow control */
	outT0(Hack);
	waitack = 1;
	do
		if(rcv() == 0){
			rescue();
			exits("eof");
		}
	while(waitack);
	outmsg = outdata;
	outbuffered = 1;
}
コード例 #22
0
	void task_release_tile(RenderTile& tile)
	{
		thread_scoped_lock acquire_lock(acquire_mutex);

		if(tile.buffer) tile.buffer = ptr_imap[tile.buffer];
		if(tile.rng_state) tile.rng_state = ptr_imap[tile.rng_state];

		RPCSend snd(socket, "release_tile");
		snd.add(tile);
		snd.write();

		while(1) {
			RPCReceive rcv(socket);

			if(rcv.name == "release_tile")
				break;
			else
				process(rcv);
		}
	}
コード例 #23
0
ファイル: device_network.cpp プロジェクト: Aligorith/blender
	bool load_kernels(const DeviceRequestedFeatures& requested_features)
	{
		if(error_func.have_error())
			return false;

		thread_scoped_lock lock(rpc_lock);

		RPCSend snd(socket, &error_func, "load_kernels");
		snd.add(requested_features.experimental);
		snd.add(requested_features.max_closure);
		snd.add(requested_features.max_nodes_group);
		snd.add(requested_features.nodes_features);
		snd.write();

		bool result;
		RPCReceive rcv(socket, &error_func);
		rcv.read(result);

		return result;
	}
コード例 #24
0
ファイル: gnotfix.c プロジェクト: kahrs/cda
void
call_host(char *machine)
{
	char buf[100];
	fprint(errfd, "call_host %s.exec\n", machine);
	if(Connect(machine, "/bin/cda/aux/hplace")) {
		dup(remotefd0, 0);
		dup(remotefd1, 1);
		close(remotefd0);
		close(remotefd1);
		put1(MYDIR);
		putstr(mydir);
		while(rcv());
		return;
	}
	fprint(errfd,"can't open %s on %s", "/bin/cda/aux/hplace", machine);
	hosterr(buf, 0);
	close(remotefd0);
	close(remotefd1);
	remotefd0 = remotefd1 = 0;
}
コード例 #25
0
ファイル: l2.c プロジェクト: OlegHahm/miniature-dangerzone
void *_eventloop(void *arg)
{
    (void)arg;
    msg_t msg;
    msg_t msg_queue[NG_PKTDUMP_MSG_QUEUE_SIZE];

    /* setup the message queue */
    msg_init_queue(msg_queue, NG_PKTDUMP_MSG_QUEUE_SIZE);

    memset(received_chunks, 0, sizeof(received_chunks));

    while (1) {
        msg_receive(&msg);

        switch (msg.type) {
            case NG_NETAPI_MSG_TYPE_RCV:
                LOG_DEBUG("PKTDUMP: data received:\n");
                rcv((ng_pktsnip_t *)msg.content.ptr);
                break;
            case ICN_RESEND_INTEREST:
                LOG_DEBUG("ICN_RESEND_INTEREST: trigger retransmission for %u:\n", (uint16_t) *msg.content.ptr);
            case ICN_SEND_INTEREST:
                LOG_DEBUG("ICN_SEND_INTEREST: trigger an interest:\n");
                icn_initInterest((uint16_t) *msg.content.ptr);
                break;
            case ICN_SEND_BACKGROUND:
                LOG_DEBUG("ICN_SEND_BACKGROUND: trigger background traffic:\n");
                icn_initBackground();
                break;
            default:
                LOG_ERROR("PKTDUMP: received something unexpected\n");
                break;
        }
    }

    /* never reached */
    return NULL;
}
コード例 #26
0
ファイル: StatGet.cpp プロジェクト: przemeklal/switch-logic
int main(int argc, char *argv[]) {

	int opt= 0;
	static struct option long_options[] = {
		{"snd",	no_argument,	0,  's' },
		{"rcv",	no_argument,	0,  'r' },
		{"mac",	no_argument,	0,  'm' },
		{"all",	no_argument,	0,  'a' },
		{"ph",	required_argument, 0,  'p' },
		{0,	0,		0,   0  }
	};

	int long_index =0;
	while ((opt = getopt_long(argc, argv,"srmap:", 
					long_options, &long_index )) != -1) {
		switch (opt) {
			case 's' :
				//send statistics
				if(snd("s")==-1)
				{
					std::cout<<"Error: msg not send"<<std::endl;
					return -1;
				}
				if(rcv()==-1)
				{
					std::cout<<"Error: msg not recived"<<std::endl;
					return -1;
				}
				break;
			case 'r' :
				//recive statistics
				if(snd("r")==-1)
				{
					std::cout<<"Error: msg not send"<<std::endl;
					return -1;
				}
				if(rcv()==-1)
				{
					std::cout<<"Error: msg not recived"<<std::endl;
					return -1;
				}

				break;
			case 'm' :
				//Macaddress statistics
				if(snd("m")==-1)
				{
					std::cout<<"Error: msg not send"<<std::endl;
					return -1;
				}
				if(rcv()==-1)
				{
					std::cout<<"Error: msg not recived"<<std::endl;
					return -1;
				}
				break;
			case 'a' : 
				//all ports
				if(snd("a")==-1)
				{
					std::cout<<"Error: msg not send"<<std::endl;
					return -1;
				}
				if(rcv()==-1)
				{
					std::cout<<"Error: msg not recived"<<std::endl;
					return -1;
				}
				break;
			case 'p' :
				//given port
				if(snd(optarg)==-1)
				{
					std::cout<<"Error: msg not send"<<std::endl;
					return -1;
				}
				if(rcv()==-1)
				{
					std::cout<<"Error: msg not recived"<<std::endl;
					return -1;
				}
				break;
			default: print_usage(); 
				 exit(EXIT_FAILURE);
		}
	}

	return 0;
}
コード例 #27
0
ファイル: llc_input.c プロジェクト: 020gzh/linux
/**
 *	llc_rcv - 802.2 entry point from net lower layers
 *	@skb: received pdu
 *	@dev: device that receive pdu
 *	@pt: packet type
 *
 *	When the system receives a 802.2 frame this function is called. It
 *	checks SAP and connection of received pdu and passes frame to
 *	llc_{station,sap,conn}_rcv for sending to proper state machine. If
 *	the frame is related to a busy connection (a connection is sending
 *	data now), it queues this frame in the connection's backlog.
 */
int llc_rcv(struct sk_buff *skb, struct net_device *dev,
	    struct packet_type *pt, struct net_device *orig_dev)
{
	struct llc_sap *sap;
	struct llc_pdu_sn *pdu;
	int dest;
	int (*rcv)(struct sk_buff *, struct net_device *,
		   struct packet_type *, struct net_device *);
	void (*sta_handler)(struct sk_buff *skb);
	void (*sap_handler)(struct llc_sap *sap, struct sk_buff *skb);

	if (!net_eq(dev_net(dev), &init_net))
		goto drop;

	/*
	 * When the interface is in promisc. mode, drop all the crap that it
	 * receives, do not try to analyse it.
	 */
	if (unlikely(skb->pkt_type == PACKET_OTHERHOST)) {
		dprintk("%s: PACKET_OTHERHOST\n", __func__);
		goto drop;
	}
	skb = skb_share_check(skb, GFP_ATOMIC);
	if (unlikely(!skb))
		goto out;
	if (unlikely(!llc_fixup_skb(skb)))
		goto drop;
	pdu = llc_pdu_sn_hdr(skb);
	if (unlikely(!pdu->dsap)) /* NULL DSAP, refer to station */
	       goto handle_station;
	sap = llc_sap_find(pdu->dsap);
	if (unlikely(!sap)) {/* unknown SAP */
		dprintk("%s: llc_sap_find(%02X) failed!\n", __func__,
			pdu->dsap);
		goto drop;
	}
	/*
	 * First the upper layer protocols that don't need the full
	 * LLC functionality
	 */
	rcv = rcu_dereference(sap->rcv_func);
	dest = llc_pdu_type(skb);
	sap_handler = dest ? ACCESS_ONCE(llc_type_handlers[dest - 1]) : NULL;
	if (unlikely(!sap_handler)) {
		if (rcv)
			rcv(skb, dev, pt, orig_dev);
		else
			kfree_skb(skb);
	} else {
		if (rcv) {
			struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC);
			if (cskb)
				rcv(cskb, dev, pt, orig_dev);
		}
		sap_handler(sap, skb);
	}
	llc_sap_put(sap);
out:
	return 0;
drop:
	kfree_skb(skb);
	goto out;
handle_station:
	sta_handler = ACCESS_ONCE(llc_station_handler);
	if (!sta_handler)
		goto drop;
	sta_handler(skb);
	goto out;
}
コード例 #28
0
void glb_sum_matrix_dir(Matrix * matrix_p, int dir)
{
  int NP[5] = {GJP.Xnodes(), 
	       GJP.Ynodes(), 
	       GJP.Znodes(), 
	       GJP.Tnodes(), 
	       GJP.Snodes()};

  int COOR[5] = {GJP.XnodeCoor(), 
		 GJP.YnodeCoor(), 
		 GJP.ZnodeCoor(), 
		 GJP.TnodeCoor(), 
		 GJP.SnodeCoor()}; 

  if (transmit_buf == NULL) 
      transmit_buf = (Matrix *)qalloc(QFAST|QNONCACHE,sizeof(Matrix));
  if (receive_buf == NULL) 
      receive_buf = (Matrix *)qalloc(QFAST|QNONCACHE,sizeof(Matrix));
  if (gsum_buf == NULL) 
      gsum_buf = (Matrix *)qalloc(QFAST|QNONCACHE,sizeof(Matrix));

  // Sum along dir
  //--------------------------------------------------------------
  *gsum_buf = *matrix_p;

  *transmit_buf = *gsum_buf;
  int blocksize=sizeof(Matrix);
  int itmp;
  for (itmp = 1; itmp < NP[dir]; itmp++) {
    SCUDirArg send(transmit_buf, gjp_scu_dir[2*dir], SCU_SEND, blocksize);
    SCUDirArg rcv(receive_buf, gjp_scu_dir[2*dir+1], SCU_REC, blocksize);

    send.StartTrans();
    rcv.StartTrans();
    send.TransComplete();
    rcv.TransComplete();

    *gsum_buf += *receive_buf;
    *transmit_buf = *receive_buf;
  }


  // Broadcast the result of node with dir coordinate == 0
  //--------------------------------------------------------------

  if(COOR[dir] != 0) {
    gsum_buf->ZeroMatrix();
  }
    
  *transmit_buf = *gsum_buf;
  
  for (itmp = 1; itmp < NP[dir]; itmp++) {
    SCUDirArg send(transmit_buf, gjp_scu_dir[2*dir], SCU_SEND, blocksize);
    SCUDirArg rcv(receive_buf, gjp_scu_dir[2*dir+1], SCU_REC, blocksize);
    
    send.StartTrans();
    rcv.StartTrans();
    send.TransComplete();
    rcv.TransComplete();
    
    *gsum_buf += *receive_buf;
    *transmit_buf = *receive_buf;
  }


  *matrix_p = *gsum_buf;
}
コード例 #29
0
ファイル: main.c プロジェクト: siebenmann/sam
void
main(int argc, char *argv[])
{
	int i, got, scr;
	Text *t;
	Rectangle r;
	Flayer *nwhich;

	int fwdbut;

	if (argc >= 3 && strcmp(argv[1], "-r") == 0)
	{
		machine = argv[2];
	}

	getscreen(argc, argv);
	fwdbut = scrollfwdbut();
	iconinit();
	initio();
	scratch = alloc(100*RUNESIZE);
	nscralloc = 100;
	r = screen.r;
	r.max.y = r.min.y+Dy(r)/5;
	flstart(screen.clipr);
	rinit(&cmd.rasp);
	flnew(&cmd.l[0], stgettext, 1, &cmd);
	flinit(&cmd.l[0], r, font);
	cmd.nwin = 1;
	which = &cmd.l[0];
	cmd.tag = Untagged;
	outTs(Tversion, VERSION);
	startnewfile(Tstartcmdfile, &cmd);

	got = 0;
	for(;;got = waitforio()){
		if(hasunlocked && RESHAPED())
			reshape();
		if(got&RHost)
			rcv();
		if(got&RExtern){
			for(i=0; cmd.l[i].textfn==0; i++)
				;
			current(&cmd.l[i]);
			flsetselect(which, cmd.rasp.nrunes, cmd.rasp.nrunes);
			type(which, RExtern);
		}
		if(got&RKeyboard)
			if(which)
				type(which, RKeyboard);
			else
				kbdblock();
		if(got&RMouse){
			if(lock==2 || !ptinrect(mouse.xy, screen.r)){
				mouseunblock();
				continue;
			}
			nwhich = flwhich(mouse.xy);
			scr = which && ptinrect(mouse.xy, which->scroll);
			if(mouse.buttons)
				flushtyping(1);
			if (chord == 1 && !mouse.buttons)
				chord = 0;
			if (chord)
				chord |= mouse.buttons;
			else if(mouse.buttons&1){
				if(nwhich){
					if(nwhich!=which)
						current(nwhich);
					else if(scr)
						scroll(which, 1, fwdbut == 3 ? 1 : 3);
					else{
						t=(Text *)which->user1;
						if(flselect(which)){
							outTsl(Tdclick, t->tag, which->p0);
							t->lock++;
						}else if(t!=&cmd)
							outcmd();
						if(mouse.buttons&1)
							chord = mouse.buttons;
					}
				}
			}else if((mouse.buttons&2) && which){
				if(scr)
					scroll(which, 2, 2);
				else
					menu2hit();
			}else if((mouse.buttons&4)){
				if(scr)
					scroll(which, 3, fwdbut == 3 ? 3 : 1);
				else
					menu3hit();
			}else if((mouse.buttons&8)){
				scrollone(which, 1);
			}else if((mouse.buttons&16)){
				scrollone(which, 3);
			}
			mouseunblock();
		}
		if(chord) {
			t = (Text *)which->user1;
			if(!t->lock){
				int w = which-t->l;
				if(chord&2){
					cut(t, w, 1, 1);
					chord &= ~2;
				}
				if(chord&4){
					paste(t, w);
					chord &= ~4;
				}
			}
		}
	}
}
コード例 #30
0
int
main (int, char *[])
{
  ACE_START_TEST ("Stream_Test");

  /* ================================================================== */
  ACE_CLASSIX_Port_Core remote_port;

  // Sender's socket
  // Use my default port as the sending address
  ACE_CLASSIX_Stream send(remote_port);

  ACE_CLASSIX_Stream rcv(send.local_sap().get_addr(), 
			 ACE_CLASSIX_Port(remote_port));
  // make the rcv's port be one of the multiple receive ports  
  if (rcv.selectable() < 0)
      ACE_DEBUG((LM_DEBUG, "failed to make the port selectable\n"));

  send.open_writer();

  ACE_DEBUG((LM_DEBUG, "send and block on receive....\n"));
  if (send.send_n(&sndBody[0], sizeof(sndBody)) == sizeof(sndBody))
  {
      // Receiver's Socket
      int rslt = rcv.ipcRecv(rcvBody, 1000);
      if (rslt == sizeof (sndBody))
	  ACE_DEBUG((LM_DEBUG, "received %s\n", rcvBody));
      else
	  ACE_DEBUG((LM_ERROR, "???? Error in ipcReceive():%d\n", rslt));
  }
  else
  {
	  ACE_ERROR((LM_ERROR, "(%t)|%p\n", "???? Error in send_n()\n"));
  }

  ACE_DEBUG((LM_DEBUG, "send, peek then block on receive....\n"));
  if (send.send_n(&sndBody[0], sizeof(sndBody)) == sizeof(sndBody))
  {
      // Receiver's Socket
      //  int rslt = rcv.recv(rcvBody, 1000, MSG_PEEK);
      // Equivalent to rcv.peek()
      int rslt = rcv.peek();
      if (rslt < 0)
	  ACE_DEBUG((LM_ERROR, "???? Error while peeking :%d\n", rslt));
      else
      {
	  char *buf = new char(rslt);
	  if (int n = rcv.recv(buf, rslt) == rslt)
	      ACE_DEBUG((LM_DEBUG, "received %s\n", buf));
	  else
	      ACE_DEBUG((LM_ERROR, "???? Error in ipcReceive(): %d\n", n));
	  delete buf;
      }
  }
  else
  {
	  ACE_DEBUG((LM_ERROR, "???? Error in send_n()\n"));
  }

  ACE_DEBUG((LM_DEBUG, "test recv_n()....\n"));
  if (send.send_n(&sndBody[0], sizeof(sndBody)) == sizeof(sndBody) &&
      send.send_n(&sndBody[0], sizeof(sndBody)) == sizeof(sndBody))
  {
      // Receiver's Socket

      int rslt = rcv.ipcRecv_n(rcvBody, 2*sizeof (sndBody) - 10);
      if (rslt == (2 * sizeof (sndBody) -10))
      {
	  rcvBody[rslt] = '\0';	// For %s printout format
	  ACE_DEBUG((LM_DEBUG, "received %d byte: %s + %s\n", rslt,
		     rcvBody,  rcvBody + sizeof(sndBody)));
      }
      else
	  ACE_DEBUG((LM_ERROR, "???(%P|%t) %p\n", "ipcRecv_n()"));
  }
  else
      ACE_DEBUG((LM_ERROR, "???(%P|%t) %p\n", "ipcRecv_n()"));

  ACE_END_TEST;
  return 0;
}