Profile your application using the Performance Estimator

Performance Estimator Guide

Huxelerate Performance Estimator does not require any source code upload online, to guarantee the privacy of your code. To generate a profiling report, you need to slightly modify the way your source code is compiled, but do not worry, only 5 steps are required:

  1. Compile each C/C++ source file to LLVM Intermediate Representation (IR)

  2. Link all LLVM IR files to a single one

  3. Instrument your LLVM IR linked file

  4. Compile the instrumented LLVM IR file to obtain your executable

  5. Execute your application with a representative dataset to obtain an accurate estimate

Compile sources to LLVM Intermediate Representation (IR)

We assume you have a Makefile to compile your application, if not, you can simply perform the same steps by running the commands manually. First of all, we define a convenient variable inside the Makefile to run Huxelerate Performance Estimator Docker Container:

HPE=docker run --rm -v $(shell pwd):/data huxelerate/performance_estimator

The /data directory is the default working directory inside Huxelerate Performance Estimator Docker Container. As you can see, when running the Docker Container we map the current working directory (the one from which the makefile is run) to the /data directory inside the Docker Container.

With this command we assume that the Makefile is located in the main directory of your application containing all the source code and relevant files for compilation. If this is not the case, you can simply change $(shell pwd) with a specific path in your file system.

Then you need to change your default compiler to the clang compiler inside the Docker Container:

CC= $(HPE) clang

Finally, to compile into LLVM IR, it is enough to add -emit-llvm flag during object generation:

%.o : %.c
    $(CC) $(OTHER_FLAGS) -c -emit-llvm $< -o $@

Important

The Performance Estimator currently does not support profiling of C++ code that makes use of exceptions. To profile C++ code, make sure to compile it using the -fno-exceptions compiler flag.

Note

When running commands in the context of the Docker Container, absolute paths will be different from your local machine! Whenever possible try to use relative paths when compiling your code. If you really need absolute paths, make sure to change them so that they refer the same files inside the Docker Container.

Instrument your linked file

Use hux-roofline-instrument command to instrument the linked.ll file. In this step, you also need to specify the function to profile using the --function flag:

instrumented.ll : linked.ll
    $(HPE) hux-roofline-instrument -i linked.ll -o instrumented.ll --function my_function_to_profile

Compile to obtain your executable

The last compiling step is to generate the executable from the instrumented.ll file. The command to do so, is no different from compiling any other object file. The only requirement here, is to make sure that the dl and stdc++ libraries gets linked since they are needed for instrumentation purposes:

executable_name : instrumented.ll
    $(CC) $(OTHER_FLAGS) -ldl -lstdc++ instrumented.ll -o $@

Finally, if using a Makefile, a simple make command with your default option is enough to generate the specific executable file.

Execute your application with a representative dataset to allow a more accurate estimate

For performance Estimation purposes, the execution of your application must be performed inside the Huxelerate Performance Estimator Docker Container:

docker run --rm -v $(pwd):/data huxelerate/performance_estimator ./executable_name [executable_options]

The output of the execution is a profiling report file with .hprof extension that you need to upload online to obtain the performance estimation.