MCC User Manual
This document describes how to compile MUSA code with mcc and gives some details about mcc's implementations.
This document assumes a basic familiarity with the CUDA programming language. Information about CUDA programming can be found in the CUDA programming guide.
Overview
MUSA is a CUDA-like programming language for concurrency programming on MTGPU devices.
Prerequisites
mcc currently supports building MUSA which is compatible with CUDA 11.4. Before you build MUSA code, you'll need to have installed the MUSA Toolkit. mcc will attempt to find MUSA installation under the default path "/usr/local/musa". Users also can specify a different location of MUSA Toolkit location via the option "--musa-path".
MUSA compilation is only supported on Linux currently. The compiler on Windows is coming soon.
Purpose of MCC
A MUSA application consists of a mixture of conventional C++ host code and GPU device functions, which makes the compilation trajectory involve several steps of compilation and linkage for each MUSA source file. mcc, the MUSA programming language compiler driver, helps hide the complexity of these phases of building a source code.
Compilation phases
Mostly, the compilation of MUSA in mcc is like conventional C++ by clang++:
- Preprocess the source code to deal with macros and include directives by macro expansion and header including.
- Compile to llvm ir with a series of organized transformation and optimization passes.
- Code generation: lower to target specific code and generate object files.
- Link libraries to generate executable binary, including static/shared library and standalone executable file.
The difference is that MUSA code is mixed with the host-side part and device-side part. Basically, mcc will compile the source twice to generate the device code object and host code object, then try to combine them together. So the above phases will repeat twice at least for both the device-side code and host-side part.
In detail, the binary value of the device code object will be assigned to a global constant variable when compiling host-side code, before code generation. Phases of host-side code are almost the same as conventional C++'s.
When the kernel is to be launched to GPU devices, MUSA runtime and driver will help extract the device code object, which is outside of the scope of this document.
Compilation trajectory
Compilation driven by mcc follows the trajectory as below:

Supported input file suffixes
Each phase of compilation driven by mcc accepts specific input files. mcc will identify them by file suffixes and compile options.
| Input file suffix | Description |
|---|---|
| .mu | A MUSA source file, containing host code and device functions. |
| .c | A C source file. |
| .cc, .cxx, .cpp | A C++ source file. |
| .ll | A LLVM IR file. |
| .o, .obj | An object file. |
| .a | A library file. |
| .so | A shared library file. |
And other file suffixes are supported by clang/clang++.
Compiler command-line options
mcc is the compiler driver for the MUSA language inspired by llvm-project 14.0.0. Most of the compiler options work fine just as Clang and LLVM toolchain. Additionally, it provides specific options for the MUSA language and MTGPU target.
Options for help information
--help/-help
Displays help for available options.
--help-hidden
Displays help for hidden options.
- v
Displays verbose output for sub-commands.
--version
Prints version information.
Options for input file and specifications
-o [file]
Defines the name of the output file.
- x [language]
Specifies the language for the input files(e.g. -x musa), and subsequent input files will recognize as having type.
- D [macro]=[value]
Defines [macro] to [value] (or 1 if [value] omitted).
Options for path specifications
--musa-path= value
Specifies MUSA Toolkit installation path.