Files
Threadwell/archive/threads/NOTimothyLottes/2024-11-16-0-what-a-horrible-term-printf-debugging/2024-11-16-static_assert_0-this-is-super-cool-but-why-map-a-file-and-not.md
T
2026-08-25 16:26:52 -04:00

1.9 KiB

title, type, source, source_url, author, handle, post_id, date, archived, draft, tags, description, in_reply_to, parent_post_id
title type source source_url author handle post_id date archived draft tags description in_reply_to parent_post_id
@NOTimothyLottes This is super cool, but why map a file and not just stdout? archive twitter https://x.com/static_assert_0/status/1857867668289663108 static_assert(false) static_assert_0 1857867668289663108 2024-11-16 2026-08-25 false
archive
twitter
NOTimothyLottes
@NOTimothyLottes This is super cool, but why map a file and not just stdout? 1857803914604618029

Source

Branch

1/ @static_assert_0 ^1857867668289663108

@NOTimothyLottes

This is super cool, but why map a file and not just stdout?

2/ @vodangkhoa873 ^1857882178463608868

@static_assert_0 @NOTimothyLottes

The writes can be done concurrently from many threads?

3/ @NOTimothyLottes ^1857884114403340408

@vodangkhoa873 @static_assert_0

Yes, one 'atomicAdd(atomAdr,1)&65535' to get the line number (window of 65536 max lines) then write the line individually. Only contention is on that atomicAdd CPU instruction which is as minimal as possible.

I do the atomic add instruction using simple inline ASM (below)

4/ @static_assert_0 ^1857885819274453195

@NOTimothyLottes @vodangkhoa873

I love this, but are you not able to get that codegen with intrinsics or just normal C?

5/ @NOTimothyLottes ^1857887943261827446

@static_assert_0 @vodangkhoa873

I've been hand rolling intrinsics CPU-side in GCC with inline asm since the dawn of support for that. So haven't kept up with the high-level-lang mess fire since.