« first day  last day (14 days later) » 

4:55 AM
@Mysticial ok I'm back :) and I'm not sure I understand, I mean alignment wasn't really related to my question
@Mysticial I meant why are there specific intrinsics for memory operations if regular memory access works just fine for SSE types?
 
5:06 AM
@Mehrdad For the misaligned intrinsics, it's obvious. But I dunno about the aligned ones. Maybe they're there just for completeness.
Or perhaps older compilers we're as capable.
 
@Mysticial yeah that's what I meant ok
Interesting, I'll see if I can come up with an example, because I could swear I've seen a difference at some point a couple or so years ago
but I don't remember what it was exactly
 
Interestingly, all the intrinsics for aligned load/store take the scalar type.
So perhaps it's just to save a cast.
 
Maybe
 
Either way, it took them until AVX512 to realize the mess it made.
 
lol
 
5:08 AM
But the old intrinsics will stay the way they are for backwards compatibility.
 
yeah :\
 
They can't even overload it because of C compatibility.
 
yeah
I honestly don't understand why they don't have C++ wrappers that just do vector arithmetic
through operator overloading.
 
But yeah, the only load/store intrinsics that I use nowadays are the misaligned ones as well as the streaming ones.
 
right
 
5:10 AM
Since most of the SIMD that I do now is code that is completely designed around the SIMD.
So rather than vectorizing on a loop-by-loop basis, I change the fundamental datatype to the SIMD vector and go from there.
 
@Mysticial you mean like MATLAB style? (same code, just vectorized)
 
Kinda. I had to sort of invent my own programming style to make this work.
Especially with the variable vector sizes.
 
@Mysticial yeah I can imagine
that works well if you actually have multiple data streams to process
if not though then you have to be more creative haha
(if I'm understanding it correctly)
 
Typically, I do a block conversion from the raw datatype into the internal datatype.
The internal datatype is 100% SIMD objects.
 
By the way, do you ever run into trouble with embedding SSE data types inside structs? Because I've run into trouble with those before
(in VS 2008)
 
5:15 AM
Here's a bit of the type of programming that I "invented" a few years ago to handle variable SIMD sizes: github.com/Mysticial/Flops/blob/master/version2/source/macros/…
vpma = vector positive multiply-add
vnma = vector negative multiply-add
The intrinsics for them.
@Mehrdad Only when I throw them into STL objects. Obvious because of alignment.
 
@Mysticial oh that's a good point, but that's not what I meant -- I meant even on the stack I had trouble with them
 
Nope. No problems whatsoever.
 
@Mysticial Have you tried it on VS 2008? I think the later versions work fine, but older compilers had issues
 
I stopped caring about older versions of compilers. :)
I don't remember if I even did SIMD back in the VS2008 days.
 
LOL ok
 
5:19 AM
I get held by compilers a lot.
 
yeah..
 
Visual Studio is always behind on picking up the new intrinsics.
Intel Compiler is always behind on language features.
GCC is fine, but I work mostly in Windows.
 
exactly
lol
although I don't have ICC on Windows either
so I have to stick with VS
 
The thing that pissed me off about ICC is that it refuses to produce binaries that will run on non-Intel processors unless AMD has a processor that can run it.
So I can't build a binary that uses auto-generated AVX2 that will run on a future AMD processor.
I had the same problem back when AVX came out.
 
yeahh
I've heard about that
I've never used ICC though, since I've never had access to it
 
5:24 AM
they have Qx:AVX and arch:AVX.
The Qx version only runs on Intel processors.
 
By the way, I had a completely unrelated question I thought you might be a good person to ask
 
The arch version doesn't become available until it is supported by AMD.
@Mehrdad Go ahead.
 
@Mysticial I've made a heap manager that I think beats existing heap managers in some scenarios
and by some scenarios
I mean those scenarios that aren't best-case for typical heap managers
i.e., its average performance is slightly worse, but its worst case performance is much much better (probably asymptotically, though I haven't proven it)
anyway, I was hoping to have people give it a try, but I'm not quite ready to open-source it yet
I was wondering if you had any advice on how to go about it
 
Release a .dll.
 
@Mysticial where? HN? SourceForge?
 
5:27 AM
Good question...
When I released my pi program is was from my personal website.
And it had enough attention to get itself rolling.
Github will let you upload binaries.
So you can make a project with the header file, .lib, and .dll files.
 
@Mysticial I mean it's not quite a hosting issue -- I can find some host easily
but what I meant is I don't know how to make it visible
wherever I host it.
Like how would people find out about it? Show HN?
 
That's sorta what I meant. I'm not sure how you would advertise it.
 
@Mysticial Yeah
 
In my case, the Pi stuff was the publicity grabber itself. So it wasn't really a problem at all.
 
@Mysticial Yeah I can imagine haha
 
5:29 AM
But before that, I started by putting up the fully working and usable benchmark on an overclocking forum.
But in this case, you're somewhat limited to developers only.
 
@Mysticial Yeah
 
It's probably gonna be difficult. Everywhere I see people putting up their projects and nobody seems to care.
There would need to be a really compelling reason for someone to bother.
 
@Mysticial Yeah exactly
 
As in, if you can find a way to demonstrate conclusively that it is much faster than everything else, then maybe.
 
@Mysticial well I can provide benchmarks (I think I had a simple one at some point too), but still, how would I actually initially publicize it?
 
5:35 AM
I have no idea. If you can find a widely used (performance critical) application, switch it to your memory allocator and show that it is much faster, then people might be interested.
 
@Mysticial Hmm ok, thanks.
 
And even then, you might need a publicity stunt to get people to look in the first place.
 
@Mysticial Yeah
 
It's probably gonna be an uphill battle.
 
@Mysticial Yep haha
 
5:36 AM
If you can do it in a competition setting. Win some performance competition with it.
 
@Mysticial Like what kind of competition? Not sure what you have in mind.
 
lol, I'm not aware of any myself.
 
@Mysticial lol ok
 
At the very least, start by building a site for it with the download and benchmarks.
And link it from your various profiles, SO, LinkedIn and such.
 
@Mysticial Yeah I probably will, sounds like a good start
 
5:40 AM
With enough SEO, it'll start showing up in search results.
Especially since you have rep on SO to get rid of the <no follow> thingy.
 
@Mysticial Huh, I didn't even know that was a thing, thanks for pointing that out
 
But don't expect it to happen quickly. It took a good year or so before my pi program started showing up search results for "program to compute pi".
 
@Mysticial Ahh okay good to know
 
I guess part of the reason is because I gave it a shitty name as far as SEO is concerned.
 
@Mysticial lol
 
5:42 AM
Not that I cared. :)
 
@Mysticial Haha :)
 
5:59 AM
@Mysticial Hey, I think I have proof that _mm_loadu_pd isn't the same thing as a regular memory load
(even aligned)
 
oh?
 
Lemme upload an example
@Mysticial pastebin.com/ZMgVPwT6 (grab it soon, expires in 10 mins)
@Mysticial Run it under MSVC 2013, x86, /O2
@Mysticial Then try uncommenting that macro and seeing what the running time is
@Mysticial It should be slightly higher if you uncomment that macro
 
interesting
reproed
 
@Mysticial yay :D
@Mysticial I think the optimizer doesn't like it when SSE types are accessed in memory
 
Looking at the assembly, I would've expected the opposite.
 
6:07 AM
@Mysticial lol
@Mysticial I've learned not to expect anything at this point xD
@Mysticial compilers just aren't as smart as I'd expect them to be
 
It's doing something really silly with the intrinsic. And it's faster.
lol
 
@Mysticial lol
 
Hard to say. There's efficiency of that code is so low that there's free execution slots everywhere.
So extra instructions and memory accesses could easily end up being free.
 
@Mysticial I don't know enough about modern CPU architectures to comment on it from that aspect, but I think it's reasonable that when the compiler has an intrinsic, it's going to be faster than a non-intrinsic approach :-) (as unreasonable as it might be for that particular intrinsic to exist in the first place)
@Mysticial From a compiler standpoint, I think the compiler is getting confused about something (maybe aliasing? not sure)
 
The way you're using it is also very unlike the way that I do it.
 
6:12 AM
@Mysticial Ooh... how would you do it?
 
I don't cast. I just deference with [].
 
@Mysticial You can't avoid casting though...
it's a double*
 
In your case you can't. But in the majority of my use cases, I can.
Since the scalar type isn't even used at all.
That said, I still can't figure out why the uglier intrinsic code is slower.
 
@Mysticial Oh well I mean the only reason I gave you this code was that I already had it sitting around
it wasn't geared toward this particular scenario
it's just the easiest thing I could use as an example
in a different scenario I might code it differently haha
@Mysticial Compiler confusion :)
@Mysticial I'm pretty sure a similar thing happens when you embed an SSE type inside a struct -- and my best guess is that as soon as the address of an SSE type becomes taken, it defeats the aliasing analysis in the compiler somehow
 
Possible.
 
6:16 AM
@Mysticial In any case... myth = busted :-)
@Mysticial Update your answer? =P
 
@Mehrdad I didn't mention anything about direct access vs. intrinsic in my answer.
The casting is a completely separate issue.
 
@Mysticial hmm I guess
 
In your case, the intrinsic version is spilling more registers than the direct access version.
 
@Mysticial Yeah
@Mysticial unintuitive
 
Clearly intrinsics vs. direct has a different effect on the register allocator. lol
btw, you don't need the aligned version.
 
6:22 AM
@Mysticial lol yeah
@Mysticial you mean the unaligned version?
 
All processors since Nehalem will do an access on an aligned address just as fast - regardless of whether the instruction is an aligned or unaligned move.
And since you're using FMA...
 
@Mysticial that doesn't mean the compiler is going to generate the same code for aligned and unaligned moves though. If it's aligned the compiler might generate better code.
@Mysticial Also, side note, but I could swear if I post this code as-is on StackOverflow somewhere, people are going to downvote me for not free'ing the memory correctly, for trying to read uninitialized memory, etc.
 
@Mehrdad You'd have to try it.
But you can get rid of that branch completely.
And only run the unaligned part of the if-statement.
 
@Mysticial Lemme try and see
 
If you were doing 256-bit SIMD, the compiler would issue unaligned access for everything - even if you use an aligned intrinsic.
Both VS2013 and ICC does it.
 
6:26 AM
@Mysticial Yeah I've seen that, and it's annoying lol. I really want the instruction to be correct regardless of the actual speed
 
Same. I want it to crash when it's misaligned. Since it tells me that I have a bug in the code.
You can always try the streaming instructions. :)
 
@Mysticial Also, it turns out if you change align to false && align, the code will actually slow down by 50 milliseconds
(or at least it does for me)
did you try it?
(Make sure it's actually aligned though -- you might need to change the + 1 at the bottom to + 0)
 
It got 20ms faster for me.
 
@Mysticial what?
 
If I comment out the aligned portion.
 
6:28 AM
@Mysticial What CPU do you have?
 
FX-8350
 
I'm on 4700MQ
 
lol
 
@Mysticial that's not even Intel lol
 
:)
The entire AMD Bulldozer line is allergic to branches.
 
6:29 AM
@Mysticial I think what you said regarding unaligned being just as fast (or just as slow?) might apply to AMD but it obviously doesn't apply to Intel (at least not to Haswell...)
@Mysticial lol
 
@Mehrdad It applies to all Intel since Nehalem.
 
@Mysticial I mean I just proved it wrong in front of my eyes lol
 
If the address is aligned, it doesn't matter which load/store you use. It'll be the same speed.
@Mehrdad Then the compiler is probably doing something weird.
 
@Mysticial how would you explain what I just showed you then? it slowed by 50 ms
@Mysticial Yeah that's what I said earlier -- even if the instruction is the same speed, the compiler doesn't necessarily generate the same code for both, so you should still have separate aligned and unaligned code regardless
 
I'm saying that if you took a binary and replaced all the aligned load/stores with unaligned load/stores, it should make no difference in performance on all Intel processors since Nehalem.
That's why Intel says, confirmed by Agner Fog and others.
 
6:31 AM
@Mysticial right but that's impossible in practice lol. all you can do is change the intrinsics in the code which will not necessarily have the same effect :P
@Mysticial Also, why is the Bulldozer so allergic to branches? Isn't that branch ~100% predictable?
 
@Mehrdad I didn't try to read the rest of the code. It's got too many constructs that I'm not used to reading. :)
 
@Mysticial I mean it's only branching on a single Boolean that never changes inside the loop, so it should be 100% predictable
 
It still needs to execute the branch.
no branch > 100% predictable branch
 
@Mysticial I guess
 
I'm sure it's possible to construct a counterexample that exploits some corner case, but for the most part, it holds.
 
6:36 AM
ok
ok well I'm leaving the chat room :) nice talking to you
see ya
 
cya
 

« first day  last day (14 days later) »