问题标签 [cufft]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
cuda - 为什么 cufftPlanMany() 需要太长时间?
第一次调用 cufftPlanMany() 时,大约需要 0.7 秒,但接下来的所有调用都很快。知道如何加速 cufftPlanMany() 的第一次调用吗?
cufft - 袖带的错误结果
我需要袖带方面的帮助,我的结果是错误的,我不知道为什么。
这是我的代码:
这就是我在结果的第一行得到的:
0.00000 + 0.00000i 0.69098 - 0.95106i 1.80902 - 0.58779i 0.00000 + 0.00000i 0.69098 - 0.95105i
它应该是:
0.00000 + 0.00000i 0.69098 - 0.95106i 1.80902 - 0.58779i 1.80902 + 0.58779i 0.69098 + 0.95106i
在 otfFx[14] 之后一切都是垃圾,就像结果是 5x3 而应该是 5x5。
这是给我“正确”结果的八度代码:
numpy - FFTW / CUFFT 在多维数组的给定轴上
有没有一种有效的方法来使用 FFTW / CUFFT(它们有类似的 API)在多维数组的给定轴上执行 fft?
假设我有一个形状为 (2, 3, 4) 的 3D 数组。步幅为 (12, 4, 1),这意味着为了沿最后一个轴移动一个单位,我们在平面阵列中移动 1 个单位,而要沿第一个轴移动一个单位,我们必须跨过3 * 4 = 12 个单位。(该数组是一个 numpy ndarray,当轴被转置时,它也可以有其他的步幅,但我很高兴得到一个答案,它只解决给定步幅的这个特定的 3D 案例)
现在假设我想沿中轴计算一维 fft。CUFFT 公开了以下功能:
我认为我们需要nembed
, stride
,dist
参数来进行转换。它们记录在这里:
http ://docs.nvidia.com/cuda/cufft/index.html#advanced-data-layout
参数说明对于一维 fft,批次 b 中位置 x 的元素将取自:
input[b * idist + x * istride]
但是,位置 [b][x][z] 处的元素存储在:
input[b * 12 + x * 4 + z]
因此尚不清楚如何使 CUFFT 在第三 (z) 轴上循环。
如果我设置:
- idist 和 odist 为 3*4=12 (因此递增 b 使我们沿第一个轴移动)并且,
- isstride 和 ostride 到 4(这样递增的 x 沿着第二个轴移动,这是我们想要 fft 的轴),
- 批次 = 2
- inembed 和 oneembed 为 3(但根据文档,这些对于 1D 变换被忽略)
然后它为最后一个轴索引为 0 的 2 个批次中的每一个计算正确的 fft,但保留最后一个索引为 1、2 或 3 的子数组不变。
这似乎是一个常见的用例,但我似乎无法弄清楚如何在不进行多次调用(这在 GPU 上很昂贵)或使用不同的内存布局进行复制的情况下使用给定的参数来做到这一点。
cuda - 错误的结果 cufft 3D in-place
我写作是因为我在原地使用 cufft 3D 变换时遇到了问题,而对于原地版本我没有任何问题。我在这里尝试遵循 Robert Crovella 的回答,但在进行 FFT+IFT 时没有获得正确的结果。这是我的代码:
程序输出以下数据:
起始文件
平面 = 0 --------------
0.000 4.000 8.000 12.000
16.000 20.000 24.000 28.000
32.000 36.000 40.000 44.000
48.000 52.000 56.000 60.000
平面 = 1 ----------------------------
1.000 5.000 9.000 13.000
17.000 21.000 25.000 29.000
33.000 37.000 41.000 45.000
49.000 53.000 57.000 61.000
平面 = 2 ----------------------------
2.000 6.000 10.000 14.000
18.000 22.000 26.000 30.000
34.000 38.000 42.000 46.000
50.000 54.000 58.000 62.000
平面 = 3 --------------
3.000 7.000 11.000 15.000
19.000 23.000 27.000
31.000 35.000 39.000 43.000 47.000
51.000 55.000 59.000 63.000
FFT+IFT 后
平面 = 0 --------------
-0.000 -0.344 8.000 12.000
-0.031 20.000 24.000 -0.031
32.000 36.000 0.031 44.000
48.000 -0.094 56.000 60.000
平面 = 1 ----------------------------
1.000 -0.000 9.000 13.000
-0.000 21.000 25.000 0.125
33.000 37.000 0.000 45.000
49.000 0.000 57.000 61.000
平面 = 2 ----------------------------
2.000 6.000 -0.000 14.000
18.000 0.000 26.000 30.000
0.000 38.000 42.000 -0.000
50.000 54.000 -0.000 62.000
平面 = 3 --------------
3.000 7.000 0.031 15.000
19.000 -0.031 27.000
31.000 -0.031 39.000 43.000 0.031
51.000 55.000 0.031 63.000
我什至尝试以这种方式填充数据:
我究竟做错了什么?
cuda - 调试 CUFFTW 接口计划创建
我开始移植现有的 fftw3 应用程序以使用 cuda fftw 库。初始阶段是简单地将fftw3.h
header替换为cufft.h
header 并链接 cufft 库而不是 fftw3 库。
这很简单,代码用nvcc
. 但是,当我执行代码时,应用程序无法使用该命令创建计划fftw_plan_guru_dft
(它只返回 0 而不是有效计划)。
由于没有报告错误,我不知道如何调试此问题。cuda-gdb
并且gdb
不提供任何进一步的见解。他们只是报告
更新:所以这是最小的工作示例。正如我在对 Talonmies 的评论中提到的,此代码是由科学微分方程求解器自动生成的。所以请原谅函数名称等。
除非其他人知道我做错了什么,否则 cufftw 可能不支持 fftw3 的这种特殊功能。
cuda - 为什么 cuFFT 在 K40 上“慢”?
我在双精度模式下在 GTX 780 和 Tesla K40 上比较了一个简单的 3D cuFFT 程序。
在 GTX 780 上我测量了大约 85 Gflops,而在 K40 上我测量了大约 160 Gflops。这些结果让我感到困惑:GTX 780 ha 166 Gflops 的峰值理论性能,而 K40 有 1.4 Tflops。
K40 上 cuFFT 的有效性能与理论峰值性能如此遥远的事实也来自 Nvidia 在此链接上创建的图表。
有人可以向我解释为什么会这样吗?cuFFT 库有限制吗?也许一些缓存动机......
matlab - Recursively use of self-implemented cuIDFT.cu leads to changing output every time when re-runing the code
I have implemented a CUDA version of inverse discrete cosine transform (IDCT), by "translating" the MATLAB built-in function idct.m
into CUDA:
- My implementation is
cuIDCT.cu
, works when m = n and both m and n are even numbers.
cuIDCT.cu
Then I compared the result of my CUDA IDCT (i.e. cuIDCT.cu
) against MATLAB idct.m
using following code:
- a test
main.cpp
function, and - a MATLAB main function
main.m
to read result from CUDA and compare it against MATLAB.
main.cpp
main.m
I ran the code on Visual Studio 11 (i.e. VS2012) in Windows 7 with Nvidia GPU Tesla K20c, using CUDA Toolkit version 7.5, and my MATLAB version is R2015b.
My test steps:
- For test case 1. Un-comment test case 1 and comment test case 2.
- Run
main.cpp
. - Run
main.m
in MATLAB. - Repeat step 1 and step 2 (without any change, just re-run the code).
- Run
I repeated step 3 for 20 times. The output result is unchanged, and results in main.m
are:
The maximum error is 7.7152e-07.
- For test case 2. Un-comment test case 2 and comment test case 1.
- Run
main.cpp
. - Run
main.m
in MATLAB. - Repeat step 1 and step 2 (without any change, just re-run the code).
- Run
I repeated step 3 for 20 times. The output result is changed, and results in main.m
are (not enough reputation to put all images, only wrong case is shown below):
one situation (the wrong one) of test case 2
The maximum error is 0.45341 (2 times), 0.44898 (1 time), 0.26186 (1 time), 0.26301 (1 time), and 9.5716e-07 (15 times).
From the test results, my conclusion is:
- From test case 1:
cuIDCT.cu
is numerically correct (error ~10^-7) toidct.m
. - From test case 2: recursively use of
cuIDCT.cu
leads to unstable result (i.e. the output changes every time when re-run the code and may sometimes be numerically wrong, error ~0.1)
My question:
From test case 1 we know cuIDCT.cu
is numerically correct to idct.m
. But why recursiviely use of cuIDCT.cu
leads to different output result each time when re-run the code?
Any helps or suggestions are highly appreciated.
c - cufftcomplex.h 程序员参考/文档
我正在研究 cufft 实现,但找不到对 cufftcomplex 函数的任何引用。不过,我通过谷歌找到了 cucomplex.h,但这对我没有帮助。具体来说,我想知道如何读出 cufftcomplex 结构的虚部和实部。
fft - cuFFT R2C 批量输出大小与输入大小不匹配
我正在用cuFFT试验批次。但我不认为我得到了正确的输出。
我在 GPU 上分配两个数组:
我正在使用这样的简单内核初始化源数组:
所以基本上,每个数组都有从 0 到 15 的值。我得到了 16 次。
我这样制定我的计划:
然后我正在执行我的计划:
最后,我将dst的内容传回主机。但是当我打印出这些值时,我得到了这个:
我期待一个重复的输出,但它每 9 个数字重复一次,而不是应该的每 16 个重复。
难道我做错了什么?或者有什么我不明白的。