-
Notifications
You must be signed in to change notification settings - Fork 18
Collecting a Task Graph
Now that you have built clang and the Contech LLVM pass using Getting Started Instrumentation, these directions will walk through the steps to instrument a program and generate a task graph for use by backend analysis tools.
In the Contech repository, is a python script - $CONTECH_HOME/scripts/contech_wrapper_par.py and contech_wrapper_par++.py. This pair of scripts are intended as wrappers for clang and clang++ respectively and require LLVM 3.8+. Each script parses the provided arguments in order for each source file to be passed through the Contech LLVM pass. And detecting when the requested operation is link, at which point the script includes the Contech runtime as part of the link step and adds the -lto flag if not already present.
Having used the script, you will have an instrumented binary (as well as _ct.link.bc, which contains all IR files combined together). Run this binary as you would normally. It will produce an event trace, default at /tmp/contech_fe (see below). Several additional messages will be sent to stdout during execution, although a future version may optionally disable them.
You will need to pass the event trace through middle in order to produce a valid task graph. Middle is executed:
middle/middle [event trace] [taskgraph name]
This process will likely take significantly longer than the execution itself, as it is reconstructing thread interleavings, passing all data through compression libraries, etc.
Here are the environment variables that specifically impact compilation and running instrumented programs:
- CONTECH_STATE_FILE - State information to maintain across compiler instances for a single build (default: scripts/output/contechStateFile.temp)
- CONTECH_FE_FILE - Filename for frontend to write event trace into (default: /tmp/contech_fe)
- CONTECH_FE_LIMIT - Memory limit for frontend to queue thread-local buffers into (default: 90% of free memory)