int main(int argc, char* argv[]) { glutInit(&argc, argv); display_init(); comm_initialize(); /* Call backs */ glutDisplayFunc( display); glutReshapeFunc( reshape); glutKeyboardFunc( keyboard); glutIdleFunc( comm_read); satellite = add_element("Satellite"); satellite_camera = new Camera(); current_camera = satellite_camera; planet = add_element("Ball"); for (int ii=0; ii<3 ; ii++) { planet->pos[ii] = 0.0; } glutMainLoop(); return 0; }
static int multi_thread_test() { printids("main thread:"); int err; #if 1 /*Process: *1,thread0 is thr_fn0, which reads input from standard input. *2,thread1 and thread2 waits for data. *3,thread0 send the input string to thread1, and reversed input string to thread2. *4,thread1 and thread2 receives data and print them. *5,go back to step 2. */ comm_initialize(device1,COMM_BLOCK); comm_initialize(device2,COMM_BLOCK); err = pthread_create(&ntid1, NULL, thr_fn0, NULL); if (err != 0) { perror("create thread error!\n"); return err; } /*pthread_detach(ntid1);*/ err = pthread_create(&ntid2, NULL, thr_fn1, NULL); if (err != 0) { perror("create thread error!\n"); return err; } /*pthread_detach(ntid2);*/ err = pthread_create(&ntid3, NULL, thr_fn2, NULL); if (err != 0) { perror("create thread error!\n"); return err; } /*pthread_detach(ntid3);*/ pthread_join(ntid1,NULL); pthread_join(ntid2,NULL); pthread_join(ntid3,NULL); comm_release(device1); comm_release(device2); comm_info("Test end.\n"); #endif }
int main(int argc, char *argv[]) { measurement_p l,g; test_p tst = (test_p)malloc(sizeof(test_t)); /* initialize communication and get options */ comm_initialize(tst, &argc, &argv); ROOTONLY printf("%s\n", COPYRIGHT); general_options(tst,argc,argv); /* create measurement structs */ l = measurement_create(tst, "local"); g = measurement_create(tst, "global"); ROOTONLY mkdir(tst->case_name, 0755); ROOTONLY printf("Confidence: testing...\n"); measurement_collect(tst, l); ROOTONLY printf("Confidence: local analysis...\n"); measurement_analyze(tst, l, -1.0); ROOTONLY printf("Confidence: remote analysis\n"); comm_aggregate(g, l); measurement_analyze(tst, g, -1.0); ROOTONLY printf("Confidence: saving results\n"); measurement_serialize(tst, g, root_rank); /* free measurement and test structs */ l = measurement_destroy(l); g = measurement_destroy(g); if (tst->argv != NULL) free(tst->argv); if (tst->tsdump != NULL) free(tst->tsdump); free(tst); comm_finalize(); return 0; }
static int single_thread_test() { char send_str[] = "send data"; int send_count = sizeof(send_str); int sent = 0; char recv_str[10] = {'\0',}; int rcv_len; int received = 0; int device = 0;/*which device [0,31]*/ int times = 1; comm_initialize(device,COMM_NBLOCK); #if 1 /*XXX test create*/ comm_info("Test create start.\n"); comm_create(device, nblks, blksz); comm_info("Test create end.\n"); #endif #if 1 /*XXX test send and receive one time.*/ comm_info("Test send start.\n"); comm_info("Send data is:%s\n",send_str); sent = comm_send(device, send_str, send_count); comm_info("Sent length is:%d\n",sent); comm_info("Test receive start.\n"); do { rcv_len = comm_getlen(device); }while(rcv_len < 0); comm_receive(device, recv_str, rcv_len); comm_info("Received data is:%s\n",recv_str); comm_info("Received length is:%d\n",rcv_len); #endif #if 1 /*XXX test send and receive many times*/ while(times<6) { comm_info("times:%d.\n",times); send_str[0]+=1; times +=1; comm_info("Test send start.\n"); comm_info("Send data is:%s\n",send_str); sent = comm_send(device, send_str, send_count); comm_info("Sent length is:%d\n",sent); comm_info("Test receive start.\n"); do { rcv_len = comm_getlen(device); }while(rcv_len < 0); comm_receive(device, recv_str, rcv_len); comm_info("Received data is:%s\n",recv_str); comm_info("Received length is:%d\n",rcv_len); } #endif comm_release(device); comm_info("Test end.\n"); }