Beispiel #1
0
static int run(void)
{
	int i, ret = 0;

	ret = ft_init_fabric();
	if (ret)
		return ret;

	if (!(opts.options & FT_OPT_SIZE)) {
		for (i = 0; i < TEST_CNT; i++) {
			if (!ft_use_size(i, opts.sizes_enabled))
				continue;
			opts.transfer_size = test_size[i].size;
			init_test(&opts, test_name, sizeof(test_name));
			ret = pingpong();
			if (ret)
				goto out;
		}
	} else {
		init_test(&opts, test_name, sizeof(test_name));
		ret = pingpong();
		if (ret)
			goto out;
	}

	ft_finalize();
out:
	return ret;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
  minit(argc,argv);
  pingpong(0);
  mloop();
  pingpong(2);
  mexit();
  return(0);
}
int main(int argc, char *argv[]) {
	hydrazine::ArgumentParser parser(argc, argv);
	
	int port;
	std::string host;
	bool verbose;
	
	parser.parse("-p", "--port", port, 2011, "Port to connect on");
	parser.parse("-h", "--host", host, "127.0.0.1", "Remote host to connect to");
	parser.parse("-v", "--verbose", verbose, false, "Verbose printing");
	
	try {
		//using boost::asio::ip::tcp;
    boost::asio::io_service io_service;
    boost::system::error_code error;
    
    boost::asio::ip::tcp::endpoint hostAddress(boost::asio::ip::address::from_string(host), port);

    boost::asio::ip::tcp::socket socket(io_service);
    socket.connect(hostAddress);
    
    if (verbose) {
	    std::cout << "Connecting to: " << host << ":" << port << std::endl;
	   }
		pingpong(socket, verbose);
	}
	catch (std::exception &exp) {
		std::cerr << "TestOcelotServer - " << exp.what() << std::endl;
	}
	return 0;
}
Beispiel #4
0
void do_pong()
{
  static uint32_t interval = MAKUO_PONG_INTERVAL;
  if(mtimeout(&lastpong, interval)){
    interval  = MAKUO_PONG_INTERVAL;
    interval += ((rand() % 31) - 15) * 1000;
    pingpong(1);
  }
}
Beispiel #5
0
static int run(void)
{
	char *node, *service;
	uint64_t flags;
	int i, ret;

	ret = ft_read_addr_opts(&node, &service, hints, &flags, &opts);
	if (ret)
		return ret;

	if (!opts.dst_addr) {
		ret = ft_start_server();
		if (ret)
			return ret;
	}

	ret = opts.dst_addr ? client_connect() : server_connect();
	if (ret) {
		return ret;
	}

	if (!(opts.options & FT_OPT_SIZE)) {
		for (i = 0; i < TEST_CNT; i++) {
			if (!ft_use_size(i, opts.sizes_enabled))
				continue;
			opts.transfer_size = test_size[i].size;
			init_test(&opts, test_name, sizeof(test_name));
			ret = pingpong();
			if (ret)
				goto out;
		}
	} else {
		init_test(&opts, test_name, sizeof(test_name));
		ret = pingpong();
		if (ret)
			goto out;
	}

	ret = ft_finalize();
out:
	fi_shutdown(ep, 0);
	return ret;
}
Beispiel #6
0
static int run(void)
{
	int i, ret;

	ret = ft_init_fabric();
	if (ret)
		return ret;

	/* Post an extra receive to avoid lacking a posted receive in the
	 * finalize.
	 */
	ret = fi_recv(ep, rx_buf, rx_size + ft_rx_prefix_size(), fi_mr_desc(mr),
			0, &rx_ctx);

	if (!(opts.options & FT_OPT_SIZE)) {
		for (i = 0; i < TEST_CNT; i++) {
			if (!ft_use_size(i, opts.sizes_enabled))
				continue;

			opts.transfer_size = test_size[i].size;
			if (opts.transfer_size > fi->ep_attr->max_msg_size)
				continue;

			init_test(&opts, test_name, sizeof(test_name));
			ret = pingpong();
			if (ret)
				return ret;
		}
	} else {
		init_test(&opts, test_name, sizeof(test_name));
		ret = pingpong();
		if (ret)
			return ret;
	}

	return ft_finalize();
}
Beispiel #7
0
void MLKKMRefine(CtrlType *ctrl, GraphType *orggraph, GraphType *graph, int nparts, int chain_length, float *tpwgts, float ubfactor)
{
  int i, nlevels, mustfree=0, temp_cl;
  GraphType *ptr;

  IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->UncoarsenTmr));

  /* Compute the parameters of the coarsest graph */
  ComputeKWayPartitionParams(ctrl, graph, nparts);
  temp_cl = chain_length;

  /* Determine how many levels are there */
  for (ptr=graph, nlevels=0; ptr!=orggraph; ptr=ptr->finer, nlevels++); 
  //printf("Number of levels is %d\n", nlevels);

  for (i=0; ;i++) {
    timer tmr;
    float result;

    cleartimer(tmr);
    starttimer(tmr);
    
    //pingpong(ctrl, graph, nparts, chain_length, tpwgts, ubfactor);
    //chain_length /= 1.5;
    //printf("Level: %d\n", i+1);
    
    if (graph == orggraph){
      //chain_length = chain_length>0 ? chain_length : 1;
      pingpong(ctrl, graph, nparts, chain_length, tpwgts, ubfactor, 1);
      break;
    }
    else{
      //pingpong(ctrl, graph, nparts, 0, tpwgts, ubfactor, 0);
      pingpong(ctrl, graph, nparts, chain_length, tpwgts, ubfactor, 0);
      //chain_length /= 2;
    }
    
    
    //pingpong(ctrl, graph, nparts, chain_length, tpwgts, ubfactor);
    
    //    /* for time and quality each level 
    
    stoptimer(tmr);
    //printf("Level %d: %7.3f", i+1, tmr);
    if (cutType == NCUT){
      result = ComputeNCut(graph, graph->where, nparts);
      //printf("   %7f", result);
    }
    else{
      result = ComputeRAsso(graph, graph->where, nparts);
      //printf("   %7f", result);
    }
    //printf(" (%d)\n\n", graph->nvtxs);
    //ends here*/

    if (graph == orggraph)
      break;
    /*
    if(i>1)
      chain_length /= 10;
    */

    GKfree((void **) &graph->gdata, LTERM);  /* Deallocate the graph related arrays */
    graph = graph->finer;
    IFSET(ctrl->dbglvl, DBG_TIME, starttimer(ctrl->ProjectTmr));
    if (graph->vwgt == NULL) {
      graph->vwgt = idxsmalloc(graph->nvtxs, 1, "RefineKWay: graph->vwgt");
      graph->adjwgt = idxsmalloc(graph->nedges, 1, "RefineKWay: graph->adjwgt");
      mustfree = 1;
    }
    ProjectKWayPartition(ctrl, graph, nparts);
    IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->ProjectTmr));
  }
  
  if (mustfree) 
    GKfree((void **) &graph->vwgt, (void **) &graph->adjwgt, LTERM);

  IFSET(ctrl->dbglvl, DBG_TIME, stoptimer(ctrl->UncoarsenTmr));
}
Beispiel #8
0
/** The central function within each kernel. This function
 *  is called for each measurment step seperately.
 *  @param  mdpv         a pointer to the structure created in bi_init,
 *                       it is the pointer the bi_init returns
 *  @param  problemsize  the actual problemsize
 *  @param  results      a pointer to a field of doubles, the
 *                       size of the field depends on the number
 *                       of functions, there are #functions+1
 *                       doubles
 *  @return 0 if the measurment was sucessfull, something
 *          else in the case of an error
 */
int bi_entry( void * mdpv, int iproblemsize, double * dresults )
{
  /* dstart, dend: the start and end time of the measurement */
  /* dtime: the time for a single measurement in seconds */
  double dstart = 0.0, dend = 0.0, dtime = 0.0;
  /* flops stores the calculated FLOPS */
  double dres = 0.0;
  /* ii is used for loop iterations */
  myinttype isender = 0, ireceiver = 0, imyproblemsize = (myinttype) iproblemsize;
  /* cast void* pointer */
  mydata_t * pmydata = (mydata_t *) mdpv;

  IDL(3, printf("\nrank=%d entered bi_entry\n",pmydata->commrank));

  /* calculate real problemsize */
  //fprintf( stderr, "\nrank=%d problemsize=%d\n",pmydata->commrank ,imyproblemsize);fflush( stderr );
  // rank from 0-inf
  // problemsize from 1-inf
  /* example: 
   * 4 mpi-proccesses means rank = 0,1,2,3 size=4 problemsize=4*3=12
   * pair1 to pair12: (sender,receiver) 
   * sender=rank0     (0,1) (0,2) (0,3)     0,0 - prohibited
   * sender=rank1     (1,0) (1,2) (1,3)     1,1 - prohibited 
   * sender=rank2     (2,0) (2,1) (2,3)     2,2 - prohibited 
   * sender=rank3     (3,0) (3,1) (3,2)     3,3 - prohibited
   */
  isender = (myinttype) (imyproblemsize / pmydata->commsize);
  ireceiver = imyproblemsize % pmydata->commsize;
  if (ireceiver == isender) ireceiver++;

  /* check wether the pointer to store the results in is valid or not */
  if ( pmydata->commrank == 0 )
  {
    if ( dresults == NULL )
    {
      fprintf( stderr, "\nrank=%d resultpointer not allocated - panic\n",pmydata->commrank);fflush( stderr );
      return 1;
    }
  }

  /* get the actual time
   * do the measurement / your algorythm
   * get the actual time
   */
  MPI_Barrier( MPI_COMM_WORLD );
  dstart = bi_gettime(); 
  pingpong(&isender, &ireceiver, pmydata);
  MPI_Barrier( MPI_COMM_WORLD );
  dend = bi_gettime();

  IDL(3, printf("rank=%d Problemsize=%d, Value=%f\n",pmydata->commrank, imyproblemsize, dres));

  if ( pmydata->commrank == 0 )
  {
    /* calculate the used time and FLOPS */
    dtime = dend - dstart;
    dtime -= dTimerOverhead;
        
    /* If the operation was too fast to be measured by the timer function,
     * mark the result as invalid 
     */
    if( dtime < dTimerGranularity ) dtime = INVALID_MEASUREMENT;
  
    /* store the results in results[1], results[2], ...
    * [1] for the first function, [2] for the second function
    * and so on ...
    * the index 0 always keeps the value for the x axis
    */
    dresults[0] = (double)imyproblemsize;
    dresults[1] = (double) (dtime / 2*pmydata->repeat);
  }

  return 0;
}
Beispiel #9
0
int
main (void)
{
  fprintf(stderr, "sizeof(evcom_server): %d\n", (int)sizeof(evcom_server));
  fprintf(stderr, "sizeof(evcom_stream): %d\n", (int)sizeof(evcom_stream));
  fprintf(stderr, "sizeof(evcom_reader): %d\n", (int)sizeof(evcom_reader));
  fprintf(stderr, "sizeof(evcom_writer): %d\n", (int)sizeof(evcom_writer));

  evcom_ignore_sigpipe();

#if EVCOM_HAVE_GNUTLS
  gnutls_global_init();

  gnutls_dh_params_init (&dh_params);

  fsync(fileno(stderr));
  gnutls_dh_params_generate2 (dh_params, DH_BITS);

  gnutls_anon_allocate_server_credentials (&server_credentials);
  gnutls_anon_set_server_dh_params (server_credentials, dh_params);
#endif


  struct sockaddr_in tcp_address;
  memset(&tcp_address, 0, sizeof(struct sockaddr_in));
  tcp_address.sin_family = AF_INET;
  tcp_address.sin_port = htons(PORT);
  tcp_address.sin_addr.s_addr = INADDR_ANY;

  use_tls = 0;

  fprintf(stderr, "pair_pingpong use_pipe=1: ");
  assert(pair_pingpong(1) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "pair_pingpong use_pipe=0: ");
  assert(pair_pingpong(0) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "zero_stream tcp: ");
  assert(zero_stream((struct sockaddr*)&tcp_address, 5*1024*1024) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "pipe_stream: ");
  assert(pipe_stream() == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "pingpong tcp: ");
  assert(pingpong((struct sockaddr*)&tcp_address) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "connint tcp: ");
  assert(connint((struct sockaddr*)&tcp_address) == 0);
  fprintf(stderr, "\n");

#if EVCOM_HAVE_GNUTLS
  use_tls = 1;

  fprintf(stderr, "zero_stream ssl: ");
  assert(zero_stream((struct sockaddr*)&tcp_address, 50*1024) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "pair_pingpong ssl use_pipe=1: ");
  assert(pair_pingpong(1) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "pair_pingpong ssl use_pipe=0: ");
  assert(pair_pingpong(0) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "pingpong ssl: ");
  assert(pingpong((struct sockaddr*)&tcp_address) == 0);
  fprintf(stderr, "\n");

  fprintf(stderr, "connint ssl: ");
  assert(connint((struct sockaddr*)&tcp_address) == 0);
  fprintf(stderr, "\n");

#endif

  struct sockaddr *unix_address;

  use_tls = 0;

  fprintf(stderr, "pingpong unix: ");
  unix_address = create_unix_address();
  assert(pingpong(unix_address) == 0);
  free_unix_address(unix_address);
  fprintf(stderr, "\n");

  fprintf(stderr, "connint unix: ");
  unix_address = create_unix_address();
  assert(connint(unix_address) == 0);
  free_unix_address(unix_address);
  fprintf(stderr, "\n");

#if EVCOM_HAVE_GNUTLS
  use_tls = 1;

  fprintf(stderr, "pingpong unix ssl: ");
  unix_address = create_unix_address();
  assert(pingpong(unix_address) == 0);
  free_unix_address(unix_address);
  fprintf(stderr, "\n");

  fprintf(stderr, "connint unix ssl: ");
  unix_address = create_unix_address();
  assert(connint(unix_address) == 0);
  free_unix_address(unix_address);
  fprintf(stderr, "\n");
#endif

  return 0;
}