{"action":"closed","issue":{"url":"https://api.github.com/repos/ANL-CESAR/XSBench/issues/3","labels_url":"https://api.github.com/repos/ANL-CESAR/XSBench/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/ANL-CESAR/XSBench/issues/3/comments","events_url":"https://api.github.com/repos/ANL-CESAR/XSBench/issues/3/events","html_url":"https://github.com/ANL-CESAR/XSBench/issues/3","id":59688238,"number":3,"title":"Result of computation is never checked -> optimising compilers skew results","user":{"login":"stephand","id":177268,"avatar_url":"https://avatars.githubusercontent.com/u/177268?v=3","gravatar_id":"","url":"https://api.github.com/users/stephand","html_url":"https://github.com/stephand","followers_url":"https://api.github.com/users/stephand/followers","following_url":"https://api.github.com/users/stephand/following{/other_user}","gists_url":"https://api.github.com/users/stephand/gists{/gist_id}","starred_url":"https://api.github.com/users/stephand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephand/subscriptions","organizations_url":"https://api.github.com/users/stephand/orgs","repos_url":"https://api.github.com/users/stephand/repos","events_url":"https://api.github.com/users/stephand/events{/privacy}","received_events_url":"https://api.github.com/users/stephand/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-03T19:00:04Z","updated_at":"2015-03-04T02:48:10Z","closed_at":"2015-03-04T02:48:10Z","body":"I manually added the LTO options to CFLAGS / LDFLAGS on GCC and the compiler is smart enough to throw away the computation.\r\n\r\nThe issue is that in Main.c calculate_macro_xs, the return value (in macro_xs_vector) is never checked in the main function.  If I force the generation of the results through asm volatile (\"\"::\"m\"(macro_xs_vector[0]),\"m\"(macro_xs_vector[1]), ...) the results change significantly:\r\nComparing lookups/s on a three core machine:\r\n\r\n$ while true; do res1=$(./XSBench -s small | awk '/Lookups.s:/ {print $2}'); res2=$(./XSBench.force_use -s small | awk '/Lookups.s:/ {print $2}'); echo $res1 $res2; done\r\n6,142,927 920,383\r\n5,513,363 983,074\r\n5,243,478 991,507\r\n\r\n\r\nShows a over 6x speed increase due to the optimised out computation in the existing code.  The numbers on the right are very similar to what I get if I disable LTO.\r\nPlease fix the usage of the results, through either this mechanism (empty asm volatile consuming the data), or by keeping a running sum of the results etc."}}