Hello Again,
Let me expand on the question.
The root cause of the failure is: the needed files were created, then deleted on the next iteration of the loop (when the whole directory was swept) but the hash map with the information about created headers has not been cleared.
Let me carry away and focus on the next problem, the contention one that causes an exception:
[info] Cause: java.lang.UnsatisfiedLinkError: Native Library /home/alsam/work/scalan-cuda-codegen/generatedCache/cuda/bin/runtime/cudaHostddmvm_1010.so already loaded in another classloader
The .so resource captured by
object Executable1 extends DeliteExecutable {
@native def hostExecutable1: Unit
System.load("""/home/alsam/work/scalan-cuda-codegen/generatedCache/cuda/bin/runtime/cudaHostddmvm_1010.so""")
has never been released
A naive attempt just to catch an exception:
--- a/delite/runtime/src/ppl/delite/runtime/codegen/CppExecutableGenerator.scala
+++ b/delite/runtime/src/ppl/delite/runtime/codegen/CppExecutableGenerator.scala
@@ -237,14 +237,27 @@ class ScalaNativeExecutableGenerator(override val location: Int, override val gr
val configString = Config.numThreads.toString + Config.numCpp + Config.numCuda + Config.numOpenCL
val tgt = OpHelper.scheduledTarget(location)
out.append("@native def host" + executableName(location) + ": Unit\n")
- out.append("System.load(\"\"\"")
- out.append(Compilers(tgt).binCacheHome + tgt + "Host" + appName + "_" + configString + "." + OS.libExt)
+ out.append("try {\n")
+ out.append(" System.load(\"\"\"")
+ val libpath = Compilers(tgt).binCacheHome + tgt + "Host" + appName + "_" + configString + "." + OS.libExt
+ out.append(libpath)
out.append("\"\"\")\n")
+ out.append("} catch {\n")
+ out.append(" case _ => println(\"\"\"")
+ out.append("-W- an exception occurred while loading " + libpath)
+ out.append("\"\"\")\n")
+ out.append("}\n")
}
private def writeNativeCall() {
- out.append("host")
+ out.append("try {\n")
+ out.append(" host")
out.append(executableName(location))
out.append('\n')
+ out.append("} catch {\n")
+ out.append(" case _ => println(\"\"\"")
+ out.append("-W- an exception occurred while calling a native executable")
+ out.append("\"\"\")\n")
+ out.append("}\n")
}
}
leads to a race condition, to deadlock to be more exact.
I looked into the ExecutionThread.scala code and noticed:
protected def loadNative(fileName: String, compiler: CCompile) = {
val sep = File.separator
val root = compiler.staticResources + fileName
val path = root + "." + OS.libExt
val lib = new File(path)
if (!lib.exists) compiler.compileInit(root)
System.load(path) //TODO: doesn't work properly with sbt test suite
}
What would you recommend to override it?
Thanks!
Alexander