HNHacker News
TopNewBestAskShowJobs

TinkersW

680 karma · joined May 19, 2020

submissionscomments
TinkersW··on We Can Terraform the American West
This might shock you, but we aren't the only species on the planet.

We cannot consume every piece of the planet and leave nothing for other species, and there are already far more of us than necessary.

TinkersW··on We Can Terraform the American West
Article assumes people want to live in cramped cities.. clearly this is not the case when we look at where Americans choose to live, so premise is flawed. In reality 300 more Americans would spread out and wreck the environment more than it already is.
TinkersW··on Why those particular integer multiplies?
SSE2 is a requirement for x86-64, which gives at least a reasonable(128bit wide SIMD) baseline.

SSE4 is from 2008, so making it a requirement isn't unreasonable.

Even AVX2 is from 2013, so some apps require it nowadays.

It is extremely difficult for a compiler to convert scalar code to SIMD automatically, even static C++ compilers really suck at it.

A dynamic compiler for javascript would have no real hope of any meaningful gains.

TinkersW··on Why Safety Profiles Failed
It seems to me that it would handle the sort case fine, you would read/write an invalid page and it would fall over(assuming all allocations had invalid pages at the end of the allocation & no 2 allocations share a page).

The strlen could be made safe by having the malloc return the address 100 bytes before the end of the page. If it did make it to the end of the 100 bytes it would fall over safely. Result would be nonsense of course. Of course if you read bytes < than the returned ptr you would have 4k-100 bytes before it fails on bad page.

TinkersW··on Zero or Sign Extend
Shifts run on less ports than xor/sub, so should be avoided if possible when performance is important, especially when using SIMD where the shifts are often quite subpar.
TinkersW··on Ireland's big school secret: how a year off-curriculum changes teenage lives
I very much found it to be a cage.
TinkersW··on Rebooting the Arsenal of Democracy
Countries don't always behave logically, see Russia & the self defeating war in Ukraine.
TinkersW··on Diffusion for World Modeling
It requires a monster GPU to run 10 fps at what looks like sub 720p... I think it may be abit more than 5 years..
TinkersW··on Initial CUDA Performance Lessons
CPU numbers are off, as FMA is considered 2 instructions, and Zen5 can do 2 of them per cycle in addition to two adds, so it would be 6 instructions per cycle not 4(GPU numbers are always quoted this way, so it is only fair to do the same for the CPU).

Also the 9950x has 32 threads, but is hyperthreaded, so it only has 16 actual cores, so the correct scaling factor is 16 cores * 16 SIMD lanes. Anyway the final number is 8.678 32 bit float TFLOPS.

The RTX 4090 has 82.58 32 bit TFLOPS according to Nvidia, but it also costs far more than the 9950x($1,600 vs $650), so I find this comparison rather odd.

So it costs 2.46 as much and delivers 9.5x the perf.

If you normalize for cost the perf advantage is about 3.8x, which is roughly the same numbers Intel reported years ago when they debunked the whole GPU is 100x better nonsense.

Anyway, I really hate the Cuda terminology where they refer to SIMD lanes as "threads".

There are also alot of the things to consider, where either the CPU or GPU has an advantage such as..

GPU advantages:

Hardware sin/cos support(with Nivida at least)

abs/saturate are often just modifiers

scaling by small powers of 2 is often free

16bit floats are fully supported

CPU advantages:

doubles are full speed and you can interleave with floats if you just need for a few calculations

access to wide variety of integer sizes and bit manipulation functions, GPU has some of this but not nearly as broad

lower level programing model

TinkersW··on Germans decry influence of English as 'idiot's apostrophe' gets approval
Uno isn't a number in english though, and you wouldn't capitalize a number, so treating it as a name seems reasonable.
TinkersW··on Rust GPU: The future of GPU programming
It was 17 seconds for 1 shader file.

Iterative C++ compile times can be very fast if you know what are you doing, 17 seconds is very long unless you have link time optimizations on(which makes no sense for an iterative build).

TinkersW··on Modifications to GPU Hardware to Benefit Signed Distance Fields
OpenVDB is high level description for voxel data, not a compressed format that GPU hardware supports.
TinkersW··on Modifications to GPU Hardware to Benefit Signed Distance Fields
Ya it does, but desktop GPUs don't support ASTC(or if they do it isn't exposed)
TinkersW··on Modifications to GPU Hardware to Benefit Signed Distance Fields
An actual 3D block based format would be useful, currently on PC at least the only formats are for 2D textures. They do work for 3D textures, but in 2D slices so the result is not as good as it could be. Also the only 1 channel format is BC4 which is .5 byte per entry, and has 2 encodings modes, but the 2nd one is mostly useless for an SDF, so that is a waste.

I'd prefer a 1 per byte entry option for higher detail, no need for any fancy modes, needs to be simply and fast to encode so it can be done realtime.

IDK about this post though, separating the block min/max into a separate memory location from the indices doesn't make much sense, you could just access a less detailed mip if that is what you want.

TinkersW··on The Fastest Mutexes
The post doesn't include any benchmarks for the uncontended case, where I've found SRWLock is also very fast, I'm curious why this wasn't included.

At least for what I use locks for, the uncontended case is like 10000x more common, I actually don't think I have any super heavy contention such as the case shown in the post, as this is simply something to be avoided--as no no matter how good the mutex this won't play well with the memory system.

TinkersW··on The Fastest Mutexes
Maybe they weren't using SRWLock, at least last time I checked std::mutex didn't use it with MS STL(They were stuck with critical section because of binary compatibility).
TinkersW··on Building a compile-time SIMD optimized smoothing filter
I only clicked through the slides and didn't watch the video..but ugh all I see is scalar SIMD in the assembly output(the ss ending means scalar, it would be ps if it was vector)

And they are apparently relying on the compiler to generate it...just no.

Use intrinsics, it ant that hard.

TinkersW··on Californian Cities Facing $50K Monthly Fines for Blocking New Homes
CA doesn't need more houses, it needs less people
TinkersW··on Coffee Stats – Maximize Caffeine Intake and Get to Bed at Night
Hum I sometimes just don't drink coffee for a week or whatever, and never noticed any symptoms
TinkersW··on Linus Torvalds muses about maintainer gray hairs and the next 'King of Linux'
Yah I'm sure the African pycon was planning to ask every attendee if they are LGBT...

You do know this kind of thing has zero to do with Python? Nobody is having sex at pycon? They can just do what everyone else does, and not make that the most important thing in the world while at the stupid convention.

Like personally I think logging should end, so can I just make this position a requirement that everyone else has to agree with to attend Pycon? It makes no sense, as it isn't related to the topic of the convention. I think that is why it gets labeled as an ideology.

TinkersW··on Exploring the scalable matrix extension of the Apple M4 processor
What? The article says this thing does 2005 GFOPs, aka 2 TFLOPS, which is decent, but we have had CPUs that could do more than this for a long time now. My Zen2 12 core does about 3 TFLOPs, and a modern 16 core Zen5 can do 8-10 TFLOPS(I'm unsure what clock speed it can maintain with all cores engaged). And that is generally purpose SIMD not specialized matrix stuff(less generally useful).

Apple CPU's kinda suck at vector ops, but they aren't that bad, this thing is only mildly better. I would guess power savings is a big part of why they use this SVE streaming matrix mode.

TinkersW··on UE5 Nanite in WebGPU
A couple reasons

1. HW does 2x2 blocks of pixels always so it can have derivatives, even if you don't use them..

2. Accessing SV_PrimitiveID is surprisingly slow on Nvidia/AMD, by writing it out in the PS you will take a huge perf hit in HW. There are ways to work around this, but they aren't trivial and differ between vendors, and you have to be aware of the issue it in the first place! I think some of the "software" > "hardware" raster stuff may come from this.

The HW shader in this demo looks wonky though, it should be writing out the visibility buffer, and instead it is writing out a vec4 with color data, so of course that is going to hurt perf. Way too many varyings being passed down also.

In a high triangle HW rasterizer you want the visibility buffer PS do a little compute as possible, and write as little as possible, so it should only have 1 or 2 input varyings and simply writes them out.

TinkersW··on SDL3 new GPU API merged
WebGPU would be alot more useful if it hadn't gone with such a needlessly different shader language syntax, makes it much harder to have any single src between the C++ and it.
TinkersW··on Starliner Is Such a Disaster That Boeing May Cancel the Entire Project
Boeing isn't in a learning phase... more of a how much can we underpay our employees and how many cheap subtractors can we get away with phase. Also starliner would not be "nominally" second best, but truly second, or perhaps third best if other options come around(dreamchaser).

Musk may be huffing the right wing nonsense too much, but I don't know if he has actually done anything anti-american(though supporting someone as obviously corrupt as Trump could be considered so I suppose), much of the headlines about him appear to be clickbait nonsense.

SpaceX can't do jack shit without Gov approval, so it wouldn't really matter if they had ulterior motives.

TinkersW··on Clay (short for C Layout) is a high performance 2D UI layout library
Lots of other issues also such as page up/page down on keyboard not working and mouse scroll wheel is very slow(it behaves as if acceleration is turned off).
TinkersW··on SIMD Matters: Graph Coloring
You can often find them by search stack overflow(try AVX2 + (deinterleave/AoS to SoA/transpose etc), especially any answers by Peter Cordes.

You can write them yourself also but I'd add a verifier that checks the output with scalar code as it can be tricky to get correct.

Intel had an article up for the 3x8 transpose, but it seems to no longer exist so i'll just post the psuedo code

   //xyz -> xxx 
 void swizzle3_AoS_to_SoA(v8float &x, v8float &y, v8float &z) {
  v8float m14 = interleave_low_high<1, 2>(x, z); //swap low/high 128 bits
  v8float m03 = blend<0, 0, 0, 0, 1, 1, 1, 1>(x, y); //_mm256_blend_ps 1 cycle
  v8float m25 = blend<0, 0, 0, 0, 1, 1, 1, 1>(y, z);

  //shuffles are all 1 cycle
  __m256 xy = _mm256_shuffle_ps(m14, m25, _MM_SHUFFLE(2, 1, 3, 2)); // upper x's and y's 
  __m256 yz = _mm256_shuffle_ps(m03, m14, _MM_SHUFFLE(1, 0, 2, 1)); // lower y's and z's
  v8float xo = _mm256_shuffle_ps(m03, xy, _MM_SHUFFLE(2, 0, 3, 0));
  v8float yo = _mm256_shuffle_ps(yz, xy, _MM_SHUFFLE(3, 1, 2, 0));
  v8float zo = _mm256_shuffle_ps(yz, m25, _MM_SHUFFLE(3, 0, 3, 1));
  x = xo;
  y = yo;
  z = zo;

 }
TinkersW··on Bit Twiddling Hacks (2009)
Tricks that work on floating point are sometimes useful and not listed there..

   Make float sortable as integer. (the reason you might wish to do this is that integer comparisons are faster and run on more ports, also you won't get unsortable data from NAN). You can undo the transform by calling this fxn again. You only need this with a mix of positive/negative floats, if they are all positive you can skip this.
int i = cast_int(f); shift_right_sign_bits(i, 31) & 0x7FFFFFFF) ^ i

   Scale float by powers of 2
Cast a float to integer and add 0x00800000 * N(N being the power of 2). Subtract to divide. Fails with 0 value float.

Not super useful unless you already have the float in the integer domain for some other reason, also integer adds/subs run on more ports and are 1 cycle.

   The fast sqrt function is well known but you can do this for other powers of 2
//An approximate pow(a, 1/4) float fastPow_1_4(float a) { return asfloat((asuint(a) >> 2u) + 798700996u); }

//An approximate pow(a, 1/8) float fastPow_1_8(float a) { return asfloat((asuint(a) >> 3u) + 931853847u); }

//An approximate pow(a, 1/16) float fastPow_1_16(float a) { return asfloat((asuint(a) >> 4u) + 998350438u); }

//An approximate pow(a, 1/32) float fastPow_1_32(float a) { return asfloat((asuint(a) >> 5u) + 1031705320u); }

They are very low accuracy as they don't have a newton raphson step, and were just intended for stuff like graphics where accuracy isn't always important.

TinkersW··on SIMD Matters: Graph Coloring
Basically everything you said was wrong..

   The other problem with simd is that in modern cpu-centric languages it often requires a rewrite for every vector width.
Nope, you can use many existing libraries that present the same interface for all sizes, or write your own(which is what I did).

   And for 80% of the cases by the point there is enough vectorizable data for a programmer to look into simd, a gpu can provide 1000%+ of perf AND a certain level of portability.
Transfer latency & bandwidth to GPU is horrible, just utterly horrible. And GPU to CPU perf dif is more like 5x, and in games etc the GPU is already nearly maxed out

   And it also takes a lot of space on your cpu die. Like, A LOT.
Relative to the performance it can offer it is a very small area. The gains in the article are small compared to what I see, probably the author is new to SIMD.*
TinkersW··on SIMD Matters: Graph Coloring
Gather is still terrible, the only core that handles it well is the Intel's P core. AMD issues 40+ micro ops in AVX2(80 in AVX512), and the Intel E core is much worse.

When using SIMD you must either use SoA or AoSoA for optimal performance. You can sometimes use AoS if you have a special hand coded swizzle loader for the format.

TinkersW··on Ladybird browser to start using Swift language this fall
Swift/C++/Zig all have the exact same level of memory safety, but anyone they said they aren't porting, sounds more like writing new stuff in Swift and hoping the interop story is good enough.
← PreviousPage 6 of 13Next →