@@ -20,68 +20,67 @@ branch. LLVM should be built with at least
20
20
21
21
An example ` bash ` session to build Comgr on Linux using GNUMakefiles is:
22
22
23
- $ LLVM_PROJECT=~/llvm-project
24
- $ DEVICE_LIBS=~/llvm-project/amd/device-libs
25
- $ COMGR=~/llvm-project/amd/comgr
26
- $ mkdir -p "$LLVM_PROJECT/build"
27
- $ cd "$LLVM_PROJECT/build"
23
+ $ LLVM_PROJECT=~/llvm-project/build
24
+ $ DEVICE_LIBS=~/llvm-project/amd/device-libs/build
25
+ $ mkdir -p "$LLVM_PROJECT"
26
+ $ cd "$LLVM_PROJECT"
28
27
$ cmake \
29
28
-DCMAKE_BUILD_TYPE=Release \
30
29
-DLLVM_ENABLE_PROJECTS="llvm;clang;lld" \
31
30
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \
32
31
../llvm
33
32
$ make
34
- $ mkdir -p "$DEVICE_LIBS/build "
35
- $ cd "$DEVICE_LIBS/build "
33
+ $ mkdir -p "$DEVICE_LIBS"
34
+ $ cd "$DEVICE_LIBS"
36
35
$ cmake \
37
36
-DCMAKE_BUILD_TYPE=Release \
38
- -DCMAKE_PREFIX_PATH="$LLVM_PROJECT/build " \
37
+ -DCMAKE_PREFIX_PATH="$LLVM_PROJECT" \
39
38
..
40
39
$ make
41
- $ mkdir -p "$COMGR/build"
42
- $ cd "$COMGR/ build"
40
+ $ cd ~/llvm-project/amd/comgr
41
+ $ mkdir -p build; cd build;
43
42
$ cmake \
44
43
-DCMAKE_BUILD_TYPE=Release \
45
- -DCMAKE_PREFIX_PATH="$LLVM_PROJECT/build ;$DEVICE_LIBS/build " \
44
+ -DCMAKE_PREFIX_PATH="$LLVM_PROJECT;$DEVICE_LIBS" \
46
45
..
47
46
$ make
48
47
$ make test
49
48
50
49
The equivalent on Windows in ` cmd.exe ` using Visual Studio project files is:
51
50
52
- > set LLVM_PROJECT="%HOMEPATH%\llvm-project"
53
- > set DEVICE_LIBS="%HOMEPATH%\llvm-project\amd\device-libs"
54
- > set COMGR="%HOMEPATH%\llvm-project\amd\comgr"
55
- > mkdir "%LLVM_PROJECT%\build"
56
- > cd "%LLVM_PROJECT%\build"
51
+ > set LLVM_PROJECT="%HOMEPATH%\llvm-project\build"
52
+ > set DEVICE_LIBS="%HOMEPATH%\llvm-project\amd\device-libs\build"
53
+ > mkdir "%LLVM_PROJECT%"
54
+ > cd "%LLVM_PROJECT%"
57
55
> cmake ^
58
56
-DLLVM_ENABLE_PROJECTS="llvm;clang;lld" ^
59
57
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ^
60
58
..\llvm
61
59
> msbuild /p:Configuration=Release ALL_BUILD.vcxproj
62
- > mkdir "%DEVICE_LIBS%\build "
63
- > cd "%DEVICE_LIBS%\build "
60
+ > mkdir "%DEVICE_LIBS%"
61
+ > cd "%DEVICE_LIBS%"
64
62
> cmake ^
65
- -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%\build " ^
63
+ -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%" ^
66
64
..
67
65
> msbuild /p:Configuration=Release ALL_BUILD.vcxproj
68
- > mkdir "%COMGR%\build"
69
- > cd "%COMGR%\build"
66
+ > cd "%HOMEPATH%\llvm-project\amd\comgr"
67
+ > mkdir build
68
+ > cd build
70
69
> cmake ^
71
- -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%\build ;%DEVICE_LIBS%\build " ^
70
+ -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%;%DEVICE_LIBS%" ^
72
71
..
73
72
> msbuild /p:Configuration=Release ALL_BUILD.vcxproj
74
73
> msbuild /p:Configuration=Release RUN_TESTS.vcxproj
75
74
76
- Optionally,
75
+ ** ASAN support: ** Optionally,
77
76
[ AddressSanitizer] ( https://github.com/google/sanitizers/wiki/AddressSanitizer )
78
77
may be enabled during development via ` -DADDRESS_SANITIZER=On ` during the Comgr
79
78
` cmake ` step.
80
79
81
- Comgr can be built as a static library by passing
80
+ ** Static Comgr: ** Comgr can be built as a static library by passing
82
81
` -DCOMGR_BUILD_SHARED_LIBS=OFF ` during the Comgr ` cmake ` step.
83
82
84
- To enable SPIRV support, checkout
83
+ ** SPIRV Support: ** To enable SPIRV support, checkout
85
84
[ SPIRV-LLVM-Translator] ( https://github.com/ROCm/SPIRV-LLVM-Translator ) in
86
85
` llvm/projects ` or ` llvm/tools ` and build using the above instructions, with the
87
86
exception that the ` -DCMAKE_PREFIX_PATH ` for llvm-project must be an install
@@ -92,6 +91,37 @@ Comgr SPIRV-related APIs can be disabled by passing
92
91
` -DCOMGR_DISABLE_SPIRV=1 ` during the Comgr ` cmake ` step. This removes any
93
92
dependency on LLVM SPIRV libraries or the llvm-spirv tool.
94
93
94
+ ** Code Coverage Instrumentation:** Comgr supports source-based [ code coverage
95
+ via clang] ( https://clang.llvm.org/docs/SourceBasedCodeCoverage.html ) , and
96
+ leverages the same CMake variables as
97
+ [ LLVM] ( https://www.llvm.org/docs/CMake.html#llvm-related-variables )
98
+ (LLVM_BUILD_INSTRUMENTED_COVERAGE, etc.).
99
+
100
+ Example of insturmenting with covereage, generating profiles, and creating an
101
+ HTML for investigation:
102
+
103
+ $ cmake -DCMAKE_STRIP="" -DLLVM_PROFILE_DATA_DIR=`pwd`/profiles \
104
+ -DLLVM_BUILD_INSTRUMENTED_COVERAGE=On \
105
+ -DCMAKE_CXX_COMPILER="$LLVM_PROJECT/bin/clang++" \
106
+ -DCMAKE_C_COMPILER="$LLVM_PROJECT/bin/clang" \
107
+ -DCMAKE_BUILD_TYPE=Release \
108
+ -DCMAKE_PREFIX_PATH="$LLVM_PROJECT;$DEVICE_LIBS" ..
109
+ $ make -j
110
+ $ make test test-lit
111
+ $ cd profiles
112
+ # Manually aggregate the data and create text report.
113
+ $ $LLVM_PROJECT/bin/llvm-profdata merge -sparse *.profraw -o \
114
+ comgr_test.profdata # merge and index data
115
+ $ $LLVM_PROJECT/bin/llvm-cov report ../libamd_comgr.so \
116
+ -instr-profile=comgr_test.profdata \
117
+ -ignore-filename-regex="[cl].*/include/*" # show test report without \
118
+ includes
119
+ # Or use python script to aggregate the data and create html report.
120
+ $ $LLVM_PROJECT/../llvm/utils/prepare-code-coverage-artifact.py \
121
+ --preserve-profiles $LLVM_PROJECT/bin/llvm-profdata \
122
+ $LLVM_PROJECT/bin/llvm-cov . html ../libamd_comgr.so \
123
+ # create html report
124
+
95
125
Depending on the Code Object Manager
96
126
------------------------------------
97
127
0 commit comments