示例#1
0
文件: erq.c 项目: amotzkau/ldmud
/*-------------------------------------------------------------------------*/
int
writen (int fd, char *mesg, int len, struct equeue_s **qpp)

/* Send or queue the message <mesg> (length <len> bytes) to <fd>.
 * If *<qpp> is non-NULL, the message is queued immediately.
 * Otherwise, the function tries to send as much of the message
 * as possible, and the queues whatever is left.
 */

{
    int l = 0;

    XPRINTF((stderr, "%s writen(%d, %p:%d, %p (-> %p) ))\n"
                   , time_stamp(), fd, mesg, len, qpp, *qpp));
    if (!(*qpp))
    {
        /* Send as much of the message as possible */
        do
            l = write(fd, mesg, len);
        while (l == -1 && errno == EINTR);
        XPRINTF((stderr, "%s   Wrote %d bytes.\n", time_stamp(), l));
        if (l < 0 || l == len)
            return l;
        mesg += l;
        len -= l;
    }

    if (!len)
        return 0;

    XPRINTF((stderr, "%s   Queuing data %p:%d\n", time_stamp(), mesg, len));
    add_to_queue(qpp, mesg, len, 0);
    return l;
} /* writen() */
示例#2
0
void _rdma_read_offset(void *context, void* buf, uint64_t offset)
{
  struct connection *conn = (struct connection *)context;
  struct ibv_send_wr wr, *bad_wr = NULL;
  struct ibv_sge sge;
  //printf("7\n");
  memset(&wr, 0, sizeof(wr));

  wr.wr_id = (uintptr_t)conn;
  wr.opcode = IBV_WR_RDMA_READ;
  wr.sg_list = &sge;
  wr.num_sge = 1;
  wr.send_flags = IBV_SEND_SIGNALED;
  wr.wr.rdma.remote_addr = (uintptr_t)conn->peer_mr.addr + offset;
  wr.wr.rdma.rkey = conn->peer_mr.rkey;

  sge.addr = (uintptr_t)conn->rdma_local_region;
  sge.length = RDMA_BUFFER_SIZE;
  sge.lkey = conn->rdma_local_mr->lkey;

  time_stamp(2);
  time_stamp(6);
  //read lock
  TEST_NZ(ibv_post_send(conn->qp, &wr, &bad_wr));
  //printf("8\n");
  sem_wait(&read_ops);
  memcpy((char*)buf, conn->rdma_local_region, RDMA_BUFFER_SIZE);
  time_stamp(3);
}
示例#3
0
文件: socket.c 项目: amotzkau/ldmud
/*-------------------------------------------------------------------------*/
static void
free_socket (socket_t *sp)

/* The socket in structure <sp> has been closed already, now remove the
 * structure from the socket list and free it and all still pending
 * data.
 */

{
    socket_t **spp;
    equeue_t *qp, *qnext;

    XPRINTF((stderr, "%s Freeing socket %p\n", time_stamp(), sp));
    /* Remove the socket from the socket */
    for (spp = &sockets; *spp; spp = &(*spp)->next)
    {
        if (*spp != sp)
            continue;
        XPRINTF((stderr, "%s   Unlinking socket %p\n", time_stamp(), sp));
        *spp = sp->next;
        break;
    }

    /* Free all pending queued data */
    for (qp = sp->queue; qp;)
    {
        XPRINTF((stderr, "%s   Freeing queue %p\n", time_stamp(), qp));
        qnext = qp->next;
        free(qp);
        qp = qnext;
    }
    
    free(sp);
} /* free_socket() */
示例#4
0
文件: erq.c 项目: amotzkau/ldmud
/*-------------------------------------------------------------------------*/
void
write1 (void *mesg, int len)

/* Write the <len> bytes of <mesg> to stdout, ie to the driver.
 */

{
    int l;

    l = writen(1, mesg, len, &stdout_queue);
    if (l < 0)
    {
        int myerrno = errno;
        fprintf(stderr, "%s Error occurred on driver socket, errno=%d",
                time_stamp(), errno);
        errno = myerrno;
        perror(" ");
        die();
    }
#if ERQ_DEBUG > 0
    if (l != len)
        fprintf( stderr
               , "%s Driver-erq socket blocked, queueing %d bytes\n"
               , time_stamp(), len);
#endif
} /* write1() */
示例#5
0
int main(){
	// initialize hardware
	// Ports
	DDRB = (1<<PB0) | (1<<PB4); // MISO and PB0
	// spi
	SPCR = (1<<SPIE) | (1<<SPE);	// interrupt, f/4
	SPDR = 0;
	// timer counter 1
	OCR1A = TIMEOUT;
	uint16_t risingEdge = 0;
	uint16_t fallingEdge = 0;
	
	while(1){
		// trigger the sonar with a 5 micro second pulse
		DDRB |= (1<<PB0);
		cli();
		// atmega88pa pins can be flipped by writing to them
		// hence the two writes and not one write and one
		// clear
		PINB |= (_BV(PB0));
		_delay_us(5);
		PINB |= (_BV(PB0));
		sei();
		// PB0 now input to receive pulse from Ping)))
		DDRB &=~(1<<PB0);
		// Start Timer
		// set timer up to capture incoming pulse
		// rising edge, ctc, OCR1A as top, f/8
		TCCR1B = (1<<ICES1) | (1<<WGM12) | (1<<CS11);
		// clear pending interrupts
		TIFR1 |= (1<<ICF1) | (1<<OCF1B) | (1<<OCF1A);
		// input capture compA interrupt enabled
		TIMSK1 = (1<<ICIE1) | (1<<OCIE1A);
		
		// look for rising edge, timestamp it then look for falling edge, timestamp it.
		// Do math to find distance. Distance is just a number of counts not normal units
		// ie inches or cm.
		while(conversionComplete == 0){
			if(edgeDetect == 1)
				risingEdge = time_stamp(0);
			if(edgeDetect == 3){
				cli();
				fallingEdge = time_stamp(1);
				distance = fallingEdge - risingEdge;
				SPDR = low(distance);
				conversionComplete = 1;
				sei();
			}
		}
		// delay 200 microseconds before next reading 
		// as instructed by Ping))) datasheet
		// stop and reset timer
		conversionComplete = 0;
		TCCR1B = 0x00;
		TCNT1 = 0x0000;
		TIMSK1 = 0x00;
		_delay_us(200);
	}
}
示例#6
0
/** Fire off all timed handlers that are ready.
 *  This function is called internally by the event loop.
 *
 *  @param ctx a Strophe context object
 *
 *  @return the time in milliseconds until the next handler will be ready
 */
uint64_t handler_fire_timed(xmpp_ctx_t * const ctx)
{
    xmpp_connlist_t *connitem;
    xmpp_handlist_t *handitem, *temp;
    int ret, fired;
    uint64_t elapsed, min;

    min = (uint64_t)(-1);

    connitem = ctx->connlist;
    while (connitem) {
	if (connitem->conn->state != XMPP_STATE_CONNECTED) {
	    connitem = connitem->next;
	    continue;
	}
	
	/* enable all handlers that were added */
	for (handitem = connitem->conn->timed_handlers; handitem;
	     handitem = handitem->next)
	    handitem->enabled = 1;

	handitem = connitem->conn->timed_handlers;
	while (handitem) {
	    /* skip newly added handlers */
	    if (!handitem->enabled) {
		handitem = handitem->next;
		continue;
	    }

	    /* only fire user handlers after authentication */
	    if (handitem->user_handler && !connitem->conn->authenticated) {
		handitem = handitem->next;
		continue;
	    }

	    fired = 0;
	    elapsed = time_elapsed(handitem->last_stamp, time_stamp());
	    if (elapsed >= handitem->period) {
		/* fire! */
		fired = 1;
		handitem->last_stamp = time_stamp();
		ret = ((xmpp_timed_handler)handitem->handler)(connitem->conn, handitem->userdata);
	    } else if (min > (handitem->period - elapsed))
		min = handitem->period - elapsed;
		
	    temp = handitem;
	    handitem = handitem->next;

	    /* delete handler if it returned false */
	    if (fired && !ret)
		xmpp_timed_handler_delete(connitem->conn, temp->handler);
	}

	connitem = connitem->next;
    }

    return min;
}
示例#7
0
void exe_remove(t_dir* lroot, char* name, int size){
	int i;
	int filesize;
	t_file *tempLFile = NULL;

	//my_int(size);
	p_node *currentChild;
	t_metafile *cf;
printf("Test 11\n");
	if (lroot->GFiles->head == NULL)
		return;
	
	//my_int(size);
	if(size <=0)
		return;
	
	currentChild = lroot->GFiles->head;
	cf = (t_metafile*)currentChild->object;

	for (i=0; i < lroot->GFiles->size; i++){
		if (!my_strcmp(cf->filename, name)){
			plus_filesize(filesize);	
	
			cf->filesize = cf->filesize - size;
			filesize = cf->filesize;

			minus_filesize(filesize);
			if (filesize <= 0){
				free_Lfile(cf->LFile);
				cf->tv = time_stamp();
				cf->LFile = NULL;
				cf->filesize = 0;
				return;
			}
			if (filesize < gl_blocksize){
				cf->tv = time_stamp();
				return;
			}	


			while (filesize > gl_blocksize){
				filesize -= gl_blocksize;
				if (tempLFile == NULL)
					tempLFile = cf->LFile;
				tempLFile = tempLFile->next;
			}

			cf->tv = time_stamp();
			free_Lfile(tempLFile->next);
			tempLFile->next = NULL;
			return;
		}
		currentChild = currentChild->next;
		cf = (t_metafile*)currentChild->object;
	}	
	
}
示例#8
0
int on_connection(struct rdma_cm_id *id)
{
  on_connect(id->context);
  time_stamp(1);
  time_stamp(4);
  //send_mr(id->context);
  conn_context = (void*)id->context;
  return 0;
}
示例#9
0
/*-------------------------------------------------------------------------*/
void
load_wiz_file (void)

/* Load the old wizlist from the wizlist file and add it's data to
 * the wizlist already in memory.
 *
 * This function is called at driver start up.
 * TODO: Since the wizlist is saved from the mudlib, this function
 * TODO:: should be implemented on mudlib level, too.
 */

{
    char buff[1000];
    FILE *f;

    if (wizlist_name[0] == '\0')
        return;

    f = fopen(wizlist_name, "r");
    if (f == NULL)
        return;

    while (fgets(buff, sizeof buff, f) != NULL)
    {
        char *p;
        uint32 score;

        p = strchr(buff, ' ');
        if (p == 0)
        {
            fprintf(stderr, "%s Bad WIZLIST file '%s'.\n"
                          , time_stamp(), wizlist_name);
            break;
        }
        *p = '\0';
        p++;
        if (*p == '\0')
        {
            fprintf(stderr, "%s Bad WIZLIST file '%s'.\n"
                          , time_stamp(), wizlist_name);
            break;
        }
        score = atoi(p);
        if (score > 0)
        {
            string_t * tmp;

            tmp = new_mstring(buff);
            add_name(tmp)->score += score;
            free_mstring(tmp);
        }
    }
    fclose(f);
} /* load_wiz_file() */
示例#10
0
void xor_redundancy_2()
{
    INIT_TEST_CASE;

    typedef write_export<
            in_order<
            xor_fixed_redundancy<
            final_layer
            >>> coder;
    
    uint32_t symbol_size = 101;
    uint32_t N = 100003;
    
    coder* c = new coder({ {"xor_fixed_redundancy::amount", 2} });
    
    c->connect_signal_fw(boost::bind(&coder::write_pkt, c, _1));
    
    T_pkt_queue Q;
    c->set_export_buffer(&Q);
    
    p_pkt_buffer A = new_pkt_buffer();
    for (uint32_t i = 0; i < N; ++i)
    {
        A->clear();
        A->data_push(symbol_size);
        memset(A->head, i, symbol_size);
        c->read_pkt(A);
    }

    TEST_EQ(N, Q.size());

    uint64_t start_time = time_stamp();

    for (uint32_t i = 0; i < N; ++i)
    {
        A->clear();
        A->data_push(symbol_size);
        memset(A->head, i, symbol_size);
        bool r = std::equal(A->head, A->head+symbol_size, Q[i]->head);
        if (r != true)
        {
            A->print_head(A->len, "A");
            Q[i]->print_head(Q[i]->len, "Q");
        }
        TEST_EQ(r, true);
    }
    
    uint64_t end_time = time_stamp();
    TEST_LTE(end_time - start_time, 12000UL);
    
    delete c;

    CONCLUDE_TEST_CASE;
}
示例#11
0
int on_route_resolved(struct rdma_cm_id *id)
{
  struct rdma_conn_param cm_params;
  time_stamp(15);
  //printf("route resolved.\n");
  build_params(&cm_params);
  TEST_NZ(rdma_connect(id, &cm_params));
  time_stamp(16);

  return 0;
}
示例#12
0
int on_addr_resolved(struct rdma_cm_id *id)
{
  //printf("address resolved.\n");

  build_connection(id);
  time_stamp(13);   
  //sprintf(get_local_message_region(id->context), "message from active/client side with pid %d", getpid());
  TEST_NZ(rdma_resolve_route(id, TIMEOUT_IN_MS));
  time_stamp(14);

  return 0;
}
示例#13
0
static int create_rdma(void *ctx)
{

  //  struct addrinfo *addr;
  struct rdma_cm_event *event = NULL;
  struct rdma_cm_id *id = NULL;
  rdma_cm_event_handler event_handler = NULL;

  /*
  if (strcmp(argv[1], "write") == 0)
    set_mode(M_WRITE);
  else if (strcmp(argv[1], "read") == 0)
    set_mode(M_READ);
  else
    usage(argv[0]);
  */


 // TEST_NZ(getaddrinfo(s_ip, s_port, NULL, &addr));
  struct sockaddr_in addr = { 0 };
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = htonl(ip);
  addr.sin_port = htons(port);


  //TEST_Z(ec = rdma_create_event_channel()); 
  TEST_NZ( id = rdma_create_id( event_handler, NULL, RDMA_PS_TCP, IB_QPT_RC ) ); //WHAT QP?
  TEST_NZ( rdma_resolve_addr(id, NULL, (struct sockaddr*) &addr, TIMEOUT_IN_MS) );

//  kfree(addr);


  time_stamp(0);


  while ( event_handler(id, event) == 0) {
    struct rdma_cm_event event_copy;

    memcpy(&event_copy, event, sizeof(*event));
//    rdma_ack_cm_event(event);


    if (on_event(id, &event_copy))
      break;
  }

  rdma_destroy_id(id);

  time_stamp(9);
  time_calculate();
  return 0;
}
示例#14
0
文件: jacobi-v3.c 项目: 8l/rose
void driver( )
{
  initialize();

  time1 = time_stamp();
  /* Solve Helmholtz equation */
  jacobi ();
  time2 = time_stamp();

  printf("------------------------\n");     
  printf("Execution time = %f\n",time2-time1);
  /* error_check (n,m,alpha,dx,dy,u,f)*/
  error_check ( );
}
示例#15
0
文件: setup.c 项目: erinaldi/milc_qcd
/* SETUP ROUTINES */
static int initial_set(){
  int prompt,status;
#ifdef FIX_NODE_GEOM
  int i;
#endif
  /* On node zero, read lattice size and send to others */
  if(mynode()==0){
    /* print banner */
    printf("SU3 clover, staggered and naive valence fermions\n");
    printf("MIMD version %s\n",MILC_CODE_VERSION);
    printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
    gethostname(hostname, 128);
    printf("Host(0) = %s\n",hostname);
    printf("Username = %s\n", getenv("USER"));
    time_stamp("start");
    
    status = get_prompt(stdin,  &prompt );
    
    IF_OK status += get_i(stdin,prompt,"nx", &param.nx );
    IF_OK status += get_i(stdin,prompt,"ny", &param.ny );
    IF_OK status += get_i(stdin,prompt,"nz", &param.nz );
    IF_OK status += get_i(stdin,prompt,"nt", &param.nt );
#ifdef FIX_NODE_GEOM
    IF_OK status += get_vi(stdin, prompt, "node_geometry", 
			   param.node_geometry, 4);
#ifdef FIX_IONODE_GEOM
    IF_OK status += get_vi(stdin, prompt, "ionode_geometry", 
			   param.ionode_geometry, 4);
#endif
#endif
    IF_OK status += get_s(stdin, prompt,"job_id",param.job_id);
    
    if(status>0) param.stopflag=1; else param.stopflag=0;
  } /* end if(mynode()==0) */

  /* Node 0 broadcasts parameter buffer to all other nodes */
  broadcast_bytes((char *)&param,sizeof(param));

  if( param.stopflag != 0 )
    normal_exit(0);

  nx=param.nx;
  ny=param.ny;
  nz=param.nz;
  nt=param.nt;
  iseed=param.iseed;
#ifdef FIX_NODE_GEOM
  for(i = 0; i < 4; i++)
    node_geometry[i] = param.node_geometry[i];
#ifdef FIX_IONODE_GEOM
  for(i = 0; i < 4; i++)
    ionode_geometry[i] = param.ionode_geometry[i];
#endif
#endif
  
  this_node = mynode();
  number_of_nodes = numnodes();
  volume=nx*ny*nz*nt;
  return(prompt);
}
示例#16
0
文件: erq.c 项目: amotzkau/ldmud
/*-------------------------------------------------------------------------*/
void
bad_request (char *mesg)

/* ERQ received a bad message in <mesg> - print some diagnostics.
 */

{
    fprintf(stderr, "%s Bad request %d\n", time_stamp(), mesg[8]);
    fprintf(stderr, "%s %x %x %x %x %x %x %x %x %x\n", time_stamp(),
        mesg[0], mesg[1], mesg[2], mesg[3], mesg[4],
        mesg[5], mesg[6], mesg[7], mesg[8]);
    fprintf(stderr, "%s %c %c %c %c %c %c %c %c %c\n", time_stamp(),
        mesg[0], mesg[1], mesg[2], mesg[3], mesg[4],
        mesg[5], mesg[6], mesg[7], mesg[8]);
    reply1(get_handle(mesg), "", 0);
} /* bad_request() */
示例#17
0
void print_can_frame(char *format_string, unsigned char *netframe, int verbose) {
    uint32_t canid;
    int i, dlc;
    char timestamp[16];

    if (!verbose)
	return;

    memcpy(&canid, netframe, 4);
    dlc = netframe[4];
    time_stamp(timestamp);
    printf("%s   ", timestamp);
    printf(format_string, ntohl(canid) & CAN_EFF_MASK, netframe[4]);
    for (i = 5; i < 5 + dlc; i++) {
	printf(" %02x", netframe[i]);
    }
    if (dlc < 8) {
	printf("(%02x", netframe[i]);
	for (i = 6 + dlc; i < CAN_ENCAP_SIZE; i++) {
	    printf(" %02x", netframe[i]);
	}
	printf(")");
    } else {
	printf(" ");
    }
    printf("  ");
    for (i = 5; i < CAN_ENCAP_SIZE; i++) {
	if (isprint(netframe[i]))
	    printf("%c", netframe[i]);
	else
	    putchar('.');
    }

    printf("\n");
}
示例#18
0
int main(int argc, char *argv[])
{
   char *infile, *outfile;
   Volume_Info volume_info;
   char *arg_string;
   int input_icvid, output_icvid;
   unsigned char *image;
   int islice;

   /* Get arguments */
   if (argc != 3) {
      (void) fprintf(stderr, "Usage: %s <infile.mnc> <outfile.mnc>\n",
                     argv[0]);
      exit(EXIT_FAILURE);
   }
   infile = argv[1];
   outfile = argv[2];

   /* Save list of arguments as string */
   arg_string = time_stamp(argc, argv);

   /* Read in input volume information */
   input_icvid = get_volume_info(infile, &volume_info);

   /* Print out volume information */
   (void) printf("File %s:\n", infile);
   (void) printf("  maximum = %10g, minimum = %10g\n",
                 volume_info.maximum, volume_info.minimum);
   (void) printf("  slices  = %10s: n=%3d, step=%10g, start=%10g\n",
                 volume_info.dimension_names[SLICE], 
                 (int) volume_info.nslices,
                 volume_info.step[SLICE], volume_info.start[SLICE]);
   (void) printf("  rows    = %10s: n=%3d, step=%10g, start=%10g\n",
                 volume_info.dimension_names[ROW], 
                 (int) volume_info.nrows,
                 volume_info.step[ROW], volume_info.start[ROW]);
   (void) printf("  columns = %10s: n=%3d, step=%10g, start=%10g\n",
                 volume_info.dimension_names[COLUMN], 
                 (int) volume_info.ncolumns,
                 volume_info.step[COLUMN], volume_info.start[COLUMN]);

   /* Save the volume, copying information from input file */
   output_icvid = save_volume_info(input_icvid, outfile, arg_string, 
                                   &volume_info);

   /* Loop through slices, copying them */
   image = malloc(volume_info.nrows * volume_info.ncolumns * sizeof(*image));
   for (islice=0; islice < volume_info.nslices; islice++) {
      get_volume_slice(input_icvid, &volume_info, islice, image);
      save_volume_slice(output_icvid, &volume_info, islice, image,
                        volume_info.minimum, volume_info.maximum);
   }

   /* Free up image and close files */
   close_volume(input_icvid);
   close_volume(output_icvid);
   free(image);

   exit(EXIT_SUCCESS);
}
示例#19
0
void print_can_frame(char *format_string, unsigned char *netframe) {
    uint32_t canid;
    int i, dlc;

    memcpy(&canid, netframe, 4);
    dlc = netframe[4];
    printf("%s   ",time_stamp()); 
    printf(format_string, ntohl(canid) & CAN_EFF_MASK, netframe[4]);
    for (i = 5; i < 5 + dlc; i++) {
	printf(" %02x", netframe[i]);
    }
    if (dlc < 8) {
	printf("(%02x", netframe[i]);
	for (i = 6 + dlc ; i < 13 ; i++) {
	    printf(" %02x", netframe[i]);
        }
	printf(")");
    } else {
	printf(" ");
    }
    printf("  ");
    for (i = 5; i < 13; i++) {
	if(isprint(netframe[i]))
	    printf("%c",netframe[i]);
        else
	    putchar(46);
    }

    printf("\n");
}
示例#20
0
void log_prog_params(FILE *FP) {
    fprintf( FP,
	     "#<\n#Date: %s"
	     "#EnergyModel: dangle=%d Temp=%.1f logML=%s Par=%s\n"
	     "#MoveSet: noShift=%s noLP=%s\n"
	     "#Simulation: num=%d time=%.2f seed=%s fpt=%s mc=%s\n"
	     "#Simulation: phi=%g pbounds=%s\n"
	     "#Output: log=%s silent=%s lmin=%s cut=%.2f\n",
	     time_stamp(),
	     GTV.dangle,
	     GSV.Temp,
	     verbose(GTV.logML, "logML"),
	     GAV.ParamFile,
	     verbose(GTV.noShift, NULL),
	     verbose(GTV.noLP, NULL),
	     GSV.num,
	     GSV.time,
	     verbose(GTV.seed, "seed"),
	     verbose(GTV.fpt, NULL),
	     verbose(GTV.mc, "met"),
	     GSV.phi,
	     verbose(GTV.phi, "pbounds"),
	     GAV.BaseName,
	     verbose(GTV.silent, NULL),
	     verbose(GTV.lmin, NULL),
	     GSV.cut);
    fflush(FP);
}
示例#21
0
void store_aws_data(int8 macro, int16 mmacro_var)
{
   char comma[2] = {',' , '\0'};
   char endofline[3] = {'\r' , '\n' , '\0'};
   char config_str[30];
   
   clear_data_buffer();
   time_stamp();
   strcat(data_buffer, time_stmp_str);
   strcat(data_buffer, comma);
   sprintf(config_str, "%u,%Lu",macro,mmacro_var);
   strcat(data_buffer, config_str);
   strcat(data_buffer, endofline);
   
   if (nv_report_mode == 4) fprintf(COM_A, "%s\r\n", data_buffer);

   if(sd_status==0){
   
      buffer_select = 0;
      
      heartbeat(FALSE);
         append_data(file_ptr_raw_all);
      heartbeat(TRUE);         
      
      heartbeat(FALSE);
         append_data(file_ptr_raw_new);   
      heartbeat(TRUE);
   }
}
示例#22
0
void store_wms_data(int8 macro)
{
   char comma[2] = {',' , '\0'};
   char endofline[3] = {'\r' , '\n' , '\0'};
   char config_str[30];
   
   clear_data_buffer();
   time_stamp();
   strcat(data_buffer, time_stmp_str);
   strcat(data_buffer, comma);
   sprintf(config_str, "%u,%Lu,%Lu,%Lu,%Lu,%Lu,%Lu,%Ld",
         macro,nv_macro_mode, nv_interval, nv_volume, nv_port, nv_sample,
         e_target_port[0],m_lin_pos[1]);  // changed from e_port[0]
   strcat(data_buffer, config_str);
   strcat(data_buffer, endofline);
   
   fprintf(COM_A, "%s\r\n", data_buffer);

   if(sd_status==0){
   
      buffer_select = 0;
      
      heartbeat(FALSE);
         append_data(file_ptr_raw_all);
      heartbeat(TRUE);         
      
      heartbeat(FALSE);
         append_data(file_ptr_raw_new);   
      heartbeat(TRUE);
   }
}
示例#23
0
文件: setup.c 项目: liu0604/milc_qcd
/* SETUP ROUTINES */
int initial_set() {
    int prompt,status;
    /* On node zero, read lattice size, seed, nflavors and send to others */
    if(mynode()==0) {
        /* print banner */
        printf("SU3 with Wilson fermions\n");
        printf("Microcanonical simulation with refreshing\n");
        printf("MIMD version 6\n");
        printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());
#ifdef HMC_ALGORITHM
        printf("Hybrid Monte Carlo algorithm\n");
#endif
#ifdef PHI_ALGORITHM
        printf("PHI algorithm\n");
#else
        printf("R algorithm\n");
#endif
#ifdef SPECTRUM
        printf("With spectrum measurements\n");
#endif
        time_stamp("start");
        status = get_prompt(stdin, &prompt);
        IF_OK status += get_i(stdin,  prompt, "nflavors", &par_buf.nflavors );
#ifdef PHI_ALGORITHM
        if( par_buf.nflavors != 2) {
            printf("Dummy! Use phi algorithm only for two flavors\n");
            terminate(-1);
        }
#endif
        IF_OK status += get_i(stdin,  prompt, "nx", &par_buf.nx );
        IF_OK status += get_i(stdin,  prompt, "ny", &par_buf.ny );
        IF_OK status += get_i(stdin,  prompt, "nz", &par_buf.nz );
        IF_OK status += get_i(stdin,  prompt, "nt", &par_buf.nt );
        IF_OK status += get_i(stdin,  prompt, "iseed", &par_buf.iseed );
        if(status>0) par_buf.stopflag=1;
        else par_buf.stopflag=0;

    } /* end if(mynode()==0) */

    /* Node 0 broadcasts parameter buffer to all other nodes */
    broadcast_bytes((char *)&par_buf,sizeof(par_buf));

    if( par_buf.stopflag != 0 )
        normal_exit(0);


    nx=par_buf.nx;
    ny=par_buf.ny;
    nz=par_buf.nz;
    nt=par_buf.nt;
    iseed=par_buf.iseed;
    nflavors=par_buf.nflavors;

    this_node = mynode();
    number_of_nodes = numnodes();
    volume=nx*ny*nz*nt;
    total_iters=0;
    return(prompt);
}
示例#24
0
文件: setup.c 项目: liu0604/milc_qcd
/* SETUP ROUTINES */
int initial_set(){
int prompt,status;
    /* On node zero, read lattice size, seed, and send to others */
    if(mynode()==0){
	/* print banner */
	printf("SU3 with improved KS action\n");
	printf("Eigenvalues and eigenvectors\n");
	printf("MIMD version 6\n");
	printf("Machine = %s, with %d nodes\n",machine_type(),numnodes());

	gethostname(hostname, 128);
	printf("Host(0) = %s\n",hostname);
	printf("Username = %s\n", getenv("USER"));
	time_stamp("start");
	get_utc_datetime(utc_date_time);
	
	/* Print list of options selected */
	node0_printf("Options selected...\n");
	show_generic_opts();
	show_generic_ks_opts();
	
#if FERM_ACTION == HISQ
	show_su3_mat_opts();
	show_hisq_links_opts();
#elif FERM_ACTION == HYPISQ
	show_su3_mat_opts();
	show_hypisq_links_opts();
#endif

	status=get_prompt(stdin, &prompt);

	IF_OK status += get_i(stdin, prompt,"nx", &par_buf.nx );
	IF_OK status += get_i(stdin, prompt,"ny", &par_buf.ny );
	IF_OK status += get_i(stdin, prompt,"nz", &par_buf.nz );
	IF_OK status += get_i(stdin, prompt,"nt", &par_buf.nt );
	IF_OK status += get_i(stdin, prompt,"iseed", &par_buf.iseed );

	if(status>0) par_buf.stopflag=1; else par_buf.stopflag=0;
    } /* end if(mynode()==0) */

    /* Node 0 broadcasts parameter buffer to all other nodes */
    broadcast_bytes((char *)&par_buf,sizeof(par_buf));

    if( par_buf.stopflag != 0 )
      normal_exit(0);

    nx=par_buf.nx;
    ny=par_buf.ny;
    nz=par_buf.nz;
    nt=par_buf.nt;
    iseed=par_buf.iseed;
    
    this_node = mynode();
    number_of_nodes = numnodes();
    volume=nx*ny*nz*nt;
    total_iters=0;
    return(prompt);
}
示例#25
0
文件: logmsg.c 项目: guygal/egui
void log_msg(const char *file, int line, unsigned short level, int err, char *fmt, ...)
{
	FILE *fp = log_fp;
	va_list args;
	char *time = NULL;
	char tbuf[TIMESTAMP_SIZE];
	char mbuf[MAX_LINE_SIZE];

	if (level > log_level || log_type == LOGTYPE_NULL)
		return;

	va_start(args, fmt);

	if (fp == NULL)
		fp = stderr;

	if (time_stamp_log) {
		time_stamp(tbuf);
		time = tbuf;
	}

	snprintf(mbuf, sizeof(mbuf), "%s[%d](%d/%lu): %s%s%.*s%s",
			file, line,
			getpid(), pthread_self() / 100000,
			(time ? time : ""),
			(time ? ": " : ""),
			level, "          ",
			(level ? "" : "ERROR: "));

	vsnprintf(mbuf + strlen(mbuf), sizeof(mbuf) - strlen(mbuf), fmt, args);

	va_end(args);

	if (err) {
		snprintf(mbuf + strlen(mbuf),
				sizeof(mbuf) - strlen(mbuf),
				": (%s)", strerror(err));
	}

	pthread_mutex_lock(&mutexlock);

	switch (log_type) {
	case LOGTYPE_LOCAL:
		fprintf(fp, "%s\n", mbuf);
		fflush(fp);
		break;

	case LOGTYPE_SYSLOG:
		msg_to_syslog(level, mbuf);
		break;

	default:
		break;
	}

	pthread_mutex_unlock(&mutexlock);
}
示例#26
0
 bool first_pkt_time_out()
 {
     if (rx_pkt_queue.size() == 0)
     {
         return false;
     }
     uint64_t time_now = time_stamp();
     return (rx_pkt_queue.begin()->second->time_stamp + (1000000 * pkt_timeout) <= time_now);
 }
示例#27
0
文件: server.cpp 项目: CCJY/ACE
static void
exit_server (int sig)
{
  ACE_DEBUG ((LM_DEBUG,
              "%s exiting on signal %S\n",
              time_stamp (),
              sig));
  ACE_OS::exit (0);
}
示例#28
0
bool
FFmpegInput::seek (int frame)
{
    int64_t offset = time_stamp (frame);
    int flags = AVSEEK_FLAG_BACKWARD;
    avcodec_flush_buffers (m_codec_context);
    av_seek_frame (m_format_context, -1, offset, flags );
    return true;
}
示例#29
0
int main(int argc, char *argv[])
{
   char **input_files;
   char *output_file;
   char *arg_string;
   int num_input_files;
   int inmincid;
   Loop_Options *loop_options;
   Program_Data program_data;

   /* Save time stamp and args */
   arg_string = time_stamp(argc, argv);

   /* Get arguments */
   if (ParseArgv(&argc, argv, argTable, 0) || (argc < 3)) {
      (void) fprintf(stderr, 
                     "\nUsage: %s [options] <in1.mnc> [...] <out.mnc>\n",
                     argv[0]);
      (void) fprintf(stderr,
                     "       %s -help\n\n",
                     argv[0]);
      exit(EXIT_FAILURE);
   }
   input_files = &argv[1];
   num_input_files = argc - 2;
   output_file = argv[argc-1];

   /* Open the first input file and get the vector length */
   inmincid = miopen(input_files[0], NC_NOWRITE);
   if (get_vector_length(inmincid) > 1) {
      (void) fprintf(stderr, "Input file %s is not a scalar file\n",
                     input_files[0]);
      exit(EXIT_FAILURE);
   }

   /* Set up looping options */
   loop_options = create_loop_options();
   set_loop_clobber(loop_options, clobber);
   set_loop_verbose(loop_options, verbose);
#if MINC2
   set_loop_v2format(loop_options, v2format);
#endif /* MINC2 */
   set_loop_datatype(loop_options, datatype, is_signed, 
                     valid_range[0], valid_range[1]);
   set_loop_output_vector_size(loop_options, num_input_files);
   set_loop_buffer_size(loop_options, (long) buffer_size * 1024);
   set_loop_first_input_mincid(loop_options, inmincid);
   set_loop_accumulate(loop_options, TRUE, 0, NULL, NULL);

   /* Do loop */
   voxel_loop(num_input_files, input_files, 1, &output_file, 
              arg_string, loop_options,
              do_makevector, (void *) &program_data);

   exit(EXIT_SUCCESS);
}
示例#30
0
void on_completion(struct ibv_wc *wc)
{
  struct connection *conn = (struct connection *)(uintptr_t)wc->wr_id;

  if (wc->status != IBV_WC_SUCCESS){
    if (wc->opcode == IBV_WC_RDMA_WRITE)
        printf("IBV_WC_RDMA_WRITE failed!\n");
    die("on_completion: status is not IBV_WC_SUCCESS.");
  }

  if (wc->opcode & IBV_WC_RECV) {
    if ((conn->recv_state == RS_INIT) && (conn->recv_msg->type == MSG_MR)) {  //RECV Server MR
      memcpy(&conn->peer_mr, &conn->recv_msg->data.mr, sizeof(conn->peer_mr));
      post_receives(conn); /* only rearm for MSG_MR */
      conn->recv_state = RS_MR_RECV;
      if (conn->send_state == SS_INIT && conn->recv_state == RS_MR_RECV) {
        sem_post(&init_wait);  //end of init
      }
    }else if (conn->recv_state == RS_MR_RECV){  //RECV Server Done msg
        conn->recv_state = RS_DONE_RECV;
    }
  }else { //Send completion
    if ((conn->send_state == SS_INIT) && (conn->recv_state == RS_MR_RECV)) {
      if (wc->opcode == IBV_WC_RDMA_READ){
  	time_stamp(7);
        sem_post(&read_ops);
      }
      if (wc->opcode == IBV_WC_SEND){ //Send Done msg
        conn->send_state = SS_DONE_SENT;
        sem_post(&done_ops);
      }
      if (wc->opcode == IBV_WC_RDMA_WRITE){
        sem_post(&write_ops);
          time_stamp(3);
      }
    }
  }

  if ((conn->send_state == SS_DONE_SENT) && (conn->recv_state == RS_DONE_RECV)) {
    //printf("remote buffer: %s\n", get_local_message_region(conn));
    rdma_disconnect(conn->id);
  }
}