Skip to content

Commit

Permalink
Merge branch 'main' into dont_force_memspace1_toaie
Browse files Browse the repository at this point in the history
  • Loading branch information
newling authored Aug 26, 2024
2 parents 9bed1f7 + 652d648 commit 4005af9
Show file tree
Hide file tree
Showing 30 changed files with 511 additions and 565 deletions.
76 changes: 25 additions & 51 deletions .github/workflows/ci.yml → .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: CI Linux

on:
workflow_call:
Expand All @@ -9,72 +9,44 @@ on:
branches:
- main

schedule:
# At minute 0 past every 2nd hour. (see https://crontab.guru)
# this job is to keep the ccache cache warm
# specifically for the free windows runner
- cron: '0 */2 * * *'

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-${{ github.event.number || github.sha }}
group: ci-build-test-cpp-linux-${{ github.event.number || github.sha }}
cancel-in-progress: true

defaults:
run:
# force bash for windows
shell: bash

jobs:
build_and_ctest:
name: Build and Test (${{ matrix.os }}, ASSERTIONS)
runs-on: ${{ matrix.runs-on }}
name: Build and Test (linux, ASSERTIONS)
runs-on: nod-ai-shared-cpubuilder-manylinux-x86_64
strategy:
fail-fast: false
matrix:
include:
- os: linux
runs-on: nod-ai-shared-cpubuilder-manylinux-x86_64
- os: windows
runs-on: windows-2019
fail-fast: true
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
steps:
- name: Set unified TZ
uses: szenius/set-timezone@v2.0
with:
# this is an arbitrary choice
timezoneLinux: "Asia/Singapore"
timezoneMacos: "Asia/Singapore"
timezoneWindows: "Singapore Standard Time"

- name: Configure local git mirrors
if: ${{ matrix.runs-on == 'nod-ai-shared-cpubuilder-manylinux-x86_64' }}
run: |
/gitmirror/scripts/trigger_update_mirrors.sh
/gitmirror/scripts/git_config.sh
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
submodules: recursive

- name: Install static libs
if: ${{ matrix.runs-on == 'nod-ai-shared-cpubuilder-manylinux-x86_64' }}
run: |
dnf install -y almalinux-release-devel
yum remove -y openssl-devel zlib-devel || true
yum install -y protobuf-devel protobuf-compiler
- name: Setup Cpp
uses: aminya/setup-cpp@v1
if: ${{ matrix.os == 'windows' }}
with:
compiler: msvc
vcvarsall: true
cmake: true
ninja: true
ccache: true

- uses: actions/setup-python@v4
if: ${{ matrix.os == 'windows' }}
with:
python-version: '3.11'

- name: Sync source deps
run: |
python ./sync_deps.py
Expand All @@ -87,8 +59,8 @@ jobs:
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
key: "${{ matrix.os }}-build-test-cpp-asserts-v1-${{ github.sha }}"
restore-keys: "${{ matrix.os }}-build-test-cpp-"
key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }}
restore-keys: linux-build-test-cpp-

- name: Build packages
run: |
Expand All @@ -100,31 +72,33 @@ jobs:
run: |
rm -f iree-install/bin/clang*
rm -f iree-install/bin/llvm-link*
tar cf iree-${{ matrix.os }}-dist.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test
tar cf iree-dist-linux.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: "${{ matrix.os }}_x86_64_release_packages"
path: "iree-${{ matrix.os }}-dist.tar"
name: linux_x86_64_release_packages
path: iree-dist-linux.tar
if-no-files-found: warn

- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: "${{ matrix.os }}-build-test-cpp-asserts-v1-${{ github.sha }}"
key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }}

test_linux:
name: E2E Test linux
runs-on: amd7940hs
needs: build_and_ctest
strategy:
fail-fast: true
fail-fast: false
matrix:
runs-on: [linux-phoenix-20240606, linux-phoenix-20240819]
runs-on: ${{ matrix.runs-on }}
env:
XILINXD_LICENSE_FILE: /home/svcnod/Xilinx.lic
XILINXD_LICENSE_FILE: /opt/xilinx/Xilinx.lic
steps:
- name: "Checking out repository" # for test scripts
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
Expand All @@ -139,7 +113,7 @@ jobs:
- name: Extract artifact
run: |
mkdir iree-install
tar -xf iree-linux-dist.tar -C iree-install
tar -xf iree-dist-linux.tar -C iree-install
bash build_tools/download_peano.sh
- name: Create venv and install dependencies
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CI Windows

on:
workflow_call:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- main

schedule:
# At minute 0 past every 4nd hour. (see https://crontab.guru)
# this job is to keep the ccache cache warm
- cron: '0 */4 * * *'

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-cpp-windows-${{ github.event.number || github.sha }}
cancel-in-progress: true

defaults:
run:
# force bash for windows
shell: bash

jobs:
build_and_ctest:
name: Build and Test (windows, ASSERTIONS)
runs-on: windows-2019
strategy:
fail-fast: true
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
steps:
- name: Set unified TZ
uses: szenius/set-timezone@v2.0
with:
# this is an arbitrary choice
timezoneLinux: "Asia/Singapore"
timezoneMacos: "Asia/Singapore"
timezoneWindows: "Singapore Standard Time"

- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
submodules: recursive

- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: msvc
vcvarsall: true
cmake: true
ninja: true
ccache: true

- uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Sync source deps
run: |
python ./sync_deps.py
- name: Python deps
run: |
pip install "numpy<2" pyyaml "pybind11[global]==2.10.3" nanobind
- name: Enable cache
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
# without datetime stamps you'll get collisions for the cache warming runs
# ("Failed to save: Unable to reserve cache with key ..., another job may be creating this cache.")
key: windows-build-test-cpp-asserts-v1-${{ github.sha }}-${{ github.event.repository.updated_at }}
restore-keys: windows-build-test-cpp-

- name: Build packages
run: |
export cache_dir="${{ env.CACHE_DIR }}"
bash build_tools/ci/build_test_cpp.sh
- name: Create artifacts
if: ${{ !cancelled() }}
run: |
rm -f iree-install/bin/clang*
rm -f iree-install/bin/llvm-link*
tar cf iree-dist-windows.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test.exe
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: windows_x86_64_release_packages
path: iree-dist-windows.tar
if-no-files-found: warn

- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: windows-build-test-cpp-asserts-v1-${{ github.sha }}-${{ github.event.repository.updated_at }}
9 changes: 8 additions & 1 deletion build_tools/ci/build_test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ echo "Using python: $python"

# https://stackoverflow.com/a/8597411/9045206
# note: on windows (git-bash) result is "msys"
# well only if you have apparently the right version of git-bash installed
# https://stackoverflow.com/a/72164385
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export CMAKE_TOOLCHAIN_FILE="$this_dir/linux_default_toolchain.cmake"
export CC=clang
Expand Down Expand Up @@ -86,7 +88,12 @@ cmake --build "$build_dir" --target iree-install-dist

echo "CTest"
echo "-----"
ctest --test-dir "$build_dir" -R amd-aie --output-on-failure -j
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
ctest --test-dir "$build_dir" -R amd-aie --output-on-failure -j
else
# hack while windows is flaky to get past failing tests
ctest --test-dir "$build_dir" -R amd-aie --output-on-failure -j --repeat until-pass:5
fi

# Show ccache stats.
ccache --show-stats
68 changes: 42 additions & 26 deletions build_tools/ci/cpu_comparison/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ def __init__(
if xrt_hash:
self.xrt_hash = xrt_hash[0]

xdna_datetime = re.findall(
# eg 2.18.0_20240606
r"amdxdna\s+:\s\d\.\d+\.\d+_(\d+)",
xrt_info,
flags=re.MULTILINE | re.IGNORECASE,
)
if xdna_datetime:
self.xdna_datetime = int(xdna_datetime[0])

# Try and get the peano commit hash. This is a bit of a hack, if it fails
# peano_commit_has is left as "undetermined".
self.peano_commit_hash = "undetermined"
Expand Down Expand Up @@ -589,38 +598,45 @@ def run(self, config):
test_files_dir = config.file_dir / "test_files"
output_dir = config.output_dir

for name in [
"two_matmul_switching",
"matmul_f32_8_8_4",
"matmul_f32_8_4_8",
]:
aie_vs_llvm_cpu(config, test_files_dir / f"{name}.mlir")

aie_vs_llvm_cpu(
config,
test_files_dir / "three_matmuls.mlir",
function_name="three_$mm$",
)

# Test(s) of the form matmul(A,B) where A:MxK, B:KxN
test_name = output_dir / "test_from_template.mlir"
template_name = matmul_template_dir / "matmul_MxK_KxN.mlir"
generate_matmul_test(test_name, template_name, 32, 32, 64, "bf16", "f32")
aie_vs_llvm_cpu(config, test_name)

# Test(s) of the form matmul(A,B) + C where A:MxK, B:KxN, C:N
test_name = output_dir / "test_from_template_bias_N.mlir"
template_name = matmul_template_dir / "matmul_bias_MxK_KxN_N.mlir"
generate_matmul_test(test_name, template_name, 1024, 1024, 512, "bf16", "f32")
aie_vs_llvm_cpu(config, test_name, tile_pipeline="pack-peel", use_ukernel=True)
aie_vs_llvm_cpu(config, test_name, tile_pipeline="pack-peel", use_ukernel=False)

# Test(s) of the form matmul(A,B) + C where A:MxK, B:KxN, C:MxN
test_name = output_dir / "test_from_template_full_bias.mlir"
template_name = matmul_template_dir / "matmul_bias_MxK_KxN_MxN.mlir"
generate_matmul_test(test_name, template_name, 128, 128, 256, "i32", "i32")
aie_vs_llvm_cpu(config, test_name, tile_pipeline="pack-peel", rtol=0, atol=0)

if config.xdna_datetime and config.xdna_datetime < 20240819:
for name in [
"two_matmul_switching",
"matmul_f32_8_8_4",
"matmul_f32_8_4_8",
]:
aie_vs_llvm_cpu(config, test_files_dir / f"{name}.mlir")

aie_vs_llvm_cpu(
config,
test_files_dir / "three_matmuls.mlir",
function_name="three_$mm$",
)

# Test(s) of the form matmul(A,B) where A:MxK, B:KxN
test_name = output_dir / "test_from_template.mlir"
template_name = matmul_template_dir / "matmul_MxK_KxN.mlir"
generate_matmul_test(test_name, template_name, 32, 32, 64, "bf16", "f32")
aie_vs_llvm_cpu(config, test_name)

# Test(s) of the form matmul(A,B) + C where A:MxK, B:KxN, C:N
test_name = output_dir / "test_from_template_bias_N.mlir"
template_name = matmul_template_dir / "matmul_bias_MxK_KxN_N.mlir"
generate_matmul_test(
test_name, template_name, 1024, 1024, 512, "bf16", "f32"
)
aie_vs_llvm_cpu(
config, test_name, tile_pipeline="pack-peel", use_ukernel=True
)
aie_vs_llvm_cpu(
config, test_name, tile_pipeline="pack-peel", use_ukernel=False
)


class SmokeSet(TestSet):
def __init__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

#include <algorithm>
#include <cassert>
#include <list>
#include <set>

#include "AIEDialect.h"
#include "Passes.h"
#include "iree-amd-aie/aie_runtime/iree_aie_router.h"
#include "iree-amd-aie/aie_runtime/iree_aie_runtime.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/raw_os_ostream.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"

Expand Down
Loading

0 comments on commit 4005af9

Please sign in to comment.