// Read mesh if available. Otherwise create empty mesh with same non-proc // patches as proc0 mesh. Requires all processors to have all patches // (and in same order). autoPtr<fvMesh> createMesh ( const Time& runTime, const word& regionName, const fileName& instDir, const bool haveMesh ) { Pout<< "Create mesh for time = " << runTime.timeName() << nl << endl; IOobject io ( regionName, instDir, runTime, IOobject::MUST_READ ); if (!haveMesh) { // Create dummy mesh. Only used on procs that don't have mesh. fvMesh dummyMesh ( io, xferCopy(pointField()), xferCopy(faceList()), xferCopy(labelList()), xferCopy(labelList()), false ); Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath() << endl; dummyMesh.write(); } Pout<< "Reading mesh from " << io.objectPath() << endl; autoPtr<fvMesh> meshPtr(new fvMesh(io)); fvMesh& mesh = meshPtr(); // Determine patches. if (Pstream::master()) { // Send patches for ( int slave=Pstream::firstSlave(); slave<=Pstream::lastSlave(); slave++ ) { OPstream toSlave(Pstream::blocking, slave); toSlave << mesh.boundaryMesh(); } } else { // Receive patches IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); PtrList<entry> patchEntries(fromMaster); if (haveMesh) { // Check master names against mine const polyBoundaryMesh& patches = mesh.boundaryMesh(); forAll(patchEntries, patchI) { const entry& e = patchEntries[patchI]; const word type(e.dict().lookup("type")); const word& name = e.keyword(); if (type == processorPolyPatch::typeName) { break; } if (patchI >= patches.size()) { FatalErrorIn ( "createMesh(const Time&, const fileName&, const bool)" ) << "Non-processor patches not synchronised." << endl << "Processor " << Pstream::myProcNo() << " has only " << patches.size() << " patches, master has " << patchI << exit(FatalError); } if ( type != patches[patchI].type() || name != patches[patchI].name() ) { FatalErrorIn ( "createMesh(const Time&, const fileName&, const bool)" ) << "Non-processor patches not synchronised." << endl << "Master patch " << patchI << " name:" << type << " type:" << type << endl << "Processor " << Pstream::myProcNo() << " patch " << patchI << " has name:" << patches[patchI].name() << " type:" << patches[patchI].type() << exit(FatalError); } } } else { // Add patch List<polyPatch*> patches(patchEntries.size()); label nPatches = 0; forAll(patchEntries, patchI) { const entry& e = patchEntries[patchI]; const word type(e.dict().lookup("type")); const word& name = e.keyword(); if (type == processorPolyPatch::typeName) { break; } Pout<< "Adding patch:" << nPatches << " name:" << name << " type:" << type << endl; dictionary patchDict(e.dict()); patchDict.remove("nFaces"); patchDict.add("nFaces", 0); patchDict.remove("startFace"); patchDict.add("startFace", 0); patches[patchI] = polyPatch::New ( name, patchDict, nPatches++, mesh.boundaryMesh() ).ptr(); } patches.setSize(nPatches); mesh.addFvPatches(patches, false); // no parallel comms //// Write empty mesh now we have correct patches //meshPtr().write(); } }
// Perform SVD on each block in the image sequence, // subject to the block overlap restriction void Decompose(const arma::cube &u) { // Do the local SVDs arma::mat Ublock, Vblock; arma::vec Sblock; Ublock.set_size(Bs*Bs, T); Sblock.set_size(T); Vblock.set_size(T, T); // Fix block overlap parameter arma::uvec firstpatches(vecSize); int kiter = 0; for (int i = 0; i < 1+(Ny-Bs); i+=Bo) { for (int j = 0; j < 1+(Nx-Bs); j+=Bo) { firstpatches(kiter) = i*(Ny-Bs)+j; kiter++; } } // Code must include right and bottom edges // of the image sequence to ensure an // accurate PGURE reconstruction arma::uvec patchesbottomedge(1+(Ny-Bs)/Bo); for (int i = 0; i < 1+(Ny-Bs); i+=Bo) { patchesbottomedge(i/Bo) = (Ny-Bs+1)*i + (Nx-Bs); } arma::uvec patchesrightedge(1+(Nx-Bs)/Bo); for (int i = 0; i < 1+(Nx-Bs); i+=Bo) { patchesrightedge(i/Bo) = (Ny-Bs+1)*(Nx-Bs) + i; } // Concatenate and find unique indices arma::uvec joinpatches(vecSize + 1+(Ny-Bs)/Bo + 1+(Nx-Bs)/Bo); joinpatches( arma::span(0, vecSize-1)) = firstpatches; joinpatches( arma::span(vecSize, vecSize+(Ny-Bs)/Bo)) = patchesrightedge; joinpatches( arma::span(vecSize+(Ny-Bs)/Bo+1, vecSize+(Ny-Bs)/Bo+1+(Nx-Bs)/Bo)) = patchesbottomedge; actualpatches = arma::sort(joinpatches.elem(arma::find_unique(joinpatches))); // Get new vector size newVecSize = actualpatches.n_elem; // Memory allocation U.resize(newVecSize); S.resize(newVecSize); V.resize(newVecSize); for (int it = 0; it < newVecSize; it++) { U[it] = arma::zeros<arma::mat>(Bs*Bs, T); S[it] = arma::zeros<arma::vec>(T); V[it] = arma::zeros<arma::mat>(T, T); } #pragma omp parallel for private(Ublock, Sblock, Vblock) for (int it = 0; it < newVecSize; it++) { arma::mat block(Bs*Bs, T); // Extract block for (int k = 0; k < T; k++) { int newy = patches(0, actualpatches(it), k); int newx = patches(1, actualpatches(it), k); block.col(k) = arma::vectorise( u(arma::span(newy, newy+Bs-1), arma::span(newx, newx+Bs-1), arma::span(k))); } // Do the SVD arma::svd_econ(Ublock, Sblock, Vblock, block); U[it] = Ublock; S[it] = Sblock; V[it] = Vblock; } return; }
bool triSurface::readAC(const fileName& ACfileName) { IFstream ACfile(ACfileName); if (!ACfile.good()) { FatalErrorIn("triSurface::readAC(const fileName&)") << "Cannot read file " << ACfileName << exit(FatalError); } string line; ACfile.getLine(line); string version = line.substr(4); if (version != "b") { WarningIn("bool triSurface::readAC(const fileName& ACfileName)") << "When reading AC3D file " << ACfileName << " read header " << line << " with version " << version << endl << "Only tested reading with version 'b'." << " This might give problems" << endl; } string cmd; string args; if (!readUpto("OBJECT", ACfile, args) || (args != "world")) { FatalErrorIn("bool triSurface::readAC(const fileName& ACfileName)") << "Cannot find \"OBJECT world\" in file " << ACfileName << exit(FatalError); } // Number of kids = patches readUpto("kids", ACfile, args, ""); label nPatches = parseInt(args); // Storage for patches and unmerged points and faces DynamicList<point> points; DynamicList<labelledTri> faces; geometricSurfacePatchList patches(nPatches); // Start of vertices for object/patch label patchStartVert = 0; for (label patchI = 0; patchI < nPatches; patchI++) { readUpto("OBJECT", ACfile, args, " while reading patch " + patchI); // Object global values string patchName = string("patch") + name(patchI); label nVerts = 0; tensor rot(I); vector loc(0, 0, 0); // Read all info for current patch while (ACfile.good()) { // Read line and get first word. If end of file break since // patch should always end with 'kids' command ?not sure. if (!readCmd(ACfile, cmd, args)) { FatalErrorIn("triSurface::readAC(const fileName&)") << "Did not read up to \"kids 0\" while reading patch " << patchI << " from file " << ACfileName << exit(FatalError); } if (cmd == "name") { IStringStream nameStream(args); nameStream >> patchName; } else if (cmd == "rot") { // rot %f %f %f %f %f %f %f %f %f IStringStream lineStream(args); lineStream >> rot.xx() >> rot.xy() >> rot.xz() >> rot.yx() >> rot.yy() >> rot.yz() >> rot.zx() >> rot.zy() >> rot.zz(); WarningIn("triSurface::readAC(const fileName&)") << "rot (rotation tensor) command not implemented" << "Line:" << cmd << ' ' << args << endl << "while reading patch " << patchI << endl; }
int Interpreter::SingleStepInner(void) { static UGeckoInstruction instCode; u32 function = m_EndBlock ? HLE::GetFunctionIndex(PC) : 0; // Check for HLE functions after branches if (function != 0) { int type = HLE::GetFunctionTypeByIndex(function); if (type == HLE::HLE_HOOK_START || type == HLE::HLE_HOOK_REPLACE) { int flags = HLE::GetFunctionFlagsByIndex(function); if (HLE::IsEnabled(flags)) { HLEFunction(function); if (type == HLE::HLE_HOOK_START) { // Run the original. function = 0; } } else { function = 0; } } } if (function == 0) { #ifdef USE_GDBSTUB if (gdb_active() && gdb_bp_x(PC)) { Host_UpdateDisasmDialog(); gdb_signal(SIGTRAP); gdb_handle_exception(); } #endif NPC = PC + sizeof(UGeckoInstruction); instCode.hex = Memory::Read_Opcode(PC); // Uncomment to trace the interpreter //if ((PC & 0xffffff)>=0x0ab54c && (PC & 0xffffff)<=0x0ab624) // startTrace = 1; //else // startTrace = 0; if (startTrace) { Trace(instCode); } if (instCode.hex != 0) { UReg_MSR& msr = (UReg_MSR&)MSR; if (msr.FP) //If FPU is enabled, just execute { m_opTable[instCode.OPCD](instCode); if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI) { PowerPC::CheckExceptions(); m_EndBlock = true; } } else { // check if we have to generate a FPU unavailable exception if (!PPCTables::UsesFPU(instCode)) { m_opTable[instCode.OPCD](instCode); if (PowerPC::ppcState.Exceptions & EXCEPTION_DSI) { PowerPC::CheckExceptions(); m_EndBlock = true; } } else { Common::AtomicOr(PowerPC::ppcState.Exceptions, EXCEPTION_FPU_UNAVAILABLE); PowerPC::CheckExceptions(); m_EndBlock = true; } } } else { // Memory exception on instruction fetch PowerPC::CheckExceptions(); m_EndBlock = true; } } last_pc = PC; PC = NPC; #if defined(_DEBUG) || defined(DEBUGFAST) if (PowerPC::ppcState.gpr[1] == 0) { WARN_LOG(POWERPC, "%i Corrupt stack", PowerPC::ppcState.DebugCount); } PowerPC::ppcState.DebugCount++; #endif patches(); GekkoOPInfo *opinfo = GetOpInfo(instCode); return opinfo->numCyclesMinusOne + 1; }
void VersionBuilder::readInstancePatches() { PatchOrder userOrder; readOverrideOrders(m_instance, userOrder); QDir patches(instance_root.absoluteFilePath("patches/")); // first, load things by sort order. for (auto id : userOrder) { // ignore builtins if (id == "net.minecraft") continue; if (id == "org.lwjgl") continue; // parse the file QString filename = patches.absoluteFilePath(id + ".json"); QFileInfo finfo(filename); if(!finfo.exists()) { QLOG_INFO() << "Patch file " << filename << " was deleted by external means..."; continue; } QLOG_INFO() << "Reading" << filename << "by user order"; auto file = parseJsonFile(finfo, false); // sanity check. prevent tampering with files. if (file->fileId != id) { throw VersionBuildError( QObject::tr("load id %1 does not match internal id %2").arg(id, file->fileId)); } m_version->VersionPatches.append(file); } // now load the rest by internal preference. QMap<int, QPair<QString, VersionFilePtr>> files; for (auto info : patches.entryInfoList(QStringList() << "*.json", QDir::Files)) { // parse the file QLOG_INFO() << "Reading" << info.fileName(); auto file = parseJsonFile(info, true); // ignore builtins if (file->fileId == "net.minecraft") continue; if (file->fileId == "org.lwjgl") continue; // do not load what we already loaded in the first pass if (userOrder.contains(file->fileId)) continue; if (files.contains(file->order)) { // FIXME: do not throw? throw VersionBuildError(QObject::tr("%1 has the same order as %2") .arg(file->fileId, files[file->order].second->fileId)); } files.insert(file->order, qMakePair(info.fileName(), file)); } for (auto order : files.keys()) { auto &filePair = files[order]; m_version->VersionPatches.append(filePair.second); } }
int main (void) { unsigned long c; mp_limb_t t[4]; int i; /* Casts are for C++ compilers. */ for (i = 0; i < (int) (sizeof (t) / sizeof (mp_limb_t)); i++) t[i] = (mp_limb_t) -1; /**************** Information about the C implementation ****************/ /* This is useful, as this can affect the behavior of MPFR. */ #define COMP "Compiler: " #ifdef __INTEL_COMPILER # ifdef __VERSION__ # define ICCV " [" __VERSION__ "]" # else # define ICCV "" # endif printf (COMP "ICC %d.%d.%d" ICCV "\n", __INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE); #elif (defined(__GNUC__) || defined(__clang__)) && defined(__VERSION__) # ifdef __clang__ # define COMP2 COMP # else # define COMP2 COMP "GCC " # endif printf (COMP2 "%s\n", __VERSION__); #endif #if defined(__STDC__) || defined(__STDC_VERSION__) printf ("C/C++: __STDC__ = " #if defined(__STDC__) MAKE_STR(__STDC__) #else "undef" #endif ", __STDC_VERSION__ = " #if defined(__STDC_VERSION__) MAKE_STR(__STDC_VERSION__) #else "undef" #endif #if defined(__cplusplus) ", C++" #endif "\n"); #endif #if defined(__GNUC__) printf ("GNU compatibility: __GNUC__ = " MAKE_STR(__GNUC__) ", __GNUC_MINOR__ = " #if defined(__GNUC_MINOR__) MAKE_STR(__GNUC_MINOR__) #else "undef" #endif "\n"); #endif #if defined(__ICC) || defined(__INTEL_COMPILER) printf ("Intel compiler: __ICC = " #if defined(__ICC) MAKE_STR(__ICC) #else "undef" #endif ", __INTEL_COMPILER = " #if defined(__INTEL_COMPILER) MAKE_STR(__INTEL_COMPILER) #else "undef" #endif "\n"); #endif #if defined(_WIN32) || defined(_MSC_VER) printf ("MS Windows: _WIN32 = " #if defined(_WIN32) MAKE_STR(_WIN32) #else "undef" #endif ", _MSC_VER = " #if defined(_MSC_VER) MAKE_STR(_MSC_VER) #else "undef" #endif "\n"); #endif #if defined(__GLIBC__) printf ("GNU C library: __GLIBC__ = " MAKE_STR(__GLIBC__) ", __GLIBC_MINOR__ = " #if defined(__GLIBC_MINOR__) MAKE_STR(__GLIBC_MINOR__) #else "undef" #endif "\n"); #endif printf ("\n"); /************************************************************************/ #if defined(__MPIR_VERSION) printf ("MPIR .... Library: %-12s Header: %d.%d.%d\n", mpir_version, __MPIR_VERSION, __MPIR_VERSION_MINOR, __MPIR_VERSION_PATCHLEVEL); #else printf ("GMP ..... Library: %-12s Header: %d.%d.%d\n", gmp_version, __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL); #endif printf ("MPFR .... Library: %-12s Header: %s (based on %d.%d.%d)\n", mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR, MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL); printf ("MPFR features: TLS = %s, decimal = %s", mpfr_buildopt_tls_p () ? "yes" : "no", mpfr_buildopt_decimal_p () ? "yes" : "no"); #if MPFR_VERSION_MAJOR > 3 || MPFR_VERSION_MINOR >= 1 printf (", GMP internals = %s\nMPFR tuning: %s", mpfr_buildopt_gmpinternals_p () ? "yes" : "no", mpfr_buildopt_tune_case ()); #endif /* 3.1 */ printf ("\n"); patches (); printf ("\n"); #ifdef __GMP_CC printf ("__GMP_CC = \"%s\"\n", __GMP_CC); #endif #ifdef __GMP_CFLAGS printf ("__GMP_CFLAGS = \"%s\"\n", __GMP_CFLAGS); #endif printf ("GMP_LIMB_BITS = %d\n", (int) GMP_LIMB_BITS); printf ("GMP_NAIL_BITS = %d\n", (int) GMP_NAIL_BITS); printf ("GMP_NUMB_BITS = %d\n", (int) GMP_NUMB_BITS); printf ("mp_bits_per_limb = %d\n", (int) mp_bits_per_limb); printf ("sizeof(mp_limb_t) = %d\n", (int) sizeof(mp_limb_t)); if (mp_bits_per_limb != GMP_LIMB_BITS) printf ("Warning! mp_bits_per_limb != GMP_LIMB_BITS\n"); if (GMP_LIMB_BITS != sizeof(mp_limb_t) * CHAR_BIT) printf ("Warning! GMP_LIMB_BITS != sizeof(mp_limb_t) * CHAR_BIT\n"); c = mpn_popcount (t, 1); printf ("The GMP library expects %lu bits in a mp_limb_t.\n", c); if (c != GMP_LIMB_BITS) printf ("Warning! This is different from GMP_LIMB_BITS!\n" "Different ABI caused by a GMP library upgrade?\n"); printf ("\n"); printf ("sizeof(mpfr_prec_t) = %d (%s type)\n", (int) sizeof(mpfr_prec_t), SIGNED_STR((mpfr_prec_t) -1)); printf ("sizeof(mpfr_exp_t) = %d (%s type)\n", (int) sizeof(mpfr_exp_t), SIGNED_STR((mpfr_exp_t) -1)); #ifdef _MPFR_PREC_FORMAT printf ("_MPFR_PREC_FORMAT = %d\n", (int) _MPFR_PREC_FORMAT); #endif /* Note: "long" is sufficient for all current _MPFR_PREC_FORMAT values (1, 2, 3). Thus we do not need to depend on ISO C99 or later. */ printf ("MPFR_PREC_MIN = %ld (%s)\n", (long) MPFR_PREC_MIN, SIGNED (MPFR_PREC_MIN)); printf ("MPFR_PREC_MAX = %ld (%s)\n", (long) MPFR_PREC_MAX, SIGNED (MPFR_PREC_MAX)); #ifdef _MPFR_EXP_FORMAT printf ("_MPFR_EXP_FORMAT = %d\n", (int) _MPFR_EXP_FORMAT); #endif printf ("sizeof(mpfr_t) = %d\n", (int) sizeof(mpfr_t)); printf ("sizeof(mpfr_ptr) = %d\n", (int) sizeof(mpfr_ptr)); failure_test (); return 0; }
markPointNbrs(surf, faceI, false, okToCollapse); break; } } } } Pout<< "collapseEdge : collapsing " << nCollapsed << " triangles" << endl; nTotalCollapsed += nCollapsed; if (nCollapsed == 0) { break; } // Pack the triangles surf = pack(surf, newPoints, pointMap); } // Remove any unused vertices surf = triSurface(surf.localFaces(), surf.patches(), surf.localPoints()); return nTotalCollapsed; } // ************************************************************************* //