Use a Custom Collector
Configure the Custom Collector
Environment Variable Provided by
Enables Custom Collector To Do This
Identify a path to the
VTuneanalysis result. The custom collector uses this path to save the output
csvfile and make it accessible for the
VTunethat adds the
csvdata to the native
Manage a custom data collection. The custom collector may receive the values listed below. After any of these commands the custom collector should exit immediately and return control to the
For each command, the custom collector will be re-launched.
Identify a Process ID of the application to analyze.
VTunesets this environment variable to the PID of the root target process. The custom collector may use it, for example, to filter the data.
VTunesets this variable to the process only when profiling in the Launch Application or Attach to Process mode. For system-wide profiling, the value is empty. When your profiled application spawns a tree of processes, the
AMPLXE_COLLECT_PIDvariable points to the PID of the launched or attached process. This is important to know in case of using a script to launch a workload since you may need to use your own means to pass the child process PID to the custom collector.
import os def main(): cmd = os.environ['AMPLXE_COLLECT_CMD'] if cmd == "start": path = os.environ['AMPLXE_DATA_DIR'] #starting collection of data to the given directory elif cmd == "stop": pass #stopping the collection and making transformation of own data to CSV if necessary main()
if "%AMPLXE_COLLECT_CMD%" == "start" goto start if "%AMPLXE_COLLECT_CMD%" == "stop" goto stop echo Invalid command exit 1 :start rem Start command in non-blocking mode start <my collector command to start the collection> “%AMPLXE_DATA_DIR%”\data_file.csv exit 0 :stop <my collector command to stop the collection> exit 0
Launch the Custom Collector
- Click theConfigure Analysisbutton on the toolbar.The Configure Analysis window opens.
- Make sure the correct target system and target type are selected in theWHEREandWHATpanes.
- In theAdvancedsection of theWHATpane, edit theCustom collectorfield to add a command launching your external collector, for example:
- on Windows*:python.exe C:\work\custom_collector.py
- on Linux*:python home/my_collectors/custom_collector.py
- From theHOWpane, select the required analysis type, for example,Hotspots.
- Configure available analysis options as you need.
- Click theStartbutton to launch theVTuneanalysis and collect custom data in parallel.ProfilerVTunedoes the following:Profiler
If your custom collector cannot be launched in the attach mode, the collection may produce incomplete data.
- Launches the target application, if any, in the suspended mode.
- Launches the custom collector in the attach (or system-wide) mode.
- Switches the application to the active mode and starts profiling.
vtune -collect hotspots -custom-collector="python.exe C:\work\custom_collector.py" -- notepad.exe
vtune -collect hotspots -custom-collector="python /home/my_collectors/custom_collector.py" -- my_app
vtune -collect-with runsa -custom-collector="set | find \"AMPLXE\"" -- notepad.exe
vtune -collect-with runsa -custom-collector="set | find \"AMPLXE\"" -- my_app
- AMPLXE_DATA_DIRenvironment variable to identify a path to theVTuneresult directory and save the outputProfilercsvfile in this location.
- AMPLXE_HOSTNAMEenvironment variable to identify the name of the current host and use it for thecsvfile name.