Skip to content

Commit 89cb09d

Browse files
committed
add docs
1 parent 787306f commit 89cb09d

File tree

2 files changed

+57
-26
lines changed

2 files changed

+57
-26
lines changed

amd/comgr/README.md

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,68 +20,67 @@ branch. LLVM should be built with at least
2020

2121
An example `bash` session to build Comgr on Linux using GNUMakefiles is:
2222

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"
2827
$ cmake \
2928
-DCMAKE_BUILD_TYPE=Release \
3029
-DLLVM_ENABLE_PROJECTS="llvm;clang;lld" \
3130
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \
3231
../llvm
3332
$ make
34-
$ mkdir -p "$DEVICE_LIBS/build"
35-
$ cd "$DEVICE_LIBS/build"
33+
$ mkdir -p "$DEVICE_LIBS"
34+
$ cd "$DEVICE_LIBS"
3635
$ cmake \
3736
-DCMAKE_BUILD_TYPE=Release \
38-
-DCMAKE_PREFIX_PATH="$LLVM_PROJECT/build" \
37+
-DCMAKE_PREFIX_PATH="$LLVM_PROJECT" \
3938
..
4039
$ make
41-
$ mkdir -p "$COMGR/build"
42-
$ cd "$COMGR/build"
40+
$ cd ~/llvm-project/amd/comgr
41+
$ mkdir -p build; cd build;
4342
$ cmake \
4443
-DCMAKE_BUILD_TYPE=Release \
45-
-DCMAKE_PREFIX_PATH="$LLVM_PROJECT/build;$DEVICE_LIBS/build" \
44+
-DCMAKE_PREFIX_PATH="$LLVM_PROJECT;$DEVICE_LIBS" \
4645
..
4746
$ make
4847
$ make test
4948

5049
The equivalent on Windows in `cmd.exe` using Visual Studio project files is:
5150

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%"
5755
> cmake ^
5856
-DLLVM_ENABLE_PROJECTS="llvm;clang;lld" ^
5957
-DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ^
6058
..\llvm
6159
> 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%"
6462
> cmake ^
65-
-DCMAKE_PREFIX_PATH="%LLVM_PROJECT%\build" ^
63+
-DCMAKE_PREFIX_PATH="%LLVM_PROJECT%" ^
6664
..
6765
> 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
7069
> cmake ^
71-
-DCMAKE_PREFIX_PATH="%LLVM_PROJECT%\build;%DEVICE_LIBS%\build" ^
70+
-DCMAKE_PREFIX_PATH="%LLVM_PROJECT%;%DEVICE_LIBS%" ^
7271
..
7372
> msbuild /p:Configuration=Release ALL_BUILD.vcxproj
7473
> msbuild /p:Configuration=Release RUN_TESTS.vcxproj
7574

76-
Optionally,
75+
**ASAN support:** Optionally,
7776
[AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer)
7877
may be enabled during development via `-DADDRESS_SANITIZER=On` during the Comgr
7978
`cmake` step.
8079

81-
Comgr can be built as a static library by passing
80+
**Static Comgr:** Comgr can be built as a static library by passing
8281
`-DCOMGR_BUILD_SHARED_LIBS=OFF` during the Comgr `cmake` step.
8382

84-
To enable SPIRV support, checkout
83+
**SPIRV Support:** To enable SPIRV support, checkout
8584
[SPIRV-LLVM-Translator](https://github.com/ROCm/SPIRV-LLVM-Translator) in
8685
`llvm/projects` or `llvm/tools` and build using the above instructions, with the
8786
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
9291
`-DCOMGR_DISABLE_SPIRV=1` during the Comgr `cmake` step. This removes any
9392
dependency on LLVM SPIRV libraries or the llvm-spirv tool.
9493

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 profile
112+
> $LLVM_PROJECT/bin/llvm-profdata merge -sparse \*.profraw -o ^
113+
comgr_test.profdata # merge and index data
114+
> $LLVM_PROJECT/bin/llvm-cov report ../libamd_comgr.so ^
115+
-instr-profile=comgr_test.profdata # show test report
116+
> $LLVM_PROJECT/bin/llvm-cov report ../libamd_comgr.so ^
117+
-instr-profile=comgr_test.profdata -ignore-filename-regex="build-.*/" ^
118+
-ignore-filename-regex="llvm-project-internal/[cl].*/include/*" ^
119+
# show test report without includes
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+
95125
Depending on the Code Object Manager
96126
------------------------------------
97127

amd/comgr/docs/ReleaseNotes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ Comgr Testing, Debugging, and Logging Updates
6060
---------------------------------------------
6161
- Removed HIP\_PATH and ROCM\_PATH environment variables. These were used for
6262
now-removed Comgr actions, such as \*COMPILE\_SOURCE\_TO\_FATBIN.
63-
- Added a new Comgr LIT testing infrastrucutre, which can be found in
63+
- Added a new Comgr LIT testing infrastructure, which can be found in
6464
amd/comgr/test-lit. This will allow us to write more in-depth and targeted
6565
tests.
66+
- Added support for source-based code coverage. See README.md for more details.
6667

6768
New Targets
6869
-----------

0 commit comments

Comments
 (0)