Difference between revisions of "Adding Functionality"

From gem5
Jump to: navigation, search
(Clean out a bunch of redundant info)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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.
+
If you find the need to modify or extend gem5, you may be tempted to just start editing files in your local gem5 repository.  While this approach will work initially, it will cause problems if/when you decide to update your copy of gem5 with changes that have been made since you originally cloned the repository.  It's very likely that you will want to update your code to get bug fixes and new features. Thus 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 gem5 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.
+
There are two recommend ways to add your own functionality to gem5 and retain the ability to revision control your own code: Mercurial Queues (MQ) and the EXTRAS feature of our build system.
  
If you are extending M5 in a way that could be useful to the community, please consider pushing it back upstream. See [[#Contributing Your Changes|Contributing Your Changes]].
+
Mercurial Queues is the most powerful option, as it tracks changes you make to the existing gem5 code as well as files you may add to the source tree.  It's also the recommended path for developing changes that you contribute back to the public code base (see [[Submitting Contributions]]).  For more information, see [[Managing Local Changes with Mercurial Queues]].
  
== Using Mercurial Queues ==
+
The [[Extras | EXTRAS]] option is more limited, in that it only allows you to compile additional files in to the gem5 code base, rather than changing or overriding existing files.  However, the code compiled with EXTRAS is completely decoupled from the gem5 repository, and thus can be managed separately (e.g., in a different Mercurial repository, or using a completely different revision control system).  EXTRAS can also be used to incorporate code that can't be distributed with gem5 due to licensing issues (e.g., the "encumbered" [[repository]]).  Often users end up using EXTRAS to incorporate new SimObject models while they concurrently manage a (ideally much smaller) set of changes using MQ.  See the [[Extras | EXTRAS]] page for more details.
  
The first method is using [http://hgbook.red-bean.com/hgbookch12.html 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:
 
<pre>
 
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/main.cc
 
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
 
</pre>
 
 
== Using EXTRAS ==
 
 
The other method relies on the [[Extras]] functionality in the build process. This feature allows you to keep new M5 models in a directory of your choosing and have them compile and link code in with the M5 binary from arbitrary directories.  Because the location of this directory is completely independent of the M5 mercurial repository, you can use any revision control system you like, and you can include code that you don't want to release (or that was released under a different license) without worrying about contaminating the M5 repository.
 
 
The drawback of the Extras technique is that it only allows the addition of new source code to M5, not the replacement or modification of any existing source code.
 
 
See the [[Extras]] page for details on how to use this feature.
 
 
 
==Contributing Your Changes==
 
The [http://www.selenic.com/mercurial/wiki/index.cgi/PatchbombExtension patchbomb] extension is a great way to share patches with other users.  It adds the <tt>hg email</tt> command which allows you to send a set of changesets (or mq patches) to the m5 developer's mailing list! This will allow us to include valuable community contributions and bugfixes into the main tree.
 
 
 
To e-mail us patches you'll need to add the following to <code>m5/.hg/hgrc</code> (or create it if it doesn't exist).
 
[email]
 
to = m5-dev@m5sim.org
 
Then to e-mail a particular changeset simply execute: <code>hg email [REV]</code>
 
  
 
__NOTOC__
 
__NOTOC__

Latest revision as of 00:43, 23 May 2015

If you find the need to modify or extend gem5, you may be tempted to just start editing files in your local gem5 repository. While this approach will work initially, it will cause problems if/when you decide to update your copy of gem5 with changes that have been made since you originally cloned the repository. It's very likely that you will want to update your code to get bug fixes and new features. Thus 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 gem5 versions without the error prone process of manually diffing and patching versions.

There are two recommend ways to add your own functionality to gem5 and retain the ability to revision control your own code: Mercurial Queues (MQ) and the EXTRAS feature of our build system.

Mercurial Queues is the most powerful option, as it tracks changes you make to the existing gem5 code as well as files you may add to the source tree. It's also the recommended path for developing changes that you contribute back to the public code base (see Submitting Contributions). For more information, see Managing Local Changes with Mercurial Queues.

The EXTRAS option is more limited, in that it only allows you to compile additional files in to the gem5 code base, rather than changing or overriding existing files. However, the code compiled with EXTRAS is completely decoupled from the gem5 repository, and thus can be managed separately (e.g., in a different Mercurial repository, or using a completely different revision control system). EXTRAS can also be used to incorporate code that can't be distributed with gem5 due to licensing issues (e.g., the "encumbered" repository). Often users end up using EXTRAS to incorporate new SimObject models while they concurrently manage a (ideally much smaller) set of changes using MQ. See the EXTRAS page for more details.