Skip to content

Commit

Permalink
Rename AutoPipeLoopBack to Cycle.
Browse files Browse the repository at this point in the history
  • Loading branch information
joewing committed Jan 30, 2014
1 parent 11a1f22 commit 07b2499
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 51 deletions.
7 changes: 3 additions & 4 deletions src/main/scala/examples/Cluster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,16 @@ object Cluster {

}

val Loop = new AutoPipeLoopBack(ClusterType)

val Cluster = new Application {
val csrc = ClusterSource(Loop.output())
val loop = Cycle(ClusterType)
val csrc = ClusterSource(loop)
val bmp = BMPReader('file -> "in.bmp")
val vsrc = ValueSource(bmp(0), bmp(1), bmp(2))
val assignments = Assign(vsrc(0), vsrc(1), vsrc(2), csrc(0))
val updated = UpdateClusters(assignments(0), assignments(1),
assignments(2), assignments(3))
val out = Output(updated(0), assignments(4), updated(1), updated(2))
Loop.input(out(0))
loop(out(0))
BMPWriter(out(1), out(2), out(3), 'file -> "out.bmp")
}
Cluster.emit("cluster")
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/examples/NBody.scala
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ object NBody {

}

val Loop = new AutoPipeLoopBack(PARTICLE)

val Buffer = new Kernel("Buffer") {

Expand Down Expand Up @@ -457,8 +456,9 @@ object NBody {

val app = new Application {

val cycle = Cycle(PARTICLE)
val source = Source()
val buffer = Buffer(source(0), Loop.output())
val buffer = Buffer(source(0), cycle)
val stream = Streamer(buffer(0))

val oldParticle = Dup(stream(0))
Expand All @@ -467,7 +467,7 @@ object NBody {
val updated = Dup(newParticle)

Print(updated(0))
Loop.input(updated(1))
cycle(updated(1))

if (hw) {
map(ANY_KERNEL -> Force, CPU2FPGA());
Expand Down
8 changes: 3 additions & 5 deletions src/main/scala/examples/Simplex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ object Simplex extends App {

}

// Loop-back kernel.
val Loop = AutoPipeLoopBack(VALUE_TYPE)

// Output the result.
// This will terminate the program when a solution is found.
val Output = new Kernel("Output") {
Expand Down Expand Up @@ -334,7 +331,8 @@ object Simplex extends App {
map(Parser -> ANY_KERNEL, CPU2FPGA())
map(ANY_KERNEL -> Output, FPGA2CPU())

val stream = Streamer(Parser(), Loop.output())
val cycle = Cycle(VALUE_TYPE)
val stream = Streamer(Parser(), cycle)
val split = ArraySplitter(stream(0))
val pivot = PivotSelect(stream(1))
val prow = DupValues(pivot(0))
Expand All @@ -346,7 +344,7 @@ object Simplex extends App {
pindex(i), column(i), 'index -> i)
RowBuffer(row)
}
Loop.input(ArrayBuilder(rows))
cycle(ArrayBuilder(rows))
Output(stream(2))
}
app.emit("simplex")
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/scalapipe/KernelType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ private[scalapipe] abstract class KernelType(
val sp: ScalaPipe,
val name: String,
val symbols: SymbolTable,
val platform: Platforms.Value,
val loopBack: Boolean
val platform: Platforms.Value
) {

private[scalapipe] val configs = symbols.configs
Expand All @@ -20,7 +19,7 @@ private[scalapipe] abstract class KernelType(
private[scalapipe] val outputs = symbols.outputs

def this(sp: ScalaPipe, kernel: Kernel, p: Platforms.Value) = {
this(sp, kernel.name, new SymbolTable(kernel), p, kernel.loopBack)
this(sp, kernel.name, new SymbolTable(kernel), p)
kernel.inputs.foreach { i =>
symbols.addInput(i.name, i.valueType)
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/scalapipe/dsl/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Application {

implicit def streamList2Stream(sl: StreamList) = sl.apply()

implicit def cycle2Arg(cycle: Cycle) = (null, cycle.output(sp))

implicit def objToEdge[T <: Edge](e: EdgeObject[T]): T = e.apply()

def measure(streamList: StreamList, stat: Symbol, metric: Symbol) {
Expand Down
31 changes: 0 additions & 31 deletions src/main/scala/scalapipe/dsl/AutoPipeLoopBack.scala

This file was deleted.

34 changes: 34 additions & 0 deletions src/main/scala/scalapipe/dsl/Cycle.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package scalapipe.dsl

import scalapipe._

object Cycle {
def apply(t: Type) = new Cycle(t)
}

class Cycle(val t: Type) {

private var stream: Stream = null

private val kernel = new Kernel {
val in = input(t)
val out = output(t)
out = in
}

private var instance: KernelInstance = null

private[dsl] def output(sp: ScalaPipe): Stream = {
instance = sp.createInstance(kernel)
instance.apply()()
}

def apply(s: Stream) {
if (instance == null) {
Error.raise("unconnected cycle")
} else {
instance.setInput(null, s)
}
}

}
5 changes: 0 additions & 5 deletions src/main/scala/scalapipe/dsl/Kernel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Kernel(val name: String) extends EmbeddedControls {
private[scalapipe] val externals = new ListBuffer[Platforms.Value]
private[scalapipe] val dependencies = new DependencySet
private[scalapipe] val scopeStack = new ListBuffer[scalapipe.Scope]
private[scalapipe] var loopBack = false

def this() = this(LabelMaker.getKernelLabel)

Expand All @@ -34,10 +33,6 @@ class Kernel(val name: String) extends EmbeddedControls {
!externals.contains(p)
}

private[scalapipe] def setLoopBack {
super.__assign(loopBack, true)
}

private def getLabel: String = labelCounter.next()

def inputType(i: Int): Type = inputs(i).t
Expand Down

0 comments on commit 07b2499

Please sign in to comment.