Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
mtklein
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
7 ms
·
31.
▲
by
mtklein
1y ago
I found this especially nice working with large SIMD constants.
32.
▲
by
mtklein
1y ago
Okay, I'll bite: 2 and 5 are prime, this is the perfect fifth problem, only approximate solutions are possible. Make me wrong!
33.
▲
by
mtklein
1y ago
I completely agree that technology in the last couple years has genuinely been fulfilling the promise established in my childhood sci-fi. The other day, alone in a city I'd never been to before, I snapped a photo of a bistro's dai
34.
▲
by
mtklein
1y ago
My preferred way to compare floats as being interchangeably equivalent in unit tests is bool equiv(float x, float y) { return (x <= y && y <= x) || (x != x && y != y); } This handles th
35.
▲
by
mtklein
1y ago
Ah, I can confirm what I see elsewhere in the thread, this is no longer true in Clang. That first clang was Apple Clang 17---who knows what version that actually is---and here is Clang 20: $ /opt/homebrew/opt/llvm
36.
▲
by
mtklein
1y ago
I have always thought that punning through a union was legal in C but UB in C++, and that punning through incompatible pointer casting was UB in both. I am basing this entirely on memory and the wikipedia article on type punning. I welcome
37.
▲
by
mtklein
1y ago
This was my instinct too, until I got this little tickle in the back of my head that maybe I remembered that Clang was already acting like this, so maybe it won't be so bad. Notice 32-bit wzr vs 64-bit xzr: $ cat union.c &&a
38.
▲
by
mtklein
1y ago
"The peer malus" - Frederic Beal
39.
▲
by
mtklein
2y ago
It hadn't yet been at the time this program was in practice. I wager the enthusiasm for nudging was probably around its peak at the time we're talking, somewhere early 2010s?
40.
▲
by
mtklein
2y ago
The idiom I am familiar with here is to make the constructor private and provide a public static factory method that allocates on the heap.
41.
▲
by
mtklein
2y ago
It can be fun to explore the interactions of unorm and float bit representations even when you have float instructions. E.g. if you bit-or a unorm8 into 0x47000000 (32768.0f) then subtract 32768.0f, you'll get a number very close to r
42.
▲
by
mtklein
2y ago
Looks a little more like std::bit_cast? (Of course, there's a large overlap between the two.)
43.
▲
by
mtklein
2y ago
I'd suggest working incrementally from areas of your existing strength. Tweak whatever code base you are most familiar with, starting with a tiny change, and see how the assembly changes. I use objdump -d and git diff --no-index for
44.
▲
by
mtklein
3y ago
I could have been more precise when I said it's easy to fool yourself into thinking you know _any_ language better than you do... both rustc and ghc have made it abundantly and repeatedly clear that I don't know Rust and Haskell w
45.
▲
by
mtklein
3y ago
I think this is actually one of the selling points of C over other languages. Certainly it's easy to fool yourself into thinking you know any language better than you do, but C genuinely is relatively tiny, and I think it's reaso
46.
▲
by
mtklein
3y ago
Looking at the GPU tech used and the committer names in that repo, I'm pretty confident this will at very least compete with both Skia and Pathfinder. I'm not super familiar with Vello. These are solid tech choices by people who
47.
▲
by
mtklein
3y ago
One bit I find easy to lose sight of is that if I do spend my day cultivating wheat for flour for a cake, to make sure to eventually make and eat that cake, and not just spend all my time getting better at cultivating more and more wheat.
48.
▲
by
mtklein
3y ago
Might try Simulacron-3.
49.
▲
by
mtklein
3y ago
On the topic of finding Bayes' theorem intuitively, I can never remember it on its own, but starting from the joint probability P(A,B) for any arbitrary A and B always helps me: // A and B are arbitrary. P(A,B) = P(
50.
▲
by
mtklein
3y ago
I agree that (void)bla is desirably clear, pithy and unambiguous. And I like something like this if I'm dealing with functions with more than a couple unused parameters: static void unused_(int x, ...) { (void)x; } #define u
51.
▲
by
mtklein
3y ago
If you've got control over the type of the pointee and not just the pointer, __attribute__((packed)) can work for this. struct foo { int x; }; struct bar { __attribute__((packed)) int x; }; _Stati
52.
▲
by
mtklein
3y ago
Ordinarily you're at the whim of the optimizer whether calls in tail position are made in a way that grows the stack or keeps it constant. musttail guarantees that those calls can and are made in a way that does not let the stack grow
53.
▲
by
mtklein
3y ago
My only major objection to C++ magic statics is that you can only use them for statics. Sometimes you find yourself with a task that needs to be done once per object instead of globally, and you've got to roll your own, and then you m
54.
▲
by
mtklein
3y ago
Valgrind is like all the sanitizers (memory, thread, leak, address, undefined) all together, plus performance and memory profilers, all for uninstrumented code. For me the real key is the last part. If you're happy building and testin
55.
▲
by
mtklein
3y ago
Hey dude, I was in your class, and I can say firsthand that you deserved to be there like any of us. Almost everyone at a place like MIT feels some impostor syndrome, and I think maybe even for good bogus-mathematical-theorem reasons: if a
56.
▲
by
mtklein
3y ago
Oh! Yeah! I do forget about “base” avx-512 sometimes. No one but HPC folks really ever had any proximity to that. In practice if you’ve got a computer that supports avx-512, it supports VL.
57.
▲
by
mtklein
3y ago
The promise of the AVX-512 instruction set really was that it would be much easier to (auto-)vectorize code that wasn’t written with vectorization in mind, with tools like masked execution and gather/scatter that either didn’t exist at
58.
▲
by
mtklein
3y ago
IIRC what you’re describing here is indeed what shipped. All the AVX-512 instructions are available for 128-bit, 256-bit and 512-bit registers (xmm, ymm, zmm). If not strictly all, essentially all?
59.
▲
by
mtklein
3y ago
14 or 15 year Reddit user, mostly as a lurker -- I strongly support this. Reddit is a community, and a community is its people.
60.
▲
by
mtklein
3y ago
I love seeing this instruction pop up in disassembly. I've seen it come up when growing a dynamic array, with some C code like... if (is_pow2_or_zero(len)) { int grown = len ? len*2 : 1; ptr = realloc(ptr, (size
More ›