void r4300_init(void) { current_instruction_table = cached_interpreter_table; delay_slot=0; stop = 0; rompause = 0; /* clear instruction counters */ #if defined(COUNT_INSTR) memset(instr_count, 0, 131 * sizeof(instr_count[0])); #endif last_addr = 0xa4000040; next_interupt = 624999; init_interupt(); if (r4300emu == CORE_PURE_INTERPRETER) { DebugMessage(M64MSG_INFO, "Starting R4300 emulator: Pure Interpreter"); r4300emu = CORE_PURE_INTERPRETER; pure_interpreter_init(); } #if defined(DYNAREC) else if (r4300emu >= 2) { DebugMessage(M64MSG_INFO, "Starting R4300 emulator: Dynamic Recompiler"); { r4300emu = CORE_DYNAREC; init_blocks(); #ifdef NEW_DYNAREC new_dynarec_init(); #elif !defined(NO_ASM) && defined(DYNAREC) dyna_start(dynarec_setup_code); #endif } } #endif else /* if (r4300emu == CORE_INTERPRETER) */ { DebugMessage(M64MSG_INFO, "Starting R4300 emulator: Cached Interpreter"); r4300emu = CORE_INTERPRETER; init_blocks(); jump_to(0xa4000040); /* Prevent segfault on failed jump_to */ if (!actual->block) return; last_addr = PC->addr; } }
static void nmi_int_handler(void) { // Non Maskable Interrupt -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS and SR, set BEV, ERL, and SR g_cp0_regs[CP0_STATUS_REG] = (g_cp0_regs[CP0_STATUS_REG] & ~UINT32_C(0x00380000)) | UINT32_C(0x00500004); g_cp0_regs[CP0_CAUSE_REG] = 0x00000000; // simulate the soft reset code which would run from the PIF ROM r4300_reset_soft(); // clear all interrupts, reset interrupt counters back to 0 g_cp0_regs[CP0_COUNT_REG] = 0; g_gs_vi_counter = 0; init_interupt(); // clear the audio status register so that subsequent write_ai() calls will work properly g_ai.regs[AI_STATUS_REG] = 0; // set ErrorEPC with the last instruction address g_cp0_regs[CP0_ERROREPC_REG] = PC->addr; // reset the r4300 internal state if (r4300emu != CORE_PURE_INTERPRETER) { // clear all the compiled instruction blocks and re-initialize free_blocks(); init_blocks(); } // adjust ErrorEPC if we were in a delay slot, and clear the delay_slot and dyna_interp flags if(delay_slot==1 || delay_slot==3) { g_cp0_regs[CP0_ERROREPC_REG]-=4; } delay_slot = 0; dyna_interp = 0; // set next instruction address to reset vector last_addr = UINT32_C(0xa4000040); generic_jump_to(UINT32_C(0xa4000040)); }
static void init_daemon(struct net_child_info *nci) { init_log(); init_blkdb(); bp_utxo_set_init(&uset); init_blocks(); init_orphans(); readprep_blocks_file(); init_nci(nci); }
int main(void) { init_blocks(); print_blocks(); block_quick_sort(start, end+1, SORT_BY_ADDRESS); print_blocks(); return 0; }
void Model::init_items(){ QJsonObject json_obj= read_json_file(":/map/items_1.json"); QJsonArray blocks_array = json_obj.value(QString("items")).toObject()["block"].toArray(); init_blocks(blocks_array); QJsonArray coins_array = json_obj.value(QString("items")).toObject()["coins"].toArray(); init_coins(coins_array); QJsonArray pipes_array = json_obj.value(QString("items")).toObject()["pipes"].toArray(); init_pipes(pipes_array); QJsonArray decor_array = json_obj.value(QString("items")).toObject()["decor"].toArray(); init_decor(decor_array); }
/* Initialize a new RECS structure */ struct RECS *initrecs(char recfm,int recl,unsigned char *hdr,int hdrsz) { struct RECS *recs; recs=malloc(sizeof(struct RECS)); recs->blocks=init_blocks(TAPE_BLOCKSIZE,TAPE_BLKSIZE_MODULO,hdr,hdrsz); recs->reccount=0; recs->recfm=recfm; recs->reclen=recl; recs->filesz=0; return recs; }
/*Ici les fantomes accélèrent de plus en plus * et le but est de tenir le plus longtemps * sans se faire dévorer*/ void survivor(int level, config *cfg) { if(level>=NB_LEVEL) return; int selection, counter=SDL_GetTicks(), tmp=counter, elapsed; SAVE_ENABLE=0; play_menu(level); Pacman pac; Fantome ftm[NB_MAX_GHOSTS]; score_message *msg_list = NULL; Input in; init_pacman(&pac, cfg); init_level(); init_blocks(); load_level(level); pac_restart(&pac); pac.nb_lives=1; init_ghosts(ftm, cfg); memset(&in,0,sizeof(in)); DELAY = 40; while(pac.nb_lives && POINTS) { elapsed = SDL_GetTicks()-tmp; if(elapsed > 10000) { //On accélere les fantomes speed_up(ftm, 1); tmp=SDL_GetTicks(); } UpdateEvents(&in); if(in.quit) //Si clique sur croix { delete(&pac, ftm); exit(EXIT_SUCCESS); } while(in.key[SDLK_ESCAPE]) { selection=game_menu(); if(selection==0) in.key[SDLK_ESCAPE]=0; else if(selection==2) //Retour menu principal { delete(&pac, ftm); return; } } jouer(&pac, ftm, in, cfg, level, &msg_list); } counter = SDL_GetTicks() - counter; fprintf(stderr, "Wouaw tu as tenu %d ms!\n", counter); if(pacmanIsHuman(cfg)) draw_result("data/survivor.txt", counter); delete(&pac, ftm); }
/*Permet de jouer un seul niveau * choisi dans la liste des niveaux * disponibles*/ void one_level(int level, config *cfg) { if(level>=NB_LEVEL) return; int selection; SAVE_ENABLE=0; play_menu(level); Pacman pac; Fantome ftm[NB_MAX_GHOSTS]; score_message *msg_list = NULL; Input in; init_pacman(&pac, cfg); init_level(); init_blocks(); load_level(level); pac_restart(&pac); init_ghosts(ftm, cfg); memset(&in,0,sizeof(in)); DELAY = 40-level; while(POINTS) //Tant que l'on a pas mangé toutes les pac-gommes { UpdateEvents(&in); if(in.quit) //Si clique sur croix { delete(&pac, ftm); exit(EXIT_SUCCESS); } while(in.key[SDLK_ESCAPE]) { selection=game_menu(); if(selection==0) in.key[SDLK_ESCAPE]=0; else if(selection==2) //Retour menu principal { delete(&pac, ftm); return; } } if (in.key[SDLK_w]) POINTS=0; //cheat code for winning!! else if (in.key[SDLK_l] || !(pac.nb_lives)) //cheat code for loosing!! { lost_menu(); delete(&pac, ftm); if(pacmanIsHuman(cfg)) draw_result("data/results.txt", pac.score); return; } jouer(&pac, ftm, in, cfg, level, &msg_list); } win_menu(); if(pacmanIsHuman(cfg)) draw_result("data/results.txt", pac.score); delete(&pac, ftm); }
static void nmi_int_handler(void) { /* Non Maskable Interrupt -- remove interrupt event from queue */ remove_interrupt_event(); /* setup r4300 Status flags: reset TS and SR, set BEV, ERL, and SR */ g_cp0_regs[CP0_STATUS_REG] = (g_cp0_regs[CP0_STATUS_REG] & ~(CP0_STATUS_SR | CP0_STATUS_TS | UINT32_C(0x00080000))) | (CP0_STATUS_ERL | CP0_STATUS_BEV | CP0_STATUS_SR); g_cp0_regs[CP0_CAUSE_REG] = 0x00000000; /* simulate the soft reset code which would run from the PIF ROM */ pifbootrom_hle_execute(&g_dev); /* clear all interrupts, reset interrupt counters back to 0 */ g_cp0_regs[CP0_COUNT_REG] = 0; g_gs_vi_counter = 0; init_interrupt(); g_dev.vi.delay = g_dev.vi.next_vi = 5000; add_interrupt_event_count(VI_INT, g_dev.vi.next_vi); /* clear the audio status register so that subsequent write_ai() calls will work properly */ g_dev.ai.regs[AI_STATUS_REG] = 0; /* set ErrorEPC with the last instruction address */ g_cp0_regs[CP0_ERROREPC_REG] = PC->addr; /* reset the r4300 internal state */ if (r4300emu != CORE_PURE_INTERPRETER) { /* clear all the compiled instruction blocks and re-initialize */ free_blocks(); init_blocks(); } /* adjust ErrorEPC if we were in a delay slot, and clear the delay_slot and dyna_interp flags */ if(g_dev.r4300.delay_slot==1 || g_dev.r4300.delay_slot==3) { g_cp0_regs[CP0_ERROREPC_REG]-=4; } g_dev.r4300.delay_slot = 0; dyna_interp = 0; /* set next instruction address to reset vector */ last_addr = UINT32_C(0xa4000040); generic_jump_to(UINT32_C(0xa4000040)); #ifdef NEW_DYNAREC if (r4300emu == CORE_DYNAREC) { g_cp0_regs[CP0_ERROREPC_REG]=(pcaddr&~3)-(pcaddr&1)*4; pcaddr = 0xa4000040; pending_exception = 1; invalidate_all_pages(); } #endif }
void reset_hard(void) { poweron_device(&g_dev); pifbootrom_hle_execute(&g_dev); last_addr = UINT32_C(0xa4000040); next_interrupt = 624999; init_interrupt(); g_dev.vi.delay = g_dev.vi.next_vi = 5000; add_interrupt_event_count(VI_INT, g_dev.vi.next_vi); if(r4300emu != CORE_PURE_INTERPRETER) { free_blocks(); init_blocks(); } generic_jump_to(last_addr); }
int main(){ char command[20],first[5],second[5]; char *temp,*buf; int max,from,to; void (*func)(int, int, int); scanf("%d", &max); getchar(); init_blocks(max); while(1){ fgets(command,20,stdin); buf = command; if (strcmp(buf,"quit\n") == 0){ break; } sscanf(buf,"%s %d %s %d", first, &from, second, &to); if(!checkvalid(from,to,max)){ continue; } action(first, second, from, to, max); } output_blocks(max); return 0; }
void gen_interupt() { if(!__emulation_run) stop = 1; if (stop == 1) { vi_counter = 0; // debug dyna_stop(); } if (savestates_job & LOADSTATE) { savestates_load(); savestates_job &= ~LOADSTATE; return; } if (skip_jump) { if (q->count > Count || (Count - q->count) < 0x80000000) next_interupt = q->count; else next_interupt = 0; if (interpcore) { interp_addr = skip_jump; last_addr = interp_addr; } else { unsigned int dest = skip_jump; skip_jump=0; jump_to(dest); last_addr = PC->addr; } skip_jump=0; return; } switch(q->type) { case SPECIAL_INT: if (Count > 0x10000000) return; remove_interupt_event(); add_interupt_event_count(SPECIAL_INT, 0); return; break; case VI_INT: if(vi_counter < 60) { if (vi_counter == 0) cheat_apply_cheats(ENTRY_BOOT); vi_counter++; } else { cheat_apply_cheats(ENTRY_VI); } updateScreen(); #ifdef WITH_LIRC lircCheckInput(); #endif SDL_PumpEvents(); refresh_stat(); // if paused, poll for input events if(rompause) { osd_render(); // draw Paused message in case updateScreen didn't do it SDL_GL_SwapBuffers(); while(rompause) { #ifdef __WIN32__ Sleep(10); #else struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 10000000; nanosleep(&ts, NULL); // sleep for 10 milliseconds #endif SDL_PumpEvents(); #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC } } new_vi(); if (vi_register.vi_v_sync == 0) vi_register.vi_delay = 500000; else vi_register.vi_delay = ((vi_register.vi_v_sync + 1)*1500); next_vi += vi_register.vi_delay; if (vi_register.vi_status&0x40) vi_field=1-vi_field; else vi_field=0; remove_interupt_event(); add_interupt_event_count(VI_INT, next_vi); MI_register.mi_intr_reg |= 0x08; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case COMPARE_INT: remove_interupt_event(); Count+=2; add_interupt_event_count(COMPARE_INT, Compare); Count-=2; Cause = (Cause | 0x8000) & 0xFFFFFF83; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case CHECK_INT: remove_interupt_event(); break; case SI_INT: #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC SDL_PumpEvents(); PIF_RAMb[0x3F] = 0x0; remove_interupt_event(); MI_register.mi_intr_reg |= 0x02; si_register.si_stat |= 0x1000; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case PI_INT: remove_interupt_event(); MI_register.mi_intr_reg |= 0x10; pi_register.read_pi_status_reg &= ~3; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case AI_INT: if (ai_register.ai_status & 0x80000000) // full { unsigned int ai_event = get_event(AI_INT); remove_interupt_event(); ai_register.ai_status &= ~0x80000000; ai_register.current_delay = ai_register.next_delay; ai_register.current_len = ai_register.next_len; add_interupt_event_count(AI_INT, ai_event+ai_register.next_delay); MI_register.mi_intr_reg |= 0x04; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; } else { remove_interupt_event(); ai_register.ai_status &= ~0x40000000; //------- MI_register.mi_intr_reg |= 0x04; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; } break; case SP_INT: remove_interupt_event(); sp_register.sp_status_reg |= 0x303; //sp_register.signal1 = 1; sp_register.signal2 = 1; sp_register.broke = 1; sp_register.halt = 1; if (!sp_register.intr_break) return; MI_register.mi_intr_reg |= 0x01; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case DP_INT: remove_interupt_event(); dpc_register.dpc_status &= ~2; dpc_register.dpc_status |= 0x81; MI_register.mi_intr_reg |= 0x20; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case HW2_INT: // Hardware Interrupt 2 -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS, and SR, set IM2 Status = (Status & ~0x00380000) | 0x1000; Cause = (Cause | 0x1000) & 0xFFFFFF83; /* the exception_general() call below will jump to the interrupt vector (0x80000180) and setup the * interpreter or dynarec */ break; case NMI_INT: // Non Maskable Interrupt -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS and SR, set BEV, ERL, and SR Status = (Status & ~0x00380000) | 0x00500004; Cause = 0x00000000; // simulate the soft reset code which would run from the PIF ROM r4300_reset_soft(); // clear all interrupts, reset interrupt counters back to 0 Count = 0; vi_counter = 0; init_interupt(); // clear the audio status register so that subsequent write_ai() calls will work properly ai_register.ai_status = 0; // reset the r4300 internal state if (interpcore) /* pure interpreter only */ { // set ErrorEPC with last instruction address and set next instruction address to reset vector ErrorEPC = interp_addr; interp_addr = 0xa4000040; last_addr = interp_addr; } else /* decode-cached interpreter or dynamic recompiler */ { int i; // clear all the compiled instruction blocks for (i=0; i<0x100000; i++) { if (blocks[i]) { if (blocks[i]->block) { free(blocks[i]->block); blocks[i]->block = NULL; } if (blocks[i]->code) { free(blocks[i]->code); blocks[i]->code = NULL; } if (blocks[i]->jumps_table) { free(blocks[i]->jumps_table); blocks[i]->jumps_table = NULL; } if (blocks[i]->riprel_table) { free(blocks[i]->riprel_table); blocks[i]->riprel_table = NULL; } free(blocks[i]); blocks[i] = NULL; } } // re-initialize init_blocks(); // jump to the start ErrorEPC = PC->addr; jump_to(0xa4000040); last_addr = PC->addr; } // adjust ErrorEPC if we were in a delay slot, and clear the delay_slot and dyna_interp flags if(delay_slot==1 || delay_slot==3) { ErrorEPC-=4; } delay_slot = 0; dyna_interp = 0; return; default: remove_interupt_event(); break; } #ifdef NEW_DYNAREC EPC = pcaddr; pcaddr = 0x80000180; Status |= 2; Cause &= 0x7FFFFFFF; pending_exception=1; #else exception_general(); #endif if (savestates_job & SAVESTATE) { savestates_save(); savestates_job &= ~SAVESTATE; } }
int main(int argc, char *argv[]) { FILE *parameterfile = NULL; int c, j, i, ix = 0, isample = 0, op_id = 0; char * filename = NULL; char datafilename[50]; char parameterfilename[50]; char conf_filename[50]; char * input_filename = NULL; double plaquette_energy; struct stout_parameters params_smear; spinor **s, *s_; #ifdef _KOJAK_INST #pragma pomp inst init #pragma pomp inst begin(main) #endif #if (defined SSE || defined SSE2 || SSE3) signal(SIGILL, &catch_ill_inst); #endif DUM_DERI = 8; DUM_MATRIX = DUM_DERI + 5; #if ((defined BGL && defined XLC) || defined _USE_TSPLITPAR) NO_OF_SPINORFIELDS = DUM_MATRIX + 3; #else NO_OF_SPINORFIELDS = DUM_MATRIX + 3; #endif verbose = 0; g_use_clover_flag = 0; #ifdef MPI # ifdef OMP int mpi_thread_provided; MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED, &mpi_thread_provided); # else MPI_Init(&argc, &argv); # endif MPI_Comm_rank(MPI_COMM_WORLD, &g_proc_id); #else g_proc_id = 0; #endif while ((c = getopt(argc, argv, "h?vVf:o:")) != -1) { switch (c) { case 'f': input_filename = calloc(200, sizeof(char)); strcpy(input_filename, optarg); break; case 'o': filename = calloc(200, sizeof(char)); strcpy(filename, optarg); break; case 'v': verbose = 1; break; case 'V': fprintf(stdout,"%s %s\n",PACKAGE_STRING,git_hash); exit(0); break; case 'h': case '?': default: usage(); break; } } if (input_filename == NULL) { input_filename = "invert.input"; } if (filename == NULL) { filename = "output"; } /* Read the input file */ if( (j = read_input(input_filename)) != 0) { fprintf(stderr, "Could not find input file: %s\nAborting...\n", input_filename); exit(-1); } #ifdef OMP if(omp_num_threads > 0) { omp_set_num_threads(omp_num_threads); } else { if( g_proc_id == 0 ) printf("# No value provided for OmpNumThreads, running in single-threaded mode!\n"); omp_num_threads = 1; omp_set_num_threads(omp_num_threads); } init_omp_accumulators(omp_num_threads); #endif /* this DBW2 stuff is not needed for the inversion ! */ if (g_dflgcr_flag == 1) { even_odd_flag = 0; } g_rgi_C1 = 0; if (Nsave == 0) { Nsave = 1; } if (g_running_phmc) { NO_OF_SPINORFIELDS = DUM_MATRIX + 8; } tmlqcd_mpi_init(argc, argv); g_dbw2rand = 0; /* starts the single and double precision random number */ /* generator */ start_ranlux(rlxd_level, random_seed); /* we need to make sure that we don't have even_odd_flag = 1 */ /* if any of the operators doesn't use it */ /* in this way even/odd can still be used by other operators */ for(j = 0; j < no_operators; j++) if(!operator_list[j].even_odd_flag) even_odd_flag = 0; #ifndef MPI g_dbw2rand = 0; #endif #ifdef _GAUGE_COPY j = init_gauge_field(VOLUMEPLUSRAND, 1); #else j = init_gauge_field(VOLUMEPLUSRAND, 0); #endif if (j != 0) { fprintf(stderr, "Not enough memory for gauge_fields! Aborting...\n"); exit(-1); } j = init_geometry_indices(VOLUMEPLUSRAND); if (j != 0) { fprintf(stderr, "Not enough memory for geometry indices! Aborting...\n"); exit(-1); } if (no_monomials > 0) { if (even_odd_flag) { j = init_monomials(VOLUMEPLUSRAND / 2, even_odd_flag); } else { j = init_monomials(VOLUMEPLUSRAND, even_odd_flag); } if (j != 0) { fprintf(stderr, "Not enough memory for monomial pseudo fermion fields! Aborting...\n"); exit(-1); } } if (even_odd_flag) { j = init_spinor_field(VOLUMEPLUSRAND / 2, NO_OF_SPINORFIELDS); } else { j = init_spinor_field(VOLUMEPLUSRAND, NO_OF_SPINORFIELDS); } if (j != 0) { fprintf(stderr, "Not enough memory for spinor fields! Aborting...\n"); exit(-1); } if (g_running_phmc) { j = init_chi_spinor_field(VOLUMEPLUSRAND / 2, 20); if (j != 0) { fprintf(stderr, "Not enough memory for PHMC Chi fields! Aborting...\n"); exit(-1); } } g_mu = g_mu1; if (g_cart_id == 0) { /*construct the filenames for the observables and the parameters*/ strcpy(datafilename, filename); strcat(datafilename, ".data"); strcpy(parameterfilename, filename); strcat(parameterfilename, ".para"); parameterfile = fopen(parameterfilename, "w"); write_first_messages(parameterfile, 1); fclose(parameterfile); } /* define the geometry */ geometry(); /* define the boundary conditions for the fermion fields */ boundary(g_kappa); phmc_invmaxev = 1.; init_operators(); /* this could be maybe moved to init_operators */ #ifdef _USE_HALFSPINOR j = init_dirac_halfspinor(); if (j != 0) { fprintf(stderr, "Not enough memory for halffield! Aborting...\n"); exit(-1); } if (g_sloppy_precision_flag == 1) { j = init_dirac_halfspinor32(); if (j != 0) { fprintf(stderr, "Not enough memory for 32-bit halffield! Aborting...\n"); exit(-1); } } # if (defined _PERSISTENT) if (even_odd_flag) init_xchange_halffield(); # endif #endif for (j = 0; j < Nmeas; j++) { sprintf(conf_filename, "%s.%.4d", gauge_input_filename, nstore); if (g_cart_id == 0) { printf("#\n# Trying to read gauge field from file %s in %s precision.\n", conf_filename, (gauge_precision_read_flag == 32 ? "single" : "double")); fflush(stdout); } if( (i = read_gauge_field(conf_filename)) !=0) { fprintf(stderr, "Error %d while reading gauge field from %s\n Aborting...\n", i, conf_filename); exit(-2); } if (g_cart_id == 0) { printf("# Finished reading gauge field.\n"); fflush(stdout); } #ifdef MPI xchange_gauge(g_gauge_field); #endif /*compute the energy of the gauge field*/ plaquette_energy = measure_gauge_action( (const su3**) g_gauge_field); if (g_cart_id == 0) { printf("# The computed plaquette value is %e.\n", plaquette_energy / (6.*VOLUME*g_nproc)); fflush(stdout); } if (use_stout_flag == 1){ params_smear.rho = stout_rho; params_smear.iterations = stout_no_iter; /* if (stout_smear((su3_tuple*)(g_gauge_field[0]), ¶ms_smear, (su3_tuple*)(g_gauge_field[0])) != 0) */ /* exit(1) ; */ g_update_gauge_copy = 1; g_update_gauge_energy = 1; g_update_rectangle_energy = 1; plaquette_energy = measure_gauge_action( (const su3**) g_gauge_field); if (g_cart_id == 0) { printf("# The plaquette value after stouting is %e\n", plaquette_energy / (6.*VOLUME*g_nproc)); fflush(stdout); } } if (reweighting_flag == 1) { reweighting_factor(reweighting_samples, nstore); } /* Compute minimal eigenvalues, if wanted */ if (compute_evs != 0) { eigenvalues(&no_eigenvalues, 5000, eigenvalue_precision, 0, compute_evs, nstore, even_odd_flag); } if (phmc_compute_evs != 0) { #ifdef MPI MPI_Finalize(); #endif return(0); } /* Compute the mode number or topological susceptibility using spectral projectors, if wanted*/ if(compute_modenumber != 0 || compute_topsus !=0){ s_ = calloc(no_sources_z2*VOLUMEPLUSRAND+1, sizeof(spinor)); s = calloc(no_sources_z2, sizeof(spinor*)); if(s_ == NULL) { printf("Not enough memory in %s: %d",__FILE__,__LINE__); exit(42); } if(s == NULL) { printf("Not enough memory in %s: %d",__FILE__,__LINE__); exit(42); } for(i = 0; i < no_sources_z2; i++) { #if (defined SSE3 || defined SSE2 || defined SSE) s[i] = (spinor*)(((unsigned long int)(s_)+ALIGN_BASE)&~ALIGN_BASE)+i*VOLUMEPLUSRAND; #else s[i] = s_+i*VOLUMEPLUSRAND; #endif z2_random_spinor_field(s[i], VOLUME); /* what is this here needed for?? */ /* spinor *aux_,*aux; */ /* #if ( defined SSE || defined SSE2 || defined SSE3 ) */ /* aux_=calloc(VOLUMEPLUSRAND+1, sizeof(spinor)); */ /* aux = (spinor *)(((unsigned long int)(aux_)+ALIGN_BASE)&~ALIGN_BASE); */ /* #else */ /* aux_=calloc(VOLUMEPLUSRAND, sizeof(spinor)); */ /* aux = aux_; */ /* #endif */ if(g_proc_id == 0) { printf("source %d \n", i); } if(compute_modenumber != 0){ mode_number(s[i], mstarsq); } if(compute_topsus !=0) { top_sus(s[i], mstarsq); } } free(s); free(s_); } /* move to operators as well */ if (g_dflgcr_flag == 1) { /* set up deflation blocks */ init_blocks(nblocks_t, nblocks_x, nblocks_y, nblocks_z); /* the can stay here for now, but later we probably need */ /* something like init_dfl_solver called somewhere else */ /* create set of approximate lowest eigenvectors ("global deflation subspace") */ /* g_mu = 0.; */ /* boundary(0.125); */ generate_dfl_subspace(g_N_s, VOLUME); /* boundary(g_kappa); */ /* g_mu = g_mu1; */ /* Compute little Dirac operators */ /* alt_block_compute_little_D(); */ if (g_debug_level > 0) { check_projectors(); check_local_D(); } if (g_debug_level > 1) { check_little_D_inversion(); } } if(SourceInfo.type == 1) { index_start = 0; index_end = 1; } g_precWS=NULL; if(use_preconditioning == 1){ /* todo load fftw wisdom */ #if (defined HAVE_FFTW ) && !( defined MPI) loadFFTWWisdom(g_spinor_field[0],g_spinor_field[1],T,LX); #else use_preconditioning=0; #endif } if (g_cart_id == 0) { fprintf(stdout, "#\n"); /*Indicate starting of the operator part*/ } for(op_id = 0; op_id < no_operators; op_id++) { boundary(operator_list[op_id].kappa); g_kappa = operator_list[op_id].kappa; g_mu = 0.; if(use_preconditioning==1 && PRECWSOPERATORSELECT[operator_list[op_id].solver]!=PRECWS_NO ){ printf("# Using preconditioning with treelevel preconditioning operator: %s \n", precWSOpToString(PRECWSOPERATORSELECT[operator_list[op_id].solver])); /* initial preconditioning workspace */ operator_list[op_id].precWS=(spinorPrecWS*)malloc(sizeof(spinorPrecWS)); spinorPrecWS_Init(operator_list[op_id].precWS, operator_list[op_id].kappa, operator_list[op_id].mu/2./operator_list[op_id].kappa, -(0.5/operator_list[op_id].kappa-4.), PRECWSOPERATORSELECT[operator_list[op_id].solver]); g_precWS = operator_list[op_id].precWS; if(PRECWSOPERATORSELECT[operator_list[op_id].solver] == PRECWS_D_DAGGER_D) { fitPrecParams(op_id); } } for(isample = 0; isample < no_samples; isample++) { for (ix = index_start; ix < index_end; ix++) { if (g_cart_id == 0) { fprintf(stdout, "#\n"); /*Indicate starting of new index*/ } /* we use g_spinor_field[0-7] for sources and props for the moment */ /* 0-3 in case of 1 flavour */ /* 0-7 in case of 2 flavours */ prepare_source(nstore, isample, ix, op_id, read_source_flag, source_location); operator_list[op_id].inverter(op_id, index_start); } } if(use_preconditioning==1 && operator_list[op_id].precWS!=NULL ){ /* free preconditioning workspace */ spinorPrecWS_Free(operator_list[op_id].precWS); free(operator_list[op_id].precWS); } if(operator_list[op_id].type == OVERLAP){ free_Dov_WS(); } } nstore += Nsave; } #ifdef MPI MPI_Finalize(); #endif #ifdef OMP free_omp_accumulators(); #endif free_blocks(); free_dfl_subspace(); free_gauge_field(); free_geometry_indices(); free_spinor_field(); free_moment_field(); free_chi_spinor_field(); return(0); #ifdef _KOJAK_INST #pragma pomp inst end(main) #endif }
void gen_interupt(void) { if (stop == 1) { vi_counter = 0; // debug dyna_stop(); } if (!interupt_unsafe_state) { if (savestates_get_job() == savestates_job_load) { savestates_load(); return; } if (reset_hard_job) { reset_hard(); reset_hard_job = 0; return; } } if (skip_jump) { unsigned int dest = skip_jump; skip_jump = 0; if (q->count > Count || (Count - q->count) < 0x80000000) next_interupt = q->count; else next_interupt = 0; last_addr = dest; generic_jump_to(dest); return; } switch(q->type) { case SPECIAL_INT: if (Count > 0x10000000) return; remove_interupt_event(); add_interupt_event_count(SPECIAL_INT, 0); return; break; case VI_INT: if(vi_counter < 60) { if (vi_counter == 0) cheat_apply_cheats(ENTRY_BOOT); vi_counter++; } else { cheat_apply_cheats(ENTRY_VI); } gfx.updateScreen(); #ifdef WITH_LIRC lircCheckInput(); #endif SDL_PumpEvents(); refresh_stat(); // if paused, poll for input events if(rompause) { osd_render(); // draw Paused message in case gfx.updateScreen didn't do it VidExt_GL_SwapBuffers(); while(rompause) { SDL_Delay(10); SDL_PumpEvents(); #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC } } new_vi(); if (vi_register.vi_v_sync == 0) vi_register.vi_delay = 500000; else vi_register.vi_delay = ((vi_register.vi_v_sync + 1)*1500); next_vi += vi_register.vi_delay; if (vi_register.vi_status&0x40) vi_field=1-vi_field; else vi_field=0; remove_interupt_event(); add_interupt_event_count(VI_INT, next_vi); MI_register.mi_intr_reg |= 0x08; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case COMPARE_INT: remove_interupt_event(); Count+=count_per_op; add_interupt_event_count(COMPARE_INT, Compare); Count-=count_per_op; Cause = (Cause | 0x8000) & 0xFFFFFF83; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case CHECK_INT: remove_interupt_event(); break; case SI_INT: #ifdef WITH_LIRC lircCheckInput(); #endif //WITH_LIRC SDL_PumpEvents(); PIF_RAMb[0x3F] = 0x0; remove_interupt_event(); MI_register.mi_intr_reg |= 0x02; si_register.si_stat |= 0x1000; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case PI_INT: remove_interupt_event(); MI_register.mi_intr_reg |= 0x10; pi_register.read_pi_status_reg &= ~3; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case AI_INT: if (ai_register.ai_status & 0x80000000) // full { unsigned int ai_event = get_event(AI_INT); remove_interupt_event(); ai_register.ai_status &= ~0x80000000; ai_register.current_delay = ai_register.next_delay; ai_register.current_len = ai_register.next_len; add_interupt_event_count(AI_INT, ai_event+ai_register.next_delay); MI_register.mi_intr_reg |= 0x04; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; } else { remove_interupt_event(); ai_register.ai_status &= ~0x40000000; //------- MI_register.mi_intr_reg |= 0x04; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; } break; case SP_INT: remove_interupt_event(); sp_register.sp_status_reg |= 0x203; // sp_register.sp_status_reg |= 0x303; if (!(sp_register.sp_status_reg & 0x40)) return; // !intr_on_break MI_register.mi_intr_reg |= 0x01; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case DP_INT: remove_interupt_event(); dpc_register.dpc_status &= ~2; dpc_register.dpc_status |= 0x81; MI_register.mi_intr_reg |= 0x20; if (MI_register.mi_intr_reg & MI_register.mi_intr_mask_reg) Cause = (Cause | 0x400) & 0xFFFFFF83; else return; if ((Status & 7) != 1) return; if (!(Status & Cause & 0xFF00)) return; break; case HW2_INT: // Hardware Interrupt 2 -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS, and SR, set IM2 Status = (Status & ~0x00380000) | 0x1000; Cause = (Cause | 0x1000) & 0xFFFFFF83; /* the exception_general() call below will jump to the interrupt vector (0x80000180) and setup the * interpreter or dynarec */ break; case NMI_INT: // Non Maskable Interrupt -- remove interrupt event from queue remove_interupt_event(); // setup r4300 Status flags: reset TS and SR, set BEV, ERL, and SR Status = (Status & ~0x00380000) | 0x00500004; Cause = 0x00000000; // simulate the soft reset code which would run from the PIF ROM r4300_reset_soft(); // clear all interrupts, reset interrupt counters back to 0 Count = 0; vi_counter = 0; init_interupt(); // clear the audio status register so that subsequent write_ai() calls will work properly ai_register.ai_status = 0; // set ErrorEPC with the last instruction address ErrorEPC = PC->addr; // reset the r4300 internal state if (r4300emu != CORE_PURE_INTERPRETER) { // clear all the compiled instruction blocks and re-initialize free_blocks(); init_blocks(); } // adjust ErrorEPC if we were in a delay slot, and clear the delay_slot and dyna_interp flags if(delay_slot==1 || delay_slot==3) { ErrorEPC-=4; } delay_slot = 0; dyna_interp = 0; // set next instruction address to reset vector last_addr = 0xa4000040; generic_jump_to(0xa4000040); return; default: DebugMessage(M64MSG_ERROR, "Unknown interrupt queue event type %.8X.", q->type); remove_interupt_event(); break; } #ifdef NEW_DYNAREC if (r4300emu == CORE_DYNAREC) { EPC = pcaddr; pcaddr = 0x80000180; Status |= 2; Cause &= 0x7FFFFFFF; pending_exception=1; } else { exception_general(); } #else exception_general(); #endif if (!interupt_unsafe_state) { if (savestates_get_job() == savestates_job_save) { savestates_save(); return; } } }
void init_grids(int32_t rank) { #if defined(NUMA_AWARE) int32_t cbi, cbj, cbk, cbn; #if !defined(COLLABORATIVE_THREADING) int32_t coreBlock[3], coreBlockMin[3], coreBlockMax[3]; cbn = 0; for (cbi=0; cbi < numCoreBlocks_x; cbi++) { for (cbj=0; cbj < numCoreBlocks_y; cbj++) { for (cbk=0; cbk < numCoreBlocks_z; cbk++) { if (((cbn/numCoreBlocksPerChunk) % numThreads) == rank) { coreBlock[0] = cbi; coreBlock[1] = cbj; coreBlock[2] = cbk; coreBlockMin[0] = realMin_x + coreBlock[0] * numCoreBlockCells_x; coreBlockMax[0] = coreBlockMin[0] + numCoreBlockCells_x; coreBlockMin[1] = realMin_y + coreBlock[1] * numCoreBlockCells_y; coreBlockMax[1] = coreBlockMin[1] + numCoreBlockCells_y; coreBlockMin[2] = realMin_z + coreBlock[2] * numCoreBlockCells_z; coreBlockMax[2] = coreBlockMin[2] + numCoreBlockCells_z; init_blocks(coreBlock, coreBlockMin, coreBlockMax); #if defined(DEBUG) printf("Thread %d: coreBlock = [%d, %d, %d]\n", rank, coreBlock[0], coreBlock[1], coreBlock[2]); printf("Thread %d: coreBlockMin = [%d, %d, %d]\n", rank, coreBlockMin[0], coreBlockMin[1], coreBlockMin[2]); printf("Thread %d: coreBlockMax = [%d, %d, %d]\n", rank, coreBlockMax[0], coreBlockMax[1], coreBlockMax[2]); #endif } cbn++; } } } #else int32_t threadBlock[3], threadBlockMin[3], threadBlockMax[3]; int32_t tbj, tbk, tbn; cbn = 0; for (cbi=0; cbi < numCoreBlocks_x; cbi++) { threadBlock[0] = cbi; threadBlockMin[0] = realMin_x + threadBlock[0] * numCoreBlockCells_x; threadBlockMax[0] = threadBlockMin[0] + numCoreBlockCells_x; for (cbj=0; cbj < numCoreBlocks_y; cbj++) { for (cbk=0; cbk < numCoreBlocks_z; cbk++) { if (((cbn/numCoreBlocksPerChunk) % (numThreads/numThreadBlocksPerCoreBlock)) == (rank/numThreadBlocksPerCoreBlock)) { tbn = 0; for (tbj=0; tbj < numThreadBlocksPerCoreBlock_y; tbj++) { for (tbk=0; tbk < numThreadBlocksPerCoreBlock_z; tbk++) { if ((rank % numThreadBlocksPerCoreBlock) == tbn) { threadBlock[1] = cbj * numThreadBlocksPerCoreBlock_y + tbj; threadBlock[2] = cbk * numThreadBlocksPerCoreBlock_z + tbk; threadBlockMin[1] = realMin_y + threadBlock[1] * numThreadBlockCells_y; threadBlockMax[1] = threadBlockMin[1] + numThreadBlockCells_y; threadBlockMin[2] = realMin_z + threadBlock[2] * numThreadBlockCells_z; threadBlockMax[2] = threadBlockMin[2] + numThreadBlockCells_z; init_blocks(threadBlock, threadBlockMin, threadBlockMax); #if defined(DEBUG) printf("Thread %d: threadBlock = [%d, %d, %d]\n", rank, threadBlock[0], threadBlock[1], threadBlock[2]); printf("Thread %d: threadBlockMin = [%d, %d, %d]\n", rank, threadBlockMin[0], threadBlockMin[1], threadBlockMin[2]); printf("Thread %d: threadBlockMax = [%d, %d, %d]\n", rank, threadBlockMax[0], threadBlockMax[1], threadBlockMax[2]); #endif } tbn++; } } } cbn++; } } } #endif #else int32_t i, j, k; if (rank == 0) { for (i=0; i < nx; i++) { for (j=0; j < ny; j++) { for (k=0; k < nz; k++) { A[Index3D(i,j,k)] = INIT_GHOST_VALUE; B[Index3D(i,j,k)] = INIT_GHOST_VALUE; } } } for (i=realMin_x; i < realMax_x; i++) { for (j=realMin_y; j < realMax_y; j++) { for (k=realMin_y; k < realMax_z; k++) { A[Index3D(i,j,k)] = INIT_REAL_VALUE; } } } } #endif }
int main() { const char* testm = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasdsdsdsdasfsadfasdfsdafasdfasdfasdfasdfsadfsadf"; BIGNUM* e; BIGNUM* n; if (load_rsa_keys(1, &e, &n) != 0) { return 1; } size_t b_size = BN_num_bytes(n); size_t m_size = strlen(testm) + 1; struct message_blocks* b = create_message_bloks(m_size, b_size); init_blocks(testm, m_size, b); size_t o_size = b->size * b->b_size; void* out_message = malloc(o_size); int ind = 0; for (; ind < b->size; ++ind) { void* out; size_t outsize; RSA_EncDec_block(b->bloks[ind], b->b_size, e, n, &out, &outsize); printf("\nOUT SIZE = %d m = %s\n", outsize, b->bloks[ind]); assert(b_size == outsize); memcpy(((char*)out_message) + ind * outsize, out, outsize); } if (load_rsa_keys(0, &e, &n) != 0) { return 1; } ind = 0; for (; ind < b->size; ++ind) { void* out; size_t outsize; printf("\nOUT SIZE = %d m = %s\n", outsize, b->bloks[ind]); RSA_EncDec_block(b->bloks[ind], b->b_size, e, n, &out, &outsize); printf("\nOUT SIZE = %d m = %s\n", outsize, b->bloks[ind]); assert(b_size == outsize); memcpy(((char*)out_message) + ind * b_size, out, b_size); } printf("------------------------%s\n", out_message); /* FILE* pfp = fopen("./keys/private.pem","r"); if (pfp == NULL) printf("sdsds"); RSA *prsa = PEM_read_RSAPrivateKey(pfp, NULL, password_cb, "12345"); if (prsa == NULL) { printf("error load pivate key\n"); fclose(pfp); return 1; } RSA_EncDec_block(out, outsize, prsa->d, prsa->n, &out, &outsize); size_t i = 0; for (; i < outsize; ++i) { printf("%c", ((char*)out)[i]); } printf("%c", '\n'); */ return 0; }
int main(int argc, char *argv[]) { FILE *parameterfile = NULL; int j, i, ix = 0, isample = 0, op_id = 0; char datafilename[206]; char parameterfilename[206]; char conf_filename[50]; char * input_filename = NULL; char * filename = NULL; double plaquette_energy; struct stout_parameters params_smear; #ifdef _KOJAK_INST #pragma pomp inst init #pragma pomp inst begin(main) #endif #if (defined SSE || defined SSE2 || SSE3) signal(SIGILL, &catch_ill_inst); #endif DUM_DERI = 8; DUM_MATRIX = DUM_DERI + 5; NO_OF_SPINORFIELDS = DUM_MATRIX + 4; //4 extra fields (corresponding to DUM_MATRIX+0..5) for deg. and ND matrix mult. NO_OF_SPINORFIELDS_32 = 6; verbose = 0; g_use_clover_flag = 0; process_args(argc,argv,&input_filename,&filename); set_default_filenames(&input_filename, &filename); init_parallel_and_read_input(argc, argv, input_filename); /* this DBW2 stuff is not needed for the inversion ! */ if (g_dflgcr_flag == 1) { even_odd_flag = 0; } g_rgi_C1 = 0; if (Nsave == 0) { Nsave = 1; } if (g_running_phmc) { NO_OF_SPINORFIELDS = DUM_MATRIX + 8; } tmlqcd_mpi_init(argc, argv); g_dbw2rand = 0; /* starts the single and double precision random number */ /* generator */ start_ranlux(rlxd_level, random_seed^nstore); /* we need to make sure that we don't have even_odd_flag = 1 */ /* if any of the operators doesn't use it */ /* in this way even/odd can still be used by other operators */ for(j = 0; j < no_operators; j++) if(!operator_list[j].even_odd_flag) even_odd_flag = 0; #ifndef TM_USE_MPI g_dbw2rand = 0; #endif #ifdef _GAUGE_COPY j = init_gauge_field(VOLUMEPLUSRAND, 1); j += init_gauge_field_32(VOLUMEPLUSRAND, 1); #else j = init_gauge_field(VOLUMEPLUSRAND, 0); j += init_gauge_field_32(VOLUMEPLUSRAND, 0); #endif if (j != 0) { fprintf(stderr, "Not enough memory for gauge_fields! Aborting...\n"); exit(-1); } j = init_geometry_indices(VOLUMEPLUSRAND); if (j != 0) { fprintf(stderr, "Not enough memory for geometry indices! Aborting...\n"); exit(-1); } if (no_monomials > 0) { if (even_odd_flag) { j = init_monomials(VOLUMEPLUSRAND / 2, even_odd_flag); } else { j = init_monomials(VOLUMEPLUSRAND, even_odd_flag); } if (j != 0) { fprintf(stderr, "Not enough memory for monomial pseudo fermion fields! Aborting...\n"); exit(-1); } } if (even_odd_flag) { j = init_spinor_field(VOLUMEPLUSRAND / 2, NO_OF_SPINORFIELDS); j += init_spinor_field_32(VOLUMEPLUSRAND / 2, NO_OF_SPINORFIELDS_32); } else { j = init_spinor_field(VOLUMEPLUSRAND, NO_OF_SPINORFIELDS); j += init_spinor_field_32(VOLUMEPLUSRAND, NO_OF_SPINORFIELDS_32); } if (j != 0) { fprintf(stderr, "Not enough memory for spinor fields! Aborting...\n"); exit(-1); } if (g_running_phmc) { j = init_chi_spinor_field(VOLUMEPLUSRAND / 2, 20); if (j != 0) { fprintf(stderr, "Not enough memory for PHMC Chi fields! Aborting...\n"); exit(-1); } } g_mu = g_mu1; if (g_cart_id == 0) { /*construct the filenames for the observables and the parameters*/ strncpy(datafilename, filename, 200); strcat(datafilename, ".data"); strncpy(parameterfilename, filename, 200); strcat(parameterfilename, ".para"); parameterfile = fopen(parameterfilename, "w"); write_first_messages(parameterfile, "invert", git_hash); fclose(parameterfile); } /* define the geometry */ geometry(); /* define the boundary conditions for the fermion fields */ boundary(g_kappa); phmc_invmaxev = 1.; init_operators(); /* list and initialize measurements*/ if(g_proc_id == 0) { printf("\n"); for(int j = 0; j < no_measurements; j++) { printf("# measurement id %d, type = %d\n", j, measurement_list[j].type); } } init_measurements(); /* this could be maybe moved to init_operators */ #ifdef _USE_HALFSPINOR j = init_dirac_halfspinor(); if (j != 0) { fprintf(stderr, "Not enough memory for halffield! Aborting...\n"); exit(-1); } /* for mixed precision solvers, the 32 bit halfspinor field must always be there */ j = init_dirac_halfspinor32(); if (j != 0) { fprintf(stderr, "Not enough memory for 32-bit halffield! Aborting...\n"); exit(-1); } # if (defined _PERSISTENT) if (even_odd_flag) init_xchange_halffield(); # endif #endif for (j = 0; j < Nmeas; j++) { sprintf(conf_filename, "%s.%.4d", gauge_input_filename, nstore); if (g_cart_id == 0) { printf("#\n# Trying to read gauge field from file %s in %s precision.\n", conf_filename, (gauge_precision_read_flag == 32 ? "single" : "double")); fflush(stdout); } if( (i = read_gauge_field(conf_filename,g_gauge_field)) !=0) { fprintf(stderr, "Error %d while reading gauge field from %s\n Aborting...\n", i, conf_filename); exit(-2); } if (g_cart_id == 0) { printf("# Finished reading gauge field.\n"); fflush(stdout); } #ifdef TM_USE_MPI xchange_gauge(g_gauge_field); #endif /*Convert to a 32 bit gauge field, after xchange*/ convert_32_gauge_field(g_gauge_field_32, g_gauge_field, VOLUMEPLUSRAND); /*compute the energy of the gauge field*/ plaquette_energy = measure_plaquette( (const su3**) g_gauge_field); if (g_cart_id == 0) { printf("# The computed plaquette value is %e.\n", plaquette_energy / (6.*VOLUME*g_nproc)); fflush(stdout); } if (use_stout_flag == 1){ params_smear.rho = stout_rho; params_smear.iterations = stout_no_iter; /* if (stout_smear((su3_tuple*)(g_gauge_field[0]), ¶ms_smear, (su3_tuple*)(g_gauge_field[0])) != 0) */ /* exit(1) ; */ g_update_gauge_copy = 1; plaquette_energy = measure_plaquette( (const su3**) g_gauge_field); if (g_cart_id == 0) { printf("# The plaquette value after stouting is %e\n", plaquette_energy / (6.*VOLUME*g_nproc)); fflush(stdout); } } /* if any measurements are defined in the input file, do them here */ measurement * meas; for(int imeas = 0; imeas < no_measurements; imeas++){ meas = &measurement_list[imeas]; if (g_proc_id == 0) { fprintf(stdout, "#\n# Beginning online measurement.\n"); } meas->measurefunc(nstore, imeas, even_odd_flag); } if (reweighting_flag == 1) { reweighting_factor(reweighting_samples, nstore); } /* Compute minimal eigenvalues, if wanted */ if (compute_evs != 0) { eigenvalues(&no_eigenvalues, 5000, eigenvalue_precision, 0, compute_evs, nstore, even_odd_flag); } if (phmc_compute_evs != 0) { #ifdef TM_USE_MPI MPI_Finalize(); #endif return(0); } /* Compute the mode number or topological susceptibility using spectral projectors, if wanted*/ if(compute_modenumber != 0 || compute_topsus !=0){ invert_compute_modenumber(); } // set up blocks if Deflation is used if (g_dflgcr_flag) init_blocks(nblocks_t, nblocks_x, nblocks_y, nblocks_z); if(SourceInfo.type == SRC_TYPE_VOL || SourceInfo.type == SRC_TYPE_PION_TS || SourceInfo.type == SRC_TYPE_GEN_PION_TS) { index_start = 0; index_end = 1; } g_precWS=NULL; if(use_preconditioning == 1){ /* todo load fftw wisdom */ #if (defined HAVE_FFTW ) && !( defined TM_USE_MPI) loadFFTWWisdom(g_spinor_field[0],g_spinor_field[1],T,LX); #else use_preconditioning=0; #endif } if (g_cart_id == 0) { fprintf(stdout, "#\n"); /*Indicate starting of the operator part*/ } for(op_id = 0; op_id < no_operators; op_id++) { boundary(operator_list[op_id].kappa); g_kappa = operator_list[op_id].kappa; g_mu = operator_list[op_id].mu; g_c_sw = operator_list[op_id].c_sw; // DFLGCR and DFLFGMRES if(operator_list[op_id].solver == DFLGCR || operator_list[op_id].solver == DFLFGMRES) { generate_dfl_subspace(g_N_s, VOLUME, reproduce_randomnumber_flag); } if(use_preconditioning==1 && PRECWSOPERATORSELECT[operator_list[op_id].solver]!=PRECWS_NO ){ printf("# Using preconditioning with treelevel preconditioning operator: %s \n", precWSOpToString(PRECWSOPERATORSELECT[operator_list[op_id].solver])); /* initial preconditioning workspace */ operator_list[op_id].precWS=(spinorPrecWS*)malloc(sizeof(spinorPrecWS)); spinorPrecWS_Init(operator_list[op_id].precWS, operator_list[op_id].kappa, operator_list[op_id].mu/2./operator_list[op_id].kappa, -(0.5/operator_list[op_id].kappa-4.), PRECWSOPERATORSELECT[operator_list[op_id].solver]); g_precWS = operator_list[op_id].precWS; if(PRECWSOPERATORSELECT[operator_list[op_id].solver] == PRECWS_D_DAGGER_D) { fitPrecParams(op_id); } } for(isample = 0; isample < no_samples; isample++) { for (ix = index_start; ix < index_end; ix++) { if (g_cart_id == 0) { fprintf(stdout, "#\n"); /*Indicate starting of new index*/ } /* we use g_spinor_field[0-7] for sources and props for the moment */ /* 0-3 in case of 1 flavour */ /* 0-7 in case of 2 flavours */ prepare_source(nstore, isample, ix, op_id, read_source_flag, source_location, random_seed); //randmize initial guess for eigcg if needed-----experimental if( (operator_list[op_id].solver == INCREIGCG) && (operator_list[op_id].solver_params.eigcg_rand_guess_opt) ){ //randomize the initial guess gaussian_volume_source( operator_list[op_id].prop0, operator_list[op_id].prop1,isample,ix,0); //need to check this } operator_list[op_id].inverter(op_id, index_start, 1); } } if(use_preconditioning==1 && operator_list[op_id].precWS!=NULL ){ /* free preconditioning workspace */ spinorPrecWS_Free(operator_list[op_id].precWS); free(operator_list[op_id].precWS); } if(operator_list[op_id].type == OVERLAP){ free_Dov_WS(); } } nstore += Nsave; } #ifdef TM_USE_OMP free_omp_accumulators(); #endif free_blocks(); free_dfl_subspace(); free_gauge_field(); free_gauge_field_32(); free_geometry_indices(); free_spinor_field(); free_spinor_field_32(); free_moment_field(); free_chi_spinor_field(); free(filename); free(input_filename); free(SourceInfo.basename); free(PropInfo.basename); #ifdef TM_USE_QUDA _endQuda(); #endif #ifdef TM_USE_MPI MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); #endif return(0); #ifdef _KOJAK_INST #pragma pomp inst end(main) #endif }
/*Permet de jouer tout les niveaux * à la suite*/ void campagne(config *cfg, int cmp_level) { int selection=0, level; SAVE_ENABLE=1; Pacman pac; Fantome ftm[NB_MAX_GHOSTS]; score_message *msg_list = NULL; Input in; init_pacman(&pac, cfg); init_blocks(); memset(&in,0,sizeof(in)); while(cmp_level < CAMPAGNE_LEVEL) { level=0; while(strcmp(LEVEL_FILE[level], CAMPAGNE[cmp_level]) && level < NB_LEVEL) { level++; } DELAY = 40-cmp_level; play_menu(cmp_level); init_level(); load_level(level); pac_restart(&pac); init_ghosts(ftm, cfg); while(POINTS) //Tant que l'on a pas mangé toutes les pac-gommes { UpdateEvents(&in); if(in.quit) //Si clique sur croix { delete(&pac, ftm); exit(EXIT_SUCCESS); } while(in.key[SDLK_ESCAPE]) { selection=game_menu(); if(selection==0) in.key[SDLK_ESCAPE]=0; else if(selection==1) save_game(cmp_level); else if(selection==2) //Retour menu principal { delete(&pac, ftm); return; } } if (in.key[SDLK_w]) { in.key[SDLK_w]=0; POINTS=0; //cheat code for winning!! } else if (in.key[SDLK_l] || !(pac.nb_lives)) //cheat code for loosing!! { lost_menu(); draw_result("data/results.txt", pac.score); delete(&pac, ftm); return; } jouer(&pac, ftm, in, cfg, cmp_level, &msg_list); } cmp_level++; win_menu(); } draw_result("data/results.txt", pac.score); delete(&pac, ftm); }
int main(int argc, char **argv) { shutdown = false; //Create a screen context that will be used to create an EGL surface to to receive libscreen events screen_create_context(&screen_cxt, 0); //Initialize BPS library bps_initialize(); //Determine initial orientation angle orientation_direction_t direction; orientation_get(&direction, &orientation_angle); //Use utility code to initialize EGL for rendering with GL ES 1.1 if (EXIT_SUCCESS != bbutil_init_egl(screen_cxt, GL_ES_1)) { fprintf(stderr, "bbutil_init_egl failed\n"); bbutil_terminate(); screen_destroy_context(screen_cxt); return 0; } //Initialize application logic if (EXIT_SUCCESS != init_blocks()) { fprintf(stderr, "initialize failed\n"); bbutil_terminate(); screen_destroy_context(screen_cxt); return 0; } //Signal BPS library that navigator and screen events will be requested if (BPS_SUCCESS != screen_request_events(screen_cxt)) { fprintf(stderr, "screen_request_events failed\n"); bbutil_terminate(); screen_destroy_context(screen_cxt); return 0; } if (BPS_SUCCESS != navigator_request_events(0)) { fprintf(stderr, "navigator_request_events failed\n"); bbutil_terminate(); screen_destroy_context(screen_cxt); return 0; } //Signal BPS library that navigator orientation is not to be locked if (BPS_SUCCESS != navigator_rotation_lock(false)) { fprintf(stderr, "navigator_rotation_lock failed\n"); bbutil_terminate(); screen_destroy_context(screen_cxt); return 0; } //Setup Sensors if (sensor_is_supported(SENSOR_TYPE_AZIMUTH_PITCH_ROLL)) { //Microseconds between sensor reads. This is the rate at which the //sensor data will be updated from hardware. The hardware update //rate is set below using sensor_set_rate. static const int SENSOR_RATE = 25000; //Initialize the sensor by setting the rates at which the //sensor values will be updated from hardware sensor_set_rate(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, SENSOR_RATE); sensor_set_skip_duplicates(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, true); sensor_request_events(SENSOR_TYPE_AZIMUTH_PITCH_ROLL); } else { set_gravity(0.0f, -1.0f); } //Start with one cube on the screen add_cube(200, 100); int i = 0; while (!shutdown) { i = check(1); // Handle user input and sensors handle_events(); //Update cube positions update(); // Draw Scene render(); } //Stop requesting events from libscreen screen_stop_events(screen_cxt); //Shut down BPS library for this process bps_shutdown(); //Free app data free(boxes); //Use utility code to terminate EGL setup bbutil_terminate(); //Destroy libscreen context screen_destroy_context(screen_cxt); return 0; }
void r4300_execute(void) { #if (defined(DYNAREC) && defined(PROFILE_R4300)) unsigned int i; #endif current_instruction_table = cached_interpreter_table; delay_slot=0; stop = 0; rompause = 0; /* clear instruction counters */ #if defined(COUNT_INSTR) memset(instr_count, 0, 131*sizeof(instr_count[0])); #endif last_addr = 0xa4000040; next_interupt = 624999; init_interupt(); if (r4300emu == CORE_PURE_INTERPRETER) { DebugMessage(M64MSG_INFO, "Starting R4300 emulator: Pure Interpreter"); r4300emu = CORE_PURE_INTERPRETER; pure_interpreter(); } #if defined(DYNAREC) else if (r4300emu >= 2) { DebugMessage(M64MSG_INFO, "Starting R4300 emulator: Dynamic Recompiler"); r4300emu = CORE_DYNAREC; init_blocks(); #ifdef NEW_DYNAREC new_dynarec_init(); new_dyna_start(); new_dynarec_cleanup(); #else dyna_start(dynarec_setup_code); PC++; #endif #if defined(PROFILE_R4300) pfProfile = fopen("instructionaddrs.dat", "ab"); for (i=0; i<0x100000; i++) if (invalid_code[i] == 0 && blocks[i] != NULL && blocks[i]->code != NULL && blocks[i]->block != NULL) { unsigned char *x86addr; int mipsop; // store final code length for this block mipsop = -1; /* -1 == end of x86 code block */ x86addr = blocks[i]->code + blocks[i]->code_length; if (fwrite(&mipsop, 1, 4, pfProfile) != 4 || fwrite(&x86addr, 1, sizeof(char *), pfProfile) != sizeof(char *)) DebugMessage(M64MSG_ERROR, "Error writing R4300 instruction address profiling data"); } fclose(pfProfile); pfProfile = NULL; #endif free_blocks(); } #endif else /* if (r4300emu == CORE_INTERPRETER) */ { DebugMessage(M64MSG_INFO, "Starting R4300 emulator: Cached Interpreter"); r4300emu = CORE_INTERPRETER; init_blocks(); jump_to(0xa4000040); /* Prevent segfault on failed jump_to */ if (!actual->block) return; last_addr = PC->addr; while (!stop) { #ifdef COMPARE_CORE if (PC->ops == cached_interpreter_table.FIN_BLOCK && (PC->addr < 0x80000000 || PC->addr >= 0xc0000000)) virtual_to_physical_address(PC->addr, 2); CoreCompareCallback(); #endif #ifdef DBG if (g_DebuggerActive) update_debugger(PC->addr); #endif PC->ops(); } free_blocks(); } DebugMessage(M64MSG_INFO, "R4300 emulator finished."); /* print instruction counts */ #if defined(COUNT_INSTR) if (r4300emu == CORE_DYNAREC) instr_counters_print(); #endif }