Home > Community > Blogs > System Design and Verification > parallel compilation for systemc
 
Login with a Cadence account.
Not a member yet?
Create a permanent login account to make interactions with Cadence more convenient.

Register | Membership benefits
Get email delivery of the System Design and Verification blog (individual posts).
 

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

Parallel Compilation for SystemC

Comments(1)Filed under: embedded software, SystemC, System Design and Verification, virtual platforms, virtual prototypes, C, Virtual System Platform, parallel compilation, LSF, compile, pallallel compile, make, GNU

One of the most common complaints about SystemC is that it takes too long to compile. I tend to agree that it does take longer to compile compared to C or Verilog. The primary reason is that SystemC is a somewhat complex set of libraries built on top of C++ and is compiled with g++. Almost every programming language has pros and cons, and compile time happens to be a con of SystemC.

The next most common complaint after general SystemC compile time is that the utility commonly used to compile SystemC Virtual Platform models, ncsc_run, doesn't implement parallel compile like make -j does. The GNU make -j option stands for jobs and specifies how many jobs to run in parallel. The best number is generally equal to the number or processors in your machine. If you have only 1 CPU this option doesn't help you, but since most machines have at least 2 CPUs compilation can be run in parallel. If the -j is not followed by a number then make will not limit the number of jobs that can be run simultaneously.

I did a little digging and found out that ncsc_run actually does implement parallel compile and it's pretty easy to do, it's just not obvious how to do it. As a result I decided a quick explanation will go a long way toward helping others implement parallel SystemC compilation.

Inspection of ncsc_run -help revealed some options for distributed compilation, but they look like they are for a farm of machines and the only solution mentioned is LSF (Load Sharing Facility from Platform Computing). LSF support is good, but I'm looking for parallel compile on a single machine with multiple processors (like my laptop). In the Virtual System Platform (VSP) User Guide there is also a section after the distributed compilation system about using -CATCXX to concatenate multiple source files together to save compile time. Again, a good idea, but not what I'm looking for.

In the end I found the solution is to use an environment variable called NCSC_MAKE. To enable parallel compilation set it like this (for csh):

% setenv NCSC_MAKE "make -j"

The VSP User Guide doesn't say much about this environment variable, but it is mentioned. The only description is that the variable specifies which make utility to run, but no mention of parallel compile or make -j.

The bad news is that setting the environment variable NCSC_MAKE doesn't actually work; no parallel compile is executed when ncsc_run is invoked. All hope is not lost, it turns out that the key to enable parallel compile is to use the -format off switch. This switch disables the pretty printing by ncsc_run and displays the raw output of all of the compilation steps. Normally this is a good thing to do if you are really stuck on a compilation issue and can't see what is going on. In this case I don't really know why it triggers the NCSC_MAKE environment variable to work as expected, but it does.

In conclusion, it is possible to do parallel compilation of SystemC with ncsc_run using a combination of the NCSC_MAKE environment variable and the "-format off" switch.

Let's try an example.

Go to a scratch area, and from your release tree take a copy of one of the examples. I don't know what this example does, but it doesn't matter for this experiment.

% cp -r `ncroot`/tools/systemc/examples/precompiled_headers .

Now edit the file run_ncsc_run to put a $* at the end of the second ncsc_run invocation so we can pass extra options to it to experiment with parallel compile.

First, run the regular way, I told ncsc_run to stop after elaboration since we only care about compile right now:

% time ./run_ncsc_run -O3 -stop elab

Now set the environment variable:

% setenv NCSC_MAKE "make -j"

and run with -format off to see the parallel compile:

% time ./run_ncsc_run -O3 -stop elab -format off

I ran on a 12 processor server and the compilation was done in a fraction of the time it took using serial compile. Of course, your results will vary depending on your machine and how many SystemC files and the size of the files you pass to ncsc_run.

Hopefully you learned something about ncsc_run and can now setup a better compilation environment on your Virtual Platform modeling projects.

I'm sure the same is possible with irun for those of you doing mixed language simulation (or just using irun for fun). Maybe somebody can try with irun and post the instructions.

Jason Andrews

Comments(1)

By Bas Arts on November 17, 2011
Jason,
I guess you found the command line options "-DISTCOMP" and "-DISTCOMPJOBS nr" to support parallel compilation. I don't see why this won't work on a single machine?
--
greetz,
Bas

Leave a Comment


Name
E-mail (will not be published)
Comment
 I have read and agree to the Terms of use and Community Guidelines.
Community Guidelines
The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.