Monday, November 12, 2018

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

Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 11 11:29PM

On 11/11/2018 21:35, Rick C. Hodgin wrote:
 
> Prior posted similar content on November 9, 2018:
> https://groups.google.com/d/msg/comp.lang.c++/4GRuB8txcaE/L2BwxuKlBQAJ
> https://groups.google.com/forum/#!original/comp.lang.c++/4GRuB8txcaE/L2BwxuKlBQAJ
 
Any offence I have caused you by being a bit sweary and listing some of
your negative (but true) personality traits is equal and opposite to the
offence you have caused me. This is the Internet mate; deal with it.
 
/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."
David Brown <david.brown@hesbynett.no>: Nov 12 10:45AM +0100

On 11/11/18 22:35, Rick C. Hodgin wrote:
> If you would like to see Leigh Johnston (aka Mr. Flibble) stop posting
> his hateful, obscene content, please send an email to abuse@newsdemon.com.
 
I haven't seen any obscene posts by Mr. Flibble in recent times. A bit
of "colourful language" is not obscene. Unnecessary, yes, but not obscene.
 
But I have seen plenty of annoying posts by him, and they are a pain. I
am okay with the occasional off-topic thread discussing fossils,
beliefs, or whatever (I know my opinions are not universal here).
However, it is really tedious to see Mr. Flibble's idiotic fossil posts
whenever you make a technical post in a technical thread.
 
I think the only thing you can do is ignore him. We all know your
thoughts on fossils, evolution, and whatever else Mr. Flibble throws up
as though it were proof that your beliefs are wrong - and the rest of us
know fine that these are no more valid proofs that you are wrong than
your own posts are proof that you are right. We don't need his
repetitive and pointless posts every time you make an entirely
reasonable, on-topic and technical post. Equally, we don't need a reply
from you to those posts - they add nothing new, and provoke more silliness.
 
So my advice is to ignore these posts and not respond to them. And
continue with your on-topic and technical posts. (I might disagree with
much of what you write in them, but I fully support your right to make
these posts.)
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 12 05:22AM -0800

On Monday, November 12, 2018 at 4:45:52 AM UTC-5, David Brown wrote:
> So my advice is to ignore these posts and not respond to them.
 
My advice is to contact abuse@newsdemon.com and report his hateful
and abusive posts.
 
No human being deserves to be addressed the way he addresses me
and others ... on the Internet or anywhere else.
 
--
Rick C. Hodgin
David Brown <david.brown@hesbynett.no>: Nov 12 03:17PM +0100

On 12/11/18 14:22, Rick C. Hodgin wrote:
> and abusive posts.
 
> No human being deserves to be addressed the way he addresses me
> and others ... on the Internet or anywhere else.
 
I agree with your second paragraph - but I am not convinced that
reporting his posts is going to help. By all means give it a try, but
be prepared for disappointment. (You could also try abstaining from
making any posts related to your beliefs, regardless of the provocation.)
 
And be very clear here about your religious posts - no matter what your
motivation, no matter how much you feel you are obliged to make them, no
matter what you think you are doing or what you call the posts - they
are as annoying as anything Mr. Flibble comes up with, and they can be
as insulting, hateful and abusive. It does not matter what you
intended, or how /you/ view them - it matters how other people see them.
I find it hard to imagine a set of rules and regulations that would see
Leigh banned from posting, without also banning you. Personally, I
would not like to see either of you banned - merely that the pair of you
stop squabbling like kids pulling each other's hair at the back of the
class.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 12 06:49AM -0800

On Monday, November 12, 2018 at 9:17:16 AM UTC-5, David Brown wrote:
> would not like to see either of you banned - merely that the pair of you
> stop squabbling like kids pulling each other's hair at the back of the
> class.
 
I have a command an obligation by God to go forth and teach
people about His Saving Grace, through His Son Jesus Christ.
 
The people in this world don't recognize value in that teaching
today, here on this Earth, with all the other draws and pulls
given to them by the enemy. They can pick and choose what they
feel is right, and pursue it.
 
But the day is coming when all falseness will be shown for what
it is, and only truth will endure.
 
I challenge everyone to go and seek and read for yourself and
see if what I am teaching is true or not. It's not Rick's opinion.
It's Rick conveying what God first gave man. You can verify that
claim by examining the content for yourself.
 
--
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 12 07:11AM -0800

On Monday, November 12, 2018 at 9:17:16 AM UTC-5, David Brown wrote:
> ... I am not convinced that
> reporting his posts is going to help...
 
It won't help when one person posts. But when many do, he'll
lose his account like he did at GigaNews. And just maybe
eventually he'll learn that people can disagree categorically
on every issue that's before them, and still do so with a civil
tongue, showing respect for the other individual as a living,
breathing soul, with their full set of feelings, emotions,
thoughts, drives, passions, etc., and not as some throwaway or
disposable person concept that can be treated as garbage on a
childish whim.
 
--
Rick C. Hodgin
Daniel <danielaparker@gmail.com>: Nov 12 07:49AM -0800

On Monday, November 12, 2018 at 9:49:45 AM UTC-5, Rick C. Hodgin wrote:
 
> I have a command an obligation by God to go forth and teach
 
Nothing as grand as that. You're just another street preacher, Rick, and your
message is the same as all the other street preachers, loud, yelling, words about burning and sinners and salvation. Even Christians don't like that.
 
Daniel
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 12 08:10AM -0800

On Monday, November 12, 2018 at 10:49:43 AM UTC-5, Daniel wrote:
 
> > I have a command an obligation by God to go forth and teach
 
> Nothing as grand as that. You're just another street preacher, Rick, and your
> message is the same as all the other street preachers, loud, yelling, words about burning and sinners and salvation. Even Christians don't like that.
 
You mistake me for other people, Daniel.
 
I teach. Point people to scripture. Ask them not to trust me,
but to go and investigate for themselves.
 
It is the subject matter I teach people take exception to. It
brings them under scrutiny, under condemnation, under judgment,
but it is not me judging them. I'm teaching people that a real
judgment awaits us when we leave this world, and that we need
to be forgiven for our sin.
 
That teaching is a warning. It is the same as many street
preachers, but different than others. It comes from a place of
caring about your soul, your future, your eternity. It comes
from me wanting a better end for you.
 
Again, I ask you NOT to take my word for any of this, but to
go and investigate for yourself. See if what I am teaching you
is true. See if what I'm warning you about is real. If you
are willing to seek the truth with sincerity, you will know.
 
--
Rick C. Hodgin
"Öö Tiib" <ootiib@hot.ee>: Nov 12 08:34AM -0800

On Monday, 12 November 2018 17:49:43 UTC+2, Daniel wrote:
 
> > I have a command an obligation by God to go forth and teach
 
> Nothing as grand as that. You're just another street preacher, Rick, and your
> message is the same as all the other street preachers, loud, yelling, words about burning and sinners and salvation. Even Christians don't like that.
 
Let's imagine there exists powerful enemy to humans. What does
it want? It does likely want that we bequeath terribly damaged and
contaminated environment to our future generations. What feels like
simple way to achieve that?
 
Perhaps to feed wasteful lies into current generation. For example
that our world is only few thousand years old illusion that ends soon.
Perhaps to throw stories of recent total ecological catastrophes like
world-wide floods into mix. Illusion that self-repairs fastly. That would
give excuse to the madmen to damage it carelessly and so to turn it
into contaminated wastelands.
 
Future generations will be in difficulties and desperation. Few serious
military conflicts over the left-over resources would then make that
self-fulfilling prophecy complete.
 
However I think there are no such enemy but the madness is fully
man-made and so likes of Rick won't receive their deserved "thanks"
from it at "Pearly Gates".
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 12 08:34AM -0800

On Monday, November 12, 2018 at 10:49:43 AM UTC-5, Daniel wrote:
> On Monday, November 12, 2018 at 9:49:45 AM UTC-5, Rick C. Hodgin wrote:
> > I have a command an obligation by God to go forth and teach
 
> Nothing as grand as that...
 
We have marching orders:
 
https://www.biblegateway.com/passage/?search=Matthew+28%3A18-20&version=KJV
 
18 And Jesus came and spake unto them, saying, All power
is given unto me in heaven and in earth.
19 Go ye therefore, and teach all nations, baptizing them
in the name of the Father, and of the Son, and of the
Holy Ghost:
20 Teaching them to observe all things whatsoever I have
commanded you: and, lo, I am with you always, even unto
the end of the world. Amen.
 
Verse 18 is stating His authority to guide us in this way. And
we see where His authority derives from: from His death, burial,
and resurrection from the dead.
 
The teaching I give is information about the Kingdom of God,
about His call for us in our lives, about the things we need
to know so we can come to recognize our sin, acknowledge we are
guilty, ask forgiveness, and be saved.
 
You do not learn these things from the world. And in many
cases, even when you do hear it, you don't place significance
on it because the enemy's prior teaching in your ears is there
with another voice, making it hard to believe.
 
But if you will investigate it with a truth-seeking heart, God
Himself will reveal that truth to you, and you will then know
the truth, and that truth will literally make you free (from
judgment and death).
 
It is literally eternal life God offers. It's why He commands
us to go forth and teach. It is His free gift to all who will
repent and ask forgiveness for their sin.
 
--
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Nov 12 08:41AM -0800

On Monday, November 12, 2018 at 11:34:45 AM UTC-5, Öö Tiib wrote:
> it want? It does likely want that we bequeath terribly damaged and
> contaminated environment to our future generations. What feels like
> simple way to achieve that?
 
The Bible teaches us the nature of our enemy. You see, we (mankind)
were made in the image and likeness of God. We are made three-fold
beings (soul, body, spirit), just as He is (Father, Son, Holy Spirit).
 
Even the angels were not made so. Not even the most powerful angel,
Lucifer, who is called Satan now (Satan means "accuser" because he
accuses us of our sin night and day before God).
 
That angel was not content to be the most powerful angel. He wanted
to be God, to overthrow His creation, to undo His work, because He
is an enemy of God.
 
He came here to deceive us into sin, because God had decreed that
the wages of sin is death. So, he tricked us into sinning, and in
that way, forfeiting our eternal life.
 
What we are now is less than God created us to be because of sin's
judgment already at work upon us. We are spiritually dead, and our
soul is under condemnation for sin.
 
What Jesus did was come here to die in our place, a type of sub-
stitutional death, where He dies with our sin, leaving us without
sin, and therefore taking us out of judgment and setting us free
from the enemy's attempt at our eternal life.
 
Jesus saves people from death.
 
 
> However I think there are no such enemy but the madness is fully
> man-made and so likes of Rick won't receive their deserved "thanks"
> from it at "Pearly Gates".
 
There are a lot of hokey stories about the nature of the things
of God. Many are given to mankind by the enemy, and are designed
to mislead us, to deceive us.
 
Go to the Bible and read directly from the source. If you are
truly seeking to know the truth, God will open your eyes and heart
to it, and you will be changed by it.
 
It's not a Rick thing teaching you, but it is God using Rick as
part of the mechanism where God Himself is drawing you to this
knowledge. He uses these "encounters" with other Christians to
get you to answer those questions in your mind / heart, the big
deep life questions that He'll use to draw you to His Son.
 
It's about God teaching you... when you set your sights on the
truth, on knowing the truth, on not being deceived, but in a
real and true honesty wanting to know.
 
Seek, and you will find, Öö Tiib. Not by me, but by Him. I
can only point you to His knowledge and teaching. He is the
only one who can give you the faculties you need to be able to
believe it.
 
--
Rick C. Hodgin
Paul <pepstein5@gmail.com>: Nov 12 02:39AM -0800

No matter how much googling I do, I can't find the source code for the gcc function __builtin_popcount for any version of gcc. Could anyone help? Thanks a lot. The more recent the compiler, the better.
 
My aim is to compare times of various popcount algorithms. This raises another problem in that the times fluctuate wildly between runs.
 
I use this type of methodology below.
 
Thanks a lot,
 
Paul
 
// high_resolution_clock example
#include <iostream>
#include <ctime>
#include <ratio>
#include <chrono>
 
int main ()
{
using namespace std::chrono;
 
high_resolution_clock::time_point t1 = high_resolution_clock::now();
 
std::cout << "printing out 1000 stars...\n";
for (int i=0; i<1000; ++i) std::cout << "*";
std::cout << std::endl;
 
high_resolution_clock::time_point t2 = high_resolution_clock::now();
 
duration<double> time_span = duration_cast<duration<double>>(t2 - t1);
 
std::cout << "It took me " << time_span.count() << " seconds.";
std::cout << std::endl;
 
return 0;
}
 
Paul
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 12 01:38PM +0100

On 12.11.2018 11:39, Paul wrote:
> code for the gcc function __builtin_popcount
 
I just googled the quoted phrase, clicked on the most likely hit,
clicked on relevant link in that hit, and was dispatched to <url:
https://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/libgcc2.c?view=markup&pathrev=200506>,
which appears to have the current source for some support code for the
intrinsic, though not that function itself.
 
 
 
Cheers!,
 
- Alf
Paul <pepstein5@gmail.com>: Nov 12 05:20AM -0800

On Monday, November 12, 2018 at 12:38:48 PM UTC, Alf P. Steinbach wrote:
> https://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/libgcc2.c?view=markup&pathrev=200506>,
> which appears to have the current source for some support code for the
> intrinsic, though not that function itself.
 
Alf,
When I saw the first two lines of your posting, I was confidently
expecting a reprimand of the form "But it's the very first hit.
How come you can't use google etc?."
But at the end, you say that we don't have support code for "that function
itself" and yet, "that function itself" is what I wanted.
 
So I'm still stuck.
 
Paul
Paul <pepstein5@gmail.com>: Nov 12 05:26AM -0800

On Monday, November 12, 2018 at 12:38:48 PM UTC, Alf P. Steinbach wrote:
> intrinsic, though not that function itself.
 
> Cheers!,
 
> - Alf
 
Oh, I get it now.
I think you mean to piece it together from the popcount-related code
in the link you gave.
It hardcodes the answers in a table for x between 0 and 255 and uses bitmasking combined with look up for each set of 16 bits.
 
Paul
Juha Nieminen <nospam@thanks.invalid>: Nov 12 01:43PM

> My aim is to compare times of various popcount algorithms.
> This raises another problem in that the times fluctuate wildly
> between runs.
 
This is not something that's trivial to measure, because it depends a
bit on what exactly you want to measure. For example, it's difficult
to measure exactly how fast it is to count the number of 1-bits in
a 32-bit unsigned integer (although if you can use inline asm,
many/most CPU architectures have a way to count the exact clock
cycle count, which would be the best possible way, but it's not
something trivial to implement).
 
On the other hand, if you want to measure how fast the algorithm
can count the number of 1-bits in a bitset of 10 billion bits,
that's much easier to measure, but that task is quite different
and tells little about how fast the algorithm is for that previous
case. (In this case you would be traversing a huge array, and thus
constantly running into cache misses, which slow down the process,
adding thus time overhead that's unrelated to the popcount algorithm
itself into the mix.)
 
However, if what you are doing is measuring if algorithm A is
faster than algorithm B, then you could do something more like
the second option. Have like an array of a million bits, and
calculate in a loop its number of 1-bits several times, so that
the total time spent is in the order of several seconds, and
then compare the times. (Make sure that the compiler isn't doing
some overly smart optimizations that bypass the subsequent loops
or something, or bypassing the whole thing because it sees that
the result isn't used for anything. One way to ensure this last
thing is to print the result, for example, even if you aren't
interested in what the actual value is.)
David Brown <david.brown@hesbynett.no>: Nov 12 03:22PM +0100

On 12/11/18 13:38, Alf P. Steinbach wrote:
> https://gcc.gnu.org/viewcvs/gcc/trunk/libgcc/libgcc2.c?view=markup&pathrev=200506>,
> which appears to have the current source for some support code for the
> intrinsic, though not that function itself.
 
Intrinsics and builtins don't really have a function definition as such.
Depending on the target, the optimisation, the target-specific options,
the surrounding code, etc., __builtin_popcount can generate a "popcount"
instruction, inline code, or a call to a support library function. What
you have found is the source for the support library, which is probably
as good as it gets - and it includes versions using lookup tables as
well as versions with calculations.
David Brown <david.brown@hesbynett.no>: Nov 12 10:19AM +0100

On 11/11/18 13:39, Juha Nieminen wrote:
> bit array (which is represented eg. by an array of unsigned ints)
> that does not use any lookup tables and is faster than a typical
> implementation that does.
 
__builtin_popcount()
 
A number of processors have instructions for doing this - and a single
"popcnt" opcode will be faster than any manual implementation.
 
If you need a fast popcount function, it makes sense to see if your
compiler has a builtin or extension for it, or if there is a suitable
intrinsic function available for your target processor. Depending on
your portability needs, you will maybe need conditional compilation to
use gcc's intrinsic on gcc, MSVC's intrinsic on MSVC, etc., with a
fall-back to a generic algorithm.
 
And don't forget compiler flags that match the target processor families
- if your code doesn't have to run on an old device, don't limit the
compiler to the instruction set from the old devices.
 
(Yes, I know this answer is cheating.)
 
 
I suspect, however, that when the processor does not have a dedicated
population count instruction, a lookup table will be the fastest
implementation. There is no point in bothering about a fast
implementation unless you are calling the function frequently, so the
table is likely to be in cache when it matters - and therefore very fast.
Juha Nieminen <nospam@thanks.invalid>: Nov 12 10:20AM

> (Yes, I know this answer is cheating.)
 
When I wrote the question, I actually expected many replies of that sort.
At least you were honest enough to admit that it's a non-standard
extension, not even supported by most CPUs nor compilers, and thus not
really an option in portable code.
 
> implementation. There is no point in bothering about a fast
> implementation unless you are calling the function frequently, so the
> table is likely to be in cache when it matters - and therefore very fast.
 
Most (probably all?) implementations of std::bitset and
boost::dynamic_bitset use a lookup table algorithm for their count()
function, and it's really fast (and much faster than anything else
you could concoct, using standard C++.)
 
Even a simple 256-element lookup table is faster than anything else
not using lookup tables (because it essentially allows you to process
8 bits at a time, rather than having to check individual bits one by one).
And it only takes 256 bytes, so it ought to fit inside any CPU cache
quite comfortably.
David Brown <david.brown@hesbynett.no>: Nov 12 01:00PM +0100

On 12/11/18 11:20, Juha Nieminen wrote:
> At least you were honest enough to admit that it's a non-standard
> extension, not even supported by most CPUs nor compilers, and thus not
> really an option in portable code.
 
I am quite happy with the idea of code like:
 
#ifdef __GNUC__
inline int popcount(unsigned int x) {
return __builtin_popcount(x);
}
#else
int popcount(unsigned int x) {
// calculation
}

No comments: