Filter function returns different results on different GPUs

Hello,
I'm running into an issue where the built-in filter function returns different results on two different machines. One machine is running MATLAB 2022a and has a GeForce RTX 3080 Ti, the other is running 2018b and has a GeForce GTX 1070 Ti. The code being run to both is the line below - in each case, b1, a1, and dataRAW are the same, but filter returns different values.
datr = filter(b1, a1, dataRAW)
I think the source of the error has to do with the fact that dataRAW is a gpuArray object. In the code below, datr is the result of the filter function on the RTX PC, and dataRAW is the input data on the GTX PC. The first line returns false and the second returns true when both are run on the GTX PC.
isequal(filter(b1, a1, dataRAW), datr)
isequal(filter(b1, a1, gather(dataRAW)), datr)
Any ideas as to if/why the gpu may be creating a discrepancy here? The error between the results is quite large - the greatest difference is about 0.1755 which is not negligible for my application. Please let me know if I can clarify anything. Thanks!

댓글 수: 5

Rounding errors are expected. Filtering contains a summation and sums are numerically instable. The difference of "0.1755" is not meaningful without knowing the absolute values. This might still be near to eps of the actual values.
What are the types of the arrays: single or double?
The arrays are singles. The maximum value in the array is about 400, so an error of 0.1755 seemed large - would that be in the range of expected error?
To clarify what is happening, when I pass in a 20 element gpuArray dataRAW variable with the following values
Columns 1 through 13
4.6461 -8.5038 -4.9968 -9.1288 -2.8733 -2.1869 0.9040 -0.7962 -9.1457 -0.3660 2.2983 0.8298 1.0495
Columns 14 through 20
-2.1288 0.4772 -3.0542 -0.7289 -5.0673 2.8573 -3.5927
I get different results when I call filter on dataRAW vs. gather(dataRAW):
>> filter(b1, a1, dataRAW(1:20, 1))
Columns 1 through 13
4.5113 -8.5227 -4.6232 -8.3562 -1.7752 -0.9748 2.1168 0.3764 -7.7210 1.2904 3.8468 2.2382 2.3575
Columns 14 through 20
-0.8329 1.7773 -1.7236 0.6657 -3.5527 4.3838 -2.0982
>> filter(b1, a1, gather(dataRAW(1:20, 1)))
Columns 1 through 13
4.5113 -8.5227 -4.6232 -8.3562 -1.7752 -0.9748 2.1168 0.3764 -7.7210 1.2903 3.8467 2.2381 2.3574
Columns 14 through 20
-0.8330 1.7771 -1.7238 0.6655 -3.5529 4.3836 -2.0985
I suggest attaching one .mat file containing a1, b1, dataRaw so we can test for ourselves.
Sure, this file contains a1, b1, and a truncated dataRAW (the whole thing exceeds the 5 mb limit but this smaller version still generates the same issue).

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2022년 5월 12일
편집: Matt J 2022년 5월 12일
Use double floating point, instead of single floating point.
load('kilo_vars.mat')
res1=filter(b1, a1, dataraw);
res2=filter(b1, a1, gather(dataraw));
mismatch=max(abs(res1-res2))
mismatch =
gpuArray single
0.0174
dataraw=double(dataraw);
res1=filter(b1, a1, dataraw);
res2=filter(b1, a1, gather(dataraw));
mismatch=max(abs(res1-res2))
mismatch =
3.6103e-11

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 5월 12일

편집:

2022년 5월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by