int main () { int i=0, error=0, nx=NX, ny=NY, count; float diff,t_cpu,t_gpu,time; /* Matrix allocation */ float *mat_in1 = (floa,t*) malloc(nx * ny * sizeof(float)); float *mat_in2 = (float*) malloc(nx * ny * sizeof(float)); float *mat_out = (float*) malloc(nx * ny * sizeof(float)); /* Matrix initialization */ Init(mat_in1, nx, ny); Init(mat_in2, nx, ny); t_gpu = AddOnGpu(mat_out, mat_in1, mat_in2, nx, ny); /* We now check that the result is correct */ chrono (START, &time); for (count = 0;count < MANY; count++){ for (i=0; i< nx*ny; i++) { /* No need for a 2D loop, actually ! */ mat_out[i] = mat_in1[i] + mat_in2[i]; } } chrono (STOP, &time); t_cpu=time/(float)MANY; printf("Tiempo de CPU: %f segundos\n",t_cpu); printf("Tiempo de GPU: %f segundos\n",t_gpu); printf("factor de aceleracion %f segundos\n",t_cpu/t_gpu); free (mat_in1); free (mat_in2); free (mat_out); }
void wait(u64 amount) { startChrono(); u64 initialValue = chrono(); while(chrono() - initialValue < amount); }
LSst *LS_init(int dim,int ver,char typ,char mfree) { LSst *lsst; /* default values */ lsst = (LSst*)calloc(1,sizeof(LSst)); memset(&lsst->mesh,0,sizeof(Mesh)); /* solution structure */ memset(&lsst->sol,0,sizeof(Sol)); lsst->sol.cl = (Cl*)calloc(LS_CL,sizeof(Cl)); lsst->sol.mat = (Mat*)calloc(LS_MAT,sizeof(Mat)); lsst->sol.res = LS_RES; lsst->sol.nit = LS_MAXIT; lsst->sol.nbcl = 0; lsst->sol.nmat = 0; /* global parameters */ lsst->info.dim = dim; lsst->info.ver = ver; lsst->info.verb = '1'; lsst->info.zip = 0; lsst->info.typ = typ; lsst->info.mfree = mfree; /* init timer */ tminit(lsst->info.ctim,TIMEMAX); chrono(ON,&lsst->info.ctim[0]); return(lsst); }
bool loadSplash(void) { const char *topSplashFile = "splash.bin", *bottomSplashFile = "splashbottom.bin"; bool isTopSplashValid = getFileSize(topSplashFile) == SCREEN_TOP_FBSIZE, isBottomSplashValid = getFileSize(bottomSplashFile) == SCREEN_BOTTOM_FBSIZE, ret; //Don't delay boot nor init the screens if no splash images or invalid splash images are on the SD if(!isTopSplashValid && !isBottomSplashValid) ret = false; else { initScreens(); clearScreens(true, true, true); if(isTopSplashValid) isTopSplashValid = fileRead(fbs[1].top_left, topSplashFile, SCREEN_TOP_FBSIZE) == SCREEN_TOP_FBSIZE; if(isBottomSplashValid) isBottomSplashValid = fileRead(fbs[1].bottom, bottomSplashFile, SCREEN_BOTTOM_FBSIZE) == SCREEN_BOTTOM_FBSIZE; if(!isTopSplashValid && !isBottomSplashValid) ret = false; else { swapFramebuffers(true); chrono(3); ret = true; } } return ret; }
static void mshmet_endcod() { double ttot,ttim[TIMEMAX]; int k,call[TIMEMAX]; chrono(OFF,&mshmet_ctim[0]); for (k=0; k<TIMEMAX; k++) { call[k] = mshmet_ctim[k].call; ttim[k] = mshmet_ctim[k].call ? gttime(mshmet_ctim[k]) : 0.0; } ttot = ttim[1]+ttim[2]+ttim[3]+ttim[4]; ttim[0] = MS_MAX(ttim[0],ttot); if ( ttot > 0.01 ) { fprintf(stdout,"\n -- CPU REQUIREMENTS\n"); fprintf(stdout," in/out %8.2f %% %3d. calls, %7.2f sec/call\n", 100.*ttim[1]/ttim[0],call[1],ttim[1]/(float)call[1]); fprintf(stdout," analysis %8.2f %% %3d. calls, %7.2f sec/call\n", 100.*ttim[2]/ttim[0],call[2],ttim[2]/(float)call[2]); fprintf(stdout," metric %8.2f %% %3d. calls, %7.2f sec/call\n", 100.*ttim[3]/ttim[0],call[3],ttim[3]/(float)call[3]); fprintf(stdout," total %8.2f %% %3d. calls, %7.2f sec/call\n", 100.*ttot/ttim[0],call[0],ttot/(float)call[0]); } fprintf(stdout,"\n ELAPSED TIME %.2f SEC. (%.2f)\n",ttim[0],ttot); }
static inline void endcod() { char stim[32]; chrono(OFF,&ctim[0]); printim(ctim[0].gdif,stim); fprintf(stdout,"\n MMG3DLIB: ELAPSED TIME %s\n",stim); }
/** * * Messages at end of the code. * */ static void _MMG5_endcod() { char stim[32]; chrono(OFF,&MMG5_ctim[0]); printim(MMG5_ctim[0].gdif,stim); fprintf(stdout,"\n ELAPSED TIME %s\n",stim); }
VLst *VL_init(int dim,int ver,char typ,char mfree) { VLst *vlst; /* default values */ vlst = (VLst*)calloc(1,sizeof(VLst)); memset(&vlst->mesh,0,sizeof(Mesh)); /* solution structure */ memset(&vlst->sol,0,sizeof(Sol)); vlst->sol.cl = (Cl*)calloc(VL_CL,sizeof(Cl)); vlst->sol.mat = (Mat*)calloc(VL_MAT,sizeof(Mat)); vlst->sol.res = VL_RES; vlst->sol.nit = VL_MAXIT; vlst->sol.nbcl = 0; vlst->sol.nmat = 0; /* global parameters */ vlst->info.dim = dim; vlst->info.ver = ver; vlst->info.verb = '1'; vlst->info.zip = 0; vlst->info.ls = 0; vlst->info.mfree = mfree; /* init timer */ tminit(vlst->info.ctim,TIMEMAX); chrono(ON,&vlst->info.ctim[0]); return(vlst); }
void exactTest(int instMax,int loop){ float c1 = 0.0; float c2 = 0.0; float c3 = 0.0; int n1 = 0; int n2 = 0; int n3 = 0; chrono(); for(int i = 0;i<instMax;i++){ for(int j = 0;j<loop;j++){ instance_t* t = instanceCreer(i,"test"); instanceInit(t); instanceRandNC(t); //instanceAfficher(t); //instance_t* johnlogn = johnsonnlogn(t,0); //instanceAfficher(johnlogn); instance_t * sol = branch_bound(t,&n1); //printf("Solution finale :"); //instanceAfficher(sol); instanceDetruire(sol); c1 += chrono(); instanceRandDE(t); sol = branch_bound(t,&n2); instanceDetruire(sol); c2 += chrono(); instanceRandM(t); sol = branch_bound(t,&n3); instanceDetruire(sol); c3 += chrono(); instanceDetruire(t); } printf("%i %.5f %.5f %.5f %i %i %i\n",i,c1/loop,c2/loop,c3/loop,n1/loop,n2/loop,n3/loop); } }
void bench_john_nlogn_vs_n2(int taille){ printf("Bench johnson nlogn vs n^2 taille instance : %i\n",taille); chrono(); instance_t* t; t=instanceCreer(taille,"Bench"); instanceRandNC(t); //instanceAfficher(t); instance_t* johnlogn = johnsonnlogn(t,1); //instanceAfficher(johnlogn); printf("Temps d'execution nlogn : %.6f secondes.\n",chrono()); instance_t* john = johnson(t); //instanceAfficher(john); printf("Temps d'execution n^2 : %.6f secondes.\n",chrono()); instanceDetruire(johnlogn); instanceDetruire(john); instanceDetruire(t); }
u32 waitInput(bool isMenu) { static u64 dPadDelay = 0ULL; u64 initialValue = 0ULL; u32 key, oldKey = HID_PAD; if(isMenu) { dPadDelay = dPadDelay > 0ULL ? 87ULL : 143ULL; startChrono(); initialValue = chrono(); } while(true) { key = HID_PAD; if(!key) { if((i2cReadRegister(I2C_DEV_MCU, 0x10) & 1)== 1) mcuPowerOff(); oldKey = 0; dPadDelay = 0; continue; } if(key == oldKey && (!isMenu || (!(key & DPAD_BUTTONS) || chrono() - initialValue < dPadDelay))) continue; //Make sure the key is pressed u32 i; for(i = 0; i < 0x13000 && key == HID_PAD; i++); if(i == 0x13000) break; } return key; }
/* free global data structure */ int LS_stop(LSst *lsst) { char stim[32]; /* release memory */ free(lsst->sol.u); free(lsst->sol.cl); free(lsst->sol.mat); chrono(OFF,&lsst->info.ctim[0]); if ( lsst->info.verb != '0' ) { printim(lsst->info.ctim[0].gdif,stim); fprintf(stdout,"\n ** Cumulative time: %s sec.\n",stim); } return(1); }
/* free global data structure */ int VL_stop(VLst *vlst) { char stim[32]; /* release memory */ free(vlst->sol.u); free(vlst->sol.cl); free(vlst->sol.mat); chrono(OFF,&vlst->info.ctim[0]); if ( vlst->info.verb != '0' ) { printim(vlst->info.ctim[0].gdif,stim); fprintf(stdout,"\n Cumulative time: %s sec.\n",stim); } return(1); }
void johnsonTest(int instMax){ float c1 = 0.0; float c2 = 0.0; float c3 = 0.0; float c4 = 0.0; float c5 = 0.0; float c6 = 0.0; for(int i = 0;i<instMax;i+=100){ instance_t* t = instanceCreer(i,"test"); instanceInit(t); instanceRandNC(t); chrono(); instanceDetruire(johnsonnlogn(t,0)); c1 = chrono(); instanceDetruire(johnson(t)); c2 = chrono(); instanceRandDE(t); chrono(); instanceDetruire(johnsonnlogn(t,0)); c3 = chrono(); instanceDetruire(johnson(t)); c4 = chrono(); instanceRandM(t); chrono(); instanceDetruire(johnsonnlogn(t,0)); c5 = chrono(); instanceDetruire(johnson(t)); c6 = chrono(); printf("%i %.4f %.4f %.4f %.4f %.4f %.4f\n",i,c2,c1,c4,c3,c6,c5); instanceDetruire(t); } }
void colorcyclinghandler() { int s,e,d; SDL_Color colors[256]; int i,c; s=colorcycling_s; e=colorcycling_e; d=colorcycling_d; if(d==0){ c=Palette[s]; for(i=s;i<=e;i++){ //color(i,Palette[i+1]); colors[i].b = Palette[i+1] & 255; colors[i].g =( Palette[i+1] / 256) & 255 ; colors[i].r =( Palette[i+1] / (256*256)) & 255; Palette[i]= Palette[i+1]; } //color(e,c); colors[e].b = c & 255; colors[e].g =( c / 256) & 255 ; colors[e].r =( c / (256*256)) & 255; Palette[e]=c; } else{ c=Palette[e]; for(i=e;i>=s;i--){ //color(i,Palette[i-1]); colors[i].b = Palette[i-1] & 255; colors[i].g =( Palette[i-1] / 256) & 255 ; colors[i].r =( Palette[i-1] / (256*256)) & 255; Palette[i]= Palette[i-1]; } //color(s,c); colors[s].b = c & 255; colors[s].g =( c / 256) & 255 ; colors[s].r =( c / (256*256)) & 255; Palette[s]=c; } /* Set palette */ SDL_SetPalette(SDLdisplay, SDL_LOGPAL|SDL_PHYSPAL, &colors[s], s, e-s); colorcycling_next=colorcycling_delay+chrono(); }
void FileSystem::put(std::string localFile, std::string remoteFile) { // hashing function to find the machine/s where to store the file; ChronoCpu chrono("cpu"); chrono.tic(); int fileKey = hashString(remoteFile); int position = findPositionByKey(fileKey); // cout<<"put "<<localFile<<" "<<fileKey<<" to "<<position<<" "<<virtualRing[position].ip_str<<" "<<virtualRing[position].key<<endl; bool attempt = putToNode( position, localFile, remoteFile ); attempt = putToNode( position+1, localFile, remoteFile ); attempt = putToNode( position+2, localFile, remoteFile ); chrono.tac(); std::cout << "File " << remoteFile << " added in " << chrono.getElapsedStats().lastTime_ms << " ms" << std::endl; }
void FileSystem::get(std::string localFile, std::string remoteFile) { //https://gitlab-beta.engr.illinois.edu/remis2/MP3-FileSystem.git // hashing function to find the machine where to ask for the file; ChronoCpu chrono("cpu"); chrono.tic(); int fileKey = hashString(remoteFile); int position = findPositionByKey(fileKey); // cout<<"get "<<localFile<<" "<<fileKey<<" from "<<position<<" "<<virtualRing[position].ip_str<<" "<<virtualRing[position].key<<endl; bool attempt = getFromNode( position, localFile, remoteFile ); if(!attempt) { std::cout << "Retrying... " << std::endl; attempt = getFromNode( position+1, localFile, remoteFile ); } if(!attempt) { std::cout << "Retrying... " << std::endl; attempt = getFromNode( position+2, localFile, remoteFile ); } if (!attempt) { std::cout << "Error retrieving " << remoteFile << std::endl; } chrono.tac(); if(attempt) std::cout << "File " << remoteFile << " received in " << chrono.getElapsedStats().lastTime_ms << " ms" << std::endl; else std::cout << "File " << remoteFile << " cannot be found. returning in " << chrono.getElapsedStats().lastTime_ms << " ms" << std::endl; }
// Déclenchement du chrono // Le remet à zéro s'il était déjà lancé void chrono_start() { chrono(0); }
/** * \param argc number of command line arguments. * \param argv command line arguments. * \return \ref MMG5_SUCCESS if success. * \return \ref MMG5_LOWFAILURE if failed but a conform mesh is saved. * \return \ref MMG5_STRONGFAILURE if failed and we can't save the mesh. * * Main program for MMG3D executable: perform mesh adaptation. * */ int main(int argc,char *argv[]) { MMG5_Mesh mesh; MMG5_Sol met; int ier; char stim[32]; fprintf(stdout," -- MMG3d, Release %s (%s) \n",MG_VER,MG_REL); fprintf(stdout," %s\n",MG_CPY); fprintf(stdout," %s %s\n",__DATE__,__TIME__); signal(SIGABRT,_MMG5_excfun); signal(SIGFPE,_MMG5_excfun); signal(SIGILL,_MMG5_excfun); signal(SIGSEGV,_MMG5_excfun); signal(SIGTERM,_MMG5_excfun); signal(SIGINT,_MMG5_excfun); atexit(_MMG5_endcod); tminit(MMG5_ctim,TIMEMAX); chrono(ON,&MMG5_ctim[0]); /* assign default values */ memset(&mesh,0,sizeof(MMG5_Mesh)); memset(&met,0,sizeof(MMG5_Sol)); MMG5_Init_parameters(&mesh); met.size = 1; /* command line */ if ( !MMG5_parsar(argc,argv,&mesh,&met) ) return(MMG5_STRONGFAILURE); #ifdef USE_SCOTCH _MMG5_warnScotch(&mesh); #endif /* load data */ fprintf(stdout,"\n -- INPUT DATA\n"); chrono(ON,&MMG5_ctim[1]); _MMG5_warnOrientation(&mesh); /* read mesh file */ if ( !MMG5_loadMesh(&mesh) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); /* read metric if any */ ier = MMG5_loadMet(&mesh,&met); if ( !ier ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); else if ( ier > 0 && met.np != mesh.np ) { fprintf(stdout," ## WARNING: WRONG SOLUTION NUMBER. IGNORED\n"); _MMG5_DEL_MEM(&mesh,met.m,(met.size*met.npmax+1)*sizeof(double)); met.np = 0; } else if ( met.size!=1 ) { fprintf(stdout," ## ERROR: ANISOTROPIC METRIC NOT IMPLEMENTED.\n"); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); } if ( !MMG5_parsop(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_LOWFAILURE); chrono(OFF,&MMG5_ctim[1]); printim(MMG5_ctim[1].gdif,stim); fprintf(stdout," -- DATA READING COMPLETED. %s\n",stim); /* analysis */ chrono(ON,&MMG5_ctim[2]); _MMG5_setfunc(&mesh,&met); MMG5_Set_saveFunc(&mesh); if ( abs(mesh.info.imprim) > 0 ) _MMG5_outqua(&mesh,&met); fprintf(stdout,"\n %s\n MODULE MMG3D: IMB-LJLL : %s (%s)\n %s\n", MG_STR,MG_VER,MG_REL,MG_STR); if ( mesh.info.imprim ) fprintf(stdout,"\n -- PHASE 1 : ANALYSIS\n"); if ( !_MMG5_scaleMesh(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( mesh.info.iso ) { if ( !met.np ) { fprintf(stdout,"\n ## ERROR: A VALID SOLUTION FILE IS NEEDED \n"); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); } if ( !_MMG5_mmg3d2(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); } if ( !mesh.info.iso && !met.np && !_MMG5_DoSol(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_LOWFAILURE); if ( !_MMG5_analys(&mesh) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_LOWFAILURE); if ( mesh.info.imprim > 3 && !mesh.info.iso && met.m ) _MMG5_prilen(&mesh,&met); chrono(OFF,&MMG5_ctim[2]); printim(MMG5_ctim[2].gdif,stim); if ( mesh.info.imprim ) fprintf(stdout," -- PHASE 1 COMPLETED. %s\n",stim); /* mesh adaptation */ chrono(ON,&MMG5_ctim[3]); if ( mesh.info.imprim ) fprintf(stdout,"\n -- PHASE 2 : %s MESHING\n",met.size < 6 ? "ISOTROPIC" : "ANISOTROPIC"); /* renumerotation if available */ if ( !_MMG5_scotchCall(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); #ifdef PATTERN if ( !_MMG5_mmg3d1_pattern(&mesh,&met) ) { if ( !(mesh.adja) && !_MMG5_hashTetra(&mesh,1) ) { fprintf(stdout," ## Hashing problem. Unable to save mesh.\n"); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); } if ( !_MMG5_unscaleMesh(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( !MMG5_saveMesh(&mesh) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( met.m && !MMG5_saveMet(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_LOWFAILURE); } #else /* Pattern in iso mode, delauney otherwise */ if ( !mesh.info.iso ) { if( !_MMG5_mmg3d1_delone(&mesh,&met) ) { if ( !(mesh.adja) && !_MMG5_hashTetra(&mesh,1) ) { fprintf(stdout," ## Hashing problem. Unable to save mesh.\n"); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); } if ( !_MMG5_unscaleMesh(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( !MMG5_saveMesh(&mesh) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( met.m && !MMG5_saveMet(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_LOWFAILURE); } } else { if( !_MMG5_mmg3d1_pattern(&mesh,&met) ) { if ( !(mesh.adja) && !_MMG5_hashTetra(&mesh,1) ) { fprintf(stdout," ## Hashing problem. Unable to save mesh.\n"); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); } if ( !_MMG5_unscaleMesh(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( !MMG5_saveMesh(&mesh) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( met.m && !MMG5_saveMet(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_LOWFAILURE); } } #endif chrono(OFF,&MMG5_ctim[3]); printim(MMG5_ctim[3].gdif,stim); if ( mesh.info.imprim ) fprintf(stdout," -- PHASE 2 COMPLETED. %s\n",stim); fprintf(stdout,"\n %s\n END OF MODULE MMG3d: IMB-LJLL \n %s\n",MG_STR,MG_STR); /* save file */ _MMG5_outqua(&mesh,&met); if ( mesh.info.imprim > 3 && !mesh.info.iso ) _MMG5_prilen(&mesh,&met); chrono(ON,&MMG5_ctim[1]); if ( mesh.info.imprim ) fprintf(stdout,"\n -- WRITING DATA FILE %s\n",mesh.nameout); if ( !_MMG5_unscaleMesh(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( !MMG5_saveMesh(&mesh) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); if ( !MMG5_saveMet(&mesh,&met) ) _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_STRONGFAILURE); chrono(OFF,&MMG5_ctim[1]); if ( mesh.info.imprim ) fprintf(stdout," -- WRITING COMPLETED\n"); /* free mem */ _MMG5_RETURN_AND_FREE(&mesh,&met,MMG5_SUCCESS); }
int main(int argc,char *argv[]) { MMG5_pMesh mesh; MMG5_pSol met; int ier; char stim[32]; atexit(endcod); tminit(ctim,TIMEMAX); chrono(ON,&ctim[0]); /* assign default values */ mesh = NULL; met = NULL; MMG5_Init_mesh(&mesh,&met); /* reset default values for file names */ MMG5_Free_names(mesh,met); /* command line */ if ( !MMG5_parsar(argc,argv,mesh,met) ) return(1); /* load data */ fprintf(stdout,"\n -- INPUT DATA\n"); chrono(ON,&ctim[1]); /* read mesh file */ if ( !MMG5_loadMesh(mesh) ) { MMG5_Free_all(mesh,met ); return(MMG5_STRONGFAILURE); } if ( !MMG5_Set_solSize(mesh,met,MMG5_Vertex,0,MMG5_Scalar) ) { MMG5_Free_all(mesh,met); return(MMG5_STRONGFAILURE); } /* read metric if any */ ier = MMG5_loadMet(mesh,met); if ( !ier ) { MMG5_Free_all(mesh,met); return(MMG5_STRONGFAILURE); } if ( !MMG5_parsop(mesh,met) ) RETURN_AND_FREE(mesh,met,MMG5_LOWFAILURE); chrono(OFF,&ctim[1]); printim(ctim[1].gdif,stim); fprintf(stdout," -- DATA READING COMPLETED. %s\n",stim); ier = MMG5_mmg3dlib(mesh,met ); if ( ier != MMG5_STRONGFAILURE ) { chrono(ON,&ctim[1]); if ( mesh->info.imprim ) fprintf(stdout,"\n -- WRITING DATA FILE %s\n",mesh->nameout); if ( !MMG5_saveMesh(mesh) ) { MMG5_Free_all(mesh,met ); return(EXIT_FAILURE); } if ( !MMG5_saveMet(mesh,met) ) { MMG5_Free_all(mesh,met); return(EXIT_FAILURE); } chrono(OFF,&ctim[1]); if ( mesh->info.imprim ) fprintf(stdout," -- WRITING COMPLETED\n"); } /* free mem */ chrono(OFF,&ctim[0]); printim(ctim[0].gdif,stim); fprintf(stdout,"\n MMG3D: ELAPSED TIME %s\n",stim); MMG5_Free_all(mesh,met); return(ier); }
int MSHMET_mshmet(int intopt[7], double fopt[4], pMesh mesh, pSol sol){ Info *info; fprintf(stdout," -- MSHMET, Release %s (%s) \n",MS_VER,MS_REL); fprintf(stdout," %s\n",MS_CPY); fprintf(stdout," %s\n",COMPIL); /* trap exceptions */ signal(SIGABRT,mshmet_excfun); signal(SIGFPE,mshmet_excfun); signal(SIGILL,mshmet_excfun); signal(SIGSEGV,mshmet_excfun); signal(SIGTERM,mshmet_excfun); signal(SIGINT,mshmet_excfun); //atexit(mshmet_endcod); tminit(mshmet_ctim,TIMEMAX); chrono(ON,&mshmet_ctim[0]); chrono(ON,&mshmet_ctim[1]); /* default */ info = &mesh->info; info->hmin = (float) fopt[0]; // 0.01; info->hmax = (float) fopt[1]; // 1.0; info->eps = (float) fopt[2]; // 0.01; info->width = (float) fopt[3]; // 0.05; info->nnu = intopt[0]; // 0; info->iso = intopt[1]; // 0; info->ls = intopt[2]; // 0; info->ddebug = intopt[3]; // 0; info->imprim = intopt[4]; // 10; info->nlis = intopt[5]; // 0; info->bin = 1; // pas besoin c'est pour le fichier info->nsol = -1; //-1; // pas besoin ==> on peut prendre plusieurs solutions en meme temps ??? info->metric = intopt[6]; // 0; // metric given besoin ??? MSHMET_setfunc(mesh); chrono(OFF,&mshmet_ctim[1]); if ( mesh->info.imprim ) mshmet_stats(mesh,sol); fprintf(stdout," -- DATA READING COMPLETED. %.2f sec.\n",gttime(mshmet_ctim[1])); fprintf(stdout,"\n %s\n MODULE MSHMET-LJLL : %s (%s)\n %s\n", MS_STR,MS_VER,MS_REL,MS_STR); /* analysis */ chrono(ON,&mshmet_ctim[2]); if ( mesh->info.imprim ) fprintf(stdout,"\n -- PHASE 1 : ANALYSIS\n"); if ( abs(mesh->info.imprim) > 4 ) { fprintf(stdout," ** SETTING ADJACENCIES\n"); fflush(stdout); } if ( !scaleMesh(mesh,sol) ) return(1); if ( !hashel(mesh) ) exit(1); chrono(OFF,&mshmet_ctim[2]); if ( mesh->info.imprim ) fprintf(stdout," -- PHASE 1 COMPLETED. %.2f sec.\n",gttime(mshmet_ctim[2])); /* metric */ chrono(ON,&mshmet_ctim[3]); if ( mesh->info.imprim ) fprintf(stdout,"\n -- PHASE 2 : METRIC\n"); if ( !mshme1(mesh,sol) ) exit(1); chrono(OFF,&mshmet_ctim[3]); if ( mesh->info.imprim ) fprintf(stdout," -- PHASE 2 COMPLETED. %.2f sec.\n",gttime(mshmet_ctim[3])); fprintf(stdout,"\n %s\n END OF MODULE MSHMET \n %s\n",MS_STR,MS_STR); /* sol->outn="zzzz"; if ( !saveMet(sol,&mesh->info,sol->outn) ) exit(1); */ if ( mesh->info.imprim ) mshmet_endcod(); fprintf(stdout,"\n %s\n END OF MODULE MSHMET \n %s\n",MS_STR,MS_STR); if ( mesh->info.imprim < -4 || mesh->info.ddebug ) M_memDump(); return(0); }
void show_wep_stats( int B, int force, PTW_tableentry table[PTW_KEYHSBYTES][PTW_n], int choices[KEYHSBYTES], int depth[KEYHSBYTES], int prod, int keylimit ) { float delta; struct winsize ws; int i, et_h, et_m, et_s; static int is_cleared = 0; return; if( ioctl( 0, TIOCGWINSZ, &ws ) < 0 ) { ws.ws_row = 25; ws.ws_col = 80; } if( (chrono( &t_stats, 0 ) < 1.51) && force == 0 ) return; chrono( &t_stats, 1 ); delta = chrono( &t_begin, 0 ); et_h = delta / 3600; et_m = ( delta - et_h * 3600 ) / 60; et_s = delta - et_h * 3600 - et_m * 60; if( is_cleared == 0 ) { is_cleared++; printf( "\33[2J" ); } if(table) printf( "\33[5;%dH[%02d:%02d:%02d] Tested %d/%d keys\33[K", (ws.ws_col - 44) / 2, et_h, et_m, et_s, prod, keylimit ); printf( "\33[7;4HKB depth byte(vote)\n" ); for( i = 0; i <= B; i++ ) { int j, k = ( ws.ws_col - 20 ) / 9; if(table) printf( " %2d %3d/%3d ", i, depth[i], choices[i] ); if(table) { for( j = depth[i]; j < k + depth[i]; j++ ) { if( j >= 256 ) break; printf( "%02X(%4d) ", table[i][j].b, table[i][j].votes ); } } printf( "\n" ); } // if( B < opt.keylen - 1 ) // printf( "\33[J" ); printf( "\n" ); }
int main(int argc,char *argv[]) { int type; char pwd[1024]; #ifdef ppc if ( !getwd(pwd) ) exit(2); #endif fprintf(stdout," -- Medit, Release %s (%s)\n",ME_VER,ME_REL); fprintf(stdout," %s.\n",ME_CPY); fprintf(stdout," compiled: %s.\n\n",COMPIL); /* trap exceptions */ signal(SIGABRT,excfun); signal(SIGFPE,excfun); signal(SIGILL,excfun); signal(SIGSEGV,excfun); signal(SIGTERM,excfun); signal(SIGINT,excfun); atexit(endcod); tminit(ctim,TIMEMAX); chrono(ON,&ctim[0]); /* default values */ option = STANDARD; saveimg = GL_FALSE; imgtype = P6; animate = FALSE; morphing = FALSE; fullscreen = FALSE; animdep = 0; animfin = 0; ddebug = FALSE; quiet = TRUE;//FALSE; stereoMode = 0; cv.nbm = cv.nbs = 0; /* default value for popen */ dpopen = FALSE; dpopenbin = FALSE; dpopensol = FALSE; /* init grafix */ parsar(argc,argv); //printf("fin de parsar"); if ( option == ISOSURF ) { fprintf(stdout,"ISOSURF"); if ( !medit0() ) exit(1); if ( !medit1() ) exit(1); return(0); } glutInit(&argc,argv); //printf("fin de glutInit"); #ifdef ppc chdir(pwd); #endif chrono(ON,&ctim[0]); if ( stereoMode == MONO ) type = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH; else type = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO; glutInitDisplayMode(type); if ( infogl ) grInfo(); /* call animate or normal mode */ if( dpopen == FALSE ){ switch (option) { case STANDARD: case SCHNAUZER: if ( !medit0() ) exit(1); if ( !medit1() ) exit(1); break; case SEQUENCE: if ( !animat() ) exit(1); break; case SEQUENCE+PARTICLE: if ( !animat() ) exit(1); break; case MORPHING: if ( !medit0() ) exit(1); if ( !modeMorphing() ) exit(1); morphing = GL_FALSE; break; default: fprintf(stderr," ## Unrecognized option %d\n",option); exit(1); break; } } else{ switch (option) { case STANDARD: case SCHNAUZER: if ( !medit0_popen() ) exit(1); if ( !medit1() ) exit(1); break; case SEQUENCE: if ( !animat() ) exit(1); break; case SEQUENCE+PARTICLE: if ( !animat() ) exit(1); break; case MORPHING: if ( !medit0_popen() ) exit(1); if ( !modeMorphing() ) exit(1); morphing = GL_FALSE; break; default: fprintf(stderr," ## Unrecognized option %d\n",option); exit(1); break; } } /* main grafix loop */ fprintf(stdout,"\n Rendering scene(s)\n"); glGetBooleanv(GL_STEREO,&hasStereo); glutMainLoop(); return(0); }
static void endcod() { chrono(OFF,&ctim[0]); fprintf(stdout,"\n Total running seconds: %.2f\n",gttime(ctim[0])); fprintf(stdout," Thank you for using Medit.\n"); }
float chrono_val() { return chrono(1); }