Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/actions/setup-typeart/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: 'Setup TypeART Environment'
description: 'Sets up LLVM, Clang, OpenMPI, and other dependencies for TypeART CI'

inputs:
llvm-version:
description: 'LLVM version to install'
required: true
typeart-typegen-legacy:
description: 'Set TYPEART_TYPEGEN_IR env variable'
required: false
install-libcxx:
description: 'Install libc++'
required: false
default: 'false'
install-lcov:
description: 'Install lcov'
required: false
default: 'false'
install-omp:
description: 'Install LLVM OpenMP runtime'
required: false
default: 'true'
setup-mold:
description: 'Setup Mold Linker'
required: false
default: 'false'

runs:
using: "composite"
steps:
- name: LLVM apt
if: ${{ inputs.llvm-version >= 19 }}
shell: bash
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-${{ inputs.llvm-version }} main" | sudo tee /etc/apt/sources.list.d/llvm-${{ inputs.llvm-version }}.list

- name: Update apt
shell: bash
run: sudo apt-get update

- name: Install LLVM
shell: bash
run: sudo apt-get install -y libllvm${{ inputs.llvm-version }} llvm-${{ inputs.llvm-version }} llvm-${{ inputs.llvm-version }}-dev

- name: Install LLVM OpenMP runtime
if: ${{ inputs.install-omp == 'true' }}
shell: bash
run: sudo apt-get install -y libomp-${{ inputs.llvm-version }}-dev

- name: Install Clang
shell: bash
run: sudo apt-get install -y clang-${{ inputs.llvm-version }} clang-tidy-${{ inputs.llvm-version }}

- name: Install libc++
if: ${{ inputs.install-libcxx == 'true' }}
shell: bash
run: sudo apt-get install -y --no-install-recommends libc++-${{ inputs.llvm-version }}-dev libc++abi-${{ inputs.llvm-version }}-dev

- name: Install OpenMPI
shell: bash
run: sudo apt-get install -y libopenmpi-dev openmpi-bin

- name: Install lcov
if: ${{ inputs.install-lcov == 'true' }}
shell: bash
run: sudo apt-get install -y lcov

- name: Setup Mold Linker
if: ${{ inputs.setup-mold == 'true' && inputs.llvm-version > 14 }}
uses: rui314/setup-mold@v1

- name: Setup env
shell: bash
run: |
sudo ln -f -s /usr/bin/clang-${{ inputs.llvm-version }} /usr/bin/clang
sudo ln -f -s /usr/bin/clang++-${{ inputs.llvm-version }} /usr/bin/clang++
echo "LLVM_CMAKE_DIR=/usr/lib/llvm-${{ inputs.llvm-version }}/cmake" >> $GITHUB_ENV
echo "EXTERNAL_LIT=/usr/lib/llvm-${{ inputs.llvm-version >= 20 && 18 || inputs.llvm-version }}/build/utils/lit/lit.py" >> $GITHUB_ENV
if [ -n "${{ inputs.typeart-typegen-legacy }}" ]; then
echo "TYPEART_TYPEGEN_IR=${{ inputs.typeart-typegen-legacy }}" >> $GITHUB_ENV
fi
180 changes: 141 additions & 39 deletions .github/workflows/basic-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,80 +81,182 @@ jobs:
steps:
- uses: actions/checkout@v6

- name: LLVM apt
if: ${{ matrix.platform.llvm-version >= 19 }}
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-${{ matrix.platform.llvm-version }} main" | sudo tee /etc/apt/sources.list.d/llvm-${{ matrix.platform.llvm-version }}.list

- name: Update apt
run: sudo apt-get update
- name: Setup TypeART Environment
uses: ./.github/actions/setup-typeart
with:
llvm-version: ${{ matrix.platform.llvm-version }}
typeart-typegen-legacy: ${{ matrix.platform.typeart-typegen-legacy }}
install-libcxx: ${{ matrix.preset.libcxx || 'false' }}
install-lcov: ${{ matrix.preset.coverage || 'false' }}
install-omp: 'true'
setup-mold: 'true'

- name: Install LLVM
run: sudo apt-get install libllvm${{ matrix.platform.llvm-version }} llvm-${{ matrix.platform.llvm-version }} llvm-${{ matrix.platform.llvm-version }}-dev
- name: Configure TypeART
run: cmake -B build --preset ${{ matrix.preset.name }} -DLLVM_DIR=${LLVM_CMAKE_DIR} -DLLVM_EXTERNAL_LIT=${EXTERNAL_LIT}

- name: Install LLVM OpenMP runtime
run: sudo apt-get install libomp-${{ matrix.platform.llvm-version }}-dev
- name: Build TypeART
run: cmake --build build --parallel 2

- name: Install Clang
run: sudo apt-get install clang-${{ matrix.platform.llvm-version }} clang-tidy-${{ matrix.platform.llvm-version }}
- name: Prepare TypeART coverage
if: matrix.preset.coverage
run: cmake --build build --target typeart-lcov-clean

- name: Install libc++
if: matrix.preset.libcxx
run: sudo apt-get install --no-install-recommends libc++-${{ matrix.platform.llvm-version }}-dev libc++abi-${{ matrix.platform.llvm-version }}-dev
- name: Test TypeART lit-suite
if: matrix.preset.skip_test == false
run: cmake --build build --target check-typeart

- name: Install OpenMPI
run: sudo apt-get install libopenmpi-dev openmpi-bin
- name: Build coverage report
if: matrix.preset.coverage
run: cmake --build build --target typeart-lcov-html

- name: Install lcov
- name: Coveralls (parallel)
if: matrix.preset.coverage
run: sudo apt-get install lcov
uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: build/typeart.coverage
flag-name: ${{ matrix.preset.name }}-${{ matrix.platform.llvm-version }}-${{ matrix.platform.typeart-typegen-legacy }}
parallel: true

cuda-suite:
strategy:
fail-fast: false
matrix:
include:
- llvm-version: 14
os: ubuntu-22.04
cuda: 11.8.0
- llvm-version: 22
os: ubuntu-24.04
cuda: 12.6.0

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v6

- uses: Jimver/cuda-toolkit@v0.2.35
id: cuda-toolkit
with:
cuda: "${{ matrix.cuda }}"
method: network
sub-packages: '["nvcc", "cudart", "cudart-dev"]'
non-cuda-sub-packages: '["libcurand", "libcurand-dev"]'

- name: Setup TypeART Environment
uses: ./.github/actions/setup-typeart
with:
llvm-version: ${{ matrix.llvm-version }}
typeart-typegen-legacy: 0
install-lcov: 'true'
install-omp: 'true'
setup-mold: 'true'

- name: Configure TypeART
run: cmake -B build --preset ci-cov-thread-safe -DLLVM_DIR=${LLVM_CMAKE_DIR} -DLLVM_EXTERNAL_LIT=${EXTERNAL_LIT}

- name: Build TypeART
run: cmake --build build --parallel 2

- name: Setup Mold Linker
if: ${{ matrix.platform.llvm-version > 14 }}
uses: rui314/setup-mold@v1
- name: Prepare TypeART coverage
run: cmake --build build --target typeart-lcov-clean

- name: Test TypeART cuda-suite
run: cmake --build build --target check-typeart

- name: Setup env
- name: Build coverage report
run: cmake --build build --target typeart-lcov-html

- name: Coveralls (parallel)
uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: build/typeart.coverage
flag-name: cuda-suite-${{ matrix.llvm-version }}-${{ matrix.cuda }}
parallel: true

hip-suite:
runs-on: ubuntu-24.04

env:
ROCM_PATH: /opt/rocm
ROCM_VERSION: 6.4.4

steps:
- uses: actions/checkout@v6

- name: Setup ROCm Toolchain
run: |
sudo mkdir --parents --mode=0755 /etc/apt/keyrings
wget -qO - https://repo.radeon.com/rocm/rocm.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/rocm.gpg
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${ROCM_VERSION} noble main" | sudo tee /etc/apt/sources.list.d/rocm.list
echo -e "Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" | sudo tee /etc/apt/preferences.d/rocm-pin-600

- name: Install ROCm ${{ env.ROCM_VERSION }}
run: |
sudo ln -f -s /usr/bin/clang-${{ matrix.platform.llvm-version }} /usr/bin/clang
sudo ln -f -s /usr/bin/clang++-${{ matrix.platform.llvm-version }} /usr/bin/clang++
echo "LLVM_CMAKE_DIR=/usr/lib/llvm-${{ matrix.platform.llvm-version }}/cmake" >> $GITHUB_ENV
echo "EXTERNAL_LIT=/usr/lib/llvm-${{ matrix.platform.llvm-version >= 20 && 18 || matrix.platform.llvm-version }}/build/utils/lit/lit.py" >> $GITHUB_ENV
echo "TYPEART_TYPEGEN_IR=${{ matrix.platform.typeart-typegen-legacy }}" >> $GITHUB_ENV
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
rocm-llvm \
rocm-llvm-dev \
rocm-dev

- name: Setup ROCm Environment
run: |
sudo ln -sfn /opt/rocm-${ROCM_VERSION} /opt/rocm
echo "/opt/rocm/llvm/bin" >> $GITHUB_PATH
echo "/opt/rocm/bin" >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/opt/rocm/llvm/lib:/opt/rocm/lib:${LD_LIBRARY_PATH}" >> $GITHUB_ENV

- name: Setup TypeART Environment
uses: ./.github/actions/setup-typeart
with:
llvm-version: 18
typeart-typegen-legacy: 0
install-lcov: 'true'
install-omp: 'false'
setup-mold: 'true'

- name: Configure TypeART
run: cmake -B build --preset ${{ matrix.preset.name }} -DLLVM_DIR=${LLVM_CMAKE_DIR} -DLLVM_EXTERNAL_LIT=${EXTERNAL_LIT}
run: |
cmake -B build --preset ci-cov-thread-safe \
-DCMAKE_C_COMPILER=/opt/rocm/bin/amdclang \
-DCMAKE_CXX_COMPILER=/opt/rocm/bin/amdclang++ \
-DLLVM_DIR=${ROCM_PATH}/llvm/lib/cmake/llvm -DLLVM_EXTERNAL_LIT=${EXTERNAL_LIT} \
-DTYPEART_CLANG_EXEC=/opt/rocm/bin/amdclang \
-DTYPEART_CLANGCXX_EXEC=/opt/rocm/bin/amdclang++ \
-DTYPEART_OPT_EXEC=/opt/rocm/llvm/bin/opt \
-DTYPEART_LLC_EXEC=/opt/rocm/llvm/bin/llc \
-DTYPEART_LLVMCONFIG_COMMAND=/opt/rocm/llvm/bin/llvm-config \
-DCMAKE_DISABLE_FIND_PACKAGE_OpenMP=ON

- name: Build TypeART
run: cmake --build build --parallel 2

- name: Prepare TypeART coverage
if: matrix.preset.coverage
run: cmake --build build --target typeart-lcov-clean

- name: Test TypeART lit-suite
if: matrix.preset.skip_test == false
- name: Test TypeART hip-suite
run: cmake --build build --target check-typeart

- name: Build coverage report
if: matrix.preset.coverage
run: cmake --build build --target typeart-lcov-html

- name: Coveralls (parallel)
if: matrix.preset.coverage
uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: build/typeart.coverage
flag-name: ${{ matrix.preset.name }}-${{ matrix.platform.llvm-version }}-${{ matrix.platform.typeart-typegen-legacy }}
flag-name: hip-suite-rocm-${{ env.ROCM_VERSION }}
parallel: true

finish-coverage:
needs: lit-suite
if: ${{ always() }}
needs: [lit-suite, cuda-suite, hip-suite]
runs-on: ubuntu-24.04
steps:
- name: Coveralls Finished

uses: coverallsapp/github-action@v2.3.6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
parallel-finished: true
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Specifically, `TYPEART_OPTIONS` can globally modify the TypeART pass (stack/heap
| `TYPEART_STACK` | `stack` | `false` | Instrument stack and global allocations. Enables instrumentation of global allocations. |
| `TYPEART_STACK_LIFETIME` | `stack-lifetime` | `true` | Instrument stack `llvm.lifetime.start` instead of `alloca` directly |
| `TYPEART_GLOBAL` | `global` | `false` | Instrument global allocations (see stack). |
| `TYPEART_GPU` | `gpu` | `false` | Instrument GPU allocation/free instructions (HIP and CUDA). |
| `TYPEART_TYPEGEN` | `typegen` | `dimeta` | Values: `dimeta`, `ir`. How serializing of type information is done, see [Section 2.2](#22-serialized-type-information). |
| `TYPEART_TYPE_SERIALIZATION` | `type-serialization` | `hybrid` | Values: `file`, `hybrid`, `inline`. How type information are stored (in the executable or externally), see [Section 2.2](#22-serialized-type-information). |
| `TYPEART_STATS` | `stats` | `false` | Show instrumentation statistic counters |
Expand All @@ -185,6 +186,11 @@ Additionally, there are two debug environment flags for dumping the LLVM IR per

<!--- @formatter:on --->

#### 2.1.1 Passing options via compiler wrapper

The compiler wrappers support passing TypeART options directly via the command line using the `--typeart-<option name>=<value>` syntax. For boolean flags, no assignment value is required to enable them. These options are transformed into the corresponding `TYPEART_<OPTION>=<value>` environment variables by the wrapper. For example, invoking, e.g., `typeart-clang` with `--typeart-gpu` is equivalent to setting `TYPEART_GPU=true` in the environment.



### 2.2 Serialized type information

Expand Down Expand Up @@ -284,7 +290,7 @@ void foo() {

## 3. Building TypeART

TypeART supports LLVM version 14, 18-21, and CMake version >= 3.20.
TypeART supports LLVM version 14, 18-22, and CMake version >= 3.20.

### 3.1 Optional software requirements

Expand Down Expand Up @@ -316,10 +322,10 @@ $> cmake --build build --target install --parallel

<!--- @formatter:off --->

| Option | Default | Description |
|------------------------------|:-------:|----------------------------------------------------------------------------------|
| `TYPEART_MPI_WRAPPER` | `ON` | Install TypeART MPI wrapper (mpic, mpic++). Requires MPI. |
| `TYPEART_USE_LEGACY_WRAPPER` | `OFF` | Use legacy wrapper invoking opt/llc directly instead of Clang's `-fpass-plugin`. |
| Option | Default | Description |
|------------------------------|:-------:|-----------------------------------------------------------------------------------------------|
| `TYPEART_MPI_WRAPPER` | `ON` | Install TypeART MPI wrapper (mpic, mpic++). Requires MPI. |
| `TYPEART_USE_LEGACY_WRAPPER` | `OFF` | (Deprecated) Use legacy wrapper invoking opt/llc directly instead of Clang's `-fpass-plugin`. |


<!--- @formatter:on --->
Expand Down
21 changes: 19 additions & 2 deletions cmake/modules/coverage-lcov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ if(TYPEART_LCOV_EXEC-NOTFOUND OR TYPEART_GENHTML_EXEC-NOTFOUND)
message(WARNING "lcov and genhtml command needed for coverage.")
endif()

# Detect whether lcov supports: --ignore-errors unused:
# - avoids CUDA error "geninfo: ERROR: 'exclude' pattern '*/Version.cpp' is unused"
set(TYPEART_LCOV_IGNORE_UNUSED)
if(TYPEART_LCOV_EXEC)
execute_process(
COMMAND ${TYPEART_LCOV_EXEC} --version
OUTPUT_VARIABLE TYPEART_LCOV_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(TYPEART_LCOV_VERSION_STRING MATCHES "LCOV version ([0-9]+)\\.([0-9]+)")
set(TYPEART_LCOV_VERSION_MAJOR ${CMAKE_MATCH_1})
if(TYPEART_LCOV_VERSION_MAJOR GREATER_EQUAL 2)
set(TYPEART_LCOV_IGNORE_UNUSED --ignore-errors unused)
endif()
endif()
endif()

add_custom_target(
typeart-lcov-clean
COMMAND ${TYPEART_LCOV_EXEC} -d ${CMAKE_BINARY_DIR} -z
Expand All @@ -27,7 +44,7 @@ endif()

add_custom_target(
typeart-lcov-make
COMMAND ${TYPEART_LCOV_EXEC} ${GCOV_TOOL} ${GCOV_WORKAROUND}
COMMAND ${TYPEART_LCOV_EXEC} ${GCOV_TOOL} ${GCOV_WORKAROUND} ${TYPEART_LCOV_IGNORE_UNUSED}
--no-external -c -d ${CMAKE_BINARY_DIR} -b ${CMAKE_SOURCE_DIR} -o typeart.coverage
COMMAND ${TYPEART_LCOV_EXEC} --rc derive_function_end_line=0 --remove typeart.coverage '${CMAKE_BINARY_DIR}/*' -o typeart.coverage
)
Expand All @@ -50,7 +67,7 @@ function(typeart_target_lcov target)

add_custom_target(
typeart-lcov-make-${target}
COMMAND ${TYPEART_LCOV_EXEC} ${GCOV_TOOL} ${GCOV_WORKAROUND}
COMMAND ${TYPEART_LCOV_EXEC} ${GCOV_TOOL} ${GCOV_WORKAROUND} ${TYPEART_LCOV_IGNORE_UNUSED}
--no-external -c -d ${CMAKE_BINARY_DIR}
-b ${LCOV_TARGET_SOURCE_DIR} -o counter-${target}.pro
COMMAND ${TYPEART_LCOV_EXEC} --remove counter-${target}.pro '${CMAKE_BINARY_DIR}/*'
Expand Down
Loading