Skip to content

Commit

Permalink
Fix #1169.
Browse files Browse the repository at this point in the history
It's a bit ad-hoc that we just lock here.  This should use the
criticalSection abstraction, but that's internal to GenericC.  This is
good enough for now, but if we ever do more complex entry/exit
operations, this will need refactoring.
  • Loading branch information
athas committed Oct 31, 2020
1 parent a96882a commit 7b08f8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Fixed a flattening issue for certain complex `map` nestings
(#1168).

* Made API function `futhark_context_clear_caches()` thread safe
(#1169).

## [0.18.1]

### Added
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/Backends/CCUDA/Boilerplate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,9 @@ generateContextFuns cfg cost_centres kernels sizes failures = do
GC.publicDef_ "context_clear_caches" GC.MiscDecl $ \s ->
( [C.cedecl|int $id:s(struct $id:ctx* ctx);|],
[C.cedecl|int $id:s(struct $id:ctx* ctx) {
lock_lock(&ctx->lock);
CUDA_SUCCEED(cuda_free_all(&ctx->cuda));
lock_unlock(&ctx->lock);
return 0;
}|]
)
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/Backends/COpenCL/Boilerplate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,9 @@ generateBoilerplate opencl_code opencl_prelude cost_centres kernels types sizes
GC.publicDef_ "context_clear_caches" GC.MiscDecl $ \s ->
( [C.cedecl|int $id:s(struct $id:ctx* ctx);|],
[C.cedecl|int $id:s(struct $id:ctx* ctx) {
lock_lock(&ctx->lock);
ctx->error = OPENCL_SUCCEED_NONFATAL(opencl_free_all(&ctx->opencl));
lock_unlock(&ctx->lock);
return ctx->error != NULL;
}|]
)
Expand Down

0 comments on commit 7b08f8f

Please sign in to comment.