void Quat::Inverse() { assume(IsNormalized()); assume(IsInvertible()); Conjugate(); }
ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef State, NonLoc Cond, bool Assumption) { // We cannot reason about SymSymExprs, and can only reason about some // SymIntExprs. if (!canReasonAbout(Cond)) { // Just add the constraint to the expression without trying to simplify. SymbolRef Sym = Cond.getAsSymExpr(); return assumeAuxForSymbol(State, Sym, Assumption); } switch (Cond.getSubKind()) { default: llvm_unreachable("'Assume' not implemented for this NonLoc"); case nonloc::SymbolValKind: { nonloc::SymbolVal SV = Cond.castAs<nonloc::SymbolVal>(); SymbolRef Sym = SV.getSymbol(); assert(Sym); // Handle SymbolData. if (!SV.isExpression()) { return assumeAuxForSymbol(State, Sym, Assumption); // Handle symbolic expression. } else if (const SymIntExpr *SE = dyn_cast<SymIntExpr>(Sym)) { // We can only simplify expressions whose RHS is an integer. BinaryOperator::Opcode Op = SE->getOpcode(); if (BinaryOperator::isComparisonOp(Op)) { if (!Assumption) Op = BinaryOperator::negateComparisonOp(Op); return assumeSymRel(State, SE->getLHS(), Op, SE->getRHS()); } } else if (const SymSymExpr *SSE = dyn_cast<SymSymExpr>(Sym)) { // Translate "a != b" to "(b - a) != 0". // We invert the order of the operands as a heuristic for how loop // conditions are usually written ("begin != end") as compared to length // calculations ("end - begin"). The more correct thing to do would be to // canonicalize "a - b" and "b - a", which would allow us to treat // "a != b" and "b != a" the same. SymbolManager &SymMgr = getSymbolManager(); BinaryOperator::Opcode Op = SSE->getOpcode(); assert(BinaryOperator::isComparisonOp(Op)); // For now, we only support comparing pointers. assert(Loc::isLocType(SSE->getLHS()->getType())); assert(Loc::isLocType(SSE->getRHS()->getType())); QualType DiffTy = SymMgr.getContext().getPointerDiffType(); SymbolRef Subtraction = SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy); const llvm::APSInt &Zero = getBasicVals().getValue(0, DiffTy); Op = BinaryOperator::reverseComparisonOp(Op); if (!Assumption) Op = BinaryOperator::negateComparisonOp(Op); return assumeSymRel(State, Subtraction, Op, Zero); } // If we get here, there's nothing else we can do but treat the symbol as // opaque. return assumeAuxForSymbol(State, Sym, Assumption); } case nonloc::ConcreteIntKind: { bool b = Cond.castAs<nonloc::ConcreteInt>().getValue() != 0; bool isFeasible = b ? Assumption : !Assumption; return isFeasible ? State : nullptr; } case nonloc::PointerToMemberKind: { bool IsNull = !Cond.castAs<nonloc::PointerToMember>().isNullMemberPointer(); bool IsFeasible = IsNull ? Assumption : !Assumption; return IsFeasible ? State : nullptr; } case nonloc::LocAsIntegerKind: return assume(State, Cond.castAs<nonloc::LocAsInteger>().getLoc(), Assumption); } // end switch }
void __VERIFIER_atomic_acquire(int * m) { assume(*m==0); *m = 1; }
void float3x3::BatchTransform(float4 *vectorArray, int numVectors, int stride) const { assume(false && "Not implemented!"); ///\todo }
void __VERIFIER_atomic_acquire() { assume(MTX==0); MTX = 1; }
float3x3 float3x3::MakeOrthographicProjectionXY() { assume(false && "Not implemented!"); return float3x3(); ///\todo }
void float3x3::InverseOrthonormal() { assume(IsOrthonormal()); Transpose(); }
void * MyPartOfCalc(int Id) { int myRow, col; float sum; if (flag == 0) { pthread_mutex_lock(&mutex_Flag); rowlimit = currentRow + MyNoofRows; flag++; pthread_mutex_unlock(&mutex_Flag); } while (1) { /* * Thread selects the row of Matrix on which it has to do the * operation */ pthread_mutex_lock(&mutex_Row); { #ifdef _CIVL $assume(currentRow < rowlimit); #endif if (currentRow >= rowlimit) { pthread_mutex_unlock(&mutex_Row); pthread_exit(0); } myRow = currentRow; currentRow++; } pthread_mutex_unlock(&mutex_Row); /* * Perform the addition on the row selected and and store in * max if it is the maximum value until now out of computed * sums */ printf(" Thread Id %d of process with Rank %d operated on Matrix Row %d\n", Id, MyRank, myRow); sum = 0.0; for (col = 0; col < NoofCols; col++) sum += fabs(Matrix[myRow][col]); pthread_mutex_lock(&mutex_Max); if (maxflag == 0) { max = sum; maxflag = 1; } else if (sum > max) max = sum; pthread_mutex_unlock(&mutex_Max); } }
void __VERIFIER_atomic_acquire() { assume(m==0); m = 1; }
void __VERIFIER_atomic_acquire() { /* reachable */ assume(MTX==0); MTX = 1; }
//main(int argc, char **argv) int main(int argc, char **argv) { int iproc, irow, icol, modval, divval, *Displacement; int iprocb, *ArrayNoofRows, Numprocs, Root = 0, NoofRows, VectorSize; float Result; pthread_t *threads; FILE *fp; /* MPI Initialisation ... */ MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &MyRank); MPI_Comm_size(MPI_COMM_WORLD, &Numprocs); /* Validity checking for minimum number of processors */ #ifdef _CIVL $assume(Numprocs >= 2); #endif if (Numprocs < 2) { printf("Invalid Number of Processors ..... \n"); printf("Numprocs must be greater than 1 ......\n"); MPI_Finalize(); exit(0); } /* Read the Matrix from the file. */ fp = fopen("Norm_Data.dat", "r"); if (!fp) { printf("\nUnable to open the file Norm_Data.dat"); exit(0); } fscanf(fp, "%d", &NoofRows); fscanf(fp, "%d", &NoofCols); #ifdef _CIVL $assume(NoofRows <= NUM_ROWS_BOUND); $assume(NoofCols <= NUM_COLS_BOUND); #endif printf("\n Rows: %d Col:%d.", NoofRows, NoofCols); MPI_Barrier(MPI_COMM_WORLD); MPI_Bcast(&NoofRows, 1, MPI_INT, Root, MPI_COMM_WORLD); MPI_Bcast(&NoofCols, 1, MPI_INT, Root, MPI_COMM_WORLD); /* Validity checking for negative sizes of Matrix */ #ifdef _CIVL $assume(NoofRows >= 1 && NoofCols >= 1); #endif if (NoofRows < 1 || NoofCols < 1) { printf("The number of rows or columns or size of Vector should be atleast one\n"); MPI_Finalize(); exit(-1); } /* Validity checking for minimum number of Rows of Matrix */ #ifdef _CIVL $assume(NoofRows >= Numprocs); #endif if (NoofRows < Numprocs) { printf("The number of rows of Matrix should be greater than number of processors\n"); MPI_Finalize(); exit(-1); } /* Allocating and Populating the Matrix */ Matrix = (float **) malloc(NoofRows * sizeof(float *)); for (irow = 0; irow < NoofRows; irow++) Matrix[irow] = (float *) malloc(NoofCols * sizeof(float)); for (irow = 0; irow < NoofRows; irow++) for (icol = 0; icol < NoofCols; icol++) fscanf(fp, "%f", &Matrix[irow][icol]); /* Storing the number of Rows to be operated by each process in array */ modval = NoofRows % Numprocs; divval = NoofRows / Numprocs; MyNoofRows = (MyRank < modval ? divval + 1 : divval); ArrayNoofRows = (int *) malloc(Numprocs * sizeof(int)); MPI_Allgather(&MyNoofRows, 1, MPI_INT, ArrayNoofRows, 1, MPI_INT, MPI_COMM_WORLD); /* Storing the starting Row to be operated by each process in array */ Displacement = (int *) malloc(Numprocs * sizeof(int)); Displacement[0] = 0; for (iproc = 1; iproc < Numprocs; iproc++) Displacement[iproc] = Displacement[iproc - 1] + ArrayNoofRows[iproc - 1]; currentRow = Displacement[MyRank]; MPI_Barrier(MPI_COMM_WORLD); /* * Call threads equal to number of Rows to be processed by this * process */ threads = (pthread_t *) malloc(sizeof(pthread_t) * MyNoofRows); for (irow = 0; irow < MyNoofRows; irow++) pthread_create(&threads[irow], NULL, (void *(*) (void *)) MyPartOfCalc, (void *) irow); MPI_Barrier(MPI_COMM_WORLD); for (irow = 0; irow < MyNoofRows; irow++) pthread_join(threads[irow], NULL); MPI_Barrier(MPI_COMM_WORLD); MPI_Reduce(&max, &Result, 1, MPI_FLOAT, MPI_MAX, Root, MPI_COMM_WORLD); if (MyRank == Root) { printf("The matrix is :\n\n"); for (irow = 0; irow < NoofRows; irow++) { for (icol = 0; icol < NoofCols; icol++) printf("%.1f ", Matrix[irow][icol]); printf("\n"); } printf("The infinity norm is %f \n", Result); } MPI_Finalize(); }
float3 MUST_USE_RESULT Quat::AxisFromTo(const Quat &target) const { assume(this->IsInvertible()); Quat q = target / *this; return q.Axis(); }
float MUST_USE_RESULT Quat::AngleBetween(const Quat &target) const { assume(this->IsInvertible()); Quat q = target / *this; return q.Angle(); }
Quat MUST_USE_RESULT Quat::Inverted() const { assume(IsNormalized()); assume(IsInvertible()); return Conjugated(); }
float3x3 float3x3::MakeOrthographicProjection(float nearPlaneDistance, float farPlaneDistance, float horizontalViewportSize, float verticalViewportSize) { assume(false && "Not implemented!"); return float3x3(); ///\todo }
void __VERIFIER_atomic_release() { assume(m==1); m = 0; }
float3x3 float3x3::MakeOrthographicProjection(const Plane &target) { assume(false && "Not implemented!"); return float3x3(); ///\todo }
void __VERIFIER_atomic_release() { /* reachable */ assume(mutex==1); mutex = 0; }
void float3x3::Set(int row, int col, float value) { assume(0 <= row && row <= 2); assume(0 <= col && col <= 2); v[row][col] = value; }
int rsv_thread() { assume(stop_rsv); rsv_running = 0; }
void float3x3::BatchTransform(float3 *pointArray, int numPoints, int stride) const { assume(false && "Not implemented!"); ///\todo }
int rc_thread() { assert(neh_running); assume(stop_rc); rc_running = 0; }
I(I const&i) { assume(i.o->count >= 1); o = i.o; ++o->count; }
int neh_thread() { assert(rsv_running); assume(stop_neh); neh_running = 0; }
void __VERIFIER_atomic_release() { assume(MTX==1); MTX = 0; }
float4 operator *(const float4 &lhs, const float3x3 &rhs) { assume(lhs.IsWZeroOrOne()); return float4(rhs.TransformLeft(lhs.xyz()), lhs.w); }
MMINLINE uintptr_t getNumCells(uintptr_t sizeClass) const { assume(sizeClass >= OMR_SIZECLASSES_MIN_SMALL && sizeClass <= OMR_SIZECLASSES_MAX_SMALL, "getNumCells: invalid sizeclass"); return _smallNumCells[sizeClass]; }
float3x3 float3x3::Reflect(const Plane &p) { assume(false && "Not implemented!"); return float3x3(); ///\todo }
void __VERIFIER_atomic_release(int * m) { assume(*m==1); *m = 0; }
void __VERIFIER_atomic_release() { /* reachable */ assume(mStartLock==1); mStartLock = 0; }