Adding Functionality

From gem5
Revision as of 10:35, 15 October 2008 by Stever (talk | contribs)
Jump to: navigation, search

This page describes the methods available to extend M5 while preserving the ability to update to new versions. If you intend to make any changes to M5 we strongly advise you to follow one of the following methods. It will save you a great deal of time in the future and allow you to take advantage of new M5 versions without the error prone process of manually diffing and patching versions.

There are two recommend ways to add your own functionality to M5 and retain the ability to revision control your own code. The first suggested method relies on the queues feature of Mercurial (the revision control tool used for M5 development). The second relies on your own source control scheme (you could use mercurial or something else), and instead uses the Extras functionality in the build process to link extra objects into M5. In some situations a hybrid approach may be the best one, where the features you're attempting to evaluate are handled via the extras functionality, and minor changes to interfaces are done with Mercurial queues.

Using Mercurial Queues

The first method is using Mercurial Queues (MQ). MQ provides management commands inis to provide management commands to create and apply patches to an upstream source tree. When the underlying source tree is updated (see above), you can remove your patches, get the new changes and reapply your patches very quickly. The patches themselves can be an complete mercurial repository that is revision controlled. It's essential to read the above chapter in the Mercurial manual to understand this process, but briefly you would begin by creating a mercurial queues repository. You can then add patches to the mercurial queues repository and automatically update them based on the changes you've made. With this method it is good to segment changes into logical blocks rather than have one large patch for all your changes. When it comes time to update to a new version of M5 you remove all your patches from the repository, update to the latest version and add re-apply all of your patches. Normally this requires minimal effort. For example:

 hg qinit -c
 hg qnew my_new_feature.diff
 echo "// No so much a new feature as an additional line in the source tree" >> src/sim/
 hg qrefresh # my_new_feature.diff now contains the the extra line in the source tree

 # Remove the patch by executing
 hg qpop
 # Reapply the patch by executing
 hg qpush
 # Commit the changes to the path
 hg qcommit

 #To update to the latest version of M5
 hg qpop -a
 hg fetch
 hg qpush -a

 # Again PLEASE read the manual


The other method relies on the Extras functionality in the build process. You can create new models for M5 and place them in a directory of your choosing. If you would like to use mercurial to revision control this directory, you may, however you can control revisions in any manner. In the root of this directory you should have a SConscript that uses the Source() and SimObject() scons function that are used in the rest of M5. An example of how this works is provided in the encumbered directory.