Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] runWithTimeout does not kill the running thread, only returns to host program #193

Open
johanneslenfers opened this issue Jun 30, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@johanneslenfers
Copy link
Member

Describe the bug
Function runWithTimeout does not kill the running thread. It only returns to host program. The thread stays running in the background.

  // WARNING: does not kill the thread, we only return to host program
  // Thread.stop() is deprecated and cannot be used here
  // add option to stop thread in unsafe way
  def runWithTimeout[T](timeoutMs: Long)(f: => T) : Option[T] = {
    try {
      val executor = Executors.newSingleThreadExecutor()
      val res = executor.invokeAll(java.util.Arrays.asList(new java.util.concurrent.Callable[T] {
        override def call(): T = f
      }), timeoutMs, TimeUnit.MILLISECONDS)
      executor.shutdown()
      Some(res.get(0).get())
    } catch {
      case _: TimeoutException => None
      case _: java.util.concurrent.CancellationException => None
    }
  }

To Reproduce
Execute test generate huge amount of code (line 568) in autotuning.scala

Expected behavior
Code generation would create opencl kernel file bigger than 150MB. Function is timed out after 5 seconds. Code generation will continue in the background.

Possible solution
Stop thread in an unsafe way.

@johanneslenfers johanneslenfers added the bug Something isn't working label Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant