Skip to content

Commit

Permalink
added host-code generation checks for other gemv versions
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneslenfers committed Oct 27, 2021
1 parent 2f8aaa6 commit 5071fc7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/apps/gemv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ object gemv {
zip(xs)(t._1) |>
split(n) |>
toLocalFun(mapLocal(
reduceSeq(fun(a => fun(x => mult(x) + a)))(lf32(0.0f))
oclReduceSeq(AddressSpace.Private)(fun(a => fun(x => mult(x) + a)))(lf32(0.0f))
)) |>
mapLocal(fun(x => (alpha * x) + (t._2 * beta)))
)) |> join
Expand Down
30 changes: 16 additions & 14 deletions src/test/scala/apps/gemvCheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Type._
import rise.autotune
import rise.core.Expr
import rise.core.types._
import util.{SyntaxChecker, gen}
import util.{gen}
import util.gen.c.function
import rise.core.types.DataType._
import shine.OpenCL.{GlobalSize, LocalSize}
Expand Down Expand Up @@ -43,6 +43,21 @@ class gemvCheck extends test_util.Tests {
ocl.gemvKeplerBest.toExpr
}

test("OpenCL gemv versions host-code generation creates syntactically correct host-code"){

def run(e: ToBeTyped[Expr], localSize: LocalSize, globalSize: GlobalSize):String = {
val wrapped = autotune.wrapOclRun(localSize, globalSize)(e)
val codeModule = gen.opencl.hosted.fromExpr(wrapped)
shine.OpenCL.Module.translateToString(codeModule) // syntax checker is called here
}

run(ocl.gemvBlastN, LocalSize(64), GlobalSize(1024))
run(ocl.gemvBlastT, LocalSize(64), GlobalSize(1024))
run(ocl.gemvFused, LocalSize(128), GlobalSize(1024))
run(ocl.gemvFusedAMD, LocalSize(128), GlobalSize(1024))
run(ocl.gemvKeplerBest, LocalSize(128), GlobalSize(1024))
}

test("OpenMP gemv versions type inference works") {
omp.gemvFused.toExpr
}
Expand Down Expand Up @@ -78,17 +93,4 @@ class gemvCheck extends test_util.Tests {
))
}
}

test("hostcode generation for GEMV expressions"){

def run(e: ToBeTyped[Expr]):String = {
val wrapped = autotune.wrapOclRun(LocalSize(128), GlobalSize(1024))(e)
val codeModule = gen.opencl.hosted.fromExpr(wrapped)
shine.OpenCL.Module.translateToString(codeModule)
}

run(ocl.gemvFusedAMD)
run(ocl.gemvKeplerBest)

}
}

0 comments on commit 5071fc7

Please sign in to comment.