Inconsistent results when using a Cuda Kernel in Matlab

7 ビュー (過去 30 日間)
Leoluca Tinzmann
Leoluca Tinzmann 2021 年 3 月 5 日
コメント済み: Leoluca Tinzmann 2021 年 3 月 10 日
Hello,
I have recently come across a problem when using a Cuda kernel: The results I get from the kernel are not always the same even though the input data is always the same.
Note the difference in the third row second column.
This is the Matlab code from the function:
And the Kernel:
Does Matlab perhaps not work well cuDoubleComplex when used inside the kernel?
I also tried to use wait(gpuDevice(1)) after I gathered the data. I thought that perhaps the gpu was not done with the calculation. It did not work.
Can somebody help me?

採用された回答

Joss Knight
Joss Knight 2021 年 3 月 8 日
You are overwriting the contents of wReal and wImag inside your kernel, but every thread with the same x grid position is reading the same element of that array. Some threads will see the original value and some the updated value and it'll be pretty much random which is which. Remove lines 68 and 69 and your problem will probably go away, although you may also need to update lines 82 and 88 to use w.x and w.y instead.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGPU Computing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by