← All projects
Project record1 mention
Originally shared on Hacker News

xc

xc is a programming language, with its compiler xcc, that compiles the same source for GPUs and CPUs: 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), generated by xcc without needing an SDK installed. At run time the program measures each block on that machine and keeps the faster placement. The compiler also reads plain C via clang's front end and does the same thing to C loops with no pragmas. Version 1.0.1 is out for Linux (x86-64 and arm64, including the Pi 5), macOS and Windows.

Last shared
01 / The problem

What it addresses

Running the same code on GPUs normally requires separate code paths, installed SDKs and boilerplate; xc instead parallelises ordinary C/xc loops automatically and runs them on whichever of CPU or GPU is faster on that machine.

02 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. xc

    xc is a programming language, with its compiler xcc, that compiles the same source for GPUs and CPUs: 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), generated by xcc without needing an SDK installed. At run time the program measures each block on that machine and keeps the faster placement. The compiler also reads plain C via clang's front end and does the same thing to C loops with no pragmas. Version 1.0.1 is out for Linux (x86-64 and arm64, including the Pi 5), macOS and Windows.

    Problem: Running the same code on GPUs normally requires separate code paths, installed SDKs and boilerplate; xc instead parallelises ordinary C/xc loops automatically and runs them on whichever of CPU or GPU is faster on that machine.

    Posted by @spacedcowboy · Original source ↗

    Story title · @spacedcowboy · · Source ↗

    Show HN: "xc", Compile the same source for GPUs and CPUs

    Submitted URL · @spacedcowboy · · Source ↗

    https://github.com/ThrudTheBarbarian/xc

    Source text · @spacedcowboy · · Source ↗

    I'm writing a language called xc and its compiler, xcc for the last 6 months or so

    Source text · @spacedcowboy · · Source ↗

    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)

    Source text · @spacedcowboy · · Source ↗

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

    Source text · @spacedcowboy · · Source ↗

    The compiler also reads plain old C via clang's front end and does the same thing to C loops, with no pragmas.

    Source text · @spacedcowboy · · Source ↗

    I've finally got version 1 (actually v1.0.1) out, for Linux (x86-64 and arm64, including the Pi 5), macOS and Windows.

    Source text · @spacedcowboy · · Source ↗

    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