Thursday, November 15, 2018

Digest for comp.lang.c++@googlegroups.com - 3 updates in 3 topics

Paul <pepstein5@gmail.com>: Nov 15 02:11PM -0800

On Thursday, November 15, 2018 at 9:29:40 PM UTC, Jorgen Grahn wrote:
 
> If the compiler had access to the basicPopcount() implementation
> when it compiled that, I'm surprised it wasn't all optimized away.
> It doesn't do anything! Did you enable optimization when compiling?
 
Thanks, Jorgen.
I just used the default gcc settings previously.
This explains why it wasn't all optimized away.
 
I changed to -O3 optimization. I'm not sure whether this is best
or what you would advise (?).
I changed the code to try and force the compiler to run through the loop
but to do as little extra work as possible. So now it
accumulates the results.
 
Full code is below. My times are derived from the "execution time" on my
console. This varies but is approximately 2 seconds for the 1ull version
and 0.8 versions where I use only ints.
For the sake of clarity, the full text of both versions is below.
I learned a lot already.
Many thanks for your further thoughts,
 
Paul .
 
/************************With ull *************/
#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()
{
int count = 0;
for(int i = 0; i < 10 * 1000 * 1000; ++i)
count += basicPopcount(i);
 
std::cout << count;
}
 
/************************Without ull *************/
#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(1 << place <= x)
if(1 << place++ & x)
++count;
 
return count;
}
 
// Main function is unchanged but is repeated for total clarity.
int main()
{
int count = 0;
for(int i = 0; i < 10 * 1000 * 1000; ++i)
count += basicPopcount(i);
 
std::cout << count;
}
ram@zedat.fu-berlin.de (Stefan Ram): Nov 15 10:07PM

Been to "programming language shootout" (now called
"benchmarkgame" or similar) recently. For the first
time in history, AFAIK, now there C++ is reported to
be faster than C! Finally after all those years and
all those efforts by many contributors, C++ has won!
 
I also saw that a Python program does now not take
anymore about 40 times the duration of a C program,
but just about 30 times. So Python also has become
significantly faster.
 
Now, let's celebrate!
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 15 07:50PM

On 15/11/2018 19:39, Rick C. Hodgin wrote:
> who will be saved, Leigh. It comes from within, not from without.
> God draws a person to His Son to be saved. It doesn't come from
> man's convincing arguments or statements.
 
The Nordic Alien who likes to go by the monikers "God" and "Jesus" does
like to push that line from the Nordic's disinformation document known as
the "Bible" because they don't want to see their pets (us) get too uppity.
The contents of that document are a great way to retard mental/sexual
development and, as a consequence, technological developments. The
Nordics like as as pets.
 
> stunned in every way that the very thing you mocked for decades
> now has made Himself known to you, and you've been forever changed
> by it.
 
The Nordic Alien known as "God" is quite a busy alien so I doubt I am in
his contact list. Maybe I should lose weight to become more fuckable so
he takes an interest.
 
> all the while concluding that I and the other people who believe in
> Jesus, are categorical lunatics of grand stature, deserving your
> pity at best, your wrath at worst, as "bigots" and "haters."
 
The Nordic Alien known as "Satan" is the Nordic Alien "Jesus"'s best mate;
they like to go on fuck parties together fucking their pets (us).
 
 
> Jesus is the great divider:
 
> (1) Sinners, saved by His Grace, going to Heaven.
> (2) Sinners, unsaved, going to Hell.
 
Yes Jesus likes to classify people by how fuckable they are. If you want
to be fucked by Jesus you probably need to lose some weight fat boy.
 
> it will be too late. I would save you from that today, Leigh,
> but it's not up to me. It's up to you and your willingness to
> hear that call and answer it.
 
Hear the call from Jesus? As I said I don't think I am on that particular
Nordic Alien's contact list as I am currently a bit rotund and portly.
 
 
> It's between you and God alone. No one else.
 
Nah, Nordic Alien "God" likes orgies too: some of his fuck parties are
legendary.
 
/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."
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: