public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/103005] New: experimental simd sin and cos with big arguments returns values bigger than 1 @ 2021-10-30 17:15 andreas_roever at web dot de 2021-11-01 10:32 ` [Bug libstdc++/103005] " marxin at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: andreas_roever at web dot de @ 2021-10-30 17:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103005 Bug ID: 103005 Summary: experimental simd sin and cos with big arguments returns values bigger than 1 Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: andreas_roever at web dot de Target Milestone: --- Created attachment 51704 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51704&action=edit example program displaying the problem there seems to be a bug in the sin and cos functions for the experimental/simd header. When giving a very big argument to those functions they return values outside the range -1 .. 1. I understand that the result will be quite meaningless for such big values. But I'd argue that it should always be in the range -1..1. so calculating sin(-2985064393126969344) gives 2527133379.389218 This is on Linux compiled with g++-11.2.0 -g -march=native --std=c++20 test1.cpp here the CPU info (for one core) processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz stepping : 3 microcode : 0xc2 cpu MHz : 3301.335 cache size : 6144 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single pti ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit srbds bogomips : 6399.96 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/103005] experimental simd sin and cos with big arguments returns values bigger than 1 2021-10-30 17:15 [Bug libstdc++/103005] New: experimental simd sin and cos with big arguments returns values bigger than 1 andreas_roever at web dot de @ 2021-11-01 10:32 ` marxin at gcc dot gnu.org 2021-11-06 16:51 ` andreas_roever at web dot de 2021-11-06 16:52 ` andreas_roever at web dot de 2 siblings, 0 replies; 4+ messages in thread From: marxin at gcc dot gnu.org @ 2021-11-01 10:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103005 Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-11-01 Ever confirmed|0 |1 CC| |marxin at gcc dot gnu.org, | |redi at gcc dot gnu.org Status|UNCONFIRMED |NEW --- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> --- Confirmed. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/103005] experimental simd sin and cos with big arguments returns values bigger than 1 2021-10-30 17:15 [Bug libstdc++/103005] New: experimental simd sin and cos with big arguments returns values bigger than 1 andreas_roever at web dot de 2021-11-01 10:32 ` [Bug libstdc++/103005] " marxin at gcc dot gnu.org @ 2021-11-06 16:51 ` andreas_roever at web dot de 2021-11-06 16:52 ` andreas_roever at web dot de 2 siblings, 0 replies; 4+ messages in thread From: andreas_roever at web dot de @ 2021-11-06 16:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103005 --- Comment #2 from Andreas Röver <andreas_roever at web dot de> --- I think the source of the problem is function __fold_input(const simd<double, _Abi>& __x) in simd_math.h this function should return values between -pi/4 and pi/4 but doesn't for the big argument. E.g for 2985064393126969344 it returns 27.678747 according to wolfram alpha it should return 0.189812 This "big" value throws off the calculation of the power series that is performed after this the 27.678646 is the result of a rounding error 2985064393126969344 / (pi/2) is (according to wolfram alpha again) 1900351014455063569.620838 but the CPU gets 1900351014455063552 This seems to be the closest value that the CPU can get to the real value. the difference between those 2 times pi/2 is the above mentioned 27.67... ... now my numerics skills are not good enough to find a cure for that problem. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libstdc++/103005] experimental simd sin and cos with big arguments returns values bigger than 1 2021-10-30 17:15 [Bug libstdc++/103005] New: experimental simd sin and cos with big arguments returns values bigger than 1 andreas_roever at web dot de 2021-11-01 10:32 ` [Bug libstdc++/103005] " marxin at gcc dot gnu.org 2021-11-06 16:51 ` andreas_roever at web dot de @ 2021-11-06 16:52 ` andreas_roever at web dot de 2 siblings, 0 replies; 4+ messages in thread From: andreas_roever at web dot de @ 2021-11-06 16:52 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103005 --- Comment #3 from Andreas Röver <andreas_roever at web dot de> --- I think the source of the problem is function __fold_input(const simd<double, _Abi>& __x) in simd_math.h this function should return values between -pi/4 and pi/4 but doesn't for the big argument. E.g for 2985064393126969344 it returns 27.678747 according to wolfram alpha it should return 0.189812 This "big" value throws off the calculation of the power series that is performed after this the 27.678646 is the result of a rounding error 2985064393126969344 / (pi/2) is (according to wolfram alpha again) 1900351014455063569.620838 but the CPU gets 1900351014455063552 This seems to be the closest value that the CPU can get to the real value. the difference between those 2 times pi/2 is the above mentioned 27.67... ... now my numerics skills are not good enough to find a cure for that problem. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-06 16:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-30 17:15 [Bug libstdc++/103005] New: experimental simd sin and cos with big arguments returns values bigger than 1 andreas_roever at web dot de 2021-11-01 10:32 ` [Bug libstdc++/103005] " marxin at gcc dot gnu.org 2021-11-06 16:51 ` andreas_roever at web dot de 2021-11-06 16:52 ` andreas_roever at web dot de
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).