这篇教程C++ tic函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tic函数的典型用法代码示例。如果您正苦于以下问题:C++ tic函数的具体用法?C++ tic怎么用?C++ tic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tic函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fprintfWrapImpl *WrapImpl::getWrapImpl(WrapImplType t){ m_wrapImplType = t; FILE *stream = stdout; WrapImpl *w = NULL; if ((t == NoSCM) || (t == NoGuarantee) || (t == NoAtomicity) || (t == MemCheck) || (t == Wrap_Hardware)) { if (t == MemCheck) fprintf(stream, "MemCheck/n"); else if (t == NoAtomicity) fprintf(stream, "NoAtomicity/n"); else if (t == NoSCM) fprintf(stream, "NoSCM/n"); else if (t == NoGuarantee) fprintf(stream, "NoGuarantee/n"); else if (t == Wrap_Hardware) fprintf(stream, "Wrap_Hardware/n"); else assert(0); w = new WrapImpl(); } if (t == UndoLog) { fprintf(stream, "UndoLog/n"); w = new WrapImplUndoLog(); } if (t == Wrap_Software) { fprintf(stream, "Software/n"); w = new WrapImplSoftware(); } tic(); totalWrapTime = getTime(); return w;}
开发者ID:nvmwrap,项目名称:softwrap,代码行数:37,
示例2: solveLinSysscs_int solveLinSys(const AMatrix * A, const Settings * stgs, Priv * p, scs_float * b, const scs_float * s, scs_int iter) { scs_int cgIts; scs_float cgTol = calcNorm(b, A->n) * (iter < 0 ? CG_BEST_TOL : CG_MIN_TOL / POWF((scs_float) iter + 1, stgs->cg_rate)); tic(&linsysTimer); /* solves Mx = b, for x but stores result in b */ /* s contains warm-start (if available) */ accumByAtrans(A, p, &(b[A->n]), b); /* solves (I+A'A)x = b, s warm start, solution stored in b */ cgIts = pcg(A, stgs, p, s, b, A->n, MAX(cgTol, CG_BEST_TOL)); scaleArray(&(b[A->n]), -1, A->m); accumByA(A, p, b, &(b[A->n])); if (iter >= 0) { totCgIts += cgIts; } totalSolveTime += tocq(&linsysTimer);#if EXTRAVERBOSE > 0 scs_printf("linsys solve time: %1.2es/n", tocq(&linsysTimer) / 1e3);#endif return 0;}
开发者ID:zhangrj7,项目名称:scs,代码行数:24,
示例3: mainint main(int argc, char **argv){ ref_vector X, B, Bi; vector C, C1; comp_vector S, Si, Scomp, Scompi; comp_vector R, Ri, Rcomp, Rcompi; comp_matrix O, Oi; int s_ratio; exome ex; check_syntax(argc, 5, "preprocess_debug ref_file output_dir s_ratio nucleotides"); timevars(); init_replace_table(argv[4]); s_ratio = atoi(argv[3]); encode_reference(&X, &ex, true, argv[1]); save_exome_file(&ex, argv[2]); tic("Calculating BWT"); calculateBWTdebug(&B, &S, &X, 0); toc(); save_ref_vector(&X, argv[2], "X"); print_vector(S.vector, S.n); print_vector(B.vector, B.n); tic("Calculating prefix-trie matrices C and O"); calculate_C(&C, &C1, &B); calculate_O(&O, &B); toc(); print_vector(C.vector, C.n); print_vector(C1.vector, C1.n); print_comp_matrix(O); save_ref_vector(&B, argv[2], "B"); free(B.vector); save_vector(&C, argv[2], "C"); free(C.vector); save_vector(&C1, argv[2], "C1"); free(C1.vector); save_comp_matrix(&O, argv[2], "O"); free_comp_matrix(NULL, &O); tic("Calculating R"); calculate_R(&R, &S); toc(); print_vector(R.vector, R.n); tic("Calculating Scomp Rcomp"); compress_SR(&S, &Scomp, s_ratio); print_vector(Scomp.vector, Scomp.n); compress_SR(&R, &Rcomp, s_ratio); print_vector(Rcomp.vector, Rcomp.n); toc(); save_comp_vector(&S, argv[2], "S"); free(S.vector); save_comp_vector(&R, argv[2], "R"); free(R.vector); save_comp_vector(&Scomp, argv[2], "Scomp"); free(Scomp.vector); save_comp_vector(&Rcomp, argv[2], "Rcomp"); free(Rcomp.vector); tic("Calculating BWT of reverse reference"); calculateBWTdebug(&Bi, &Si, &X, 1); toc(); save_ref_vector(&X, argv[2], "Xi"); print_vector(Bi.vector, Bi.n); print_vector(Si.vector, Si.n); tic("Calculating inverted prefix-trie matrix Oi"); calculate_O(&Oi, &Bi); toc(); free(X.vector); print_comp_matrix(Oi); save_ref_vector(&Bi, argv[2], "Bi"); free(Bi.vector); save_comp_matrix(&Oi, argv[2], "Oi"); free_comp_matrix(NULL, &Oi); tic("Calculating Ri"); calculate_R(&Ri, &Si); toc(); print_vector(Ri.vector, Ri.n);//.........这里部分代码省略.........
开发者ID:josator,项目名称:gnu-bwt-aligner,代码行数:101,
示例4: mexFunction//.........这里部分代码省略......... if( utIsInterruptPending() ){ if( INPUT[1] != NULL ){ mxDestroyArray( INPUT[1] ); INPUT[1]=NULL; } if( OUTPUT[0] != NULL ){ mxDestroyArray( OUTPUT[0] ); OUTPUT[0]=NULL; } if( OUTPUT[1] != NULL ){ mxDestroyArray( OUTPUT[1] ); OUTPUT[1]=NULL; } if( OUTPUT[2] != NULL ){ mxDestroyArray( OUTPUT[2] ); OUTPUT[2]=NULL; } mexPrintf("USER INTERRUP!!!/n"); mxErrMsgTxt("USER INTERRUP!!!"); } if( VERBOSE ){ mexPrintf("v_init: %d (%g) of %d/n", v_init , LAST_MAX , EVERY ); } for( v = v_init ; v < nV ; v += EVERY ){ vv = VV[ v ]; thisMINx = V[ vv ]; thisMINy = -thisMINx; if( ( thisMINx < LAST_MAX ) && ( thisMINy < LAST_MAX ) ){ continue; } T = TS[ vv ]; ijk[0] = T.i + 1; ijk[1] = T.j + 1; ijk[2] = T.k + 1; if( OUTPUT[0] != NULL ){ mxDestroyArray( OUTPUT[0] ); OUTPUT[0]=NULL; } if( OUTPUT[1] != NULL ){ mxDestroyArray( OUTPUT[1] ); OUTPUT[1]=NULL; } if( OUTPUT[2] != NULL ){ mxDestroyArray( OUTPUT[2] ); OUTPUT[2]=NULL; } if( !callSort ){ tic( CallMatlab ); result = mexCallMATLAB( 2 , OUTPUT , 2 , INPUT , "feval" ); fevals++; tac( CallMatlab ); } else { tic( CallMatlab ); result = mexCallMATLAB( 1 , OUTPUT , 2 , INPUT , "feval" ); fevals++; tac( CallMatlab ); } DI = mySize( OUTPUT[0] , 0 ); DJ = mySize( OUTPUT[0] , 1 ); DK = mySize( OUTPUT[0] , 2 ); DIJK = DI*DJ*DK; if( volumes[ NVOLS_1 ] > DIJK ){ if( INPUT[1] != NULL ){ mxDestroyArray( INPUT[1] ); INPUT[1]=NULL; } if( OUTPUT[0] != NULL ){ mxDestroyArray( OUTPUT[0] ); OUTPUT[0]=NULL; } if( OUTPUT[1] != NULL ){ mxDestroyArray( OUTPUT[1] ); OUTPUT[1]=NULL; } if( OUTPUT[2] != NULL ){ mxDestroyArray( OUTPUT[2] ); OUTPUT[2]=NULL; } mxErrMsgTxt("el maximo volumen debe ser menor que numel(DIST)"); } DIJK_1 = DIJK - 1; DIST = (double *) mxGetData( OUTPUT[0] ); DTS = (triplet *) mxRealloc( DTS , DIJK*sizeof( triplet ) ); s = 0; for( kk = 0 ; kk < DK ; kk++ ){ for( jj = 0 ; jj < DJ ; jj++ ){ for( ii = 0 ; ii < DI ; ii++ ){ DTS[ s ].i = ii; DTS[ s ].j = jj; DTS[ s ].k = kk;
开发者ID:jackjallen,项目名称:MATLAB2,代码行数:67,
示例5: ticintPreconditionerAS<space_type,coef_space_type>::applyInverse ( const vector_type& X /*R*/, vector_type& Y /*W*/) const{ /* * We solve Here P_v w = r * With P_v^-1 = diag(P_m)^-1 (=A) * + P (/bar L + g /bar Q) P^t (=B) * + C (L^-1) C^T (=C) */ U = X; U.close(); // solve equ (12) if ( this->type() == AS ) { tic(); *M_r = U; M_r->close(); // step A : diag(Pm)^-1*r A->pointwiseDivide(*M_r,*M_diagPm); A->close(); // s = P^t r M_Pt->multVector(M_r,M_s); // Impose boundary conditions on M_s#if 1 M_qh3_elt = *M_s; M_qh3_elt.close();#if FEELPP_DIM == 3 M_qh3_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.), cst(0.)) );#else M_qh3_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.)) );#endif *M_s = M_qh3_elt; M_s->close();#endif#if 1 // Subvectors for M_s (per component) need to be updated M_s1 = M_s->createSubVector(M_Qh3_indices[0], true); M_s2 = M_s->createSubVector(M_Qh3_indices[1], true);#if FEELPP_DIM == 3 M_s3 = M_s->createSubVector(M_Qh3_indices[2], true);#endif#else // s = [ s1, s2, s3 ] M_s->updateSubVector(M_s1, M_Qh3_indices[0]); M_s->updateSubVector(M_s2, M_Qh3_indices[1]);#if FEELPP_DIM == 3 M_s->updateSubVector(M_s3, M_Qh3_indices[2]);#endif#endif M_s->close(); /* * hat(L) + g Q is a (Qh,Qh) matrix * [[ hat(L) + g Q, 0 , 0 ], [ y1 ] [ s1 ] * [ 0, hat(L) + g Q, 0 ], * [ y2 ] = [ s2 ] * [ 0, 0 , hat(L) + g Q ]] [ y3 ] [ s3 ] */ M_lgqOp->applyInverse(M_s1,M_y1); M_lgqOp->applyInverse(M_s2,M_y2);#if FEELPP_DIM == 3 M_lgqOp->applyInverse(M_s3,M_y3);#endif // y = [ y1, y2, y3 ] M_y->updateSubVector(M_y1, M_Qh3_indices[0]); M_y->updateSubVector(M_y2, M_Qh3_indices[1]);#if FEELPP_DIM == 3 M_y->updateSubVector(M_y3, M_Qh3_indices[2]);#endif M_y->close(); // step B : P*y M_P->multVector(M_y,B); // Impose boundary conditions on B = Py#if 1 M_vh_elt = *B; M_vh_elt.close();#if FEELPP_DIM == 3 M_vh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.), cst(0.)) );#else M_vh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=vec(cst(0.), cst(0.)) );#endif *B = M_vh_elt; B->close();#endif // t = C^t r M_Ct->multVector(M_r,M_t); // Impose boundary conditions on M_t#if 1 M_qh_elt = *M_t; M_qh_elt.close(); M_qh_elt.on( _range=boundaryfaces( M_Qh3->mesh() ), _expr=cst(0.) ); *M_t = M_qh_elt; M_t->close();#endif//.........这里部分代码省略.........
开发者ID:feelpp,项目名称:feelpp,代码行数:101,
示例6: hpquadsint hpquads(startree_t* starkd, codefile_t* codes, quadfile_t* quads, int Nside, double scale_min_arcmin, double scale_max_arcmin, int dimquads, int passes, int Nreuses, int Nloosen, int id, anbool scanoccupied, void* sort_data, int (*sort_func)(const void*, const void*), int sort_size, char** args, int argc) { hpquads_t myhpquads; hpquads_t* me = &myhpquads; int i; int pass; anbool circle = TRUE; double radius2; il* hptotry; int Nhptotry = 0; int nquads; double hprad; double quadscale; int skhp, sknside; qfits_header* qhdr; qfits_header* chdr; int N; int dimcodes; int quadsize; int NHP; memset(me, 0, sizeof(hpquads_t)); if (Nside > HP_MAX_INT_NSIDE) { ERROR("Error: maximum healpix Nside = %i", HP_MAX_INT_NSIDE); return -1; } if (Nreuses > 255) { ERROR("Error, reuse (-r) must be less than 256"); return -1; } me->Nside = Nside; me->dimquads = dimquads; NHP = 12 * Nside * Nside; dimcodes = dimquad2dimcode(dimquads); quadsize = sizeof(unsigned int) * dimquads; logmsg("Nside=%i. Nside^2=%i. Number of healpixes=%i. Healpix side length ~ %g arcmin./n", me->Nside, me->Nside*me->Nside, NHP, healpix_side_length_arcmin(me->Nside)); me->sort_data = sort_data; me->sort_func = sort_func; me->sort_size = sort_size; tic(); me->starkd = starkd; N = startree_N(me->starkd); logmsg("Star tree contains %i objects./n", N); // get the "HEALPIX" header from the skdt... skhp = qfits_header_getint(startree_header(me->starkd), "HEALPIX", -1); if (skhp == -1) { if (!qfits_header_getboolean(startree_header(me->starkd), "ALLSKY", FALSE)) { logmsg("Warning: skdt does not contain /"HEALPIX/" header. Code and quad files will not contain this header either./n"); } } // likewise "HPNSIDE" sknside = qfits_header_getint(startree_header(me->starkd), "HPNSIDE", 1); if (sknside && Nside % sknside) { logerr("Error: Nside (-n) must be a multiple of the star kdtree healpixelisation: %i/n", sknside); return -1; } if (!scanoccupied && (N*(skhp == -1 ? 1 : sknside*sknside*12) < NHP)) { logmsg("/n/n"); logmsg("NOTE, your star kdtree is sparse (has only a fraction of the stars expected)/n"); logmsg(" so you probably will get much faster results by setting the /"-E/" command-line/n"); logmsg(" flag./n"); logmsg("/n/n"); } quads->dimquads = me->dimquads; codes->dimcodes = dimcodes; quads->healpix = skhp; codes->healpix = skhp; quads->hpnside = sknside; codes->hpnside = sknside; if (id) {//.........这里部分代码省略.........
开发者ID:HarvardPHATSY,项目名称:astrometry.net,代码行数:101,
示例7: mainint main(int argc, char **argv){ tic(); char *conf_file = NULL; socket_fd = -1; for (int i=1; i<argc; i++) { if (!strcmp(argv[i], "-c")) { if (argc <= i) { print_usage(); } conf_file = argv[++i]; } else if (!strcmp(argv[i], "-fd")) { if (argc <= i) { print_usage(); } socket_fd = atoi(argv[++i]); } else { printf(" >> unknown option: %s/n", argv[i]); } } if (!conf_file) conf_file = "cbot.conf"; load_config(conf_file); // Set rand seed srand(time(NULL)); // Set up cURL curl_global_init(CURL_GLOBAL_ALL); // Set up db connection for logging if (config->enabled_modules & MODULE_LOG) { log_init(); } // Parse markov corpus if (config->enabled_modules & MODULE_MARKOV) { markov_init(config->markovcorpus); } irc_init(); if (socket_fd == -1) { printf(" - Connecting to %s:%s with nick %s, joining channels.../n", config->host, config->port, config->nick); net_connect(); } else { // In-place upgrade yo printf(" >> Already connected, upgraded in-place!/n"); join_channels(); } struct recv_data *irc = malloc(sizeof(struct recv_data)); patterns = malloc(sizeof(*patterns)); compile_patterns(patterns); // Select param fd_set socket_set; FD_ZERO(&socket_set); FD_SET(STDIN_FILENO, &socket_set); FD_SET(socket_fd, &socket_set); int recv_size; char buffer[BUFFER_SIZE]; char input[BUFFER_SIZE]; memset(buffer, 0, BUFFER_SIZE); size_t buffer_length = 0; while (1) { int ret = select(socket_fd+1, &socket_set, 0, 0, 0); if (ret == -1) { printf(" >> Disconnected, reconnecting.../n"); close(socket_fd); net_connect(); } if (FD_ISSET(STDIN_FILENO, &socket_set)) { if (fgets(input, BUFFER_SIZE, stdin) == NULL) { printf(" >> Error while reading from stdin!/n"); continue; } if (strcmp(input, "quit/n") == 0) { printf(" >> Bye!/n"); break; } else if (strcmp(input, "reload/n") == 0) { terminate(); free(irc); free_patterns(patterns); free(patterns); // Set up arguments char * arguments[6]; arguments[0] = argv[0]; arguments[1] = "-c"; arguments[2] = conf_file; arguments[3] = "-fd"; char fdstring[snprintf(NULL, 0, "%d", socket_fd)]; sprintf(fdstring, "%d", socket_fd); arguments[4] = fdstring;//.........这里部分代码省略.........
开发者ID:larsivsi,项目名称:cbot,代码行数:101,
示例8: run_benchmarkvoid run_benchmark( void *vargs, cl_context& context, cl_command_queue& commands, cl_program& program, cl_kernel& kernel ) { struct bench_args_t *args = (struct bench_args_t *)vargs; int num_jobs = 1 << 16; char* seqA_batch = (char *)malloc(sizeof(args->seqA) * num_jobs); char* seqB_batch = (char *)malloc(sizeof(args->seqB) * num_jobs); char* alignedA_batch = (char *)malloc(sizeof(args->alignedA) * num_jobs); char* alignedB_batch = (char *)malloc(sizeof(args->alignedB) * num_jobs); int i; for (i=0; i<num_jobs; i++) { memcpy(seqA_batch + i*sizeof(args->seqA), args->seqA, sizeof(args->seqA)); memcpy(seqB_batch + i*sizeof(args->seqB), args->seqB, sizeof(args->seqB)); memcpy(alignedA_batch + i*sizeof(args->alignedA), args->alignedA, sizeof(args->alignedA)); memcpy(alignedB_batch + i*sizeof(args->alignedB), args->alignedB, sizeof(args->alignedB)); } // 0th: initialize the timer at the beginning of the program timespec timer = tic(); // Create device buffers // cl_mem seqA_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(args->seqA)*num_jobs, NULL, NULL); cl_mem seqB_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(args->seqB)*num_jobs, NULL, NULL); cl_mem alignedA_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(args->alignedA)*num_jobs, NULL, NULL); cl_mem alignedB_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(args->alignedB)*num_jobs, NULL, NULL); if (!seqA_buffer || !seqB_buffer || !alignedA_buffer || !alignedB_buffer) { printf("Error: Failed to allocate device memory!/n"); printf("Test failed/n"); exit(1); } // 1st: time of buffer allocation toc(&timer, "buffer allocation"); // Write our data set into device buffers // int err; err = clEnqueueWriteBuffer(commands, seqA_buffer, CL_TRUE, 0, sizeof(args->seqA)*num_jobs, seqA_batch, 0, NULL, NULL); err |= clEnqueueWriteBuffer(commands, seqB_buffer, CL_TRUE, 0, sizeof(args->seqB)*num_jobs, seqB_batch, 0, NULL, NULL); if (err != CL_SUCCESS) { printf("Error: Failed to write to device memory!/n"); printf("Test failed/n"); exit(1); } // 2nd: time of pageable-pinned memory copy toc(&timer, "memory copy"); // Set the arguments to our compute kernel // err = clSetKernelArg(kernel, 0, sizeof(cl_mem), &seqA_buffer); err |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &seqB_buffer); err |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &alignedA_buffer); err |= clSetKernelArg(kernel, 3, sizeof(cl_mem), &alignedB_buffer); err |= clSetKernelArg(kernel, 4, sizeof(int), &num_jobs); if (err != CL_SUCCESS) { printf("Error: Failed to set kernel arguments! %d/n", err); printf("Test failed/n"); exit(1); } // 3rd: time of setting arguments toc(&timer, "set arguments"); // Execute the kernel over the entire range of our 1d input data set // using the maximum number of work group items for this device //#ifdef C_KERNEL err = clEnqueueTask(commands, kernel, 0, NULL, NULL);#else printf("Error: OpenCL kernel is not currently supported!/n"); exit(1);#endif if (err) { printf("Error: Failed to execute kernel! %d/n", err); printf("Test failed/n"); exit(1); } // 4th: time of kernel execution clFinish(commands); toc(&timer, "kernel execution"); // Read back the results from the device to verify the output // err = clEnqueueReadBuffer( commands, alignedA_buffer, CL_TRUE, 0, sizeof(args->alignedA)*num_jobs, alignedA_batch, 0, NULL, NULL ); err |= clEnqueueReadBuffer( commands, alignedB_buffer, CL_TRUE, 0, sizeof(args->alignedB)*num_jobs, alignedB_batch, 0, NULL, NULL ); if (err != CL_SUCCESS) { printf("Error: Failed to read output array! %d/n", err); printf("Test failed/n"); exit(1); } // 5th: time of data retrieving (PCIe + memcpy)//.........这里部分代码省略.........
开发者ID:peterpengwei,项目名称:HDLRevisit,代码行数:101,
示例9: mainint main (int argc, char** argv){ int i; int iterations = 100; // prepare grids // declare_grids --> float * u_0_0_out; float * u_0_0; float * ux_1_0; float * uy_2_0; float * uz_3_0; float * u_0_0_out_cpu; float * u_0_0_cpu; float * ux_1_0_cpu; float * uy_2_0_cpu; float * uz_3_0_cpu; if ((argc<4)) { printf("Wrong number of parameters. Syntax:/n%s <x_max> <y_max> <z_max> <# of iterations>/n", argv[0]); exit(-1); } int x_max = atoi(argv[1]); int y_max = atoi(argv[2]); int z_max = atoi(argv[3]); if(argc==5) iterations = atoi(argv[4]); // <-- // allocate_grids --> u_0_0=((float * )malloc((((x_max*y_max)*z_max)*sizeof (float)))); ux_1_0=((float * )malloc(((((x_max+2)*y_max)*z_max)*sizeof (float)))); uy_2_0=((float * )malloc((((x_max*(y_max+2))*z_max)*sizeof (float)))); uz_3_0=((float * )malloc((((x_max*y_max)*(z_max+2))*sizeof (float)))); u_0_0_cpu=((float * )malloc((((x_max*y_max)*z_max)*sizeof (float)))); ux_1_0_cpu=((float * )malloc(((((x_max+2)*y_max)*z_max)*sizeof (float)))); uy_2_0_cpu=((float * )malloc((((x_max*(y_max+2))*z_max)*sizeof (float)))); uz_3_0_cpu=((float * )malloc((((x_max*y_max)*(z_max+2))*sizeof (float)))); // <-- // initialize // initialize_grids --> initialize(u_0_0, ux_1_0, uy_2_0, uz_3_0, 0.1, 0.2, 0.30000000000000004, x_max, y_max, z_max); initialize(u_0_0_cpu, ux_1_0_cpu, uy_2_0_cpu, uz_3_0_cpu, 0.1, 0.2, 0.30000000000000004, x_max, y_max, z_max); // <-- long nFlopsPerStencil = 8; long nGridPointsCount = iterations * ((x_max*y_max)*z_max); long nBytesTransferred = iterations * (((((((x_max+2)*y_max)*z_max)*sizeof (float))+(((x_max*(y_max+2))*z_max)*sizeof (float)))+(((x_max*y_max)*(z_max+2))*sizeof (float)))+(((x_max*y_max)*z_max)*sizeof (float))); /* *************************** PGI GPU-acc benchmark ********************* */ // warm up { // compute_stencil --> divergence(( & u_0_0_out), u_0_0, ux_1_0, uy_2_0, uz_3_0, 0.4, 0.5, 0.6, x_max, y_max, z_max,iterations); // <-- } // run the benchmark tic (); { // compute_stencil --> divergence(( & u_0_0_out), u_0_0, ux_1_0, uy_2_0, uz_3_0, 0.7, 0.7999999999999999, 0.8999999999999999, x_max, y_max, z_max,iterations); // <-- } toc (nFlopsPerStencil, nGridPointsCount, nBytesTransferred); /* *************************** ******************** ********************* */ /* *************************** Naive CPU Comparison ********************* */ // warm up cpu comparison { // compute_stencil --> divergence(( & u_0_0_out_cpu), u_0_0_cpu, ux_1_0_cpu, uy_2_0_cpu, uz_3_0_cpu, 0.4, 0.5, 0.6, x_max, y_max, z_max,iterations); // <-- } // run the benchmark tic (); { // compute_stencil --> divergence_cpu(( & u_0_0_out_cpu), u_0_0_cpu, ux_1_0_cpu, uy_2_0_cpu, uz_3_0_cpu, 0.7, 0.7999999999999999, 0.8999999999999999, x_max, y_max, z_max,iterations); // <-- } toc (nFlopsPerStencil, nGridPointsCount, nBytesTransferred); // checking "correctness" (assuming cpu version is correct) int error_count=0; int halo = 0; int x,y,z; for(y=0;y<x_max;y++) { for(x=0;x<x_max;x++) { for(z=0;z<y_max;z++) {//.........这里部分代码省略.........
开发者ID:rietmann,项目名称:pgi_accelerator_testing,代码行数:101,
示例10: main//.........这里部分代码省略......... args.element=element; args.iter=iter; /* * Find a memory region that supports kernel arguments. */ hsa_region_t kernarg_region; kernarg_region.handle=(uint64_t)-1; hsa_agent_iterate_regions(agent, get_kernarg_memory_region, &kernarg_region); err = (kernarg_region.handle == (uint64_t)-1) ? HSA_STATUS_ERROR : HSA_STATUS_SUCCESS; check(Finding a kernarg memory region, err); void* kernarg_address = NULL; /* * Allocate the kernel argument buffer from the correct region. */ err = hsa_memory_allocate(kernarg_region, kernarg_segment_size, &kernarg_address); check(Allocating kernel argument memory buffer, err); memcpy(kernarg_address, &args, sizeof(args)); /* * Obtain the current queue write index. */ uint64_t index = hsa_queue_load_write_index_relaxed(queue); /* * Write the aql packet at the calculated queue index address. */ const uint32_t queueMask = queue->size - 1; hsa_kernel_dispatch_packet_t* dispatch_packet = &(((hsa_kernel_dispatch_packet_t*)(queue->base_address))[index&queueMask]); dispatch_packet->header |= HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_ACQUIRE_FENCE_SCOPE; dispatch_packet->header |= HSA_FENCE_SCOPE_SYSTEM << HSA_PACKET_HEADER_RELEASE_FENCE_SCOPE; dispatch_packet->setup |= 1 << HSA_KERNEL_DISPATCH_PACKET_SETUP_DIMENSIONS; dispatch_packet->workgroup_size_x = (uint16_t)LOCAL_SIZE; dispatch_packet->workgroup_size_y = (uint16_t)1; dispatch_packet->workgroup_size_z = (uint16_t)1; dispatch_packet->grid_size_x = (uint32_t) (GLOBAL_SIZE); dispatch_packet->grid_size_y = 1; dispatch_packet->grid_size_z = 1; dispatch_packet->completion_signal = signal; dispatch_packet->kernel_object = kernel_object; dispatch_packet->kernarg_address = (void*) kernarg_address; dispatch_packet->private_segment_size = private_segment_size; dispatch_packet->group_segment_size = group_segment_size; __atomic_store_n((uint8_t*)(&dispatch_packet->header), (uint8_t)HSA_PACKET_TYPE_KERNEL_DISPATCH, __ATOMIC_RELEASE); /* * Increment the write index and ring the doorbell to dispatch the kernel. */ tic(&timer_1); hsa_queue_store_write_index_relaxed(queue, index+1); hsa_signal_store_relaxed(queue->doorbell_signal, index); check(Dispatching the kernel, err); /* * Wait on the dispatch completion signal until the kernel is finished. */ hsa_signal_value_t value = hsa_signal_wait_acquire(signal, HSA_SIGNAL_CONDITION_LT, 1, UINT64_MAX, HSA_WAIT_STATE_BLOCKED); toc("Execution Period", &timer_1, &timer_2); /* * Validate the data in the output buffer. */ int temp = 0; for(i=0;i<element;i++) { if(temp<in[i]) temp = in[i]; } if(temp==out[GLOBAL_SIZE]) printf("PASS /n"); else printf("FAIL out=%d in=%d /n",out[GLOBAL_SIZE],temp); /* * Cleanup all allocated resources. */ err=hsa_signal_destroy(signal); check(Destroying the signal, err); err=hsa_executable_destroy(executable); check(Destroying the executable, err); err=hsa_code_object_destroy(code_object); check(Destroying the code object, err); err=hsa_queue_destroy(queue); check(Destroying the queue, err); err=hsa_shut_down(); check(Shutting down the runtime, err); free(in); free(out);//printf("kernarg_segment_size:%d group_segment_size:%d private_segment_size:%d",kernarg_segment_size,group_segment_size,private_segment_size); return 0;}
开发者ID:weichen8157,项目名称:HSA_microbench,代码行数:101,
示例11: mainint main(int argc, char **argv){ u16 (*bayer)[WAMI_DEBAYER_IMG_NUM_COLS] = NULL; rgb_pixel (*debayer)[WAMI_DEBAYER_IMG_NUM_COLS-2*PAD] = NULL; char *input_directory = NULL;#ifdef ENABLE_CORRECTNESS_CHECKING rgb_pixel (*gold_debayer)[WAMI_DEBAYER_IMG_NUM_COLS-2*PAD] = NULL;#endif const size_t num_bayer_pixels = WAMI_DEBAYER_IMG_NUM_ROWS * WAMI_DEBAYER_IMG_NUM_COLS; const size_t num_debayer_pixels = (WAMI_DEBAYER_IMG_NUM_ROWS-2*PAD) * (WAMI_DEBAYER_IMG_NUM_COLS-2*PAD); if (argc != 2) { fprintf(stderr, "%s <directory-containing-input-files>/n", argv[0]); exit(EXIT_FAILURE); } input_directory = argv[1]; bayer = XMALLOC(sizeof(u16) * num_bayer_pixels); debayer = XMALLOC(sizeof(rgb_pixel) * num_debayer_pixels);#ifdef ENABLE_CORRECTNESS_CHECKING gold_debayer = XMALLOC(sizeof(rgb_pixel) * num_debayer_pixels);#endif read_image_file( (char *) bayer, input_filename, input_directory, sizeof(u16) * num_bayer_pixels); memset(debayer, 0, sizeof(u16) * num_debayer_pixels); printf("WAMI kernel 1 parameters:/n/n"); printf("Input image width = %u pixels/n", WAMI_DEBAYER_IMG_NUM_COLS); printf("Input image height = %u pixels/n", WAMI_DEBAYER_IMG_NUM_ROWS); printf("Output image width = %u pixels/n", WAMI_DEBAYER_IMG_NUM_COLS-2*PAD); printf("Output image height = %u pixels/n", WAMI_DEBAYER_IMG_NUM_ROWS-2*PAD); printf("/nStarting WAMI kernel 1 (debayer)./n"); tic(); accept_roi_begin(); wami_debayer( debayer, bayer); accept_roi_end(); PRINT_STAT_DOUBLE("CPU time using func toc - ", toc());#ifdef ENABLE_CORRECTNESS_CHECKING read_image_file( (char *) gold_debayer, golden_output_filename, input_directory, sizeof(rgb_pixel) * num_debayer_pixels); /* * An exact match is expected for the debayer kernel, so we check * each pixel individually and report either the first failure or * a success message. */ { /* // original error metric int r, c, success = 1; for (r = 0; success && r < WAMI_DEBAYER_IMG_NUM_ROWS - 2*PAD; ++r) { for (c = 0; c < WAMI_DEBAYER_IMG_NUM_ROWS - 2*PAD; ++c) { if (ENDORSE(debayer[r][c].r != gold_debayer[r][c].r)) { printf("Validation error: red pixel mismatch at row=%d, col=%d : " "test value = %u, golden value = %u/n/n", r, c, debayer[r][c].r, gold_debayer[r][c].r); success = 0; break; } if (ENDORSE(debayer[r][c].g != gold_debayer[r][c].g)) { printf("Validation error: green pixel mismatch at row=%d, col=%d : " "test value = %u, golden value = %u/n/n", r, c, debayer[r][c].g, gold_debayer[r][c].g); success = 0; break; } if (ENDORSE(debayer[r][c].b != gold_debayer[r][c].b)) { printf("Validation error: blue pixel mismatch at row=%d, col=%d : " "test value = %u, golden value = %u/n/n", r, c, debayer[r][c].b, gold_debayer[r][c].b); success = 0; break; } } } if (success)//.........这里部分代码省略.........
开发者ID:hoangt,项目名称:accept-apps,代码行数:101,
示例12: M_backendPreconditionerBlockMS<space_type>::PreconditionerBlockMS(space_ptrtype Xh, // (u)x(p) ModelProperties model, // model std::string const& p, // prefix sparse_matrix_ptrtype AA, value_type relax ) // The matrix : M_backend(backend()), // the backend associated to the PC M_Xh( Xh ), M_Vh( Xh->template functionSpace<0>() ), // Potential M_Qh( Xh->template functionSpace<1>() ), // Lagrange M_Vh_indices( M_Vh->nLocalDofWithGhost() ), M_Qh_indices( M_Qh->nLocalDofWithGhost() ), M_uin( M_backend->newVector( M_Vh ) ), M_uout( M_backend->newVector( M_Vh ) ), M_pin( M_backend->newVector( M_Qh ) ), M_pout( M_backend->newVector( M_Qh ) ), U( M_Xh, "U" ), M_mass(M_backend->newMatrix(M_Vh,M_Vh)), M_L(M_backend->newMatrix(M_Qh,M_Qh)), M_er( 1. ), M_model( model ), M_prefix( p ), M_prefix_11( p+".11" ), M_prefix_22( p+".22" ), u(M_Vh, "u"), ozz(M_Vh, "ozz"), zoz(M_Vh, "zoz"), zzo(M_Vh, "zzo"), M_ozz(M_backend->newVector( M_Vh )), M_zoz(M_backend->newVector( M_Vh )), M_zzo(M_backend->newVector( M_Vh )), X(M_Qh, "X"), Y(M_Qh, "Y"), Z(M_Qh, "Z"), M_X(M_backend->newVector( M_Qh )), M_Y(M_backend->newVector( M_Qh )), M_Z(M_backend->newVector( M_Qh )), phi(M_Qh, "phi"), M_relax(relax){ tic(); LOG(INFO) << "[PreconditionerBlockMS] setup starts"; this->setMatrix( AA ); this->setName(M_prefix); /* Indices are need to extract sub matrix */ std::iota( M_Vh_indices.begin(), M_Vh_indices.end(), 0 ); std::iota( M_Qh_indices.begin(), M_Qh_indices.end(), M_Vh->nLocalDofWithGhost() ); M_11 = AA->createSubMatrix( M_Vh_indices, M_Vh_indices, true, true); /* Boundary conditions */ BoundaryConditions M_bc = M_model.boundaryConditions(); map_vector_field<FEELPP_DIM,1,2> m_dirichlet_u { M_bc.getVectorFields<FEELPP_DIM> ( "u", "Dirichlet" ) }; map_scalar_field<2> m_dirichlet_p { M_bc.getScalarFields<2> ( "phi", "Dirichlet" ) }; /* Compute the mass matrix (needed in first block, constant) */ auto f2A = form2(_test=M_Vh, _trial=M_Vh, _matrix=M_mass); auto f1A = form1(_test=M_Vh); f2A = integrate(_range=elements(M_Vh->mesh()), _expr=inner(idt(u),id(u))); // M for(auto const & it : m_dirichlet_u ) { LOG(INFO) << "Applying " << it.second << " on " << it.first << " for "<<M_prefix_11<<"/n"; f2A += on(_range=markedfaces(M_Vh->mesh(),it.first), _expr=it.second,_rhs=f1A, _element=u, _type="elimination_symmetric"); } /* Compute the L (= er * grad grad) matrix (the second block) */ auto f2L = form2(_test=M_Qh,_trial=M_Qh, _matrix=M_L);#if 0 //If you want to manage the relative permittivity materials per material, //here is the entry to deal with. for(auto it : M_model.materials() ) { f2L += integrate(_range=markedelements(M_Qh->mesh(),marker(it)), _expr=M_er*inner(gradt(phi), grad(phi))); }#else f2L += integrate(_range=elements(M_Qh->mesh()), _expr=M_er*inner(gradt(phi), grad(phi)));#endif auto f1LQ = form1(_test=M_Qh); for(auto const & it : m_dirichlet_p) { LOG(INFO) << "Applying " << it.second << " on " << it.first << " for "<<M_prefix_22<<"/n"; f2L += on(_range=markedfaces(M_Qh->mesh(),it.first),_element=phi, _expr=it.second, _rhs=f1LQ, _type="elimination_symmetric"); } toc( "[PreconditionerBlockMS] setup done ", FLAGS_v > 0 );}
开发者ID:MarieHouillon,项目名称:feelpp,代码行数:87,
示例13: mainint main(int argc, char *argv[]) { if (argc < 4) { fprintf(stderr, "[ERROR] Invalid arguments provided./n/n"); fprintf(stderr, "Usage: %s [NUMBER OF THREADS] [WORDS] [INPUT FILE]/n/n", argv[0]); exit(0); } /* Timing */ STATS_INIT("kernel", "pthread_porter_stemming"); PRINT_STAT_STRING("abrv", "pthread_stemmer"); NTHREADS = atoi(argv[1]); int WORDS = atoi(argv[2]); PRINT_STAT_INT("threads", NTHREADS); FILE *f = fopen(argv[3], "r"); if (f == 0) { fprintf(stderr, "File %s not found/n", argv[1]); exit(1); } stem_list = (struct stemmer **)sirius_malloc(WORDS * sizeof(struct stemmer *)); int words = load_data(WORDS, stem_list, f); fclose(f); if (words < 0) goto out; PRINT_STAT_INT("words", words); tic(); int start, tids[NTHREADS]; pthread_t threads[NTHREADS]; pthread_attr_t attr; iterations = words / NTHREADS; sirius_pthread_attr_init(&attr); sirius_pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for (int i = 0; i < NTHREADS; i++) { tids[i] = i; sirius_pthread_create(&threads[i], &attr, stem_thread, (void *)&tids[i]); } for (int i = 0; i < NTHREADS; i++) { sirius_pthread_join(threads[i], NULL); } PRINT_STAT_DOUBLE("pthread_stemmer", toc()); STATS_END();#ifdef TESTING f = fopen("../input/stem_porter.pthread", "w"); for (int i = 0; i < words; ++i) fprintf(f, "%s/n", stem_list[i]->b); fclose(f);#endifout: sirius_free(s); // free up allocated data for (int i = 0; i < words; i++) { sirius_free(stem_list[i]->b); sirius_free(stem_list[i]); } return 0;}
开发者ID:123de7,项目名称:lucida,代码行数:69,
示例14: mainint main(void) { std::string filePath = "CNN-DocTermCountMatrix.txt"; Matrix& X_Ori = loadMatrix(filePath); int NSample = min(20, X_Ori.getRowDimension()); Matrix& X = X_Ori.getSubMatrix(0, NSample - 1, 0, X_Ori.getColumnDimension() - 1); // disp(X.getSubMatrix(0, 10, 0, 100)); println(sprintf("%d samples loaded", X.getRowDimension())); GraphOptions& options = *new GraphOptions(); options.graphType = "nn"; std::string type = options.graphType; double NN = options.graphParam; fprintf("Graph type: %s with NN: %d/n", type.c_str(), (int)NN); // Parameter setting for text data options.kernelType = "cosine"; options.graphDistanceFunction = "cosine"; // Parameter setting for image data /*options.kernelType = "rbf"; options.graphDistanceFunction = "euclidean";*/ options.graphNormalize = true; options.graphWeightType = "heat"; bool show = true && !false; // Test adjacency function - pass tic(); std::string DISTANCEFUNCTION = options.graphDistanceFunction; Matrix& A = adjacency(X, type, NN, DISTANCEFUNCTION); fprintf("Elapsed time: %.2f seconds./n", toc()); std::string adjacencyFilePath = "adjacency.txt"; saveMatrix(adjacencyFilePath, A); if (show) disp(A.getSubMatrix(0, 4, 0, 4)); // Test laplacian function - pass tic(); Matrix& L = laplacian(X, type, options); fprintf("Elapsed time: %.2f seconds./n", toc()); std::string LaplacianFilePath = "Laplacian.txt"; saveMatrix(LaplacianFilePath, L); if (show) disp(L.getSubMatrix(0, 4, 0, 4)); // Test local learning regularization - pass NN = options.graphParam; std::string DISTFUNC = options.graphDistanceFunction; std::string KernelType = options.kernelType; double KernelParam = options.kernelParam; double lambda = 0.001; tic(); Matrix& LLR_text = calcLLR(X, NN, DISTFUNC, KernelType, KernelParam, lambda); fprintf("Elapsed time: %.2f seconds./n", toc()); std::string LLRFilePath = "localLearningRegularization.txt"; saveMatrix(LLRFilePath, LLR_text); if (show) display(LLR_text.getSubMatrix(0, 4, 0, 4)); return EXIT_SUCCESS;}
开发者ID:Maple-Wang,项目名称:libLAML,代码行数:63,
示例15: main//.........这里部分代码省略......... if(-1 == SocketFD) { perror("can not create socket"); exit(EXIT_FAILURE); } memset(&stSockAddr, 0, sizeof(stSockAddr)); stSockAddr.sin_family = AF_INET; stSockAddr.sin_port = htons(7000); stSockAddr.sin_addr.s_addr = htonl(INADDR_ANY); if(-1 == bind(SocketFD,(struct sockaddr *)&stSockAddr, sizeof(stSockAddr))) { perror("error bind failed"); close(SocketFD); exit(EXIT_FAILURE); } if(-1 == listen(SocketFD, 10)) { perror("error listen failed"); close(SocketFD); exit(EXIT_FAILURE); } int taskNum = -1; // polling setting timespec deadline; deadline.tv_sec = 0; deadline.tv_nsec = 100; // Get the start time timespec timer = tic( ); timespec socListenTime = diff(timer, timer); timespec socSendTime = diff(timer, timer); timespec socRecvTime = diff(timer, timer); timespec exeTime = diff(timer, timer); bool broadcastFlag = false; int packet_buf[PACKET_SIZE]; int time_buf[TIME_BUF_SIZE]; while (true) { //printf("/n************* Got a new task! *************/n"); timer = tic(); int ConnectFD = accept(SocketFD, NULL, NULL); if (!broadcastFlag) { broadcastFlag = true; timer = tic(); } // For profiling only //struct timeval tv; //gettimeofday(&tv, NULL); //double time_in_mill = (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000 ; // convert tv_sec & tv_usec to millisecond //printf("Receive time (ms): %lf/n", time_in_mill); accTime (&socListenTime, &timer); if(0 > ConnectFD) { perror("error accept failed"); close(SocketFD); exit(EXIT_FAILURE);
开发者ID:ytchen0323,项目名称:cloud-scale-bwamem,代码行数:67,
示例16: mainint main(int argc, char** argv){ cl_context context = 0; cl_command_queue commandQueue = 0; cl_program program = 0; cl_device_id device = 0; cl_kernel kernel = 0; cl_int status; char filename[] = "../../kernels/VectorUpdate_vec_kernel.cl"; char filename2[] = "../../common/types_kernel.h"; int profiling_info = 0; cl_event myEvent, myEvent2; if( argc != 4 ) { printf("Usage: %s vector_file1 vector_file2 alpha/n", argv[0]); return EXIT_FAILURE; } char xfilename[50]; char yfilename[50]; real alpha; strcpy(xfilename, argv[1]); strcpy(yfilename, argv[2]); alpha = strtod(argv[3], NULL);#ifdef PROFILE cl_ulong startTime, endTime, startTime2, endTime2; cl_ulong kernelExecTimeNs, readFromGpuTime; profiling_info = 1;#endif /* READING DATA FROM FILE */ real *x; real *y; real *ref_x; int N, M, N4; std::ifstream xfile; xfile.open (xfilename, std::ios::in); if (!xfile.is_open()) { printf("Error: cannot open file/n"); return EXIT_FAILURE; } xfile >> N; // it must be N%4 == 0 N4 = ((N & (4-1)) == 0) ? N : N+(4-(N&3)); HANDLE_ALLOC_ERROR(x = (real*)malloc(N4*sizeof(real))); for( int i = 0; i < N; i++) xfile >> x[i]; for(int i = N; i < N4; ++i) x[i] = 0; xfile.close(); // needed for checking result HANDLE_ALLOC_ERROR(ref_x = (real*)malloc(N*sizeof(real))); memcpy(ref_x, x, N*sizeof(real)); std::ifstream yfile; yfile.open (yfilename, std::ios::in); if (!yfile.is_open()) { printf("Error: cannot open file/n"); return EXIT_FAILURE; } yfile >> M; assert(N==M); HANDLE_ALLOC_ERROR(y = (real*)malloc(N4*sizeof(real))); for( int i = 0; i < N; i++) yfile >> y[i]; for(int i = N; i < N4; ++i) y[i] = 0; yfile.close(); int Ndev4 = N4/4; TIME start = tic(); TIME init = tic(); //.........这里部分代码省略.........
开发者ID:Tourmaline,项目名称:PPSC,代码行数:101,
示例17: tic//Main tracking Algorithmvoid AnalysisModule::larvaFind(uchar * img, int imWidth, int imHeight, int frameInd){ input = cv::Mat(imHeight,imWidth,CV_8UC1,NULL); input.data = img; if(output.rows != imHeight | output.cols != imWidth) output.create(imHeight,imWidth,CV_8UC1); int nextInd = (index+1)%sampleInd.size(); //for Profiling tic(); sampleInd[nextInd] = frameInd; sampleTime[nextInd] = frameInd * frameIntervalMS; //On first image, automatically determine threshold level using the Otsu method // Minimizes within group variance of thresholded classes. Should land on the best boundary between backlight and larva if(index == -1) threshold = otsuThreshold(img,imWidth*imHeight); //Can speed this up by applying to a roi bounding box a bit larger than the previous one //Simple inverted binary threshold of the image cv::threshold(input,output,threshold,255,CV_THRESH_BINARY_INV); profile[0] = toctic(); //Detect Contours in the binary image cv::findContours(output,contours,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_NONE); profile[1] = toctic(); //No contours detected if (contours.size() == 0) { return; } //find contour with largest perimeter length double maxLen = 0; int maxInd = -1; double cLen; for(int i=0; i<contours.size(); i++){ cLen = cv::arcLength(cv::Mat(contours[i]), false); if(cLen >= maxLen){ maxLen = cLen; maxInd = i; }; } //Check to make sure that the perimeter is a larva by simple size analysis //(larva should have a certain perimeter length at 8.1um/pixel) cLarva[nextInd] = contours[maxInd]; //calculate bounding box bBox[nextInd] = cv::boundingRect(cv::Mat(cLarva[nextInd])); profile[2] = toctic(); //Calculate fourier coefficients fourierDecompose(cLarva[nextInd],nFourier,fourier[nextInd]); centroid[nextInd] = cv::Point2f(fourier[nextInd][0][AX],fourier[nextInd][0][AY]); profile[3] = toctic(); //Reconstruct the estimated boundary fourierReconstruct(fourier[nextInd],cFit,fitRes); profile[4] = toctic(); //Calculate Curvature perimeterCurvature(cFit,curve,fitRes/8); profile[5] = toctic(); //Find head and tail based on curvature minimums (small angle = sharp region) findHeadTail(cFit,curve,headTail); head[nextInd] = headTail[0]; tail[nextInd] = headTail[1]; profile[6] = toctic(); //Calculate Skeleton skeletonCalc(cFit,skeleton,headTail,length[nextInd],neck[nextInd]); profile[7] = toctic(); //Calculate bearing and head angle to bearing bodyAngles(tailBearingAngle[nextInd], headToBodyAngle[nextInd], head[nextInd], neck[nextInd], tail[nextInd]); profile[8] = toctic(); //Capture stage position stagePos[nextInd] = cv::Point(gui->stageThread->xpos,gui->stageThread->ypos); //Keep track of entire history with a sample every 30 frames if((nextInd % 30) == 0){ fullTrack[(fullTrackInd+1)%fullTrack.size()].x = stagePos[nextInd].x/gui->stageThread->tickPerMM_X+centroid[nextInd].x*gui->camThread->umPerPixel/1000.0; fullTrack[(fullTrackInd+1)%fullTrack.size()].y = stagePos[nextInd].y/gui->stageThread->tickPerMM_Y+centroid[nextInd].y*gui->camThread->umPerPixel/1000.0; fullTrackStim[(fullTrackInd+1)%fullTrack.size()] = binStimMax; binStimMax = 0; //updated from stimThread fullTrackInd++; } //Calculate Velocities of head and tail calcVelocities(nextInd); //Spew out profiling info //for(int i=0; i<9; i++) qDebug("%d: %.4fms",i,profile[i]*1000); //qDebug("/n"); index++;};
开发者ID:LabLouis,项目名称:eLife_2015,代码行数:92,
示例18: main//.........这里部分代码省略......... printf("Done!/n"); if( debug && job == 0 ) { puts("a"); check_a(word); puts("b"); check_b(word); puts("pri"); check_pri(word); } //---------------------- // run forward algorithm //---------------------- //--------------------------- // GPU Version //--------------------------- run_opencl_fo(word); //--------------------------- // CPU Version //--------------------------- puts("/n=>CPU"); struct timeval cpu_timer; int N = word->nstates; int T = word->len; float *B = word->b; float *A = word->a; float *prior = word->pri; double tmp, alpha_sum; double log_likelihood; float *alpha; // NxT alpha = (float*)malloc(sizeof(float)*N*T); float *A_t; // NxN A_t = (float*)malloc(sizeof(float)*N*N); log_likelihood = 0.0; // start timing tic(&cpu_timer); transpose(A, A_t, N, T); for(j=0;j<T;++j) { alpha_sum = 0.0; if(j==0){ // initialize for(i=0;i<N;++i){ alpha[i*T + 0] = B[i*T + 0] * prior[i]; alpha_sum += alpha[i*T + 0]; } }else{ // move forward for(i=0;i<N;++i) { // go through each state tmp = 0.0; for(k=0;k<N;++k){ tmp += A_t[i*N + k] * alpha[k*T + j-1]; } alpha[i*T + j] = (float)tmp * B[i*T + j]; alpha_sum += alpha[i*T + j]; } } // scaling for(i=0;i<N;++i){ alpha[i*T + j] /= alpha_sum; } log_likelihood += log(alpha_sum); } // end timing toc(&cpu_timer); printf("log_likelihood = %lf/n", log_likelihood); // free memory free_hmm(word); free(A_t); free(alpha); return 0;}
开发者ID:SibghatullahSheikh,项目名称:HMM-SpeechRecogntion-GPU,代码行数:101,
示例19: mainint main(int argc, char* argv[]){#if 0 Stack *stack = Read_Stack("../data/binimg.tif"); Set_Matlab_Path("/Applications/MATLAB74/bin/matlab"); Stack *dist = Stack_Bwdist(stack); Stack* seeds = Stack_Local_Max(dist, NULL, STACK_LOCMAX_ALTER1); Stack *out = Scale_Double_Stack((double *) dist->array, stack->width, stack->height, stack->depth, GREY); Translate_Stack(out, COLOR, 1); Rgb_Color color; Set_Color(&color, 255, 0, 0); Stack_Label_Bwc(out, seeds, color); Print_Stack_Info(dist); Write_Stack("../data/test.tif", out);#endif #if 0 Stack *stack = Read_Stack("../data/benchmark/sphere_bw.tif"); //Stack *stack = Read_Stack("../data/sphere_data.tif"); //Stack_Not(stack, stack); int i; /* uint8 *array = stack->array + 512 * 600; for (i = 1; i < 512; i++) { array[i] = 1; } */ //stack->depth = 50; /* long int *label = (long int *) malloc(sizeof(long int) * Stack_Voxel_Number(stack)); */ tic(); Stack *out = Stack_Bwdist_L_U16(stack, NULL, 0); uint16 *out_array = (uint16 *) out->array; printf("%llu/n", toc()); //int *hist = Stack_Hist(out); //Print_Int_Histogram(hist); Stack *out2 = Stack_Bwdist_L(stack, NULL, NULL); float *out2_array = (float *) out2->array; int n = Stack_Voxel_Number(out); int t = 0; int x, y, z; for (i = 0; i < n; i++) { uint16 d2 = (uint16) out2_array[i]; if (out_array[i] != d2){ int area = stack->width * stack->height; STACK_UTIL_COORD(i, stack->width, area, x, y, z); printf("(%d %d %d)", x, y, z); printf("%d %d %d/n", out_array[i], d2, stack->array[i]); t++; } } printf("%d error/n", t);# if 0 //Translate_Stack(out, GREY, 1); float *out_array = (float *) out->array; int i; int n = Stack_Voxel_Number(out); /* for (i = 0; i < n; i++) { out_array[i] = sqrt(out_array[i]); } Stack *out2 = Scale_Float_Stack((float *)out->array, out->width, out->height, out->depth, GREY); */ Stack *out2 = Make_Stack(GREY, out->width, out->height, out->depth); for (i = 0; i < n; i++) { out2->array[i] = (uint8) round(sqrt(out_array[i])); } Write_Stack("../data/test.tif", out2);# endif Write_Stack("../data/test.tif", out); Kill_Stack(out); Kill_Stack(out2);#endif#if 1//.........这里部分代码省略.........
开发者ID:janelia-flyem,项目名称:NeuTu,代码行数:101,
示例20: test_7int test_7(){ idxint n = 15; idxint m = 29; pfloat feas_Gx[120] = {9999,-9999,9999,-9999,9999,-9999,9999,-9999,9999,-9999,-3.5008,3.5008,-0.4504,0.4504,-0.8764999999999999,0.8764999999999999,-0.1088,0.1088,1,1,-1,-8.4095,8.4095,-1.0107,1.0107,-1.686,1.686,-0.3525,0.3525,1,1,-1,-15.1987,15.1987,-2.0203,2.0203,-2.3932,2.3932,-0.6233,0.6233,1,1,-1,-22.5405,22.5405,-3.1862,3.1862,-2.8749,2.8749,-0.7923,0.7923,1,1,-1,-29.2639,29.2639,-4.3096,4.3096,-3.0189,3.0189,-0.8116,0.8116,1,1,-1,3.5008,-3.5008,0.4504,-0.4504,0.8764999999999999,-0.8764999999999999,0.1088,-0.1088,1,1,-1,8.4095,-8.4095,1.0107,-1.0107,1.686,-1.686,0.3525,-0.3525,1,1,-1,15.1987,-15.1987,2.0203,-2.0203,2.3932,-2.3932,0.6233,-0.6233,1,1,-1,22.5405,-22.5405,3.1862,-3.1862,2.8749,-2.8749,0.7923,-0.7923,1,1,-1,29.2639,-29.2639,4.3096,-4.3096,3.0189,-3.0189,0.8116,-0.8116,1,1,-1}; idxint feas_Gp[16] = {0,2,4,6,8,10,21,32,43,54,65,76,87,98,109,120}; idxint feas_Gi[120] = {8,9,10,11,12,13,14,15,16,17,0,1,2,3,4,5,6,7,8,18,19,0,1,2,3,4,5,6,7,10,18,20,0,1,2,3,4,5,6,7,12,18,21,0,1,2,3,4,5,6,7,14,18,22,0,1,2,3,4,5,6,7,16,18,23,0,1,2,3,4,5,6,7,9,18,24,0,1,2,3,4,5,6,7,11,18,25,0,1,2,3,4,5,6,7,13,18,26,0,1,2,3,4,5,6,7,15,18,27,0,1,2,3,4,5,6,7,17,18,28}; pfloat feas_c[15] = {0,0,0,0,0,0.127,0.9134,0.6324,0.0975,0.2785,0.873,0.0866,0.3676,0.9025,0.7215}; pfloat feas_h[29] = {-729.9349999999999,789.9349999999999,-71.015,131.015,-89.66,149.66,-1.165,61.165,9999,0,9999,0,9999,0,9999,0,9999,0,150,0,0,0,0,0,0,0,0,0,0}; idxint bool_idx[5] = {0,1,2,3,4}; /* Answer: */ pfloat x[15] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,32.383266,0.00,0.00,0.00, 0.00,0.00,0.00}; pfloat x2[15] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,86.798858, 0.000000,0.000000,0.000000}; idxint i, ret_code, pass; timer t; ecos_bb_pwork* prob = ECOS_BB_setup( n, m, 0, m, 0, NULL, 0, feas_Gx, feas_Gp, feas_Gi, NULL, NULL, NULL, feas_c, feas_h, NULL, 5, bool_idx, 0, NULL, NULL); prob->stgs->verbose = 0; tic(&t); ret_code = ECOS_BB_solve(prob); pfloat msRuntime = toc(&t); pass = 1; printf("Soln: "); for (i=5; i<n; ++i){ pass &= float_eqls(x[i] ,prob->x[i], prob->stgs->integer_tol ); printf("%f ", prob->x[i]); } printf("/nRuntime: %f/n", msRuntime); updateDataEntry_h(prob, 0, 789.935); updateDataEntry_h(prob, 1, -729.935); updateDataEntry_h(prob, 2, 131.015); updateDataEntry_h(prob, 3, -71.015); updateDataEntry_h(prob, 4, 149.66); updateDataEntry_h(prob, 5, -89.66); updateDataEntry_h(prob, 6, 61.165); updateDataEntry_h(prob, 7, -1.165); tic(&t); ret_code = ECOS_BB_solve(prob); msRuntime = toc(&t); printf("Soln2: "); for (i=5; i<n; ++i){ pass &= float_eqls(x2[i] ,prob->x[i], prob->stgs->integer_tol ); printf("%f ", prob->x[i]); } printf("/nRuntime: %f/n", msRuntime); ECOS_BB_cleanup(prob, 0); return pass;}
开发者ID:aeternocap,项目名称:ecos,代码行数:66,
示例21: Timer Timer() { tic(); TicksPerSeconds = clock::duration::period::den / clock::duration::period::num; }
开发者ID:hungptit,项目名称:utils,代码行数:5,
示例22: demo3/* Cholesky update/downdate */int demo3 (problem *Prob){ cs *A, *C, *W = NULL, *WW, *WT, *E = NULL, *W2 ; int n, k, *Li, *Lp, *Wi, *Wp, p1, p2, *p = NULL, ok ; double *b, *x, *resid, *y = NULL, *Lx, *Wx, s, t, t1 ; css *S = NULL ; csn *N = NULL ; if (!Prob || !Prob->sym || Prob->A->n == 0) return (0) ; A = Prob->A ; C = Prob->C ; b = Prob->b ; x = Prob->x ; resid = Prob->resid; n = A->n ; if (!Prob->sym || n == 0) return (1) ; rhs (x, b, n) ; /* compute right-hand side */ printf ("/nchol then update/downdate ") ; print_order (1) ; y = cs_malloc (n, sizeof (double)) ; t = tic () ; S = cs_schol (1, C) ; /* symbolic Chol, amd(A+A') */ printf ("/nsymbolic chol time %8.2f/n", toc (t)) ; t = tic () ; N = cs_chol (C, S) ; /* numeric Cholesky */ printf ("numeric chol time %8.2f/n", toc (t)) ; if (!S || !N || !y) return (done3 (0, S, N, y, W, E, p)) ; t = tic () ; cs_ipvec (S->pinv, b, y, n) ; /* y = P*b */ cs_lsolve (N->L, y) ; /* y = L/y */ cs_ltsolve (N->L, y) ; /* y = L'/y */ cs_pvec (S->pinv, y, x, n) ; /* x = P'*y */ printf ("solve chol time %8.2f/n", toc (t)) ; printf ("original: ") ; print_resid (1, C, x, b, resid) ; /* print residual */ k = n/2 ; /* construct W */ W = cs_spalloc (n, 1, n, 1, 0) ; if (!W) return (done3 (0, S, N, y, W, E, p)) ; Lp = N->L->p ; Li = N->L->i ; Lx = N->L->x ; Wp = W->p ; Wi = W->i ; Wx = W->x ; Wp [0] = 0 ; p1 = Lp [k] ; Wp [1] = Lp [k+1] - p1 ; s = Lx [p1] ; srand (1) ; for ( ; p1 < Lp [k+1] ; p1++) { p2 = p1 - Lp [k] ; Wi [p2] = Li [p1] ; Wx [p2] = s * rand () / ((double) RAND_MAX) ; } t = tic () ; ok = cs_updown (N->L, +1, W, S->parent) ; /* update: L*L'+W*W' */ t1 = toc (t) ; printf ("update: time: %8.2f/n", t1) ; if (!ok) return (done3 (0, S, N, y, W, E, p)) ; t = tic () ; cs_ipvec (S->pinv, b, y, n) ; /* y = P*b */ cs_lsolve (N->L, y) ; /* y = L/y */ cs_ltsolve (N->L, y) ; /* y = L'/y */ cs_pvec (S->pinv, y, x, n) ; /* x = P'*y */ t = toc (t) ; p = cs_pinv (S->pinv, n) ; W2 = cs_permute (W, p, NULL, 1) ; /* E = C + (P'W)*(P'W)' */ WT = cs_transpose (W2,1) ; WW = cs_multiply (W2, WT) ; cs_spfree (WT) ; cs_spfree (W2) ; E = cs_add (C, WW, 1, 1) ; cs_spfree (WW) ; if (!E || !p) return (done3 (0, S, N, y, W, E, p)) ; printf ("update: time: %8.2f (incl solve) ", t1+t) ; print_resid (1, E, x, b, resid) ; /* print residual */ cs_nfree (N) ; /* clear N */ t = tic () ; N = cs_chol (E, S) ; /* numeric Cholesky */ if (!N) return (done3 (0, S, N, y, W, E, p)) ; cs_ipvec (S->pinv, b, y, n) ; /* y = P*b */ cs_lsolve (N->L, y) ; /* y = L/y */ cs_ltsolve (N->L, y) ; /* y = L'/y */ cs_pvec (S->pinv, y, x, n) ; /* x = P'*y */ t = toc (t) ; printf ("rechol: time: %8.2f (incl solve) ", t) ; print_resid (1, E, x, b, resid) ; /* print residual */ t = tic () ; ok = cs_updown (N->L, -1, W, S->parent) ; /* downdate: L*L'-W*W' */ t1 = toc (t) ; if (!ok) return (done3 (0, S, N, y, W, E, p)) ; printf ("downdate: time: %8.2f/n", t1) ; t = tic () ; cs_ipvec (S->pinv, b, y, n) ; /* y = P*b */ cs_lsolve (N->L, y) ; /* y = L/y */ cs_ltsolve (N->L, y) ; /* y = L'/y */ cs_pvec (S->pinv, y, x, n) ; /* x = P'*y */ t = toc (t) ; printf ("downdate: time: %8.2f (incl solve) ", t1+t) ; print_resid (1, C, x, b, resid) ; /* print residual */ return (done3 (1, S, N, y, W, E, p)) ;}
开发者ID:EmanueleCannizzaro,项目名称:suitesparse,代码行数:95,
示例23: M_typePreconditionerAS<space_type,coef_space_type>::PreconditionerAS( std::string t, space_ptrtype Xh, coef_space_ptrtype Mh, BoundaryConditions bcFlags, std::string const& p, sparse_matrix_ptrtype Pm, double k ) : M_type( AS ), M_Xh( Xh ), M_Vh(Xh->template functionSpace<0>() ), M_Qh(Xh->template functionSpace<1>() ), M_Mh( Mh ), M_Vh_indices( M_Vh->nLocalDofWithGhost() ), M_Qh_indices( M_Qh->nLocalDofWithGhost() ), M_Qh3_indices( Dim ), A(backend()->newVector(M_Vh)), B(backend()->newVector(M_Vh)), C(backend()->newVector(M_Vh)), M_r(backend()->newVector(M_Vh)), M_r_t(backend()->newVector(M_Vh)), M_uout(backend()->newVector(M_Vh)), M_diagPm(backend()->newVector(M_Vh)), //M_t(backend()->newVector(M_Vh)), U( M_Vh, "U" ), M_mu(M_Mh, "mu"), M_er(M_Mh, "er"), M_bcFlags( bcFlags ), M_prefix( p ), M_k(k), M_g(1.-k*k){ tic(); LOG(INFO) << "[PreconditionerAS] setup starts"; this->setMatrix( Pm ); // Needed only if worldComm > 1 // QH3 : Lagrange vectorial space type M_Qh3 = lag_v_space_type::New(Xh->mesh()); M_qh3_elt = M_Qh3->element(); M_qh_elt = M_Qh->element(); M_vh_elt = M_Vh->element(); // Block 11.1 M_s = backend()->newVector(M_Qh3); M_y = backend()->newVector(M_Qh3); // Block 11.2 M_z = backend()->newVector(M_Qh); M_t = backend()->newVector(M_Qh); // Create the interpolation and keep only the matrix auto pi_curl = I(_domainSpace=M_Qh3, _imageSpace=M_Vh); auto Igrad = Grad( _domainSpace=M_Qh, _imageSpace=M_Vh); M_P = pi_curl.matPtr(); M_C = Igrad.matPtr(); M_Pt = backend()->newMatrix(M_Qh3,M_Vh); M_Ct = backend()->newMatrix(M_Qh3,M_Vh); M_P->transpose(M_Pt,MATRIX_TRANSPOSE_UNASSEMBLED); M_C->transpose(M_Ct,MATRIX_TRANSPOSE_UNASSEMBLED); LOG(INFO) << "size of M_C = " << M_C->size1() << ", " << M_C->size2() << std::endl; LOG(INFO) << "size of M_P = " << M_P->size1() << ", " << M_P->size2() << std::endl; // Create vector of indices to create subvectors/matrices std::iota( M_Vh_indices.begin(), M_Vh_indices.end(), 0 ); // Vh indices in Xh std::iota( M_Qh_indices.begin(), M_Qh_indices.end(), M_Vh->nLocalDofWithGhost() ); // Qh indices in Xh // "Components" of Qh3 auto Qh3_dof_begin = M_Qh3->dof()->dofPointBegin(); auto Qh3_dof_end = M_Qh3->dof()->dofPointEnd(); int dof_comp, dof_idx; for( auto it = Qh3_dof_begin; it!= Qh3_dof_end; it++ ) { dof_comp = it->template get<2>(); //Component dof_idx = it->template get<1>(); //Global index M_Qh3_indices[dof_comp].push_back( dof_idx ); } // Subvectors for M_y (per component) M_y1 = M_y->createSubVector(M_Qh3_indices[0], true); M_y2 = M_y->createSubVector(M_Qh3_indices[1], true);#if FEELPP_DIM == 3 M_y3 = M_y->createSubVector(M_Qh3_indices[2], true);#endif // Subvectors for M_s (per component) M_s1 = M_y->createSubVector(M_Qh3_indices[0], true); M_s2 = M_y->createSubVector(M_Qh3_indices[1], true);#if FEELPP_DIM == 3 M_s3 = M_y->createSubVector(M_Qh3_indices[2], true);#endif this->setType ( t ); toc( "[PreconditionerAS] setup done ", FLAGS_v > 0 );}
开发者ID:feelpp,项目名称:feelpp,代码行数:100,
示例24: tocstatic double toc (double t) { double s = tic () ; return (CS_MAX (0, s-t)) ; }
开发者ID:EmanueleCannizzaro,项目名称:suitesparse,代码行数:1,
示例25: tic/** * Iterates the ACWE for several iterations using 1 or more bands * @param numIterations * @param useAllBands */void ActiveContours::iterate(int numIterations, bool useAllBands) { //Default origin and region to copy the entire region of the 3D texture dout << "Initializing origin and region with " << width << "," << height << "," << depth << endl; origin.push_back(0); origin.push_back(0); origin.push_back(0); region.push_back(width); region.push_back(height); region.push_back(depth); cl::CommandQueue* queue = clMan.getQueue(); // Only used if we are printing the buffers. It defines the slides that we are going to print int* slidesToPrint = new int[3]; slidesToPrint[0] = 9; slidesToPrint[1] = 10; slidesToPrint[2] = 11; int sizeOfArray = 3; try { err = queue->enqueueAcquireGLObjects(&cl_textures, NULL, &evAcOGL); queue->finish(); if (currIter == 0) { //Copying img_in_gl to buf_img_in cl::Event evCopyInGlToIn; tic(tm_copyGlToBuffer); dout << "Copying input texture (img_in_gl) to cl_buffer buf_img_in" << endl; vecEvPrevTextToBuffer.push_back(evAcOGL); queue->enqueueCopyImageToBuffer(img_in_gl, buf_img_in, origin, region, (size_t)0, &vecEvPrevTextToBuffer,&evCopyInGlToIn); toc(tm_copyGlToBuffer); if (WRITE) {//Writes the init image on the temporal folder // Sets the precision of cout to 2 cout << std::setprecision(3) << endl; vecEvPrevPrinting.push_back(evCopyInGlToIn); res = queue->enqueueReadBuffer(buf_img_in, CL_TRUE, 0, sizeof (float) *width*height*depth, (void*) arr_img_out, &vecEvPrevPrinting, 0); bool normalized_values = 1; dout << "Done copying texture to buffer.... writing result to images/temp_results/InputImage/" << endl; ImageManager::write3DImage((char*) "images/temp_results/InputImage/", arr_img_out, width, height,depth, normalized_values); /* Just to test that the TEXTURE is being copied to img_in_gl correctly*/ /* int rowSize = sizeof(float)*width; res = queue->enqueueReadImage(img_in_gl, CL_FALSE, origin, region, (size_t) rowSize , (size_t) (rowSize*height), (void*) arr_img_out, &vecEvPrevPrinting, 0); queue->finish(); //Finish everything before the iterations ImageManager::write3DImage((char*) "images/temp_results/3dTexture/", arr_img_out, width, height,depth, normalized_values); queue->finish(); //Finish everything before the iterations dout << "Writing done!!!!" << endl; */ } vecEvPrevAvgInOut.push_back(evCopyInGlToIn); //For the first iteration we need to wait to copy the texture }//If iter == 0 //Compute the last iteration of this 'round' int lastIter = min(currIter + numIterations, totalIterations); // -------------------- MAIN Active Countours iteration for (; currIter < lastIter; currIter++) { if (currIter % ITER == 0) { dout << endl << endl << "******************** Iter " << currIter << " ******************** " << endl; } tic(tm_avgInOut); evAvgInOut_SmoothPhi = compAvgInAndOut(buf_phi, buf_img_in, vecEvPrevAvgInOut); toc(tm_avgInOut); if (WRITE) {// Prints the previous values of phi cout << endl << "----------- Previous Phi ------------" << endl; vecEvPrevPrinting.clear(); vecEvPrevPrinting.push_back(evAvgInOut_SmoothPhi); printBuffer(buf_phi, width*height, width*height*9, width, height, vecEvPrevPrinting); printBuffer(buf_phi, width*height, width*height*16, width, height, vecEvPrevPrinting); printBuffer(buf_phi, width*height, width*height*28, width, height, vecEvPrevPrinting); } if (WRITE) {// Gets the final average values obtained cout << endl << "----------- Final Average (avg out, avg in, count out, count in, sum out, sum in)------------" << endl; vecEvPrevPrinting.clear(); vecEvPrevPrinting.push_back(evAvgInOut_SmoothPhi); printBuffer(buf_avg_in_out, 6, vecEvPrevPrinting); } //It computes the curvatue and F values, the curvature is stored on the first layer //and the F values are stored on the second layer tic(tm_curvature);//.........这里部分代码省略.........
开发者ID:olmozavala,项目名称:3D_OpenCL_ACWE,代码行数:101,
示例26: mainint main(int argc, char** argv){ if(argc != 2) { printf("You should use the following format for running this program: %s <Number of Iterations>/n", argv[0]); exit(1); } int N = atoi(argv[1]); int rng = 42; srand(rng); array_number_t vec1 = vector_fill(DIM, 0.0); array_number_t vec2 = vector_fill(DIM, 0.0); array_number_t vec3 = vector_fill(DIM, 0.0); for(int i=0; i<DIM; i++) { vec1->arr[i] = dist(rng); vec2->arr[i] = dist(rng); vec3->arr[i] = dist(rng); }#ifdef HOIST storage_t s = storage_alloc(VECTOR_ALL_BYTES(DIM));#endif timer_t t = tic(); double total = 0; for (int count = 0; count < N; ++count) { vec1->arr[0] += 1.0 / (2.0 + vec1->arr[0]); vec2->arr[10] += 1.0 / (2.0 + vec2->arr[10]);#ifdef DPS#ifndef HOIST storage_t s = storage_alloc(VECTOR_ALL_BYTES(DIM));#endif#endif#ifdef ADD3 #ifdef DPS total += vectorSum(TOP_LEVEL_linalg_vectorAdd3_dps(s, vec1, vec2, vec3, DIM, DIM, DIM)); #else total += vectorSum(TOP_LEVEL_linalg_vectorAdd3(vec1, vec2, vec3)); #endif#elif DOT #ifdef DPS total += TOP_LEVEL_linalg_dot_prod_dps(s, vec1, vec2, DIM, DIM); #else total += TOP_LEVEL_linalg_dot_prod(vec1, vec2); #endif#elif CROSS #ifdef DPS total += vectorSum(TOP_LEVEL_linalg_cross_dps(s, vec1, vec2, DIM, DIM)); #else total += vectorSum(TOP_LEVEL_linalg_cross(vec1, vec2)); #endif#endif#ifdef DPS#ifndef HOIST storage_free(s, VECTOR_ALL_BYTES(DIM));#endif#endif } float elapsed = toc2(t); printf("total =%f, time per call = %f ms/n", total, elapsed / (double)(N)); return 0;}
开发者ID:awf,项目名称:Coconut,代码行数:63,
示例27: mirageaudio_decodefloat*mirageaudio_decode(MirageAudio *ma, const gchar *file, int *frames, int* size, int* ret){ GstBus *bus; tic(); ma->fftwsamples = 0; ma->curhop = 0; ma->cursample = 0; ma->quit = FALSE; g_mutex_lock(ma->decoding_mutex); ma->invalidate = FALSE; g_mutex_unlock(ma->decoding_mutex); // Gstreamer setup mirageaudio_initgstreamer(ma, file); if (ma->filerate < 0) { *size = 0; *frames = 0; *ret = -1; // Gstreamer cleanup gst_element_set_state(ma->pipeline, GST_STATE_NULL); gst_object_unref(GST_OBJECT(ma->pipeline)); return NULL; } // libsamplerate initialization ma->src_data.src_ratio = (double)ma->rate/(double)ma->filerate; ma->src_data.input_frames = 0; ma->src_data.end_of_input = 0; src_reset(ma->src_state); g_print("libmirageaudio: rate=%d, resampling=%f/n", ma->filerate, ma->src_data.src_ratio); // decode... gst_element_set_state(ma->pipeline, GST_STATE_PLAYING); g_print("libmirageaudio: decoding %s/n", file); bus = gst_pipeline_get_bus(GST_PIPELINE(ma->pipeline)); gboolean decoding = TRUE; *ret = 0; while (decoding) { GstMessage* message = gst_bus_timed_pop_filtered(bus, GST_MSECOND*100, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); if (message == NULL) continue; switch (GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ERROR: { GError *err; gchar *debug; gst_message_parse_error(message, &err, &debug); g_print("libmirageaudio: error: %s/n", err->message); g_error_free(err); g_free(debug); ma->curhop = 0; decoding = FALSE; *ret = -1; break; } case GST_MESSAGE_EOS: { g_print("libmirageaudio: EOS Message received/n"); decoding = FALSE; break; } default: break; } gst_message_unref(message); } gst_object_unref(bus); g_mutex_lock(ma->decoding_mutex); // Gstreamer cleanup gst_element_set_state(ma->pipeline, GST_STATE_NULL); gst_object_unref(GST_OBJECT(ma->pipeline)); toc(); if (ma->invalidate) { *size = 0; *frames = 0; *ret = -2; } else { *size = ma->winsize/2 + 1; *frames = ma->curhop; } g_mutex_unlock(ma->decoding_mutex); g_print("libmirageaudio: frames=%d (maxhops=%d), size=%d/n", *frames, ma->hops, *size); return ma->out;//.........这里部分代码省略.........
开发者ID:BansheeMediaPlayer,项目名称:banshee-community-extensions,代码行数:101,
示例28: ECOS_setup/* * Sets up all data structures needed. * Replace by codegen */pwork* ECOS_setup(idxint n, idxint m, idxint p, idxint l, idxint ncones, idxint* q, pfloat* Gpr, idxint* Gjc, idxint* Gir, pfloat* Apr, idxint* Ajc, idxint* Air, pfloat* c, pfloat* h, pfloat* b){ idxint i, j, k, cidx, conesize, lnz, amd_result, nK, *Ljc, *Lir, *P, *Pinv, *Sign; pwork* mywork; double Control [AMD_CONTROL], Info [AMD_INFO]; pfloat rx, ry, rz, *Lpr; spmat *At, *Gt, *KU;#if PROFILING > 0 timer tsetup;#endif#if PROFILING > 1 timer tcreatekkt; timer tmattranspose; timer tordering;#endif#if PROFILING > 0 tic(&tsetup);#endif #if PRINTLEVEL > 2 PRINTTEXT("/n"); PRINTTEXT(" *******************************************************************************/n"); PRINTTEXT(" * ECOS: Embedded Conic Solver - Sparse Interior Point method for SOCPs */n"); PRINTTEXT(" * */n"); PRINTTEXT(" * NOTE: The solver is based on L. Vandenberghe's 'The CVXOPT linear and quad- */n"); PRINTTEXT(" * ratic cone program solvers', March 20, 2010. Available online: */n"); PRINTTEXT(" * [http://abel.ee.ucla.edu/cvxopt/documentation/coneprog.pdf] */n"); PRINTTEXT(" * */n"); PRINTTEXT(" * This code uses T.A. Davis' sparse LDL package and AMD code. */n"); PRINTTEXT(" * [http://www.cise.ufl.edu/research/sparse] */n"); PRINTTEXT(" * */n"); PRINTTEXT(" * Written during a summer visit at Stanford University with S. Boyd. */n"); PRINTTEXT(" * */n"); PRINTTEXT(" * (C) Alexander Domahidi, Automatic Control Laboratory, ETH Zurich, 2012-13. */n"); PRINTTEXT(" * Email: [email C++ ticalcs_info函数代码示例 C++ ti函数代码示例
|