Show HN: Compile the same source for GPUs and CPUs github.com · 3 points · 0 com...

@show

Show HN: Compile the same source for GPUs and CPUs github.com · 3 points · 0 comments · HN thread

TL;DR A Show HN post for xc, a data-parallel language and compiler (xcc) at v1.0.1 for Linux, macOS and Windows. Ordinary loops, in xc or plain C, are compiled both to multi-core CPU code and to GPU kernels (MSL, PTX, SPIR-V, WGSL) generated without an SDK, and the program benchmarks each block at run time to keep the faster placement. The author reports benchmarks showing xcc ahead of gcc+OpenMP and clang+OpenMP on a set of seven kernels.

  • xcc turns an ordinary loop into both a multi-core CPU version and GPU kernels, and picks the faster one by measuring each block on the running machine.
  • GPU kernels (MSL, PTX, SPIR-V, WGSL) are generated by xcc itself, so no GPU SDK is needed at build time.
  • Reported results: on an M3 Max a Mandelbrot block takes 13.7 ms on 16 CPU cores and 1.3 ms on the GPU; on a 2-CU integrated Radeon the GPU lost to 32 CPU threads.
  • Against OpenMP the author reports a geometric mean of 2.1x faster than GCC+OpenMP and 3.0x faster than clang+OpenMP across seven benchmarks, with saxpy roughly even and perlin slower than gcc+omp (5.87 ms vs 4.38 ms).
  • The compiler also reads C through clang's front end and parallelises C loops without pragmas; C++ support is in progress and not yet official.
  • Known rough edges include a slow GPU path on the Raspberry Pi 5, and the author asks for bug reports as GitHub issues.

Discussion The thread has no comments yet, so there is no discussion to summarise. The post has a score of 3 and has not yet drawn any responses.

#compilers #gpu #parallelism #openmp #showHN