amithgopi / CPU-Branch-Prediction-and-Cache-Replacement-using-ML-and-RL

2 stars 1 forks source link

Generating Traces and API calls for cache and branch #1

Open amithgopi opened 2 years ago

amithgopi commented 2 years ago
amithgopi commented 2 years ago

Cache API Call Format

amithgopi commented 2 years ago

Cache - API calls and Where Info is populated

cache.cc, contains calls to the cache replacement APIs in the form of impl_replacement_update_state(..) (update) and impl_replacement_find_victim(..) (find) which are mapped to the corresponding replacement algorithm when Champsim is configured. This is done via the python script which creates certain .inc files (cache_modules.inc for cache) that map the function to the API call in the algorithms.

In cache.cc, main call to operate() function:

Cache APIs are then called from these as follows:

The API arguments are populated as:

NOTES: miss status holding registers (MSHR) - MSHR of type list of PACKET PACKET in block.h - message packet

amithgopi commented 2 years ago

Thoughts on generating Trace for cache

Most of the cache-based info comes as part of the runtime. Hence this most probably cannot be generated directly from the trace. It's better to get this info from one of the cache implementations or use a new implementation to capture the details.

For cache, it's better to map the info of arguments in each of the API calls to separate trace files (one for each call, or with some indicator to which call created which trace). The same process can be repeated for branch predictors. The parameters available as arguments to the API calls to cache or brach impls are limited and changing these would require extensive changes to many of the Champsim internal classes. I would be easier to just go with the ones currently available in the APIs. Although, things that are present in the last call to the API impls can be added easily. (I have not tested this, but this seems easy enough).

Notes on Champsim dynamic config changes

Champsim uses the config file passed by the user to configure the different algorithms used. Using this file the config.sh script creates a file in the inc folder which maps generic function calls in the main code to the correct ones in the user-defined files. The initial script run generates mappings to functions whose implementations are lined when the Makefile (which is also created by the config.sh script) is run. This is where the function declarations created in the .inc files are finally mapped to the ones in the user algorithms.

amithgopi commented 2 years ago

Branch Prediction

Branch prediction APIs are mapped similar to cache to the algorithm implementations in the ooo_cpu_module.inc file generated at config time. Branch prediction APIs are called from the ooo_cpu.cc file which implements the ooo_cpu (O3_CPU) class. There are two general calls to the APIs:

In these,