From ed732e836f65d10ea6a5703f9c24514ddea3f146 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Sat, 12 Jul 2025 19:57:09 +0000 Subject: [PATCH 01/30] Update omniprobe and nexus repos for https clone Signed-off-by: coleramos425 --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d97e16c9..23d25b0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,8 +39,8 @@ python3 -m pip install -r requirements.txt [tool.omniprobe] -git = "git@github.com:AMDResearch/omniprobe.git" -branch = "9083730ab0da50114c767773df49cb1d2165ba7f" +git = "https://github.com/AMDResearch/omniprobe.git" +branch = "47e7e9ac1e8daba5fd35797e950e44ba2b20e0ce" build_command = """ export CC=${ROCM_PATH}/bin/hipcc export CXX=${ROCM_PATH}/bin/hipcc @@ -61,7 +61,7 @@ cmake --install build [tool.nexus] -git = "git@github.com:AMDResearch/nexus.git" +git = "https://github.com/AMDResearch/nexus" branch = "main" build_command = """ export CC=${ROCM_PATH}/bin/hipcc From 156934c50fe579929f26657d03f47e193f654cc3 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Sat, 12 Jul 2025 19:59:29 +0000 Subject: [PATCH 02/30] Remove all old container assets for redesign Signed-off-by: coleramos425 --- apptainer/build.sh | 69 ------------------------ apptainer/intelliperf.def | 98 ----------------------------------- apptainer/run.sh | 67 ------------------------ apptainer/run_cmd.sh | 78 ---------------------------- docker/build.sh | 80 ---------------------------- docker/intelliperf.Dockerfile | 37 ------------- docker/run.sh | 40 -------------- 7 files changed, 469 deletions(-) delete mode 100755 apptainer/build.sh delete mode 100644 apptainer/intelliperf.def delete mode 100755 apptainer/run.sh delete mode 100755 apptainer/run_cmd.sh delete mode 100755 docker/build.sh delete mode 100644 docker/intelliperf.Dockerfile delete mode 100755 docker/run.sh diff --git a/apptainer/build.sh b/apptainer/build.sh deleted file mode 100755 index 6fc89cca..00000000 --- a/apptainer/build.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash -################################################################################ -# MIT License - -# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -################################################################################ - -debug=0 - -while [[ $# -gt 0 ]]; do - case $1 in - -d|--debug) - debug=1 - shift - ;; - *) - echo "Usage: $0 [-d|--debug]" - exit 1 - ;; - esac -done - - -# Auto config SSH agent -if [ ! -S ~/.ssh/ssh_auth_sock ]; then - eval `ssh-agent` > /dev/null - ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock -fi -export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock -[ -f ~/.ssh/id_rsa ] && ssh-add ~/.ssh/id_rsa -[ -f ~/.ssh/id_ed25519 ] && ssh-add ~/.ssh/id_ed25519 - -ssh_auth_sock_path=$(readlink -f "$SSH_AUTH_SOCK") -# Build the Singularity container -# --build-arg SSH_AUTH_SOCK=$SSH_AUTH_SOCK is used to pass the SSH agent socket to the container -# (advantage of this method is that the key is at no point copied to the container image.) -# If your SSH_AUTH_SOCK will not already bound to the container, and is available at /run/..., add `--bind /run` to the build command -definition="apptainer/intelliperf.def" - -if [[ $debug -eq 1 ]]; then - image="apptainer/intelliperf_debug.sif" - cmake_build_type="Debug" -else - image="apptainer/intelliperf.sif" - cmake_build_type="Release" -fi - -apptainer build \ - --build-arg SSH_AUTH_SOCK=${ssh_auth_sock_path} \ - --build-arg CMAKE_BUILD_TYPE=${cmake_build_type}\ - $image $definition \ No newline at end of file diff --git a/apptainer/intelliperf.def b/apptainer/intelliperf.def deleted file mode 100644 index 28c6d4af..00000000 --- a/apptainer/intelliperf.def +++ /dev/null @@ -1,98 +0,0 @@ -Bootstrap: docker -From: ubuntu:22.04 - -%environment - # Locale - export LANG=en_US.UTF-8 - - # ROCm globals - export PATH=/opt/rocm/bin:$PATH - export LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH - export ROCM_PATH=/opt/rocm - - # Misc globals - export GT_TUNING=/root/guided-tuning - export PATH=/opt/omniprobe/bin/logDuration:$PATH - export PATH=/root/rocprofiler-compute/src:$PATH - -%files - examples/bank_conflict/llm.c/requirements.txt /examples/bank_conflict/llm.c/requirements.txt - -%post - # Set locale - apt-get -y update - apt-get install -y locales - locale-gen en_US.UTF-8 - export LANG=en_US.UTF-8 - - # Install dependencies - apt-get -y update - apt-get install -y software-properties-common - apt-get upgrade -y - apt-get install -y build-essential python3 python3-pip python3-setuptools python3-wheel git wget clang lld libzstd-dev libomp-dev vim libdwarf-dev - apt-get install -y locales - locale-gen en_US.UTF-8 - python3 -m pip install --upgrade pip - python3 -m pip install 'cmake==3.22' - - # Add GitHub trusted host - mkdir -p ~/.ssh - touch ~/.ssh/known_hosts - ssh-keyscan github.com >> ~/.ssh/known_hosts - chmod 700 ~/.ssh - chmod 644 ~/.ssh/known_hosts - - # Install ROCm - apt-get -y update - wget https://repo.radeon.com/amdgpu-install/6.3.3/ubuntu/jammy/amdgpu-install_6.3.60303-1_all.deb - apt-get -y install ./amdgpu-install_6.3.60303-1_all.deb - apt-get -y update - apt-get install -y rocm-dev rocm-llvm-dev rocm-hip-runtime-dev rocm-smi-lib rocminfo rocthrust-dev rocprofiler-compute rocblas rocm-gdb gdb tmux - export PATH=/opt/rocm/bin:$PATH - export LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH - export ROCM_PATH=/opt/rocm - - # Install rocprof-compute (via package manager) - # python3 -m pip install --ignore-installed blinker - # python3 -m pip install -r /opt/rocm/libexec/rocprofiler-compute/requirements.txt - # Install rocprof-compute (from feature branch) - export SSH_AUTH_SOCK={{ SSH_AUTH_SOCK }} - cd /root - git clone -v https://github.com/ROCm/rocprofiler-compute.git - cd rocprofiler-compute - git checkout 41e73650d5cfc3dbd98e007d6279235578f8529a - python3 -m pip install --ignore-installed blinker - python3 -m pip install -r requirements.txt - cd src - export PATH=$PWD:$PATH - - # Install Triton (version pinned) - cd /root - export TRITON_HOME=/root - git clone -v https://github.com/triton-lang/triton.git - cd triton - git checkout 6fa33ef1eecc97348d056688df84845db7d22507 - python3 -m pip install ninja wheel pybind11 - python3 -m pip install -e python - - # Install omniprobe - echo "Building with CMAKE_BUILD_TYPE={{ CMAKE_BUILD_TYPE }}" - cd /root - git clone -v git@github.com:AARInternal/omniprobe.git - cd omniprobe - git checkout 9083730ab0da50114c767773df49cb1d2165ba7f - git submodule update --init --recursive - mkdir -p build - cmake -DCMAKE_INSTALL_PREFIX=/opt/omniprobe\ - -DCMAKE_PREFIX_PATH=${ROCM_PATH}\ - -DTRITON_LLVM=/root/.triton/llvm/llvm-ubuntu-x64\ - -DCMAKE_BUILD_TYPE={{ CMAKE_BUILD_TYPE }}\ - -DCMAKE_VERBOSE_MAKEFILE=ON -S . -B build - cmake --build build --target install - export PATH=/opt/omniprobe/bin/logDuration:$PATH - - # Install agents dependencies - python3 -m pip install openai - - # Install examples dependencies - pip3 install --no-cache-dir -r /examples/bank_conflict/llm.c/requirements.txt diff --git a/apptainer/run.sh b/apptainer/run.sh deleted file mode 100755 index 9eb9f0d7..00000000 --- a/apptainer/run.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -################################################################################ -# MIT License - -# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -################################################################################ - -script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -parent_dir="$(dirname "$script_dir")" -working_dir=$(pwd) - -cd $parent_dir - -size=2048 -debug=0 - -while [[ $# -gt 0 ]]; do - case $1 in - -s) - size=$2 - shift 2 - ;; - -d|--debug) - debug=1 - shift - ;; - *) - echo "Usage: $0 [-s size] [-d|--debug]" - exit 1 - ;; - esac -done -workload=$(date +"%Y%m%d%H%M%S") -overlay="/tmp/intelliperf_overlay_$(whoami)_$workload.img" -if [ ! -f $overlay ]; then - echo "[Log] Overlay image ${overlay} does not exist. Creating overlay of ${size} MiB..." - apptainer overlay create --size ${size} --create-dir /var/cache/intelliperf ${overlay} -else - echo "[Log] Overlay image ${overlay} already exists. Using this one." -fi -echo "[Log] Utilize the directory /var/cache/intelliperf as a sandbox to store data you'd like to persist between container runs." - -# Run the container -if [[ $debug -eq 1 ]]; then - image="apptainer/intelliperf_debug.sif" -else - image="apptainer/intelliperf.sif" -fi -apptainer exec --bind $HOME/.ssh:/root/.ssh:ro --overlay ${overlay} --pwd "$working_dir" --cleanenv --env OPENAI_API_KEY=$OPENAI_API_KEY $image bash --rcfile /etc/bash.bashrc diff --git a/apptainer/run_cmd.sh b/apptainer/run_cmd.sh deleted file mode 100755 index 928eab38..00000000 --- a/apptainer/run_cmd.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash -################################################################################ -# MIT License - -# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -################################################################################ - -script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -parent_dir="$(dirname "$script_dir")" - -cd $parent_dir - -size=2048 -cmd="" -debug=0 - -while [[ $# -gt 0 ]]; do - case $1 in - -s) - size=$2 - shift 2 - ;; - --cmd) - cmd=$2 - shift 2 - ;; - -d|--debug) - debug=1 - shift - ;; - *) - echo "Usage: $0 [-s size] --cmd '' [-d|--debug]" - exit 1 - ;; - esac -done - -workload=$(date +"%Y%m%d%H%M%S") - -# Create filesystem image overlay, if it doesn't exist -overlay="/tmp/intelliperf_overlay_$(whoami)_$workload.img" -if [ ! -f $overlay ]; then - echo "[Log] Overlay image ${overlay} does not exist. Creating overlay of ${size} MiB..." - apptainer overlay create --size ${size} --create-dir /var/cache/intelliperf ${overlay} -else - echo "[Log] Overlay image ${overlay} already exists. Using this one." -fi -echo "[Log] Utilize the directory /var/cache/intelliperf as a sandbox to store data you'd like to persist between container runs." - -# Run the container -if [[ $debug -eq 1 ]]; then - image="apptainer/intelliperf_debug.sif" -else - image="apptainer/intelliperf.sif" -fi -echo "cmd: $cmd" -apptainer exec --overlay "${overlay}"\ - --cleanenv --env OPENAI_API_KEY="$OPENAI_API_KEY"\ - "$image" bash --rcfile /etc/bash.bashrc\ - -c "cd src && eval \"$cmd\"" \ No newline at end of file diff --git a/docker/build.sh b/docker/build.sh deleted file mode 100755 index c91ac2cd..00000000 --- a/docker/build.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash -################################################################################ -# MIT License - -# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -################################################################################ - -# Parse command line arguments -dev_mode=false -while [[ $# -gt 0 ]]; do - case $1 in - --dev|-d) - dev_mode=true - shift - ;; - *) - echo "Unknown option: $1" - exit 1 - ;; - esac -done - -# Container name -name="intelliperf" - -# Script directories -script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -parent_dir="$(dirname "$script_dir")" -cur_dir=$(pwd) - -# Set INTELLIPERF_HOME based on dev mode -if [ "$dev_mode" = true ]; then - intelliperf_home="$cur_dir" -else - intelliperf_home="/intelliperf" -fi - -pushd "$script_dir" - -# Auto-configure SSH agent -if [ ! -S ~/.ssh/ssh_auth_sock ]; then - eval "$(ssh-agent)" > /dev/null - ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock -fi -export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock - -# Add default keys if they exist -[ -f ~/.ssh/id_rsa ] && ssh-add ~/.ssh/id_rsa -[ -f ~/.ssh/id_ed25519 ] && ssh-add ~/.ssh/id_ed25519 -[ -f ~/.ssh/id_github ] && ssh-add ~/.ssh/id_github - -# Enable BuildKit and build the Docker image -export DOCKER_BUILDKIT=1 -docker build \ - --ssh default \ - -t "$name" \ - --build-arg DEV_MODE="$dev_mode" \ - --build-arg INTELLIPERF_HOME="$intelliperf_home" \ - -f "$script_dir/intelliperf.Dockerfile" \ - . - -popd diff --git a/docker/intelliperf.Dockerfile b/docker/intelliperf.Dockerfile deleted file mode 100644 index b7a3adc2..00000000 --- a/docker/intelliperf.Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -# syntax=docker/dockerfile:1.4 - -FROM rocm/vllm-dev:nightly_aiter_integration_final_20250325 - -ARG DEV_MODE=false -ARG INTELLIPERF_HOME=/intelliperf - -ENV LANG=en_US.UTF-8 -ENV PATH=/opt/rocm/bin:$PATH - -# Install dependencies -RUN apt-get update && apt-get install -y \ - libzstd-dev \ - python3-setuptools \ - python3-wheel \ - libdwarf-dev \ - rocm-llvm-dev\ - locales \ - gdb \ - && locale-gen en_US.UTF-8 - -# Add GitHub trusted host -RUN mkdir -p ~/.ssh && \ - touch ~/.ssh/known_hosts && \ - ssh-keyscan github.com >> ~/.ssh/known_hosts && \ - chmod 700 ~/.ssh && \ - chmod 644 ~/.ssh/known_hosts - -# Set the working directory -WORKDIR $INTELLIPERF_HOME - -# Clone IntelliPerf only in non-dev mode -RUN --mount=type=ssh bash -c 'if [ "$DEV_MODE" = "false" ]; then \ - git clone git@github.com:AMDResearch/intelliperf.git . ; \ - pip install -e .; \ - python3 scripts/install_tool.py --all; \ - fi' diff --git a/docker/run.sh b/docker/run.sh deleted file mode 100755 index 4f4ecdae..00000000 --- a/docker/run.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -################################################################################ -# MIT License - -# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: - -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -################################################################################ - -name="intelliperf" - -docker run -it --rm \ - --name "$name" \ - --device=/dev/kfd \ - --device=/dev/dri \ - --group-add video \ - -v $HOME/.ssh:/tmp/ssh:ro \ - -v $(pwd):$(pwd) \ - -w $(pwd) \ - -e LLM_GATEWAY_KEY="$LLM_GATEWAY_KEY" \ - -e SSH_AUTH_SOCK="$SSH_AUTH_SOCK" \ - -v $SSH_AUTH_SOCK:$SSH_AUTH_SOCK \ - "$name" \ - bash -c "cp -r /tmp/ssh/* /root/.ssh/ 2>/dev/null || true && chown -R root:root /root/.ssh && chmod 700 /root/.ssh && chmod 600 /root/.ssh/config /root/.ssh/id_* /root/.ssh/known_hosts 2>/dev/null || true; exec bash" From 6fc1af26818a19f7a566ac4ad00f8a52fec6d76c Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Sat, 12 Jul 2025 20:00:57 +0000 Subject: [PATCH 03/30] Redesigned container support. Everything is centerally located and consolidated into a single run.sh script Signed-off-by: coleramos425 --- containers/build.sh | 74 +++++++++++++++ containers/intelliperf.Dockerfile | 28 ++++++ containers/intelliperf.def | 37 ++++++++ containers/run.sh | 146 ++++++++++++++++++++++++++++++ 4 files changed, 285 insertions(+) create mode 100755 containers/build.sh create mode 100644 containers/intelliperf.Dockerfile create mode 100644 containers/intelliperf.def create mode 100755 containers/run.sh diff --git a/containers/build.sh b/containers/build.sh new file mode 100755 index 00000000..854b8fec --- /dev/null +++ b/containers/build.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Container name +name="intelliperf" + +# Script directories +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +parent_dir="$(dirname "$script_dir")" +cur_dir=$(pwd) + +# Parse arguments +build_docker=false +build_apptainer=false + +while [[ $# -gt 0 ]]; do + case $1 in + --apptainer) + build_apptainer=true + shift + ;; + --docker) + build_docker=true + shift + ;; + *) + echo "Unknown option: $1" + echo "Usage: $0 [--docker] [--apptainer] -- Exactly one option is required." + exit 1 + ;; + esac +done + +if [ "$build_docker" = false ] && [ "$build_apptainer" = false ]; then + echo "Error: At least one of the options --docker or --apptainer is required." + echo "Usage: $0 [--docker] [--apptainer]" + echo " --docker Build Docker container" + echo " --apptainer Build Apptainer container" + exit 1 +fi + +pushd "$parent_dir" + +if [ "$build_docker" = true ]; then + echo "Building Docker container..." + + # Enable BuildKit and build the Docker image + export DOCKER_BUILDKIT=1 + docker build \ + -t "$name:$(cat "$parent_dir/VERSION")" \ + -f "$script_dir/intelliperf.Dockerfile" \ + . + + echo "Docker build complete!" +fi + +if [ "$build_apptainer" = true ]; then + echo "Building Apptainer container..." + + # Check if apptainer is installed + if ! command -v apptainer &> /dev/null; then + echo "Error: Apptainer is not installed or not in PATH" + echo "Please install Apptainer first: https://apptainer.org/docs/admin/main/installation.html" + exit 1 + fi + + # Build the Apptainer container with ROCm version + export ROCM_VERSION="$rocm_version" + apptainer build \ + "${script_dir}/${name}_$(cat "$parent_dir/VERSION").sif" "$script_dir/intelliperf.def" + + echo "Apptainer build complete!" +fi + +popd \ No newline at end of file diff --git a/containers/intelliperf.Dockerfile b/containers/intelliperf.Dockerfile new file mode 100644 index 00000000..26729ee8 --- /dev/null +++ b/containers/intelliperf.Dockerfile @@ -0,0 +1,28 @@ +# syntax=docker/dockerfile:1.4 + +FROM rocm/vllm-dev:nightly_aiter_integration_final_20250325 + +ARG DEV_MODE=false +ARG INTELLIPERF_HOME=/intelliperf + +ENV LANG=en_US.UTF-8 +ENV PATH=/opt/rocm/bin:$PATH + +# Install dependencies +RUN apt-get update && apt-get install -y \ + libzstd-dev \ + python3-setuptools \ + python3-wheel \ + libdwarf-dev \ + rocm-llvm-dev\ + locales \ + gdb \ + && locale-gen en_US.UTF-8 + +# Set the working directory +WORKDIR $INTELLIPERF_HOME +COPY ../ $INTELLIPERF_HOME + +# Install tool +RUN pip install -e && \ + python3 scripts/install_tool.py --all diff --git a/containers/intelliperf.def b/containers/intelliperf.def new file mode 100644 index 00000000..077a2cdb --- /dev/null +++ b/containers/intelliperf.def @@ -0,0 +1,37 @@ +Bootstrap: docker +From: rocm/vllm-dev:nightly_aiter_integration_final_20250325 + +%arguments + INTELLIPERF_HOME=/intelliperf + +%environment + # Runtime environment inside the finished SIF + export LANG=en_US.UTF-8 + export PATH=/opt/rocm/bin:$PATH + export INTELLIPERF_HOME={{ INTELLIPERF_HOME }} + +%files + . /intelliperf + +%post + PATH=/opt/rocm/bin:$PATH + INTELLIPERF_HOME={{ INTELLIPERF_HOME }} + + mkdir -p "${INTELLIPERF_HOME}" + + apt-get update + apt-get install -y --no-install-recommends \ + libzstd-dev \ + python3-setuptools \ + python3-wheel \ + libdwarf-dev \ + rocm-llvm-dev \ + locales \ + gdb \ + ssh + locale-gen en_US.UTF-8 + rm -rf /var/lib/apt/lists/* + + cd "${INTELLIPERF_HOME}" + pip install -e . + python3 scripts/install_tool.py --all \ No newline at end of file diff --git a/containers/run.sh b/containers/run.sh new file mode 100755 index 00000000..d6af6dca --- /dev/null +++ b/containers/run.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +# Supports both Docker and Apptainer with automatic building + +# Container name +name="intelliperf" + +# Script directories +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +parent_dir="$(dirname "$script_dir")" + +# Parse arguments +use_docker=false +use_apptainer=false +overlay_size=2048 + +while [[ $# -gt 0 ]]; do + case $1 in + --docker) + use_docker=true + shift + ;; + --apptainer) + use_apptainer=true + shift + ;; + -s|--overlay-size) + overlay_size=$2 + shift 2 + ;; + *) + echo "Unknown option: $1" + echo "Usage: $0 [--docker] [--apptainer] [-s|--overlay-size SIZE] -- Exactly one option is required." + echo " -s, --overlay-size SIZE Size of overlay filesystem in MiB (default: 2048, Apptainer only)" + exit 1 + ;; + esac +done + +# Validate arguments +if [ "$use_docker" = true ] && [ "$use_apptainer" = true ]; then + echo "Error: Cannot use both --docker and --apptainer simultaneously." + echo "Usage: $0 [--docker] [--apptainer]" + exit 1 +elif [ "$use_docker" = false ] && [ "$use_apptainer" = false ]; then + echo "Error: Must specify either --docker or --apptainer." + echo "Usage: $0 [--docker] [--apptainer]" + echo " --docker Run using Docker container" + echo " --apptainer Run using Apptainer container" + exit 1 +fi + +echo "Starting intelliperf container..." +echo "Project directory will be mounted at $(pwd)" +echo "Any files you create/modify will persist after the container closes." +echo "" + +if [ "$use_docker" = true ]; then + echo "Using Docker containerization..." + + # Check if the Docker image exists + if ! docker image inspect "$name:$(cat "$parent_dir/VERSION")" > /dev/null 2>&1; then + echo "Docker image $name:$(cat "$parent_dir/VERSION") not found." + echo "Building Docker image..." + echo "" + + if ! "$script_dir/build.sh" --docker; then + echo "Error: Failed to build Docker image." + exit 1 + fi + + echo "" + echo "Docker image built successfully!" + else + echo "Docker image found." + fi + + # Run the Docker container + echo "Running Docker container with project directory mounted..." + docker run -it --rm \ + --device=/dev/kfd \ + --device=/dev/dri \ + --group-add video \ + --cap-add=SYS_PTRACE \ + --security-opt seccomp=unconfined \ + -e LLM_GATEWAY_KEY="$LLM_GATEWAY_KEY" \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + "$name:$(cat "$parent_dir/VERSION")" + +elif [ "$use_apptainer" = true ]; then + echo "Using Apptainer containerization..." + + # Check if apptainer is installed + if ! command -v apptainer &> /dev/null; then + echo "Error: Apptainer is not installed or not in PATH" + echo "Please install Apptainer first: https://apptainer.org/docs/admin/main/installation.html" + exit 1 + fi + + # Apptainer image filename + apptainer_image="$script_dir/${name}_$(cat "$parent_dir/VERSION").sif" + + # Check if the Apptainer image exists + if [ ! -f "$apptainer_image" ]; then + echo "Apptainer image $apptainer_image not found." + echo "Building Apptainer image automatically..." + echo "" + + if ! "$script_dir/build.sh" --apptainer; then + echo "Error: Failed to build Apptainer image." + exit 1 + fi + + echo "" + echo "Apptainer image built successfully!" + else + echo "Apptainer image found." + fi + + # Create overlay filesystem for writable areas + workload=$(date +"%Y%m%d%H%M%S") + overlay="/tmp/intelliperf_overlay_$(whoami)_$workload.img" + if [ ! -f "$overlay" ]; then + echo "[Log] Overlay image ${overlay} does not exist. Creating overlay of ${overlay_size} MiB..." + apptainer overlay create --size ${overlay_size} --create-dir /var/cache/intelliperf ${overlay} + else + echo "[Log] Overlay image ${overlay} already exists. Using this one." + fi + echo "[Log] Overlay filesystem provides writable areas for profiling tools." + echo "[Log] Use /var/cache/intelliperf as a sandbox for persistent data between container runs." + + # Run the Apptainer container + echo "Running Apptainer container with project directory mounted..." + cd "$parent_dir" + apptainer exec \ + --cleanenv \ + --pwd $(pwd) \ + --overlay ${overlay} \ + --env LLM_GATEWAY_KEY=$LLM_GATEWAY_KEY \ + "$apptainer_image" \ + /bin/bash \ + --rcfile /etc/bashrc +fi + +echo "Container session ended." \ No newline at end of file From 6bd8ef490fe5f44d9cfb7b51ce050b328c5ea01d Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Sat, 12 Jul 2025 20:02:04 +0000 Subject: [PATCH 04/30] Update README to reflect new container usage Signed-off-by: coleramos425 --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 21d0fec3..d9c5a8d9 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,21 @@ This is not a product. Use it at your own risk and discretion. We provide both Apptainer and Docker images for easy setup: -#### Using Apptainer -```bash -./apptainer/build.sh -./apptainer/run.sh -``` -#### Using Docker -```bash -./docker/build.sh -./docker/run.sh +```console +$ ./containers/run.sh +Must specify either --docker or --apptainer. +Usage: ./containers/run.sh [--docker] [--apptainer] + --docker Run using Docker container + --apptainer Run using Apptainer container ``` + +That's it! The run script will: + +- ✅ Automatically build the container if it doesn't exist +- ✅ Mount your project directory to the container +- ✅ Start an interactive session where you can run IntelliPerf +- ✅ Persist all output files to your host machine + #### For baremetal installation From a874cb5503573bdf8832e99c442f86d2731614f1 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Sat, 12 Jul 2025 20:03:05 +0000 Subject: [PATCH 05/30] Adding a VERSION file so containers (eventually to be published) can have some notion of versioning Signed-off-by: coleramos425 --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..6c6aa7cb --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 \ No newline at end of file From e2f40fcd6c636acbcf77849aaf9be84193ba3cd5 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Mon, 14 Jul 2025 13:37:39 +0000 Subject: [PATCH 06/30] Enable instrumentation for bankConflict plugin Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 3486b2c7..87288220 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -124,12 +124,6 @@ def instrument_pass(self) -> Result: """ super().instrument_pass() - return Result( - success=False, - asset=self._instrumentation_results, - error_report="Instrumentation pass not implemented for bank conflict.", - ) - # Always instrument the first kernel kernel_to_instrument = self.get_top_kernel() if kernel_to_instrument is None: @@ -138,11 +132,11 @@ def instrument_pass(self) -> Result: error_report="No source code found. Please compile your code with -g.", ) - omniprobe_output_dir = os.path.join(self._application.get_project_directory(), "memory_analysis_output") + omniprobe_output_file = os.path.join(self._application.get_project_directory(), "memory_analysis_output.json") - # Remove directory if it exists and create a new one - if os.path.exists(omniprobe_output_dir): - shutil.rmtree(omniprobe_output_dir) + # Remove file if it exists before running omniprobe + if os.path.exists(omniprobe_output_file): + os.remove(omniprobe_output_file) ecma_regex = generate_ecma_regex_from_list([kernel_to_instrument]) logging.debug(f"ECMA Regex for kernel names: {ecma_regex}") @@ -156,6 +150,8 @@ def instrument_pass(self) -> Result: "MemoryAnalysis", "--kernels", ecma_regex, + "--log-format", "json", + "--log-location", omniprobe_output_file, "--", " ".join(self._application.get_app_cmd()), ], @@ -170,10 +166,9 @@ def instrument_pass(self) -> Result: # Try loading the memory analysis output # Find all files in the memory_analysis_output directory - output_files = glob.glob(os.path.join(omniprobe_output_dir, "memory_analysis_*.json")) - if len(output_files) == 0: - return Result(success=False, error_report="No memory analysis output files found.") - output_file = output_files[0] + output_file = omniprobe_output_file + if not os.path.exists(output_file): + return Result(success=False, error_report="Memory analysis output file not found.") try: with open(output_file, "r") as f: self._instrumentation_results = json.load(f) @@ -416,3 +411,4 @@ def summarize_previous_passes(self): Summarizes the results of the previous passes for future prompts. """ pass + From 575b9883e94c2e2f084f92c1a3dab73333bb319c Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Mon, 14 Jul 2025 13:38:10 +0000 Subject: [PATCH 07/30] Fix small typo in Dockerfile project install Signed-off-by: coleramos425 --- containers/intelliperf.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/containers/intelliperf.Dockerfile b/containers/intelliperf.Dockerfile index 26729ee8..1a596cdc 100644 --- a/containers/intelliperf.Dockerfile +++ b/containers/intelliperf.Dockerfile @@ -24,5 +24,5 @@ WORKDIR $INTELLIPERF_HOME COPY ../ $INTELLIPERF_HOME # Install tool -RUN pip install -e && \ +RUN pip install -e . && \ python3 scripts/install_tool.py --all From b8d19ea9f3072ac741fc88c20fe0a239c98a060c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 14 Jul 2025 13:39:01 +0000 Subject: [PATCH 08/30] Apply Ruff auto-fixes --- src/intelliperf/formulas/bank_conflict.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 87288220..ec73a141 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -22,11 +22,9 @@ # SOFTWARE. ################################################################################ -import glob import json import logging import os -import shutil from intelliperf.core.llm import LLM from intelliperf.formulas.formula_base import ( @@ -150,8 +148,10 @@ def instrument_pass(self) -> Result: "MemoryAnalysis", "--kernels", ecma_regex, - "--log-format", "json", - "--log-location", omniprobe_output_file, + "--log-format", + "json", + "--log-location", + omniprobe_output_file, "--", " ".join(self._application.get_app_cmd()), ], @@ -411,4 +411,3 @@ def summarize_previous_passes(self): Summarizes the results of the previous passes for future prompts. """ pass - From 4b1b3f4fe3b1226d244e496635c03222108cb36b Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 15 Jul 2025 19:42:30 +0000 Subject: [PATCH 09/30] Accept shorthand params on container build scripts Signed-off-by: coleramos425 --- README.md | 2 +- containers/build.sh | 10 +++++----- containers/run.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d9c5a8d9..50342838 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ We provide both Apptainer and Docker images for easy setup: ```console $ ./containers/run.sh Must specify either --docker or --apptainer. -Usage: ./containers/run.sh [--docker] [--apptainer] +Usage: ./containers/run.sh [--docker|-d] [--apptainer|-a] --docker Run using Docker container --apptainer Run using Apptainer container ``` diff --git a/containers/build.sh b/containers/build.sh index 854b8fec..ee84a5ec 100755 --- a/containers/build.sh +++ b/containers/build.sh @@ -14,17 +14,17 @@ build_apptainer=false while [[ $# -gt 0 ]]; do case $1 in - --apptainer) - build_apptainer=true + --docker|-d) + use_docker=true shift ;; - --docker) - build_docker=true + --apptainer|-a) + use_apptainer=true shift ;; *) echo "Unknown option: $1" - echo "Usage: $0 [--docker] [--apptainer] -- Exactly one option is required." + echo "Usage: $0 [--docker|-d] [--apptainer|-a] -- Exactly one option is required." exit 1 ;; esac diff --git a/containers/run.sh b/containers/run.sh index d6af6dca..39bee16d 100755 --- a/containers/run.sh +++ b/containers/run.sh @@ -16,11 +16,11 @@ overlay_size=2048 while [[ $# -gt 0 ]]; do case $1 in - --docker) + --docker|-d) use_docker=true shift ;; - --apptainer) + --apptainer|-a) use_apptainer=true shift ;; @@ -30,7 +30,7 @@ while [[ $# -gt 0 ]]; do ;; *) echo "Unknown option: $1" - echo "Usage: $0 [--docker] [--apptainer] [-s|--overlay-size SIZE] -- Exactly one option is required." + echo "Usage: $0 [--docker|-d] [--apptainer|-a] [-s|--overlay-size SIZE] -- Exactly one option is required." echo " -s, --overlay-size SIZE Size of overlay filesystem in MiB (default: 2048, Apptainer only)" exit 1 ;; From 55dddbdfc2bf70bcfd84b453f4adaaff34d67d5e Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 15 Jul 2025 20:08:00 +0000 Subject: [PATCH 10/30] Install omniprobe python packages Signed-off-by: coleramos425 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 23d25b0f..1850ac43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ build_command = """ export CC=${ROCM_PATH}/bin/hipcc export CXX=${ROCM_PATH}/bin/hipcc git submodule update --init --recursive +python3 -m pip install omniprobe/requirements.txt #TODO: search for a Triton LLVM. if [ -d "/root/.triton/llvm/llvm-ubuntu-x64" ]; then export TRITON_LLVM_PATH="/root/.triton/llvm/llvm-ubuntu-x64" From e899e094ac174c7024b145ad2b2417b835c75878 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 15 Jul 2025 20:10:08 +0000 Subject: [PATCH 11/30] Add get_omniprobe_path() helper for path resolution Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 7 +++++-- src/intelliperf/utils/env.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index ec73a141..225507b6 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -33,7 +33,10 @@ filter_json_field, get_kernel_name, ) -from intelliperf.utils.env import get_llm_api_key +from intelliperf.utils.env import ( + get_llm_api_key, + get_omniprobe_path, +) from intelliperf.utils.process import capture_subprocess_output from intelliperf.utils.regex import generate_ecma_regex_from_list @@ -142,7 +145,7 @@ def instrument_pass(self) -> Result: logging.debug(f"Omniprobe profiling command is: {cmd}") success, output = capture_subprocess_output( [ - "omniprobe", + get_omniprobe_path(), "--instrumented", "--analyzers", "MemoryAnalysis", diff --git a/src/intelliperf/utils/env.py b/src/intelliperf/utils/env.py index 996d21ed..df986496 100644 --- a/src/intelliperf/utils/env.py +++ b/src/intelliperf/utils/env.py @@ -27,6 +27,10 @@ from intelliperf.utils.process import exit_on_fail +def get_omniprobe_path(): + if os.environ.get("OMNIPROBE_PATH"): + return Path(os.environ["OMNIPROBE_PATH"]).resolve() + return (Path(__file__).resolve().parent / "../../../external/omniprobe/install/bin/logDuration/omniprobe").resolve() def get_guided_tuning_path(): if os.environ.get("GT_TUNING"): From bc028f2e706165e6f1c3479989a07669d7b917eb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 15 Jul 2025 20:10:40 +0000 Subject: [PATCH 12/30] Apply Ruff auto-fixes --- src/intelliperf/formulas/bank_conflict.py | 2 +- src/intelliperf/utils/env.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 225507b6..7d14309f 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -34,7 +34,7 @@ get_kernel_name, ) from intelliperf.utils.env import ( - get_llm_api_key, + get_llm_api_key, get_omniprobe_path, ) from intelliperf.utils.process import capture_subprocess_output diff --git a/src/intelliperf/utils/env.py b/src/intelliperf/utils/env.py index df986496..f728e855 100644 --- a/src/intelliperf/utils/env.py +++ b/src/intelliperf/utils/env.py @@ -27,11 +27,13 @@ from intelliperf.utils.process import exit_on_fail + def get_omniprobe_path(): if os.environ.get("OMNIPROBE_PATH"): return Path(os.environ["OMNIPROBE_PATH"]).resolve() return (Path(__file__).resolve().parent / "../../../external/omniprobe/install/bin/logDuration/omniprobe").resolve() + def get_guided_tuning_path(): if os.environ.get("GT_TUNING"): return Path(os.environ["GT_TUNING"]).resolve() From a437db464de21f4bb2bcae539146122e3a216da0 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 15 Jul 2025 20:29:11 +0000 Subject: [PATCH 13/30] Fix typo int build script Signed-off-by: coleramos425 --- containers/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/containers/build.sh b/containers/build.sh index ee84a5ec..0a614c61 100755 --- a/containers/build.sh +++ b/containers/build.sh @@ -15,11 +15,11 @@ build_apptainer=false while [[ $# -gt 0 ]]; do case $1 in --docker|-d) - use_docker=true + build_docker=true shift ;; --apptainer|-a) - use_apptainer=true + build_apptainer=true shift ;; *) From 24c44365a8e1036f554cb9fe8f9c671e6c8e8eca Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 15 Jul 2025 20:29:17 +0000 Subject: [PATCH 14/30] get_omniprobe_path() needs to be cast to str Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 7d14309f..faf32a44 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -145,7 +145,7 @@ def instrument_pass(self) -> Result: logging.debug(f"Omniprobe profiling command is: {cmd}") success, output = capture_subprocess_output( [ - get_omniprobe_path(), + str(get_omniprobe_path()), "--instrumented", "--analyzers", "MemoryAnalysis", From 5593c02399580ea30bf120a52fb77b2bb5ec3b1e Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 29 Jul 2025 18:06:49 +0000 Subject: [PATCH 15/30] Update commit hash in omniprobe and recursivly install python requirements Signed-off-by: coleramos425 --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1850ac43..ad3ac8ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,12 +40,12 @@ python3 -m pip install -r requirements.txt [tool.omniprobe] git = "https://github.com/AMDResearch/omniprobe.git" -branch = "47e7e9ac1e8daba5fd35797e950e44ba2b20e0ce" +branch = "4eb1b3d49b83f2d50823525e073eea356661e871" build_command = """ export CC=${ROCM_PATH}/bin/hipcc export CXX=${ROCM_PATH}/bin/hipcc git submodule update --init --recursive -python3 -m pip install omniprobe/requirements.txt +python3 -m pip install -r omniprobe/requirements.txt #TODO: search for a Triton LLVM. if [ -d "/root/.triton/llvm/llvm-ubuntu-x64" ]; then export TRITON_LLVM_PATH="/root/.triton/llvm/llvm-ubuntu-x64" From f7687d89377af78e03d690851fdecaef2e8257a0 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 29 Jul 2025 18:07:27 +0000 Subject: [PATCH 16/30] Update optimize pass in bank conflict to use instrumentation results Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 38 ++++++++--------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index faf32a44..4401d632 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -219,34 +219,23 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res provider=provider, ) - kernel_to_optimize = self.get_top_kernel() - if kernel_to_optimize is None: - return Result( - success=False, - error_report="No source code or bank conflicts found. Please compile your code with -g.", - ) - kernel = None kernel_file = None # Get the file from the results if self._instrumentation_results is None: - # Get the file from the results - filtered_report_card = filter_json_field( - self._initial_profiler_results, - field="lds", - subfield="bc", - comparison_func=lambda x: x > 0, - ) - - if len(filtered_report_card) == 0: - return Result(success=False, error_report="No bank conflicts found.") - - logging.debug(f"Filtered Report Card:\n{json.dumps(filtered_report_card, indent=4)}") - - kernel = filtered_report_card[0]["kernel"] - files = filtered_report_card[0]["source"]["files"] + pass + else: + kernel = self._instrumentation_results["kernel_analysis"]["kernel_info"]["name"] kernel_name = get_kernel_name(kernel) + files = [] + + # Extract files from bank conflict accesses + bank_conflicts = self._instrumentation_results["kernel_analysis"]["bank_conflicts"]["accesses"] + for access in bank_conflicts: + file_path = access["source_location"]["file"] + if file_path not in files: + files.append(file_path) kernel_file = None for file in files: if os.path.exists(file): @@ -257,7 +246,8 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res break if kernel_file is None: return Result(success=False, error_report="Kernel file not found.") - + + # Create user prompt and required reports user_prompt = ( f"There is a bank conflict in the kernel {kernel} in the source code {unoptimized_file_content}." f" Please fix the conflict but do not change the semantics of the program." @@ -277,8 +267,6 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res f"`{kernel_name}` with arguments `{args}`. Bank conflicts occur when multiple threads " f"access the same memory bank simultaneously, causing serialization and performance degradation." ) - else: - pass if kernel is None: return Result(success=False, error_report="Failed to extract the kernel name.") From f0a5addd343a5e1e962c2bf0f05b684c19ae2934 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 29 Jul 2025 18:08:15 +0000 Subject: [PATCH 17/30] Uncomment instruemented kernel name fix for omniprobe kernel filter Signed-off-by: coleramos425 --- src/intelliperf/utils/regex.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/intelliperf/utils/regex.py b/src/intelliperf/utils/regex.py index 30fc8bf9..01036524 100644 --- a/src/intelliperf/utils/regex.py +++ b/src/intelliperf/utils/regex.py @@ -39,10 +39,10 @@ def generate_ecma_regex_from_list(kernel_names: set) -> str: # add the name of the instrumented kernel clone to the regex, otherwise we'll skip it # and exclude it from the memory analysis report # duplicate_kernel_str = f"__amd_crk_{i.replace(')', ', void*)', 1)}" - # duplicate_kernel_str = f"__amd_crk_{i.replace(")", ", void*)", 1)}" - # escaped_string = re.escape(duplicate_kernel_str) - # regex_string = r"^" + escaped_string + r"$" - # res.append(regex_string) + duplicate_kernel_str = f"__amd_crk_{i.replace(")", ", void*)", 1)}" + escaped_string = re.escape(duplicate_kernel_str) + regex_string = r"^" + escaped_string + r"$" + res.append(regex_string) regex = f"({'|'.join(res)})" return regex From 0858f1e80a8cc138ba76c76cf5548b7adc5fb557 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 29 Jul 2025 18:52:08 +0000 Subject: [PATCH 18/30] Correctly index instrumentation results array to consider first element (first kernel) Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 4401d632..d3ae74b8 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -226,12 +226,12 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res if self._instrumentation_results is None: pass else: - kernel = self._instrumentation_results["kernel_analysis"]["kernel_info"]["name"] + kernel = self._instrumentation_results[0]["kernel_analysis"]["kernel_info"]["name"] kernel_name = get_kernel_name(kernel) files = [] # Extract files from bank conflict accesses - bank_conflicts = self._instrumentation_results["kernel_analysis"]["bank_conflicts"]["accesses"] + bank_conflicts = self._instrumentation_results[0]["kernel_analysis"]["bank_conflicts"]["accesses"] for access in bank_conflicts: file_path = access["source_location"]["file"] if file_path not in files: From 40df90198ae54c47f83f94c28c0ef6476d4d2b97 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Tue, 29 Jul 2025 18:53:41 +0000 Subject: [PATCH 19/30] Modify performance validation pass to account for kernel name from omniprobe report with clone suffix Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index d3ae74b8..c49e4297 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -321,10 +321,13 @@ def correctness_validation_pass(self, accordo_absolute_tolerance: float = 1e-6) return result def performance_validation_pass(self) -> Result: + # Currently, Omniprobe appends the '[clone .kd]' suffix to the kernel name + # this needs to me adjusted to reflect the actual kernel name + kernel_signature_non_cloned = self.current_kernel_signature.split(" [clone .kd]")[0] unoptimized_results = filter_json_field( self._initial_profiler_results, field="kernel", - comparison_func=lambda x: x == self.current_kernel_signature, + comparison_func=lambda x: x == kernel_signature_non_cloned, ) unoptimized_time = unoptimized_results[0]["durations"]["ns"] @@ -336,7 +339,7 @@ def performance_validation_pass(self) -> Result: optimized_results = filter_json_field( self._optimization_results, field="kernel", - comparison_func=lambda x: x == self.current_kernel_signature, + comparison_func=lambda x: x == kernel_signature_non_cloned, ) optimized_time = optimized_results[0]["durations"]["ns"] optimized_conflicts = optimized_results[0]["lds"]["bc"] From 0f4dbcf2c0a01257ac1b98a2d2116ded3d269f9e Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Wed, 30 Jul 2025 16:14:37 +0000 Subject: [PATCH 20/30] Omniprobe uses run.subprocess() with a new env, so PWD isn't set as intended. Must modify shell cmd to cd to working_directory when specified Signed-off-by: coleramos425 --- src/intelliperf/utils/process.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/intelliperf/utils/process.py b/src/intelliperf/utils/process.py index ae4befa4..2bcdb32b 100644 --- a/src/intelliperf/utils/process.py +++ b/src/intelliperf/utils/process.py @@ -45,7 +45,7 @@ def capture_subprocess_output( """ verbose = logging.getLogger().getEffectiveLevel() <= logging.DEBUG - logging.debug(f"Running the command: {' '.join(subprocess_args)}") + # logging.debug(f"Running the command: {' '.join(subprocess_args)}") if working_directory is not None: logging.debug(f"Working directory: {working_directory}") @@ -58,7 +58,15 @@ def capture_subprocess_output( if additional_path is not None: env["PATH"] = str(additional_path) + ":" + env["PATH"] + if working_directory is not None: + # Convert to absolute path to be safe + abs_working_dir = os.path.abspath(working_directory) + shell_cmd = f'cd "{abs_working_dir}" && {" ".join(subprocess_args)}' + subprocess_args = ["bash", "-c", shell_cmd] + working_directory = None # Let shell handle it + logging.debug(f"PATH: {env['PATH']}") + logging.debug(f"Running the command: {' '.join(subprocess_args)}") # Run the process and wait for completion try: From c3e6f36898a7afc5a167f9c6403719cd8fd24685 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Wed, 30 Jul 2025 16:15:16 +0000 Subject: [PATCH 21/30] Must explicitly use string notation for kernel filters in subprocess cmds with new implementation Signed-off-by: coleramos425 --- src/intelliperf/core/application.py | 2 +- src/intelliperf/formulas/bank_conflict.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intelliperf/core/application.py b/src/intelliperf/core/application.py index d6dfd4bd..e5d9ddb5 100644 --- a/src/intelliperf/core/application.py +++ b/src/intelliperf/core/application.py @@ -158,7 +158,7 @@ def profile(self, top_n: int): "-w", str(last_matching_id), "-k", - f"{'|'.join(top_n_kernels)}", + f"\"{'|'.join(top_n_kernels)}\"", "--separate", "--save", f"{get_guided_tuning_path()}/intelliperf_report_card.json", diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index c49e4297..c4a64bb8 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -150,7 +150,7 @@ def instrument_pass(self) -> Result: "--analyzers", "MemoryAnalysis", "--kernels", - ecma_regex, + f"\"{ecma_regex}\"", "--log-format", "json", "--log-location", From d4cb85b370ca117d69aab39736628608b031522e Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Wed, 30 Jul 2025 19:52:11 +0000 Subject: [PATCH 22/30] Adding an omniprobe_path argument to build_examples script Signed-off-by: coleramos425 --- examples/CMakeLists.txt | 5 ++++- scripts/build_examples.sh | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 16a0d784..0ab44fb6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -31,7 +31,10 @@ function(add_example name source_file) add_executable(${name} ${source_file}) # CMake instrumentation integration example if(INSTRUMENT) - set(OMNIPROBE_PATH ${CMAKE_SOURCE_DIR}/../external/omniprobe/install) + # Use provided OMNIPROBE_PATH or default to the standard location + if(NOT DEFINED OMNIPROBE_PATH) + set(OMNIPROBE_PATH ${CMAKE_SOURCE_DIR}/../external/omniprobe/install) + endif() # Only use omniprobe if the path exists if(EXISTS ${OMNIPROBE_PATH}/lib/libAMDGCNSubmitAddressMessages-rocm.so) # Use the plugin to instrument the code diff --git a/scripts/build_examples.sh b/scripts/build_examples.sh index 9962aa52..8f41c88e 100755 --- a/scripts/build_examples.sh +++ b/scripts/build_examples.sh @@ -32,14 +32,16 @@ parallel=8 build_dir=build verbose=false instrument=false +omniprobe_path="" print_usage() { echo "Usage: $0 [options]" echo "Options:" - echo " -c, --clean Clean build directory" - echo " -v, --verbose Print verbose output" - echo " -i, --instrument Instrument the code with Omniprobe" - echo " -j, --jobs Set number of parallel jobs" + echo " -c, --clean Clean build directory" + echo " -v, --verbose Print verbose output" + echo " -i, --instrument Instrument the code with Omniprobe" + echo " -o, --omniprobe Specify path to omniprobe tool" + echo " -j, --jobs Set number of parallel jobs" } # Parse arguments @@ -57,6 +59,16 @@ while [[ $# -gt 0 ]]; do instrument=true shift ;; + -o|--omniprobe) + if [[ -n "$2" ]]; then + omniprobe_path="$2" + shift 2 + else + echo "Error: --omniprobe requires a path argument" + print_usage + exit 1 + fi + ;; -j|--jobs) if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then parallel="$2" @@ -88,6 +100,9 @@ if [ "$instrument" = true ]; then cmake_config_args+=(-DINSTRUMENT=ON) fi +if [ -n "$omniprobe_path" ]; then + cmake_config_args+=(-DOMNIPROBE_PATH="$omniprobe_path") +fi config_command="cmake -B "$build_dir"\ From fdcb955f212badca071ab682feaf26b61b262667 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Wed, 30 Jul 2025 21:53:41 +0000 Subject: [PATCH 23/30] Update duplicate build_examples script inside of the examples subdir Signed-off-by: coleramos425 --- examples/scripts/build_examples.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/scripts/build_examples.sh b/examples/scripts/build_examples.sh index 8cdb1aca..a5dae7c3 100755 --- a/examples/scripts/build_examples.sh +++ b/examples/scripts/build_examples.sh @@ -32,14 +32,16 @@ parallel=8 build_dir=build verbose=false instrument=false +omniprobe_path="" print_usage() { echo "Usage: $0 [options]" echo "Options:" - echo " -c, --clean Clean build directory" - echo " -v, --verbose Print verbose output" - echo " -i, --instrument Instrument the code with Omniprobe" - echo " -j, --jobs Set number of parallel jobs" + echo " -c, --clean Clean build directory" + echo " -v, --verbose Print verbose output" + echo " -i, --instrument Instrument the code with Omniprobe" + echo " -o, --omniprobe Specify path to omniprobe tool" + echo " -j, --jobs Set number of parallel jobs" } # Parse arguments @@ -57,6 +59,16 @@ while [[ $# -gt 0 ]]; do instrument=true shift ;; + -o|--omniprobe) + if [[ -n "$2" ]]; then + omniprobe_path="$2" + shift 2 + else + echo "Error: --omniprobe requires a path argument" + print_usage + exit 1 + fi + ;; -j|--jobs) if [[ -n "$2" && "$2" =~ ^[0-9]+$ ]]; then parallel="$2" @@ -88,6 +100,9 @@ if [ "$instrument" = true ]; then cmake_config_args+=(-DINSTRUMENT=ON) fi +if [ -n "$omniprobe_path" ]; then + cmake_config_args+=(-DOMNIPROBE_PATH="$omniprobe_path") +fi config_command="cmake -B "$build_dir"\ From 8890e17c834469d9da08d257e7440bb1b6d42396 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Wed, 30 Jul 2025 22:34:19 +0000 Subject: [PATCH 24/30] Update container setup instructions in CONTRIBUTING.md Signed-off-by: coleramos425 --- docs/CONTRIBUTING.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index f47f1d2d..f92eb12c 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -35,14 +35,12 @@ We provide both Apptainer and Docker images containing all the dependencies. To #### Using Apptainer ```bash -./apptainer/build.sh -./apptainer/run.sh +./containers/run.sh --apptainer ``` #### Using Docker ```bash -./docker/build.sh -./docker/run.sh +./containers/run.sh --docker ``` ### Setting Up Development Environment From a36abed5a8a995778fec2699e37060614acedd46 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Thu, 31 Jul 2025 20:33:04 +0000 Subject: [PATCH 25/30] ruff prelinter should ignore guided-tuning subdir Signed-off-by: coleramos425 --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index ad3ac8ea..122105a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,9 @@ dev = [ [tool.ruff] line-length = 120 target-version = "py38" +exclude = [ + "external/guided-tuning/" +] [tool.ruff.lint] select = [ From b279f38f83660384a6fae694a7b626025f78dd55 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Thu, 31 Jul 2025 20:44:52 +0000 Subject: [PATCH 26/30] Restore old optimize_pass() implementation in case omniprobe is not availible Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 53 +++++++++++++++++++++-- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index c4a64bb8..350db392 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -150,7 +150,7 @@ def instrument_pass(self) -> Result: "--analyzers", "MemoryAnalysis", "--kernels", - f"\"{ecma_regex}\"", + f'"{ecma_regex}"', "--log-format", "json", "--log-location", @@ -224,12 +224,57 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res # Get the file from the results if self._instrumentation_results is None: - pass + # Get the file from the results + filtered_report_card = filter_json_field( + self._initial_profiler_results, + field="lds", + subfield="bc", + comparison_func=lambda x: x > 0, + ) + + if len(filtered_report_card) == 0: + return Result(success=False, error_report="No bank conflicts found.") + + logging.debug(f"Filtered Report Card:\n{json.dumps(filtered_report_card, indent=4)}") + + kernel = filtered_report_card[0]["kernel"] + files = filtered_report_card[0]["source"]["files"] + kernel_name = get_kernel_name(kernel) + kernel_file = None + for file in files: + if os.path.exists(file): + with open(file, "r") as f: + unoptimized_file_content = f.read() + if kernel_name in unoptimized_file_content: + kernel_file = file + break + if kernel_file is None: + return Result(success=False, error_report="Kernel file not found.") + + user_prompt = ( + f"There is a bank conflict in the kernel {kernel} in the source code {unoptimized_file_content}." + f" Please fix the conflict but do not change the semantics of the program." + " Do not remove any comments or licenses." + " Do not include any markdown code blocks or text other than the code." + ) + if self.current_summary is not None: + user_prompt += f"\n\nThe current summary is: {self.current_summary}" + cur_diff = self.compute_diff([kernel_file]) + user_prompt += f"\nThe diff between the current and initial code is: {cur_diff}" + + self.previous_source_code = unoptimized_file_content + + args = kernel.split("(")[1].split(")")[0] + self.bottleneck_report = ( + f"Bank Conflict Detection: IntelliPerf identified shared memory bank conflicts in kernel " + f"`{kernel_name}` with arguments `{args}`. Bank conflicts occur when multiple threads " + f"access the same memory bank simultaneously, causing serialization and performance degradation." + ) else: kernel = self._instrumentation_results[0]["kernel_analysis"]["kernel_info"]["name"] kernel_name = get_kernel_name(kernel) files = [] - + # Extract files from bank conflict accesses bank_conflicts = self._instrumentation_results[0]["kernel_analysis"]["bank_conflicts"]["accesses"] for access in bank_conflicts: @@ -246,7 +291,7 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res break if kernel_file is None: return Result(success=False, error_report="Kernel file not found.") - + # Create user prompt and required reports user_prompt = ( f"There is a bank conflict in the kernel {kernel} in the source code {unoptimized_file_content}." From 5297ecbbbdb5129bebef0c7ba3aaba97a8f13851 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Thu, 31 Jul 2025 21:28:23 +0000 Subject: [PATCH 27/30] Comply with linter Signed-off-by: coleramos425 --- src/intelliperf/utils/regex.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/intelliperf/utils/regex.py b/src/intelliperf/utils/regex.py index 01036524..25fb9633 100644 --- a/src/intelliperf/utils/regex.py +++ b/src/intelliperf/utils/regex.py @@ -38,8 +38,7 @@ def generate_ecma_regex_from_list(kernel_names: set) -> str: # Note: Temporary fix, but until bug in omniprobe is fixed we need to also # add the name of the instrumented kernel clone to the regex, otherwise we'll skip it # and exclude it from the memory analysis report - # duplicate_kernel_str = f"__amd_crk_{i.replace(')', ', void*)', 1)}" - duplicate_kernel_str = f"__amd_crk_{i.replace(")", ", void*)", 1)}" + duplicate_kernel_str = f"__amd_crk_{i.replace(')', ', void*)', 1)}" escaped_string = re.escape(duplicate_kernel_str) regex_string = r"^" + escaped_string + r"$" res.append(regex_string) From 82b5c9d48468eaf46f64220c954623cbdcc77b28 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 31 Jul 2025 21:28:37 +0000 Subject: [PATCH 28/30] Apply Ruff auto-fixes --- src/intelliperf/core/application.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/intelliperf/core/application.py b/src/intelliperf/core/application.py index e5d9ddb5..5ffcd490 100644 --- a/src/intelliperf/core/application.py +++ b/src/intelliperf/core/application.py @@ -158,7 +158,7 @@ def profile(self, top_n: int): "-w", str(last_matching_id), "-k", - f"\"{'|'.join(top_n_kernels)}\"", + f'"{"|".join(top_n_kernels)}"', "--separate", "--save", f"{get_guided_tuning_path()}/intelliperf_report_card.json", From 2e0347c97e4194233bffb6decc19cd52e0fb2ab0 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Thu, 31 Jul 2025 22:16:14 +0000 Subject: [PATCH 29/30] First attempt at adding line numbers into prompt Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 350db392..31672d3e 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -273,28 +273,32 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res else: kernel = self._instrumentation_results[0]["kernel_analysis"]["kernel_info"]["name"] kernel_name = get_kernel_name(kernel) - files = [] + files = {} # supposed to be a dict of file_path -> list of line numbers + line_numbers = [] # Extract files from bank conflict accesses bank_conflicts = self._instrumentation_results[0]["kernel_analysis"]["bank_conflicts"]["accesses"] for access in bank_conflicts: file_path = access["source_location"]["file"] + line_number = access["source_location"]["line"] if file_path not in files: - files.append(file_path) + files[file_path].append(line_number) + kernel_file = None - for file in files: + for file in files.keys(): if os.path.exists(file): with open(file, "r") as f: unoptimized_file_content = f.read() if kernel_name in unoptimized_file_content: kernel_file = file + line_numbers.append(files[file]) break if kernel_file is None: return Result(success=False, error_report="Kernel file not found.") # Create user prompt and required reports user_prompt = ( - f"There is a bank conflict in the kernel {kernel} in the source code {unoptimized_file_content}." + f"There is a bank conflict in the kernel {kernel} at line(s) numbered {line_numbers} in the source code {unoptimized_file_content}." f" Please fix the conflict but do not change the semantics of the program." " Do not remove any comments or licenses." " Do not include any markdown code blocks or text other than the code." From 509b8d0d1c93bcf393948c0b3432fe3c8c90f3d8 Mon Sep 17 00:00:00 2001 From: coleramos425 Date: Fri, 1 Aug 2025 18:06:12 +0000 Subject: [PATCH 30/30] Fixing small typo in line number parsing Signed-off-by: coleramos425 --- src/intelliperf/formulas/bank_conflict.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/intelliperf/formulas/bank_conflict.py b/src/intelliperf/formulas/bank_conflict.py index 31672d3e..99d9a5e6 100644 --- a/src/intelliperf/formulas/bank_conflict.py +++ b/src/intelliperf/formulas/bank_conflict.py @@ -282,7 +282,8 @@ def optimize_pass(self, temperature: float = 0.0, max_tokens: int = 3000) -> Res file_path = access["source_location"]["file"] line_number = access["source_location"]["line"] if file_path not in files: - files[file_path].append(line_number) + files[file_path] = [] + files[file_path].append(line_number) kernel_file = None for file in files.keys():