# Ray Tracing in a week-end - Julia vs SIMD-optimized C++

**URL:** <https://discourse.julialang.org/t/ray-tracing-in-a-week-end-julia-vs-simd-optimized-c/72958>\
**Category:** Performance\
**Tags:** gpu, graphics, benchmark, pluto, staticarrays\
**Created:** [December 11, 2021, 11:58pm UTC](https://discourse.julialang.org/t/ray-tracing-in-a-week-end-julia-vs-simd-optimized-c/72958 "2021-12-11T23:58:13Z")\
**Posts on this page:** 1\
**Showing post:** 72

<div class="post-metadata">

**Author:** ![lawless-m](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lawless-m/32/30869_2.png) [@lawless-m](https://discourse.julialang.org/u/lawless-m)\
**Post date:** [February 2, 2022, 7:09pm UTC](https://discourse.julialang.org/t/ray-tracing-in-a-week-end-julia-vs-simd-optimized-c/72958/72 "2022-02-02T19:09:50Z")

</div>

my link had a typo, an admin fixed it but it broke the link 🙂

> [@I translated Peter Shirley's Raytracer to Julia. C++ 1min -\> Julia 2m30s -\> 15s (@threads)](https://discourse.julialang.org/t/i-translated-peter-shirleys-raytracer-to-julia-c-9mins-julia-2m30s-15s-threads/75671):
>
> Hi, I like raytracing and there are a nice set of books [https://github.com/RayTracing/raytracing.github.io](https://github.com/RayTracing/raytracing.github.io) so now I’m a bit better at Julia, I transcoded the C++ into Julia and got some nice speedups. The single threaded version went from 9m in C++ to 2m30 in Julia (with no tricks - I don’t know any!) (The C++ had no compiler flags, after using -O 3 and -march=native it was down to about 1 minute) And when I added Threads (40 of them slight_smile )I got it down to 15s, including compilat…

I had bad C++ compiler flags and that version now runs in about 1 minute, not 9

So my single threaded Julia, at 2m30s is now not so good as I thought.

but the code is well suited to multi-threading

10 threads at 27s real and 20 threads take 17s real and 40 threads (my max) take 15s real - so clearly it is not a linear speedup.

```julia
julia> versioninfo()
Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, haswell)
Environment:
  JULIA_CPU_THREADS = 40
  JULIA_NUM_THREADS = 40

```

It has two physical CPUs

---

_[View the full topic](https://discourse.julialang.org/t/ray-tracing-in-a-week-end-julia-vs-simd-optimized-c/72958)._
