• entwine@programming.dev
    link
    fedilink
    arrow-up
    4
    ·
    3 months ago

    This doesn’t appear optimal. The correct way to melt a CPU is to make use of as many functional units as possible in parallel, while avoiding pipeline stalls and cache misses. I’m not a Rust guy, but skimming through the code it seems like the only work it’s doing is some integer math, so it’s not even touching the FPUs. Also I see while running.load(Ordering::SeqCst). Idk if Rust’s memory model is similar to C++, but does that mean it’s using atomic operations? That’s going to create a lot of unnecessary cache coherency traffic that works against the goal of melting. Each thread should have its own counter not shared with other threads, and it should only spawn enough threads for the number of physical cores (not logical cores) on the system, and ideally pin each thread to a single core to prevent the OS from acting like a firefighter.

    The gpu parts I’m not sure about. There’s might be some special consideration required when dealing with integrated graphics though.

    • lad@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months ago

      Yeah, Rust borrows memory model from C++ because it’s already in use and is at least somewhat understandable

  • jasory@programming.dev
    link
    fedilink
    arrow-up
    5
    arrow-down
    2
    ·
    3 months ago

    Any embarrassingly parallel program can max out your CPU. You should probably run some useful problem instead.