Closed dpanfilyonok closed 3 years ago
Looks good.
Usage:
opencl {
}
|> OpenCLEvaluationContext(IsCachingEnabled = true).RunSync
let ctx = OpenCLEvaluationContext()
// without caching
opencl {
}
|> ctx.RunSync
// with caching
ctx.IsCachingEnabled <- true
opencl {
}
|> ctx.RunSync
opencl {
let kernel1 = <@ .. @>
let kernel2 = <@ .. @>
// with caching
do! RunCommand kernel1 ...
// without caching
let! ctx = getEvaluationContext
let oldContext = ctx.Clone()
ctx.IsCachingEnabled <- false
do! RunCommand kernel2
ctx.IsCachingEnabled <- oldContext.IsCachingEnabled
}
|> OpenCLEvaluationContext(IsCachingEnabled = true).RunSync
It should be noted that the proposed solution is suitable for experimentation only. It will crash on caching equal expressions but with different types in it (because string representation of Expr erase types).
This solution is suitable for experiments and can also be improved in the future (correct hashing, refactoring). So I think I can make a release
@simpletonDL well. Please, publish new package.
Proposed Changes
Added support of kernel caching. (For experimentation only)