harvard-acc / gem5-aladdin

End-to-end SoC simulation: integrating the gem5 system simulator with the Aladdin accelerator simulator.
BSD 3-Clause "New" or "Revised" License
210 stars 59 forks source link

For each algorithm of MachSuite, how to generate the corresponding executable file and the necessary files configured in gem.5.cfg such as dynamic_trace.gz? #31

Open better1017 opened 3 years ago

better1017 commented 3 years ago

For each algorithm of MachSuite, how to generate the corresponding executable file and the necessary files configured in gem.5.cfg such as dynamic_trace.gz? For example, I want to simulate the test_aes to experiment on the gemm algorithm. Which files are necessary, how are they generated, which are generated by tools, and which need to be manually configured by themselves?

xyzsam commented 3 years ago

Here's a short answer to get you started.

gem5-aladdin already includes a set of configuration files for aes in src/aladdin/integration-test/with-cpu/test_aes. All you have to do is make all in that directory - that will build the instrumented binary, generate the trace, and build the aes binary for gem5 to use. The gem5.cfg file is already provided for you - most of that can stay the same unless there are parameters there you want to change. The test_aes.cfg file defines the accelerator itself - this needs to change for each accelerator. See the Aladdin README for more details on that config file. Those are the two main config files.

If you want to adapt test_aes for gemm, you'll need to:

  1. Write a test_gemm.cfg file.
  2. Update the gem5.cfg file so that it points to this new test_gemm.cfg file and the new dynamic trace. The places to update should be obvious.
  3. Update the gem5.cfg file's accelerator_id to match the ID used by the gemm benchmark. You can see a list of them here: https://github.com/harvard-acc/ALADDIN/blob/448b8f41865003e20eee0bdbd7a73febb5c3abe3/gem5/aladdin_sys_constants.cpp

To run the simulation, ./run.sh in that directory.

We usually don't expect people to do this manually. There is a sweep generator system called Xenon which supports all the MachSuite benchmarks. It can generate all the configuration files you need, build the traces and binaries, etc. That's under sweeps/, and a README is there for you to follow.

Don't hesitate to ask if you have any other questions. We also have a gem5-aladdin user forum (https://groups.google.com/forum/#!forum/gem5-aladdin-users) - consider posting future questions like this there.

better1017 commented 3 years ago

Thanks. OK. But when I want to adapt test_aes for gemm, I need the dynamic_trace.gz and the instrumented binary of gemm. How to generate them? When I execute the "python generate_design_sweeps.py benchmarks/machsuite.xe" command in the "sweets/" directory, the feedback is as follows:

Building DMA traces for aes_aes Traceback (most recent call last): File "generate_design_sweeps.py", line 31, in main() File "generate_design_sweeps.py", line 28, in main run(args.xenon_file) File "generate_design_sweeps.py", line 12, in run genfiles = interpreter.run() File "/workspace/gem5-aladdin/sweeps/xenon/xenon_interpreter.py", line 87, in run genfiles = self.generate_outputs() File "/workspace/gem5-aladdin/sweeps/xenon/xenon_interpreter.py", line 80, in generate_outputs generated_files = sweep.generateAllOutputs() File "/workspace/gem5-aladdin/sweeps/xenon/base/datatypes.py", line 408, in generateAllOutputs genfiles = generator() File "/workspace/gem5-aladdin/sweeps/benchmarks/designsweeptypes.py", line 48, in generate_dma_trace return generator.run() File "/workspace/gem5-aladdin/sweeps/generators/trace_generator.py", line 77, in run os.rename(trace_orig_path, trace_new_path) OSError: [Errno 2] No such file or directory

xyzsam commented 3 years ago

I think you're still on an old version of gem5-aladdin. Line 77 of trace_generator.py should be this: https://github.com/harvard-acc/gem5-aladdin/blob/master/sweeps/generators/trace_generator.py#L77