void retro_run(void) { poll_cb(); static unsigned frame_cnt = 0; //fprintf(stderr, "[NX]: Start frame.\n"); //int64_t start_time = get_usec(); //platform_sync_to_vblank(); screen->Flip(); if (retro_60hz) { //int64_t start_time_frame = get_usec(); while (!run_main()); //int64_t total_time_frame = get_usec() - start_time_frame; //fprintf(stderr, "[NX]: total_time_frame took %lld usec.\n", (long long)total_time_frame); //int64_t start_time_frame_cb = get_usec(); video_cb(retro_frame_buffer, retro_frame_buffer_width, retro_frame_buffer_height, retro_frame_buffer_pitch); //int64_t total_time_frame_cb = get_usec() - start_time_frame_cb; //fprintf(stderr, "[NX]: total_time_frame_cb took %lld usec.\n", (long long)total_time_frame_cb); frame_cnt++; } else { if (frame_cnt % 6) { while (!run_main()); video_cb(retro_frame_buffer, retro_frame_buffer_width, retro_frame_buffer_height, retro_frame_buffer_pitch); } else video_cb(NULL, SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_WIDTH * sizeof(uint16_t)); // Dupe every 6th frame. frame_cnt++; } int16_t samples[(2 * 22050) / 60 + 1] = {0}; // Average audio frames / video frame: 367.5. unsigned frames = (22050 + (frame_cnt & 1 ? 30 : -30)) / 60; mixaudio(samples, frames * 2); audio_batch_cb(samples, frames); g_frame_cnt++; //int64_t total_time = get_usec() - start_time; //fprintf(stderr, "[NX]: Frame took %lld usec.\n", (long long)total_time); }
int main() { int err = 0; #ifdef __APPLE_CC__ pthread_t id; pthread_create(&id, NULL, run_main, &err); CFRunLoopSourceContext sourceContext; sourceContext.version = 0; sourceContext.info = NULL; sourceContext.retain = NULL; sourceContext.release = NULL; sourceContext.copyDescription = NULL; sourceContext.equal = NULL; sourceContext.hash = NULL; sourceContext.schedule = NULL; sourceContext.cancel = NULL; sourceContext.perform = NULL; CFRunLoopSourceRef sourceRef = CFRunLoopSourceCreate(NULL, 0, &sourceContext); CFRunLoopAddSource(CFRunLoopGetCurrent(), sourceRef, kCFRunLoopCommonModes); CFRunLoopRun(); #else run_main(&err); #endif return err; }
/* void run_selection(sora::Device *dev) { //selection test sora::selection::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::selection::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::selection::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { break; } } } void run_shadow_map(sora::Device *dev) { //depth map test sora::shadowmap::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::shadowmap::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::shadowmap::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { exit(0); } } } void run_celshading(sora::Device *dev) { //celshading test sora::celshading::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::celshading::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::celshading::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { break; } } } void run_depthmap(sora::Device *dev) { //celshading test sora::depthmap::setup_graphics(dev, kWinWidth, kWinHeight); float prev_time = Timer_GetSecond(); while(true) { sora::depthmap::draw_frame(dev); float curr_time = Timer_GetSecond(); float dt = curr_time - prev_time; sora::depthmap::update_frame(dev, dt); glfwSwapBuffers(); prev_time = curr_time; Timer_Tick(); if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) { break; } } } void run_gles_1_test() { while(true) { SORA_test_draw(kWinWidth, kWinHeight); glfwSwapBuffers(); } } void run_gles_2_test() { SORA_init_gl_env(); //glewInit(); while(true) { SORA_test_draw2(kWinWidth, kWinHeight); glfwSwapBuffers(); } } */ int main(int argc, char *argv[]) { if( !glfwInit() ) { exit( EXIT_FAILURE ); } // Open an OpenGL window if( !glfwOpenWindow( kWinWidth,kWinHeight, 0,0,0,0,0,0, GLFW_WINDOW ) ) { glfwTerminate(); exit( EXIT_FAILURE ); } //gl test //run_gles_1_test(); //run_gles_2_test(); // init glew glewInit(); Timer_Init(); sora::Device::CreateDevice(); sora::Device *device = sora::Device::GetInstance(); run_main(device); //logic end //run_post_effect(device); //run_freeglutfont(device); //run_sysfont(device); //run_selection(device); //run_depthmap(device); //run_shadow_map(device); sora::Device::DestroyDevice(); glfwTerminate(); return 0; }
int main (int argc, char **argv) { #if SEXP_USE_PRINT_BACKTRACE_ON_SEGFAULT signal(SIGSEGV, sexp_segfault_handler); #endif sexp_scheme_init(); run_main(argc, argv); exit_success(); return 0; }
int main (int argc, char **argv) { #if SEXP_USE_PRINT_BACKTRACE_ON_SEGFAULT signal(SIGSEGV, sexp_segfault_handler); #endif sexp_scheme_init(); if (run_main(argc, argv) == SEXP_FALSE) { exit_failure(); } else { exit_success(); } return 0; }
int main (int argc, char **argv) { struct main_pars pars = init_main_pars(argc, argv); COND_VAR_INIT(sync_barrier); MUTEX_INIT(main_lock); TRACE_INIT(); run_main(pars); free_main(pars); TRACE_END(); return 0; }
bool main_open(PFOOBAR2000_API *p_api) {return run_main(p_api, &guid_main_open);}
int Xboxdrv::main(int argc, char** argv) { try { Options opts; CommandLineParser cmd_parser; cmd_parser.parse_args(argc, argv, &opts); set_scheduling(opts); switch(opts.mode) { case Options::PRINT_HELP_DEVICES: run_help_devices(); break; case Options::RUN_LIST_SUPPORTED_DEVICES: run_list_supported_devices(); break; case Options::RUN_LIST_SUPPORTED_DEVICES_XPAD: run_list_supported_devices_xpad(); break; case Options::PRINT_VERSION: cmd_parser.print_version(); break; case Options::PRINT_HELP: cmd_parser.print_help(); break; case Options::PRINT_LED_HELP: cmd_parser.print_led_help(); break; case Options::RUN_DEFAULT: run_main(opts); break; case Options::PRINT_ENUMS: run_list_enums(opts.list_enums); break; case Options::RUN_DAEMON: run_daemon(opts); break; case Options::RUN_LIST_CONTROLLER: run_list_controller(); break; } } catch(const std::exception& err) { std::cout << "\n-- [ ERROR ] ------------------------------------------------------\n" << err.what() << std::endl; } return 0; }
void Runtest(char *mode, int argc, char *argv[]) { FILE *fp,*fp0,*fp1,*fp2,*fp3; int Num_DatFiles,i,j,k,fp_OK; int Num_Atoms; int NGrid1_1,NGrid1_2,NGrid1_3; int NGrid2_1,NGrid2_2,NGrid2_3; double Utot1,Utot2,dU,dF; double Spread1,Spread2; double Omega1,Omega2; double gx,gy,gz,fx,fy,fz; double sum1,sum2; double time1,TotalTime; char fname[YOUSO10]; char fname0[YOUSO10]; char fname1[YOUSO10]; char fname2[YOUSO10]; char fname_dat[YOUSO10]; char fname_dat2[YOUSO10]; char fname_out1[YOUSO10]; char fname_out2[YOUSO10]; char ftmp[YOUSO10]; fname_type *fndat; char operate[800]; int numprocs,myid; char *dir; char *input_dir; char *output_file; DIR *dp; struct dirent *entry; MPI_Request request; MPI_Status status; /* set up MPI */ MPI_Comm_size(MPI_COMM_WORLD1, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD1, &myid); if (strcasecmp(mode,"S")==0){ input_dir = "input_example"; output_file = "runtest.result"; } else if (strcasecmp(mode,"L")==0){ input_dir = "large_example"; output_file = "runtestL.result"; } else if (strcasecmp(mode,"L2")==0){ input_dir = "large2_example"; output_file = "runtestL2.result"; } else if (strcasecmp(mode,"G")==0){ input_dir = "geoopt_example"; output_file = "runtestG.result"; } else if (strcasecmp(mode,"WF")==0){ input_dir = "wf_example"; output_file = "runtestWF.result"; } else if (strcasecmp(mode,"NEGF")==0){ input_dir = "negf_example"; output_file = "runtestNEGF.result"; } /* set Runtest_flag */ Runtest_flag = 1; /* initialize TotalTime */ TotalTime = 0.0; /* print the header */ if (myid==Host_ID){ printf("\n*******************************************************\n"); fflush(stdout); printf("*******************************************************\n"); fflush(stdout); printf(" Welcome to OpenMX Ver. %s \n",Version_OpenMX); fflush(stdout); printf(" Copyright (C), 2002-2013, T.Ozaki \n"); fflush(stdout); printf(" OpenMX comes with ABSOLUTELY NO WARRANTY. \n"); fflush(stdout); printf(" This is free software, and you are welcome to \n"); fflush(stdout); printf(" redistribute it under the constitution of the GNU-GPL.\n"); fflush(stdout); printf("*******************************************************\n"); fflush(stdout); printf("*******************************************************\n\n\n");fflush(stdout); printf("\n"); printf(" OpenMX is now in the mode to check whether OpenMX runs normally\n"); fflush(stdout); printf(" on your machine or not by comparing the stored *.out and\n"); fflush(stdout); printf(" generated *.out \n"); fflush(stdout); printf("\n");fflush(stdout); /* set dir */ dir = input_dir; /* count the number of dat files */ if(( dp = opendir(dir) ) == NULL ){ printf("could not find the directry '%s'\n",input_dir); MPI_Finalize(); exit(0); } Num_DatFiles = 0; while((entry = readdir(dp)) != NULL){ if ( strstr(entry->d_name,".dat")!=NULL ){ Num_DatFiles++; } } closedir(dp); fndat = (fname_type*)malloc(sizeof(fname_type)*Num_DatFiles); /* store the name of dat files */ if(( dp = opendir(dir) ) == NULL ){ printf("could not find the directry '%s'\n",input_dir); MPI_Finalize(); exit(0); } Num_DatFiles = 0; while((entry = readdir(dp)) != NULL){ if ( strstr(entry->d_name,".dat")!=NULL ){ sprintf(fndat[Num_DatFiles].fn,"%s/%s",input_dir,entry->d_name); Num_DatFiles++; } } closedir(dp); /* sorting fndat */ qsort(fndat, Num_DatFiles, sizeof(fname_type), stringcomp); /* for (i=0; i<Num_DatFiles; i++){ printf("i=%2d %s\n",i,fndat[i].fn); } */ } /* if (myid==Host_ID) */ sprintf(fname2,"%s",output_file); if (myid==Host_ID){ fp = fopen(fname2, "r"); if (fp!=NULL){ fclose(fp); sprintf(operate,"%s",fname2); remove(operate); } } if (myid==Host_ID){ printf(" %2d dat files are found in the directory '%s'.\n\n\n",Num_DatFiles,input_dir); } MPI_Bcast(&Num_DatFiles, 1, MPI_INT, Host_ID, MPI_COMM_WORLD1); /*********************************************************** start calculations ***********************************************************/ for (i=0; i<Num_DatFiles; i++){ if (myid==Host_ID){ sprintf(fname_dat,"%s",fndat[i].fn); } MPI_Bcast(&fname_dat, YOUSO10, MPI_CHAR, Host_ID, MPI_COMM_WORLD1); /* run openmx */ argv[1] = fname_dat; run_main(argc, argv, numprocs, myid); /*********************************************************** comparison between two files and save the result ***********************************************************/ if (myid==Host_ID){ input_open(fname_dat); input_string("System.Name",fname_dat2,"default"); input_close(); /* compare two out files */ sprintf(fname_out1,"%s.out",fname_dat2); sprintf(fname_out2,"%s/%s.out",input_dir,fname_dat2); /* generated file */ input_open(fname_out1); input_double("Utot.",&Utot1,(double)0.0); /* for Wannier functions */ if (strcasecmp(mode,"WF")==0){ input_double("Sum.of.Spreads.",&Spread1,(double)0.0); input_double("Total.Omega.=",&Omega1,(double)0.0); } input_int("Num.Grid1.",&NGrid1_1,(int)0); input_int("Num.Grid2.",&NGrid1_2,(int)0); input_int("Num.Grid3.",&NGrid1_3,(int)0); input_double("Elapsed.Time.",&time1,(double)0.0); TotalTime += time1; if (fp3=input_find("<coordinates.forces")) { fscanf(fp3,"%d",&Num_Atoms); sum1 = 0.0; for (j=1; j<=Num_Atoms; j++){ fscanf(fp3,"%d %s %lf %lf %lf %lf %lf %lf", &k,ftmp,&gx,&gy,&gz,&fx,&fy,&fz); sum1 += fx + fy + fz; } if ( ! input_last("coordinates.forces>") ) { printf("Format error for coordinates.forces\n"); } } else { sum1 = 1000.0; } input_close(); /* stored file */ input_open(fname_out2); /* Utot */ input_double("Utot.",&Utot2,(double)0.0); /* for Wannier functions */ if (strcasecmp(mode,"WF")==0){ input_double("Sum.of.Spreads.",&Spread2,(double)0.0); input_double("Total.Omega.=",&Omega2,(double)0.0); } /* grids */ input_int("Num.Grid1.",&NGrid2_1,(int)0); input_int("Num.Grid2.",&NGrid2_2,(int)0); input_int("Num.Grid3.",&NGrid2_3,(int)0); /* coordinates and forces */ if (fp3=input_find("<coordinates.forces")) { fscanf(fp3,"%d",&Num_Atoms); sum2 = 0.0; for (j=1; j<=Num_Atoms; j++){ fscanf(fp3,"%d %s %lf %lf %lf %lf %lf %lf", &k,ftmp,&gx,&gy,&gz,&fx,&fy,&fz); sum2 += fx + fy + fz; } if ( ! input_last("coordinates.forces>") ) { /* format error */ printf("Format error for coordinates.forces\n"); } } else { sum2 = 100.0; } input_close(); dU = fabs(Utot1 - Utot2); dF = fabs(sum1 - sum2); /* write the result to a file, runtest.result */ if ( (fp2 = fopen(fname2,"a")) != NULL ){ if ( (NGrid1_1!=NGrid2_1) || (NGrid1_2!=NGrid2_2) || (NGrid1_3!=NGrid2_3) ) { fprintf(fp2," Invalid comparison due to the different number of grids.\n"); fprintf(fp2," You may use a different radix for FFT.\n"); } if (strcasecmp(mode,"WF")==0){ fprintf(fp2,"%4d %-32.30s Elapsed time(s)=%8.2f diff spread=%15.12f diff Omega=%15.12f\n", i+1,fname_dat,time1,fabs(Spread1-Spread2),fabs(Omega1-Omega2)); } else{ fprintf(fp2,"%4d %-32.30s Elapsed time(s)=%8.2f diff Utot=%15.12f diff Force=%15.12f\n", i+1,fname_dat,time1,dU,dF); } if (i==(Num_DatFiles-1)){ fprintf(fp2,"\n\nTotal elapsed time (s) %11.2f\n",TotalTime); } fclose(fp2); } } } /* tell us the end of calculation */ if (myid==Host_ID){ printf("\n\n\n\n"); printf("The comparison can be found in a file '%s'.\n\n\n",output_file); } if (myid==Host_ID){ free(fndat); } MPI_Barrier(MPI_COMM_WORLD1); MPI_Finalize(); exit(0); }
/* * Carry out a request from the high level driver. */ static void ncr5380_scsi_request(struct scsipi_channel *chan, scsipi_adapter_req_t req, void *arg) { struct scsipi_xfer *xs; struct ncr_softc *sc = device_private(chan->chan_adapter->adapt_dev); int sps, flags; SC_REQ *reqp, *link, *tmp; switch (req) { case ADAPTER_REQ_RUN_XFER: xs = arg; flags = xs->xs_control; /* * We do not queue RESET commands */ if (flags & XS_CTL_RESET) { scsi_reset_verbose(sc, "Got reset-command"); scsipi_done(xs); return; } /* * Get a request block */ sps = splbio(); if ((reqp = free_head) == 0) { xs->error = XS_RESOURCE_SHORTAGE; scsipi_done(xs); return; } free_head = reqp->next; reqp->next = NULL; splx(sps); /* * Initialize our private fields */ reqp->dr_flag = (flags & XS_CTL_POLL) ? DRIVER_NOINT : 0; reqp->phase = NR_PHASE; reqp->msgout = MSG_NOOP; reqp->status = SCSGOOD; reqp->message = 0xff; reqp->link = NULL; reqp->xs = xs; reqp->targ_id = xs->xs_periph->periph_target; reqp->targ_lun = xs->xs_periph->periph_lun; reqp->xdata_ptr = (u_char*)xs->data; reqp->xdata_len = xs->datalen; memcpy(&reqp->xcmd, xs->cmd, xs->cmdlen); reqp->xcmd_len = xs->cmdlen; reqp->xcmd.bytes[0] |= reqp->targ_lun << 5; #ifdef REAL_DMA /* * Check if DMA can be used on this request */ if (scsi_dmaok(reqp)) reqp->dr_flag |= DRIVER_DMAOK; #endif /* REAL_DMA */ /* * Insert the command into the issue queue. Note that * 'REQUEST SENSE' commands are inserted at the head of the * queue since any command will clear the existing contingent * allegience condition and the sense data is only valid while * the condition exists. * When possible, link the command to a previous command to * the same target. This is not very sensible when AUTO_SENSE * is not defined! Interrupts are disabled while we are * fiddling with the issue-queue. */ sps = splbio(); link = NULL; if ((issue_q == NULL) || (reqp->xcmd.opcode == SCSI_REQUEST_SENSE)) { reqp->next = issue_q; issue_q = reqp; } else { tmp = issue_q; do { if (!link && (tmp->targ_id == reqp->targ_id) && !tmp->link) link = tmp; } while (tmp->next && (tmp = tmp->next)); tmp->next = reqp; #ifdef AUTO_SENSE if (link && (ncr_will_link & (1<<reqp->targ_id))) { link->link = reqp; link->xcmd.bytes[link->xs->cmdlen-2] |= 1; } #endif } #ifdef AUTO_SENSE /* * If we haven't already, check the target for link support. * Do this by prefixing the current command with a dummy * Request_Sense command, link the dummy to the current * command, and insert the dummy command at the head of the * issue queue. Set the DRIVER_LINKCHK flag so that we'll * ignore the results of the dummy command, since we only * care about whether it was accepted or not. */ if (!link && !(ncr_test_link & (1<<reqp->targ_id)) && (tmp = free_head) && !(reqp->dr_flag & DRIVER_NOINT)) { free_head = tmp->next; tmp->dr_flag = (reqp->dr_flag & ~DRIVER_DMAOK) | DRIVER_LINKCHK; tmp->phase = NR_PHASE; tmp->msgout = MSG_NOOP; tmp->status = SCSGOOD; tmp->xs = reqp->xs; tmp->targ_id = reqp->targ_id; tmp->targ_lun = reqp->targ_lun; memcpy(&tmp->xcmd, sense_cmd, sizeof(sense_cmd)); tmp->xcmd_len = sizeof(sense_cmd); tmp->xdata_ptr = (u_char *)&tmp->xs->sense.scsi_sense; tmp->xdata_len = sizeof(tmp->xs->sense.scsi_sense); ncr_test_link |= 1<<tmp->targ_id; tmp->link = reqp; tmp->xcmd.bytes[sizeof(sense_cmd)-2] |= 1; tmp->next = issue_q; issue_q = tmp; #ifdef DBG_REQ if (dbg_target_mask & (1 << tmp->targ_id)) show_request(tmp, "LINKCHK"); #endif } #endif splx(sps); #ifdef DBG_REQ if (dbg_target_mask & (1 << reqp->targ_id)) show_request(reqp, (reqp->xcmd.opcode == SCSI_REQUEST_SENSE) ? "HEAD":"TAIL"); #endif run_main(sc); return; case ADAPTER_REQ_GROW_RESOURCES: /* XXX Not supported. */ return; case ADAPTER_REQ_SET_XFER_MODE: /* XXX Not supported. */ return; } }
bool main_activate(PFOOBAR2000_API *p_api) {return run_main(p_api, &guid_main_activate);}
bool main_hide(PFOOBAR2000_API *p_api) {return run_main(p_api, &guid_main_hide);}
bool main_exit(PFOOBAR2000_API *p_api) {return run_main(p_api, &guid_main_exit);}
int main (int argc, char **argv) { sexp_scheme_init(); run_main(argc, argv); return 0; }
bool main_add_files(PFOOBAR2000_API *p_api) {return run_main(p_api, &guid_main_add_files);}
bool main_add_directory(PFOOBAR2000_API *p_api) {return run_main(p_api, &guid_main_add_directory);}
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { return run_main (argc, argv); }