« first day (914 days earlier)      last day (4260 days later) » 

05:00
@Telkitty It's pretty easy to write a linked list that works with almost any arbitrary type, at least as long as it supports a few trivial capabilities like copy construction and destruction. For a vector, you need to add in supporting assignment correctly. Inheritance is irrelevant except to the extent that (for example) deep inheritance trees can make assignment difficult to implement correctly.
user1357851
@StackedCrooked right, and what if the linked list is also deployed in a multi threaded environment with read/write locks?
Your code should be thread-safe.
99.9% chance of homework
Oh you....
My first hash table. (Still kindergarten level.)
Just toying with the idea actually :)
I'll tell him to use beans.
Posted.
But not the beans.
My hash algorithm is x%10 lol.
#define BOOST_TEMPLATED_STREAM_COMMA ,
:|
This fucking header.
05:11
Is it a header?
Yes
boost/detail/templated_streams.hpp
That must be there for some really really old compilers.
05:15
Generating a comma often requires a macro though.
lol
2
A: Speedup a short to float cast?

MysticialHere's a basic SSE4.1 implementation: __m128 factor = _mm_set1_ps(1.0f / value); for (int i = 0; i < W*H; i += 8) { // Load 8 16-bit ushorts. // vi = {a,b,c,d,e,f,g,h} __m128i vi = _mm_load_si128((const __m128i*)(source + i)); // Convert to 32-bit integers // vi0 = {a,0,...

^^ That's a fine example of the kind of hard-core micro-optimization that I do.
Look at the fully unrolled version of the loop. > 15x faster, and ridiculously complicated. :)
using namespace std;?! system("pause");?!?
shhhhhhh
using namespace std; is great for scripting. :)
I didn't expect to get any speed-up beyond unrolling 2 or 4.
This one surprised me...
I turned a 2-line loop, into an 80-line monstrosity - that runs more than 15x faster. lol
by hand?
05:22
Lots of copy paste actually.
I write the simply vectorized version.
By hand is the best way, copy pasting and watching for patterns. ^^
couldnt the compiler do it for you?
Normalize the names a bit. Then copy and paste.
@Borgleader nope
I wish a compiler could do it. But as of 2012, they can't.
Not a single compiler that I've used is capable of doing what I did.
Compilers can unroll. But they can't interleave like that.
At least not on huge chunks of straight line code.
Someone should use machine learning to analyze your before and after code and learn your process :P
Compiler optimization is NP-complete. The only reason why I can do it is because I'm the programmer and I have outside (big-picture) information.
05:26
The promise is that idiomatic code will be better optimizable than non-idiomatic.
But I wonder if it's really a dogma :)
@StackedCrooked Which is true. But in this case, I knew what the compiler is and isn't capable of. So I wrote the code in a way that it would compile very well.
This is a unique case though. Usually, unrolling of SSE loops never gets up to 8 iterations with linear improvement.
But in this case, each iteration requires only 2 SSE registers. So you can get away with 8-way loop unroll with no problems.
Most code will need more than 2 registers for an iteration. So it won't unroll this well.
@Mysticial I'll grant that it's unusual, but I doubt it's truly unique.
You should work for a game company, we'd have holodeck graphics in no time ;)
@JerryCoffin At least compared to the cases I run into my Pi program.
A radix-4 FFT butterfly needs 12 registers. So loop unrolling + interleaving doesn't work.
@Mysticial Btw, have you seen Alexdrescu's talk at Facebook about optimization? (It was a few months ago.)
05:31
@StackedCrooked link?
I might have.
Let me see if I can find it.
@Mysticial Fair enough -- I'd even agree that it's fairly unusual in general.
Hah beat you to it! :P
05:33
He mentions some things I had never heard before.
That optimization he does on the string code is insane
I'm pretty sure @Mysticial has -- I think we discussed it some time back.
he gets like 7x speed?
Yeah, I've seen that one.
Including the video.
I remember pointing out a few things that I didn't agree with as well.
05:34
I think I linked it to you a while ago
@Mysticial Which ones?
Don't remember. I need to go through the slides again.
Ah well.
I was really surprised by some things. Like array indexing being (sometimes) faster than pointers.
On the "More generalities" slide, I disagree with 2nd and 3rd bullets.
If one replaces a + b + c + d with (a + b) + (c + d) will the compiler generate faster code?
05:37
On the "Strength reduction" slide, two of the bullets are in the wrong place.
comparisons are not faster than integer adds.
@StackedCrooked why would it be faster ?
Silly question perhaps. But I wonder because (a + b + c) evaluates to (a + (b + c)) which prevents SIMD optimization.
integer multiplication is not slower than floating-point adds.
At least not on modern hardware.
@Mysticial I see.
He does mention that his talk will likely be outdated very soon.
On the "Integrals" slide. The first bullet is only true for 32-bit systems.
The second bullet is... well... BS to say the least.
05:40
It'd be nice to have a sort of test suite to be able to "reliably" determine the strength of these types of operations
@Mysticial prefer unsigned to signed?
The floating-point side looks ok.
@StackedCrooked yeah, that bullet makes no sense whatsoever.
In the hardware, they are all the same.
Dammit, how to beat the Rancor monster? :(
grenade + pheromones => the pile of bones
@StackedCrooked These were outdated before he gave the talk. The notion that comparisons are faster than adds was probably never true. In fact, the best you can generally hope for is that a comparison will be the same speed as an add. On older hardware, it's often slower (uses subtract, which in some old processors adds a pipeline stage for negation). In newer ones, still forms a dependency between comparison and conditional branch, so even though the comparison itself is fast, the code is slower.
If the branch is unpredictable, may be a lot slower.
05:43
@Borgleader Oh, right! My first hunch was an all out assault. :$
Well you asked for our help at first
Whoa, I just wrote my first piece of code that only compiles in GCC 4.8
was wondering why it didn't compile in ideone :(
The first version blocked system calls. Which made it somewhat safe, but it was very limiting.
@Rapptz std::atomic::is_lock_free?
nope.
It's a usage of auto
static constexpr auto value = Size<T>::value;
where it's template<template<typename> class Size, typename T> :S
05:55
@Rapptz I wouldn't have dared to release it in the wild. Actually, I still don't dare to do that.
Xeo
Xeo
@StackedCrooked It's already being used "in the wild", though - some guy in a question mentioned it.
And that std::random_device seems borken?
Yeah it was even mentioned in isocpp
@Xeo Indeed. It has been posted on isocpp after all. And the Wikipedia C++11 page links to it. However, it's still not very widely used.
I've also seen it used on the GCC mailing list to report GCC bugs :)
Xeo
Xeo
heh
Someone even linked to it on 4chan.
Xeo
Xeo
06:00
Wait, what
Just a compiler thread on /g/ :)
Well, I think I need to go get some sleep. Talk to you later.
@JerryCoffin Good night.
@JerryCoffin night
06:21
Weee
user1357851
I almost jumped into my screen.
06:38
I feel the shark is smiling and happy, I must be wrong.
It's almost like a puppy.
@ScottW Could it be that you are actually a bitch?
Well. I'll find out sooner or later.
One day you'll be mine.
Have +20.
@Mysticial so you would basically say, int add/multiply, float add/multiply, int/float div?
@ScottW That does it. I've had enough of you!
Leaving for work now.
l8r
int - add, sub, xor, and, or, not
int - shift
int - mul
float - add, sub
float - mul
float - div
int - div
yeah, ok
06:45
@StackedCrooked later
@Mysticial Is there any reliable way of benchmarking that?
@Borgleader Not easily.
There's actually two factors involved. So it's not just a single one that is "speed"
There's latency and throughput.
Latency is how long it takes. Thoughput is how many you can sustain per cycle if you did multiple of then at the same time.
What's not intuitive is why shifts are slower than add/sub.
That's just because the way modern processors are optimized.
^^ interesting...
@Mysticial I have another question for you. Current CPUs can do one SSE multiplication and addition at the same time, right?
@bamboon Correct. I'm not sure about Haswell though.
0
A: How to parsing from xml(with namespace) to object in java(JPA)?

Srkcolor.... asdad asasdkd as asd as da d asd s d as das das dasd a das da d ds d...

06:57
Bulldozer has FMAs so it's a bit more complicated.
@Mysticial Ok, and the difference to FMA is that FMA can write that to a single result vector?
@bamboon Let's back up a bit. In the older processors (without FMA), there are two pipelines: An add pipeline and a multiply pipeline. They are completely separate. Each one can sustain 1 instruction per cycle.
On Bulldozer (as well as most FMA processors), there is only a single pipline: an FMA pipline that can do both along with FMAs.
user1357851
I indulged myself with food, I think I need a 60 minutes jog this evening
The FMA unit can do an add by essentially bypassing the multiplier. Likewise, it can do a multiply by bypassing the adder. But in essence, it's one unit with a multiplier+adder back to back.
So an FMA unit can only sustain one instruction per cycle. Those instructions can be either add, mul, or FMA.
I wish you had a blog where you put up before/after code snippets that you optimized and the thought process behind that optimization.
07:06
@Mysticial ah ok, that's interesting. But with FMA we can basically do b * c + d and we would have the result after one cycle while without FMA we would have to do b * c in one cycle and then in a second cycle do result_of(b * c) + d. On the other side we could a * b and c + d in one cycle? (Ignoring the differences between FMA3 and FMA4 for now)
@Borgleader I've been pondering writing one like that
@Borgleader I have a couple of examples which I keep for presentation and teaching purposes. But it's not written up in a blog or anything.
You teach!?!?
@bamboon Well, it's not one cycle. It takes long than that. But it can sustain 1 per cycle. On Bulldozer, adds, multiplies, and FMAs all take exactly 4 cycles. But you can start a new one each cycle.
That's why it's called a pipeline.
And FMA is essentially a tightly-coupled multiplier and adder. It's sole purpose is to perform fused multiply-adds. (a*b+c) If you want an add, you feed a 1 into b. If you want a multiply, you feed 0 into c.
That's somewhat of a simplification of how it's done.
So no, a single FMA cannot do both a multiply and add at the same time in the sense of the older processors which have separate add and multiply pipelines.
So instead of having two specialized factories. You have only one factory that's generic.
@Mysticial Hmm, just to get this straight. When talking about FLOPs aren't we always talking about throughput and not about latency?
07:20
@bamboon Yes we are. But you mentioned, "b * c in one cycle and then in a second cycle do result_of(b * c) + d". Which is not true since the whole thing takes longer than that.
On bulldozer, the whole thing takes 4 cycles. How much of that is split up between the multiply and the add, we don't know or care.
@Mysticial ah yeah, right.
IOW, the adder and the multiplier in an FMA can't be separated to recreate the independent pipelines that existing in the older processors without FMA.
So in the older processors, if you want peak flops, you need to issue an equal # of adds and multiplies. That's it.
On FMA processors, if you want peak flops, you MUST issue ONLY FMAs...
Since an FMA counts as two flops. But the processor see FMA, add, mul, as all the same.
yup, that's what I got from your max FLOP answer.
@Mysticial can compilers be tweaked to do that themselves?
Yeah. My max flop answer doesn't do FMAs. So it'll only get half the peak flops.
@Borgleader Not all adds can be fused with a multiply, and vice versa.
07:26
No I mean, can they be "told" to do it whenever possible
@Borgleader Yes, they can do that if you allow relaxed floating-point behavior.
Since fusing breaks strict floating-point behavior.
argh
more gallstones
I actually answered something related to this a week ago: stackoverflow.com/a/15933677/922184
@DeadMG again? =/
@DeadMG Is this a recurring thing?
07:28
@Mysticial For the last 30 months.
ow...
Sorry Lightness Races in Orbit .I didn't read the Release Notes for "Crystal Reports" .Can you please suggest me whether it supports or not.? If does not support I need to convert my entire project for this. — rakesh 2 mins ago
sigh
@ThePhD not sure if I should be insulted by that :O
@fibertech WTF?
@LightnessRacesinOrbit the answer is read release notes
07:41
@thecoshman no, read release notes
READ RELEASE NOTES!
@BenjaminGruenbaum just a troll, nothing to see here
@LightnessRacesinOrbit erm... that's what I said
@thecoshman no, you said read release notes. Instead, the OP should read release notes
where's the fibertech msg? can't see it
all his crap was binned
oh
got it - lol!
in bin, 6 hours ago, by fibertech
@BenjaminGruenbaum your avatar looks to be photosopped, cause tours to india are very expensive
07:44
@LightnessRacesinOrbit yeah, I meant that as the response to say to him, perhaps I should have quoted it to spare your simple mind
@thecoshman why don't you just read the release notes
@thecoshman (I feel like this joke isn't working)
I thought you were already, from the start, parodying my having to repeat "read the fucking release notes", so I continued that scheme. But now it looks like you didn't mean it that way :(
@LightnessRacesinOrbit clearly... though I am sure I didn't spell anything wrong, for once
@thecoshman that is true!
I have to say, that is slightly amusing
what ever the joke is, it's not just flown over my head, it's damn well orbiting the outer solar system o_0
07:47
@thecoshman racing in orbit, you might say
fuck those fucking singletons! Aaaargh
@jalf legacy code?
dealing with polymorphic allocators right now in LEWG
@thecoshman That would imply singletons were acceptable at some prior point in time. :P
@thecoshman kind of but not really. It's only a couple of years old. Was written by another team member before I joined though
07:49
@EtiennedeMartel seems like a nice addition to me, I agree with the sentiment very much
I can't believe I'm not in the room's frequent users list
I'm here all the fucking time
Anyway, for the most part it'd been fairly harmless, but now it's causing all those errors singletons are so good at
@DomagojPandža no, it implies that legacy code is full of them... any sort of validation of them is purely made up in your head
@Mysticial do you know if Thuban also had two pipelines for add and mul?
@LightnessRacesinOrbit I can't believe I am, I am only on for about an hour a day, and almost never the weekend
07:51
@bamboon Thuban is K10 right?
I'd argue singletons are "ok" in very small projects that won't grow (code that will be used once of twice and is less than 200-400 lines), for anything else they always bite you in the ass
@thecoshman Yeah. It's blatantly a fix.
@BenjaminGruenbaum no, not even then.
@Mysticial yup
@bamboon Then yes. It has still have separate pipelines for add and mul.
07:52
design EVERYTHING with the intent that it could grow
@BenjaminGruenbaum even if they're harmless there (and I don't think they are), why on earth would you add a singleton to a 200-line project?
I am not saying design it so it can scale to support billions of users, but design it so that the transition is easier
so adding known bad design ideas is just 'keying your own car' stupid
@jalf hint: they are not harmless, ever
@jalf Sometimes at work I have to design crawlers that work once and are then discarded. I don't use singletons, but if I saw a solution using singletons I really wouldn't mind.
@BenjaminGruenbaum but a singleton is never discarded. It stays alive until the process terminates
As much as I hate the concept of globals, and non-testable code, I don't mind code that isn't best practice as long as I can easily understand it and it's sufficiently small.
07:54
Singletons: Not Even Once
Anyway, this doesn't answer my question: even if we accept the assumption that "they do no harm", why would you do it? If your code is so small and simple, why would you ever want to add a singleton to it?
oh, that Java course I was on. The man was defending the use of singletons; luckily I got chatting with him. He actually agrees the true singletons are bad, but he actually means a factory method that only returns one instance, but where the class itself is not a singleton (and the factory would be another class)
@jalf Ok, that's not why I wouldn't use singletons though. Singletons represent a wrong approach to do something that is left with us from the days people couldn't OOP correctly.
@jalf For example a DB connection or a logger are both things that shouldn't be singletons, but if they are singletons in a sufficiently small project I really wouldn't mind it that much.
the problems with singletons is that when you have to work on code that has been built using them, it is a massive pain in the ass to actually change anything about it.
Sure, you could say that, but my main beef isn't with what they "represent", but with what they actually do. I don't care that they represent sloppy code, I care that they actually cause painful bugs and make the code hard to use and extend
07:57
@thecoshman No argument there, singletons on a big code-base are maintenance hell
@BenjaminGruenbaum just as much pain in small projects, why add them in the first place?
@thecoshman Because writing bad code is easier than writing good code, and I don't have absolute control over what other people do. I'm saying that I would pass a singleton in a code review if it were sufficiently minor, not that I would use them in my own code.
sure when they are already there, and you are working for money, you have to justify the cost of removing the singletons, which can easily be shot down with 'what functionality are you adding', and countering it with 'it's easier to maintain and develop' falls on dumb ears
Just like I wouldn't mind service location instead of DI with IoC containers in small enough code. Or not using a container at all.

« first day (914 days earlier)      last day (4260 days later) »