frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: Compile the same source for GPUs and CPUs

https://github.com/ThrudTheBarbarian/xc
3•spacedcowboy•1w ago
I'm writing a language called xc and its compiler, xcc for the last 6 months or so (full disclosure: with a lot of help from Claude). I've finally got version 1 (actually v1.0.1) out, for Linux (x86-64 and arm64, including the Pi 5), macOS and Windows.

The idea: you write an ordinary loop, the compiler works out whether it can run in parallel, and it emits both a multi-core CPU version and GPU kernels (MSL, PTX, SPIR-V or WGSL, all generated by xcc itself without needing an SDK installed).

At run time the program measures each block on that machine and keeps the faster placement.

Examples:

- On an M3 Max a Mandelbrot block takes 13.7 ms on all 16 cores and 1.3 ms on the GPU

- On a Ryzen 9955HX's 2-CU integrated Radeon the GPU loses to the 32 CPU threads, so it stays on the CPU.

The compiler also reads plain old C via clang's front end and does the same thing to C loops, with no pragmas. Comparing xcc to OpenMP for both gcc and clang (with the helping hand of "#pragma omp parallel for" gives (times in ms):

                 xcc    gcc+omp  clang+omp
  mandel_deep    371    2170     2231
  mandelbrot     2.45   12.2     12.8
  md5            9.39   16.1     13.4
  md5_mask       8.17   12.1     13.4
  nbody          0.45   1.29     9.92
  perlin         5.87   4.38     7.05
  saxpy          2.26   2.18     2.32
Geometric mean: xcc is 2.1x faster than GCC+OpenMP and 3.0x faster than clang+OpenMP.

All the builds are checked to make sure they give the same result - no point having a benchmark that doesn't produce the same result! xcc has a notable win for nbody, because its vectorisation is better (across bodies) but perlin has been a bit of a bugbear throughout the leading-up-to-v1 timespan.

Platform-specific binary tarballs, the sources, OpenMP versions and method are on the site (linked from github), and there are Phoronix Test Suite profiles if you'd like to run them yourself.

It's only just made v1 so there's a few rough edges: C++ through clang is in-progress (but not official yet), and the Pi 5's GPU is slow. Not sure if that's the Pi or the code yet...

There's more to the language but I don't want this to be an essay! The real, honest-to-$deity cool thing is the automatic parallelising of standard C/xc loops and being able to run that code on the GPU with no boilerplate - "ARC for Algorithms" (what Objective-C's ARC did for memory management), it "just works".

Very keen to get feedback and fix any gaps. I think it's generally useful right now, but it is "v1" - Bug reports welcome as GitHub issues...

Show HN: The Riemann Proof Handbook

https://github.com/tamnd/riemann-handbook
2•tamnd•18m ago•0 comments

Show HN: Zero C# – C# without a runtime or GC

https://onurgumus.github.io/zero-csharp/index.html
147•reverseblade2•14h ago•104 comments

Show HN: Compile the same source for GPUs and CPUs

https://github.com/ThrudTheBarbarian/xc
3•spacedcowboy•1w ago•0 comments

Show HN: An ASCII cell aquarium for your terminal

https://github.com/kborer/cells/
59•kborer•4d ago•22 comments

Show HN: Hikari.ImGui, a pure C# re-implementation of Dear ImGui

https://github.com/LeastActionTech/Hikari.ImGui
2•charm137•2h ago•0 comments

Show HN: Tinnitus frequency finder and audio notch tool

https://trynotched.com/find
221•brianrhea•4d ago•134 comments

Show HN: A modern take on the Go language

https://github.com/telgatech/gpp
2•u89012•2h ago•0 comments

Show HN: Lifetime Black Friday Deals (Mega List)

https://www.blackfridaydeals.directory/black-friday-lifetime-deals
2•bfdd•3h ago•0 comments

Show HN: I made an audio-to-MIDI model 60x more efficient

https://kobi.music/research/dettato
301•hidude562•5d ago•69 comments

Show HN: I made a PS1 style racing game

https://outpostracer.com
27•shash7•16h ago•25 comments

Show HN: Mount your iPhone as a filesystem on Linux over WiFi

https://github.com/Amirjon06/iphone-linux
2•Amirjon_Abd•4h ago•0 comments

Show HN: agent-mcts – Monte Carlo tree search on top of Claude Code

https://github.com/natsu0529/agent-mcts
14•natsu529•16h ago•0 comments

Show HN: OpenComputer – an open source alternative to Devin

https://github.com/diggerhq/opencomputer
118•iacguy•1d ago•36 comments

Show HN: Foolscap – a writing app that reads your book and never writes for you

https://foolscap.works/
128•atugard•2d ago•94 comments

Show HN: Fast deterministic natural language search for OpenStreetMap data

https://hippomaps.ch/?q=cafes+by+the+Limmat+100+m+from+the+lake+in+zurich#map=15.02/47.36708/8.54935
136•vihren•2d ago•45 comments

Show HN: Security Watch – alerts when a new vulnerability affects your stack

https://github.com/ShieldaAI/security-watch
3•VDudaG-A•6h ago•0 comments

Show HN: Hearthen, an app for building and keeping strong relationships

https://hearthenapp.com
3•mamorales•6h ago•1 comments

Show HN: An API for word timestamps from speech, 75% within 20ms

https://quebec.yarn.so
81•jasperstory•4d ago•11 comments

Show HN: Mastra Factory, the open-source software factory we use to build Mastra

156•codekarate•3d ago•44 comments

Show HN: System 1.5 Model – Inkling-2-Mini Decision

https://huggingface.co/eltokh7/inkling-2-mini-decision
3•eltokh7•2h ago•0 comments

Show HN: It's now easy to install Linux on an Android Phone – Android2linux

https://github.com/android2linux/android2linux
4•brazukadev•8h ago•2 comments

Show HN: Open-Source Vulnerability Scanner

https://waffuru.ai/products/pantry
6•ekryski•8h ago•0 comments

Show HN: LZ0 -An asymmetric LZ compressor with ultra minimal, 0-alloc decoder

https://github.com/seb3773/lz0
23•seb3773•2d ago•6 comments

Show HN: Pencil – LLM writes whiteboard lessons as JSON, a browser draws them

https://github.com/VBS2004/pencil
3•VBS2004•11h ago•0 comments

Show HN: A modern reimagining of the Python progresssss bar

https://github.com/minimaxir/psnek
3•minimaxir•12h ago•0 comments

Show HN: Cornhole News – A Hacker News inspired site for news across the Midwest

https://cornholenews.news
237•cornholemedia•2d ago•121 comments

Show HN: Direct weight edits turn a 0.5B model into an expert species classifier

https://andrewxhill.com/frontier-model-weight-edits/
6•andrewxhill•13h ago•1 comments

Show HN: Type Fighter 2

https://typefighter2.com/
149•torumitch•3d ago•72 comments

Show HN: Open-source, real-time object tracking for live video feeds

https://github.com/aryamandarda/tamserve
123•aryaman_darda•5d ago•17 comments

Show HN: Radiotherapy Delivery Demo

https://tps.neuralrad.com
20•coolwulf•1w ago•10 comments