AccelerateHS / AccelerateHS/accelerate-fft

Thread-unsafe cuFFT plan cache usage

未关闭
#12 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Haskell
星标
11
派生
9
PR 合并指标
30 天内没有已合并 PR

描述

Fortunately plans are cached by `accelerate-fft` however there is only one plan per shape and data-type and no mutual exclusion for concurrent usage of that plan which poses a thread-safety issue when multiple separate threads try to use the same plan, assign it a corresponding CUDA stream, and then execute said plan. Execution could feasibly look like:
```
p = ... cached plan #1 ...
thread 1: FFT.setStream p s1
thread 2: FFT.setStream p s2
thread 1: FFT.execC2C p (fftMode mode) d_in d_out
thread 2: FFT.execC2C p (fftMode mode) d_in d_out
```

Solutions include:
1. Make redundant copies of cuFFT plans as concurrent demand is observed.
2. Enforce mutual exclusion on plans during `cuFFT` call.

The former is vastly preferred to the latter.

Additionally, the [cuFFT documentation](https://docs.nvidia.com/cuda/cufft/#thread-safety) makes clear that concurrent usage of plans is fundamentally thread-unsafe.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。