}
}
+object CodeGenerator {
+ def getAllSpaces(term: IterationSpace) : Set[IterationSpace] =
+ term.getOperands.toSet.flatMap(getAllSpaces(_: IterationSpace)) + term
+}
+
class CodeGenerator {
val code = new StringBuilder()
val nameManager = new NameManager()
def collectDeclarations(term: IterationSpace) : Set[String] = {
- val declarations = for(index <- term.getSpatialIndices ++ term.getDiscreteIndices;
+ val declarations = for(index <- term.getIndices;
declaration <- index.getDeclarations(nameManager)) yield declaration
var declarationsSet = declarations.toSet
}
def generateCode(space: IterationSpace) {
+ val allSpaces = CodeGenerator.getAllSpaces(space)
+ val allIndices = allSpaces flatMap (_.getIndices)
+
+ println("dumping operations")
+ for(op <- allSpaces)
+ println(op)
+ println("finished dumping operations\n\ndumping indices")
+ for (i <- allIndices)
+ println(i)
+ println("finished dumping indices")
+
+ // Next: we dump all these things into a prefix map
+ System.exit(0)
+
val operands = space.getOperands
for(operand <- operands)
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
}
trait DataSpace extends IterationSpace {
def getOperands = List(lhs,rhs)
def getSpatialIndices = Nil
def getDiscreteIndices = Nil
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getOperands = Nil
def getSpatialIndices = Nil
def getDiscreteIndices = Nil
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getOperands = operands
def getSpatialIndices = spatialIndices
def getDiscreteIndices = discreteIndices
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getOperands = List(op)
def getSpatialIndices = spatialIndices.toList
def getDiscreteIndices = op.getDiscreteIndices
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getOperands = List(op)
def getSpatialIndices = op.getSpatialIndices
def getDiscreteIndices = op.getDiscreteIndices
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getOperands = List(op)
def getSpatialIndices = spatialIndices.toList
def getDiscreteIndices = op.getDiscreteIndices
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getSpatialIndices = Nil
def getDiscreteIndices = List(rowIndex, colIndex)
+ def getExternalIndices = Set()
def getAccessExpression(indexNames: NameManager) = throw new UnimplementedException("Access failed")
}
def getSpatialIndices = spatialIndices.toList
def getDiscreteIndices = List(getSphereIndex)
+ def getExternalIndices = Set(getPPDIndex)
def getAccessExpression(indexNames: NameManager) = {
val index = getSphere(indexNames)+"%offset + &\n" +