B. Compiling Charm++ Programs

The charmc program, located in ``charm/bin'', standardizes compiling and linking procedures among various machines and operating systems. ``charmc'' is a general-purpose tool for compiling and linking, not only restricted to Charm++ programs. Charmc can perform the following tasks. The (simplified) syntax for each of these modes is shown. Caution: in reality, one almost always has to add some command-line options in addition to the simplified syntax shown below. The options are described next.


  * Compile C                            charmc -o pgm.o pgm.c
 * Compile C++                          charmc -o pgm.o pgm.C
 * Link                                 charmc -o pgm   obj1.o obj2.o obj3.o...
 * Compile + Link                       charmc -o pgm   src1.c src2.ci src3.C
 * Create Library                       charmc -o lib.a obj1.o obj2.o obj3.o...
 * Translate Charm++ Interface File     charmc file.ci

Charmc automatically determines where the charm lib and include directories are -- at no point do you have to configure this information. However, the code that finds the lib and include directories can be confused if you remove charmc from its normal directory, or rearrange the directory tree. Thus, the files in the charm/bin , charm/include , and charm/lib directories must be left where they are relative to each other.

The following command-line options are available to users of charmc:

-o output-file :

Output file name. Note: charmc only ever produces one output file at a time. Because of this, you cannot compile multiple source files at once, unless you then link or archive them into a single output-file. If exactly one source-file is specified, then an output file will be selected by default using the obvious rule (e.g., if the input file if pgm.c, the output file is pgm.o). If multiple input files are specified, you must manually specify the name of the output file, which must be a library or executable.

-c :

Ignored. There for compatibility with cc .

-D symbol [= value ] :

Defines preprocessor variables from the command line at compile time.

-I :

Add a directory to the search path for preprocessor include files.

-g :

Causes compiled files to include debugging information.

-L* :

Add a directory to the search path for libraries selected by the -l command.

-l* :

Specifies libraries to link in.

-module m1 [, m2 [,...]
] Specifies additional Charm++ modules to link in. Similar to -l , but also registers Charm++ parallel objects. See the library's documentation for whether to use -l or -module .

-optimize :

Causes files to be compiled with maximum optimization.

-no-optimize :

If this follows -optimize on the command line, it turns optimization back off. This can be used to override options specified in makefiles.

-production :

Enable architecture-specific production-mode features. For instance, use available hardware features more aggressively. It's probably a bad idea to build some objects with this, and others without.

-s :

Strip the executable of debugging symbols. Only meaningful when producing an executable.

-verbose :

All commands executed by charmc are echoed to stdout.

-seq :

Indicates that we're compiling sequential code. On parallel machines with front ends, this option also means that the code is for the front end. This option is only valid with C and C++ files.

-use-fastest-cc :

Some environments provide more than one C compiler (cc and gcc, for example). Usually, charmc prefers the less buggy of the two. This option causes charmc to switch to the most aggressive compiler, regardless of whether it's buggy or not.

-use-reliable-cc :

Some environments provide more than one C compiler (cc and gcc, for example). Usually, charmc prefers the less buggy of the two, but not always. This option causes charmc to switch to the most reliable compiler, regardless of whether it produces slow code or not.

-language {converse|charm++|ampi|fem|f90charm} :

When linking with charmc, one must specify the ``language''. This is just a way to help charmc include the right libraries. Pick the ``language'' according to this table:

  • Charm++ if your program includes Charm++ , C++, and C.
  • Converse if your program includes C or C++.
  • f90charm if your program includes f90 Charm interface.

-balance seed load-balance-strategy :

When linking any Converse program (including any Charm++ or sdag program), one must include a seed load-balancing library. There are currently three to choose from: rand , test , and neighbor are supported. Default is -balance rand .

When linking with neighbor seed load balancer, one can also specify a virtual topology for constructing neighbors during run-time using +LBTopo topo , where topo can be one of (a) ring, (b) mesh2d, (c) mesh3d and (d) graph. The default is mesh2d.

-tracemode tracing-mode :

Selects the desired degree of tracing for Charm++ programs. See the Charm++ manual and the Projections manuals for more information. Currently supported modes are none , summary , and projections . Default is -tracemode none .

-memory memory-mode :
Selects the implementation of malloc and free to use. Select a memory mode from the table below.

  • os Use the operating system's standard memory routines.
  • gnu Use a set of GNU memory routines.
  • paranoid Use an error-checking set of routines. These routines will detect common mistakes such as buffer overruns, underruns, double-deletes, and use-after-delete. The extra checks slow down programs, so this version should not be used in production code.
  • leak Use a special set of memory routines and annotation functions for detecting memory leaks. Call CmiMemoryMark() to mark allocated memory as OK, do work which you suspect is leaking memory, then call CmiMemorySweep(const char *tag) to check.
  • verbose Use a tracing set of memory routines. Every memory-related call results in a line printed to standard out.
  • default Use the default, which depends on the version of Charm++.

-c++ C++ compiler :

Forces the specified C++ compiler to be used.

-cc C-compiler :

Forces the specified C compiler to be used.

-cp copy-file :

Creates a copy of the output file in copy-file .

-cpp-option options :

Options passed to the C pre-processor.

-ld linker :

Use this option only when compiling programs that do not include C++ modules. Forces charmc to use the specified linker.

-ld++ linker :

Use this option only when compiling programs that include C++ modules. Forces charmc to use the specified linker.

-ld++-option options :

Options passed to the linker for -language charm++ .

-ld-option options :

Options passed to the linker for -language converse .

-ldro-option options :

Options passes to the linker when linking .o files.

Other options that are not listed here will be passed directly to the underlying compiler and/or linker.