├── .classpath ├── .gitignore ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs └── org.eclipse.jdt.launching.prefs ├── README.md ├── arch ├── CPU_OpenMP │ ├── Makefile │ ├── driver.c │ ├── ssemathlib.c │ ├── ssemathlib.h │ ├── ssereductions.c │ └── ssereductions.h ├── CPU_OpenMP_AVX │ ├── Makefile │ ├── avxmathlib.h │ ├── avxreductions.c │ ├── avxreductions.h │ └── driver.c ├── CPU_OpenMP_PAPI │ ├── Makefile │ └── driver.c ├── GPU_CUDA │ ├── Makefile │ └── driver.cu ├── INTEL_OpenMP_Native │ ├── Makefile │ ├── driver.c │ └── micmathlib.h ├── INTEL_OpenMP_Offload │ ├── Makefile │ ├── driver.c │ └── micmathlib.h ├── MIC_OpenMP │ ├── Makefile │ ├── driver.c │ └── micmathlib.h ├── Strategy2 │ ├── Makefile │ └── driver.cpp └── architectures.xml ├── bin ├── autotune ├── patus ├── patus.bat ├── patus.jar ├── patus.jar.160412.bak └── patus.jar.311012.bak ├── doc ├── BaierHandout_Patus.pdf ├── manual_0 │ ├── alternate.tex │ ├── back.tex │ ├── commandline.tex │ ├── copyrights.tex │ ├── ebnf.sty │ ├── fig │ │ └── archmapping.pdf │ ├── front.tex │ ├── grammars.tex │ ├── integrating.tex │ ├── limitations.tex │ ├── patus-doc.aux │ ├── patus-doc.bbl │ ├── patus-doc.bib │ ├── patus-doc.blg │ ├── patus-doc.idx │ ├── patus-doc.out │ ├── patus-doc.pdf │ ├── patus-doc.tcp │ ├── patus-doc.tex │ ├── patus-doc.toc │ ├── patus-doc.tps │ ├── patus-indepth.tex │ ├── stencils.tex │ ├── style.tex │ ├── todo.txt │ └── walkthrough.tex └── quickstart │ ├── citeref.sty │ ├── commandline.tex │ ├── copyrights.tex │ ├── copyrights.tex.backup │ ├── ebnf.sty │ ├── examples.tex │ ├── examples.tex.backup │ ├── grammars.tex │ ├── install.tex │ ├── install.tex.backup │ ├── introduction.tex │ ├── limitations.tex │ ├── limitations.tex.backup │ ├── quickstart.aux │ ├── quickstart.bbl │ ├── quickstart.blg │ ├── quickstart.out │ ├── quickstart.pdf │ ├── quickstart.tex │ ├── quickstart.tex.backup │ ├── style.tex │ ├── usage.tex │ └── usage.tex.backup ├── examples ├── HorzDiffFluxes.stc ├── HorzDiffLaplacian.stc ├── HorzDiffOut.stc ├── Reference │ ├── blur.c │ ├── lapgsrb.c │ ├── laplacian.c │ ├── uxx1.c │ └── wave.c ├── blur.stc ├── compileHorzDiff.sh ├── divergence-double.stc ├── divergence-float.stc ├── edge.stc ├── fdtdE2D.stc ├── game-of-life.stc ├── gradient-double.stc ├── gradient-float.stc ├── heat3d.stc ├── himeno-2.stc ├── laplacian-double.stc ├── laplacian-float.stc ├── laplacian-gsrb-float.stc ├── operator.f ├── patus_stencil.vim ├── simple.stc ├── tricubic-double.stc ├── tricubic-float-2.stc ├── tricubic-float.stc ├── trigonometric-float.stc ├── upstream-double.stc ├── upstream-float.stc ├── uxx1.stc ├── wave-1.stc ├── wave-2.stc ├── wave-2_pp.stc ├── wave-double.stc ├── wave-float-2.stc ├── wave-float.stc ├── whispering.stc └── whispering_gallery.stc ├── lib ├── TableLayout.jar ├── jgap.jar └── log4j-1.2.16.jar ├── license.txt ├── release └── 0.1 │ ├── Patus │ ├── arch │ │ ├── CPU_OpenMP │ │ │ ├── Makefile │ │ │ ├── driver.c │ │ │ ├── ssemathlib.c │ │ │ ├── ssemathlib.h │ │ │ ├── ssereductions.c │ │ │ └── ssereductions.h │ │ ├── CPU_OpenMP_AVX │ │ │ ├── Makefile │ │ │ ├── avxmathlib.h │ │ │ ├── avxreductions.c │ │ │ ├── avxreductions.h │ │ │ └── driver.c │ │ ├── GPU_CUDA │ │ │ ├── Makefile │ │ │ └── driver.cu │ │ └── architectures.xml │ ├── bin │ │ ├── patus │ │ ├── patus.bat │ │ └── patus.jar │ ├── etc │ │ ├── gedit │ │ │ ├── README │ │ │ ├── stc.lang │ │ │ └── stg.lang │ │ └── vi │ │ │ ├── README │ │ │ ├── patus-filetypes.vim │ │ │ ├── patus_stencil.vim │ │ │ └── patus_strategy.vim │ ├── examples │ │ ├── applications │ │ │ ├── image-filter │ │ │ │ ├── Makefile │ │ │ │ ├── README.txt │ │ │ │ ├── filter.stc │ │ │ │ ├── hpc.png │ │ │ │ └── pngfilter.c │ │ │ ├── wave │ │ │ │ ├── Makefile │ │ │ │ ├── kernel.h │ │ │ │ ├── utils.h │ │ │ │ ├── visualize.sh │ │ │ │ ├── wave.c │ │ │ │ ├── wave_basic.c │ │ │ │ └── waves.gp │ │ │ └── whispering-gallery │ │ │ │ ├── Makefile │ │ │ │ ├── WhisperingGallery.c │ │ │ │ ├── WhisperingGallery.h │ │ │ │ ├── fdtdE2D.stc │ │ │ │ ├── fdtdH2D.stc │ │ │ │ ├── integrate.stc │ │ │ │ ├── kernel.h │ │ │ │ └── plot.gp │ │ └── stencils │ │ │ ├── Makefile │ │ │ ├── blur.stc │ │ │ ├── divergence.stc │ │ │ ├── edge.stc │ │ │ ├── game-of-life.stc │ │ │ ├── gradient.stc │ │ │ ├── laplacian.stc │ │ │ ├── tricubic.stc │ │ │ ├── wave-1.stc │ │ │ └── wave-2.stc │ ├── quickstart.pdf │ ├── runtime │ │ ├── cycle.h │ │ ├── patusrt.h │ │ ├── timer.c │ │ └── util.c │ ├── strategy │ │ ├── cacheblocked.stg │ │ ├── gpu.stg │ │ └── simple.stg │ └── util │ │ ├── fixpath │ │ ├── patusvars.csh │ │ └── patusvars.sh │ ├── createzip.sh │ ├── patus-0.1.1.zip │ ├── patus-0.1.2.zip │ ├── patus-0.1.3.zip │ ├── patus-0.1.4.zip │ └── patus-0.1.zip ├── runtime ├── cycle.h ├── patusrt.h ├── timer.c └── util.c ├── src ├── cetus │ ├── analysis │ │ ├── AliasAnalysis.java │ │ ├── AnalysisPass.java │ │ ├── ArrayParameterAnalysis.java │ │ ├── ArrayPrivatization.java │ │ ├── BanerjeeTest.java │ │ ├── BasicBlock.java │ │ ├── CFGraph.java │ │ ├── Cache.java │ │ ├── CallGraph.java │ │ ├── CallSite.java │ │ ├── CetusAnnotationParser.java │ │ ├── ControlFlowGraph.java │ │ ├── DDArrayAccessInfo.java │ │ ├── DDGraph.java │ │ ├── DDTDriver.java │ │ ├── DDTest.java │ │ ├── DDTestWrapper.java │ │ ├── DFAGraph.java │ │ ├── DFANode.java │ │ ├── DataFlow.java │ │ ├── DependenceVector.java │ │ ├── Domain.java │ │ ├── GCD.java │ │ ├── IPAGraph.java │ │ ├── IPANode.java │ │ ├── IPAnalysis.java │ │ ├── IPPointsToAnalysis.java │ │ ├── IPRangeAnalysis.java │ │ ├── InlineExpansion.java │ │ ├── LoopAnalysisPass.java │ │ ├── LoopInfo.java │ │ ├── LoopParallelizationPass.java │ │ ├── LoopTools.java │ │ ├── MayMod.java │ │ ├── NormalExpression.java │ │ ├── NullDomain.java │ │ ├── OmegaTest.java │ │ ├── OmpParser.java │ │ ├── PointsToAnalysis.java │ │ ├── PointsToDomain.java │ │ ├── PointsToRel.java │ │ ├── ProcBasicBlock.java │ │ ├── RangeAnalysis.java │ │ ├── RangeDomain.java │ │ ├── RangeTest.java │ │ ├── Reduction.java │ │ ├── Relation.java │ │ ├── Section.java │ │ ├── SetDomain.java │ │ └── SubscriptPair.java │ ├── codegen │ │ ├── CodeGenPass.java │ │ └── ompGen.java │ ├── exec │ │ ├── CommandLineOptionSet.java │ │ └── Driver.java │ ├── hir │ │ ├── AccessExpression.java │ │ ├── AccessLevel.java │ │ ├── AccessOperator.java │ │ ├── AccessSymbol.java │ │ ├── AlignofExpression.java │ │ ├── Annotatable.java │ │ ├── Annotation.java │ │ ├── AnnotationDeclaration.java │ │ ├── AnnotationStatement.java │ │ ├── ArrayAccess.java │ │ ├── ArraySpecifier.java │ │ ├── AssignmentExpression.java │ │ ├── AssignmentOperator.java │ │ ├── BinaryExpression.java │ │ ├── BinaryOperator.java │ │ ├── BitfieldSpecifier.java │ │ ├── BooleanLiteral.java │ │ ├── BreadthFirstIterator.java │ │ ├── BreakStatement.java │ │ ├── Case.java │ │ ├── CetusAnnotation.java │ │ ├── ChainedList.java │ │ ├── CharLiteral.java │ │ ├── ClassDeclaration.java │ │ ├── CodeAnnotation.java │ │ ├── CommaExpression.java │ │ ├── CommentAnnotation.java │ │ ├── CompoundStatement.java │ │ ├── ConditionalExpression.java │ │ ├── ConstructorInitializer.java │ │ ├── ContinueStatement.java │ │ ├── DataFlowTools.java │ │ ├── Declaration.java │ │ ├── DeclarationStatement.java │ │ ├── Declarator.java │ │ ├── Default.java │ │ ├── DeleteExpression.java │ │ ├── DepthFirstIterator.java │ │ ├── DerefSymbol.java │ │ ├── DestructorID.java │ │ ├── DoLoop.java │ │ ├── DuplicateSymbolException.java │ │ ├── Enumeration.java │ │ ├── EscapeLiteral.java │ │ ├── ExceptionHandler.java │ │ ├── ExceptionSpecification.java │ │ ├── Expression.java │ │ ├── ExpressionStatement.java │ │ ├── FlatIterator.java │ │ ├── FloatLiteral.java │ │ ├── ForLoop.java │ │ ├── FunctionCall.java │ │ ├── GotoStatement.java │ │ ├── IDExpression.java │ │ ├── IRIterator.java │ │ ├── IRTools.java │ │ ├── Identifier.java │ │ ├── IfStatement.java │ │ ├── InfExpression.java │ │ ├── Initializer.java │ │ ├── IntegerLiteral.java │ │ ├── Intrinsic.java │ │ ├── Label.java │ │ ├── LinkageSpecification.java │ │ ├── ListInitializer.java │ │ ├── Literal.java │ │ ├── Loop.java │ │ ├── MinMaxExpression.java │ │ ├── NameID.java │ │ ├── Namespace.java │ │ ├── NamespaceAlias.java │ │ ├── NestedDeclarator.java │ │ ├── NewExpression.java │ │ ├── NotAChildException.java │ │ ├── NotAnOrphanException.java │ │ ├── NullStatement.java │ │ ├── OffsetofExpression.java │ │ ├── OmpAnnotation.java │ │ ├── OperatorID.java │ │ ├── PointerSpecifier.java │ │ ├── PostOrderIterator.java │ │ ├── PragmaAnnotation.java │ │ ├── PreAnnotation.java │ │ ├── PrintTools.java │ │ ├── Printable.java │ │ ├── Procedure.java │ │ ├── ProcedureDeclarator.java │ │ ├── Program.java │ │ ├── PseudoSymbol.java │ │ ├── QualifiedID.java │ │ ├── RangeExpression.java │ │ ├── ReturnStatement.java │ │ ├── SimpleExpression.java │ │ ├── SizeofExpression.java │ │ ├── SomeExpression.java │ │ ├── Specifier.java │ │ ├── StandardLibrary.java │ │ ├── Statement.java │ │ ├── StatementExpression.java │ │ ├── StringLiteral.java │ │ ├── SwitchStatement.java │ │ ├── Symbol.java │ │ ├── SymbolTable.java │ │ ├── SymbolTools.java │ │ ├── Symbolic.java │ │ ├── TemplateDeclaration.java │ │ ├── TemplateID.java │ │ ├── ThrowExpression.java │ │ ├── Tools.java │ │ ├── TranslationUnit.java │ │ ├── Traversable.java │ │ ├── Typecast.java │ │ ├── TypeofSpecifier.java │ │ ├── UnaryExpression.java │ │ ├── UnaryOperator.java │ │ ├── UserSpecifier.java │ │ ├── UsingDeclaration.java │ │ ├── UsingDirective.java │ │ ├── VaArgExpression.java │ │ ├── ValueInitializer.java │ │ ├── VariableDeclaration.java │ │ ├── VariableDeclarator.java │ │ └── WhileLoop.java │ ├── transforms │ │ ├── AnnotationParser.java │ │ ├── IVSubstitution.java │ │ ├── InlineExpansionPass.java │ │ ├── LoopInterchange.java │ │ ├── LoopNormalization.java │ │ ├── LoopProfiler.java │ │ ├── LoopTiling.java │ │ ├── LoopTransformPass.java │ │ ├── NormalizeReturn.java │ │ ├── ProcedureTransformPass.java │ │ ├── RemoveUselessSpecifiers.java │ │ ├── SingleCall.java │ │ ├── SingleDeclarator.java │ │ ├── SingleReturn.java │ │ └── TransformPass.java │ └── treewalker │ │ ├── CCTreeWalker.java │ │ ├── CTreeWalker.java │ │ ├── DagParser.java │ │ ├── TreeNode.java │ │ └── TreeWalker.java ├── ch │ └── unibas │ │ └── cs │ │ └── hpwc │ │ └── patus │ │ ├── AbstractBaseCodeGenerator.java │ │ ├── CodeGeneratorMain.java │ │ ├── CommandLineOptions.java │ │ ├── Main.java │ │ ├── TrapezoidCodeGeneratorMain.java │ │ ├── UnrollConfig.java │ │ ├── analysis │ │ ├── HIRAnalyzer.java │ │ ├── LoopAnalyzer.java │ │ ├── ReuseNodesCollector.java │ │ ├── StencilAnalyzer.java │ │ ├── StrategyAnalyzer.java │ │ └── StrategyFix.java │ │ ├── arch │ │ ├── ArchitectureDescriptionManager.java │ │ ├── ArchitectureTypes.java │ │ ├── IArchitectureDescription.java │ │ ├── ObjectFactory.java │ │ ├── TypeArchitectureType.java │ │ ├── TypeBaseDatatype.java │ │ ├── TypeBaseIntrinsicEnum.java │ │ ├── TypeCgType.java │ │ ├── TypeDeclspec.java │ │ ├── TypeExecUnitType.java │ │ ├── TypeRegister.java │ │ ├── TypeRegisterClass.java │ │ ├── TypeRegisterType.java │ │ └── arch-config.xsd │ │ ├── ast │ │ ├── BoundaryCheck.java │ │ ├── IStatementList.java │ │ ├── IndexBoundsCalculationInsertionAnnotation.java │ │ ├── Loop.java │ │ ├── Parameter.java │ │ ├── ParameterAssignment.java │ │ ├── RangeIterator.java │ │ ├── StatementList.java │ │ ├── StatementListBundle.java │ │ ├── StencilProperty.java │ │ ├── StencilSpecifier.java │ │ ├── SubdomainIdentifier.java │ │ ├── SubdomainIterator.java │ │ └── UniqueStatementList.java │ │ ├── autotuner │ │ ├── AbstractOptimizer.java │ │ ├── AbstractRunExecutable.java │ │ ├── DiRectOptimizer.java │ │ ├── ExhaustiveSearchOptimizer.java │ │ ├── GeneralCombinedEliminationOptimizer.java │ │ ├── GreedyOptimizer.java │ │ ├── Histogram.java │ │ ├── HookeJeevesOptimizer.java │ │ ├── HybridOptimizer.java │ │ ├── IOptimizer.java │ │ ├── IRunExecutable.java │ │ ├── MetaHeuristicOptimizer.java │ │ ├── OptimizerFactory.java │ │ ├── OptimizerLog.java │ │ ├── OptimizerTest.java │ │ ├── OptimizerUtil.java │ │ ├── ParamSet.java │ │ ├── RandomSearchOptimizer.java │ │ ├── Range.java │ │ ├── RunExecutable.java │ │ ├── SimplexSearchOptimizer.java │ │ ├── StandaloneAutotuner.java │ │ └── TestOptimizerUtil.java │ │ ├── codegen │ │ ├── AbstractMask.java │ │ ├── AbstractSubdomainIteratorCodeGenerator.java │ │ ├── BoundaryCheckCodeGenerator.java │ │ ├── CodeGenerationOptions.java │ │ ├── CodeGenerator.java │ │ ├── CodeGeneratorData.java │ │ ├── CodeGeneratorSharedObjects.java │ │ ├── CodeGenerators.java │ │ ├── ConstantGeneratedIdentifiers.java │ │ ├── DatatransferCodeGenerator.java │ │ ├── FuseMultiplyAddCodeGenerator.java │ │ ├── GlobalGeneratedIdentifiers.java │ │ ├── Globals.java │ │ ├── IBaseCodeGenerator.java │ │ ├── ICodeGenerator.java │ │ ├── IConstantExpressionCalculator.java │ │ ├── IInnermostLoopCodeGenerator.java │ │ ├── IInternalAutotuningParameters.java │ │ ├── IMask.java │ │ ├── IndexCalculatorCodeGenerator.java │ │ ├── IndexExpressionCache.java │ │ ├── InverseMask.java │ │ ├── KernelSourceFile.java │ │ ├── LoopCodeGenerator.java │ │ ├── MainFunctionCodeGenerator.java │ │ ├── MemoryObject.java │ │ ├── MemoryObjectManager.java │ │ ├── Operators.java │ │ ├── ProjectionMask.java │ │ ├── ProjectionUnmask.java │ │ ├── ReuseMask.java │ │ ├── ReuseUnmask.java │ │ ├── SIMDScalarGeneratedIdentifiers.java │ │ ├── SingleThreadCodeGenerator.java │ │ ├── StencilNodeSet.java │ │ ├── Strategy.java │ │ ├── SubdomainGeneratedIdentifiers.java │ │ ├── SubdomainIteratorCodeGenerator.java │ │ ├── ThreadCodeGenerator.java │ │ ├── TrapezoidCodeGenerator.java │ │ ├── TrapezoidalSubdomainIteratorCodeGenerator.java │ │ ├── UnrollGeneratedIdentifiers.java │ │ ├── ValidationCodeGenerator.java │ │ ├── backend │ │ │ ├── AbstractArithmeticImpl.java │ │ │ ├── AbstractBackend.java │ │ │ ├── AbstractNonKernelFunctionsImpl.java │ │ │ ├── BackendFactory.java │ │ │ ├── IAdditionalKernelSpecific.java │ │ │ ├── IArithmetic.java │ │ │ ├── IBackend.java │ │ │ ├── IDataTransfer.java │ │ │ ├── IIndexing.java │ │ │ ├── INonKernelFunctions.java │ │ │ ├── IParallel.java │ │ │ ├── IndexingLevelUtil.java │ │ │ ├── Strategy2CodeGenerator.java │ │ │ ├── assembly │ │ │ │ ├── AbstractInstruction.java │ │ │ │ ├── AbstractInstructionScheduler.java │ │ │ │ ├── AddSub.java │ │ │ │ ├── Argument.java │ │ │ │ ├── Arguments.java │ │ │ │ ├── AssemblyExpressionCodeGenerator.java │ │ │ │ ├── AssemblyParameters.java │ │ │ │ ├── AssemblySection.java │ │ │ │ ├── Comment.java │ │ │ │ ├── CriticalPathInstructionScheduler.java │ │ │ │ ├── IInstruction.java │ │ │ │ ├── IOperand.java │ │ │ │ ├── InnermostLoopCodeGenerator.java │ │ │ │ ├── Instruction.java │ │ │ │ ├── InstructionList.java │ │ │ │ ├── InstructionListTranslator.java │ │ │ │ ├── InstructionRegionScheduler.java │ │ │ │ ├── InstructionRegionSchedulerILPSolver.java │ │ │ │ ├── InstructionRegionSchedulerILPSolver2.java │ │ │ │ ├── InstructionRegionSchedulerILPSolver3.java │ │ │ │ ├── InstructionScheduler.java │ │ │ │ ├── Label.java │ │ │ │ ├── RegisterAllocator.java │ │ │ │ ├── StencilAssemblySection.java │ │ │ │ ├── TooFewRegistersException.java │ │ │ │ ├── analyze │ │ │ │ │ ├── DAGraph.java │ │ │ │ │ ├── DependenceAnalysis.java │ │ │ │ │ ├── Graph.java │ │ │ │ │ ├── InstructionListAnalyzer.java │ │ │ │ │ ├── LAGraph.java │ │ │ │ │ └── LiveAnalysis.java │ │ │ │ ├── copt6.pdf │ │ │ │ ├── optimize │ │ │ │ │ ├── IInstructionListOptimizer.java │ │ │ │ │ ├── InstructionScheduleOptimizer.java │ │ │ │ │ ├── LoadStoreMover.java │ │ │ │ │ ├── MultipleMemoryLoadRemover.java │ │ │ │ │ ├── SimpleUnneededAddressLoadRemover.java │ │ │ │ │ ├── UnneededAddressLoadRemover.java │ │ │ │ │ └── UnneededPseudoRegistersRemover.java │ │ │ │ ├── p121-wilken.pdf │ │ │ │ ├── test │ │ │ │ │ ├── DummyArchitectureDescription.java │ │ │ │ │ ├── ILPTest.java │ │ │ │ │ ├── InstructionListTranslatorTest.java │ │ │ │ │ └── InstructionSchedulerTest.java │ │ │ │ ├── translate-instructions.ods │ │ │ │ ├── translate-instructions.txt │ │ │ │ └── x86_64 │ │ │ │ │ ├── MultiplyByConstantCodeGenerator.java │ │ │ │ │ ├── MultiplyByConstantCodeGeneratorTest.java │ │ │ │ │ ├── PrefetchConfig.java │ │ │ │ │ ├── X86_64InnermostLoopCodeGenerator.java │ │ │ │ │ └── X86_64PrefetchingCodeGenerator.java │ │ │ ├── cuda │ │ │ │ ├── AbstractCUDACodeGenerator.java │ │ │ │ ├── CUDA1DCodeGenerator.java │ │ │ │ ├── CUDA4CodeGenerator.java │ │ │ │ └── CUDACodeGenerator.java │ │ │ ├── intel │ │ │ │ ├── IntelXeonCodeGenerator.java │ │ │ │ └── TestIntelXeonCodeGenerator.java │ │ │ ├── mic │ │ │ │ └── OpenMPMICCodeGenerator.java │ │ │ └── openmp │ │ │ │ ├── AVXSelectGenerator.java │ │ │ │ ├── OpenMPAVXAsmCodeGenerator.java │ │ │ │ ├── OpenMPAVXCodeGenerator.java │ │ │ │ ├── OpenMPCodeGenerator.java │ │ │ │ ├── Permutator.java │ │ │ │ ├── PermutatorGenetic.java │ │ │ │ └── test_avxselect.c │ │ ├── benchmark │ │ │ └── BenchmarkHarness.java │ │ ├── computation │ │ │ ├── AbstractStencilCalculationCodeGenerator.java │ │ │ ├── InitializeCodeGenerator.java │ │ │ ├── StencilCalculationCodeGenerator.java │ │ │ └── StencilCodeGenerator.java │ │ ├── iterator │ │ │ ├── AbstractIteratorCodeGenerator.java │ │ │ ├── ManycoreSubdomainIteratorCodeGenerator.java │ │ │ ├── MulticoreRangeIteratorCodeGenerator.java │ │ │ ├── MulticoreSubdomainIteratorCodeGenerator.java │ │ │ ├── MulticoreSubdomainIteratorCodeGenerator0.java │ │ │ └── MulticoreSubdomainIteratorCodeGenerator2.java │ │ ├── options │ │ │ ├── CodeGeneratorRuntimeOptions.java │ │ │ ├── LoopUnrollingConfiguration.java │ │ │ └── StencilLoopUnrollingConfiguration.java │ │ └── test │ │ │ └── StencilNodeSetTest.java │ │ ├── compiler │ │ └── Compile.java │ │ ├── config │ │ ├── AbstractConfigurable.java │ │ ├── ConfigUI.java │ │ ├── Configuration.java │ │ ├── ConfigurationProperty.java │ │ └── IConfigurable.java │ │ ├── geometry │ │ ├── Border.java │ │ ├── Box.java │ │ ├── Point.java │ │ ├── Primitive.java │ │ ├── Size.java │ │ ├── Subdomain.java │ │ └── Vector.java │ │ ├── grammar │ │ ├── stencil │ │ │ ├── Parser.frame │ │ │ ├── Parser.java │ │ │ ├── Scanner.frame │ │ │ ├── Scanner.java │ │ │ └── Stencil.atg │ │ ├── stencil2 │ │ │ ├── ArithmeticUtil.java │ │ │ ├── LocalVars.java │ │ │ ├── Parser.frame │ │ │ ├── Parser.java │ │ │ ├── Range.java │ │ │ ├── Scanner.frame │ │ │ ├── Scanner.java │ │ │ ├── Stencil.atg │ │ │ └── StencilSpecificationAnalyzer.java │ │ └── strategy │ │ │ ├── IAutotunerParam.java │ │ │ ├── Parser.frame │ │ │ ├── Parser.java │ │ │ ├── Scanner.frame │ │ │ ├── Scanner.java │ │ │ └── Strategy.atg │ │ ├── graph │ │ ├── DefaultGraph.java │ │ ├── IEdge.java │ │ ├── IGraph.java │ │ ├── IParametrizedEdge.java │ │ ├── IParametrizedObject.java │ │ ├── IParametrizedVertex.java │ │ ├── IVertex.java │ │ └── algorithm │ │ │ ├── CriticalPathLengthCalculator.java │ │ │ ├── CriticalPathLengthCalculatorTest.java │ │ │ ├── GraphColoringGreedy.java │ │ │ ├── GraphUtil.java │ │ │ └── GraphUtilTest.java │ │ ├── ilp │ │ ├── ILPModel.java │ │ ├── ILPSolution.java │ │ └── ILPSolver.java │ │ ├── preprocessor │ │ └── Preprocessor.java │ │ ├── representation │ │ ├── FindMinNonparallelSet.java │ │ ├── FindStencilNodeBaseVectors.java │ │ ├── ISpaceIndexable.java │ │ ├── IStencilOperations.java │ │ ├── IStencilStructure.java │ │ ├── Index.java │ │ ├── IndexSetUtil.java │ │ ├── Stencil.java │ │ ├── StencilBundle.java │ │ ├── StencilCalculation.java │ │ └── StencilNode.java │ │ ├── symbolic │ │ ├── ExpressionData.java │ │ ├── ExpressionOptimizer.java │ │ ├── ExpressionParser.java │ │ ├── HardCodedMaximaConfiguration.java │ │ ├── IMaximaConfiguration.java │ │ ├── Maxima.java │ │ ├── MaximaConfiguration.java │ │ ├── MaximaExpression.atg │ │ ├── MaximaRuntimeException.java │ │ ├── MaximaTimeoutException.java │ │ ├── NotConvertableException.java │ │ ├── Parser.frame │ │ ├── Parser.java │ │ ├── Scanner.frame │ │ ├── Scanner.java │ │ └── Symbolic.java │ │ ├── tools │ │ ├── Compare.java │ │ └── ReadExhaustiveMatrix.java │ │ └── util │ │ ├── ASTUtil.java │ │ ├── AnalyzeTools.java │ │ ├── CodeGeneratorUtil.java │ │ ├── DomainPointEnumerator.java │ │ ├── ExpressionUtil.java │ │ ├── FileUtil.java │ │ ├── IParallelOperation.java │ │ ├── IndentOutputStream.java │ │ ├── IntArray.java │ │ ├── MathUtil.java │ │ ├── MathUtilTest.java │ │ ├── StatementListBundleUtil.java │ │ ├── StringUtil.java │ │ ├── StringUtilTest.java │ │ └── VectorUtil.java ├── log4j.properties └── omp2gpu │ ├── analysis │ ├── AnalysisTools.java │ ├── CudaMallocAnalysis.java │ ├── CudaParser.java │ ├── IpG2CMemTrAnalysis.java │ ├── IpResidentGVariableAnalysis.java │ ├── LiveAnalysis.java │ ├── LocalityAnalysis.java │ ├── MemTrAnalysis.java │ ├── OCFGraph.java │ ├── OmpAnalysis.java │ ├── ReachAnalysis.java │ └── UEPrivateAnalysis.java │ ├── codegen │ └── omp2gpu.java │ ├── exec │ └── OMP2GPUDriver.java │ ├── hir │ ├── CUDASpecifier.java │ ├── CudaAnnotation.java │ ├── CudaStdLibrary.java │ ├── Dim3Specifier.java │ ├── KernelFunctionCall.java │ └── TextureSpecifier.java │ └── transforms │ ├── CudaAnnotationParser.java │ ├── LoopCollapse.java │ ├── O2GTranslator.java │ ├── ParallelLoopSwap.java │ ├── SplitOmpPRegion.java │ └── TransformTools.java ├── src_jni ├── CoinInterface.cpp ├── Makefile ├── ch_unibas_cs_hpwc_patus_ilp_ILPModel.h ├── ch_unibas_cs_hpwc_patus_ilp_ILPModel_EOperator.h ├── ch_unibas_cs_hpwc_patus_ilp_ILPSolution.h ├── ch_unibas_cs_hpwc_patus_ilp_ILPSolution_ESolutionStatus.h ├── ch_unibas_cs_hpwc_patus_ilp_ILPSolver.h ├── libilpsolver.so └── msvc │ ├── ilpsolver │ ├── ilpsolver.vcxproj │ ├── ilpsolver.vcxproj.filters │ └── ilpsolver.vcxproj.user │ ├── msvc.sln │ ├── msvc.suo │ └── x64 │ └── Release │ ├── ilpsolver.dll │ ├── ilpsolver.exp │ ├── ilpsolver.lib │ └── ilpsolver.pdb ├── strategy ├── cacheblocked.stg ├── cacheblocked2.stg ├── gpu.stg ├── gpu2.stg └── simple.stg ├── tools ├── CocoR │ ├── Coco.jar │ ├── CocoSourcesJava.zip │ ├── Parser.frame │ └── Scanner.frame └── JAXB │ └── org.jvnet.jaxbw.zip └── util ├── fixpath ├── patusvars.csh └── patusvars.sh /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | classes/ 2 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Patus-GoogleCode 4 | 5 | 6 | 7 | 8 | 9 | at.ssw.coco.eclipse.builder.CocoBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | at.ssw.coco.eclipse.builder.CocoNature 22 | 23 | 24 | 25 | Link 26 | 2 27 | TEMP 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.builder.cleanOutputFolder=clean 3 | org.eclipse.jdt.core.builder.duplicateResourceTask=warning 4 | org.eclipse.jdt.core.builder.invalidClasspath=abort 5 | org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore 6 | org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.atg,*.frame 7 | org.eclipse.jdt.core.circularClasspath=error 8 | org.eclipse.jdt.core.classpath.exclusionPatterns=enabled 9 | org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled 10 | org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error 11 | org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 12 | org.eclipse.jdt.core.incompatibleJDKLevel=ignore 13 | org.eclipse.jdt.core.incompleteClasspath=error 14 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.launching.prefs: -------------------------------------------------------------------------------- 1 | #Mon Aug 08 09:55:08 CEST 2011 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # About Patus 2 | 3 | In many numerical codes, ranging from simple PDE solvers to complex AMR and multigrid solvers, the class of stencil computations is a constituent class of kernels. Oftentimes, stencil computations comprise a dominant part of the compute time. Therefore, in order to minimize the time to solution, it is crucial that the stencil kernels make use of the available computing resources as efficiently as possible. 4 | 5 | The Patus framework is a code generation and autotuning tool for the class of stencil computations. The idea behind the Patus framework is twofold: on the one hand, it provides a software infrastructure for generating architecture-specific (CPUs, GPUs) stencil code from a specification of the stencil incorporating domain-specific knowledge that enables optimizing the code beyond the abilities of current compilers. On the other hand, it aims at being an experimentation toolbox for parallelization and optimization strategies. Using a small domain specific language, the user can define the stencil kernel as shown in the example. Predefined strategies describe how the kernel is optimized and parallelized. Or custom strategies can be designed to experiment with other algorithms or to find a better mapping to the hardware. 6 | -------------------------------------------------------------------------------- /arch/CPU_OpenMP/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | UNAME_S := $(shell uname -s) 8 | ifeq ($(UNAME_S), Darwin) 9 | CC = /usr/local/bin/gcc 10 | GNUPLOT = /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot 11 | else 12 | CC = gcc 13 | GNUPLOT = gnuplot 14 | endif 15 | 16 | CFLAGS = -O3 -g -msse2 -fopenmp -I. 17 | 18 | 19 | bench: kernel.o driver.o ssemathlib.o $(PATUS_RUNTIME_OBJECT_FILES) 20 | $(CC) $(CFLAGS) -o $@ $+ -lm 21 | 22 | %.o: %.c 23 | $(CC) $(CFLAGS) -c -o $@ $< 24 | 25 | tune: 26 | $(PATUS_TEST_NONAUTOTUNE_EXE_PARAMS) 27 | $(PATUS_AUTOTUNER) bench $(PATUS_EXE_PARAMS) | tee `date +tune_%F_%H.%M.%S.txt` 28 | 29 | plot: 30 | for f in *.data; do echo "set term png; set view map; splot \"$$f\" matrix with image" | $(GNUPLOT) > $${f%.data}.png; done 31 | 32 | clean: 33 | rm -rf *.o bench 34 | -------------------------------------------------------------------------------- /arch/CPU_OpenMP/ssereductions.c: -------------------------------------------------------------------------------- 1 | #include "ssereductions.c" 2 | 3 | 4 | -------------------------------------------------------------------------------- /arch/CPU_OpenMP/ssereductions.h: -------------------------------------------------------------------------------- 1 | #ifndef __SSE_REDUCTIONS_H__ 2 | #define __SSE_REDUCTIONS_H__ 3 | 4 | #include "xmmintrin.h" 5 | #include "emmintrin.h" 6 | 7 | inline float vec_reduce_sum_ps (__m128 v) 8 | { 9 | } 10 | 11 | inline float vec_reduce_product_ps (__m128 v) 12 | { 13 | } 14 | 15 | inline float vec_reduce_min_ps (__m128 v) 16 | { 17 | } 18 | 19 | inline float vec_reduce_max_ps (__m128 v) 20 | { 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /arch/CPU_OpenMP_AVX/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | UNAME_S := $(shell uname -s) 9 | ifeq ($(UNAME_S), Darwin) 10 | CC = /usr/local/bin/gcc 11 | GNUPLOT = /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot 12 | else 13 | CC = gcc 14 | GNUPLOT = gnuplot 15 | endif 16 | 17 | CFLAGS = -O3 -g -mavx -fopenmp -I. 18 | 19 | 20 | bench: kernel.o driver.o $(PATUS_RUNTIME_OBJECT_FILES) 21 | $(CC) $(CFLAGS) -o $@ $+ -lm 22 | 23 | %.o: %.c 24 | $(CC) $(CFLAGS) -c -o $@ $< 25 | 26 | tune: 27 | $(PATUS_TEST_NONAUTOTUNE_EXE_PARAMS) 28 | $(PATUS_AUTOTUNER) bench $(PATUS_EXE_PARAMS) | tee `date +tune_%F_%H.%M.%S.txt` 29 | 30 | plot: 31 | for f in *.data; do echo "set term png; set view map; splot \"$$f\" matrix with image" | $(GNUPLOT) > $${f%.data}.png; done 32 | 33 | clean: 34 | rm -rf *.o bench 35 | -------------------------------------------------------------------------------- /arch/CPU_OpenMP_AVX/avxreductions.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/arch/CPU_OpenMP_AVX/avxreductions.c -------------------------------------------------------------------------------- /arch/CPU_OpenMP_PAPI/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = cc 9 | CFLAGS = -O3 -fopenmp -I. 10 | 11 | bench: kernel.o driver.o $(PATUS_RUNTIME_OBJECT_FILES) 12 | $(CC) $(CFLAGS) -o $@ $+ -lm 13 | 14 | %.o: %.c 15 | $(CC) $(CFLAGS) -c -o $@ $< 16 | 17 | tune: 18 | $(PATUS_TEST_NONAUTOTUNE_EXE_PARAMS) 19 | $(PATUS_AUTOTUNER) bench $(PATUS_EXE_PARAMS) | tee `date +tune_%F_%H.%M.%S.txt` 20 | 21 | clean: 22 | rm -rf *.o bench -------------------------------------------------------------------------------- /arch/GPU_CUDA/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = nvcc 9 | NVCCFLAGS = -O3 -arch=sm_13 -I$(HOME)/Software/NVIDIA_GPU_Computing_SDK/C/common/inc 10 | #NVCCFLAGS = -O0 -g -arch=sm_13 -I/home/christen/NVIDIA_GPU_Computing_SDK/C/common/inc 11 | 12 | bench: kernel.cu driver.cu $(PATUS_RUNTIME_FILES) 13 | $(CC) $(NVCCFLAGS) -o $@ $+ 14 | 15 | clean: 16 | rm -rf *.o bench -------------------------------------------------------------------------------- /arch/INTEL_OpenMP_Native/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = icc 9 | #CFLAGS = -O3 -fno-alias -fno-fnalias -g -openmp -offload-build -offload-copts="-openmp -g -O3" -I. 10 | 11 | # only build native MIC for now... 12 | CFLAGS = -O3 -mmic -fno-alias -fno-fnalias -g -openmp -I. 13 | 14 | bench: kernel.o driver.o util.o timer.o 15 | $(CC) $(CFLAGS) -o $@ $+ 16 | 17 | %.o: %.c 18 | $(CC) $(CFLAGS) -c -o $@ $< 19 | 20 | clean: 21 | rm -rf *.o bench 22 | -------------------------------------------------------------------------------- /arch/INTEL_OpenMP_Native/micmathlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIC_MATH_LIB_H__ 2 | #define __MIC_MATH_LIB_H__ 3 | 4 | #include 5 | 6 | 7 | #ifdef _MSC_VER /* Visual C++ */ 8 | # define MIC_ALIGN64_BEG __declspec(align(64)) 9 | # define MIC_ALIGN64_END 10 | #else /* gcc or icc */ 11 | # define MIC_ALIGN64_BEG 12 | # define MIC_ALIGN64_END __attribute__((aligned(64))) 13 | #endif 14 | 15 | #define MIC_DECLARE_INT_CONST(Name, Val) \ 16 | static const MIC_ALIGN64_BEG int Name##_PI32_[16] MIC_ALIGN64_END = { Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val }; 17 | #define MIC_DECLARE_LONG_CONST(Name, Val1, Val2) \ 18 | static const MIC_ALIGN64_BEG int Name##_PI32_[16] MIC_ALIGN64_END = { Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2 }; 19 | 20 | MIC_DECLARE_INT_CONST(MIC_SIGN_MASK_SINGLE, 0x80000000) 21 | #define MIC_SIGN_MASK_SINGLE *(__m512i*) MIC_SIGN_MASK_SINGLE_PI32_ 22 | MIC_DECLARE_LONG_CONST(MIC_SIGN_MASK_DOUBLE, 0x00000000, 0x80000000) 23 | #define MIC_SIGN_MASK_DOUBLE *(__m512i*) MIC_SIGN_MASK_DOUBLE_PI32_ 24 | 25 | #define _mm512_neg_ps(x) _mm512_xor_epi32 ((__m512i) x, MIC_SIGN_MASK_SINGLE) 26 | #define _mm512_neg_pd(x) _mm512_xor_epi32 ((__m512i) x, MIC_SIGN_MASK_DOUBLE) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /arch/INTEL_OpenMP_Offload/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = icc 9 | #CFLAGS = -O3 -fno-alias -fno-fnalias -g -openmp -offload-build -offload-copts="-openmp -g -O3" -I. 10 | 11 | # only build native MIC for now... 12 | CFLAGS = -O3 -fno-alias -fno-fnalias -g -openmp -I. 13 | 14 | bench: kernel.o driver.o util.o timer.o 15 | $(CC) $(CFLAGS) -o $@ $+ 16 | 17 | %.o: %.c 18 | $(CC) $(CFLAGS) -c -o $@ $< 19 | 20 | clean: 21 | rm -rf *.o bench 22 | -------------------------------------------------------------------------------- /arch/INTEL_OpenMP_Offload/micmathlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIC_MATH_LIB_H__ 2 | #define __MIC_MATH_LIB_H__ 3 | 4 | #include 5 | 6 | 7 | #ifdef _MSC_VER /* Visual C++ */ 8 | # define MIC_ALIGN64_BEG __declspec(align(64)) 9 | # define MIC_ALIGN64_END 10 | #else /* gcc or icc */ 11 | # define MIC_ALIGN64_BEG 12 | # define MIC_ALIGN64_END __attribute__((aligned(64))) 13 | #endif 14 | 15 | #define MIC_DECLARE_INT_CONST(Name, Val) \ 16 | static const MIC_ALIGN64_BEG int Name##_PI32_[16] MIC_ALIGN64_END = { Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val }; 17 | #define MIC_DECLARE_LONG_CONST(Name, Val1, Val2) \ 18 | static const MIC_ALIGN64_BEG int Name##_PI32_[16] MIC_ALIGN64_END = { Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2 }; 19 | 20 | MIC_DECLARE_INT_CONST(MIC_SIGN_MASK_SINGLE, 0x80000000) 21 | #define MIC_SIGN_MASK_SINGLE *(__m512i*) MIC_SIGN_MASK_SINGLE_PI32_ 22 | MIC_DECLARE_LONG_CONST(MIC_SIGN_MASK_DOUBLE, 0x00000000, 0x80000000) 23 | #define MIC_SIGN_MASK_DOUBLE *(__m512i*) MIC_SIGN_MASK_DOUBLE_PI32_ 24 | 25 | #define _mm512_neg_ps(x) _mm512_xor_epi32 ((__m512i) x, MIC_SIGN_MASK_SINGLE) 26 | #define _mm512_neg_pd(x) _mm512_xor_epi32 ((__m512i) x, MIC_SIGN_MASK_DOUBLE) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /arch/MIC_OpenMP/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = icc 9 | #CFLAGS = -O3 -fno-alias -fno-fnalias -g -openmp -offload-build -offload-copts="-openmp -g -O3" -I. 10 | 11 | # only build native MIC for now... 12 | CFLAGS = -mmic -O3 -fno-alias -fno-fnalias -g -openmp -I. 13 | 14 | bench: kernel.o driver.o $(PATUS_RUNTIME_OBJECT_FILES) 15 | $(CC) $(CFLAGS) -o $@ $+ 16 | 17 | %.o: %.c 18 | $(CC) $(CFLAGS) -c -o $@ $< 19 | 20 | clean: 21 | rm -rf *.o bench 22 | -------------------------------------------------------------------------------- /arch/MIC_OpenMP/micmathlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __MIC_MATH_LIB_H__ 2 | #define __MIC_MATH_LIB_H__ 3 | 4 | #include 5 | 6 | 7 | #ifdef _MSC_VER /* Visual C++ */ 8 | # define MIC_ALIGN64_BEG __declspec(align(64)) 9 | # define MIC_ALIGN64_END 10 | #else /* gcc or icc */ 11 | # define MIC_ALIGN64_BEG 12 | # define MIC_ALIGN64_END __attribute__((aligned(64))) 13 | #endif 14 | 15 | #define MIC_DECLARE_INT_CONST(Name, Val) \ 16 | static const MIC_ALIGN64_BEG int Name##_PI32_[16] MIC_ALIGN64_END = { Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val, Val }; 17 | #define MIC_DECLARE_LONG_CONST(Name, Val1, Val2) \ 18 | static const MIC_ALIGN64_BEG int Name##_PI32_[16] MIC_ALIGN64_END = { Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2 }; 19 | 20 | MIC_DECLARE_INT_CONST(MIC_SIGN_MASK_SINGLE, 0x80000000) 21 | #define MIC_SIGN_MASK_SINGLE *(__m512i*) MIC_SIGN_MASK_SINGLE_PI32_ 22 | MIC_DECLARE_LONG_CONST(MIC_SIGN_MASK_DOUBLE, 0x00000000, 0x80000000) 23 | #define MIC_SIGN_MASK_DOUBLE *(__m512i*) MIC_SIGN_MASK_DOUBLE_PI32_ 24 | 25 | #define _mm512_neg_ps(x) _mm512_xor_epi32 ((__m512i) x, MIC_SIGN_MASK_SINGLE) 26 | #define _mm512_neg_pd(x) _mm512_xor_epi32 ((__m512i) x, MIC_SIGN_MASK_DOUBLE) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /arch/Strategy2/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | UNAME_S := $(shell uname -s) 9 | ifeq ($(UNAME_S), Darwin) 10 | CC = /usr/local/bin/g++ 11 | GNUPLOT = /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot 12 | else 13 | CC = g++ 14 | GNUPLOT = gnuplot 15 | endif 16 | 17 | CFLAGS = -O3 -g -ltbb -std=c++11 -DPARALLEL -mavx -I. 18 | 19 | 20 | bench: kernel.o driver.o $(PATUS_RUNTIME_OBJECT_FILES) 21 | $(CC) $(CFLAGS) -o $@ $+ -lm 22 | 23 | %.o: %.c 24 | $(CC) $(CFLAGS) -c -o $@ $< 25 | 26 | #tune: 27 | #$(PATUS_TEST_NONAUTOTUNE_EXE_PARAMS) 28 | # $(PATUS_AUTOTUNER) bench $(PATUS_EXE_PARAMS) | tee `date +tune_%F_%H.%M.%S.txt` 29 | 30 | #plot: 31 | # for f in *.data; do echo "set term png; set view map; splot \"$$f\" matrix with image" | $(GNUPLOT) > $${f%.data}.png; done 32 | 33 | clean: 34 | rm -rf *.o bench 35 | -------------------------------------------------------------------------------- /bin/autotune: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | PATUS_HOME=$HOME/Workspace/Patus 3 | 4 | if [ $# -eq 0 ] 5 | then 6 | echo 7 | echo "Syntax: autotune " 8 | echo 9 | 10 | exit 11 | fi 12 | 13 | java -jar $PATUS_HOME/bin/patus.jar autotune $@ -mch.unibas.cs.hpwc.patus.autotuner.MetaHeuristicOptimizer | tee `date +tune_%F_%H.%M.%S.txt` 14 | -------------------------------------------------------------------------------- /bin/patus.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/bin/patus.jar -------------------------------------------------------------------------------- /bin/patus.jar.160412.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/bin/patus.jar.160412.bak -------------------------------------------------------------------------------- /bin/patus.jar.311012.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/bin/patus.jar.311012.bak -------------------------------------------------------------------------------- /doc/BaierHandout_Patus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/doc/BaierHandout_Patus.pdf -------------------------------------------------------------------------------- /doc/manual_0/alternate.tex: -------------------------------------------------------------------------------- 1 | \chapter{Alternate Entry Points to \textsc{Patus}} 2 | 3 | As the auto-tuner module is decoupled from the code generating system, it can be used as a stand-alone auto-tuner 4 | for other codes besides the ones created by \textsc{Patus}. 5 | If the user has a hand-crafted existing parametrized code for which the best configurations need to be determined, 6 | the \textsc{Patus} auto-tuner is a perfectly valid option to find the best set of parameters. 7 | The only requirements are that the tunable parameters must be exposed as command line parameters 8 | and that the program must print the timing information to \texttt{stdout} as last line of the program output in an arbitrary 9 | time measurement unit. 10 | Note that the auto-tuner tries to {\em minimize} this number, i.e., it must be a time measurement rather than a performance number. 11 | -------------------------------------------------------------------------------- /doc/manual_0/back.tex: -------------------------------------------------------------------------------- 1 | % *************** Back matter *************** 2 | 3 | % *************************************************************************** 4 | % You can disable here list of symbols, list of figures, and list of tables. 5 | % You can also disable index generation. 6 | % *************************************************************************** 7 | 8 | \backmatter 9 | 10 | %\normalfont 11 | %\clearpage 12 | %\input{symbols.tex} 13 | 14 | %\clearpage 15 | %\listoffigures 16 | %\clearpage 17 | %\listoftables 18 | 19 | \footnotesize 20 | \printindex 21 | 22 | 23 | % *************** End of back matter *************** 24 | -------------------------------------------------------------------------------- /doc/manual_0/copyrights.tex: -------------------------------------------------------------------------------- 1 | \chapter*{Copyrights} 2 | 3 | %ANTLR 3 4 | %Copyright (c) 2010 Terence Parr 5 | %All rights reserved. 6 | 7 | \textbf{Cetus}\\ 8 | Copyright under the Cetus Artistic License. \url{http://cetus.ecn.purdue.edu/} 9 | 10 | \medskip 11 | 12 | \noindent \textbf{JGAP}\\ 13 | Copyright under the GNU Lesser Public License. 14 | \url{http://jgap.sourceforge.net/} 15 | 16 | \medskip 17 | 18 | \noindent \textbf{Time measurement}\\ 19 | Copyright (c) 2003, 2007-8 Matteo Frigo,\\ 20 | Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 21 | 22 | -------------------------------------------------------------------------------- /doc/manual_0/fig/archmapping.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/doc/manual_0/fig/archmapping.pdf -------------------------------------------------------------------------------- /doc/manual_0/front.tex: -------------------------------------------------------------------------------- 1 | % *************** Front matter *************** 2 | 3 | % *************************************************** 4 | % You should specify the contents of title page here 5 | % Then you can specify dedication page or disable it 6 | % *************************************************** 7 | 8 | % *************** Title page *************** 9 | \pagestyle{empty} 10 | \sffamily 11 | 12 | \begin{center} 13 | \Huge\bfseries 14 | \textsc{Patus} Documentation 15 | \end{center} 16 | 17 | \vfill 18 | \begin{center} 19 | \Large 20 | Matthias-M. Christen\\ 21 | \texttt{m.christen@unibas.ch}\\ 22 | University of Basel, Switzerland 23 | \end{center} 24 | 25 | 26 | \cleardoublepage 27 | 28 | \rmfamily 29 | \normalfont 30 | 31 | % *************** Table of contents *************** 32 | \pagenumbering{roman} 33 | \pagestyle{headings} 34 | \tableofcontents 35 | 36 | % *************** End of front matter *************** 37 | -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{1} 2 | 3 | \bibitem{fftw05} 4 | M.~Frigo and S.~Johnson. 5 | \newblock {The Design and Implementation of FFTW3}. 6 | \newblock {\em Proceedings of the IEEE}, 93(2):216--231, 2005. 7 | \newblock Special issue on ``Program Generation, Optimization, and Platform 8 | Adaptation''. 9 | 10 | \bibitem{opencl08} 11 | {Khronos OpenCL Working Group}. 12 | \newblock {\em {The OpenCL Specification}}, 8 December 2008. 13 | 14 | \end{thebibliography} 15 | -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/doc/manual_0/patus-doc.bib -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99dThe top-level auxiliary file: C:\Users\Matthias\Projects\Java\Patus-GoogleCode\doc\patus-doc.aux 2 | The style file: plain.bst 3 | Database file #1: patus-doc.bib 4 | -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.idx: -------------------------------------------------------------------------------- 1 | \indexentry{wave equation|hyperpage}{3} 2 | \indexentry{finite difference|hyperpage}{3} 3 | \indexentry{PDE|hyperpage}{3} 4 | \indexentry{\textsc{Patus} code generator|hyperpage}{5} 5 | \indexentry{auto-tuning|hyperpage}{6} 6 | \indexentry{stencil specification|hyperpage}{21} 7 | \indexentry{strategy|hyperpage}{25} 8 | \indexentry{Strategy|hyperpage}{25} 9 | \indexentry{cache blocking|hyperpage}{25} 10 | \indexentry{hardware model|hyperpage}{29} 11 | \indexentry{parallelism level|hyperpage}{29} 12 | \indexentry{domain decomposition|hyperpage}{29} 13 | \indexentry{hardware mapping|hyperpage}{29} 14 | \indexentry{subdomain iterator|hyperpage}{30} 15 | \indexentry{index calculation|hyperpage}{30} 16 | -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/doc/manual_0/patus-doc.pdf -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.tcp: -------------------------------------------------------------------------------- 1 | [FormatInfo] 2 | Type=TeXnicCenterProjectInformation 3 | Version=4 4 | 5 | [ProjectInfo] 6 | MainFile=patus-doc.tex 7 | UseBibTeX=1 8 | UseMakeIndex=1 9 | ActiveProfile=LaTeX => PDF 10 | ProjectLanguage= 11 | ProjectDialect= 12 | 13 | -------------------------------------------------------------------------------- /doc/manual_0/patus-doc.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt, a4paper, makeidx]{memoir} 2 | \input{style.tex} 3 | 4 | \begin{document} 5 | 6 | % *************** Front matter *************** 7 | \frontmatter 8 | \input{front.tex} 9 | 10 | % *************** Main matter *************** 11 | \mainmatter 12 | 13 | \input{copyrights.tex} 14 | \input{walkthrough.tex} 15 | \input{commandline.tex} 16 | \input{integrating.tex} 17 | \input{alternate.tex} 18 | \input{patus-indepth.tex} 19 | \input{limitations.tex} 20 | 21 | % *************** Bibliography *************** 22 | \bibliographystyle{plain} 23 | {\small\bibliography{patus-doc}} 24 | 25 | 26 | % *************** Appendixes *************** 27 | \appendix 28 | \appendixpage* 29 | \input{grammars.tex} 30 | \input{stencils.tex} 31 | 32 | 33 | % *************** Back matter *************** 34 | \backmatter 35 | \input{back.tex} 36 | 37 | \end{document} 38 | -------------------------------------------------------------------------------- /doc/manual_0/todo.txt: -------------------------------------------------------------------------------- 1 | InlineAsm: 2 | AssemblyExpressionGenerator: worthwhile breaking add-sub dependence chains? (balanced trees?) 3 | (=> trade off between instruction level parallelism and register pressure) 4 | make tunable? 5 | 6 | How to optimize large kernels? 7 | 8 | 9 | Implement boundary conditions, e.g., 10 | boundaries (float grid u) 11 | { 12 | u[0, y, z] = u[x_max-2, y, z]; 13 | u[x_max-1, y, z] = u[0, y, z]; 14 | u[x, 0, z] = 0; 15 | u[x, y, z_max-1] = 1; 16 | } 17 | 18 | Synchronization on parallelism levels 19 | allow to specify whether sync is possible on that level, 20 | if not, do sync on level above 21 | if no level above exists exit and restart kernel (=> GPU global sync) 22 | 23 | Loop invariant code motion 24 | move calculation of constants in the stencil specification out of the loops 25 | store partial sums if possible? e.g. u[x-2,y-1]+u[x-1,y-1]+u[x,y-1]+u[x+1,y-1] -> s; 26 | can be reused for u[x-1,y-1]+u[x,y-1]+u[x+1,y-1]+u[x+2,y-1] = s-u[x-2,y-1]+u[x+2,y-1] -------------------------------------------------------------------------------- /doc/quickstart/copyrights.tex: -------------------------------------------------------------------------------- 1 | \subsection{Copyrights} 2 | 3 | \textsc{Patus} itself is licensed under the 4 | \href{http://www.gnu.org/licenses/lgpl-3.0.html}{GNU Lesser General Public License}. 5 | \medskip 6 | 7 | %ANTLR 3 8 | %Copyright (c) 2010 Terence Parr 9 | %All rights reserved. 10 | 11 | \noindent The following software packages are used in \textsc{Patus}: 12 | \medskip 13 | 14 | \noindent \textbf{Cetus.} A Source-to-Source Compiler Infrastructure for C Programs. 15 | Copyright under the Cetus Artistic License.\\ 16 | \url{http://cetus.ecn.purdue.edu/} 17 | 18 | \medskip 19 | 20 | \noindent \textbf{JGAP.} Java Genetic Algorithms Package. 21 | Copyright under the GNU Lesser General Public License.\\ 22 | \url{http://jgap.sourceforge.net/} 23 | 24 | \medskip 25 | 26 | \noindent \textbf{Time measurement.} Adapted from the time measurement in \href{http://www.fftw.org/}{FFTW}. 27 | Copyright (c) 2003, 2007-8 Matteo Frigo. 28 | Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology. 29 | 30 | -------------------------------------------------------------------------------- /doc/quickstart/copyrights.tex.backup: -------------------------------------------------------------------------------- 1 | \subsection{Copyrights} 2 | 3 | %ANTLR 3 4 | %Copyright (c) 2010 Terence Parr 5 | %All rights reserved. 6 | 7 | The following software packages are used in \textsc{Patus}: 8 | \medskip 9 | 10 | \noindent \textbf{Cetus.} 11 | Copyright under the Cetus Artistic License.\\ 12 | \url{http://cetus.ecn.purdue.edu/} 13 | 14 | \medskip 15 | 16 | \noindent \textbf{JGAP.} Copyright under the GNU Lesser Public License.\\ 17 | \url{http://jgap.sourceforge.net/} 18 | 19 | \medskip 20 | 21 | \noindent \textbf{Time measurement.} 22 | Copyright (c) 2003, 2007-8 Matteo Frigo. 23 | Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology. 24 | 25 | -------------------------------------------------------------------------------- /doc/quickstart/examples.tex.backup: -------------------------------------------------------------------------------- 1 | \section{Examples} 2 | 3 | In the \texttt{example} directory some example stencil specifications can be found. 4 | 5 | The \texttt{stencil} subdirectory contains single stencil specifications, for which 6 | code can be generated using the provided Makefile. The Makefile builds the benchmarking 7 | harnesses at the same time. 8 | 9 | In the \texttt{applications} two example applications can be found, which use 10 | \textsc{Patus} to generate the computate kernels. 11 | For both applications, Makefiles are provided. Typing \cmd{make} in the shell will 12 | build and run the simulations. 13 | 14 | \begin{itemize} 15 | \item \textbf{wave} is the simple wave equation solver from 16 | \end{itemize} 17 | -------------------------------------------------------------------------------- /doc/quickstart/quickstart.bbl: -------------------------------------------------------------------------------- 1 | \begin{thebibliography}{} 2 | 3 | \end{thebibliography} 4 | -------------------------------------------------------------------------------- /doc/quickstart/quickstart.blg: -------------------------------------------------------------------------------- 1 | This is BibTeX, Version 0.99d (TeX Live 2012/Debian) 2 | Capacity: max_strings=35307, hash_size=35307, hash_prime=30011 3 | The top-level auxiliary file: quickstart.aux 4 | The style file: plain.bst 5 | I couldn't open database file patus-doc.bib 6 | ---line 43 of file quickstart.aux 7 | : \bibdata{patus-doc 8 | : } 9 | I'm skipping whatever remains of this command 10 | I found no \citation commands---while reading file quickstart.aux 11 | I found no database files---while reading file quickstart.aux 12 | You've used 0 entries, 13 | 2118 wiz_defined-function locations, 14 | 497 strings with 4002 characters, 15 | and the built_in function-call counts, 18 in all, are: 16 | = -- 0 17 | > -- 0 18 | < -- 0 19 | + -- 0 20 | - -- 0 21 | * -- 2 22 | := -- 7 23 | add.period$ -- 0 24 | call.type$ -- 0 25 | change.case$ -- 0 26 | chr.to.int$ -- 0 27 | cite$ -- 0 28 | duplicate$ -- 0 29 | empty$ -- 1 30 | format.name$ -- 0 31 | if$ -- 1 32 | int.to.chr$ -- 0 33 | int.to.str$ -- 0 34 | missing$ -- 0 35 | newline$ -- 3 36 | num.names$ -- 0 37 | pop$ -- 0 38 | preamble$ -- 1 39 | purify$ -- 0 40 | quote$ -- 0 41 | skip$ -- 1 42 | stack$ -- 0 43 | substring$ -- 0 44 | swap$ -- 0 45 | text.length$ -- 0 46 | text.prefix$ -- 0 47 | top$ -- 0 48 | type$ -- 0 49 | warning$ -- 0 50 | while$ -- 0 51 | width$ -- 0 52 | write$ -- 2 53 | (There were 3 error messages) 54 | -------------------------------------------------------------------------------- /doc/quickstart/quickstart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/doc/quickstart/quickstart.pdf -------------------------------------------------------------------------------- /doc/quickstart/quickstart.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,9pt]{extarticle} 2 | 3 | \title{ 4 | {\Huge \textsc{Patus} Quickstart}\\ 5 | {\small \textsc{Patus} v.\patusversion} 6 | } 7 | 8 | \author{ 9 | Matthias-M. Christen\\ 10 | {\small University of Lugano, Switzerland}\\ 11 | {\small \href{mailto:matthias.christen@usi.ch}{matthias.christen@usi.ch}} 12 | } 13 | 14 | \pdfinfo{% 15 | /Title (Patus Quickstart) 16 | /Author (Matthias-M. Christen) 17 | /Creator () 18 | /Producer () 19 | /Subject () 20 | /Keywords (Patus) 21 | } 22 | 23 | \newcommand{\patusversion}{0.1} 24 | 25 | \input{style.tex} 26 | 27 | \begin{document} 28 | \maketitle 29 | \date 30 | 31 | \input{introduction.tex} 32 | \input{copyrights.tex} 33 | \input{install.tex} 34 | \input{usage.tex} 35 | \input{examples.tex} 36 | \input{limitations.tex} 37 | %\input{grammars.tex} 38 | 39 | \section*{Acknowledgments} 40 | \textsc{Patus} has been developed within the \href{http://www.hp2c.ch/}{High Performance and High Productivity Computing} 41 | initiative of the Swiss National Supercomputer Center (CSCS). 42 | 43 | We also want to acknowledge Max Nolte for testing and using \textsc{Patus} for his nano-optics simulation project and 44 | for kindly agreeing to publish his code. 45 | 46 | %\bibliographystyle{plain} 47 | %{\small\bibliography{patus-doc}} 48 | 49 | \end{document} 50 | -------------------------------------------------------------------------------- /doc/quickstart/quickstart.tex.backup: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper,9pt]{extarticle} 2 | 3 | \title{ 4 | {\Huge \textsc{Patus} Quickstart}\\ 5 | {\small \textsc{Patus} v.\patusversion} 6 | } 7 | 8 | \author{ 9 | Matthias-M. Christen\\ 10 | {\small University of Lugano, Switzerland}\\ 11 | {\small \href{mailto:matthias.christen@usi.ch}{matthias.christen@usi.ch}} 12 | } 13 | 14 | \pdfinfo{% 15 | /Title (Patus Quickstart) 16 | /Author (Matthias-M. Christen) 17 | /Creator () 18 | /Producer () 19 | /Subject () 20 | /Keywords (Patus) 21 | } 22 | 23 | \newcommand{\patusversion}{0.1} 24 | 25 | \input{style.tex} 26 | 27 | \begin{document} 28 | \maketitle 29 | \date 30 | 31 | \input{introduction.tex} 32 | \input{copyrights.tex} 33 | \input{install.tex} 34 | \input{usage.tex} 35 | \input{limitations.tex} 36 | \input{examples.tex} 37 | %\input{grammars.tex} 38 | 39 | \section*{Acknowledgments} 40 | \textsc{Patus} has been developed within the \href{http://www.hp2c.ch/}{High Performance and High Productivity Computing} 41 | initiative of the Swiss National Supercomputer Center (CSCS). 42 | 43 | %\bibliographystyle{plain} 44 | %{\small\bibliography{patus-doc}} 45 | 46 | \end{document} 47 | -------------------------------------------------------------------------------- /examples/HorzDiffFluxes.stc: -------------------------------------------------------------------------------- 1 | stencil HorzDiffFluxes ( 2 | float grid flx(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 3 | float grid fly(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 4 | const float grid lap(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 5 | const float grid up(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 6 | const float grid crlato(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1) 7 | ) 8 | { 9 | domainsize = (2 .. iDim-3, 2 .. jDim-3, 0 .. kDim-1); 10 | 11 | operation 12 | { 13 | flx[x, y, z; t+1] = lap[x+1, y, z] - lap[x, y, z]; 14 | fly[x, y, z; t+1] = crlato[x, y, z] * (lap[x, y+1, z] - lap[x, y, z]); 15 | 16 | flx[x, y, z; t+1] = clamp0if (flx[x, y, z; t+1], flx[x, y, z; t+1] * (up[x+1, y, z] - up[x, y, z])); 17 | fly[x, y, z; t+1] = clamp0if (fly[x, y, z; t+1], fly[x, y, z; t+1] * (up[x, y+1, z] - up[x, y, z])); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/HorzDiffLaplacian.stc: -------------------------------------------------------------------------------- 1 | stencil HorzDiffLaplacian ( 2 | float grid lap(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 3 | const float grid up(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 4 | const float grid crlato(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 5 | const float grid crlatu(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1) 6 | ) 7 | { 8 | domainsize = (2 .. iDim-3, 2 .. jDim-3, 0 .. kDim-1); 9 | 10 | operation 11 | { 12 | lap[x, y, z; t+1] = up[x+1, y, z] + up[x-1, y, z] - 2 * up[x, y, z] 13 | + crlato[x, y, z] * (up[x, y+1, z] - up[x, y, z]) 14 | - crlatu[x, y, z] * (up[x, y, z] - up[x, y-1, z]); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/HorzDiffOut.stc: -------------------------------------------------------------------------------- 1 | stencil HorzDiffOut ( 2 | float grid u_out(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 3 | const float grid flx(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 4 | const float grid fly(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 5 | const float grid up(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1), 6 | const float grid dcoeff(0 .. iDim-1, 0 .. jDim-1, 0 .. kDim-1) 7 | ) 8 | { 9 | domainsize = (2 .. iDim-3, 2 .. jDim-3, 0 .. kDim-1); 10 | 11 | operation 12 | { 13 | u_out[x, y, z; t+1] = up[x, y, z] - dcoeff[x, y, z] * (flx[x, y, z] - flx[x-1, y, z] + fly[x, y, z] - fly[x, y-1, z]); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/blur.stc: -------------------------------------------------------------------------------- 1 | stencil blur 2 | { 3 | domainsize = (1 .. width, 1 .. height); 4 | t_max = 1; 5 | 6 | operation (float grid u, float param sigma) 7 | { 8 | float f0 = 1 / (2 * sigma ^ 2); 9 | float s0 = exp ( 0 * f0); 10 | float s1 = exp (-1 * f0); 11 | float s2 = exp (-2 * f0); 12 | float s4 = exp (-4 * f0); 13 | float s5 = exp (-5 * f0); 14 | float s8 = exp (-8 * f0); 15 | float f = 1 / (s0 + 4 * (s1 + s2 + s4 + s8) + 8 * s5); 16 | 17 | u[x, y; t+1] = f * ( 18 | s0 * u[x, y; t] + 19 | s1 * (u[x - 1, y; t] + u[x + 1, y; t] + u[x, y - 1; t] + u[x, y + 1; t]) + 20 | s2 * (u[x - 1, y - 1; t] + u[x + 1, y - 1; t] + u[x - 1, y + 1; t] + u[x + 1, y + 1; t]) + 21 | s4 * (u[x - 2, y; t] + u[x + 2, y; t] + u[x, y - 2; t] + u[x, y + 2; t]) + 22 | s5 * ( 23 | u[x - 2, y - 1; t] + u[x - 1, y - 2; t] + u[x + 1, y - 2; t] + u[x + 2, y - 1; t] + 24 | u[x - 2, y + 1; t] + u[x - 1, y + 2; t] + u[x + 1, y + 2; t] + u[x + 2, y + 1; t] 25 | ) + 26 | s8 * (u[x - 2, y - 2; t] + u[x + 2, y - 2; t] + u[x - 2, y + 2; t] + u[x + 2, y + 2; t]) 27 | ); 28 | } 29 | } -------------------------------------------------------------------------------- /examples/compileHorzDiff.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | patus --architecture="x86_64 AVX asm" --create-prefetching=yes --outdir=HorzDiffLaplacian HorzDiffLaplacian.stc 3 | patus --architecture="x86_64 AVX" --outdir=HorzDiffFluxes HorzDiffFluxes.stc 4 | patus --architecture="x86_64 AVX asm" --create-prefetching=no --outdir=HorzDiffOut HorzDiffOut.stc 5 | 6 | 7 | #cd HorzDiffLaplacian 8 | #make 9 | #cd ../HorzDiffFluxes 10 | #make 11 | #cd ../HorzDiffOut 12 | #make 13 | #cd .. 14 | 15 | -------------------------------------------------------------------------------- /examples/divergence-double.stc: -------------------------------------------------------------------------------- 1 | stencil divergence 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation ( 7 | double grid u(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 8 | const double grid ux(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 9 | const double grid uy(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 10 | const double grid uz(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 11 | double param alpha, double param beta, double param gamma) 12 | { 13 | u[x, y, z; t] = 14 | alpha * (ux[x+1, y, z] - ux[x-1, y, z]) + 15 | beta * (uy[x, y+1, z] - uy[x, y-1, z]) + 16 | gamma * (uz[x, y, z+1] - uz[x, y, z-1]); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/divergence-float.stc: -------------------------------------------------------------------------------- 1 | stencil divergence 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation ( 7 | float grid u(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 8 | const float grid ux(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 9 | const float grid uy(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 10 | const float grid uz(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 11 | float param alpha, float param beta, float param gamma) 12 | { 13 | u[x, y, z; t] = 14 | alpha * (ux[x+1, y, z] - ux[x-1, y, z]) + 15 | beta * (uy[x, y+1, z] - uy[x, y-1, z]) + 16 | gamma * (uz[x, y, z+1] - uz[x, y, z-1]); 17 | } 18 | } -------------------------------------------------------------------------------- /examples/edge.stc: -------------------------------------------------------------------------------- 1 | stencil edge 2 | { 3 | domainsize = (1 .. width, 1 .. height); 4 | t_max = 1; 5 | 6 | operation (float grid u) 7 | { 8 | u[x, y; t+1] = 9 | -12 * u[x, y; t] + 10 | 2 *(u[x - 1, y; t] + u[x + 1, y; t] + u[x, y - 1; t] + u[x, y + 1; t]) + 11 | u[x - 1, y - 1; t] + u[x + 1, y - 1; t] + u[x - 1, y + 1; t] + u[x + 1, y + 1; t]; 12 | } 13 | } -------------------------------------------------------------------------------- /examples/fdtdE2D.stc: -------------------------------------------------------------------------------- 1 | stencil fdtdE2D 2 | { 3 | domainsize = (2 .. x_max-1, 2 .. y_max-1); 4 | t_max = 1; 5 | 6 | operation ( 7 | float grid e(1 .. x_max, 1 .. y_max)[2], 8 | const float grid h(1 .. x_max, 1 .. y_max), 9 | float param ca, float param cb 10 | ) 11 | // const float grid ca(1 .. x_max, 1 .. y_max), 12 | // const float grid cb(1 .. x_max, 1 .. y_max))//, float param dt) 13 | { 14 | // e[x, y; t+1; 0] = ca[x, y] * e[x, y; t; 0] + cb[x, y] * (h[x, y+1] - h[x, y]); 15 | // e[x, y; t+1; 1] = ca[x, y] * e[x, y; t; 1] - cb[x, y] * (h[x+1, y] - h[x, y]); 16 | e[x, y; t+1; 0] = ca * e[x, y; t; 0] + cb * (h[x, y+1] - h[x, y]); 17 | e[x, y; t+1; 1] = ca * e[x, y; t; 1] - cb * (h[x+1, y] - h[x, y]); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/game-of-life.stc: -------------------------------------------------------------------------------- 1 | stencil game_of_life 2 | { 3 | domainsize = (1 .. width, 1 .. height); 4 | t_max = 100; 5 | 6 | operation (float grid u) 7 | { 8 | // some large number 9 | float C = 100000000000000000000; 10 | 11 | // count the number of live neighbors 12 | float L = u[x - 1, y - 1; t] + u[x, y - 1; t] + u[x + 1, y - 1; t] + 13 | u[x - 1, y ; t] + u[x + 1, y ; t] + 14 | u[x - 1, y + 1; t] + u[x, y + 1; t] + u[x + 1, y + 1; t]; 15 | 16 | // apply the rules 17 | u[x, y; t+1] = 1 / (1 + (u[x, y; t] + L - 3) * (L - 3) * C); 18 | } 19 | } -------------------------------------------------------------------------------- /examples/gradient-double.stc: -------------------------------------------------------------------------------- 1 | stencil gradient 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation ( 7 | const double grid u(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 8 | double grid ux(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 9 | double grid uy(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 10 | double grid uz(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 11 | double param alpha, double param beta, double param gamma) 12 | { 13 | ux[x, y, z; t] = alpha * (u[x+1, y, z] - u[x-1, y, z]); 14 | uy[x, y, z; t] = beta * (u[x, y+1, z] - u[x, y-1, z]); 15 | uz[x, y, z; t] = gamma * (u[x, y, z+1] - u[x, y, z-1]); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/gradient-float.stc: -------------------------------------------------------------------------------- 1 | stencil gradient 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation ( 7 | const float grid u(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 8 | float grid ux(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 9 | float grid uy(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 10 | float grid uz(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 11 | float param alpha, float param beta, float param gamma) 12 | { 13 | ux[x, y, z; t] = alpha * (u[x+1, y, z] - u[x-1, y, z]); 14 | uy[x, y, z; t] = beta * (u[x, y+1, z] - u[x, y-1, z]); 15 | uz[x, y, z; t] = gamma * (u[x, y, z+1] - u[x, y, z-1]); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/heat3d.stc: -------------------------------------------------------------------------------- 1 | stencil Heat3D (double grid A(0 .. N+1, 0 .. N+1, 0 .. N+1)) 2 | { 3 | domainsize = (1 .. N, 1 .. N, 1 .. N); 4 | 5 | operation 6 | { 7 | A[x, y, z; t+1] = 8 | 0.125 * (A[x, y, z+1; t] - 2.0 * A[x, y, z; t] + A[x, y, z-1; t]) + 9 | 0.125 * (A[x, y+1, z; t] - 2.0 * A[x, y, z; t] + A[x, y-1, z; t]) + 10 | 0.125 * (A[x+1, y, z; t] - 2.0 * A[x, y, z; t] + A[x-1, y, z; t]) + 11 | A[x, y, z; t]; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/himeno-2.stc: -------------------------------------------------------------------------------- 1 | /** 2 | * The Himeno benchmark, "a linear solver of pressure Poisson using a point-Jacobi method." 3 | * http://www.phoronix-test-suite.com/benchmark-files/himenobmtxpa.tar.bz2 4 | */ 5 | stencil himeno ( 6 | float grid p, 7 | const float grid a[4], 8 | const float grid b[3], 9 | const float grid c[3], 10 | const float grid wrk1, 11 | const float grid bnd, 12 | float param omega, 13 | float result gosa) 14 | { 15 | domainsize (1..x_max, 1..y_max, 1..z_max); 16 | iterate while t < 100; 17 | 18 | initial 19 | { 20 | p[x, y, z; 0] = x^2 / x_max^2; 21 | a[x, y, z; 0] = 1; 22 | a[x, y, z; 1] = 1; 23 | a[x, y, z; 2] = 1; 24 | a[x, y, z; 3] = 1/6; 25 | b[x, y, z; 0] = 0; 26 | b[x, y, z; 1] = 0; 27 | b[x, y, z; 2] = 0; 28 | c[x, y, z; 0] = 1; 29 | c[x, y, z; 1] = 1; 30 | c[x, y, z; 2] = 1; 31 | wrk1[x, y, z] = 0; 32 | bnd[x, y, z] = 1; 33 | } 34 | 35 | operation 36 | { 37 | float s0 = 38 | a[x, y, z; 0] * p[x+1, y, z; t] + 39 | a[x, y, z; 1] * p[x, y+1, z; t] + 40 | a[x, y, z; 2] * p[x, y, z+1; t] + 41 | // b[x, y, z; 0] * (p[x+1, y+1, z; t] - p[x+1, y-1, z; t] - p[x-1, y+1, z; t] + p[x-1, y-1, z; t]) + 42 | b[x, y, z; 0] * ({ i=-1..1, j=-1..1 : abs(i)+abs(j)=2 } sum ((-1)^(i*j) * p[x+i, y+j, z; t])) + 43 | b[x, y, z; 1] * (p[x, y+1, z+1; t] - p[x, y-1, z+1; t] - p[x, y+1, z-1; t] + p[x, y-1, z-1; t]) + 44 | b[x, y, z; 2] * (p[x+1, y, z+1; t] - p[x-1, y, z+1; t] - p[x+1, y, z-1; t] + p[x-1, y, z-1; t]) + 45 | c[x, y, z; 0] * p[x-1, y, z; t] + 46 | c[x, y, z; 1] * p[x, y-1, z; t] + 47 | c[x, y, z; 2] * p[x, y, z-1; t] + 48 | wrk1[x, y, z]; 49 | 50 | float ss = (s0 * a[x, y, z; 3] - p[x, y, z; t]) * bnd[x, y, z]; 51 | gosa = sum (ss^2); 52 | p[x, y, z; t+1] = p[x, y, z; t] + omega * ss; 53 | } 54 | } -------------------------------------------------------------------------------- /examples/laplacian-double.stc: -------------------------------------------------------------------------------- 1 | stencil laplacian 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation (double grid u, double param alpha, double param beta) 7 | { 8 | u[x, y, z; t+1] = 9 | alpha * u[x, y, z; t] + 10 | beta * ( 11 | u[x+1, y, z; t] + u[x-1, y, z; t] + 12 | u[x, y+1, z; t] + u[x, y-1, z; t] + 13 | u[x, y, z+1; t] + u[x, y, z-1; t] 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/laplacian-float.stc: -------------------------------------------------------------------------------- 1 | stencil laplacian 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation (float grid u, float param alpha, float param beta) 7 | { 8 | u[x, y, z; t+1] = 9 | alpha * u[x, y, z; t] + 10 | beta * ( 11 | u[x+1, y, z; t] + u[x-1, y, z; t] + 12 | u[x, y+1, z; t] + u[x, y-1, z; t] + 13 | u[x, y, z+1; t] + u[x, y, z-1; t] 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/laplacian-gsrb-float.stc: -------------------------------------------------------------------------------- 1 | stencil laplacian_gsrb (float grid u, float param alpha, float param beta) 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | 5 | operation 6 | { 7 | u[x, y, z; t+1] = 8 | (alpha + 4 * beta^2) * u[x, y, z; t] + 9 | alpha * beta * ( 10 | u[x+1, y, z; t] + u[x-1, y, z; t] + 11 | u[x, y+1, z; t] + u[x, y-1, z; t] + 12 | u[x, y, z+1; t] + u[x, y, z-1; t] 13 | ) + 14 | beta^2 * ( 15 | u[x+2, y, z; t] + 16 | u[x+1, y+1, z; t] + u[x+1, y, z+1; t] + u[x+1, y, z-1; t] + u[x+1, y-1, z; t] + 17 | u[x, y+2, z; t] + u[x, y+1, z+1; t] + u[x, y+1, z-1; t] + u[x, y, z+2; t] + u[x, y, z-2; t] + u[x, y-1, z+1; t] + u[x, y-1, z-1; t] + u[x, y-2, z; t] + 18 | u[x-1, y+1, z; t] + u[x-1, y, z+1; t] + u[x-1, y, z-1; t] + u[x-1, y-1, z; t] + 19 | u[x-2, y, z; t] 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/patus_stencil.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Patus / Stencil Specification 3 | " Maintainer: Matthias Christen 4 | " Latest Revision: 22 August 2012 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | " Keywords 11 | syn keyword ssKeywords stencil domainsize operation boundaries initial grid param 12 | syn match ssKeywords "iterate\s\+while" 13 | syn keyword ssTypes float double 14 | "syn match ssOperator "[\+\-\*\/\^\<\>\=]" 15 | syn region ssComment start="/\*" end="\*/" 16 | syn region ssCommentL start="//" skip="\\$" end="$" keepend 17 | 18 | syn match ssNumber "π" 19 | "integer number, or floating point number without a dot and with "f". 20 | syn case ignore 21 | syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat 22 | syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" 23 | syn match cFloat display contained "\d\+f" 24 | "floating point number, with dot, optional exponent 25 | syn match cFloat display contained "\d\+\.\d\+\(e[-+]\=\d\+\)\=[fl]\=" 26 | "floating point number, starting with a dot, optional exponent 27 | syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 28 | " Avoid highlighting '..' 29 | syn match cNone display "\.\{2}" 30 | "floating point number, without dot, with exponent 31 | syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" 32 | 33 | syn region ssSubscript start="\[" end="\]" 34 | 35 | 36 | let b:current_syntax = "patus-stencil" 37 | 38 | hi def link ssKeywords Statement 39 | hi def link ssTypes Type 40 | hi def link ssOperator Operator 41 | hi def link ssComment Comment 42 | hi def link ssCommentL Comment 43 | hi def link ssNumber Number 44 | hi def link cNumber Number 45 | hi def link cFloat Number 46 | hi def link ssSubscript Structure 47 | -------------------------------------------------------------------------------- /examples/simple.stc: -------------------------------------------------------------------------------- 1 | stencil wave ( 2 | float grid U(0 .. x_max-1)) 3 | { 4 | iterate while t < 5; 5 | domainsize = (2 .. x_max-3); 6 | 7 | initial 8 | { 9 | 10 | U[x; 0] = 1; 11 | U[x; 1] = 0; 12 | } 13 | 14 | operation 15 | { 16 | U[x; t+1] = U[x-1; t] + U[x; t] + U[x+1; t]; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/tricubic-float-2.stc: -------------------------------------------------------------------------------- 1 | stencil tricubic ( 2 | float grid U(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2), 3 | const float grid a(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2), 4 | const float grid b(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2), 5 | const float grid c(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2)) 6 | { 7 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 8 | 9 | operation 10 | { 11 | float wa[-1..2] = { 12 | 1.0/6.0 * a[x,y,z] * (a[x,y,z]+1.0) * (a[x,y,z]+2.0), 13 | -0.5 * (a[x,y,z]-1.0) * (a[x,y,z]+1.0) * (a[x,y,z]+2.0), 14 | 0.5 * (a[x,y,z]-1.0) * a[x,y,z] * (a[x,y,z]+2.0), 15 | -1.0/6.0 * (a[x,y,z]-1.0) * a[x,y,z] * (a[x,y,z]+1.0) 16 | }; 17 | 18 | float wb[-1..2] = { 19 | 1.0/6.0 * b[x,y,z] * (b[x,y,z]+1.0) * (b[x,y,z]+2.0), 20 | -0.5 * (b[x,y,z]-1.0) * (b[x,y,z]+1.0) * (b[x,y,z]+2.0), 21 | 0.5 * (b[x,y,z]-1.0) * b[x,y,z] * (b[x,y,z]+2.0), 22 | -1.0/6.0 * (b[x,y,z]-1.0) * b[x,y,z] * (b[x,y,z]+1.0) 23 | }; 24 | 25 | float wc[-1..2] = { 26 | 1.0/6.0 * c[x,y,z] * (c[x,y,z]+1.0) * (c[x,y,z]+2.0), 27 | -0.5 * (c[x,y,z]-1.0) * (c[x,y,z]+1.0) * (c[x,y,z]+2.0), 28 | 0.5 * (c[x,y,z]-1.0) * c[x,y,z] * (c[x,y,z]+2.0), 29 | -1.0/6.0 * (c[x,y,z]-1.0) * c[x,y,z] * (c[x,y,z]+1.0) 30 | }; 31 | 32 | U[x, y, z; t+1] = { i=-1..2, j=-1..2, k=-1..2 } sum (wa[i] * wb[j] * wc[k] * U[x+i, y+j, z+k; t]); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/trigonometric-float.stc: -------------------------------------------------------------------------------- 1 | stencil laplacian 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation (float grid u, float param alpha, float param beta) 7 | { 8 | u[x, y, z; t+1] = 9 | sin (alpha * u[x, y, z; t]) + 10 | beta * ( 11 | u[x+1, y, z; t] + u[x-1, y, z; t] + 12 | u[x, y+1, z; t] + u[x, y-1, z; t] + 13 | u[x, y, z+1; t] + u[x, y, z-1; t] 14 | ); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /examples/upstream-double.stc: -------------------------------------------------------------------------------- 1 | stencil upstream 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation (double grid u, double param a) 7 | { 8 | u[x, y, z; t+1] = a * ( 9 | -2 * (u[x-3, y, z; t] + u[x, y-3, z; t] + u[x, y, z-3; t]) + 10 | 15 * (u[x-2, y, z; t] + u[x, y-2, z; t] + u[x, y, z-2; t]) + 11 | -60 * (u[x-1, y, z; t] + u[x, y-1, z; t] + u[x, y, z-1; t]) + 12 | 20 * u[x, y, z; t] + 13 | 30 * (u[x+1, y, z; t] + u[x, y+1, z; t] + u[x, y, z+1; t]) + 14 | -3 * (u[x+2, y, z; t] + u[x, y+2, z; t] + u[x, y, z+2; t]) 15 | ); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/upstream-float.stc: -------------------------------------------------------------------------------- 1 | stencil upstream 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation (float grid u, float param a) 7 | { 8 | u[x, y, z; t+1] = a * ( 9 | -2 * (u[x-3, y, z; t] + u[x, y-3, z; t] + u[x, y, z-3; t]) + 10 | 15 * (u[x-2, y, z; t] + u[x, y-2, z; t] + u[x, y, z-2; t]) + 11 | -60 * (u[x-1, y, z; t] + u[x, y-1, z; t] + u[x, y, z-1; t]) + 12 | 20 * u[x, y, z; t] + 13 | 30 * (u[x+1, y, z; t] + u[x, y+1, z; t] + u[x, y, z+1; t]) + 14 | -3 * (u[x+2, y, z; t] + u[x, y+2, z; t] + u[x, y, z+2; t]) 15 | ); 16 | } 17 | } -------------------------------------------------------------------------------- /examples/uxx1.stc: -------------------------------------------------------------------------------- 1 | stencil uxx1 ( 2 | const float grid d1(-1 .. g_nxt+2, -1 .. g_nyt+2, -1 .. g_nzt+2), 3 | float grid u1(-1 .. g_nxt+2, -1 .. g_nyt+2, -1 .. g_nzt+2), 4 | const float grid xx(-1 .. g_nxt+2, -1 .. g_nyt+2, -1 .. g_nzt+2), 5 | const float grid xy(-1 .. g_nxt+2, -1 .. g_nyt+2, -1 .. g_nzt+2), 6 | const float grid xz(-1 .. g_nxt+2, -1 .. g_nyt+2, -1 .. g_nzt+2), 7 | float param dth) 8 | { 9 | domainsize = (nxb .. nxe, nyb .. nye, nzb .. nze); 10 | 11 | operation 12 | { 13 | float c1 = 9./8.; 14 | float c2 = -1./24.; 15 | 16 | float d = 0.25 * (d1[x,y,z] + d1[x,y-1,z] + d1[x,y,z-1] + d1[x,y-1,z-1]); 17 | u1[x,y,z; t+1] = u1[x,y,z; t] + (dth / d) * ( 18 | c1 * ( 19 | xx[x, y,z] - xx[x-1,y,z] + 20 | xy[x,y, z] - xy[x,y-1,z] + 21 | xz[x,y,z ] - xz[x,y,z-1]) + 22 | 23 | c2 * ( 24 | xx[x+1,y,z] - xx[x-2,y,z] + 25 | xy[x,y+1,z] - xy[x,y-2,z] + 26 | xz[x,y,z+1] - xz[x,y,z-2]) 27 | ); 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /examples/wave-1.stc: -------------------------------------------------------------------------------- 1 | stencil wave ( 2 | float grid U(0 .. x_max-1, 0 .. y_max-1, 0 .. z_max-1), 3 | float param fMin = -1, 4 | float param fDX = 2 / (x_max-3), 5 | float param fDT_DX_sq = 0.25) 6 | { 7 | iterate while t < 5; 8 | domainsize = (2 .. x_max-3, 2 .. y_max-3, 2 .. z_max-3); 9 | 10 | initial 11 | { 12 | U[x, y, z; -1] = sinf (2*π * ((x-1) * fDX + fMin)) * sinf (2*π * ((y-1) * fDX + fMin)) * sinf (2*π * ((z-1) * fDX + fMin)); 13 | U[x, y, z; -1 : x==0 || y==0 || z==0 || x==x_max-1 || y==y_max-1 || z==z_max-1 ] = 0; 14 | U[x, y, z; 0] = U[x, y, z; -1]; 15 | U[x, y, z; 1] = 0; 16 | } 17 | 18 | operation 19 | { 20 | float c1 = 2 - 15/2 * fDT_DX_sq; 21 | float c2 = 4/3 * fDT_DX_sq; 22 | float c3 = -1/12 * fDT_DX_sq; 23 | 24 | U[x, y, z; t+1] = c1 * U[x, y, z; t] - U[x, y, z; t-1] + 25 | c2 * (U[x+1, y, z; t] + U[x-1, y, z; t] + U[x, y+1, z; t] + U[x, y-1, z; t] + U[x, y, z+1; t] + U[x, y, z-1; t]) + 26 | c3 * (U[x+2, y, z; t] + U[x-2, y, z; t] + U[x, y+2, z; t] + U[x, y-2, z; t] + U[x, y, z+2; t] + U[x, y, z-2; t]); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/wave-double.stc: -------------------------------------------------------------------------------- 1 | stencil wave 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | t_max = 1; 5 | 6 | operation (double grid u, double param dt_dx_sq) 7 | { 8 | u[x, y, z; t+1] = 2 * u[x, y, z; t] - u[x, y, z; t-1] + 9 | dt_dx_sq * ( 10 | -15/2 * u[x, y, z; t] + 11 | 4/3 * ( 12 | u[x+1, y, z; t] + u[x-1, y, z; t] + 13 | u[x, y+1, z; t] + u[x, y-1, z; t] + 14 | u[x, y, z+1; t] + u[x, y, z-1; t] 15 | ) 16 | -1/12 * ( 17 | u[x+2, y, z; t] + u[x-2, y, z; t] + 18 | u[x, y+2, z; t] + u[x, y-2, z; t] + 19 | u[x, y, z+2; t] + u[x, y, z-2; t] 20 | ) 21 | ); 22 | } 23 | } -------------------------------------------------------------------------------- /examples/wave-float.stc: -------------------------------------------------------------------------------- 1 | stencil wave 2 | { 3 | //domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | domainsize = (2 .. x_max-3, 2 .. y_max-3, 2 .. z_max-3); 5 | t_max = 1; 6 | 7 | operation (float grid u(0 .. x_max-1, 0 .. y_max-1, 0 .. z_max-1), float param dt_dx_sq) 8 | { 9 | /* 10 | u[x, y, z; t+1] = 2 * u[x, y, z; t] - u[x, y, z; t-1] + 11 | dt_dx_sq * ( 12 | -15/2 * u[x, y, z; t] + 13 | 4/3 * ( 14 | u[x+1, y, z; t] + u[x-1, y, z; t] + 15 | u[x, y+1, z; t] + u[x, y-1, z; t] + 16 | u[x, y, z+1; t] + u[x, y, z-1; t] 17 | ) 18 | -1/12 * ( 19 | u[x+2, y, z; t] + u[x-2, y, z; t] + 20 | u[x, y+2, z; t] + u[x, y-2, z; t] + 21 | u[x, y, z+2; t] + u[x, y, z-2; t] 22 | ) 23 | ); 24 | */ 25 | 26 | float c1 = 2 - 15/2 * dt_dx_sq; 27 | float c2 = 4/3 * dt_dx_sq; 28 | float c3 = -1/12 * dt_dx_sq; 29 | 30 | u[x, y, z; t+1] = c1 * u[x, y, z; t] - u[x, y, z; t-1] + 31 | c2 * ( 32 | u[x+1, y, z; t] + u[x-1, y, z; t] + 33 | u[x, y+1, z; t] + u[x, y-1, z; t] + 34 | u[x, y, z+1; t] + u[x, y, z-1; t] 35 | ) + 36 | c3 * ( 37 | u[x+2, y, z; t] + u[x-2, y, z; t] + 38 | u[x, y+2, z; t] + u[x, y-2, z; t] + 39 | u[x, y, z+2; t] + u[x, y, z-2; t] 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/whispering.stc: -------------------------------------------------------------------------------- 1 | stencil whispering_gallery ( 2 | float grid e(1 .. x_max, 1 .. y_max)[2], 3 | float grid h(1 .. x_max, 1 .. y_max), 4 | float grid u_em(1 .. x_max, 1 .. y_max), 5 | const float grid ca(1 .. x_max, 1 .. y_max), 6 | const float grid cb(1 .. x_max, 1 .. y_max), 7 | const float grid da(1 .. x_max, 1 .. y_max), 8 | const float grid db(1 .. x_max, 1 .. y_max), 9 | float param MU, float param EPSILON 10 | ) 11 | { 12 | domainsize = (2 .. x_max-1, 2 .. y_max-1); 13 | 14 | operation 15 | { 16 | float e0 = ca[x, y] * e[x, y; t; 0] + cb[x, y] * (h[x, y+1; t] - h[x, y; t]); 17 | float e1 = ca[x, y] * e[x, y; t; 1] - cb[x, y] * (h[x+1, y; t] - h[x, y; t]); 18 | 19 | // e[x, y-1; t+1; 0] 20 | float ey = ca[x, y-1] * e[x, y-1; t; 0] + cb[x, y-1] * (h[x, y; t] - h[x, y-1; t]); 21 | 22 | // e[x-1, y; t+1; 1] 23 | float ex = ca[x-1, y] * e[x-1, y; t; 1] - cb[x-1, y] * (h[x, y; t] - h[x-1, y; t]); 24 | 25 | e[x, y; t+1; 0] = e0; 26 | e[x, y; t+1; 1] = e1; 27 | 28 | float h1 = da[x, y] * h[x, y; t] + db[x, y] * (e0 - ey + ex - e1); 29 | h[x, y; t+1] = h1; 30 | 31 | u_em[x, y; t+1] = u_em[x, y; t] + 0.5 * (h1^2 / MU + EPSILON * (e0^2 + e1^2)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/TableLayout.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/lib/TableLayout.jar -------------------------------------------------------------------------------- /lib/jgap.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/lib/jgap.jar -------------------------------------------------------------------------------- /lib/log4j-1.2.16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/lib/log4j-1.2.16.jar -------------------------------------------------------------------------------- /release/0.1/Patus/arch/CPU_OpenMP/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = gcc 9 | CFLAGS = -O3 -g -msse2 -fopenmp -I. 10 | 11 | 12 | bench: kernel.o driver.o ssemathlib.o $(PATUS_RUNTIME_OBJECT_FILES) 13 | $(CC) $(CFLAGS) -o $@ $+ -lm 14 | 15 | %.o: %.c 16 | $(CC) $(CFLAGS) -c -o $@ $< 17 | 18 | tune: 19 | $(PATUS_TEST_NONAUTOTUNE_EXE_PARAMS) 20 | $(PATUS_AUTOTUNER) bench $(PATUS_EXE_PARAMS) | tee `date +tune_%F_%H.%M.%S.txt` 21 | 22 | plot: 23 | for f in *.data; do echo "set term png; set view map; splot \"$$f\" matrix with image" | gnuplot > $${f%.data}.png; done 24 | 25 | clean: 26 | rm -rf *.o bench 27 | -------------------------------------------------------------------------------- /release/0.1/Patus/arch/CPU_OpenMP/ssereductions.c: -------------------------------------------------------------------------------- 1 | #include "ssereductions.c" 2 | 3 | 4 | -------------------------------------------------------------------------------- /release/0.1/Patus/arch/CPU_OpenMP/ssereductions.h: -------------------------------------------------------------------------------- 1 | #ifndef __SSE_REDUCTIONS_H__ 2 | #define __SSE_REDUCTIONS_H__ 3 | 4 | #include "xmmintrin.h" 5 | #include "emmintrin.h" 6 | 7 | inline float vec_reduce_sum_ps (__m128 v) 8 | { 9 | } 10 | 11 | inline float vec_reduce_product_ps (__m128 v) 12 | { 13 | } 14 | 15 | inline float vec_reduce_min_ps (__m128 v) 16 | { 17 | } 18 | 19 | inline float vec_reduce_max_ps (__m128 v) 20 | { 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /release/0.1/Patus/arch/CPU_OpenMP_AVX/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = gcc 9 | CFLAGS = -O3 -g -mavx -fopenmp -I. 10 | 11 | 12 | bench: kernel.o driver.o $(PATUS_RUNTIME_OBJECT_FILES) 13 | $(CC) $(CFLAGS) -o $@ $+ -lm 14 | 15 | %.o: %.c 16 | $(CC) $(CFLAGS) -c -o $@ $< 17 | 18 | tune: 19 | $(PATUS_TEST_NONAUTOTUNE_EXE_PARAMS) 20 | $(PATUS_AUTOTUNER) bench $(PATUS_EXE_PARAMS) | tee `date +tune_%F_%H.%M.%S.txt` 21 | 22 | plot: 23 | for f in *.data; do echo "set term png; set view map; splot \"$$f\" matrix with image" | gnuplot > $${f%.data}.png; done 24 | 25 | clean: 26 | rm -rf *.o bench 27 | -------------------------------------------------------------------------------- /release/0.1/Patus/arch/CPU_OpenMP_AVX/avxmathlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __AVX_MATH_LIB_H__ 2 | #define __AVX_MATH_LIB_H__ 3 | 4 | #include "immintrin.h" 5 | 6 | 7 | #ifdef _MSC_VER /* Visual C++ */ 8 | # define AVX_ALIGN32_BEG __declspec(align(32)) 9 | # define AVX_ALIGN32_END 10 | #else /* gcc or icc */ 11 | # define AVX_ALIGN32_BEG 12 | # define AVX_ALIGN32_END __attribute__((aligned(32))) 13 | #endif 14 | 15 | #define AVX_DECLARE_INT_CONST(Name, Val) \ 16 | static const AVX_ALIGN32_BEG int Name##_PI32_[8] AVX_ALIGN32_END = { Val, Val, Val, Val, Val, Val, Val, Val }; 17 | #define AVX_DECLARE_LONG_CONST(Name, Val1, Val2) \ 18 | static const AVX_ALIGN32_BEG int Name##_PI32_[8] AVX_ALIGN32_END = { Val1, Val2, Val1, Val2, Val1, Val2, Val1, Val2 }; 19 | 20 | AVX_DECLARE_INT_CONST(AVX_SIGN_MASK_SINGLE, 0x80000000) 21 | #define AVX_SIGN_MASK_SINGLE *(__m256i*) AVX_SIGN_MASK_SINGLE_PI32_ 22 | AVX_DECLARE_LONG_CONST(AVX_SIGN_MASK_DOUBLE, 0x00000000, 0x80000000) 23 | #define AVX_SIGN_MASK_DOUBLE *(__m256i*) AVX_SIGN_MASK_DOUBLE_PI32_ 24 | 25 | #define _mm256_load1_ps(x) _mm256_set_ps(x, x, x, x, x, x, x, x) 26 | #define _mm256_load1_pd(x) _mm256_set_pd(x, x, x, x) 27 | 28 | #define _mm256_neg_ps(x) _mm256_xor_ps (x, (__m256) AVX_SIGN_MASK_SINGLE) 29 | #define _mm256_neg_pd(x) _mm256_xor_pd (x, (__m256d) AVX_SIGN_MASK_DOUBLE) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /release/0.1/Patus/arch/CPU_OpenMP_AVX/avxreductions.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/Patus/arch/CPU_OpenMP_AVX/avxreductions.c -------------------------------------------------------------------------------- /release/0.1/Patus/arch/GPU_CUDA/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for Patus stencil benchmark 3 | # 4 | # Note: $(PATUS_*) variables will be automatically replaced by the 5 | # required runtime files by Patus. 6 | # 7 | 8 | CC = nvcc 9 | NVCCFLAGS = -O3 -arch=sm_13 -I$(HOME)/NVIDIA_GPU_Computing_SDK/C/common/inc 10 | 11 | bench: kernel.cu driver.cu $(PATUS_RUNTIME_FILES) 12 | $(CC) $(NVCCFLAGS) -o $@ $+ 13 | 14 | clean: 15 | rm -rf *.o bench -------------------------------------------------------------------------------- /release/0.1/Patus/bin/patus.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/Patus/bin/patus.jar -------------------------------------------------------------------------------- /release/0.1/Patus/etc/gedit/README: -------------------------------------------------------------------------------- 1 | Patus Syntax Highlighting for gedit 2 | 3 | Copy the files 4 | stc.lang 5 | stg.lang 6 | into $HOME/.local/share/gtksourceview-3.0/language-specs 7 | -------------------------------------------------------------------------------- /release/0.1/Patus/etc/vi/README: -------------------------------------------------------------------------------- 1 | Patus Syntax Highlighting for vim 2 | 3 | Copy the files 4 | patus_stencil.vim 5 | patus_strategy.vim 6 | into $HOME/.vim/syntax 7 | and 8 | patus_filetypes.vim 9 | into $HOME/.vim/ftdetect -------------------------------------------------------------------------------- /release/0.1/Patus/etc/vi/patus-filetypes.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.stc set filetype=patus_stencil 2 | au BufRead,BufNewFile *.stg set filetype=patus_strategy 3 | -------------------------------------------------------------------------------- /release/0.1/Patus/etc/vi/patus_stencil.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Patus / Stencil Specification 3 | " Maintainer: Matthias Christen 4 | " Latest Revision: 22 August 2012 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | " Keywords 11 | syn keyword ssKeywords stencil domainsize operation boundaries initial sum product min max 12 | syn match ssKeywords "iterate\s\+while" 13 | syn keyword ssTypes float double grid param result const 14 | syn match ssOperator "[\+\-\*\/\^\<\>\=]" 15 | syn region ssComment start="/\*" end="\*/" 16 | syn region ssCommentL start="//" skip="\\$" end="$" keepend 17 | 18 | syn match ssNumber "π" 19 | "integer number, or floating point number without a dot and with "f". 20 | syn case ignore 21 | syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat 22 | syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" 23 | syn match cFloat display contained "\d\+f" 24 | "floating point number, with dot, optional exponent 25 | syn match cFloat display contained "\d\+\.\d\+\(e[-+]\=\d\+\)\=[fl]\=" 26 | "floating point number, starting with a dot, optional exponent 27 | syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 28 | " Avoid highlighting '..' 29 | syn match cNone display "\.\{2}" 30 | "floating point number, without dot, with exponent 31 | syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" 32 | 33 | syn region ssSubscript start="\[" end="\]" 34 | 35 | 36 | let b:current_syntax = "patus-stencil" 37 | 38 | hi def link ssKeywords Statement 39 | hi def link ssTypes Type 40 | hi def link ssOperator Operator 41 | hi def link ssComment Comment 42 | hi def link ssCommentL Comment 43 | hi def link ssNumber Number 44 | hi def link cNumber Number 45 | hi def link cFloat Number 46 | hi def link ssSubscript Structure 47 | -------------------------------------------------------------------------------- /release/0.1/Patus/etc/vi/patus_strategy.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Patus / Stencil Specification 3 | " Maintainer: Matthias Christen 4 | " Latest Revision: 22 August 2012 5 | 6 | if exists("b:current_syntax") 7 | finish 8 | endif 9 | 10 | " Keywords 11 | syn keyword ssKeywords strategy domain subdomain plane point stencil for in parallel schedule 12 | syn keyword ssTypes auto int dim 13 | syn match ssOperator "[\+\-\*\/\^\<\>\=]" 14 | syn region ssComment start="/\*" end="\*/" 15 | syn region ssCommentL start="//" skip="\\$" end="$" keepend 16 | 17 | "integer number, or floating point number without a dot and with "f". 18 | syn case ignore 19 | syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat 20 | syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" 21 | syn match cFloat display contained "\d\+f" 22 | "floating point number, with dot, optional exponent 23 | syn match cFloat display contained "\d\+\.\d\+\(e[-+]\=\d\+\)\=[fl]\=" 24 | "floating point number, starting with a dot, optional exponent 25 | syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" 26 | " Avoid highlighting '..' 27 | syn match cNone display "\.\{2}" 28 | "floating point number, without dot, with exponent 29 | syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" 30 | 31 | syn region ssSubscript start="\[" end="\]" 32 | 33 | 34 | let b:current_syntax = "patus-strategy" 35 | 36 | hi def link ssKeywords Statement 37 | hi def link ssTypes Type 38 | hi def link ssOperator Operator 39 | hi def link ssComment Comment 40 | hi def link ssCommentL Comment 41 | hi def link ssNumber Number 42 | hi def link cNumber Number 43 | hi def link cFloat Number 44 | hi def link ssSubscript Structure 45 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/image-filter/Makefile: -------------------------------------------------------------------------------- 1 | # define the names of the input and the output images 2 | IMAGE_INPUT_FILE = hpc.png 3 | IMAGE_OUTPUT_FILE = hpc-filtered.png 4 | 5 | # the image viewer program used to display the result image 6 | IMAGE_VIEWER = eog 7 | 8 | 9 | # compiler optimization flags 10 | ifeq ($(DEBUG), 1) 11 | # default optimizations 12 | OPT_FLAGS = -O0 -g 13 | else 14 | # for debugging 15 | OPT_FLAGS = -O3 16 | endif 17 | 18 | 19 | # get the image dimensions 20 | # NOTE that the image width must be divisible by 8 21 | IMAGE_WIDTH = $(shell file $(IMAGE_INPUT_FILE) | egrep -o '[0-9]+' | sed -n '1,1p') 22 | IMAGE_HEIGHT = $(shell file $(IMAGE_INPUT_FILE) | egrep -o '[0-9]+' | sed -n '2,1p') 23 | 24 | 25 | # do everything 26 | all: show 27 | 28 | # run the program 29 | run: filter 30 | ./filter $(IMAGE_INPUT_FILE) $(IMAGE_OUTPUT_FILE) 31 | 32 | # display the image 33 | show: $(IMAGE_OUTPUT_FILE) 34 | $(IMAGE_VIEWER) $< & 35 | 36 | 37 | # ---- build ---- 38 | 39 | filter: pngfilter.c gen/kernel.c 40 | gcc -mavx $(OPT_FLAGS) -fopenmp $+ -lpng -o $@ 41 | 42 | gen/kernel.c: filter.stc 43 | patus --outdir=gen $< 44 | make -C gen 45 | make -C gen tune width=$(IMAGE_WIDTH) height=$(IMAGE_HEIGHT) 46 | 47 | $(IMAGE_OUTPUT_FILE): run 48 | 49 | 50 | # ---- clean up ---- 51 | 52 | clean: 53 | rm -f filter 54 | rm -rf gen 55 | rm -f $(IMAGE_OUTPUT_FILE) 56 | rm -f *~ 57 | 58 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/image-filter/README.txt: -------------------------------------------------------------------------------- 1 | This example takes an image and applies a filter, defined in the stencil specification filter.stc, to it. 2 | To build, libpng-dev needs to be installed on your system. 3 | (If it isn't installed, e.g. on Ubuntu, use "sudo apt-get install libpng-dev" to install it.) 4 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/image-filter/filter.stc: -------------------------------------------------------------------------------- 1 | stencil filter ( 2 | float grid r(1..width, 1..height), 3 | float grid g(1..width, 1..height), 4 | float grid b(1..width, 1..height)) 5 | { 6 | domainsize = (2 .. width-1, 2 .. height-1); 7 | 8 | operation 9 | { 10 | // some image filter examples 11 | 12 | /* 13 | r[x, y; t+1] = 8 + r[x-1, y-1; t] - r[x+1, y-1; t] + 2 * (r[x-1, y; t] - r[x+1, y; t]) + r[x-1, y+1; t] - r[x+1, y+1; t]; 14 | g[x, y; t+1] = 32 + g[x-1, y-1; t] - g[x+1, y-1; t] + 2 * (g[x-1, y; t] - g[x+1, y; t]) + g[x-1, y+1; t] - g[x+1, y+1; t]; 15 | b[x, y; t+1] = 128 + b[x-1, y-1; t] - b[x+1, y-1; t] + 2 * (b[x-1, y; t] - b[x+1, y; t]) + b[x-1, y+1; t] - b[x+1, y+1; t]; 16 | */ 17 | 18 | r[x, y; t+1] = { i=-1..1, j=-1..1 } sum(g[x+i, y+j; t]); 19 | g[x, y; t+1] = { i=-1..1, j=-1..1 } sum(b[x+i, y+j; t]); 20 | b[x, y; t+1] = { i=-1..1, j=-1..1 } sum(r[x+i, y+j; t]); 21 | 22 | 23 | /* 24 | r[x, y; t+1] = 128 + 3 * (r[x-1, y-1; t] - r[x+1, y-1; t]) + 10 * (r[x-1, y; t] - r[x+1, y; t]) + 3 * (r[x-1, y+1; t] - r[x+1, y+1; t]); 25 | g[x, y; t+1] = 128 + 3 * (g[x-1, y-1; t] - g[x+1, y-1; t]) + 10 * (g[x-1, y; t] - g[x+1, y; t]) + 3 * (g[x-1, y+1; t] - g[x+1, y+1; t]); 26 | b[x, y; t+1] = 128 + 3 * (b[x-1, y-1; t] - b[x+1, y-1; t]) + 10 * (b[x-1, y; t] - b[x+1, y; t]) + 3 * (b[x-1, y+1; t] - b[x+1, y+1; t]); 27 | */ 28 | 29 | /* 30 | float c1[-1..1, -1..1] = {{-3, 0, 3}, {-10, 0, 10}, {-3, 0, 3}}; 31 | r[x, y; t+1] = { i=-1..1, j=-1..1 } sum(c1[i, j] * r[x+i, y+j; t]); 32 | g[x, y; t+1] = { i=-1..1, j=-1..1 } sum(c1[i, j] * g[x+i, y+j; t]); 33 | b[x, y; t+1] = { i=-1..1, j=-1..1 } sum(c1[i, j] * b[x+i, y+j; t]); 34 | */ 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/image-filter/hpc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/Patus/examples/applications/image-filter/hpc.png -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/wave/kernel.h: -------------------------------------------------------------------------------- 1 | void wave_parm(float * * U_0_1_out, float * U_0_m1, float * U_0_0, float * U_0_1, float dt_dx_square, int size, int cb_x, int cb_y, int cb_z, int chunk, int _unroll_p3); 2 | void wave(float * * U_0_1_out, float * U_0_m1, float * U_0_0, float * U_0_1, float dt_dx_square, int size); 3 | void initialize_wave_parm(float * U_0_m1, float * U_0_0, float * U_0_1, float dt_dx_square, int size, int cb_x, int cb_y, int cb_z, int chunk); 4 | void initialize_wave(float * U_0_m1, float * U_0_0, float * U_0_1, float dt_dx_square, int size); 5 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/wave/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef __WAVE_H__ 2 | #define __WAVE_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define min(a,b) ((a)<(b) ? (a) : (b)) 9 | 10 | #define IDX(i,j,k) ((i)+size*((j)+size*(k))) 11 | 12 | 13 | /** 14 | * Allocate data. 15 | * 16 | * ptr: A pointer to the array which will be allocated 17 | * ptr_aligned: A pointer which will contain the aligned address 18 | * x_max, y_max: The size of the grid 19 | */ 20 | void allocate(float** ptr, float** ptr_aligned, int x_max) 21 | { 22 | *ptr = (float*) malloc (x_max * x_max * x_max * sizeof (float) + 31); 23 | *ptr_aligned = (float*) (((uintptr_t) *ptr + 31) & (~((uintptr_t) 31))); 24 | } 25 | 26 | /** 27 | * Get current time in seconds. 28 | */ 29 | double seconds() 30 | { 31 | struct timeval tv; 32 | gettimeofday (&tv, NULL); 33 | return ((double) tv.tv_sec) + 1e-6 * tv.tv_usec; 34 | } 35 | 36 | /** 37 | * Write a cross section of the solution in u to a file. 38 | */ 39 | void write(float* u, int timestep, int size) 40 | { 41 | int i, j; 42 | char szFilename[255]; 43 | sprintf (szFilename, "%04d.txt", timestep); 44 | printf ("Writing file %s...\n", szFilename); 45 | FILE* file = fopen (szFilename, "w"); 46 | 47 | const int k = size / 3; 48 | for (j = 0; j < size; j++) 49 | { 50 | for (i = 0; i < size; i++) 51 | fprintf (file, "%f ", u[IDX(i,j,k)]); 52 | fprintf (file, "\n"); 53 | } 54 | 55 | fclose (file); 56 | } 57 | 58 | void initialize(float* u_m1, float* u_0, float* u_1, float min_x, float dx, int size); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/wave/visualize.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo "set zrange [-1:1]" > waves.gp 3 | echo "set cbrange [-1:1]" >> waves.gp 4 | echo "set pm3d" >> waves.gp 5 | for f in ????.txt 6 | do 7 | echo "splot \"$f\" matrix with pm3d" >> waves.gp 8 | done 9 | gnuplot waves.gp 10 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/whispering-gallery/WhisperingGallery.h: -------------------------------------------------------------------------------- 1 | #ifndef __WHISPERING_GALLERY_H__ 2 | #define __WHISPERING_GALLERY_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * Allocate data. 10 | * 11 | * ptr: A pointer to the array which will be allocated 12 | * ptr_aligned: A pointer which will contain the aligned address 13 | * x_max, y_max: The size of the grid 14 | */ 15 | void allocate(float** ptr, float** ptr_aligned, int x_max, int y_max) 16 | { 17 | *ptr = (float*) malloc (x_max * y_max * sizeof (float) + 31); 18 | *ptr_aligned = (float*) (((uintptr_t) *ptr + 31) & (~((uintptr_t) 31))); 19 | } 20 | 21 | /** 22 | * Returns the current time in microseconds. 23 | */ 24 | double gettime() 25 | { 26 | struct timeval tp; 27 | gettimeofday(&tp, NULL); 28 | return (double) tp.tv_sec + (double) tp.tv_usec * 1e-6; 29 | } 30 | 31 | /** 32 | * Write the time averaged solution to a text file. 33 | */ 34 | void write(float* u, int x_max, int y_max) 35 | { 36 | int i, j; 37 | FILE* file = fopen("output.txt", "w"); 38 | 39 | for (j = 0; j < y_max; j++) { 40 | for (i = 0; i < x_max; i++) 41 | fprintf (file, "%E ", (u[i + x_max * j])); 42 | fprintf (file, "\n"); 43 | } 44 | 45 | fclose (file); 46 | printf ("Data written to file output.txt.\n"); 47 | } 48 | 49 | 50 | float gaussianSource(float t); 51 | 52 | void write(float* u, int x_max, int y_max); 53 | 54 | float calculateCa(float sigma, float er); 55 | 56 | float calculateCb(float sigma, float er); 57 | 58 | float calculateDa(float sigma, float mur); 59 | 60 | float calculateDb(float sigma, float mur); 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/whispering-gallery/fdtdE2D.stc: -------------------------------------------------------------------------------- 1 | /** 2 | * Stencil specification for the E-field update. 3 | */ 4 | stencil fdtdE2D ( 5 | float grid e(1 .. x_max, 1 .. y_max)[2], 6 | const float grid h(1 .. x_max, 1 .. y_max), 7 | const float grid ca(1 .. x_max, 1 .. y_max), 8 | const float grid cb(1 .. x_max, 1 .. y_max), 9 | float param ca_vacuum, float param ca_material, 10 | float param cb_vacuum, float param cb_material) 11 | { 12 | domainsize = (2 .. x_max-1, 2 .. y_max-1); 13 | 14 | operation 15 | { 16 | e[x, y; t+1; 0] = ca[x, y] * e[x, y; t; 0] + 17 | cb[x, y] * (h[x, y+1] - h[x, y]); 18 | 19 | e[x, y; t+1; 1] = ca[x, y] * e[x, y; t; 1] - 20 | cb[x, y] * (h[x+1, y] - h[x, y]); 21 | } 22 | 23 | initial 24 | { 25 | e[x, y; 0; 0] = 0; 26 | e[x, y; 0; 1] = 0; 27 | 28 | ca[x, y] = ca_vacuum; 29 | cb[x, y] = cb_vacuum; 30 | ca[x, y : (x-x_max/2)^2 + (y-y_max/2)^2 >= (2*x_max/5)^2] = 31 | ca_material; 32 | cb[x, y : (x-x_max/2)^2 + (y-y_max/2)^2 >= (2*x_max/5)^2] = 33 | cb_material; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/whispering-gallery/fdtdH2D.stc: -------------------------------------------------------------------------------- 1 | /** 2 | * Stencil specification for the H-field update. 3 | */ 4 | stencil fdtdH2D ( 5 | const float grid e(1 .. x_max, 1 .. y_max)[2], 6 | float grid h(1 .. x_max, 1 .. y_max), 7 | const float grid da(1 .. x_max, 1 .. y_max), 8 | const float grid db(1 .. x_max, 1 .. y_max), 9 | float param da_vacuum, float param da_material, 10 | float param db_vacuum, float param db_material) 11 | { 12 | domainsize = (2 .. x_max-1, 2 .. y_max-1); 13 | 14 | operation 15 | { 16 | h[x, y; t+1] = da[x, y] * h[x, y; t] + 17 | db[x, y] * (e[x, y; 0] - e[x, y-1; 0] + e[x-1, y; 1] - e[x, y; 1]); 18 | } 19 | 20 | initial 21 | { 22 | h[x, y; 0] = 0; 23 | 24 | da[x, y] = da_vacuum; 25 | db[x, y] = db_vacuum; 26 | da[x, y : (x-x_max/2)^2 + (y-y_max/2)^2 >= (2*x_max/5)^2] = 27 | da_material; 28 | db[x, y : (x-x_max/2)^2 + (y-y_max/2)^2 >= (2*x_max/5)^2] = 29 | db_material; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/whispering-gallery/integrate.stc: -------------------------------------------------------------------------------- 1 | /** 2 | * Stencil specification integrating the energy density. 3 | */ 4 | stencil integrate ( 5 | const float grid e(1 .. x_max, 1 .. y_max)[2], 6 | const float grid h(1 .. x_max, 1 .. y_max), 7 | float grid u_em(1 .. x_max, 1 .. y_max), 8 | float param MU, float param EPSILON) 9 | { 10 | domainsize = (2 .. x_max-1, 2 .. y_max-1); 11 | 12 | operation 13 | { 14 | u_em[x, y; t+1] = u_em[x, y; t] + 15 | 0.5 * (h[x, y]^2 / MU + EPSILON * (e[x, y; 0]^2 + e[x, y; 1]^2)); 16 | } 17 | 18 | initial 19 | { 20 | u_em[x, y; 0] = 0; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/whispering-gallery/kernel.h: -------------------------------------------------------------------------------- 1 | void integrate_parm(float * * u_em_3_1_out, float * e_0_0, float * e_1_0, float * h_2_0, float * u_em_3_0, float * u_em_3_1, float MU, float EPSILON, int x_max, int y_max, int cb_x, int cb_y, int chunk, int _unroll_p3); 2 | void integrate(float * * u_em_3_1_out, float * e_0_0, float * e_1_0, float * h_2_0, float * u_em_3_0, float * u_em_3_1, float MU, float EPSILON, int x_max, int y_max); 3 | void initialize_integrate_parm(float * e_0_0, float * e_1_0, float * h_2_0, float * u_em_3_0, float * u_em_3_1, float MU, float EPSILON, int x_max, int y_max, int cb_x, int cb_y, int chunk); 4 | void initialize_integrate(float * e_0_0, float * e_1_0, float * h_2_0, float * u_em_3_0, float * u_em_3_1, float MU, float EPSILON, int x_max, int y_max); 5 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/applications/whispering-gallery/plot.gp: -------------------------------------------------------------------------------- 1 | unset key 2 | set terminal pdfcairo 3 | set output "output.pdf" 4 | set view map 5 | set size square 6 | set nocbtics 7 | set title "Time Averaged Electromagnetic Energy u" 8 | set xrange [ -0.5 : @PLOTSIZE@ ] noreverse nowriteback 9 | set yrange [ -0.5 : @PLOTSIZE@ ] noreverse nowriteback 10 | set cblabel "u_em" 11 | #set cbrange [ 0 : 1700 ] noreverse nowriteback 12 | set palette rgbformulae 33, 13, 10 13 | splot 'output.txt' matrix with image 14 | 15 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/Makefile: -------------------------------------------------------------------------------- 1 | TARGETS = blur divergence edge game-of-life gradient laplacian tricubic wave-1 wave-2 2 | 3 | ALT_ARCH = "x86_64 AVX" 4 | # or, if your CPU does not support AVX, use 5 | #ALT_ARCH = "x86_64 SSE" 6 | 7 | 8 | all: $(TARGETS) 9 | 10 | blur: blur.stc 11 | patus --outdir=$@ $< 12 | $(MAKE) -C $@ 13 | 14 | divergence: divergence.stc 15 | patus --outdir=$@ $< 16 | $(MAKE) -C $@ 17 | 18 | edge: edge.stc 19 | patus --outdir=$@ --architecture=$(ALT_ARCH) $< 20 | $(MAKE) -C $@ 21 | 22 | game-of-life: game-of-life.stc 23 | patus --outdir=$@ $< 24 | $(MAKE) -C $@ 25 | 26 | gradient: gradient.stc 27 | patus --outdir=$@ $< 28 | $(MAKE) -C $@ 29 | 30 | laplacian: laplacian.stc 31 | patus --outdir=$@ $< 32 | $(MAKE) -C $@ 33 | 34 | tricubic: tricubic.stc 35 | patus --outdir=$@ --architecture=$(ALT_ARCH) $< 36 | $(MAKE) -C $@ 37 | 38 | wave-1: wave-1.stc 39 | patus --outdir=$@ --validation-tolerance=1e-3 $< 40 | $(MAKE) -C $@ 41 | 42 | wave-2: wave-2.stc 43 | patus --outdir=$@ --validation-tolerance=1e-3 $< 44 | $(MAKE) -C $@ 45 | 46 | 47 | clean: 48 | rm -rf $(TARGETS) 49 | rm -rf out 50 | rm -f *~ 51 | 52 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/blur.stc: -------------------------------------------------------------------------------- 1 | stencil blur ( 2 | float grid U, 3 | float param s0 = expf( 0 * (1 / (2 * 2^2))), 4 | float param s1 = expf(-1 * (1 / (2 * 2^2))), 5 | float param s2 = expf(-2 * (1 / (2 * 2^2))), 6 | float param s4 = expf(-4 * (1 / (2 * 2^2))), 7 | float param s5 = expf(-5 * (1 / (2 * 2^2))), 8 | float param s8 = expf(-8 * (1 / (2 * 2^2)))) 9 | { 10 | domainsize = (1 .. width, 1 .. height); 11 | 12 | operation 13 | { 14 | float f = 1 / (s0 + 4 * (s1 + s2 + s4 + s8) + 8 * s5); 15 | 16 | U[x, y; t+1] = f * ( 17 | s0 * U[x, y; t] + 18 | s1 * (U[x-1, y; t] + U[x+1, y; t] + U[x, y-1; t] + U[x, y+1; t]) + 19 | s2 * (U[x-1, y-1; t] + U[x+1, y-1; t] + U[x-1, y+1; t] + U[x+1, y+1; t]) + 20 | s4 * (U[x-2, y; t] + U[x+2, y; t] + U[x, y-2; t] + U[x, y+2; t]) + 21 | s5 * ( 22 | U[x-2, y-1; t] + U[x-1, y-2; t] + U[x+1, y-2; t] + U[x+2, y-1; t] + 23 | U[x-2, y+1; t] + U[x-1, y+2; t] + U[x+1, y+2; t] + U[x+2, y+1; t] 24 | ) + 25 | s8 * (U[x-2, y-2; t] + U[x+2, y-2; t] + U[x-2, y+2; t] + U[x+2, y+2; t]) 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/divergence.stc: -------------------------------------------------------------------------------- 1 | stencil divergence ( 2 | double grid V(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 3 | const double grid Ux(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 4 | const double grid Uy(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 5 | const double grid Uz(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 6 | double param alpha, double param beta, double param gamma) 7 | { 8 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 9 | 10 | operation 11 | { 12 | V[x, y, z; t] = 13 | alpha * (Ux[x+1, y, z] - Ux[x-1, y, z]) + 14 | beta * (Uy[x, y+1, z] - Uy[x, y-1, z]) + 15 | gamma * (Uz[x, y, z+1] - Uz[x, y, z-1]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/edge.stc: -------------------------------------------------------------------------------- 1 | stencil edge (float grid U) 2 | { 3 | domainsize = (1 .. width, 1 .. height); 4 | 5 | operation 6 | { 7 | U[x, y; t+1] = -12 * U[x, y; t] + 8 | 2 * (U[x-1, y; t] + U[x+1, y; t] + U[x, y-1; t] + U[x, y+1; t]) + 9 | U[x-1, y-1; t] + U[x+1, y-1; t] + U[x-1, y+1; t] + U[x+1, y+1; t]; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/gradient.stc: -------------------------------------------------------------------------------- 1 | stencil gradient ( 2 | const double grid V(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 3 | double grid Ux(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 4 | double grid Uy(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 5 | double grid Uz(0 .. x_max+1, 0 .. y_max+1, 0 .. z_max+1), 6 | double param alpha, double param beta, double param gamma) 7 | { 8 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 9 | 10 | operation 11 | { 12 | Ux[x, y, z; t] = alpha * (V[x+1, y, z] - V[x-1, y, z]); 13 | Uy[x, y, z; t] = beta * (V[x, y+1, z] - V[x, y-1, z]); 14 | Uz[x, y, z; t] = gamma * (V[x, y, z+1] - V[x, y, z-1]); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/laplacian.stc: -------------------------------------------------------------------------------- 1 | stencil laplacian (double grid U, double param alpha, double param beta) 2 | { 3 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 4 | 5 | operation 6 | { 7 | U[x, y, z; t+1] = 8 | alpha * U[x, y, z; t] + 9 | beta * ( 10 | U[x+1, y, z; t] + U[x-1, y, z; t] + 11 | U[x, y+1, z; t] + U[x, y-1, z; t] + 12 | U[x, y, z+1; t] + U[x, y, z-1; t] 13 | ); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/tricubic.stc: -------------------------------------------------------------------------------- 1 | stencil tricubic ( 2 | float grid U(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2), 3 | const float grid a(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2), 4 | const float grid b(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2), 5 | const float grid c(0 .. x_max+2, 0 .. y_max+2, 0 .. z_max+2)) 6 | { 7 | domainsize = (1 .. x_max, 1 .. y_max, 1 .. z_max); 8 | 9 | operation 10 | { 11 | float wa[-1..2] = { 12 | 1.0/6.0 * a[x,y,z] * (a[x,y,z]+1.0) * (a[x,y,z]+2.0), 13 | -0.5 * (a[x,y,z]-1.0) * (a[x,y,z]+1.0) * (a[x,y,z]+2.0), 14 | 0.5 * (a[x,y,z]-1.0) * a[x,y,z] * (a[x,y,z]+2.0), 15 | -1.0/6.0 * (a[x,y,z]-1.0) * a[x,y,z] * (a[x,y,z]+1.0) 16 | }; 17 | 18 | float wb[-1..2] = { 19 | 1.0/6.0 * b[x,y,z] * (b[x,y,z]+1.0) * (b[x,y,z]+2.0), 20 | -0.5 * (b[x,y,z]-1.0) * (b[x,y,z]+1.0) * (b[x,y,z]+2.0), 21 | 0.5 * (b[x,y,z]-1.0) * b[x,y,z] * (b[x,y,z]+2.0), 22 | -1.0/6.0 * (b[x,y,z]-1.0) * b[x,y,z] * (b[x,y,z]+1.0) 23 | }; 24 | 25 | float wc[-1..2] = { 26 | 1.0/6.0 * c[x,y,z] * (c[x,y,z]+1.0) * (c[x,y,z]+2.0), 27 | -0.5 * (c[x,y,z]-1.0) * (c[x,y,z]+1.0) * (c[x,y,z]+2.0), 28 | 0.5 * (c[x,y,z]-1.0) * c[x,y,z] * (c[x,y,z]+2.0), 29 | -1.0/6.0 * (c[x,y,z]-1.0) * c[x,y,z] * (c[x,y,z]+1.0) 30 | }; 31 | 32 | U[x, y, z; t+1] = { i=-1..2, j=-1..2, k=-1..2 } sum (wa[i] * wb[j] * wc[k] * U[x+i, y+j, z+k; t]); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/wave-1.stc: -------------------------------------------------------------------------------- 1 | stencil wave ( 2 | float grid U(0 .. x_max-1, 0 .. y_max-1, 0 .. z_max-1), 3 | float param fMin, 4 | float param fDX, 5 | float param fDT_DX_sq) 6 | { 7 | iterate while t < 1; 8 | domainsize = (2 .. x_max-3, 2 .. y_max-3, 2 .. z_max-3); 9 | 10 | initial 11 | { 12 | // Initialize the timesteps (initially, t=0, so, with respect to the 13 | // stencil definition in the "operation" we need to initialize for t=-1,0,1). 14 | // Note that we can use the symbol π. 15 | U[x, y, z; -1] = sinf (2*π * ((x-1) * fDX + fMin)) * sinf (2*π * ((y-1) * fDX + fMin)) * sinf (2*π * ((z-1) * fDX + fMin)); 16 | U[x, y, z; 0] = U[x, y, z; -1]; 17 | U[x, y, z; 1] = 0; 18 | } 19 | 20 | operation 21 | { 22 | // Define some constants which will be used in the computation. 23 | // Patus will recognize these as constants and do the initialization 24 | // before the compute loop. 25 | float c1 = 2 - 15/2 * fDT_DX_sq; 26 | float c2 = 4/3 * fDT_DX_sq; 27 | float c3 = -1/12 * fDT_DX_sq; 28 | 29 | U[x, y, z; t+1] = c1 * U[x, y, z; t] - U[x, y, z; t-1] + 30 | c2 * (U[x+1, y, z; t] + U[x-1, y, z; t] + U[x, y+1, z; t] + U[x, y-1, z; t] + U[x, y, z+1; t] + U[x, y, z-1; t]) + 31 | c3 * (U[x+2, y, z; t] + U[x-2, y, z; t] + U[x, y+2, z; t] + U[x, y-2, z; t] + U[x, y, z+2; t] + U[x, y, z-2; t]); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /release/0.1/Patus/examples/stencils/wave-2.stc: -------------------------------------------------------------------------------- 1 | stencil wave ( 2 | float grid U(0 .. x_max-1, 0 .. y_max-1, 0 .. z_max-1), 3 | float param fMin, 4 | float param fDX, 5 | float param fDT_DX_sq) 6 | { 7 | domainsize = (2 .. x_max-3, 2 .. y_max-3, 2 .. z_max-3); 8 | 9 | operation 10 | { 11 | // Define a coefficient array. 12 | // Note that the lower and upper bounds can be arbitrary integers. 13 | 14 | float c[0..2] = { 15 | 2 - 15/2 * fDT_DX_sq, 16 | 4/3 * fDT_DX_sq, 17 | -1/12 * fDT_DX_sq 18 | }; 19 | 20 | 21 | // Use the compile-time reduction "sum" to sum up the neighbor points 22 | // the set preceding the sum function defines the indices which to sum over. 23 | // 24 | // Sets are specified in the set-builder notation; the first part, left of the 25 | // ":", defines the variables and assigns value ranges to them; in the second, 26 | // optional part, right of the ":", conditions for the variables can be defined. 27 | // 28 | // Note that (since c[r] is inside the sum) this will product more Flops 29 | // than strictly necessary. 30 | 31 | U[x, y, z; t+1] = 32 | c[0] * U[x, y, z; t] - U[x, y, z; t-1] + 33 | ({ i=-1..1, j=-1..1, k=-1..1, r=1..2 : i^2+j^2+k^2 == 1 } sum(c[r] * U[x+r*i,y+r*j,z+r*k; t])); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /release/0.1/Patus/quickstart.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/Patus/quickstart.pdf -------------------------------------------------------------------------------- /release/0.1/Patus/runtime/patusrt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Patus Runtime Library 3 | */ 4 | 5 | #ifndef __PATUSRT_H__ 6 | #define __PATUSRT_H__ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | 13 | /*************************************************************************/ 14 | /* Timer Functions */ 15 | /*************************************************************************/ 16 | 17 | /** 18 | * Starts the timer. 19 | */ 20 | void tic (); 21 | 22 | /** 23 | * Stops the timer and prints a time value to stdout. 24 | */ 25 | void toc (long nFlopsPerStencil, long nStencilComputationsCount, long nBytesTransferred); 26 | 27 | 28 | /*************************************************************************/ 29 | /* Utility Functions */ 30 | /*************************************************************************/ 31 | 32 | /** 33 | * Determines whether the command line argument szArg was passed to the program. 34 | */ 35 | int has_arg (char* szArg, int argc, char** argv); 36 | 37 | void write_data_f (char* szFilename, int nDim, float* pData, ...); 38 | void write_data_d (char* szFilename, int nDim, double* pData, ...); 39 | 40 | 41 | #ifndef __cplusplus 42 | /* 43 | inline int min (int a, int b) 44 | { 45 | if (a < b) 46 | return a; 47 | return b; 48 | }*/ 49 | #define min(a, b) (((a) < (b)) ? (a) : (b)) 50 | 51 | /* 52 | inline int max (int a, int b) 53 | { 54 | if (a < b) 55 | return b; 56 | return a; 57 | }*/ 58 | #define max(a, b) (((a) < (b)) ? (b) : (a)) 59 | #endif 60 | 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif -------------------------------------------------------------------------------- /release/0.1/Patus/runtime/timer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "cycle.h" 6 | 7 | 8 | ticks g_tickStart; 9 | double g_fTimeStart; 10 | 11 | 12 | double gettime () 13 | { 14 | struct timeval tp; 15 | struct timezone tzp; 16 | int i; 17 | 18 | i = gettimeofday (&tp, &tzp); 19 | return ((double) tp.tv_sec + (double) tp.tv_usec * 1.e-6); 20 | } 21 | 22 | 23 | 24 | void tic () 25 | { 26 | g_fTimeStart = gettime (); 27 | g_tickStart = getticks (); 28 | } 29 | 30 | void toc (long nFlopsPerStencil, long nStencilComputationsCount, long nBytesTransferred) 31 | { 32 | ticks tickEnd = getticks (); 33 | double fTime = gettime () - g_fTimeStart; 34 | 35 | long nTotalFlops = nFlopsPerStencil * nStencilComputationsCount; 36 | printf ("Flops / stencil call: %ld\n", nFlopsPerStencil); 37 | printf ("Stencil computations: %ld\n", nStencilComputationsCount); 38 | printf ("Bytes transferred: %ld\n", nBytesTransferred); 39 | printf ("Total Flops: %ld\n", nTotalFlops); 40 | printf ("Seconds elapsed: %f\n", fTime); 41 | printf ("Performance: %f GFlop/s\n", nTotalFlops / fTime / 1.e9); 42 | printf ("Bandwidth utilization: %f GB/s\n", nBytesTransferred / fTime / 1.e9); 43 | 44 | printf ("%f\n", elapsed (tickEnd, g_tickStart)); 45 | } 46 | -------------------------------------------------------------------------------- /release/0.1/Patus/strategy/cacheblocked.stg: -------------------------------------------------------------------------------- 1 | /** 2 | * Cache-blocking strategy. 3 | */ 4 | strategy cacheblocked_domain ( 5 | domain u, 6 | auto dim cb = ({u.size(1)/4, u.size(1)/2, u.size(1)}, 4:4:u.size(2 .. u.dim)), 7 | auto int chunk = {1,2,4}) 8 | { 9 | // iterate over time steps 10 | for t = 1 .. stencil.t_max 11 | { 12 | // iterate over subdomain 13 | for subdomain v(cb) in u(:; t) parallel schedule chunk 14 | { 15 | // calculate the stencil for each point in the subdomain 16 | for point p in v(:; t) 17 | v[p; t+1] = stencil (v[p; t]); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /release/0.1/Patus/strategy/gpu.stg: -------------------------------------------------------------------------------- 1 | strategy gpu_blocked (domain u, auto int cbx = {1,2,4}) 2 | { 3 | // iterate over time steps 4 | for t = 1 .. stencil.t_max 5 | { 6 | // iterate over subdomain 7 | for subdomain v(cbx, 1 ...) in u(:; t) parallel 8 | { 9 | for point pt in v(:; t) 10 | v[pt; t+1] = stencil (v[pt; t]); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /release/0.1/Patus/strategy/simple.stg: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple parallel strategy: 3 | * Iterate over the grid and parallelize the outer most loop. 4 | */ 5 | strategy simple_parallel (domain u, auto int chunk = 1:u.size(1)) 6 | { 7 | // do all the timesteps 8 | for t = 1 .. stencil.t_max 9 | { 10 | // apply the stencil to all the points in the domain 11 | for point p in u(:; t) parallel schedule chunk 12 | u[p; t+1] = stencil (u[p; t]); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /release/0.1/Patus/util/fixpath: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # This script takes in two arguments: $PATH and the separator for it 4 | # (since fish uses ' ' and everybody else uses ':') 5 | # Then, we remove path components that begin with $PATUS_HOME 6 | 7 | $home = $ENV{"PATUS_HOME"}; 8 | $_ = $ARGV[0]; 9 | $sep = $ARGV[1]; 10 | 11 | @oldpath = split /$sep/; 12 | @newpath = ( ); 13 | 14 | for (@oldpath) 15 | { 16 | if ($home ne "" and /^$home/) 17 | { 18 | # PATUS_HOME is defined and this element begins with PATUS_HOME 19 | } 20 | else 21 | { 22 | push (@newpath, $_); 23 | } 24 | } 25 | 26 | print join ($sep, @newpath) . "\n"; 27 | -------------------------------------------------------------------------------- /release/0.1/Patus/util/patusvars.csh: -------------------------------------------------------------------------------- 1 | # csh/tcsh shell script to set the Patus environment variables 2 | 3 | # shallow test to see if we are in the correct directory 4 | # Just probe to see if we have a few essential subdirectories -- 5 | # indicating that we are probably in a Patus root directory. 6 | if ( ! -d "bin" || ! -d "arch" || ! -d "strategy" || ! -f "bin/patus.jar" ) then 7 | echo "Error: patusvars.csh must be sourced from within the Patus root directory" 8 | exit 9 | endif 10 | 11 | set MYPATH = `./util/fixpath "$PATH" :` 12 | if ( $MYPATH == "" ) then 13 | echo "Error running ./util/fixpath" 14 | exit 15 | endif 16 | 17 | setenv PATUS_HOME "$cwd" 18 | echo "Setting PATUS_HOME to $PATUS_HOME" 19 | 20 | setenv PATH "$MYPATH":"$PATUS_HOME/bin" 21 | echo "Updating PATH to include $PATUS_HOME/bin" 22 | -------------------------------------------------------------------------------- /release/0.1/Patus/util/patusvars.sh: -------------------------------------------------------------------------------- 1 | # bash shell script to set the Patus environment variables 2 | 3 | # shallow test to see if we are in the correct directory 4 | # Just probe to see if we have a few essential subdirectories -- 5 | # indicating that we are probably in a Patus root directory. 6 | if [ -d "bin" ] && [ -d "arch" ] && [ -d "strategy" ] && [ -f "bin/patus.jar" ] 7 | then 8 | MYPATH=`./util/fixpath "$PATH" :` 9 | if [ -z "$MYPATH" ] 10 | then 11 | echo "Error running ./util/fixpath" 12 | else 13 | export PATUS_HOME=$PWD 14 | echo "Setting PATUS_HOME to $PATUS_HOME" 15 | 16 | export PATH="$MYPATH":"$PATUS_HOME"/bin 17 | echo "Updating PATH to include $PATUS_HOME/bin" 18 | fi 19 | else 20 | echo "Error: patusvars.sh must be sourced from within the Patus root directory" 21 | fi 22 | -------------------------------------------------------------------------------- /release/0.1/createzip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | zip -vr --exclude=*.svn* patus-0.1.3.zip Patus 3 | -------------------------------------------------------------------------------- /release/0.1/patus-0.1.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/patus-0.1.1.zip -------------------------------------------------------------------------------- /release/0.1/patus-0.1.2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/patus-0.1.2.zip -------------------------------------------------------------------------------- /release/0.1/patus-0.1.3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/patus-0.1.3.zip -------------------------------------------------------------------------------- /release/0.1/patus-0.1.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/patus-0.1.4.zip -------------------------------------------------------------------------------- /release/0.1/patus-0.1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/release/0.1/patus-0.1.zip -------------------------------------------------------------------------------- /runtime/patusrt.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Patus Runtime Library 3 | */ 4 | 5 | #ifndef __PATUSRT_H__ 6 | #define __PATUSRT_H__ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | 13 | /*************************************************************************/ 14 | /* Timer Functions */ 15 | /*************************************************************************/ 16 | 17 | /** 18 | * Starts the timer. 19 | */ 20 | void tic (); 21 | 22 | /** 23 | * Stops the timer and prints a time value to stdout. 24 | */ 25 | void toc (long nFlopsPerStencil, long nStencilComputationsCount, long nBytesTransferred); 26 | 27 | 28 | /*************************************************************************/ 29 | /* Utility Functions */ 30 | /*************************************************************************/ 31 | 32 | /** 33 | * Determines whether the command line argument szArg was passed to the program. 34 | */ 35 | int has_arg (char* szArg, int argc, char** argv); 36 | 37 | void write_data_f (char* szFilename, int nDim, float* pData, ...); 38 | void write_data_d (char* szFilename, int nDim, double* pData, ...); 39 | 40 | 41 | #ifndef __cplusplus 42 | /* 43 | inline int min (int a, int b) 44 | { 45 | if (a < b) 46 | return a; 47 | return b; 48 | }*/ 49 | #define min(a, b) (((a) < (b)) ? (a) : (b)) 50 | 51 | /* 52 | inline int max (int a, int b) 53 | { 54 | if (a < b) 55 | return b; 56 | return a; 57 | }*/ 58 | #define max(a, b) (((a) < (b)) ? (b) : (a)) 59 | #endif 60 | 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif -------------------------------------------------------------------------------- /runtime/timer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "cycle.h" 6 | 7 | 8 | ticks g_tickStart; 9 | double g_fTimeStart; 10 | 11 | 12 | double gettime () 13 | { 14 | struct timeval tp; 15 | struct timezone tzp; 16 | int i; 17 | 18 | i = gettimeofday (&tp, &tzp); 19 | return ((double) tp.tv_sec + (double) tp.tv_usec * 1.e-6); 20 | } 21 | 22 | 23 | 24 | void tic () 25 | { 26 | g_fTimeStart = gettime (); 27 | g_tickStart = getticks (); 28 | } 29 | 30 | void toc (long nFlopsPerStencil, long nStencilComputationsCount, long nBytesTransferred) 31 | { 32 | ticks tickEnd = getticks (); 33 | double fTime = gettime () - g_fTimeStart; 34 | 35 | long nTotalFlops = nFlopsPerStencil * nStencilComputationsCount; 36 | printf ("Flops / stencil call: %ld\n", nFlopsPerStencil); 37 | printf ("Stencil computations: %ld\n", nStencilComputationsCount); 38 | printf ("Bytes transferred: %ld\n", nBytesTransferred); 39 | printf ("Total Flops: %ld\n", nTotalFlops); 40 | printf ("Seconds elapsed: %f\n", fTime); 41 | printf ("Performance: %f GFlop/s\n", nTotalFlops / fTime / 1.e9); 42 | printf ("Bandwidth utilization: %f GB/s\n", nBytesTransferred / fTime / 1.e9); 43 | 44 | printf ("%f\n", elapsed (tickEnd, g_tickStart)); 45 | } 46 | -------------------------------------------------------------------------------- /src/cetus/analysis/AnalysisPass.java: -------------------------------------------------------------------------------- 1 | package cetus.analysis; 2 | 3 | import cetus.hir.*; 4 | 5 | public abstract class AnalysisPass 6 | { 7 | protected Program program; 8 | 9 | protected AnalysisPass(Program program) 10 | { 11 | this.program = program; 12 | } 13 | 14 | public abstract String getPassName(); 15 | 16 | public static void run(AnalysisPass pass) 17 | { 18 | double timer = Tools.getTime(); 19 | PrintTools.println(pass.getPassName() + " begin", 0); 20 | pass.start(); 21 | PrintTools.println(pass.getPassName() + " end in " + 22 | String.format("%.2f seconds", Tools.getTime(timer)), 0); 23 | if (!IRTools.checkConsistency(pass.program)) 24 | throw new InternalError("Inconsistent IR after " + pass.getPassName()); 25 | } 26 | 27 | public abstract void start(); 28 | } 29 | -------------------------------------------------------------------------------- /src/cetus/analysis/BasicBlock.java: -------------------------------------------------------------------------------- 1 | package cetus.analysis; 2 | 3 | import java.util.*; 4 | 5 | import cetus.hir.*; 6 | 7 | public class BasicBlock 8 | { 9 | ArrayList statements; 10 | ArrayList preds; 11 | ArrayList succs; 12 | 13 | boolean visited = false; 14 | boolean calladjusted = false; 15 | 16 | public BasicBlock() 17 | { 18 | statements = new ArrayList(); 19 | preds = new ArrayList(); 20 | succs = new ArrayList(); 21 | } 22 | 23 | public void addPredecessor(BasicBlock bb) 24 | { 25 | preds.add(bb); 26 | } 27 | 28 | public void addSuccessor(BasicBlock bb) 29 | { 30 | succs.add(bb); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/cetus/analysis/Cache.java: -------------------------------------------------------------------------------- 1 | package cetus.analysis; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Data structure implementing FIFO cache. Time-consuming manipulations can be 7 | * cached to save computation time at the price of additional memory usage. 8 | */ 9 | public class Cache extends LinkedHashMap 10 | { 11 | private static final long serialVersionUID = 16L; 12 | 13 | private int max_entries = 64; 14 | 15 | public Cache() 16 | { 17 | super(); 18 | } 19 | 20 | public Cache(int max_entries) 21 | { 22 | super(); 23 | this.max_entries = max_entries; 24 | } 25 | 26 | protected boolean removeEldestEntry(Map.Entry eldest) 27 | { 28 | return size() > max_entries; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/cetus/analysis/DDTest.java: -------------------------------------------------------------------------------- 1 | package cetus.analysis; 2 | 3 | import cetus.hir.*; 4 | 5 | import java.util.*; 6 | 7 | /** 8 | * Any class implementing this interface represents a Dependence testing algorithm 9 | * and provides the common functionality that these tests use to interface with the 10 | * dependence test wrapper. 11 | */ 12 | public interface DDTest 13 | { 14 | /** 15 | * Runs the dependence test on a direction vector 16 | * @param dv The dependence vector under which test needs to be performed 17 | * @return whether dependence exists or not 18 | */ 19 | boolean testDependence(DependenceVector dv); 20 | 21 | /** 22 | * Returns whether the constructor for the dependence test determined 23 | * whether it would be eligible to run the test on the pair of 24 | * subscripts or not 25 | * @return true if it is, false otherwise. 26 | */ 27 | boolean isTestEligible(); 28 | 29 | /** 30 | * Returns a list of loops from outermost to innermost that are common to the 31 | * two expressions being tested for dependence, whether they are a pair of subscripts 32 | * or a pair of whole array accesses 33 | * @return the collected list of loops. 34 | */ 35 | LinkedList getCommonEnclosingLoops(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/cetus/analysis/LoopAnalysisPass.java: -------------------------------------------------------------------------------- 1 | package cetus.analysis; 2 | 3 | import java.util.*; 4 | 5 | import cetus.hir.*; 6 | 7 | public abstract class LoopAnalysisPass extends AnalysisPass 8 | { 9 | protected LoopAnalysisPass(Program program) 10 | { 11 | super(program); 12 | } 13 | 14 | public abstract void analyzeLoop(Loop loop); 15 | 16 | public void start() 17 | { 18 | DepthFirstIterator iter = new DepthFirstIterator(program); 19 | 20 | for (;;) 21 | { 22 | Loop loop = null; 23 | 24 | try { 25 | loop = (Loop)iter.next(Loop.class); 26 | } catch (NoSuchElementException e) { 27 | break; 28 | } 29 | 30 | analyzeLoop(loop); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/cetus/analysis/ProcBasicBlock.java: -------------------------------------------------------------------------------- 1 | package cetus.analysis; 2 | 3 | import java.util.*; 4 | 5 | import cetus.hir.*; 6 | 7 | public class ProcBasicBlock extends BasicBlock { 8 | BasicBlock entryBB,exitBB,cloneentryBB,cloneexitBB ; 9 | public ProcBasicBlock() { 10 | entryBB = new BasicBlock(); 11 | exitBB = new BasicBlock(); 12 | } 13 | 14 | public void addPredecessor(BasicBlock bb) { 15 | entryBB.addPredecessor(bb); 16 | } 17 | 18 | public void addSuccessor(BasicBlock bb) { 19 | exitBB.addSuccessor(bb); 20 | } 21 | 22 | public ProcBasicBlock clonepbb(){ 23 | ProcBasicBlock newpbb = new ProcBasicBlock(); 24 | cloneentryBB = newpbb.entryBB; 25 | cloneexitBB = newpbb.exitBB; 26 | ArrayList l_arr = entryBB.preds; 27 | for(int i=0;i(); 38 | //Copy over the compoundstatement 39 | List l_li = p_bb.statements; 40 | for (i=0;i getAnnotations(); 22 | 23 | /** 24 | * Returns the list of annotations with the given type. 25 | */ 26 | List getAnnotations(Class type); 27 | 28 | /** 29 | * Checks if this annotatable contains the specified annotation type and key. 30 | */ 31 | boolean containsAnnotation(Class type, String key); 32 | 33 | /** 34 | * Returns the annotation with the specified type and key. 35 | */ 36 | T getAnnotation(Class type, String key); 37 | 38 | /** 39 | * Returns the list of annotations with the given relative position. 40 | */ 41 | List getAnnotations(int position); 42 | 43 | /** 44 | * Remove all annotations. 45 | */ 46 | void removeAnnotations(); 47 | 48 | /** 49 | * Remove all annotations of the given type. 50 | */ 51 | void removeAnnotations(Class type); 52 | } 53 | -------------------------------------------------------------------------------- /src/cetus/hir/BitfieldSpecifier.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * BitfieldSpecifier represents the bit field declared in a structure. 9 | */ 10 | public class BitfieldSpecifier extends Specifier 11 | { 12 | private Expression bit; 13 | 14 | /** 15 | * Constructs a bit field specifier from the given bit expression. 16 | */ 17 | public BitfieldSpecifier(Expression e) 18 | { 19 | bit = e; 20 | } 21 | 22 | /** Prints the specifier on the specified print writer. */ 23 | public void print(PrintWriter o) 24 | { 25 | o.print(" : "); 26 | bit.print(o); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/cetus/hir/BreakStatement.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * Represents a break statement: break ';' 9 | */ 10 | public class BreakStatement extends Statement 11 | { 12 | private static Method class_print_method; 13 | 14 | static 15 | { 16 | Class[] params = new Class[2]; 17 | 18 | try { 19 | params[0] = BreakStatement.class; 20 | params[1] = PrintWriter.class; 21 | class_print_method = params[0].getMethod("defaultPrint", params); 22 | } catch (NoSuchMethodException e) { 23 | throw new InternalError(); 24 | } 25 | } 26 | 27 | /** 28 | * Create a new break statement. 29 | */ 30 | public BreakStatement() 31 | { 32 | object_print_method = class_print_method; 33 | } 34 | 35 | /** 36 | * Prints a break statement to a stream. 37 | * 38 | * @param s The statement to print. 39 | * @param o The writer on which to print the statement. 40 | */ 41 | public static void defaultPrint(BreakStatement s, PrintWriter o) 42 | { 43 | o.print("break;"); 44 | } 45 | 46 | /** 47 | * Overrides the class print method, so that all subsequently 48 | * created objects will use the supplied method. 49 | * 50 | * @param m The new print method. 51 | */ 52 | static public void setClassPrintMethod(Method m) 53 | { 54 | class_print_method = m; 55 | } 56 | 57 | /** Returns a clone of the break statement. */ 58 | @Override 59 | public BreakStatement clone() 60 | { 61 | BreakStatement bs = (BreakStatement) super.clone(); 62 | return bs; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/cetus/hir/Case.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * Represents a case for use with switch. 9 | */ 10 | public class Case extends Statement 11 | { 12 | private static Method class_print_method; 13 | 14 | static 15 | { 16 | Class[] params = new Class[2]; 17 | 18 | try { 19 | params[0] = Case.class; 20 | params[1] = PrintWriter.class; 21 | class_print_method = params[0].getMethod("defaultPrint", params); 22 | } catch (NoSuchMethodException e) { 23 | throw new InternalError(); 24 | } 25 | } 26 | 27 | /** 28 | * Create a new case with the specified expression. 29 | * 30 | * @param expr The expression that activates the case. 31 | * @throws NotAnOrphanException if expr has a parent. 32 | */ 33 | public Case(Expression expr) 34 | { 35 | object_print_method = class_print_method; 36 | 37 | addChild(expr); 38 | } 39 | 40 | /** 41 | * Prints a case label to a stream. 42 | * 43 | * @param c The case label to print. 44 | * @param o The writer on which to print the case label. 45 | */ 46 | public static void defaultPrint(Case c, PrintWriter o) 47 | { 48 | o.print("case "); 49 | c.getExpression().print(o); 50 | o.print(":"); 51 | } 52 | 53 | public Expression getExpression() 54 | { 55 | return (Expression)children.get(0); 56 | } 57 | 58 | /** 59 | * Overrides the class print method, so that all subsequently 60 | * created objects will use the supplied method. 61 | * 62 | * @param m The new print method. 63 | */ 64 | static public void setClassPrintMethod(Method m) 65 | { 66 | class_print_method = m; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/cetus/hir/CodeAnnotation.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * CodeAnnotation is used for an annotation of raw code type. 7 | * It is convenient to insert a raw code if pass writers are sure about the 8 | * correctness of the inserted code for their passes. One example is inlined 9 | * library codes that are called after a certain program transformation. 10 | */ 11 | public class CodeAnnotation extends Annotation 12 | { 13 | /** 14 | * Constructs a new code annotation with the given code. 15 | */ 16 | public CodeAnnotation(String code) 17 | { 18 | super(); 19 | put("code", code); 20 | } 21 | 22 | /** 23 | * Returns the string representation of this code annotation. 24 | */ 25 | public String toString() 26 | { 27 | if ( skip_print ) 28 | return ""; 29 | else 30 | return get("code"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/cetus/hir/CommentAnnotation.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * CommentAnnotation is used for an annotation of comment type. 7 | * It provides two different print method depending on the location of the 8 | * comments. 9 | */ 10 | public class CommentAnnotation extends Annotation 11 | { 12 | private boolean one_liner; // Is this printed in one line. 13 | 14 | /** 15 | * Constructs a new comment annotation with the given comment. 16 | */ 17 | public CommentAnnotation(String comment) 18 | { 19 | super(); 20 | put("comment", comment); 21 | one_liner = false; 22 | } 23 | 24 | /** 25 | * Sets the one_liner field; true for one-liner comments, false for 26 | * normal multi-line comments. 27 | */ 28 | public void setOneLiner(boolean one_liner) 29 | { 30 | this.one_liner = one_liner; 31 | } 32 | 33 | /** 34 | * Returns the string representation of this comment. 35 | * @return the string comments. 36 | */ 37 | public String toString() 38 | { 39 | if ( skip_print ) 40 | return ""; 41 | else if ( one_liner ) 42 | return ("/* "+get("comment")+" */"); 43 | else 44 | return ("/*\n"+get("comment")+"\n*/"); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/cetus/hir/ConstructorInitializer.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is no longer supported */ 8 | public class ConstructorInitializer extends Initializer 9 | { 10 | public ConstructorInitializer(List values) 11 | { 12 | for (Object o : values) 13 | { 14 | children.add((Traversable)o); 15 | ((Traversable)o).setParent(this); 16 | } 17 | } 18 | 19 | public void print(PrintWriter o) 20 | { 21 | o.print("("); 22 | PrintTools.printListWithComma(children, o); 23 | o.print(")"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/cetus/hir/ContinueStatement.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * Represents a continue statement: continue ';' 9 | */ 10 | public class ContinueStatement extends Statement 11 | { 12 | private static Method class_print_method; 13 | 14 | static 15 | { 16 | Class[] params = new Class[2]; 17 | 18 | try { 19 | params[0] = ContinueStatement.class; 20 | params[1] = PrintWriter.class; 21 | class_print_method = params[0].getMethod("defaultPrint", params); 22 | } catch (NoSuchMethodException e) { 23 | throw new InternalError(); 24 | } 25 | } 26 | 27 | /** 28 | * Create a new continue statement. 29 | */ 30 | public ContinueStatement() 31 | { 32 | object_print_method = class_print_method; 33 | } 34 | 35 | /** 36 | * Prints a continue statement to a stream. 37 | * 38 | * @param s The statement to print. 39 | * @param o The writer on which to print the statement. 40 | */ 41 | public static void defaultPrint(ContinueStatement s, PrintWriter o) 42 | { 43 | o.print("continue;"); 44 | } 45 | 46 | /** 47 | * Overrides the class print method, so that all subsequently 48 | * created objects will use the supplied method. 49 | * 50 | * @param m The new print method. 51 | */ 52 | static public void setClassPrintMethod(Method m) 53 | { 54 | class_print_method = m; 55 | } 56 | 57 | /** Returns a clone of the continue statement. */ 58 | @Override 59 | public ContinueStatement clone() 60 | { 61 | ContinueStatement cs = (ContinueStatement) super.clone(); 62 | return cs; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/cetus/hir/Default.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * Represents a default for use with switch. 9 | */ 10 | public class Default extends Statement 11 | { 12 | private static Method class_print_method; 13 | 14 | static 15 | { 16 | Class[] params = new Class[2]; 17 | 18 | try { 19 | params[0] = Default.class; 20 | params[1] = PrintWriter.class; 21 | class_print_method = params[0].getMethod("defaultPrint", params); 22 | } catch (NoSuchMethodException e) { 23 | throw new InternalError(); 24 | } 25 | } 26 | 27 | /** 28 | * Create a new default. 29 | */ 30 | public Default() 31 | { 32 | object_print_method = class_print_method; 33 | } 34 | 35 | /** 36 | * Prints a default label to a stream. 37 | * 38 | * @param d The default label to print. 39 | * @param o The writer on which to print the default label. 40 | */ 41 | public static void defaultPrint(Default d, PrintWriter o) 42 | { 43 | o.print("default:"); 44 | } 45 | 46 | /** 47 | * Overrides the class print method, so that all subsequently 48 | * created objects will use the supplied method. 49 | * 50 | * @param m The new print method. 51 | */ 52 | static public void setClassPrintMethod(Method m) 53 | { 54 | class_print_method = m; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/cetus/hir/DuplicateSymbolException.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Thrown when a symbol is about to be entered into a symbol 7 | * table and there is already a symbol of the same name in 8 | * that same table. 9 | */ 10 | public class DuplicateSymbolException extends RuntimeException 11 | { 12 | /** 13 | * Creates the exception. 14 | * 15 | * @param message The message should indicate the name 16 | * of the offending symbol. 17 | */ 18 | public DuplicateSymbolException(String message) 19 | { 20 | super(message); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/cetus/hir/ExceptionSpecification.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /* TODO: remove this */ 8 | public class ExceptionSpecification 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/cetus/hir/Intrinsic.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | /** 4 | * Any class implementing this interface has the properties of what we 5 | * call an intrinsic function, it has a specific meaning and is 6 | * represented as an Expression in the IR. 7 | */ 8 | public interface Intrinsic 9 | { 10 | /** 11 | * Returns the expression. 12 | * 13 | * @return the expression that is the operand 14 | * to which this intrinsic function is being 15 | * applied as an operator. 16 | */ 17 | public Expression getExpression(); 18 | } 19 | 20 | /* Look at FunctionCall.java -> getArguments(); 21 | */ 22 | -------------------------------------------------------------------------------- /src/cetus/hir/ListInitializer.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | public class ListInitializer extends Initializer 8 | { 9 | public ListInitializer(List values) 10 | { 11 | for (Object o : values) 12 | { 13 | children.add((Traversable)o); 14 | ((Traversable)o).setParent(this); 15 | } 16 | } 17 | 18 | @Override 19 | public void print(PrintWriter o) 20 | { 21 | o.print(" = { "); 22 | PrintTools.printListWithComma(children, o); 23 | o.print(" } "); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/cetus/hir/Literal.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** Represents an immediate value within the program. */ 8 | public abstract class Literal extends Expression 9 | { 10 | /** Constructs an empty literal */ 11 | protected Literal() 12 | { 13 | /* Literals are always leaves, so we can save 14 | a lot of memory by not making a child list. */ 15 | children = null; 16 | } 17 | 18 | @Override 19 | public Literal clone() 20 | { 21 | Literal o = (Literal)super.clone(); 22 | return o; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/cetus/hir/Loop.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | /** 4 | * Any class implementing this interface has the properties of a loop. 5 | */ 6 | public interface Loop 7 | { 8 | /** 9 | * Returns the statement that is the body of the loop. 10 | * 11 | * @return the body of the loop. 12 | */ 13 | Statement getBody(); 14 | 15 | /** 16 | * Returns the expression that determines the duration of 17 | * the loop. 18 | * 19 | * @return the condition that is tested each iteration. 20 | */ 21 | Expression getCondition(); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/cetus/hir/NotAChildException.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Thrown when an action is performed on an IR object and 7 | * that action requires the object to be the child of 8 | * another object, but that is not the case. 9 | */ 10 | public class NotAChildException extends RuntimeException 11 | { 12 | public NotAChildException() 13 | { 14 | super(); 15 | } 16 | 17 | public NotAChildException(String message) 18 | { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cetus/hir/NotAnOrphanException.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Thrown when an action is performed on an IR object 7 | * and that object is required to have no parent object, 8 | * but that is not the case. 9 | */ 10 | public class NotAnOrphanException extends RuntimeException 11 | { 12 | public NotAnOrphanException() 13 | { 14 | super(); 15 | } 16 | 17 | public NotAnOrphanException(String message) 18 | { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/cetus/hir/OperatorID.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * C++ overloaded operator IDs. This class is no longer supported. 9 | */ 10 | public class OperatorID extends IDExpression 11 | { 12 | private String name; 13 | 14 | public OperatorID(String name) 15 | { 16 | super(false); 17 | this.name = name; 18 | } 19 | 20 | public void print(PrintWriter o) 21 | { 22 | o.print("operator " + name); 23 | } 24 | 25 | @Override 26 | public boolean equals(Object o) 27 | { 28 | return ( 29 | super.equals(o) && 30 | name.equals(((OperatorID)o).name) 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/cetus/hir/PointerSpecifier.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** Represents a C or C++ pointer. */ 8 | public class PointerSpecifier extends Specifier 9 | { 10 | /** * */ 11 | public static final PointerSpecifier UNQUALIFIED = new PointerSpecifier(); 12 | 13 | /** * const */ 14 | public static final PointerSpecifier CONST = 15 | new PointerSpecifier((new ChainedList()).addLink(Specifier.CONST)); 16 | 17 | /** * volatile */ 18 | public static final PointerSpecifier VOLATILE = 19 | new PointerSpecifier((new ChainedList()).addLink(Specifier.VOLATILE)); 20 | 21 | /** * const volatile */ 22 | public static final PointerSpecifier CONST_VOLATILE = 23 | new PointerSpecifier((new ChainedList()).addLink(Specifier.CONST).addLink(Specifier.VOLATILE)); 24 | 25 | private List qualifiers; 26 | 27 | private PointerSpecifier() 28 | { 29 | qualifiers = null; 30 | } 31 | 32 | private PointerSpecifier(List qualifiers) 33 | { 34 | this.qualifiers = qualifiers; 35 | } 36 | 37 | public void print(PrintWriter o) 38 | { 39 | o.print("*"); 40 | PrintTools.printList(qualifiers, o); 41 | o.print(" "); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/cetus/hir/PragmaAnnotation.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * PragmaAnnotation is used for annotations of pragma type. 7 | */ 8 | public class PragmaAnnotation extends Annotation 9 | { 10 | /** 11 | * Constructs an empty pragma annotation. 12 | */ 13 | public PragmaAnnotation() 14 | { 15 | super(); 16 | } 17 | 18 | /** 19 | * Constructs a simple pragma with raw string. 20 | */ 21 | public PragmaAnnotation(String pragma) 22 | { 23 | super(); 24 | put("pragma", pragma); 25 | } 26 | 27 | /** 28 | * Returns the name of this pragma annotation. 29 | */ 30 | public String getName() 31 | { 32 | return (String)get("pragma"); 33 | } 34 | 35 | /** 36 | * Checks if the specified keys all exist in the key set. 37 | */ 38 | public boolean containsKeys(Collection keys) 39 | { 40 | for ( String key : keys ) 41 | if ( !containsKey(key) ) 42 | return false; 43 | return true; 44 | } 45 | 46 | /** 47 | * Returns the string representation of this pragma annotation. 48 | * @return the string. 49 | */ 50 | public String toString() 51 | { 52 | if ( skip_print ) 53 | return ""; 54 | String ret = "#pragma "; 55 | String pragma = get("pragma"); 56 | if ( pragma != null ) 57 | ret += pragma+" "; 58 | if ( this.getClass() == PragmaAnnotation.class ) // pure pragma printing 59 | for ( String key : keySet() ) 60 | if ( !key.equals("pragma") ) 61 | ret += key+" "+get(key)+" "; 62 | return ret; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/cetus/hir/Printable.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | 5 | /** Any class implementing this interface can print 6 | * its data. Every class provides a default 7 | * way of printing itself as source code. The class 8 | * may also support overriding the default behavior 9 | * at the class level. For example, 10 | * the pass writer may wish all ForStatements to be 11 | * printed in a certain way. It may also support overriding 12 | * the behavior for a particular object. For example, once a pass 13 | * determines that a loop is parallel, it may need to 14 | * modify the print behavior for that loop only. For consistency, 15 | * changing the print method of a class or object will also 16 | * affect the behavior of toString for that class or object. 17 | */ 18 | public interface Printable 19 | { 20 | /** Print the code for the IR represented by the object. 21 | * Always calls object_print_method(this, o). If 22 | * the object's print method is null, nothing is printed; 23 | * this provides an easy mechanism to temporarily hide 24 | * something. 25 | * 26 | * @param o The writer on which to print the data. 27 | */ 28 | void print(PrintWriter o); 29 | } 30 | -------------------------------------------------------------------------------- /src/cetus/hir/PseudoSymbol.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | /** 4 | * PseudoSymbol is intended to provide Symbol interface in an 5 | * object that is not part of the IR. 6 | */ 7 | public abstract class PseudoSymbol implements Symbol 8 | { 9 | /** Constructs an empty pseudo symbol */ 10 | public PseudoSymbol() {} 11 | 12 | /** Returns the string representation of the pseudo symbol */ 13 | @Override 14 | public String toString() 15 | { 16 | return this.getSymbolName(); 17 | } 18 | 19 | /** 20 | * This operation is not supported. 21 | * @throws UnsupportedOperationException always 22 | */ 23 | public void setName(String name) 24 | { 25 | throw new UnsupportedOperationException(); 26 | } 27 | 28 | /** 29 | * This operation is not supported. 30 | * @throws UnsupportedOperationException always 31 | */ 32 | public Declaration getDeclaration() 33 | { 34 | throw new UnsupportedOperationException(); 35 | } 36 | 37 | /** 38 | * Returns the most representative symbol object that exist in the IR. 39 | * e.g., the symbol of the left-hand-side (base address) for accessy symbol. 40 | * Depending on the sub-class type of PseudoSymbol this method may 41 | * return null. 42 | */ 43 | public abstract Symbol getIRSymbol(); 44 | 45 | /** 46 | * This method should be provided for the symbol to be used in collection. 47 | */ 48 | public abstract boolean equals(Object o); 49 | 50 | /** 51 | * This method should be provided for the symbol to be used in hashset(map). 52 | */ 53 | public abstract int hashCode(); 54 | } 55 | -------------------------------------------------------------------------------- /src/cetus/hir/QualifiedID.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is no longer supported */ 8 | public class QualifiedID extends IDExpression 9 | { 10 | private static Method class_print_method; 11 | 12 | static 13 | { 14 | Class[] params = new Class[2]; 15 | 16 | try { 17 | params[0] = QualifiedID.class; 18 | params[1] = PrintWriter.class; 19 | class_print_method = params[0].getMethod("defaultPrint", params); 20 | } catch (NoSuchMethodException e) { 21 | throw new InternalError(); 22 | } 23 | } 24 | 25 | public QualifiedID(List id_expr_list) 26 | { 27 | super(false); 28 | 29 | object_print_method = class_print_method; 30 | children.addAll(id_expr_list); 31 | } 32 | 33 | public QualifiedID(boolean global, List id_expr_list) 34 | { 35 | super(global); 36 | 37 | object_print_method = class_print_method; 38 | children.addAll(id_expr_list); 39 | } 40 | 41 | /** 42 | * This method returns the list of IDs in the qualified ID 43 | */ 44 | public LinkedList getIDExpressionList() 45 | { 46 | return children; 47 | } 48 | 49 | @Override 50 | public QualifiedID clone() 51 | { 52 | QualifiedID o = (QualifiedID)super.clone(); 53 | return o; 54 | } 55 | 56 | /** 57 | * Prints an identifier to a stream. 58 | * 59 | * @param i The identifier to print. 60 | * @param o The writer on which to print the identifier. 61 | */ 62 | public static void defaultPrint(QualifiedID i, PrintWriter o) 63 | { 64 | if (i.typename) 65 | o.print("typename "); 66 | if (i.global) 67 | o.print("::"); 68 | PrintTools.printListWithSeparator(i.children, o, "::"); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/cetus/hir/StatementExpression.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** 8 | * Represents an expression containing a compound statement - GCC extension. 9 | */ 10 | public class StatementExpression extends Expression 11 | { 12 | private static Method class_print_method; 13 | 14 | static 15 | { 16 | Class[] params = new Class[2]; 17 | 18 | try { 19 | params[0] = StatementExpression.class; 20 | params[1] = PrintWriter.class; 21 | class_print_method = params[0].getMethod("defaultPrint", params); 22 | } catch (NoSuchMethodException e) { 23 | throw new InternalError(); 24 | } 25 | } 26 | 27 | /** Constructs a statement expression with the specified compound statement */ 28 | public StatementExpression(CompoundStatement stmt) 29 | { 30 | object_print_method = class_print_method; 31 | // addChild is not used since a statement is inserted. 32 | children.add(stmt); 33 | stmt.setParent(this); 34 | } 35 | 36 | /** Prints the statement expression on the specified print writer */ 37 | public static void defaultPrint(StatementExpression e, PrintWriter o) 38 | { 39 | o.print("("); 40 | e.getStatement().print(o); 41 | o.print(")"); 42 | } 43 | 44 | /** Returns the child statement of the statement expression */ 45 | public CompoundStatement getStatement() 46 | { 47 | return (CompoundStatement)children.get(0); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/cetus/hir/Symbol.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * An IR object that implements Symbol interface is identified as a unique 7 | * symbol in the program. Every {@link Identifier} object has a link to 8 | * its corresponding Symbol object and can access the attributes of the symbol 9 | * object. 10 | */ 11 | public interface Symbol 12 | { 13 | /** 14 | * Returns a list of type specifiers. 15 | * 16 | * @return the list of type specifiers. 17 | */ 18 | List getTypeSpecifiers(); 19 | 20 | /** 21 | * Returns a list of array specifiers. 22 | * 23 | * @return the list of array specifiers. 24 | */ 25 | List getArraySpecifiers(); 26 | 27 | /** 28 | * Returns the name of the symbol. 29 | * 30 | * @return the name of the symbol. 31 | */ 32 | String getSymbolName(); 33 | 34 | /** 35 | * Modify the name of the symbol. This method effectively renames all the 36 | * identifiers constructed from the symbol object. Pass writers should be 37 | * cautious when renaming global names since the effective scope of this 38 | * operation is within a translation unit; {@code extern} variables and 39 | * procedure names are not automatically handled. 40 | * 41 | * @param name the new name of the symbol. 42 | */ 43 | void setName(String name); 44 | 45 | /** 46 | * Returns the parent declaration containing the symbol object. The return 47 | * value is searched from the internal look-up table. Depending on the type 48 | * of the symbol, this method may return the symbol object itself, or null 49 | * if the symbol object does not exist in the IR. 50 | * 51 | * @return the parent declaration. 52 | */ 53 | Declaration getDeclaration(); 54 | } 55 | -------------------------------------------------------------------------------- /src/cetus/hir/TemplateDeclaration.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is not supported */ 8 | public class TemplateDeclaration extends Declaration 9 | { 10 | private static Method class_print_method; 11 | 12 | static 13 | { 14 | Class[] params = new Class[2]; 15 | 16 | try { 17 | params[0] = TemplateDeclaration.class; 18 | params[1] = PrintWriter.class; 19 | class_print_method = params[0].getMethod("defaultPrint", params); 20 | } catch (NoSuchMethodException e) { 21 | throw new InternalError(); 22 | } 23 | } 24 | 25 | private List params; 26 | 27 | public TemplateDeclaration(List params, Declaration decl) 28 | { 29 | object_print_method = class_print_method; 30 | 31 | this.params = params; 32 | 33 | children.add(decl); 34 | decl.setParent(this); 35 | } 36 | 37 | /** 38 | * Prints a template to a stream. 39 | * 40 | * @param d The template to print. 41 | * @param o The writer on which to print the namespace. 42 | */ 43 | public static void defaultPrint(TemplateDeclaration d, PrintWriter o) 44 | { 45 | o.print("template < "); 46 | PrintTools.printListWithComma(d.params, o); 47 | o.println(" > "); 48 | d.getDeclaration().print(o); 49 | } 50 | 51 | public Declaration getDeclaration() 52 | { 53 | return (Declaration)children.get(0); 54 | } 55 | 56 | public List getDeclaredIDs() 57 | { 58 | return getDeclaration().getDeclaredIDs(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/cetus/hir/ThrowExpression.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is no longer supported */ 8 | public class ThrowExpression extends Expression 9 | { 10 | private static Method class_print_method; 11 | 12 | static 13 | { 14 | Class[] params = new Class[2]; 15 | 16 | try { 17 | params[0] = ThrowExpression.class; 18 | params[1] = PrintWriter.class; 19 | class_print_method = params[0].getMethod("defaultPrint", params); 20 | } catch (NoSuchMethodException e) { 21 | throw new InternalError(); 22 | } 23 | } 24 | 25 | public ThrowExpression(Expression expr) 26 | { 27 | super(1); 28 | 29 | object_print_method = class_print_method; 30 | 31 | children.add(expr); 32 | expr.setParent(this); 33 | } 34 | 35 | @Override 36 | public ThrowExpression clone() 37 | { 38 | ThrowExpression o = (ThrowExpression)super.clone(); 39 | return o; 40 | } 41 | 42 | /** 43 | * Prints a throw expression to a stream. 44 | * 45 | * @param e The expression to print. 46 | * @param o The writer on which to print the expression. 47 | */ 48 | public static void defaultPrint(ThrowExpression e, PrintWriter o) 49 | { 50 | o.print("throw "); 51 | e.getExpression().print(o); 52 | } 53 | 54 | public Expression getExpression() 55 | { 56 | return (Expression)children.get(0); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/cetus/hir/TypeofSpecifier.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is no longer supported. */ 8 | public class TypeofSpecifier extends Specifier 9 | { 10 | private Expression expr; 11 | private List type_id; 12 | 13 | public TypeofSpecifier(Expression expr) 14 | { 15 | this.expr = expr; 16 | this.type_id = null; 17 | } 18 | 19 | public TypeofSpecifier(List type_id) 20 | { 21 | this.expr = null; 22 | this.type_id = type_id; 23 | } 24 | 25 | public void print(PrintWriter o) 26 | { 27 | o.print("typeof ( "); 28 | if (expr != null) 29 | expr.print(o); 30 | else 31 | PrintTools.printListWithSpace(type_id, o); 32 | o.print(" ) "); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/cetus/hir/UserSpecifier.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** Represents the name of a user-defined type, such 8 | * as created by a typedef, class declaration, etc. */ 9 | public class UserSpecifier extends Specifier 10 | { 11 | private IDExpression usertype; 12 | 13 | public UserSpecifier(IDExpression usertype) 14 | { 15 | this.usertype = usertype; 16 | } 17 | 18 | public IDExpression getIDExpression() 19 | { 20 | return usertype; 21 | } 22 | 23 | public boolean isStructure() 24 | { 25 | return toString().startsWith("struct "); 26 | } 27 | 28 | public void print(PrintWriter o) 29 | { 30 | usertype.print(o); 31 | } 32 | 33 | public boolean equals(Object o) 34 | { 35 | return ( 36 | o != null && 37 | o instanceof UserSpecifier && 38 | ((UserSpecifier)o).usertype.equals(usertype) 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/cetus/hir/UsingDeclaration.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is not supported */ 8 | public class UsingDeclaration extends Declaration 9 | { 10 | private static Method class_print_method; 11 | 12 | static 13 | { 14 | Class[] params = new Class[2]; 15 | 16 | try { 17 | params[0] = UsingDeclaration.class; 18 | params[1] = PrintWriter.class; 19 | class_print_method = params[0].getMethod("defaultPrint", params); 20 | } catch (NoSuchMethodException e) { 21 | throw new InternalError(); 22 | } 23 | } 24 | 25 | private IDExpression expr; 26 | 27 | public UsingDeclaration(IDExpression expr) 28 | { 29 | object_print_method = class_print_method; 30 | this.expr = expr; 31 | } 32 | 33 | public static void defaultPrint(UsingDeclaration d, PrintWriter o) 34 | { 35 | o.print("using "); 36 | d.expr.print(o); 37 | o.print(";"); 38 | } 39 | 40 | public List getDeclaredIDs() 41 | { 42 | return new LinkedList(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/cetus/hir/UsingDirective.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | /** This class is not supported */ 8 | public class UsingDirective extends Declaration 9 | { 10 | 11 | public List getDeclaredIDs() 12 | { 13 | return new LinkedList(); 14 | } 15 | 16 | public String toString() 17 | { 18 | return ""; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/cetus/hir/ValueInitializer.java: -------------------------------------------------------------------------------- 1 | package cetus.hir; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | public class ValueInitializer extends Initializer 8 | { 9 | public ValueInitializer(Expression value) 10 | { 11 | children.add(value); 12 | value.setParent(this); 13 | } 14 | 15 | public Expression getValue() 16 | { 17 | return (Expression)children.get(0); 18 | } 19 | 20 | public void print(PrintWriter o) 21 | { 22 | o.print(" = "); 23 | getValue().print(o); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/cetus/transforms/InlineExpansionPass.java: -------------------------------------------------------------------------------- 1 | package cetus.transforms; 2 | 3 | import cetus.analysis.InlineExpansion; 4 | import cetus.hir.DepthFirstIterator; 5 | import cetus.hir.Procedure; 6 | import cetus.hir.Program; 7 | 8 | /** 9 | * Transforms a program by performing simple subroutine in-line expansion in its main function. 10 | */ 11 | 12 | public class InlineExpansionPass extends TransformPass { 13 | 14 | /** Name of the inline expansion pass */ 15 | private static final String NAME = "[InlineExpansionPass]"; 16 | 17 | /** 18 | * Constructs an inline expansion pass 19 | * @param program - the program to perform inline expansion on 20 | */ 21 | public InlineExpansionPass(Program program) { 22 | super(program); 23 | } 24 | 25 | @Override 26 | public void start() { 27 | DepthFirstIterator i = new DepthFirstIterator(program); 28 | i.pruneOn(Procedure.class); 29 | // find the main function and perform inlining in its code 30 | while(i.hasNext()){ 31 | Object o = i.next(); 32 | if (o instanceof Procedure){ 33 | Procedure proc = (Procedure)o; 34 | String proc_name = proc.getName().toString(); 35 | if(proc_name.equals("main") || proc_name.equals("MAIN__")){ //f2c code uses MAIN__ 36 | new InlineExpansion().inline(proc); 37 | } 38 | } 39 | 40 | } 41 | } 42 | 43 | @Override 44 | public String getPassName() { 45 | return NAME; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/cetus/transforms/LoopTransformPass.java: -------------------------------------------------------------------------------- 1 | package cetus.transforms; 2 | 3 | import java.util.*; 4 | 5 | import cetus.hir.*; 6 | 7 | public abstract class LoopTransformPass extends TransformPass 8 | { 9 | protected LoopTransformPass(Program program) 10 | { 11 | super(program); 12 | } 13 | 14 | public abstract void transformLoop(Loop loop); 15 | 16 | public void start() 17 | { 18 | PostOrderIterator iter = new PostOrderIterator(program); 19 | 20 | for (;;) 21 | { 22 | Loop loop = null; 23 | 24 | try { 25 | loop = (Loop)iter.next(Loop.class); 26 | } catch (NoSuchElementException e) { 27 | break; 28 | } 29 | 30 | System.out.println("calling transformLoop"); 31 | transformLoop(loop); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/cetus/transforms/ProcedureTransformPass.java: -------------------------------------------------------------------------------- 1 | package cetus.transforms; 2 | 3 | import java.util.*; 4 | 5 | import cetus.exec.*; 6 | import cetus.hir.*; 7 | 8 | public abstract class ProcedureTransformPass extends TransformPass 9 | { 10 | protected ProcedureTransformPass(Program program) 11 | { 12 | super(program); 13 | } 14 | 15 | public abstract void transformProcedure(Procedure proc); 16 | 17 | public void start() 18 | { 19 | HashSet skip_set = Driver.getSkipProcedureSet(); 20 | 21 | DepthFirstIterator iter = new DepthFirstIterator(program); 22 | iter.pruneOn(Procedure.class); 23 | 24 | for (;;) 25 | { 26 | Procedure proc = null; 27 | 28 | try { 29 | proc = (Procedure)iter.next(Procedure.class); 30 | } catch (NoSuchElementException e) { 31 | break; 32 | } 33 | 34 | if (!skip_set.contains(proc.getName().toString())) 35 | { 36 | PrintTools.printlnStatus(getPassName() + " examining procedure " + proc.getName(), 2); 37 | 38 | transformProcedure(proc); 39 | } 40 | else 41 | { 42 | PrintTools.printlnStatus(getPassName() + " skipping procedure " + proc.getName(), 2); 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/cetus/transforms/RemoveUselessSpecifiers.java: -------------------------------------------------------------------------------- 1 | package cetus.transforms; 2 | 3 | import java.io.*; 4 | import java.lang.reflect.*; 5 | import java.util.*; 6 | 7 | import cetus.hir.*; 8 | 9 | public class RemoveUselessSpecifiers 10 | { 11 | private static String pass_name = "[RemoveUselessSpecifiers]"; 12 | 13 | private Program program; 14 | 15 | private RemoveUselessSpecifiers(Program program) 16 | { 17 | this.program = program; 18 | } 19 | 20 | public static void run(Program program) 21 | { 22 | PrintTools.printlnStatus(pass_name + " begin", 1); 23 | 24 | RemoveUselessSpecifiers pass = new RemoveUselessSpecifiers(program); 25 | pass.start(); 26 | 27 | PrintTools.printlnStatus(pass_name + " end", 1); 28 | } 29 | 30 | private void start() 31 | { 32 | DepthFirstIterator i = new DepthFirstIterator(program); 33 | i.pruneOn(VariableDeclaration.class); 34 | 35 | Set set = new HashSet(); 36 | set.add(Procedure.class); 37 | set.add(VariableDeclaration.class); 38 | 39 | for (;;) 40 | { 41 | Procedure proc = null; 42 | VariableDeclaration decl = null; 43 | 44 | try { 45 | Object o = i.next(set); 46 | if (o instanceof Procedure) 47 | proc = (Procedure)o; 48 | else 49 | decl = (VariableDeclaration)o; 50 | } catch (NoSuchElementException e) { 51 | break; 52 | } 53 | 54 | if (proc != null) 55 | { 56 | PrintTools.printlnStatus(pass_name + " examining procedure " + proc.getName(), 2); 57 | } 58 | else 59 | { 60 | while (decl.getSpecifiers().remove(Specifier.AUTO)); 61 | while (decl.getSpecifiers().remove(Specifier.REGISTER)); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/cetus/transforms/TransformPass.java: -------------------------------------------------------------------------------- 1 | package cetus.transforms; 2 | 3 | import cetus.hir.*; 4 | import cetus.analysis.IPPointsToAnalysis; 5 | import cetus.analysis.IPRangeAnalysis; 6 | 7 | /** 8 | * Base class of all transformation passes. For consistent compilation, there 9 | * are a series of checking processes at the end of every transformation pass. 10 | */ 11 | public abstract class TransformPass 12 | { 13 | /** The associated program */ 14 | protected Program program; 15 | 16 | /** Constructs a transform pass with the given program */ 17 | protected TransformPass(Program program) 18 | { 19 | this.program = program; 20 | } 21 | 22 | /** Returns the name of the transform pass */ 23 | public abstract String getPassName(); 24 | 25 | /** 26 | * Invokes the specified transform pass. 27 | * @param pass the transform pass that is to be run. 28 | */ 29 | public static void run(TransformPass pass) 30 | { 31 | double timer = Tools.getTime(); 32 | PrintTools.println(pass.getPassName() + " begin", 0); 33 | //pass.startAndCheck(); 34 | pass.start(); 35 | PrintTools.println(pass.getPassName() + " end in " + 36 | String.format("%.2f seconds", Tools.getTime(timer)), 0); 37 | if ( !IRTools.checkConsistency(pass.program) ) 38 | throw new InternalError("Inconsistent IR after " + pass.getPassName()); 39 | // Updates symbol link from each identifier. 40 | SymbolTools.linkSymbol(pass.program); 41 | // Invalidates points-to relations. 42 | IPPointsToAnalysis.clearPointsToRelations(); 43 | IPRangeAnalysis.clear(); 44 | // TODO: what about ddgraph ? 45 | } 46 | 47 | /** Starts a transform pass */ 48 | public abstract void start(); 49 | } 50 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/UnrollConfig.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus; 2 | 3 | public class UnrollConfig 4 | { 5 | private boolean m_bIsMultiConfig; 6 | private int[] m_rgUnrollings; 7 | 8 | 9 | private UnrollConfig () 10 | { 11 | } 12 | 13 | public UnrollConfig (String strConfig) 14 | { 15 | String[] rgUnrollingInDimensions = strConfig.split (":"); 16 | 17 | m_rgUnrollings = new int[rgUnrollingInDimensions.length]; 18 | for (int i = 0; i < rgUnrollingInDimensions.length; i++) 19 | m_rgUnrollings[i] = Integer.parseInt (rgUnrollingInDimensions[i]); 20 | 21 | if (rgUnrollingInDimensions.length == 1) 22 | m_bIsMultiConfig = true; 23 | } 24 | 25 | public UnrollConfig (int nUnrollFactorForAllDimensions) 26 | { 27 | m_rgUnrollings = new int[] { nUnrollFactorForAllDimensions }; 28 | m_bIsMultiConfig = true; 29 | } 30 | 31 | public int getUnrollingInDimension (int nDim) 32 | { 33 | if (m_bIsMultiConfig) 34 | return m_rgUnrollings[0]; 35 | 36 | if (nDim < 0 || nDim >= m_rgUnrollings.length) 37 | return 1; 38 | return m_rgUnrollings[nDim]; 39 | } 40 | 41 | public int[] getUnrollings () 42 | { 43 | return m_rgUnrollings; 44 | } 45 | 46 | public boolean isMultiConfig () 47 | { 48 | return m_bIsMultiConfig; 49 | } 50 | 51 | public UnrollConfig clone () 52 | { 53 | UnrollConfig config = new UnrollConfig (); 54 | 55 | config.m_bIsMultiConfig = m_bIsMultiConfig; 56 | config.m_rgUnrollings = new int[m_rgUnrollings.length]; 57 | System.arraycopy (m_rgUnrollings, 0, config.m_rgUnrollings, 0, m_rgUnrollings.length); 58 | 59 | return config; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/arch/TypeCgType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1-b02-fcs 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.08 at 05:45:06 PM CEST 6 | // 7 | 8 | 9 | package ch.unibas.cs.hpwc.patus.arch; 10 | 11 | import javax.xml.bind.annotation.XmlEnum; 12 | import javax.xml.bind.annotation.XmlEnumValue; 13 | 14 | 15 | /** 16 | *

Java class for typeCgType. 17 | * 18 | *

The following schema fragment specifies the expected content contained within this class. 19 | *

20 | *

21 |  * <simpleType name="typeCgType">
22 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
23 |  *     <enumeration value="pragma"/>
24 |  *     <enumeration value="functioncall"/>
25 |  *     <enumeration value="statement"/>
26 |  *   </restriction>
27 |  * </simpleType>
28 |  * 
29 | * 30 | */ 31 | @XmlEnum 32 | public enum TypeCgType { 33 | 34 | @XmlEnumValue("pragma") 35 | PRAGMA("pragma"), 36 | @XmlEnumValue("functioncall") 37 | FUNCTIONCALL("functioncall"), 38 | @XmlEnumValue("statement") 39 | STATEMENT("statement"); 40 | private final String value; 41 | 42 | TypeCgType(String v) { 43 | value = v; 44 | } 45 | 46 | public String value() { 47 | return value; 48 | } 49 | 50 | public static TypeCgType fromValue(String v) { 51 | for (TypeCgType c: TypeCgType.values()) { 52 | if (c.value.equals(v)) { 53 | return c; 54 | } 55 | } 56 | throw new IllegalArgumentException(v); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/arch/TypeRegisterType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.1-b02-fcs 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.08 at 05:45:06 PM CEST 6 | // 7 | 8 | 9 | package ch.unibas.cs.hpwc.patus.arch; 10 | 11 | import javax.xml.bind.annotation.XmlEnum; 12 | import javax.xml.bind.annotation.XmlEnumValue; 13 | 14 | 15 | /** 16 | *

Java class for typeRegisterType. 17 | * 18 | *

The following schema fragment specifies the expected content contained within this class. 19 | *

20 | *

21 |  * <simpleType name="typeRegisterType">
22 |  *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
23 |  *     <enumeration value="gpr"/>
24 |  *     <enumeration value="fpr"/>
25 |  *     <enumeration value="simd"/>
26 |  *   </restriction>
27 |  * </simpleType>
28 |  * 
29 | * 30 | */ 31 | @XmlEnum 32 | public enum TypeRegisterType { 33 | 34 | @XmlEnumValue("gpr") 35 | GPR("gpr"), 36 | @XmlEnumValue("fpr") 37 | FPR("fpr"), 38 | @XmlEnumValue("simd") 39 | SIMD("simd"); 40 | private final String value; 41 | 42 | TypeRegisterType(String v) { 43 | value = v; 44 | } 45 | 46 | public String value() { 47 | return value; 48 | } 49 | 50 | public static TypeRegisterType fromValue(String v) { 51 | for (TypeRegisterType c: TypeRegisterType.values()) { 52 | if (c.value.equals(v)) { 53 | return c; 54 | } 55 | } 56 | throw new IllegalArgumentException(v); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/ast/BoundaryCheck.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.ast; 2 | 3 | import java.io.PrintWriter; 4 | 5 | import cetus.hir.Statement; 6 | 7 | public class BoundaryCheck extends Statement 8 | { 9 | /////////////////////////////////////////////////////////////////// 10 | // Member Variables 11 | 12 | private SubdomainIterator m_sdit; 13 | private Statement m_stmtWithChecks; 14 | private Statement m_stmtWithoutChecks; 15 | 16 | 17 | /////////////////////////////////////////////////////////////////// 18 | // Implementation 19 | 20 | public BoundaryCheck (SubdomainIterator it, Statement stmtWithChecks, Statement stmtWithoutChecks) 21 | { 22 | m_sdit = it; 23 | m_stmtWithChecks = stmtWithChecks; 24 | m_stmtWithoutChecks = stmtWithoutChecks; 25 | 26 | if (stmtWithChecks != null) 27 | addChild (stmtWithChecks); 28 | if (stmtWithoutChecks != null) 29 | addChild (stmtWithoutChecks); 30 | } 31 | 32 | public SubdomainIterator getSubdomainIterator () 33 | { 34 | return m_sdit; 35 | } 36 | 37 | public Statement getWithChecks () 38 | { 39 | return m_stmtWithChecks; 40 | } 41 | 42 | public Statement getWithoutChecks () 43 | { 44 | return m_stmtWithoutChecks; 45 | } 46 | 47 | public BoundaryCheck clone () 48 | { 49 | return new BoundaryCheck (m_sdit.clone (), m_stmtWithChecks.clone (), m_stmtWithoutChecks.clone ()); 50 | } 51 | 52 | @Override 53 | public void print (PrintWriter out) 54 | { 55 | out.print ("if (check_bnds ("); 56 | out.print (m_sdit.getIterator ().toString ()); 57 | out.println ("))"); 58 | m_stmtWithChecks.print (out); 59 | out.println ("\nelse"); 60 | m_stmtWithoutChecks.print (out); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/ast/IStatementList.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.ast; 12 | 13 | import cetus.hir.Declaration; 14 | import cetus.hir.Statement; 15 | 16 | public interface IStatementList 17 | { 18 | /** 19 | * 20 | * @param stmt 21 | */ 22 | public abstract void addStatement (Statement stmt); 23 | 24 | /** 25 | * 26 | * @param declaration 27 | */ 28 | public abstract void addDeclaration (Declaration declaration); 29 | 30 | public void addStatementAtTop (Statement stmt); 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/ast/UniqueStatementList.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.ast; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import cetus.hir.Statement; 7 | 8 | public class UniqueStatementList extends StatementList 9 | { 10 | /////////////////////////////////////////////////////////////////// 11 | // Member Variables 12 | 13 | private Set m_setStatements; 14 | 15 | 16 | /////////////////////////////////////////////////////////////////// 17 | // Implementation 18 | 19 | public UniqueStatementList () 20 | { 21 | m_setStatements = new HashSet<> (); 22 | } 23 | 24 | private boolean existsStatement (Statement stmt) 25 | { 26 | return m_setStatements.contains (stmt.toString ()); 27 | } 28 | 29 | @Override 30 | public void addStatement (Statement stmt) 31 | { 32 | if (stmt == null || existsStatement (stmt)) 33 | return; 34 | 35 | m_setStatements.add (stmt.toString ()); 36 | super.addStatement (stmt); 37 | } 38 | 39 | @Override 40 | public void addStatementAtTop (Statement stmt) 41 | { 42 | if (stmt == null || existsStatement (stmt)) 43 | return; 44 | 45 | m_setStatements.add (stmt.toString ()); 46 | super.addStatementAtTop (stmt); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/IBaseCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen; 2 | 3 | public interface IBaseCodeGenerator 4 | { 5 | public String getFileHeader (); 6 | public String getIncludesAndDefines (boolean bIncludeAutotuneParameters); 7 | } 8 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/ICodeGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen; 12 | 13 | import cetus.hir.Traversable; 14 | import ch.unibas.cs.hpwc.patus.ast.StatementListBundle; 15 | import ch.unibas.cs.hpwc.patus.codegen.options.CodeGeneratorRuntimeOptions; 16 | 17 | public interface ICodeGenerator 18 | { 19 | /** 20 | * Generates code for a particular type of input. 21 | * @param trvInput The input structure 22 | * @return A statement list bundle containing the generated output structure 23 | */ 24 | public abstract StatementListBundle generate (Traversable trvInput, CodeGeneratorRuntimeOptions options); 25 | } 26 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/IConstantExpressionCalculator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen; 12 | 13 | import cetus.hir.Expression; 14 | import cetus.hir.Specifier; 15 | import cetus.hir.Traversable; 16 | 17 | /** 18 | * 19 | * @author Matthias-M. Christen 20 | */ 21 | public interface IConstantExpressionCalculator 22 | { 23 | /** 24 | * 25 | * @param expr 26 | * @param specDatatype 27 | * @return 28 | */ 29 | public abstract Traversable calculateConstantExpression (Expression exprExpression, Specifier specDatatype, boolean bVectorize); 30 | } 31 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/IInnermostLoopCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen; 2 | 3 | import cetus.hir.Traversable; 4 | import ch.unibas.cs.hpwc.patus.ast.StatementListBundle; 5 | import ch.unibas.cs.hpwc.patus.codegen.options.CodeGeneratorRuntimeOptions; 6 | 7 | 8 | public interface IInnermostLoopCodeGenerator extends ICodeGenerator 9 | { 10 | /** 11 | * Generates code for an innermost loop containing a stencil call. 12 | * 13 | * @param sdit 14 | * The subdomain iterator containing the innermost loop with a 15 | * stencil computation for which to generate the code 16 | * @param options 17 | * Code generation-time options 18 | */ 19 | @Override 20 | public StatementListBundle generate (Traversable sdit, CodeGeneratorRuntimeOptions options); 21 | 22 | /** 23 | * Tells whether for the instance of the inner most loop code generator the 24 | * assembly section in the architecture description is required. 25 | * 26 | * @return true iff the instance of the code generator requires 27 | * the assembly specification 28 | */ 29 | public abstract boolean requiresAssemblySection (); 30 | } 31 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/IInternalAutotuningParameters.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen; 12 | 13 | /** 14 | * 15 | * @author Matthias-M. Christen 16 | */ 17 | public interface IInternalAutotuningParameters 18 | { 19 | public final static String LOOP_UNROLLING = "loop_unrolling"; 20 | 21 | public final static String PADDING = "padding"; 22 | } 23 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/ProjectionMask.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen; 12 | 13 | import cetus.hir.Expression; 14 | import ch.unibas.cs.hpwc.patus.ast.SubdomainIterator; 15 | import ch.unibas.cs.hpwc.patus.geometry.Vector; 16 | import ch.unibas.cs.hpwc.patus.util.ExpressionUtil; 17 | 18 | public class ProjectionMask extends AbstractMask 19 | { 20 | /////////////////////////////////////////////////////////////////// 21 | // Implementation 22 | 23 | public ProjectionMask (SubdomainIterator it) 24 | { 25 | this (it.getIteratorSubdomain ().getBox ().getSize ().getCoords ()); 26 | } 27 | 28 | public ProjectionMask (Vector v) 29 | { 30 | this (v.getCoords ()); 31 | } 32 | 33 | public ProjectionMask (Expression[] rgExpressions) 34 | { 35 | super (rgExpressions); 36 | } 37 | 38 | @Override 39 | protected int[] createMask (Expression[] rgExpressions) 40 | { 41 | int[] rgMask = new int[rgExpressions.length]; 42 | for (int i = 0; i < rgExpressions.length; i++) 43 | rgMask[i] = ExpressionUtil.isValue (rgExpressions[i], 1) ? 1 : 0; 44 | return rgMask; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/ProjectionUnmask.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen; 12 | 13 | import cetus.hir.Expression; 14 | import ch.unibas.cs.hpwc.patus.ast.SubdomainIterator; 15 | import ch.unibas.cs.hpwc.patus.geometry.Vector; 16 | 17 | /** 18 | * 19 | * @author Matthias-M. Christen 20 | */ 21 | public class ProjectionUnmask extends InverseMask 22 | { 23 | /////////////////////////////////////////////////////////////////// 24 | // Implementation 25 | 26 | public ProjectionUnmask (SubdomainIterator it) 27 | { 28 | this (it.getIteratorSubdomain ().getBox ().getSize ().getCoords ()); 29 | } 30 | 31 | public ProjectionUnmask (Vector v) 32 | { 33 | this (v.getCoords ()); 34 | } 35 | 36 | public ProjectionUnmask (Expression[] rgExpressions) 37 | { 38 | super (rgExpressions, ProjectionMask.class); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/ReuseUnmask.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen; 12 | 13 | import cetus.hir.Expression; 14 | import ch.unibas.cs.hpwc.patus.ast.SubdomainIterator; 15 | import ch.unibas.cs.hpwc.patus.geometry.Vector; 16 | 17 | public class ReuseUnmask extends InverseMask 18 | { 19 | /////////////////////////////////////////////////////////////////// 20 | // Implementation 21 | 22 | public ReuseUnmask (SubdomainIterator it) 23 | { 24 | this (it.getIteratorSubdomain ().getBox ().getSize ().getCoords ()); 25 | } 26 | 27 | public ReuseUnmask (Vector v) 28 | { 29 | this (v.getCoords ()); 30 | } 31 | 32 | public ReuseUnmask (Expression[] rgExpressions) 33 | { 34 | super (rgExpressions, ReuseMask.class); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/IAdditionalKernelSpecific.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen.backend; 12 | 13 | public interface IAdditionalKernelSpecific 14 | { 15 | /** 16 | * Returns a string with additional code to be added after the includes and before the actual kernel code. 17 | * @return Additional code 18 | */ 19 | public abstract String getAdditionalKernelSpecificCode (); 20 | } 21 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/IBackend.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen.backend; 12 | 13 | import ch.unibas.cs.hpwc.patus.codegen.KernelSourceFile; 14 | 15 | /** 16 | * The backend code generator. 17 | * @author Matthias-M. Christen 18 | */ 19 | public interface IBackend extends IParallel, IDataTransfer, IIndexing, IArithmetic, IAdditionalKernelSpecific, INonKernelFunctions 20 | { 21 | /** 22 | * 23 | * @param ksf 24 | */ 25 | public abstract void setKernelSourceFile (KernelSourceFile ksf); 26 | } 27 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/IParallel.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen.backend; 12 | 13 | import cetus.hir.Statement; 14 | 15 | /** 16 | * Hardware-/programming model-specific parallelization intrinsics 17 | * (that are used for stencil kernel code generation). 18 | * 19 | * @author Matthias-M. Christen 20 | */ 21 | public interface IParallel 22 | { 23 | /** 24 | * Implements a barrier. 25 | */ 26 | public abstract Statement getBarrier (int nParallelismLevel); 27 | } 28 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/IndexingLevelUtil.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend; 2 | 3 | import ch.unibas.cs.hpwc.patus.codegen.backend.IIndexing.IIndexingLevel; 4 | 5 | public class IndexingLevelUtil 6 | { 7 | /** 8 | * Converts the parallelism level to an indexing level and returns the corresponding indexing 9 | * level object. 10 | * The lowest parallelism level is assigned to the outer-most loop, which corresponds to the 11 | * highest indexing level. 12 | * @param indexing 13 | * @param nParallelismLevel 14 | * @return 15 | */ 16 | public static IIndexingLevel getIndexingLevelFromParallelismLevel (IIndexing indexing, int nParallelismLevel) 17 | { 18 | int nIndexingLevelsCount = indexing.getIndexingLevelsCount (); 19 | if (nParallelismLevel <= 0) 20 | return indexing.getIndexingLevel (nIndexingLevelsCount - 1); 21 | if (nParallelismLevel >= nIndexingLevelsCount) 22 | return indexing.getIndexingLevel (0); 23 | return indexing.getIndexingLevel (nIndexingLevelsCount - nParallelismLevel); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/AbstractInstruction.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly; 2 | 3 | import ch.unibas.cs.hpwc.patus.ast.ParameterAssignment; 4 | 5 | public abstract class AbstractInstruction implements IInstruction 6 | { 7 | /////////////////////////////////////////////////////////////////// 8 | // Member Variables 9 | 10 | protected ParameterAssignment m_pa; 11 | 12 | 13 | /////////////////////////////////////////////////////////////////// 14 | // Implementation 15 | 16 | public AbstractInstruction () 17 | { 18 | m_pa = null; 19 | } 20 | 21 | @Override 22 | public void setParameterAssignment (ParameterAssignment pa) 23 | { 24 | m_pa = pa; 25 | } 26 | 27 | @Override 28 | public ParameterAssignment getParameterAssignment () 29 | { 30 | return m_pa; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/AddSub.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly; 2 | 3 | import cetus.hir.BinaryOperator; 4 | import cetus.hir.Expression; 5 | import ch.unibas.cs.hpwc.patus.arch.TypeBaseIntrinsicEnum; 6 | import ch.unibas.cs.hpwc.patus.codegen.Globals; 7 | import ch.unibas.cs.hpwc.patus.util.StringUtil; 8 | 9 | /** 10 | * 11 | * @author Matthias-M. Christen 12 | */ 13 | class AddSub 14 | { 15 | /////////////////////////////////////////////////////////////////// 16 | // Member Variables 17 | 18 | private Expression m_expr; 19 | private BinaryOperator m_op; 20 | 21 | 22 | /////////////////////////////////////////////////////////////////// 23 | // Implementation 24 | 25 | public AddSub (BinaryOperator op, Expression expr) 26 | { 27 | m_op = op; 28 | m_expr = expr; 29 | } 30 | 31 | public Expression getExpression () 32 | { 33 | return m_expr; 34 | } 35 | 36 | public TypeBaseIntrinsicEnum getBaseIntrinsic () 37 | { 38 | return Globals.getIntrinsicBase (m_op); 39 | } 40 | 41 | public BinaryOperator getOperator () 42 | { 43 | return m_op; 44 | } 45 | 46 | @Override 47 | public String toString () 48 | { 49 | return StringUtil.concat (m_op.toString (), m_expr.toString ()); 50 | } 51 | } -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/AssemblyParameters.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly; 2 | 3 | public class AssemblyParameters 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/Comment.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly; 2 | 3 | import java.util.Map; 4 | 5 | import ch.unibas.cs.hpwc.patus.arch.TypeBaseIntrinsicEnum; 6 | import ch.unibas.cs.hpwc.patus.ast.ParameterAssignment; 7 | import ch.unibas.cs.hpwc.patus.util.StringUtil; 8 | 9 | public class Comment extends AbstractInstruction 10 | { 11 | private String m_strComment; 12 | 13 | 14 | public Comment (String strComment) 15 | { 16 | m_strComment = strComment; 17 | } 18 | 19 | public Comment (String strComment, ParameterAssignment pa) 20 | { 21 | this (strComment); 22 | setParameterAssignment (pa); 23 | } 24 | 25 | @Override 26 | public void issue (StringBuilder sbResult) 27 | { 28 | sbResult.append ("/* "); 29 | sbResult.append (m_strComment); 30 | sbResult.append (" */"); 31 | } 32 | 33 | @Override 34 | public TypeBaseIntrinsicEnum getIntrinsic () 35 | { 36 | // this instruction doesn't correspond to an intrinsic 37 | return null; 38 | } 39 | 40 | @Override 41 | public String toString () 42 | { 43 | return StringUtil.concat ("/* ", m_strComment, " */"); 44 | } 45 | 46 | @Override 47 | public String toJavaCode (Map mapOperands) 48 | { 49 | return StringUtil.concat ("new Comment (\"", m_strComment, "\");"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/IInstruction.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly; 2 | 3 | import java.util.Map; 4 | 5 | import ch.unibas.cs.hpwc.patus.arch.TypeBaseIntrinsicEnum; 6 | import ch.unibas.cs.hpwc.patus.ast.ParameterAssignment; 7 | 8 | 9 | /** 10 | * Interface for assembly instructions. 11 | * @author Matthias-M. Christen 12 | */ 13 | public interface IInstruction 14 | { 15 | /** 16 | * Issues the instruction, i.e., adds the assembly code to 17 | * sbResult. 18 | * 19 | * @param sbResult 20 | * The string builder to which the result is added 21 | */ 22 | public abstract void issue (StringBuilder sbResult); 23 | 24 | /** 25 | * Returns the intrinsic corresponding to this instruction or 26 | * null if the instruction doesn't correspond to an intrinsic 27 | * defined in the architecture description. 28 | * 29 | * @return The intrinsic corresponding to this instruction 30 | */ 31 | public abstract TypeBaseIntrinsicEnum getIntrinsic (); 32 | 33 | /** 34 | * Returns the Java code to create this instruction. 35 | * @return 36 | */ 37 | public abstract String toJavaCode (Map mapOperands); 38 | 39 | public abstract void setParameterAssignment (ParameterAssignment pa); 40 | public abstract ParameterAssignment getParameterAssignment (); 41 | } 42 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/TooFewRegistersException.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly; 2 | 3 | import ch.unibas.cs.hpwc.patus.arch.TypeRegisterType; 4 | 5 | public class TooFewRegistersException extends Exception 6 | { 7 | private static final long serialVersionUID = 1L; 8 | 9 | private TypeRegisterType m_regtype; 10 | private int m_nExcessRegisterRequirement; 11 | 12 | public TooFewRegistersException (TypeRegisterType regtype, int nExcessRegisterRequirement) 13 | { 14 | m_regtype = regtype; 15 | m_nExcessRegisterRequirement = nExcessRegisterRequirement; 16 | } 17 | 18 | public TypeRegisterType getRegisterType () 19 | { 20 | return m_regtype; 21 | } 22 | 23 | public int getExcessRegisterRequirement () 24 | { 25 | return m_nExcessRegisterRequirement; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/copt6.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/copt6.pdf -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/optimize/IInstructionListOptimizer.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly.optimize; 2 | 3 | import ch.unibas.cs.hpwc.patus.codegen.backend.assembly.InstructionList; 4 | 5 | /** 6 | * Interface definition for instruction list optimizers 7 | * @author Matthias-M. Christen 8 | */ 9 | public interface IInstructionListOptimizer 10 | { 11 | /** 12 | * Does an optimization pass on the input instruction list il. 13 | * @param il The instruction list to optimize 14 | * @return The optimized instruction list 15 | */ 16 | public abstract InstructionList optimize (InstructionList il); 17 | } 18 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/optimize/InstructionScheduleOptimizer.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.assembly.optimize; 2 | 3 | import cetus.hir.Specifier; 4 | import ch.unibas.cs.hpwc.patus.arch.IArchitectureDescription; 5 | import ch.unibas.cs.hpwc.patus.codegen.backend.assembly.InstructionList; 6 | import ch.unibas.cs.hpwc.patus.codegen.backend.assembly.InstructionScheduler; 7 | import ch.unibas.cs.hpwc.patus.codegen.backend.assembly.analyze.DependenceAnalysis; 8 | 9 | public class InstructionScheduleOptimizer implements IInstructionListOptimizer 10 | { 11 | private IArchitectureDescription m_arch; 12 | private Specifier m_specDatatype; 13 | 14 | public InstructionScheduleOptimizer (IArchitectureDescription arch, Specifier specDatatype) 15 | { 16 | m_arch = arch; 17 | m_specDatatype = specDatatype; 18 | } 19 | 20 | @Override 21 | public InstructionList optimize (InstructionList il) 22 | { 23 | return new InstructionScheduler (new DependenceAnalysis (il, m_arch).run (m_specDatatype), m_arch).schedule (); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/p121-wilken.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/p121-wilken.pdf -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/translate-instructions.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src/ch/unibas/cs/hpwc/patus/codegen/backend/assembly/translate-instructions.ods -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/cuda/CUDA1DCodeGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen.backend.cuda; 12 | 13 | import ch.unibas.cs.hpwc.patus.codegen.CodeGeneratorSharedObjects; 14 | 15 | /** 16 | * 17 | * @author Matthias-M. Christen 18 | */ 19 | public class CUDA1DCodeGenerator extends AbstractCUDACodeGenerator 20 | { 21 | /////////////////////////////////////////////////////////////////// 22 | // Implementation 23 | 24 | public CUDA1DCodeGenerator (CodeGeneratorSharedObjects data) 25 | { 26 | super (data); 27 | } 28 | 29 | @Override 30 | protected int getIndexingLevelDimensionality (int nIndexingLevel) 31 | { 32 | return 1; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/cuda/CUDA4CodeGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen.backend.cuda; 12 | 13 | import ch.unibas.cs.hpwc.patus.codegen.CodeGeneratorSharedObjects; 14 | 15 | public class CUDA4CodeGenerator extends AbstractCUDACodeGenerator 16 | { 17 | /////////////////////////////////////////////////////////////////// 18 | // Constants 19 | 20 | /** 21 | * CUDA 4.0 and above allow (3, 3)-indexing on Fermi cards 22 | */ 23 | private final static int[] INDEXING_LEVEL_DIMENSIONALITIES = new int[] { 3, 3 }; 24 | 25 | 26 | /////////////////////////////////////////////////////////////////// 27 | // Implementation 28 | 29 | public CUDA4CodeGenerator (CodeGeneratorSharedObjects data) 30 | { 31 | super (data); 32 | } 33 | 34 | @Override 35 | protected int getIndexingLevelDimensionality (int nIndexingLevel) 36 | { 37 | return INDEXING_LEVEL_DIMENSIONALITIES[nIndexingLevel]; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/cuda/CUDACodeGenerator.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.codegen.backend.cuda; 12 | 13 | import ch.unibas.cs.hpwc.patus.codegen.CodeGeneratorSharedObjects; 14 | 15 | /** 16 | * 17 | * @author Matthias-M. Christen 18 | */ 19 | public class CUDACodeGenerator extends AbstractCUDACodeGenerator 20 | { 21 | /////////////////////////////////////////////////////////////////// 22 | // Constants 23 | 24 | private final static int[] INDEXING_LEVEL_DIMENSIONALITIES = new int[] { 3, 2 }; 25 | 26 | 27 | /////////////////////////////////////////////////////////////////// 28 | // Implementation 29 | 30 | public CUDACodeGenerator (CodeGeneratorSharedObjects data) 31 | { 32 | super (data); 33 | } 34 | 35 | @Override 36 | protected int getIndexingLevelDimensionality (int nIndexingLevel) 37 | { 38 | return INDEXING_LEVEL_DIMENSIONALITIES[nIndexingLevel]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/intel/TestIntelXeonCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.intel; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | import cetus.hir.Specifier; 8 | 9 | public class TestIntelXeonCodeGenerator { 10 | 11 | @Test 12 | public void TestgetVecLoadFunctionNameFloat() { 13 | IntelXeonCodeGenerator cg = new IntelXeonCodeGenerator(null); 14 | 15 | assertEquals(cg.getVecLoadFunctionName(Specifier.FLOAT), 16 | "_mm512_extload_ps"); 17 | } 18 | 19 | @Test 20 | public void TestgetVecLoadFunctionNameDouble() { 21 | IntelXeonCodeGenerator cg = new IntelXeonCodeGenerator(null); 22 | 23 | assertEquals(cg.getVecLoadFunctionName(Specifier.DOUBLE), 24 | "_mm512_extload_pd"); 25 | } 26 | 27 | @Test 28 | public void TesthasVecLoadFunctionPointerArg(){ 29 | IntelXeonCodeGenerator cg = new IntelXeonCodeGenerator(null); 30 | assertEquals(true, cg.hasVecLoadFunctionPointerArg()); 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/openmp/OpenMPAVXAsmCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.codegen.backend.openmp; 2 | 3 | import cetus.hir.Expression; 4 | import cetus.hir.Specifier; 5 | import ch.unibas.cs.hpwc.patus.codegen.CodeGeneratorSharedObjects; 6 | 7 | public class OpenMPAVXAsmCodeGenerator extends OpenMPAVXCodeGenerator 8 | { 9 | public OpenMPAVXAsmCodeGenerator (CodeGeneratorSharedObjects data) 10 | { 11 | super (data); 12 | } 13 | 14 | @Override 15 | public Expression unary_minus (Expression expr, Specifier specDatatype, boolean bVectorize) 16 | { 17 | return super.unary_minus (expr, specDatatype, bVectorize); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/codegen/backend/openmp/test_avxselect.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void print_vector_ps (char* szLabel, __m256 v) 6 | { 7 | float a[8]; 8 | __asm__ ( 9 | "vmovups (%0),%%ymm0\n\t" 10 | "vmovups %%ymm0,(%1)\n\t" 11 | : 12 | : "r"(&v), "r"(a) 13 | ); 14 | printf ("%s: %f, %f, %f, %f, %f, %f, %f, %f\n", szLabel, 15 | a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7] 16 | ); 17 | } 18 | 19 | int main (int argc, char** argv) 20 | { 21 | __m256 expr1 = { 0, 1, 2, 3, 4, 5, 6, 7 }; 22 | __m256 expr2 = { 8, 9, 10, 11, 12, 13, 14, 15 }; 23 | 24 | print_vector_ps ("1", (__m256) _mm256_shuffle_pd ((__m256d) expr1, (__m256d) _mm256_permute2f128_ps (expr1, expr2, 33), 5)); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/config/IConfigurable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.config; 12 | 13 | /** 14 | * 15 | * @author Matthias-M. Christen 16 | */ 17 | public interface IConfigurable 18 | { 19 | /** 20 | * Returns an iterable over all the configuration properties this configurable 21 | * provides and which can be configured by the user. 22 | */ 23 | public abstract Iterable getConfigurationProperties (); 24 | } 25 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/grammar/stencil2/Range.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.grammar.stencil2; 2 | 3 | import ch.unibas.cs.hpwc.patus.util.StringUtil; 4 | 5 | public class Range 6 | { 7 | private int m_nStart; 8 | private int m_nEnd; 9 | 10 | public Range (int nStart, int nEnd) 11 | { 12 | if (nStart > nEnd) 13 | throw new RuntimeException ("'start' must not be larger than 'end'."); 14 | m_nStart = nStart; 15 | m_nEnd = nEnd; 16 | } 17 | 18 | public int getStart () 19 | { 20 | return m_nStart; 21 | } 22 | 23 | public int getEnd () 24 | { 25 | return m_nEnd; 26 | } 27 | 28 | public int getSize () 29 | { 30 | return m_nEnd - m_nStart + 1; 31 | } 32 | 33 | @Override 34 | public String toString () 35 | { 36 | return StringUtil.concat ("[", m_nStart, "..", m_nEnd, "]"); 37 | } 38 | } -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/graph/IEdge.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.graph; 2 | 3 | public interface IEdge 4 | { 5 | public abstract V getHeadVertex (); 6 | 7 | public abstract V getTailVertex (); 8 | } -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/graph/IGraph.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.graph; 2 | 3 | import ch.unibas.cs.hpwc.patus.util.IParallelOperation; 4 | 5 | /** 6 | * A general graph data structure. 7 | * 8 | * @author Matthias-M. Christen 9 | * 10 | * @param The vertex type 11 | * @param The edge type 12 | */ 13 | public interface IGraph 14 | { 15 | /** 16 | * Adds a new vertex to the graph. 17 | * 18 | * @param vertex 19 | * The vertex to add 20 | */ 21 | public abstract void addVertex (V vertex); 22 | 23 | /** 24 | * Adds a new edge to the graph. 25 | * 26 | * @param edge 27 | * The edge to add 28 | */ 29 | public abstract void addEdge (E edge); 30 | 31 | /** 32 | * Returns an iterable over all vertices in the graph. 33 | * 34 | * @return An iterable over the graph's vertices 35 | */ 36 | public abstract Iterable getVertices (); 37 | 38 | /** 39 | * Returns an iterable over all edges in the graph. 40 | * 41 | * @return An iterable over the graph's edges 42 | */ 43 | public abstract Iterable getEdges (); 44 | 45 | /** 46 | * Returns the number of vertices in the graph. 47 | * 48 | * @return The number of vertices 49 | */ 50 | public abstract int getVerticesCount (); 51 | 52 | /** 53 | * Returns the number of edges in the graph. 54 | * 55 | * @return The number of edges 56 | */ 57 | public abstract int getEdgesCount (); 58 | 59 | public abstract void removeAllVertices (); 60 | public abstract void removeAllEdges (); 61 | 62 | /** 63 | * 64 | * @param op 65 | */ 66 | public abstract void forAllVertices (IParallelOperation op); 67 | 68 | /** 69 | * 70 | * @param op 71 | */ 72 | public abstract void forAllEdges (IParallelOperation op); 73 | } 74 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/graph/IParametrizedEdge.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.graph; 2 | 3 | public interface IParametrizedEdge extends IEdge, IParametrizedObject 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/graph/IParametrizedObject.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.graph; 2 | 3 | public interface IParametrizedObject 4 | { 5 | public abstract void setData (T data); 6 | 7 | public abstract T getData (); 8 | } 9 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/graph/IParametrizedVertex.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.graph; 2 | 3 | public interface IParametrizedVertex extends IVertex, IParametrizedObject 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/graph/IVertex.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.graph; 2 | 3 | public interface IVertex 4 | { 5 | 6 | } -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/representation/ISpaceIndexable.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.representation; 12 | 13 | public interface ISpaceIndexable 14 | { 15 | /** 16 | * Returns the space index, an array of integers corresponding to 17 | * the spatial coordinates. 18 | * @return The spatial coordinates as an int array 19 | */ 20 | public abstract int[] getSpaceIndex (); 21 | } 22 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/symbolic/IMaximaConfiguration.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | /* $Id$ 12 | * 13 | * Copyright (c) 2010, The University of Edinburgh. 14 | * All Rights Reserved 15 | */ 16 | package ch.unibas.cs.hpwc.patus.symbolic; 17 | 18 | /** 19 | * Interface for a class which provides configuration details for connecting to 20 | * Maxima. 21 | * 22 | * @see HardCodedMaximaConfiguration 23 | * @see PropertiesMaximaConfiguration 24 | * 25 | * @author David McKain 26 | * @version $Revision$ 27 | */ 28 | public interface IMaximaConfiguration 29 | { 30 | /** 31 | * Returns the path where Maxima is installed. 32 | * @return The path to Maxima 33 | */ 34 | String getMaximaExecutablePath (); 35 | 36 | /** 37 | * An array of environment variables, in the format varname=value. 38 | * @return 39 | */ 40 | String[] getMaximaRuntimeEnvironment (); 41 | 42 | /** 43 | * The default call timeout in seconds. 44 | * @return 45 | */ 46 | int getDefaultCallTimeout (); 47 | } 48 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/symbolic/NotConvertableException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2011 Matthias-M. Christen, University of Basel, Switzerland. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the GNU Lesser Public License v2.1 5 | * which accompanies this distribution, and is available at 6 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 7 | * 8 | * Contributors: 9 | * Matthias-M. Christen, University of Basel, Switzerland - initial API and implementation 10 | ******************************************************************************/ 11 | package ch.unibas.cs.hpwc.patus.symbolic; 12 | 13 | import cetus.hir.Expression; 14 | 15 | /** 16 | * 17 | * @author Matthias-M. Christen 18 | */ 19 | public class NotConvertableException extends Exception 20 | { 21 | private static final long serialVersionUID = 1L; 22 | 23 | 24 | /////////////////////////////////////////////////////////////////// 25 | // Member Variables 26 | 27 | 28 | /////////////////////////////////////////////////////////////////// 29 | // Implementation 30 | 31 | public NotConvertableException () 32 | { 33 | super (); 34 | } 35 | 36 | public NotConvertableException (String s) 37 | { 38 | super (s); 39 | } 40 | 41 | public NotConvertableException (Expression expr) 42 | { 43 | super ("The expression " + expr.toString () + " can't be converted to a Maxima expression"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/util/IParallelOperation.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.util; 2 | 3 | public interface IParallelOperation 4 | { 5 | /** 6 | * Performs an operation on the element element. 7 | * 8 | * @param element 9 | * The element on which to perform the operation 10 | */ 11 | public abstract void perform (T element); 12 | } 13 | -------------------------------------------------------------------------------- /src/ch/unibas/cs/hpwc/patus/util/StringUtilTest.java: -------------------------------------------------------------------------------- 1 | package ch.unibas.cs.hpwc.patus.util; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class StringUtilTest 8 | { 9 | @Test 10 | public void testTrimLeft () 11 | { 12 | assertEquals ("test", StringUtil.trimLeft ("test", new char[] { '_' })); 13 | assertEquals ("test", StringUtil.trimLeft ("_test", new char[] { '_' })); 14 | assertEquals ("test", StringUtil.trimLeft ("__test", new char[] { '_' })); 15 | assertEquals ("test", StringUtil.trimLeft ("_#test", new char[] { '_', '#' })); 16 | assertEquals ("", StringUtil.trimLeft ("___", new char[] { '_' })); 17 | assertEquals ("test_", StringUtil.trimLeft ("_test_", new char[] { '_' })); 18 | } 19 | 20 | @Test 21 | public void testTrimRight () 22 | { 23 | assertEquals ("test", StringUtil.trimRight ("test", new char[] { '_' })); 24 | assertEquals ("test", StringUtil.trimRight ("test__", new char[] { '_' })); 25 | assertEquals ("test", StringUtil.trimRight ("test#_", new char[] { '_', '#' })); 26 | assertEquals ("", StringUtil.trimRight ("___", new char[] { '_' })); 27 | assertEquals ("_test", StringUtil.trimRight ("_test_", new char[] { '_' })); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/log4j.properties: -------------------------------------------------------------------------------- 1 | # direct log messages to stdout 2 | 3 | # for release 4 | log4j.rootLogger=DEBUG, stdout 5 | log4j.appender.stdout.layout.ConversionPattern=(%p) %m%n 6 | 7 | # for debugging 8 | #log4j.rootLogger=debug, stdout 9 | #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} (%5p) %c{1}:%L - %m%n 10 | 11 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 12 | log4j.appender.stdout.Target=System.out 13 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 14 | -------------------------------------------------------------------------------- /src_jni/ch_unibas_cs_hpwc_patus_ilp_ILPModel_EOperator.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class ch_unibas_cs_hpwc_patus_ilp_ILPModel_EOperator */ 4 | 5 | #ifndef _Included_ch_unibas_cs_hpwc_patus_ilp_ILPModel_EOperator 6 | #define _Included_ch_unibas_cs_hpwc_patus_ilp_ILPModel_EOperator 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | #endif 14 | -------------------------------------------------------------------------------- /src_jni/ch_unibas_cs_hpwc_patus_ilp_ILPSolution.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class ch_unibas_cs_hpwc_patus_ilp_ILPSolution */ 4 | 5 | #ifndef _Included_ch_unibas_cs_hpwc_patus_ilp_ILPSolution 6 | #define _Included_ch_unibas_cs_hpwc_patus_ilp_ILPSolution 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #undef ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_OPTIMAL 11 | #define ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_OPTIMAL 0L 12 | #undef ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_INFEASIBLE 13 | #define ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_INFEASIBLE 1L 14 | #undef ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_LIMIT_REACHED 15 | #define ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_LIMIT_REACHED 2L 16 | #undef ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_ABANDONED 17 | #define ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_ABANDONED 3L 18 | #undef ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_NOSOLUTIONFOUND 19 | #define ch_unibas_cs_hpwc_patus_ilp_ILPSolution_STATUS_NOSOLUTIONFOUND 4L 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | #endif 24 | -------------------------------------------------------------------------------- /src_jni/ch_unibas_cs_hpwc_patus_ilp_ILPSolution_ESolutionStatus.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class ch_unibas_cs_hpwc_patus_ilp_ILPSolution_ESolutionStatus */ 4 | 5 | #ifndef _Included_ch_unibas_cs_hpwc_patus_ilp_ILPSolution_ESolutionStatus 6 | #define _Included_ch_unibas_cs_hpwc_patus_ilp_ILPSolution_ESolutionStatus 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | #endif 14 | -------------------------------------------------------------------------------- /src_jni/ch_unibas_cs_hpwc_patus_ilp_ILPSolver.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class ch_unibas_cs_hpwc_patus_ilp_ILPSolver */ 4 | 5 | #ifndef _Included_ch_unibas_cs_hpwc_patus_ilp_ILPSolver 6 | #define _Included_ch_unibas_cs_hpwc_patus_ilp_ILPSolver 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: ch_unibas_cs_hpwc_patus_ilp_ILPSolver 12 | * Method: solveInternal 13 | * Signature: (Lch/unibas/cs/hpwc/patus/ilp/ILPModel;[D[DI)I 14 | */ 15 | JNIEXPORT jint JNICALL Java_ch_unibas_cs_hpwc_patus_ilp_ILPSolver_solveInternal 16 | (JNIEnv *, jobject, jobject, jdoubleArray, jdoubleArray, jint); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /src_jni/libilpsolver.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src_jni/libilpsolver.so -------------------------------------------------------------------------------- /src_jni/msvc/ilpsolver/ilpsolver.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /src_jni/msvc/msvc.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ilpsolver", "ilpsolver\ilpsolver.vcxproj", "{E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Debug|Win32.Build.0 = Debug|Win32 16 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Debug|x64.ActiveCfg = Debug|x64 17 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Debug|x64.Build.0 = Debug|x64 18 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Release|Win32.ActiveCfg = Release|Win32 19 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Release|Win32.Build.0 = Release|Win32 20 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Release|x64.ActiveCfg = Release|x64 21 | {E0D2D72B-3B5D-4CB2-80B1-9A59010DDB47}.Release|x64.Build.0 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | EndGlobal 27 | -------------------------------------------------------------------------------- /src_jni/msvc/msvc.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src_jni/msvc/msvc.suo -------------------------------------------------------------------------------- /src_jni/msvc/x64/Release/ilpsolver.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src_jni/msvc/x64/Release/ilpsolver.dll -------------------------------------------------------------------------------- /src_jni/msvc/x64/Release/ilpsolver.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src_jni/msvc/x64/Release/ilpsolver.exp -------------------------------------------------------------------------------- /src_jni/msvc/x64/Release/ilpsolver.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src_jni/msvc/x64/Release/ilpsolver.lib -------------------------------------------------------------------------------- /src_jni/msvc/x64/Release/ilpsolver.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/src_jni/msvc/x64/Release/ilpsolver.pdb -------------------------------------------------------------------------------- /strategy/cacheblocked.stg: -------------------------------------------------------------------------------- 1 | /** 2 | * Cache-blocking strategy. 3 | */ 4 | strategy cacheblocked_domain ( 5 | domain u, 6 | auto dim cb = ({u.size(1)/4, u.size(1)/2, u.size(1)}, 4:4:u.size(2 .. u.dim)), 7 | auto int chunk = {1,2,4}) 8 | { 9 | // iterate over time steps 10 | for t = 1 .. stencil.t_max 11 | { 12 | // iterate over subdomain 13 | for subdomain v(cb) in u(:; t) parallel schedule chunk 14 | { 15 | // calculate the stencil for each point in the subdomain 16 | for point p in v(:; t) 17 | v[p; t+1] = stencil (v[p; t]); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /strategy/cacheblocked2.stg: -------------------------------------------------------------------------------- 1 | /** 2 | * Cache-blocking strategy. 3 | */ 4 | strategy cacheblocked_domain ( 5 | domain u, 6 | auto dim cbv = ({u.size(1)/4, u.size(1)/2, u.size(1)}, 4:4:u.size(2 .. u.dim)), 7 | auto dim cbw = (2:2:cbv), 8 | auto int chunk = {1,2,4}) 9 | { 10 | // iterate over time steps 11 | for t = 1 .. stencil.t_max 12 | { 13 | // iterate over subdomain 14 | for subdomain v(cbv) in u(:; t) parallel schedule chunk 15 | { 16 | // calculate the stencil for each point in the subdomain 17 | for subdomain w(cbw) in v(:; t) 18 | for point p in w(:; t) 19 | w[p; t+1] = stencil (w[p; t]); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /strategy/gpu.stg: -------------------------------------------------------------------------------- 1 | strategy gpu_blocked (domain u, auto int cbx = {1,2,4}) 2 | { 3 | // iterate over time steps 4 | for t = 1 .. stencil.t_max 5 | { 6 | // iterate over subdomain 7 | for subdomain v(cbx, 1 ...) in u(:; t) parallel 8 | { 9 | for point pt in v(:; t) 10 | v[pt; t+1] = stencil (v[pt; t]); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /strategy/gpu2.stg: -------------------------------------------------------------------------------- 1 | strategy gpu_blocked (domain u, auto int cbx) 2 | { 3 | // iterate over time steps 4 | for t = 1 .. stencil.t_max 5 | { 6 | // iterate over subdomain 7 | for subdomain v(stencil.size(1), stencil.size(2), 1 ...) in u(:; t) parallel 8 | { 9 | //for subdomain w(cbx, 1 ...) in v(:; t) 10 | for point pt in v(:; t) 11 | v[pt; t+1] = stencil (v[pt; t]); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /strategy/simple.stg: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple parallel strategy: 3 | * Iterate over the grid and parallelize the outer most loop. 4 | */ 5 | strategy simple_parallel (domain u, auto int chunk = 1:u.size(1)) 6 | { 7 | // do all the timesteps 8 | for t = 1 .. stencil.t_max 9 | { 10 | // apply the stencil to all the points in the domain 11 | for point p in u(:; t) parallel schedule chunk 12 | u[p; t+1] = stencil (u[p; t]); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/CocoR/Coco.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/tools/CocoR/Coco.jar -------------------------------------------------------------------------------- /tools/CocoR/CocoSourcesJava.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/tools/CocoR/CocoSourcesJava.zip -------------------------------------------------------------------------------- /tools/JAXB/org.jvnet.jaxbw.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/matthias-christen/patus/306dd3b93d8d3a1477592c6fc65dd3b7f297a23a/tools/JAXB/org.jvnet.jaxbw.zip -------------------------------------------------------------------------------- /util/fixpath: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | # This script takes in two arguments: $PATH and the separator for it 4 | # (since fish uses ' ' and everybody else uses ':') 5 | # Then, we remove path components that begin with $PATUS_HOME 6 | 7 | $home = $ENV{"PATUS_HOME"}; 8 | $_ = $ARGV[0]; 9 | $sep = $ARGV[1]; 10 | 11 | @oldpath = split /$sep/; 12 | @newpath = ( ); 13 | 14 | for (@oldpath) 15 | { 16 | if ($home ne "" and /^$home/) 17 | { 18 | # PATUS_HOME is defined and this element begins with PATUS_HOME 19 | } 20 | else 21 | { 22 | push (@newpath, $_); 23 | } 24 | } 25 | 26 | print join ($sep, @newpath) . "\n"; 27 | -------------------------------------------------------------------------------- /util/patusvars.csh: -------------------------------------------------------------------------------- 1 | # csh/tcsh shell script to set the Patus environment variables 2 | 3 | # shallow test to see if we are in the correct directory 4 | # Just probe to see if we have a few essential subdirectories -- 5 | # indicating that we are probably in a Patus root directory. 6 | if ( ! -d "bin" || ! -d "arch" || ! -d "strategy" || ! -f "bin/patus.jar" ) then 7 | echo "Error: patusvars.csh must be sourced from within the Patus root directory" 8 | exit 9 | endif 10 | 11 | set MYPATH = `./util/fixpath "$PATH" :` 12 | if ( $MYPATH == "" ) then 13 | echo "Error running ./util/fixpath" 14 | exit 15 | endif 16 | 17 | setenv PATUS_HOME "$cwd" 18 | echo "Setting PATUS_HOME to $PATUS_HOME" 19 | 20 | setenv PATH "$MYPATH":"$PATUS_HOME/bin" 21 | echo "Updating PATH to include $PATUS_HOME/bin" 22 | -------------------------------------------------------------------------------- /util/patusvars.sh: -------------------------------------------------------------------------------- 1 | # bash shell script to set the Patus environment variables 2 | 3 | # shallow test to see if we are in the correct directory 4 | # Just probe to see if we have a few essential subdirectories -- 5 | # indicating that we are probably in a Patus root directory. 6 | if [ -d "bin" ] && [ -d "arch" ] && [ -d "strategy" ] && [ -f "bin/patus.jar" ] 7 | then 8 | MYPATH=`./util/fixpath "$PATH" :` 9 | if [ -z "$MYPATH" ] 10 | then 11 | echo "Error running ./util/fixpath" 12 | else 13 | export PATUS_HOME=$PWD 14 | echo "Setting PATUS_HOME to $PATUS_HOME" 15 | 16 | export PATH="$MYPATH":"$PATUS_HOME"/bin 17 | echo "Updating PATH to include $PATUS_HOME/bin" 18 | fi 19 | else 20 | echo "Error: patusvars.sh must be sourced from within the Patus root directory" 21 | fi 22 | --------------------------------------------------------------------------------