Skip to content

Multi-thread support for simulator #632

Open

Description

@Readm

Is there any multi-threading support for the simulator?
I mean the multi-threading on the host to accelerate the simulation, intuitively, the core/cache/ddr can operate in parallel.

For example, can i use 4 cores to simulate core/l2/l3/ddr each? and speedup 4x?

Activity

  1. ngober commented on Jun 3, 2025

    @ngober
    Collaborator

    There is no support for multi-threaded hosting. I put a lot of effort into logically isolating components, they are typically only connected by queues. So, if someone wanted to take on that project, I would be supportive.

  2. Readm commented on Jun 4, 2025

    @Readm
    Author
  3. Readm commented on Jun 4, 2025

    @Readm
    Author

    I have a simply use a thread pool to parallelized the operables, Found it slowed down. And I found each operable (cache) only takes 2 us to operate, thus thread pool is not worth it. Sad.

  4. Readm commented on Jun 4, 2025

    @Readm
    Author

    @ngober is champsim deterministic?I saw code here. what if they have same current_time?

    long do_cycle(environment& env, std::vector<tracereader>& traces, std::vector<std::size_t> trace_index, champsim::chrono::clock& global_clock)
    {
      auto operables = env.operable_view();
      std::sort(std::begin(operables), std::end(operables),
                [](const champsim::operable& lhs, const champsim::operable& rhs) { return lhs.current_time < rhs.current_time; });
    
      // Operate
      long progress{0};
      for (champsim::operable& op : operables) {
        progress += op.operate_on(global_clock);
      }
    
      // Read from trace
      for (O3_CPU& cpu : env.cpu_view()) {
        auto& trace = traces.at(trace_index.at(cpu.cpu));
        for (auto pkt_count = cpu.IN_QUEUE_SIZE - static_cast<long>(std::size(cpu.input_queue)); !trace.eof() && pkt_count > 0; --pkt_count) {
          cpu.input_queue.push_back(trace());
        }
      }
    
      return progress;
    }
    
  5. ngober commented on Jun 4, 2025

    @ngober
    Collaborator

    Yes, this should still produce a deterministic ordering, if an inscrutible one. The simulation will produce the same outputs for the same inputs, but without specifying precisely what the sequence of operables will be. If this needs to be std::stable_sort for your purposes, I suppose that will be part of your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions