BEGIN;
SET LOCAL pg_strom.enabled=on;
SET LOCAL pg_strom.enable_gpuscan=on;
SET LOCAL pg_strom.enable_gpuhashjoin=on;
SET LOCAL pg_strom.enable_gpujoin=on;
SET LOCAL pg_strom.enable_gpupreagg=on;
SELECT AVG(t2.c0) FROM t2 CROSS JOIN t4 WHERE ((t2.c0)IS DISTINCT FROM(t4.c0));
COMMIT;
As you may know, FP value may cause calculation errors when we operate a big value and a little value.
In this case, when float4_accum() handled the third value, it adds 0.3 on the intermediation value -850000000.
On the other hands, PG-Strom's logic makes this problem a bit mild, because __update_nogroups__psum_fp() calculates value[0] + value[1] and value[2] + value[3] first in parallel, then calculates the both results and store the result->sum field.
This often happens in calculation of very large number of items.
Describe:
SELECT \ FROM \ JOIN \ WHERE \ brings different results, when using CPU-only configurations and GPU-used configurations.
kaigai
commented
2 weeks ago
- © Githubissues.
- Githubissues is a development platform for aggregating issues.
SQL with CPU-only Config:
Result:
SQL with GPU-used Config:
Result:
Environment:
Pg-strom Version: commit 9765660eba4fab7e4e9378c667e6bd565da83ffd
PostgreSQL Version: 15.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), 64-bit
CUDA Version: 12.2
NVIDIA Driver Version: 535.171.04
This is calculation error in floating-point values, and PG-Strom returns more precise value.
See, the following results. The
AVG(c0)
is sum of the values divided by 4.Try to calculate them with explicit cast to numeric (that will never have calculation errors in floating-point):
As you may know, FP value may cause calculation errors when we operate a big value and a little value. In this case, when
float4_accum()
handled the third value, it adds0.3
on the intermediation value-850000000
.On the other hands, PG-Strom's logic makes this problem a bit mild, because
__update_nogroups__psum_fp()
calculates value[0] + value[1] and value[2] + value[3] first in parallel, then calculates the both results and store theresult->sum
field.This often happens in calculation of very large number of items.