Skip to content
Eric Holk edited this page Oct 2, 2013 · 2 revisions

Running the Compiler

Harlan programs can be compiled with harlanc. The simplest way is to pass the name of the program on the command line:

harlanc hello.kfc

This assumes harlanc is in your path. If everything is successful, you'll end up with a program in your current directory called hello, which you can run like any other program.

The compiler accepts several command line arguments, which we now describe.

  • --debug, -g - Compile with debugging information. This also saves the generated C++ file.
  • --dump-call-graph - Save a .dot file with the program's call graph.
  • --enable-double - Use double precision floats instead of single precision. This will not work with all hardware.
  • --libdirs, -L - Search these directories for Harlan libraries. The directories are specified as a colon-separated list.
  • --no-kernels - Replace all kernels with equivalent sequential code.
  • --no-optimize, -O0 - Disable optimizations.
  • --no-verify, -V - Do not run intermediate verification passes.
  • --quiet, -q - Generate less output.
  • --rt-dir, -R - Specify where to find Harlan's runtime library.
  • --shared, -s - Generate a shared library instead of an executable.
  • --time, -t - Output timing information for each compiler pass.
  • --verbose, -v - Verbose mode. This prints out the all of the intermediate results from each compiler pass.

Interactive Mode

Harlan currently has a rather large startup time. To make this more manageable, there is now an interactive compiler, harlani. This launches a small REPL that can be used to compile programs multiple times without having the pay the startup cost each time. When harlani starts up, it will display a summary of the supported commands.

Running the Compiled Code

Harlan produces an executable that can be run just like any other program. However, these programs respond to several environment variables, which are documented in Runtime Configuration. The most important of these is HARLAN_DEVICE, which can be either cpu or gpu, and specifies which type of device to use for machines that have OpenCL available for both the CPU and GPU. Here are example commands that will run hello on the GPU and the CPU:

HARLAN_DEVICE=gpu ./hello
HARLAN_DEVICE=cpu ./hello