- Why do we need Q#? - 7 Updates
- pow(0, 0) - 5 Updates
- Hateful abusive posts by Leigh Johnston, round #2 - 3 Updates
- Optimization when local variables are not used - 3 Updates
- The unbelievable slowness of larger int types (in my experiment) - 5 Updates
- Writing a Quantum Program - 2 Updates
| "😉 Good Guy 😉" <hello.world@example.com>: Nov 16 02:45AM <https://blogs.msdn.microsoft.com/visualstudio/2018/11/15/why-do-we-need-q/> -- With over 950 million devices now running Windows 10, customer satisfaction is higher than any previous version of windows. |
| "Mr. Man-wai Chang" <toylet.toylet@gmail.com>: Nov 16 12:17PM +0800 On 11/16/2018 10:45 AM, 😉 Good Guy 😉 wrote: > <https://blogs.msdn.microsoft.com/visualstudio/2018/11/15/why-do-we-need-q/> We don't! -- @~@ Remain silent! Drink, Blink, Stretch! Live long and prosper!! / v \ Simplicity is Beauty! /( _ )\ May the Force and farces be with you! ^ ^ (x86_64 Ubuntu 9.10) Linux 2.6.39.3 ¤£É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! ½Ð¦Ò¼{ºî´© (CSSA): http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa |
| Big Bad Bob <BigBadBob-at-mrp3-dot-com@testing.local>: Nov 16 12:45AM -0800 On 11/15/18 20:17, Mr. Man-wai Chang wrote: >> <https://blogs.msdn.microsoft.com/visualstudio/2018/11/15/why-do-we-need-q/> > We don't! we didn't/don't need C-pound, either. Nor '.Not'. But none of this will stop Micro-shaft from cramming it at us and insisting we jump on "yet another bandwagon" and chase "yet another moving target" as a development platform, until they pull the rug from under us and decide to stop supporting it... Micro-shat has been "getting it wrong" since the ".Not" initiative in the early noughties. It was wrong then, it's still wrong now, and win-10-nic is just another example of them NOT having a clue. now, where did I leave my clue-bat... -- (aka 'Bombastic Bob' in case you wondered) 'Feeling with my fingers, and thinking with my brain' - me 'your story is so touching, but it sounds just like a lie' "Straighten up and fly right" |
| "Mayayana" <mayayana@invalid.nospam>: Nov 16 08:31AM -0500 On 11/15/18 20:17, Mr. Man-wai Chang wrote: On 11/16/2018 10:45 AM, ?? Good Guy ?? wrote: "Big Bad Bob" <BigBadBob-at-mrp3-dot-com@testing.local> wrote | >> <https://blogs.msdn.microsoft.com/visualstudio/2018/11/15/why-do-we-need-q/> | >> | > We don't! | > Why don't you block those posts? Do you just like to get mad? Neither of them posts anything but pro-MS and anti-everyone else. I'm not convinced either one is even a human. Though Good Guy's animosity seems a bit too colorful to be cooked up by software. :) Do you actually understand the page linked? I don't. I wasn't aware that so-called quantum computing even existed yet. Maybe it doesn't and they're just planning. The fact the author uses "TL;DR" is a good indicator that he thinks by piling popular, current cliches together. Which is an interesting thing about programmers in general. They tend to be people who are very good with math but virtually incapable of intellectual thinking. By which I mean that if the meaning of life or advice on dating can't be rendered in a scientific formula then it doesn't count for them as a relevant topic for their attention. The piece is sort of interesting, though. It sounds like Q is meant to be used like inline assembly. The main difference I can see is that inline assembly does something, going direct to the CPU, while it's not clear what, if anything, Q does at this point. Their sample code looks like randomization. But I don't think I have the curiosity to figure out whether they're really talking about something. (Nor do I want to install the latest VS.) |
| "Mr. Man-wai Chang" <toylet.toylet@gmail.com>: Nov 16 09:38PM +0800 On 11/16/2018 4:45 PM, Big Bad Bob wrote: > the early noughties. It was wrong then, it's still wrong now, and > win-10-nic is just another example of them NOT having a clue. > now, where did I leave my clue-bat... A new/different programming language is just a change of words and syntax! :) -- @~@ Remain silent! Drink, Blink, Stretch! Live long and prosper!! / v \ Simplicity is Beauty! /( _ )\ May the Force and farces be with you! ^ ^ (x86_64 Ubuntu 9.10) Linux 2.6.39.3 ¤£É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! ½Ð¦Ò¼{ºî´© (CSSA): http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa |
| "Mr. Man-wai Chang" <toylet.toylet@gmail.com>: Nov 16 09:40PM +0800 On 11/16/2018 9:31 PM, Mayayana wrote: > like randomization. But I don't think I have the curiosity > to figure out whether they're really talking about something. > (Nor do I want to install the latest VS.) Anyone wanna bet that Q# compiler would be written in C? ;) -- @~@ Remain silent! Drink, Blink, Stretch! Live long and prosper!! / v \ Simplicity is Beauty! /( _ )\ May the Force and farces be with you! ^ ^ (x86_64 Ubuntu 9.10) Linux 2.6.39.3 ¤£É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! ½Ð¦Ò¼{ºî´© (CSSA): http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa |
| Wolf K <wolfmac@sympatico.ca>: Nov 16 09:33AM -0500 On 2018-11-16 08:31, Mayayana wrote: [...] > Do you actually understand the page linked? I don't. > I wasn't aware that so-called quantum computing even > existed yet. Maybe it doesn't and they're just planning. [...] Quantum computing is simulated in ordinary computers. Obviously not the really big problems that a true q-machine could solve, but manageable problems to test programming concepts and provide proof-of-concept. A coding langauge for q-machines is part of that effort: it's kinda difficult to think in terms of propositions that are both true and false until the probability wave collapses (which IMO is a highly misleading metaphor, aka "interpretation", but that's another issue). FWIW, a recent report in New Scientists said that one of the players (IBM?) has managed to isolate four or five q-bits IIRC. The technical problem is to maintain q-bits long enough to actually do some real work. Single-atom q-bits are very unstable. There are some hints that molecular q-bits could be more stable, ie, could be made at higher temperatures. In any case, portable q-machines will not be available, since the chips will ahve to be cooled to near absolute zero. Best, -- Wolf K kirkwood40.blogspot.com People worry that computers will get too smart and take over the world, but the real problem is that they're too stupid and they've already taken over the world (Pedro Domingos) |
| Ben Bacarisse <ben.usenet@bsb.me.uk>: Nov 16 01:53AM >> return 1 for ipow(0, 0), wouldn't you? > Why? Zero raised to any power results in zero. > Why is that argument less valid than yours? Beause of the context where ipow would be used. I listed some but I can't think of any where ipow(0, 0) == 0 is more useful. What sort of code are you considering? -- Ben. |
| Geoff <geoff@invalid.invalid>: Nov 15 08:27PM -0800 On Thu, 15 Nov 2018 06:31:18 -0800 (PST), >those decisions were made entirely at random, or by someone >unfamiliar with the fact that mathematically, the value of 0^0 is >undefined. What did Whitehead and Russell have to say about it in Principia? |
| Juha Nieminen <nospam@thanks.invalid>: Nov 16 12:11PM > int result=1; > for (int i=0; i<n; i++) result*=x; > This will produce 0^0 = 1 in a "natural" way. On the other hand, you could optimize the above a bit and say: int result = x for (int i = 1; i < n; ++i) result *= x; which saves one iteration, and which would give you 0 for the case that both x and n are 0. |
| Paavo Helde <myfirstname@osa.pri.ee>: Nov 16 03:04PM +0200 On 16.11.2018 14:11, Juha Nieminen wrote: > for (int i = 1; i < n; ++i) result *= x; > which saves one iteration, and which would give you 0 for the case > that both x and n are 0. This would produce a wrong value x^0 for all x>1. |
| jameskuyper@alumni.caltech.edu: Nov 16 06:32AM -0800 On Friday, November 16, 2018 at 7:12:08 AM UTC-5, Juha Nieminen wrote: > for (int i = 1; i < n; ++i) result *= x; > which saves one iteration, and which would give you 0 for the case > that both x and n are 0. That will give the wrong result for any value of x other than 1 (except for 0, where the "right" result is not definable). |
| "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Nov 15 08:57PM -0800 On 11/15/2018 3:07 AM, Rick C. Hodgin wrote: > Sin was here (on Earth, by man). > God had to become one of us (a man) ... here ... where we are, to > save us from sin where sin was, where we were condemned. I am wondering how many planets God has visited wrt cloning itself into the sentient intelligent inhabitants that He created anyway. God has experienced being a Human on Earth within the physical realm. Did God do the same thing for other planets in the creation? [...] |
| "Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 16 05:37AM -0800 On Thursday, November 15, 2018 at 11:57:28 PM UTC-5, Chris M. Thomasson wrote: > the sentient intelligent inhabitants that He created anyway. God has > experienced being a Human on Earth within the physical realm. Did God do > the same thing for other planets in the creation? It's never been explained in scripture. What God has revealed is there are three Heavens. The first is the air. The second is what we see in space (the stars, galaxies, and beyond). The third is not seen, but is the dominion of God, a paradise. Paul describes going there and that he heard things illegal for a man to talk about. What we have here in this physical world is the merest inkling fraction of what God's creation is. And He (God) offers each of us the ability to partake in that universe beyond what we know today, a place existing outside of time, as we see multiple references in scripture to people being taken out of time, or angels appearing and describing things out of time, etc. Jesus is the doorway. He takes away our sin, restoring us to that eternal Kingdom, giving us eternal life, making it possible for us to partake of God's true domain in the third Heaven. (1) Sinners forgiven by Jesus, go on to Heaven. (2) Sinners unforgiven, enter into Hell. There is a solid chasm created by God, designed to separate all that is of His Kingdom of truth, and all that is embracing and holding on to falseness. That chasm is the division between Heaven and Hell. No one in Heaven will ever enter into Hell, and no one in Hell will ever escape and enter into Heaven. It is a literal eternal prison, holding only those who refuse to accept truth, who hold onto falseness ahead of truth, who would only believe the lies of the enemy and not approach the truth of God to receive Him, salvation for their soul, the release of sin's condemnation upon their life, etc. Each person sends themselves to Hell. God has done everything to make it possible for everyone to have eternal life. He's made Jesus' sacrifice available to all ... and it's free for the asking. A person has to work very very hard to enter into Hell given all the saving provisions God has put before them in their life. And each person will self-condemn their own soul in God's final court on Judgment Day, when the books are opened which recorded the events of our lives. For the sinner saved by grace, everything's been blotted out that could condemn us. The entries were put on Jesus' list, and He paid the price of our sin in our place. For the sinner not saved, every sin they've committed remains in full force, in written form, recorded accurately, from their entire life. The secret things. The hidden things. The things you thought nobody knew about ... it's all there, and it will be read aloud in court before all as part of the permanent record as to why your soul is cast into the eternal lake of fire from which there is no escape, no parole, no anything except pain and angst and eternal torment. The choice is each of ours today. God has made salvation avail- able to all today for free. Simply ask Jesus to forgive your sin, and take up your own personal metaphoric cross and follow Him in this world. -- Rick C. Hodgin |
| Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 16 02:24PM On 16/11/2018 13:37, Rick C. Hodgin wrote: > is there are three Heavens. The first is the air. The second > is what we see in space (the stars, galaxies, and beyond). The > third is not seen, but is the dominion of God, a paradise. The problem is, Rick, that this scripture you mention is, as I have stated already, only half the story: The Bible is a disinformation campaign designed by the Nordic Aliens to retard our mental and technological development as the Nordics like to keep us as pets and nobody wants an independently minded pet that refuses sexual favours. You can see for yourself that what I say is true by referring to the 100th Cycle (Issue 14) Buttered Scone (Sin) Manifest (Virgo Cluster Edition). [snip tl;dr] /Flibble -- "You won't burn in hell. But be nice anyway." – Ricky Gervais "I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais "Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Bryne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?" "I'd say, bone cancer in children? What's that about?" Fry replied. "How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil." "Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say." |
| Paul <pepstein5@gmail.com>: Nov 16 02:23AM -0800 I posted the below code on another thread. A respondent said that the code should be "optimized away" by a good compiler. Presumably, this means that because basicPopcount has no side effects, and because main() doesn't do anything with the local variables it generates by calling basicPopcount, many of the basicPopcount calls should simply be skipped because the compiler has worked out that the computation would be pointless. I attempted to test this theory with Godbolt's compiler explorer. I have no formal education in assembly or computing more generally, so the feedback is cryptic. Complete code and compiler explorer data are copy-pasted below. Compiler is x86-64 gcc 8.2 What does the compiler feedback say about whether the computations are skipped in the way described above? Many thanks for your comments, and for all help previously given. Paul #include<iostream> int basicPopcount(int x) { int count = 0; int place = 0; // An overflow bug can arise in this method for large values of x // So make sure types are large enough while(1ull << place <= x) if(1ull << place++ & x) ++count; return count; } int main() { for(int i = 0; i < 10 * 1000 * 1000; ++i) basicPopcount(i); } basicPopcount(int): push rbp mov rbp, rsp mov DWORD PTR [rbp-20], edi mov DWORD PTR [rbp-4], 0 mov DWORD PTR [rbp-8], 0 .L4: mov eax, DWORD PTR [rbp-8] mov edx, 1 mov ecx, eax sal rdx, cl mov eax, DWORD PTR [rbp-20] cdqe cmp rdx, rax ja .L2 mov eax, DWORD PTR [rbp-20] movsx rsi, eax mov eax, DWORD PTR [rbp-8] lea edx, [rax+1] mov DWORD PTR [rbp-8], edx mov ecx, eax shr rsi, cl mov rax, rsi and eax, 1 test rax, rax setne al test al, al je .L4 add DWORD PTR [rbp-4], 1 jmp .L4 .L2: mov eax, DWORD PTR [rbp-4] pop rbp ret main: push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], 0 .L8: cmp DWORD PTR [rbp-4], 9999999 jg .L7 mov eax, DWORD PTR [rbp-4] mov edi, eax call basicPopcount(int) add DWORD PTR [rbp-4], 1 jmp .L8 .L7: mov eax, 0 leave ret __static_initialization_and_destruction_0(int, int): push rbp mov rbp, rsp sub rsp, 16 mov DWORD PTR [rbp-4], edi mov DWORD PTR [rbp-8], esi cmp DWORD PTR [rbp-4], 1 jne .L12 cmp DWORD PTR [rbp-8], 65535 jne .L12 mov edi, OFFSET FLAT:_ZStL8__ioinit call std::ios_base::Init::Init() [complete object constructor] mov edx, OFFSET FLAT:__dso_handle mov esi, OFFSET FLAT:_ZStL8__ioinit mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev call __cxa_atexit .L12: nop leave ret _GLOBAL__sub_I_basicPopcount(int): push rbp mov rbp, rsp mov esi, 65535 mov edi, 1 call __static_initialization_and_destruction_0(int, int) pop rbp ret |
| Ben Bacarisse <ben.usenet@bsb.me.uk>: Nov 16 11:43AM > generates by calling basicPopcount, many of the basicPopcount calls should > simply be skipped because the compiler has worked out that the computation > would be pointless. Yup. That's what happens with, for example, with g++ 8.2.0 with -O1 and above. > Compiler is x86-64 gcc 8.2 > What does the compiler feedback say about whether the computations > are skipped in the way described above? No. What you show has a main function that loops calling your basicPopcount function: > mov eax, 0 > leave > ret Maybe you did not request optimisation? A couple of points about the function itself... > ++count; > return count; > } The term "overflow" is a little odd here. There are two things to worry about. The first is shifting a 1 bit into the sign position and you've dealt with that but using 1u. The second thing is not really "overflow" per se. Shifting by the width of the (promoted) left-hand operand is undefined so the only way to give your loop defined behaviour is use a type that is wider than int. Unfortunately, unsigned long long int is not guaranteed to be wider -- you might find some odd implementation that has decided to make all the int types the same width. There are various ways round this but I won't give any right now since I get the impression you like to work things out for yourself. Finally, you *do* have a theoretical overflow problem here: > for(int i = 0; i < 10 * 1000 * 1000; ++i) > basicPopcount(i); > } 10 * 1000 * 1000 is larger than the smallest permitted value for INT_MAX (or, in more C++ terms, std::numeric_limits<int>::max()). You may never come across an implementation with that narrow an int, but you could impress an interviewer by showing that you are aware of the issue. -- Ben. |
| David Brown <david.brown@hesbynett.no>: Nov 16 01:44PM +0100 On 16/11/18 11:23, Paul wrote: > I attempted to test this theory with Godbolt's compiler explorer. > I have no formal education in assembly or computing more generally, > so the feedback is cryptic. The code below looks like you did not have optimisations enabled. You can put whatever flags you want in the command line on godbolt.org. Useful ones include : -x c // For C compilation rather than C++ -std=gnu++17 // For gcc extended C++17 -std=c++17 // For standard C++17 -std=gnu11 // For gcc extended C11 (with -x c) -Wpedantic // For warnings about non-standard C or C++ -O1 or -O2 // Basic optimisation -Wall -Wextra // Common warnings -m32 // Generate 32-bit code instead of 64-bit Another good trick when looking at the code is to avoid complicated library code. For example, if you want to see the code for calculating "foo(x) + bar(x)", don't try to pass the result to std::cout or printf. The important stuff will get lost in the details. Rather, write a simple function "int foobar(x) { return foo(x) + bar(x); }" so that you can look at the code for that function. |
| Robert Wessel <robertwessel2@yahoo.com>: Nov 15 09:38PM -0600 On Thu, 15 Nov 2018 12:35:46 -0800 (PST), Paul <pepstein5@gmail.com> wrote: > ++count; > return count; > } I just ran a quick GCC test (not on Windows, but). The generated code is nearly identical, except for using 64-bit instead of 32 bit registers for some of the operations. And those shouldn't see a big performance difference on most processors. Are you by any chance building 32-bit code? That will show a significant slowdown when using the 64-bit type. |
| bitrex <user@example.net>: Nov 16 01:09AM -0500 On 11/15/2018 03:35 PM, Paul wrote: > ++count; > return count; > } why not use Compiler Explorer: <https://godbolt.org/> and write your code there and you can see precisely what it generates for many compiler versions and many architectures |
| Paul <pepstein5@gmail.com>: Nov 16 12:15AM -0800 > performance difference on most processors. Are you by any chance > building 32-bit code? That will show a significant slowdown when > using the 64-bit type. I'm sure that building 32-bit code is the problem. Thanks for pointing this out. I'm using gcc with CLion. I'm going to attempt to use these instructions to fix the issue: https://dev.my-gate.net/2014/09/15/how-to-use-mingw-w64-with-clion/ Please let me know if you have anything else to add. Paul |
| Paul <pepstein5@gmail.com>: Nov 16 12:17AM -0800 On Friday, November 16, 2018 at 6:10:00 AM UTC, bitrex wrote: > <https://godbolt.org/> > and write your code there and you can see precisely what it generates > for many compiler versions and many architectures Thanks, good tip. Paul |
| Juha Nieminen <nospam@thanks.invalid>: Nov 16 12:22PM > This took 2.5 seconds. However, 10 million is small enough that you can > replace 1ull by 1 with no problems. This cut the time from 2.5 seconds > to 0.98 seconds, and I did this experiment many times. I haven't checked, but when creating such benchmarks, you should *always* make sure and check that the compiler isn't actually optimizing code away because the result is unused. It's a very typical mistake to make. Just very recently I had a conversation with someone in another forum who thought that his O(n^2) linked list traversal was faster than who you traverse std::list with iterators... only to find out that the compiler was optimizing his code out completely because it noticed that the end result was not being used for anything. (Not saying you have made such a mistake. Just pointing out that you should make sure that's not what's happening.) One way to check what the compiler is doing is to make it output in asm and examine the resulting code. (Of course this requires a modicum of understanding of asm.) At the very least you should always do something with the end result (such as printing it, even if you aren't interested in what the end result actually is). Even then, there can still be situations where the compiler is overly smart and optimizing code away that shouldn't be, if it's optimizing away the code you are trying to benchmark the speed of. |
| "😉 Good Guy 😉" <hello.world@example.com>: Nov 16 02:35AM Quantum Programs ( Q# ) are here and you better learn it fast!!!!!!!!!!! <https://docs.microsoft.com/en-gb/quantum/quickstart?view=qsharp-preview&tabs=tabid-vs2017> -- With over 950 million devices now running Windows 10, customer satisfaction is higher than any previous version of windows. |
| "Mr. Man-wai Chang" <toylet.toylet@gmail.com>: Nov 16 12:17PM +0800 On 11/16/2018 10:35 AM, 😉 Good Guy 😉 wrote: > Quantum Programs ( Q# ) are here and you better learn it fast!!!!!!!!!!! > <https://docs.microsoft.com/en-gb/quantum/quickstart?view=qsharp-preview&tabs=tabid-vs2017> A "Quantum Programs" is also a program and is just a file of source codes! :) -- @~@ Remain silent! Drink, Blink, Stretch! Live long and prosper!! / v \ Simplicity is Beauty! /( _ )\ May the Force and farces be with you! ^ ^ (x86_64 Ubuntu 9.10) Linux 2.6.39.3 ¤£É¶U! ¤£¶BÄF! ¤£½ä¿ú! ¤£´©¥æ! ¤£¥´¥æ! ¤£¥´§T! ¤£¦Û±þ! ¤£¨D¯«! ½Ð¦Ò¼{ºî´© (CSSA): http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa |
| You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment