« first day (1653 days earlier)      last day (3292 days later) » 

@LightningRacisinObrit is that what obrit is like?
 
make that your new avatar
 
@orlp yes
@Prismatic ok
 
euphoric
 
I'm only a few days from getting back to my regular nick (fuck was April Fools' day really that long ago????) so I'll do it then
maybe
 
11:07 PM
looooooooooooooooooooooooooooooooooool
> I bet you, you don't know 2+2 - it's 4, it's 4
> Even if you had infinity knifes, I would punch you up into the air like a kite (?(
> Plus Beyonce thinks that I'm cute - It's ok, Beyonce, I think you're cute, too
Literally every single line he drops is absolutely ... epic
 
spent an hour chasing up the registered letter that's status is still 'in transit' 12 days after posting it. Its destination is in the same country, same state.
 
@Columbo is that you?
 
@AlexM. :o
How did you know?
 
I could have hiked to the destination within 12 days
 
guessed
I like this guy
 
11:13 PM
Protip: dramatically kneeling and cursing the heavens hurts like hell.
 
Also increases the chance that you're gonna get hit by a lightning bolt
 
told tax office the trouble with Australian post & was hit by "that's your problem, we probably going to penalise you for late lodgement"
FU australian post
 
@Mysticial do you know if there's a GCC intrinsic for mulq? on MSVC it's _umul128
 
that's the second time - first time was when my parents sent an express letter & it arrived 7-10 days after posting it(I can't remember exactly how long but it was at least a week). They had to fork out US$4000 in tax to the chinese government because there was a deadline on when they could sell their property to some no resident.
 
@orlp There's one for mulx, but not for mulq.
 
11:18 PM
all right
I'll keep my inline assembly then
I'm not great with inline assembly, is this ok with the clobbering and stuff?
            uint64_t h, l;
            asm("mulq %3"
                : "=a"(l),"=d"(h)
                : "a"(a), "rm"(b)
                : "cc");
(a and b are the source variables)
 
Australian post, you piece of shit!
 
@LightningRacisinObrit glad to hear it
 
@orlp Or you can you use unsigned __int128. GCC's MULX intrinsics is just a force inlined function that uses __int128. It relies on the built-in implementation of __int128 and the compiler flags to generate MULX.
 
@Rapptz Such a sad, sad game.
woooooowwww
wtf C++
 
@Xeo That could very well happen, the funny thing is that all major compilers actually implements this because the standard indirectly mandates that it shall work (besides clang and the noexcept-bug, but that is not too important in upcoming posts)
but I mean, I surely believe that it was unintentional - just like TMP was back in the days, unless there actually is a troll in the committee (or perhaps the NSA!?)
my bet is the NSA, trying to spy on those constant-expressions
 
11:28 PM
@Mysticial seems they are indeed identical coliru.stacked-crooked.com/a/e9d420b9996890fd
@Mysticial this has the added benefit of that MSVC also supports __int128, right?
 
@orlp No it doesn't.
 
lol you said "benefit" and "MSVC" in the same sentence
 
I have my own set of compiler-specific files for 128-bit multiply in my pi program.
3 of them, MSVC, GCC, and ICC - all with different implementations.
 
@Mysticial do you also have 128 / 64 -> 64 division?
 
@orlp Nope.
Fortunately, I don't need it anywhere performance critical.
 
11:30 PM
I need it for montgomery calculation
need to compute 2^64 * a mod n
 
@orlp I have something similar in one of my Github repos. But it's part of two-step process and is not efficient.
 
I have a GCC implementation
literally mulq -> divq in inline assembly
 
Hmm
 
If you precompute 2^128 / n, then you can 2^64 * a mod n efficiently.
 
@Mysticial n varies
 
11:34 PM
That's what my implementation does since it uses the same n with many different a.
@orlp Then you're fucked. :)
 
well, the fun part is
with montgomery multiplication I only need to compute it once
per factorization
@Mysticial since your y-cruncher is closed source, would you mind sharing just your intrinsics implementation for mulq?
 
@orlp It's nothing, special. I could possibly inline it here without pissing off the other regulars:
YM_FORCE_INLINE void Mul(u64_t& L,u64_t& H,u64_t A,u64_t B){
    L = _umul128(A,B,&H);
}
^^ MSVC 64-bit
YM_FORCE_INLINE void Mul(u64_t& L,u64_t& H,u64_t A,u64_t B){
    L = _mulx_u64(A,B,&H);
}
^^ All compilers - x64 BMI2/MULX
YM_FORCE_INLINE void Mul(u64_t& L,u64_t& H,u64_t A,u64_t B){
    unsigned __int128 temp = (unsigned __int128)A * B;
    L = (u64_t)temp;
    H = (u64_t)(temp >> 64);
}
 
wait, what's the difference between mulq and mulx?
 
^^ GCC 64-bit
mulx is new. It's only in Haswell.
I have a 4th one using only standard C++. That one's long so I won't post it.
 
I'm really interested in that one
I still need a fallback
 
11:39 PM
Oh fuck it...
 
Oo, my fault. I am the dumb one :'( ... double check the record, apparently both registered letters are delivered. One confirmed by the recipent, one's status were 'delivered' on the tracking system (albeit it took 8 days for the same state delivery). Why do I kept on thinking the one with status 'in transit' is the one not received by the recipent?
 
if you don't want to share you're of course under no obligation to do so
 
YM_FORCE_INLINE void Mul(u64_t& L,u64_t& H,u64_t A,u64_t B){
    u32_t AL = (u32_t)A;
    u32_t BL = (u32_t)B;
    u32_t AH = (u32_t)(A >> 32);
    u32_t BH = (u32_t)(B >> 32);

    u64_t r0,r1;

    L  = (u64_t)AL * BL;
    r0 = (u64_t)AH * BL;
    r1 = (u64_t)AL * BH;
    H  = (u64_t)AH * BH;

    r0 += L >> 32;
    L  &= 0xffffffff;

    r1 += r0 & 0xffffffff;
    L  |= r1 << 32;
    H  += r0 >> 32;
    H  += r1 >> 32;
}
Shit, it doesn't collapse?
 
thanks a ton
 
The ones that are more interesting are the mul+add intrinsics.
{L,H} = A * B + C
As well as: {L,H} = A * B + C + D
Those I need much more often than the plain mul.
 
11:46 PM
is it worth optimizing for that? the mul + add is only one 64-bit add away from just mul, no?
 
@orlp You need to carry through the upper word.
 
@orlp Well, after much discussing and much googling we decided to hitchhike to Amsterdam.
 
@R.MartinhoFernandes when?
@Mysticial I'm confused, can you specify the widths of L, H, A, B and C?
 
In assembly it'll be something like:
mul rdx
add rax, r8
adc rdx, r9
@orlp All 64-bit.
 
@orlp Departure Wednesday.
 
11:48 PM
A * B + C + D into a 128-bit integer
 
@R.MartinhoFernandes if you came tomorrow you could experience koningsdag :P
@Mysticial ah
 
@orlp Can't leave before Wednesday. Tuesday is my birthday and I invited some 20 people to it.
 
@R.MartinhoFernandes all right
@Mysticial there's one place in my code where I'm struggling with carries
 
@orlp There's a new intrinsic for carries. MSVC and ICC have it. GCC doesn't.
 
@AndyProwl What. The. Fuck.
 
But in GCC, you have __int128. So you kinda don't need it.
 
Here she is! :) @TeslaMotors http://t.co/LPiWuhNYsN
 
Though I have evidence to show that using GCC's __int128 is slower than manually using mul128 and add-with-carry intrinsics.
 
intrinsics are such a mess :(
 
Supposedly GCC is going to get that add-with-carry intrinsic. I saw a patch somewhere, but I have no idea whether it even made it into trunk let alone a release branch.
 
11:55 PM
every compiler uses its own system
and then they inconsistently copy from eachother
 
I have no idea what you're talking about.
 
The only thing they are all consistent with are the SSE/AVX intrinsics.
 
@LightningRacisinObrit compiler intrinsics
 
It's a mysticialery.
 
Which fortunately for me, is what I care about the most.
 
11:56 PM
@orlp Yeah I can read the words I just don't know what they mean.
I've heard them before but I still don't know what they mean.
To be clear, I'm not saying that I care...
 
@LightningRacisinObrit the C++ type system is incapable of representing all operations your CPU can do efficiently
 
But yeah, even shit like bitscan instructions are totally different on every fucking compiler.
 
Could I ask something something about the complexity of an algorithm?
I wanted to know if there is a tighter bound for the modified dfs algorithm: http://stackoverflow.com/questions/29871890/time-complexity-of-modified-dfs-algorithm
so that the time complexity is linear
 
@LightningRacisinObrit one example is multiplying two 64-bit quantities into a 128-bit quantity
@LightningRacisinObrit there is no way to do that in C++, but your x64 CPU can do that perfectly fine, very fast, using one instruction
 
The other example is asking the CPU to fuck off. You can't do that in standard C++.
2
 
11:57 PM
@LightningRacisinObrit intrinsic functions expose that functionality, for example through a function call _umul128.
 
another example is finding the lowest/highest set bit of an integer
 
So optimisation-related compiler extensions.
 
that operation makes soooo many bit twiddling algorithms fast, it's not even funny
 
Good night I guess (inb4 "eww")
 
11:58 PM
y u no have eaten it
 
@Mysticial fun fact, I use __builtin_ctzll to compute gcd
 
@Jefffrey Isn't that what they call the "double-bypass burger" from the Heart Attack Grill?
 
@Mysticial LOL
 
@Jefffrey ew
 

« first day (1653 days earlier)      last day (3292 days later) »