{"action":"created","issue":{"url":"https://api.github.com/repos/RetroPie/RetroPie-Setup/issues/1385","repository_url":"https://api.github.com/repos/RetroPie/RetroPie-Setup","labels_url":"https://api.github.com/repos/RetroPie/RetroPie-Setup/issues/1385/labels{/name}","comments_url":"https://api.github.com/repos/RetroPie/RetroPie-Setup/issues/1385/comments","events_url":"https://api.github.com/repos/RetroPie/RetroPie-Setup/issues/1385/events","html_url":"https://github.com/RetroPie/RetroPie-Setup/issues/1385","id":141372581,"number":1385,"title":"RPI3 default compiler flags might need -funsafe-math-optimizations","user":{"login":"joyrider3774","id":10714776,"avatar_url":"https://avatars.githubusercontent.com/u/10714776?v=3","gravatar_id":"","url":"https://api.github.com/users/joyrider3774","html_url":"https://github.com/joyrider3774","followers_url":"https://api.github.com/users/joyrider3774/followers","following_url":"https://api.github.com/users/joyrider3774/following{/other_user}","gists_url":"https://api.github.com/users/joyrider3774/gists{/gist_id}","starred_url":"https://api.github.com/users/joyrider3774/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyrider3774/subscriptions","organizations_url":"https://api.github.com/users/joyrider3774/orgs","repos_url":"https://api.github.com/users/joyrider3774/repos","events_url":"https://api.github.com/users/joyrider3774/events{/privacy}","received_events_url":"https://api.github.com/users/joyrider3774/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-16T19:09:27Z","updated_at":"2016-03-17T08:30:31Z","closed_at":null,"body":"RPI 3 flags are set to the following in system.h:\r\n__default_cflags=\"-O2 -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard\"\r\n\r\nhowever specifying only -mfpu=neon-fp-armv8 does not have an effect if -funsafe-math-optimizations is not specified.\r\n\r\nto quote from  https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/ARM-Options.html from the -mfpu section\r\n\r\n> If the selected floating-point hardware includes the NEON extension (e.g. -mfpu=‘neon’), note that floating-point operations are not generated by GCC's auto-vectorization pass unless -funsafe-math-optimizations is also specified. This is because NEON hardware does not fully implement the IEEE 754 standard for floating-point arithmetic (in particular denormal values are treated as zero), so the use of NEON instructions may lead to a loss of precision. \r\n\r\nso i did a quick test using a whetstone benchmark from here http://www.roylongbottom.org.uk/Raspberry%20Pi%20Benchmarks.htm using default 4.9.2 pi compiler\r\n\r\n1st test: not specifying  -funsafe-math-optimizations\r\ncc whets.c cpuidc.c -lm -O3 -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -o whetstonePiA8-neon-fp-armv8\r\n```\r\nLoop content                   Result              MFLOPS      MOPS   Seconds\r\n\r\nN1 floating point      -1.12475013732910156      **336.557**              0.040\r\nN2 floating point      -1.12274742126464844       **328.799**               0.290\r\nN3 if then else         1.00000000000000000                1798.005     0.041\r\nN4 fixed point         12.00000000000000000                **1498.745**     0.149\r\nN5 sin,cos etc.         0.49911010265350342                  12.188     4.840\r\nN6 floating point       0.99999982118606567       256.915               1.489\r\nN7 assignments          3.00000000000000000                1198.953     0.109\r\nN8 exp,sqrt etc.        0.75110864639282227                   8.712     3.028\r\n\r\nMWIPS                                             710.041               9.985\r\n```\r\n\r\n2nd test: specifying -funsafe-math-optimizations \r\ncc whets.c cpuidc.c -lm -O3 -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -funsafe-math-optimizations -o whetstonePiA8-neon-fp-armv8 \r\n\r\n```\r\nLoop content                   Result              MFLOPS      MOPS   Seconds\r\n\r\nN1 floating point      -1.12367534637451172       **518.495**               0.027\r\nN2 floating point      -1.12167274951934814       **500.473**               0.198\r\nN3 if then else         1.00000000000000000                1798.265     0.042\r\nN4 fixed point         12.00000000000000000               **4495.306**     0.052\r\nN5 sin,cos etc.         0.49911010265350342                  12.165     5.047\r\nN6 floating point       0.99999982118606567       256.801               1.550\r\nN7 assignments          3.00000000000000000                1198.780     0.114\r\nN8 exp,sqrt etc.        0.75110864639282227                   9.264     2.963\r\n\r\nMWIPS                                             738.422               9.994\r\n```\r\n\r\ntest3: specifying mfpu=vfp\r\ncc whets.c cpuidc.c -lm -O3 -march=armv8-a -mfloat-abi=hard -mfpu=vfp -o whetstonePiA8-vfp \r\n```\r\nLoop content                  Result              MFLOPS      MOPS   Seconds\r\n\r\nN1 floating point     -1.12475013732910156       **336.550**              0.041\r\nN2 floating point     -1.12274742126464844       **363.128**              0.269\r\nN3 if then else        1.00000000000000000                1798.260    0.042\r\nN4 fixed point        12.00000000000000000                **1498.800**    0.153\r\nN5 sin,cos etc.        0.49911010265350342                  12.190    4.962\r\nN6 floating point      0.99999982118606567       299.717              1.308\r\nN7 assignments         3.00000000000000000                1188.301    0.113\r\nN8 exp,sqrt etc.       0.75110864639282227                   8.706    3.106\r\n\r\nMWIPS                                            727.358              9.995\r\n```\r\n\r\nTest 4: mfpu=neon-vfpv4 without -funsafe-math-optimizations\r\ncc whets.c cpuidc.c -lm -O3 -march=armv8-a -mfloat-abi=hard -mfpu=neon-vfpv4 -o whetstonePiA8-neon-vfp4\r\n```\r\nLoop content                  Result              MFLOPS      MOPS   Seconds\r\n\r\nN1 floating point     -1.12475013732910156       **336.581**              0.040\r\nN2 floating point     -1.12274742126464844       **328.885**              0.290\r\nN3 if then else        1.00000000000000000                1798.226    0.041\r\nN4 fixed point        12.00000000000000000                **1498.814**    0.149\r\nN5 sin,cos etc.        0.49911010265350342                  12.189    4.840\r\nN6 floating point      0.99999982118606567       256.921              1.489\r\nN7 assignments         3.00000000000000000                1198.839    0.109\r\nN8 exp,sqrt etc.       0.75110864639282227                   8.706    3.030\r\n\r\nMWIPS                                            709.921              9.987\r\n```\r\n\r\ntest5: mfpu=neon-vfpv4 with -funsafe-math-optimizations\r\ncc whets.c cpuidc.c -lm -O3 -march=armv8-a -mfloat-abi=hard -mfpu=neon-vfpv4 -funsafe-math-optimizations -o whetstonePiA8-neon-vfp4-unsafe-math\r\n```\r\n\r\nLoop content                  Result              MFLOPS      MOPS   Seconds\r\n\r\nN1 floating point     -1.12367534637451172       **518.469**              0.027\r\nN2 floating point     -1.12167274951934814       **500.466**              0.198\r\nN3 if then else        1.00000000000000000                1798.114    0.042\r\nN4 fixed point        12.00000000000000000                **4490.131**    0.052\r\nN5 sin,cos etc.        0.49911010265350342                  12.174    5.044\r\nN6 floating point      0.99999982118606567       256.816              1.550\r\nN7 assignments         3.00000000000000000                1198.939    0.114\r\nN8 exp,sqrt etc.       0.75110864639282227                   9.262    2.964\r\n\r\nMWIPS                                            738.646              9.991\r\n```\r\nthese tests were compiled on my pi3 itselve and ran while the cpu was NOT throttling due to tempratue settings the tests don't take long though but i am able to reproduce this fairly consitent specifying -funsafe-math-optimizations does seem to be needed for a further speed increase. It is also mentioned in the quote i posted above. \r\n\r\nWhen looking at the total MFLOPS there's an increase of 28000 with it specified however i have tried compiling ppsspp with that setting but did not *see* a real improvement\r\n\r\nfeel free to experiment / comment\r\n"},"comment":{"url":"https://api.github.com/repos/RetroPie/RetroPie-Setup/issues/comments/197760737","html_url":"https://github.com/RetroPie/RetroPie-Setup/issues/1385#issuecomment-197760737","issue_url":"https://api.github.com/repos/RetroPie/RetroPie-Setup/issues/1385","id":197760737,"user":{"login":"joyrider3774","id":10714776,"avatar_url":"https://avatars.githubusercontent.com/u/10714776?v=3","gravatar_id":"","url":"https://api.github.com/users/joyrider3774","html_url":"https://github.com/joyrider3774","followers_url":"https://api.github.com/users/joyrider3774/followers","following_url":"https://api.github.com/users/joyrider3774/following{/other_user}","gists_url":"https://api.github.com/users/joyrider3774/gists{/gist_id}","starred_url":"https://api.github.com/users/joyrider3774/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joyrider3774/subscriptions","organizations_url":"https://api.github.com/users/joyrider3774/orgs","repos_url":"https://api.github.com/users/joyrider3774/repos","events_url":"https://api.github.com/users/joyrider3774/events{/privacy}","received_events_url":"https://api.github.com/users/joyrider3774/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T08:30:31Z","updated_at":"2016-03-17T08:30:31Z","body":"ah thats too bad, it seems it has no real impact on real applications well at least not in quake and ppsspp but i doubt we'll find one then. Weird that it did have an impact on the benchmark program. ah Well it was worth a shot, could have been it did had an impact, at least now we know it does not make that much diffrence"}}