static void get_grey_data(DB *db, DB_TXN *txn) { int rc; rc = db->get(db, txn, &dbkey, &dbdata, 0); if (rc == DB_NOTFOUND) { touch_data(); build_data(); } else if (rc) { log_db_error("get failed", rc); jmperr("get failed"); } else { time_t ref_time; double age_max; if (triplet_data.pass_count) { ref_time = triplet_data.access_time; age_max = pass_max_idle; } else { ref_time = triplet_data.create_time; age_max = bloc_max_idle; } touch_data(); /* Expire IDLE records */ if (difftime(triplet_data.access_time, ref_time) > age_max) build_data(); } }
// Main program int main(void) { char i; char *heap_end; // Initialize all modules uart_init(115200); accel_init(); touch_init((1 << 9) | (1 << 10)); // Channels 9 and 10 // usb_init(); setvbuf(stdin, NULL, _IONBF, 0); // No buffering // Run tests tests(); delay(500); RGB_LED(0,100,0); // Green // Welcome banner iprintf("\r\n\r\n====== Freescale Freedom FRDM-LK25Z\r\n"); iprintf("Built: %s %s\r\n\r\n", __DATE__, __TIME__); heap_end = _sbrk(0); iprintf("Heap: %p to %p (%d bytes used)\r\n", __heap_start, heap_end, heap_end - __heap_start); iprintf("Stack: %p to %p (%d bytes used)\r\n", &i, __StackTop, __StackTop - &i); iprintf("%d bytes free\r\n", &i - heap_end); for(;;) { iprintf("monitor> "); getchar(); iprintf("\r\n"); iprintf("Inputs: x=%5d y=%5d z=%5d ", accel_x(), accel_y(), accel_z()); iprintf("touch=(%d,%d)\r\n", touch_data(9), touch_data(10)); // usb_dump(); } }
/* * Measure RDS bandwidth (server side). */ void run_server_rds_bw(void) { char *buf; int sockfd; sockfd = init(); sync_test(); buf = qmalloc(Req.msg_size); while (!Finished) { int n = read(sockfd, buf, Req.msg_size); if (Finished) break; if (n != Req.msg_size) { LStat.r.no_errs++; continue; } LStat.r.no_bytes += n; LStat.r.no_msgs++; if (Req.access_recv) touch_data(buf, Req.msg_size); } stop_test_timer(); exchange_results(); free(buf); close(sockfd); }
int main (int argc, char *argv[]) { int i, ret; int size, is_server; double t_start = 0.0, t_end = 0.0; double latency; struct iovec s_iov, r_iov; uintptr_t peer_addr; int peer_pid; if (allocate_memory(&s_buf, &r_buf)) { /* Error allocating memory */ exit(-1); } is_server = (argc == 1); if (is_server) { fprintf(stderr, "server ready: %d, %p\n", getpid(), r_buf); while (1); } peer_pid = atoi(argv[1]); peer_addr = (uintptr_t) strtol(argv[2], NULL, 16); s_iov.iov_base = s_buf; r_iov.iov_base = (void *) peer_addr; print_header(); /* Latency test */ for(size = 0; size <= MAX_MSG_SIZE; size = (size ? size * 2 : 1)) { touch_data(s_buf, r_buf, size); if(size > LARGE_MESSAGE_SIZE) { loop = LOOP_LARGE; skip = SKIP_LARGE; } for(i = 0; i < loop + skip; i++) { if(i == skip) t_start = TIME(); s_iov.iov_len = r_iov.iov_len = size; ret = process_vm_writev(peer_pid, &s_iov, 1, &r_iov, 1, 0); if (ret != size) { fprintf(stderr, "process_vm_writev failed: %d\n", ret); exit(-1); } } t_end = TIME(); latency = (1.0 * (t_end-t_start)) / loop; fprintf(stderr, "%-*d%*.*f\n", 10, size, FIELD_WIDTH, FLOAT_PRECISION, latency); } return 0; }
/* * Measure RDMA bandwidth (client side). */ int rd_client_rdma_bw(DEVICE *dev, CONNECTION *con, size_t n_req, const void **local_addr, const void **remote_addr, const size_t *sizes) { rd_post_rdma_std(dev, opcode, NCQE); while (!Finished) { int i; struct ibv_wc wc[NCQE]; int n = rd_poll(&dev, wc, cardof(wc)); if (Finished) break; if (n > LStat.max_cqes) LStat.max_cqes = n; for (i = 0; i < n; ++i) { int status = wc[i].status; if (status == IBV_WC_SUCCESS) { if (opcode == IBV_WR_RDMA_READ) { LStat.r.no_bytes += dev.msg_size; LStat.r.no_msgs++; LStat.rem_s.no_bytes += dev.msg_size; LStat.rem_s.no_msgs++; if (Req.access_recv) touch_data(dev.buffer, dev.msg_size); } } else do_error(status, &LStat.s.no_errs); } rd_post_rdma_std(&dev, opcode, n); } stop_test_timer(); exchange_results(); rd_close(&dev); fprintf(stderr, "Max n %d\n", LStat.max_cqes); return 0; }
// Main program int main(void) { char i; char ch; char *heap_end; char inBuffer[BUF_SIZE]; int readLen,bufPos; int n; int nargs[10]; int hasAccelData = 0; int hasTouchData = 0; // Initialize all modules RGB_LED(100,0,0); //uart_init(115200); uart_init(9600); accel_init(); touch_init((1 << 9) | (1 << 10)); // Channels 9 and 10 // usb_init(); setvbuf(stdin, NULL, _IONBF, 0); // No buffering // Run tests tests(); delay(500); // Welcome banner iprintf("\r\n\r\n====== Freescale Freedom FRDM-LK25Z\r\n"); iprintf("Built: %s %s\r\n\r\n", __DATE__, __TIME__); heap_end = _sbrk(0); iprintf("Heap: %p to %p (%d bytes used)\r\n", __heap_start, heap_end, heap_end - (char *)__heap_start); iprintf("Stack: %p to %p (%d bytes used)\r\n", &i, __StackTop, (char *)__StackTop - &i); iprintf("%d bytes free\r\n", &i - heap_end); inBuffer[0] = 0; // reset buffer bufPos = 0; RGB_LED(0,100,0); // Green for(;;) { readLen = uart_read_nonblock(inBuffer+bufPos,BUF_SIZE-(bufPos+2)); if (readLen>0) { bufPos+=readLen; // quick trim while(bufPos>0 && isspace(inBuffer[bufPos-1])) bufPos--; inBuffer[bufPos] = 0; if (inBuffer[bufPos-1] == ';') { iprintf("(in buf = '%s', len=%d)\r\n",inBuffer,bufPos); switch(inBuffer[0]) { case 'C': n = sscanf(inBuffer+1,"%i,%i,%i",&nargs[0],&nargs[1],&nargs[2]); if(n==3) RGB_LED(nargs[0],nargs[1],nargs[2]); break; case 'R': RGB_LED(100,0,0); break; case 'G': RGB_LED(0,100,0); break; case 'B': RGB_LED(0,0,100); break; case 'A': hasAccelData = 1; break; case 'a': hasAccelData = 0; break; case 'T': hasTouchData = 1; break; case 't': hasTouchData = 0; break; case 'i': iprintf("[efb,0.1] empiriKit Freescale Board, v.0.1\r\n"); break; } bufPos = 0; // "clear" the buffer } } if (hasAccelData) iprintf("a%d,%d,%d;\r\n", accel_x(), accel_y(), accel_z()); if (hasTouchData) iprintf("t%d,%d;\r\n", touch_data(9), touch_data(10)); } }
int main (int argc, char *argv[]) { int myid, numprocs, i, j; int size; char *s_buf, *r_buf; double t_start = 0.0, t_end = 0.0, t = 0.0; int loop = 100; int window_size = 64; int skip = 10; int po_ret = process_options(argc, argv); if (po_okay == po_ret && cuda == options.accel) { if (init_cuda_context()) { fprintf(stderr, "Error initializing cuda context\n"); exit(EXIT_FAILURE); } } MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); if (0 == myid) { switch (po_ret) { case po_cuda_not_avail: fprintf(stderr, "CUDA support not enabled. Please recompile " "benchmark with CUDA support.\n"); break; case po_openacc_not_avail: fprintf(stderr, "OPENACC support not enabled. Please " "recompile benchmark with OPENACC support.\n"); break; case po_bad_usage: case po_help_message: usage(); break; } } switch (po_ret) { case po_cuda_not_avail: case po_openacc_not_avail: case po_bad_usage: MPI_Finalize(); exit(EXIT_FAILURE); case po_help_message: MPI_Finalize(); exit(EXIT_SUCCESS); case po_okay: break; } if(numprocs != 2) { if(myid == 0) { fprintf(stderr, "This test requires exactly two processes\n"); } MPI_Finalize(); exit(EXIT_FAILURE); } if (allocate_memory(&s_buf, &r_buf, myid)) { /* Error allocating memory */ MPI_Finalize(); exit(EXIT_FAILURE); } print_header(myid); /* Bandwidth test */ for(size = 1; size <= MAX_MSG_SIZE; size *= 2) { touch_data(s_buf, r_buf, myid, size); if(size > LARGE_MESSAGE_SIZE) { loop = LOOP_LARGE; skip = SKIP_LARGE; window_size = WINDOW_SIZE_LARGE; } if(myid == 0) { for(i = 0; i < loop + skip; i++) { if(i == skip) { t_start = MPI_Wtime(); } for(j = 0; j < window_size; j++) { MPI_Isend(s_buf, size, MPI_CHAR, 1, 100, MPI_COMM_WORLD, request + j); } MPI_Waitall(window_size, request, reqstat); MPI_Recv(r_buf, 4, MPI_CHAR, 1, 101, MPI_COMM_WORLD, &reqstat[0]); } t_end = MPI_Wtime(); t = t_end - t_start; } else if(myid == 1) { for(i = 0; i < loop + skip; i++) { for(j = 0; j < window_size; j++) { MPI_Irecv(r_buf, size, MPI_CHAR, 0, 100, MPI_COMM_WORLD, request + j); } MPI_Waitall(window_size, request, reqstat); MPI_Send(s_buf, 4, MPI_CHAR, 0, 101, MPI_COMM_WORLD); } } if(myid == 0) { double tmp = size / 1e6 * loop * window_size; fprintf(stdout, "%-*d%*.*f\n", 10, size, FIELD_WIDTH, FLOAT_PRECISION, tmp / t); fflush(stdout); } } free_memory(s_buf, r_buf, myid); MPI_Finalize(); if (cuda == options.accel) { if (destroy_cuda_context()) { fprintf(stderr, "Error destroying cuda context\n"); exit(EXIT_FAILURE); } } return EXIT_SUCCESS; }