From 913316fa3e4348602bb3e2d1ab90151d3cdcb13c Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Wed, 28 Mar 2012 17:10:24 +0100 Subject: [PATCH] Disable most of existing code generation framework. --- src/ofc/codegen/Expression.scala | 3 +++ src/ofc/codegen/IterationTemplate.scala | 4 ++++ src/ofc/codegen/Symbol.scala | 3 +++ src/ofc/generators/Onetep.scala | 12 ++++++------ src/ofc/generators/onetep/Assignment.scala | 3 ++- src/ofc/generators/onetep/CodeGenerator.scala | 3 ++- .../generators/onetep/GeneralInnerProduct.scala | 5 ++--- src/ofc/generators/onetep/Index.scala | 13 +++++++------ src/ofc/generators/onetep/IterationSpace.scala | 15 +++++---------- src/ofc/generators/onetep/Laplacian.scala | 5 ++--- src/ofc/generators/onetep/LoopTree.scala | 4 ++-- src/ofc/generators/onetep/PPDFunctionSet.scala | 2 ++ src/ofc/generators/onetep/Reciprocal.scala | 5 ++--- src/ofc/generators/onetep/SPAM3.scala | 5 ++--- src/ofc/generators/onetep/Scalar.scala | 5 ++--- .../generators/onetep/SpatialRestriction.scala | 5 ++--- src/ofc/generators/onetep/TreeBuilder.scala | 16 +++------------- 17 files changed, 51 insertions(+), 57 deletions(-) create mode 100644 src/ofc/codegen/Expression.scala create mode 100644 src/ofc/codegen/IterationTemplate.scala create mode 100644 src/ofc/codegen/Symbol.scala diff --git a/src/ofc/codegen/Expression.scala b/src/ofc/codegen/Expression.scala new file mode 100644 index 0000000..ab49031 --- /dev/null +++ b/src/ofc/codegen/Expression.scala @@ -0,0 +1,3 @@ +package ofc.codegen + +trait Expression diff --git a/src/ofc/codegen/IterationTemplate.scala b/src/ofc/codegen/IterationTemplate.scala new file mode 100644 index 0000000..723c045 --- /dev/null +++ b/src/ofc/codegen/IterationTemplate.scala @@ -0,0 +1,4 @@ +package ofc.codegen + +class IterationTemplate { +} diff --git a/src/ofc/codegen/Symbol.scala b/src/ofc/codegen/Symbol.scala new file mode 100644 index 0000000..424c052 --- /dev/null +++ b/src/ofc/codegen/Symbol.scala @@ -0,0 +1,3 @@ +package ofc.codegen + +class Symbol(name: String) diff --git a/src/ofc/generators/Onetep.scala b/src/ofc/generators/Onetep.scala index 306b003..d5d125f 100644 --- a/src/ofc/generators/Onetep.scala +++ b/src/ofc/generators/Onetep.scala @@ -35,8 +35,8 @@ class Onetep extends Generator { call match { case Some(FunctionCall(matType, params)) => (matType, params) match { - case (Identifier("SPAM3"), ParameterList(StringParameter(name))) => - dictionary.matrices += (id -> new SPAM3(name)) + //case (Identifier("SPAM3"), ParameterList(StringParameter(name))) => + // dictionary.matrices += (id -> new SPAM3(name)) case _ => throw new InvalidInputException("Unknown usage of type: "+matType.name) } case _ => throw new InvalidInputException("Undefined concrete type for matrix: "+id.name) @@ -48,8 +48,8 @@ class Onetep extends Generator { call match { case Some(FunctionCall(fSetType, params)) => (fSetType, params) match { - case (Identifier("PPDFunctionSet"), ParameterList(StringParameter(basis), StringParameter(data))) => - dictionary.functionSets += id -> new PPDFunctionSet(basis, data) + //case (Identifier("PPDFunctionSet"), ParameterList(StringParameter(basis), StringParameter(data))) => + // dictionary.functionSets += id -> new PPDFunctionSet(basis, data) case _ => throw new InvalidInputException("Unknown usage of type: "+fSetType.name) } case _ => throw new InvalidInputException("Undefined concrete type for function set: "+id.name) @@ -86,8 +86,8 @@ class Onetep extends Generator { def buildDefinition(definition : parser.Definition) { val builder = new TreeBuilder(dictionary) val assignment = builder(definition.term, definition.expr) - val codeGenerator = new CodeGenerator() - codeGenerator(assignment) + //val codeGenerator = new CodeGenerator() + //codeGenerator(assignment) } def buildDefinitions(statements : List[parser.Statement]) { diff --git a/src/ofc/generators/onetep/Assignment.scala b/src/ofc/generators/onetep/Assignment.scala index 4d779c4..23c34a7 100644 --- a/src/ofc/generators/onetep/Assignment.scala +++ b/src/ofc/generators/onetep/Assignment.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class Assignment(indexBindings: IndexBindings, lhs: DataSpace, rhs: IterationSpace) extends IterationSpace { def getIndexBindings = indexBindings def getOperands = List(rhs) @@ -11,3 +11,4 @@ class Assignment(indexBindings: IndexBindings, lhs: DataSpace, rhs: IterationSpa def getTransformGenerator = None def getProducerGenerator = None } +*/ diff --git a/src/ofc/generators/onetep/CodeGenerator.scala b/src/ofc/generators/onetep/CodeGenerator.scala index 7735c9e..9f7c673 100644 --- a/src/ofc/generators/onetep/CodeGenerator.scala +++ b/src/ofc/generators/onetep/CodeGenerator.scala @@ -1,6 +1,6 @@ package ofc.generators.onetep import scala.collection.mutable.HashMap - +/* class NameManager { var nextIndexID = 0 val names = new HashMap[Index, String]() @@ -107,3 +107,4 @@ class CodeGenerator { // We now generate the actual loop for space. This may involve a composite iteration construction } } +*/ diff --git a/src/ofc/generators/onetep/GeneralInnerProduct.scala b/src/ofc/generators/onetep/GeneralInnerProduct.scala index 6b8e9b6..267b7e5 100644 --- a/src/ofc/generators/onetep/GeneralInnerProduct.scala +++ b/src/ofc/generators/onetep/GeneralInnerProduct.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class GeneralInnerProduct(operands: List[IterationSpace], removedIndices: Set[Index]) extends IterationSpace { class DenseSpatialIndex(parent: GeneralInnerProduct, original: SpatialIndex) extends SpatialIndex{ @@ -43,5 +43,4 @@ class GeneralInnerProduct(operands: List[IterationSpace], removedIndices: Set[In def getTransformGenerator = None def getProducerGenerator = None } - - +*/ diff --git a/src/ofc/generators/onetep/Index.scala b/src/ofc/generators/onetep/Index.scala index 2b3e5c0..435d62e 100644 --- a/src/ofc/generators/onetep/Index.scala +++ b/src/ofc/generators/onetep/Index.scala @@ -1,5 +1,7 @@ package ofc.generators.onetep +import ofc.codegen.Expression +/* object Index { def sort(indices: Traversable[Index]) : List[Index] = { def helper(input: Index, seen: collection.mutable.Set[Index]) : List[Index] = @@ -12,15 +14,14 @@ object Index { indices.toList.flatMap(helper(_, seen)) } } +*/ trait Index { def getName : String - def getDependencies : Set[Index] - def getDenseWidth(names: NameManager) : String - def getDensePosition(names: NameManager) : String = names(this) - def generateIterationHeader(names: NameManager) : String - def generateIterationFooter(names: NameManager) : String - def getDeclarations(names: NameManager) : List[String] + def getMappingFunction : Expression + def getMinimumValue : Expression + def getLength : Expression + def isRandomAccess : Boolean } trait SpatialIndex extends Index diff --git a/src/ofc/generators/onetep/IterationSpace.scala b/src/ofc/generators/onetep/IterationSpace.scala index bf02a19..6b6ff2e 100644 --- a/src/ofc/generators/onetep/IterationSpace.scala +++ b/src/ofc/generators/onetep/IterationSpace.scala @@ -1,5 +1,7 @@ package ofc.generators.onetep +import ofc.codegen.IterationTemplate +/* object IterationSpace { def sort(spaces : Traversable[IterationSpace]) : List[IterationSpace] = { def helper(input: IterationSpace, seen: collection.mutable.Set[IterationSpace]) : List[IterationSpace] = @@ -15,29 +17,22 @@ object IterationSpace { def flattenPostorder(term: IterationSpace) : Traversable[IterationSpace] = term.getOperands.toTraversable.flatMap(flattenPostorder(_)) ++ List(term) } +*/ trait IterationSpace { def getOperands : List[IterationSpace] def getSpatialIndices : List[SpatialIndex] def getDiscreteIndices : List[DiscreteIndex] - def getExternalIndices : Set[Index] - def getInternalIndices : Set[Index] = (getSpatialIndices ++ getDiscreteIndices).toSet - def getIndices : Set[Index] = getInternalIndices ++ getExternalIndices + def getIndices : Set[Index] = (getSpatialIndices ++ getDiscreteIndices).toSet def getDependencies : Set[IterationSpace] = { val operands = getOperands operands.toSet ++ operands.flatMap(_.getDependencies) } - - // Code generation - def getConsumerGenerator : Option[ConsumerGenerator] - def getTransformGenerator : Option[TransformGenerator] - def getProducerGenerator : Option[ProducerGenerator] + def getReader : IterationTemplate } trait DataSpace extends IterationSpace { def getOperands = Nil - def getConsumerGenerator = None - def getTransformGenerator = None } trait Matrix extends DataSpace diff --git a/src/ofc/generators/onetep/Laplacian.scala b/src/ofc/generators/onetep/Laplacian.scala index e2d9649..abab4c4 100644 --- a/src/ofc/generators/onetep/Laplacian.scala +++ b/src/ofc/generators/onetep/Laplacian.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class Laplacian(op: IterationSpace) extends IterationSpace { def getOperands = List(op) def getSpatialIndices = op.getSpatialIndices @@ -10,5 +10,4 @@ class Laplacian(op: IterationSpace) extends IterationSpace { def getTransformGenerator = None def getProducerGenerator = None } - - +*/ diff --git a/src/ofc/generators/onetep/LoopTree.scala b/src/ofc/generators/onetep/LoopTree.scala index ae4f7fb..a2ae25f 100644 --- a/src/ofc/generators/onetep/LoopTree.scala +++ b/src/ofc/generators/onetep/LoopTree.scala @@ -7,6 +7,7 @@ import ofc.LogicError Stores the configuration of indices we will use for code generation. */ +/* object LoopNest { def apply(root: IterationSpace) : LoopNest = { val sortedSpaces = IterationSpace.flattenPostorder(root) @@ -375,5 +376,4 @@ class LoopTree private[onetep](localIndex: Option[Index]) extends Fragment { result.toList } } - - +*/ diff --git a/src/ofc/generators/onetep/PPDFunctionSet.scala b/src/ofc/generators/onetep/PPDFunctionSet.scala index f7adac4..ebd2537 100644 --- a/src/ofc/generators/onetep/PPDFunctionSet.scala +++ b/src/ofc/generators/onetep/PPDFunctionSet.scala @@ -1,6 +1,7 @@ package ofc.generators.onetep class PPDFunctionSet(val basis : String, data : String) extends FunctionSet { +/* class SphereIndex(parent: PPDFunctionSet) extends DiscreteIndex { def getName = "sphere_index" def getDependencies = Set() @@ -137,6 +138,7 @@ class PPDFunctionSet(val basis : String, data : String) extends FunctionSet { data+"("+getPPDIndex.getPPDPoint+")" } }) +*/ } diff --git a/src/ofc/generators/onetep/Reciprocal.scala b/src/ofc/generators/onetep/Reciprocal.scala index b16d5f3..1391b79 100644 --- a/src/ofc/generators/onetep/Reciprocal.scala +++ b/src/ofc/generators/onetep/Reciprocal.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class Reciprocal(op: IterationSpace) extends IterationSpace { class BlockIndex(parent: Reciprocal, dimension: Int, original: SpatialIndex) extends SpatialIndex { def getName = "reciprocal_index_" + dimension @@ -22,5 +22,4 @@ class Reciprocal(op: IterationSpace) extends IterationSpace { def getTransformGenerator = None def getProducerGenerator = None } - - +*/ diff --git a/src/ofc/generators/onetep/SPAM3.scala b/src/ofc/generators/onetep/SPAM3.scala index abbe79b..b913444 100644 --- a/src/ofc/generators/onetep/SPAM3.scala +++ b/src/ofc/generators/onetep/SPAM3.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class SPAM3(name : String) extends Matrix { override def toString = name def getName = name @@ -44,5 +44,4 @@ class SPAM3(name : String) extends Matrix { def getProducerGenerator = None } - - +*/ diff --git a/src/ofc/generators/onetep/Scalar.scala b/src/ofc/generators/onetep/Scalar.scala index 2eb8437..97fe64e 100644 --- a/src/ofc/generators/onetep/Scalar.scala +++ b/src/ofc/generators/onetep/Scalar.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class Scalar(value: Double) extends DataSpace { def getSpatialIndices = Nil def getDiscreteIndices = Nil @@ -8,5 +8,4 @@ class Scalar(value: Double) extends DataSpace { def generate(names: NameManager) = value.toString }) } - - +*/ diff --git a/src/ofc/generators/onetep/SpatialRestriction.scala b/src/ofc/generators/onetep/SpatialRestriction.scala index 3f5fe00..4f54676 100644 --- a/src/ofc/generators/onetep/SpatialRestriction.scala +++ b/src/ofc/generators/onetep/SpatialRestriction.scala @@ -1,5 +1,5 @@ package ofc.generators.onetep - +/* class SpatialRestriction(op: IterationSpace) extends IterationSpace { class RestrictedIndex(parent: SpatialRestriction, dimension: Int) extends SpatialIndex { def getName = "restriction_index_" + dimension @@ -26,5 +26,4 @@ class SpatialRestriction(op: IterationSpace) extends IterationSpace { def getTransformGenerator = None def getProducerGenerator = None } - - +*/ diff --git a/src/ofc/generators/onetep/TreeBuilder.scala b/src/ofc/generators/onetep/TreeBuilder.scala index 738f571..9b878bd 100644 --- a/src/ofc/generators/onetep/TreeBuilder.scala +++ b/src/ofc/generators/onetep/TreeBuilder.scala @@ -4,18 +4,6 @@ import ofc.parser import ofc.parser.Identifier import ofc.{InvalidInputException,UnimplementedException} -trait ConsumerGenerator { - def generate(names: NameManager, indices: Map[Index,String], values : Map[IterationSpace, String]) : String -} - -trait ProducerGenerator { - def generate(names: NameManager) : String -} - -trait TransformGenerator { - def generate(names: NameManager) : String -} - class BindingIndex(name : String) { override def toString() = name } @@ -70,7 +58,7 @@ class TreeBuilder(dictionary : Dictionary) { val rhsTree = buildExpression(rhs) lhsTree match { - case (lhsTree: DataSpace) => new Assignment(indexBindings, lhsTree, rhsTree) + //case (lhsTree: DataSpace) => new Assignment(indexBindings, lhsTree, rhsTree) case _ => throw new InvalidInputException("Non-assignable expression on LHS of assignment.") } } @@ -93,6 +81,7 @@ class TreeBuilder(dictionary : Dictionary) { term match { case (t: IndexedTerm) => buildIndexedTerm(t) +/* case ScalarConstant(s) => new Scalar(s) case Multiplication(a, b) => new GeneralInnerProduct(List(buildExpression(a), buildExpression(b)), Set()) @@ -114,6 +103,7 @@ class TreeBuilder(dictionary : Dictionary) { case Operator(Identifier("laplacian"), List(op)) => new Laplacian(buildExpression(op)) case Operator(Identifier("fftbox"), List(op)) => new SpatialRestriction(buildExpression(op)) case Operator(Identifier(name), _) => throw new UnimplementedException("Unknown or incorrectly called operator: "+name) +*/ } } } -- 2.47.3