480 likes | 629 Views
Asim /AWB Training. Mohit Gambhir Intel Massachusetts Content: Joel Emer, Michael Pellauer , Chris Weaver. Agenda. AWB Overview Modular Software Design AWB Abstractions & Terminology AWB Tools Configuration File Formats Asimcore ( libasim ) Overview . AWB . Architects Workbench
E N D
Asim/AWB Training Mohit Gambhir Intel Massachusetts Content: Joel Emer, Michael Pellauer, Chris Weaver
Agenda • AWB Overview • Modular Software Design • AWB Abstractions & Terminology • AWB Tools • Configuration File Formats • Asimcore (libasim) Overview
AWB • Architects Workbench • Originally written to create software performance models • Core Principle: Modularity • AWB facilitates the modular plug-n-play style construction of software and hybrid software/hardware projects
AWB (contd.) • A suite of tools to support rapid modular construction and analysis of performance model • GUI and command-line based • Publically released under the GPL (models are not) • Across Multiple: • Code bases: • Different repositories, or even types of repositories • Model configurations: • Alternative modules, knobs, levels of accuracy • ISA variations • Benchmark suites • Results from different runs, etc.
Why Modularity • Speed of model development • Shared components between products • Reuse across generations • Encourages isomorphism to design • Improved fidelity • Facilitates speed/fidelity trade-offs • Architectural experimentation • Factorial development and evaluations • Sharing
AWB Abstractions & Terminology • Packages (codebases) are stored in repositories • Packages can be grouped into related bundles • Users check out bundles into local workspaces • The set of packages in a workspace is viewed a Union Dir • Bundle packages contain modules (modular source code) • Modules are arranged into models (configurations) • Each workspace can contain multiple model build directories • Each build directory can contain multiple benchmarkruns
AWB Abstractions and Terminology • Workspace • Configure (a model) • Repository • Bundle • Package • Model • Module • Uniondir Search Path
Workspace • Directory where one works on the AWB based project • awb commands that need a workspace context in which to operate search up the directory tree until they find the root of a workspace. • contain a stylized directory structure
Configure • Collect a set of source files together that can be built into a specific design or model • The specific set of modules (and hence source code) that comprise a specific model are specified in an .apm file. • Since a model is created from a pool of modules, the build paradigm adds a new step to “configure” a model source tree from a pool of modules. • Thus given an .apm file, the configure process involves placing copies of the designated source files (via symbolic links) and some automatically created glue files into a model-specific subtree in the build area of the workspace.
Repository • A repository is a source code repository using one of the supported source code management systems. • Supported versioning systems - CVS, SVN, Bitkeeper and git • Repository specification • <repository-name>[/<version>] • The set of available repository names are specified in a .pack file. • <INSTALLDIR>/etc/respositories/<package-name>.pack • ~/.asim/respositories/<package-name>.pack
Bundle • Collection of repositories (with optional versions) – used to checkout a group of packages together. • Bundle specification • <bundle_name>[/<bundle_version>] • Bundles are specified in bundlefiles • <INSTALLDIR>/etc/asim/bundles.d/ • ~/.asim/bundles.d/ • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Bundlefiles
Package • Portion of repository that is checked out in the workspace • the configure/Makefile.in/Makefile files are optional and do not build a user's model, but simply the tools that might exist in the package • Globally installed packages that can be shared by all users • <INSTALLDIR>/share/asim/<package>/<release> • Private packages: • <workspace>/src/<package>
Model • An AWB model is a hierarchical representation of a design, where each node of the hierarchy is a module • Each workspace may have multiple models configured/built each constructed plug-n-play style out of the pool of modules available in all packages in a workspace • Represented in .apm file • Typically found in config/pm directory inside a package • Can be edited by apm-edit • In the AWB editor GUI, models are marked with an icon which looks like a double cog
Module • Modules represent the unit of “swapability” in source code • If two modules provide the same awb type then this is an assertion that they can be swapped for one another and that the result will be a coherent model that will successfully build • Each module is specified in an .awb file which specifies • ‘awb-type’of the module, • Awb-types of the children modules that it 'requires' • Source files that implement the module.
Uniondir Search Path • awb supports a union mount-like directory structure that overlays the files from a set of packages. • This set of packages is specified as a uniondirsearch path • File references resolved through search of all package directories in the search path • Packages added to search path at checkout awb-resolver config/pm/simcore/model.apm /home/mgambhir/asim/src/asim-simcore/config/pm/simcore/model.pm
Workspace AWB Operation Example Repositories
AWB Tools • awb-shell • awb • apm-edit
Awb-shell • This is a program that provides a command line interface to manipulate various ASIM objects. • Has default values for these Asim objects • Can set reset default values through set command • help command displays all possible commands • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Awb-shell • awb-shell help quickstart
% awb-shell awb> set model pm/Arana/arana_aint_dev.apm awb> clean model awb> configure model awb> build model awb> run model bm/Micro/maxipc.cfg awb> quit % awb-shell --package=arana commit package % awb-shell help % awb-shell help code Awb-shell % awb-shell awb> set model pm/Arana/arana_aint_dev.apm awb> clean model awb> configure model awb> build model awb> run model bm/Micro/maxipc.cfg awb> quit
Awb-shell • Primer for most commonly used awb-shell wrapped svn commands • awb-shell checkout package <name> • awb-shell update package <name> • awb-shell commit package <name> • Make sure that environment variable EDITOR is set to your favorite EDITOR • setenv EDITOR vi • awb-shell checkout package <name>/<branch> • To checkout a package branch • awb-shell checkout package <name>/<rev> • To checkout a particular revision of a package
Awb-shell • Bundle commands • awb-shell new bundle <name>[/<tag>] • By default takes a snapshot of packages in the current workspace • By default adds the file into ~/.asim/bundles/release • Use --head to specify the head version • Use --install to publicly install in /p/asim • Requires asimadm permissions • awb-shell checkout bundle <name>[/<tag>] • awb-shell update bundle <name>[/<tag>] • awb-shell show bundle <name>[/<tag>]
Awb • cd into your workspace • Type: “awb”
Awb Lets Select an ape softsdv model
Awb Nuke
Awb Configure
Awb Build
Configuration File formats • Workspace configuration: awb.config • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Awbconfig • Model description: .apm file • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Apm_file • Module description: .awb file • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Awb_file • Benchmark description: .cfg file • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Cfg_file • Multiple benchmark description: .cfx file • http://asim.csail.mit.edu/redmine/projects/awb/wiki/Cfx_file
Asimcore (libasim) overview • Clocking • Ports • Stats
Clocking • Cycle accurate models: • Hierarchical and explicit time control void ASIM_CPU_CLASS::Clock (UINT64 cycle) { efmmbx.Clock(cycle); mbx.Clock(cycle); qbx.Clock(cycle); ibx.Clock(cycle); … } • Clock Server bool ASIM_RBOX_CLASS::InitModule () { ostringstreamos; os << "SYSINT_CLOCK_DOMAIN_" << myUniqueRboxId; RegisterClock(os.str()); } • Clock techniques can be combined
Clocking • Creating Clock domains • void newClockDomain (string name, float freq, INT32 threadId = -1) • void newClockDomain (string name, list<float> freqs, INT32 threadId = -1) List of valid frequencies
Clocking • Set Domain Frequency • void setDomainFrequency (string domainName, float freq) • Register Clock • void RegisterClock (string domainName, UINT32 skew = 0, • INT32 threadId = -1, boolreferenceDomain = false) • void RegisterClock (string domainName, CLOCK_CALLBACK_INTERFACE cb, • UINT32 skew = 0, INT32 threadId = -1, • boolreferenceDomain = false) • void RegisterClock (string domainName, CLOCK_CALLBACK_INTERFACE cb, • CLK_EDGE ed, UINT32 skew = 0, INT32 threadId = -1, • boolreferenceDomain = false)
Clocking template<class T> CLOCK_CALLBACK_INTERFACE newCallback (T *obj, void (T::*meth)(UINT64)) • Traditionally all the module work happen in one method: void Clock(UINT64 cycle) • Callbacks enable: • Having more that one clock method in a module • Clocking a module at different frequencies
Clocking bool ASIM_CBOX_CLASS::InitModule () { … ostringstreamos; os.str(""); os << "RING_CLOCK_DOMAIN_" << myChipNum; RegisterClock(os.str()); os.str(""); os << "CBOX_CLOCK_DOMAIN_" << myChipNum; RegisterClock(os.str(), newCallback(this, &ASIM_CBOX_CLASS::ClockCBOX)); … } void ASIM_CBOX_CLASS::ClockCBOX (const UINT64 cycle) { // Clocked at CBOX frequency … } void ASIM_CBOX_CLASS::Clock (const UINT64 cycle) { // Clocked at Ring frequency … }
Ports 2 “NetworkInUse” “NetworkInUse” • In an Asim model, time only passes when messages flow through ports • Activity within each module is instantaneously fast • Each port defines a latency and a bandwidth • BW: Number of abstract objects that can enter/exit in a cycle • LAT: Number of cycles that objects travel through port • Sender defines BW and receiver defines LAT • Benefits: • LAT and BW are often useful knobs for architectural exploration • Separates functionality from timing • Encourages reuse • Can ease burden of coding
Ports • Connect modules • Read port and write port make a connection • BW set by writer • Latency set be reader • What gets passed through ports? • Pointers to objects • allows for generic interfaces between modules • does make it easier to “cheat” by accessing info that shouldn’t be available to certain modules • Bools & integers
Ports • ReadPort<CPU_INST> var1_RPort; • var1_RPort.Init("Unique_String"); • var1_RPort.SetLatency(latency); • WritePort<CPU_INST> var1_WPort; • var1_WPort.Init("Unique_String"); • var1_WPort.SetBandwidth(bandwidth);
// Write data into the port in cycle C • CPU_INST inst; • var1_WPort.Write(inst1, cycle); Ports • // Read data in cycle C + latency • CPU_INST inst2; • var2_RPort.Read(inst2, cycle);
Ports • Other Kinds of Ports • Stall Ports • Enable reader to stall the port to disable write from writing • Rate Matcher Ports • To connect modules in different frequency domains • Skid Ports • Allow lazy reading of data
Stats • Stat Types • Scalar • Stats that comprise of one value collected over the entire simulation run. • For eg. DCacheMisses • Multidimensional (Histograms) • These stats show the number of times particular clusters of events occur. • For eg, the number of times N instructions were issued in a cycle where N for an 8 way processor varies from 0 to 8. • Per Instructions Stats • Global • Per instruction type • Per instruction
Stats • Declare the stats data member of a class as a UINT64, Double, UINT64* or a Double* • UINT64 dstreamFull; • UINT64 instsRetired[CPU_THREADS]; • Register the stats variable with StatsRegistry class • RegisterState(dstreamFull, "PremafDstreamFull", "Number of dstream full events"); • RegisterState(instsRetired, CPU_THREADS, "RetiredInstructions", "Retired Instructions"); • Accumulate Stats • dstreamFull++; • instRetired[tpu]++;
Stats • Histograms Stats • Declaration • HISTOGRAM_TEMPLATE<ENABLE_QBOX_STATS> instrIssuedPerCycle • Initilization • HISTOGRAM_TEMPLATE (UINT32 num_rows, UINT32 num_cols = 1, UINT32 row_size = 1, BOOL row_flex_cap = FALSE, UINT32 col_size = 1, BOOL col_flex_cap = FALSE) • Register • RegisterState(&instrIssuedPerCycle, "instrIssuedPerCycle", "Number of instructions issued from the IQ per cycle"); • Accumulate Stats • AddEvent(UINT32 row_val, UINT32 col_val = 0, UINT64 value = 1) • AddEventWideBins(UINT32 row_val, UINT32 col_val = 0, UINT64 value = 1)
Stats • Command line switches • -sc <n> Emit stats file every <n> cycles • -sn <n> Emit stats file every <n> nanoseconds • -si <n> Emit stats file every <n> instructions • -sm <n> Emit stats file every <n> macro instructions • -rsc <n> Reset stats on cycle <n> • -rsi <n> Reset stats on instruction <n> • -rsm <n> Reset stats on macro instruction <n> • -rsn <n> Reset stats on nanosecond <n> • Adding a p after the previous flags (for instance -rscp) will reset stats periodically after <n> events