diff --git a/src/main/scala/apps/mm.scala b/src/main/scala/apps/mm.scala index 1813aff81..52de9846b 100644 --- a/src/main/scala/apps/mm.scala +++ b/src/main/scala/apps/mm.scala @@ -107,8 +107,8 @@ object mm { mapWorkGroup(0)(fun(p3 => zip(p2)(p3) |> // O'.(v8.v5.f x v8.v7.f) // FIXME: there seems to be a bug in AdjustArraySizesForAllocations -// oclReduceSeq(AddressSpace.Private)(fun((p13, p14) => - oclReduceSeq(AddressSpace.Local)(fun((p13, p14) => + oclReduceSeq(AddressSpace.Private)(fun((p13, p14) => +// oclReduceSeq(AddressSpace.Local)(fun((p13, p14) => // (v5/^v4).(v7/^v3).v4.v3.f x (v8.v5.f x v8.v7.f) let (toLocal(makePair( p14._1 |> join |> split(v6) |> // ((v8 x v5) /^ v6).v6.f diff --git a/src/main/scala/rise/autotune/execution.scala b/src/main/scala/rise/autotune/execution.scala index 841ae26bc..616349ace 100644 --- a/src/main/scala/rise/autotune/execution.scala +++ b/src/main/scala/rise/autotune/execution.scala @@ -43,11 +43,11 @@ object execution { val codegenStart = System.currentTimeMillis() - val codegenResult = try { + val codegenResult = /* try */ { // run code-generation with timeout - val codgenResult = autoTuningUtils.runWithTimeout( - timeouts.codegenerationTimeout)(gen.opencl.hosted("fun").fromExpr(expression)) + val codgenResult: Option[gen.opencl.HostedModule] = /*autoTuningUtils.runWithTimeout( + timeouts.codegenerationTimeout)(*/Some(gen.opencl.hosted("fun").fromExpr(expression))//) // check if timeout was triggered codgenResult match { @@ -58,10 +58,10 @@ object execution { ) ) } - } catch { + } /* catch { case e:Throwable => Left(AutoTuningError(CODE_GENERATION_ERROR, Some(e.getCause.getMessage))) - } + } */ val codegenTime = TimeSpan.inMilliseconds((System.currentTimeMillis() - codegenStart).toDouble) @@ -92,6 +92,8 @@ object execution { assert(executionIterations > 0) + println(program) + // execute program val result = executeWithRuntime( program, @@ -103,6 +105,8 @@ object execution { execution ) + println(result) + ExecutionResult( runtime = result._1, codegenTime = Some(codegenTime), diff --git a/src/main/scala/shine/C/Compilation/CodeGenerator.scala b/src/main/scala/shine/C/Compilation/CodeGenerator.scala index 2efd4a8a5..20bbdcab6 100644 --- a/src/main/scala/shine/C/Compilation/CodeGenerator.scala +++ b/src/main/scala/shine/C/Compilation/CodeGenerator.scala @@ -90,7 +90,8 @@ class CodeGenerator(val decls: CodeGenerator.Declarations, visitAndGenerateNat(phrase match { case Phrases.IfThenElse(cond, thenP, elseP) => cond |> exp(env, Nil, cond => - C.AST.IfThenElse(cond, cmd(env)(thenP), Some(cmd(env)(elseP)))) + C.AST.IfThenElse(cond, C.AST.Block(scala.Seq(cmd(env)(thenP))), + Some(C.AST.Block(scala.Seq(cmd(env)(elseP)))))) case i: Identifier[CommType] => env.commEnv(i) diff --git a/src/main/scala/shine/DPIA/Compilation/Passes/UnrollLoops.scala b/src/main/scala/shine/DPIA/Compilation/Passes/UnrollLoops.scala index a09680741..8efb01447 100644 --- a/src/main/scala/shine/DPIA/Compilation/Passes/UnrollLoops.scala +++ b/src/main/scala/shine/DPIA/Compilation/Passes/UnrollLoops.scala @@ -85,9 +85,18 @@ object UnrollLoops { shine.DPIA.DSL.comment(s"unrolling loop of $numIter"))({ case (prev, i) => val index = init + Cst(i * incr) - assert(isSmaller(index, n).contains(true)) //TODO add if-guards otherwise. //TODO store result of init in temporary variable - Seq(prev, genBody(index)) + val current = if (isSmaller(index, n).contains(true)) { + genBody(index) + } else { + shine.DPIA.Phrases.IfThenElse( + shine.DPIA.Phrases.BinOp(shine.DPIA.Phrases.Operators.Binary.LT, + shine.DPIA.Phrases.Natural(index), + shine.DPIA.Phrases.Natural(n)), + genBody(index), + shine.DPIA.primitives.imperative.Skip()) + } + Seq(prev, current) }) tmp