void BytecodeAssembler::load_string(Symbol* sym) { u2 cpool_index = _cp->string(sym); if (cpool_index < 0x100) { ldc(cpool_index); } else { ldc_w(cpool_index); } }
int CompiledLoop::defsInLoop(PReg* r, NonTrivialNode** defNode) { // returns the number of definitions of r within the loop // also sets defNode to the last definition // BUG: won't work if loop has sends -- will ignore possible defs to inst vars etc. LoopDefCounter ldc(this); r->forAllDefsDo(&ldc); if (defNode) *defNode = ldc.defNode; return ldc.defCount; }
void SimpleShear::createActors(shared_ptr<Scene>& scene) { shared_ptr<IGeomDispatcher> interactionGeometryDispatcher(new IGeomDispatcher); interactionGeometryDispatcher->add(new Ig2_Sphere_Sphere_ScGeom6D); interactionGeometryDispatcher->add(new Ig2_Box_Sphere_ScGeom6D); shared_ptr<IPhysDispatcher> interactionPhysicsDispatcher(new IPhysDispatcher); shared_ptr<IPhysFunctor> CL1Rel(new Ip2_2xNormalInelasticMat_NormalInelasticityPhys); interactionPhysicsDispatcher->add(CL1Rel); shared_ptr<InsertionSortCollider> collider(new InsertionSortCollider); collider->boundDispatcher->add(new Bo1_Sphere_Aabb); collider->boundDispatcher->add(new Bo1_Box_Aabb); shared_ptr<GravityEngine> gravityCondition(new GravityEngine); gravityCondition->gravity = gravity; shared_ptr<GlobalStiffnessTimeStepper> globalStiffnessTimeStepper(new GlobalStiffnessTimeStepper); globalStiffnessTimeStepper->timeStepUpdateInterval = timeStepUpdateInterval; globalStiffnessTimeStepper->defaultDt=3e-6; shared_ptr<KinemCTDEngine> kinemEngine (new KinemCTDEngine); kinemEngine->compSpeed = 10.0; kinemEngine->targetSigma=2000.0; shared_ptr<InteractionLoop> ids(new InteractionLoop); ids->geomDispatcher=interactionGeometryDispatcher; ids->physDispatcher=interactionPhysicsDispatcher; ids->lawDispatcher=shared_ptr<LawDispatcher>(new LawDispatcher); shared_ptr<Law2_ScGeom6D_NormalInelasticityPhys_NormalInelasticity> ldc(new Law2_ScGeom6D_NormalInelasticityPhys_NormalInelasticity); ids->lawDispatcher->add(ldc); scene->engines.clear(); scene->engines.push_back(shared_ptr<Engine>(new ForceResetter)); scene->engines.push_back(globalStiffnessTimeStepper); scene->engines.push_back(collider); scene->engines.push_back(ids); if(gravApplied) scene->engines.push_back(gravityCondition); scene->engines.push_back(shared_ptr<Engine> (new NewtonIntegrator)); scene->engines.push_back(kinemEngine); }
Matrix operator * (const Matrix& A, const Matrix& B) { if (A.Clo() != B.Rlo() || A.Chi() != B.Rhi()) Matpack.Error("Matrix operator * (const Matrix&, const Matrix&): " "non conformant arguments\n"); // allocate return matrix Matrix C(A.Rlo(),A.Rhi(),B.Clo(),B.Chi()); //------------------------------------------------------------------------// // the BLAS version //------------------------------------------------------------------------// #if defined ( _MATPACK_USE_BLAS_ ) if ( LT(B) ) { // full matrix * lower triangle #ifdef DEBUG cout << "GM*LT\n"; #endif checksquare(B); // copy A to C to protect from overwriting copyvec(C.Store(),A.Store(),A.Elements()); charT side('L'), uplo('U'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(B.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,B.Store(),&ldb, C.Store(),&ldc); } else if ( UT(B) ) { // full matrix * upper triangle #ifdef DEBUG cout << "GM*UT\n"; #endif checksquare(B); // copy A to C to protect from overwriting copyvec(C.Store(),A.Store(),A.Elements()); charT side('L'), uplo('L'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(B.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,B.Store(),&ldb, C.Store(),&ldc); } else if ( LT(A) ) { // lower triangle * full matrix #ifdef DEBUG cout << "LT*GM\n"; #endif checksquare(A); // copy B to C to protect from overwriting copyvec(C.Store(),B.Store(),B.Elements()); charT side('R'), uplo('U'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(A.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,A.Store(),&ldb, C.Store(),&ldc); } else if ( UT(A) ) { // upper triangle * full matrix #ifdef DEBUG cout << "UT*GM\n"; #endif checksquare(A); // copy A to C to protect from overwriting copyvec(C.Store(),B.Store(),B.Elements()); charT side('R'), uplo('L'), transc('N'), diag('N'); intT m(C.Cols()), n(C.Rows()), ldb(A.Cols()), ldc(C.Cols()); doubleT alpha(1.0); F77NAME(dtrmm)(&side,&uplo,&transc,&diag,&m,&n, &alpha,A.Store(),&ldb, C.Store(),&ldc); } else /* GM(A) and GM(B) */ { // GM*GM: full matrix * full matrix #ifdef DEBUG cout << "GM*GM\n"; #endif charT t('N'); intT m(B.Cols()), n(A.Rows()), k(B.Rows()), lda(A.Cols()), ldb(B.Cols()), ldc(C.Cols()); doubleT alpha(1.0), beta(0.0); F77NAME(dgemm)(&t,&t, &m,&n,&k, &alpha,B.Store(),&ldb, A.Store(),&lda, &beta,C.Store(),&ldc); } //------------------------------------------------------------------------// // the non-BLAS version //------------------------------------------------------------------------// #else int cl = A.cl, ch = A.ch, arl = A.rl, arh = A.rh, bcl = B.cl, bch = B.ch; // avoid call to index operator that optimizes very badely double **a = A.M, **b = B.M, **c = C.M; for (int i = arl; i <= arh; i++) { for (int j = bcl; j <= bch; j++) c[i][j] = 0.0; for (int l = cl; l <= ch; l++) { if ( a[i][l] != 0.0 ) { double temp = a[i][l]; for (int j = bcl; j <= bch; j++) c[i][j] += temp * b[l][j]; } } } #endif return C.Value(); }
void run(double *accum, int *cur_loc, mem_array mem) { int prg_counter = 0, // mem cell location of the command being executed next_loc = 0, // mem cell location of the next command to be executed run_flag = CONTINUE; // flag for when to stop the execution of the // user's program. Values are CONTINUE, STOP // and RUN_ERR char cmdtrans[80]; // an English translation of the current command enum speed run_speed; // the run mode hidemouse(); // if they want to run if(get_speed(&run_speed) == CONTINUE) { // set up screen for running put_accum(accum); clear_monitor(); clear_keyboard(); clear_keys(); /* user's program loop */ do { // execute at the next location prg_counter = next_loc; // THF patch, was +2 put_prg_counter(prg_counter + 1); put_instruct(mem[prg_counter]); bright_cell(prg_counter, mem[prg_counter]); // case statement for run mode switch(run_speed) { case SLOW: delay(SLOW_DELAY_TIME); break; case FAST: delay(FAST_DELAY_TIME); } /// if there is a command in the cell if(mem[prg_counter].entry_type == CMD) { // command type case statement switch(mem[prg_counter].cmd_type) { case LDC: run_flag = ldc(accum, mem, cmdtrans, prg_counter, &next_loc); break; case ADC: run_flag = adc(accum, mem, cmdtrans, prg_counter, &next_loc); break; case LDA: run_flag = lda(accum, mem, cmdtrans, prg_counter, &next_loc); break; case STA: run_flag = sta(accum, mem, cmdtrans, prg_counter, &next_loc); break; case ADD: run_flag = add(accum, mem, cmdtrans, prg_counter, &next_loc); break; case SUB: run_flag = sub(accum, mem, cmdtrans, prg_counter, &next_loc); break; case MUL: run_flag = mul(accum, mem, cmdtrans, prg_counter, &next_loc); break; case DIV: run_flag = div(accum, mem, cmdtrans, prg_counter, &next_loc); break; case INP: run_flag = inp(mem, cmdtrans, prg_counter, &next_loc); break; case OUT: run_flag = out(mem, cmdtrans, prg_counter, &next_loc); break; case BPA: run_flag = bpa(accum, mem, cmdtrans, prg_counter, &next_loc); break; case BNA: run_flag = bna(accum, mem, cmdtrans, prg_counter, &next_loc); break; case BZA: run_flag = bza(accum, mem, cmdtrans, prg_counter, &next_loc); break; case BRU: run_flag = bru(mem, cmdtrans, prg_counter, &next_loc); break; case STP: run_flag = stp(cmdtrans, prg_counter, &next_loc); if(run_speed == CYCLE) { display_cmdtrans(cmdtrans); } break; default: run_err_message("ERROR: Unkown command at this location."); run_flag = RUN_ERR; break; } } else { run_err_message("ERROR: Unkown command at this location."); run_flag = RUN_ERR; } // check to see if the user wants to stop if(kbhit()) { if(getch() == EscKey) { run_flag = STOP; } } if((run_speed == CYCLE) && (run_flag == CONTINUE)) { run_flag = display_cmdtrans(cmdtrans); } dim_cell(prg_counter, mem[prg_counter]); } while((run_flag == CONTINUE) && (mem[prg_counter].cmd_type != STP)); // clear the registers when program is done clear_instruct(); clear_prg_counter(); } showmouse(); if(run_flag == RUN_ERR) { *cur_loc = prg_counter; } display_keys(); }