Hi Volkan, Following is my understanding of the issues you mentioned in your email (I hope someone with more RISCV experience can augment/correct this):
1. Each functional unit can be responsible for execution of multiple classes of instructions and you can configure the latency of each class of instructions using the Python interface. The class that an instruction belongs to is decided through the ISA specific instruction decoding module (the "execute" function which can execute a particular instruction is also decided at this point). If you have not already, I will suggest having a look at this page: https://www.gem5.org/documentation/general_docs/cpu_models/execution_basics Once the instruction reaches the execute stage, the class of the instruction and the corresponding latency are used to decide when the results of the operation will be available. 2. gem5 tries to keep the ISA independent parts of micro-architecture same for all ISAs. So, mostly MinorCPU will behave similarly irrespective of the ISA. But, ISA specific things will be handled differently. For example, when you build the MinorCPU for RISC vs x86, the build system generates ISA specific instruction classes with different execute methods for example. Moreover, some parts of the CPU micro-architecture could be ISA specific and you might occasionally find ISA specific directives in the code for conditional compilation. 3. If you wish to instrument individual functions of your code, you can rely on m5ops (https://www.gem5.org/documentation/general_docs/m5ops/) which allow you to move control out of the simulated code to potentially do things like generating stats at that particular point of execution or switching to different CPU models. -Ayaz On Wed, Nov 25, 2020 at 6:53 PM Volkan Mutlu via gem5-users < [email protected]> wrote: > Hello all, I'm new to gem5 and I'm trying to use it as a simulation > environment for a RISC-V related project. I'll first ask my questions, and > if there are any confusions as to what I'm trying to achieve please see > description below. Any help or response is much appreciated! > 1) For the MinorCPU model, how does gem5 know how many clock cycles an > instruction's execution would take? For instance, in most > microarchitectures, the instructions ADDI, MUL and DIV would all take > different number of cycles to execute. Where is timing information for this > set? Digging into the code a bit, I've noticed there is a class called > MinorFUTimings where some timing properties can be set for a functional > unit which seems like the answer to my question, but I couldn't find > anything that indicates this is used for each standard instruction to > adjust their timings. There is likely a more systematic way this is > managed, which makes more sense of course, but I wasn't able to figure it > out after looking through the documentation on Minor CPU model and the > source code. > 2) Seeing as the CPU models in gem5 span all ISAs, I'm assuming these > models don't necessarily reflect any particular microarchitecture's > details. Is there any difference between the MinorCPU when I build gem5 for > RISC-V vs. x86? Especially pertaining to this timing information I > mentioned in my first question. How does gem5 know, for instance, how many > cycles a simple multiply with register operands would take for RISC-V vs. > x86, both with the MinorCPU model? > 3) What would be the best way to get information on time spent in > functions when running gem5 in SE mode for RISC-V? I tried using the > clock() function from the C time library and I get results that roughly > make sense but I'm not sure if this is accurate. For now I am only taking > the number of CPU cycles reported in stats at face value, but it would be > convenient to actually instrument the code. > Thanks in advance for your attention and responses! Below are more details > if needed. > Basically, I'm trying to extend RV64 with some custom instructions and run > certain benchmarks to see what performance improvement I can get compared > to standard software libraries that provide the functions that these > instructions will fulfill. One good example I'm particularly trying are SHA > instructions (x86 provides an extension for these, for instance, but as far > as I know RISC-V doesn't have a standard extension for them). > To keep things simpler, I wanted to use the MinorCPU model. Now, I was > able to add custom instructions and run compiled code invoking those, but I > have not specified any details regarding the execution of these custom > instructions. As far as I know, gem5 only knows which 'class' of > instructions they belong to, their opcodes and their functional > description. Yet, when I look at the stats after running my code its clear > that gem5 is making some assumptions as to how many clock cycles these > instructions are taking. To get a better sense of this I included a new > instruction that's basically a duplicate of an already existing one, and > gem5 indeed reports the same timing information. This led me to think maybe > this information was being derived from the class of instructions, but > switching the instruction to a different one from the same class (I tested > this with IntAlu operations) and keeping the code otherwise same led to > different results. I'm doing very simple tests, just defining a fu > nction using inline assembly and then operating on two integers with this > function. So I am a bit confused as to how this timing information is set. > _______________________________________________ > gem5-users mailing list -- [email protected] > To unsubscribe send an email to [email protected] > %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s >
_______________________________________________ gem5-users mailing list -- [email protected] To unsubscribe send an email to [email protected] %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
