diff --git a/.github/requirements.txt b/.github/requirements.txt new file mode 100644 index 000000000..a50539a19 --- /dev/null +++ b/.github/requirements.txt @@ -0,0 +1 @@ +# platform: linux-64 diff --git a/.github/workflows/bisect.yml b/.github/workflows/bisect.yml new file mode 100644 index 000000000..9f7b1fa91 --- /dev/null +++ b/.github/workflows/bisect.yml @@ -0,0 +1,77 @@ +name: bisect + +on: + workflow_dispatch: + inputs: + last_good_commit: + description: 'Last known good commit' + required: true + # ! CHANGE + default: 'a1c8eab588fb7c8c38175cbebdeff75334d70f5d' + first_bad_commit: + description: 'First known bad commit, default HEAD' + required: false + default: 'HEAD' + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: gpu + timeout-minutes: 450 + + env: + TBB_VER: 2021.6.0 + LEVEL_ZERO_VER: v1.6.2 + HOME_DIR: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/gpurefactorbuild + HOME: /github/home + TBB_URL_PREFIX: https://github.com/oneapi-src/oneTBB/releases/download/ + LLVM_SHA_FILE: llvm_version.txt + + steps: + - name: Source Vars + run: | + mkdir -p $HOME_DIR + cd $HOME_DIR + rm -rf * + source /opt/intel/oneapi/compiler/latest/env/vars.sh + - uses: actions/checkout@v3 + with: + repository: intel-innersource/frameworks.ai.mlir.mlir-extensions + token: ${{secrets.WORKFLOW_TOKEN}} + fetch-depth: 0 + path: ${{env.HOME_DIR}}/mlir-extensions + + - name: Setup Latest Level Zero + shell: bash -l {0} + run: | + cd $HOME_DIR + git clone https://github.com/oneapi-src/level-zero.git + cd level-zero + git checkout $LEVEL_ZERO_VER + cd .. + mkdir level-zero-build + cd level-zero-build + cmake ../level-zero -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level-zero-install + ninja install + + - name: Build LLVM MLIR + run: | + mkdir -p $HOME_DIR/llvm-mlir + # omitted for bisect + + - name: Setup IMEX + run: | + cd $HOME_DIR + cp /home/gta/actions-runner/refactor_gpu_bisect_script.sh . + cd mlir-extensions + git bisect start + git bisect bad + git bisect good ${{ github.event.inputs.last_good_commit }} + git bisect run ../refactor_gpu_bisect_script.sh 2>&1 | tee output.out + cat output.out | grep -A 10 "first bad commit" > badcommit.log + + - name: Upload the bad commit + uses: actions/upload-artifact@v3.1.1 + with: + name: bisect-results + path: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/gpurefactorbuild/mlir-extensions/badcommit.log diff --git a/.github/workflows/build-cpu-composite-action/action.yml b/.github/workflows/build-cpu-composite-action/action.yml new file mode 100644 index 000000000..15d762952 --- /dev/null +++ b/.github/workflows/build-cpu-composite-action/action.yml @@ -0,0 +1,40 @@ +name: "CPU Build composite action" +description: "Checks out repo, build and run cpu tests" +inputs: + build_root: # id of input + description: 'build_root' + required: false + default: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_cpu + home_dir: # id of input + description: 'home_dir' + required: false + default: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_cpu/home +runs: + using: "composite" + steps: + - name: Checkout MLIR + shell: bash + run: | + cd ${{ inputs.build_root }} + if [ ! -d "llvm-project" ]; then git clone https://github.com/llvm/llvm-project; fi + cd ${{ inputs.build_root }}/llvm-project + git reset --hard HEAD + export LLVM_SHA=`cat ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build_tools/llvm_version.txt` + git fetch --prune + git checkout $LLVM_SHA || exit 1 + if [ -d "${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build_tools/patches" ]; then git apply ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build_tools/patches/*.patch; fi + + - name: Setup IMEX and run tests + shell: bash + run: | + cd ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions || exit 1 + cmake -S ${{ inputs.build_root }}/llvm-project/llvm -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_ZSTD=OFF -DLLVM_EXTERNAL_PROJECTS="Imex" -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. || exit 1 + set -o pipefail + cmake --build build --target check-imex | tee build/tests.txt + + - name: Upload tests.txt + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: tests.txt + path: ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build/tests.txt diff --git a/.github/workflows/build-gpu-composite-action/action.yml b/.github/workflows/build-gpu-composite-action/action.yml new file mode 100644 index 000000000..1e49c6463 --- /dev/null +++ b/.github/workflows/build-gpu-composite-action/action.yml @@ -0,0 +1,67 @@ +name: "GPU Build composite action" +description: "Checks out repo, build and run gpu tests" +inputs: + build_root: # id of input + description: 'build_root' + required: false + default: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_gpu + home_dir: # id of input + description: 'home_dir' + required: false + default: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_gpu/home + level_zero_ver: # id of input + description: 'level_zero_ver' + required: false + default: 'v1.8.1' +runs: + using: "composite" + steps: + - name: Setup Level Zero + shell: bash -l {0} + run: | + cd ${{ inputs.home_dir }} + git clone https://github.com/oneapi-src/level-zero.git + cd level-zero + git checkout ${{ inputs.level_zero_ver }} + cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level-zero-install + cmake --build build --target install + + - name: Checkout MLIR + shell: bash + run: | + cd ${{ inputs.build_root }} + if [ ! -d "llvm-project" ]; then git clone https://github.com/llvm/llvm-project; fi + cd ${{ inputs.build_root }}/llvm-project + git reset --hard HEAD + export LLVM_SHA=`cat ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build_tools/llvm_version.txt` + git fetch --prune + git checkout $LLVM_SHA || exit 1 + if [ -d "${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build_tools/patches" ]; then git apply ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build_tools/patches/*.patch; fi + + - name: Setup IMEX and run tests + shell: bash + run: | + source /opt/intel/oneapi/setvars.sh + cd ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions + cmake -S ${{ inputs.build_root }}/llvm-project/llvm -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_ZSTD=OFF -DLLVM_EXTERNAL_PROJECTS="Imex" -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. -DIMEX_ENABLE_SYCL_RUNTIME=1 -DIMEX_ENABLE_L0_RUNTIME=1 -DLEVEL_ZERO_DIR=${{ inputs.home_dir }}/level-zero-install/ || exit + set -o pipefail + cmake --build build --target check-imex | tee build/tests.txt + + #- name: Run perf script + # shell: bash + # run: | + # cd ${{ inputs.home_dir }}/mlir-extensions/scripts + # ./run_perf_test.sh + + - name: Upload tests.txt + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: tests.txt + path: ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/build/tests.txt + + #- name: Upload report.txt + # uses: actions/upload-artifact@v3 + #with: + #name: report.txt + #path: ${{ inputs.home_dir }}/frameworks.ai.mlir.mlir-extensions/scripts/report.txt diff --git a/.github/workflows/build_cpu.yml b/.github/workflows/build_cpu.yml new file mode 100644 index 000000000..5fddece01 --- /dev/null +++ b/.github/workflows/build_cpu.yml @@ -0,0 +1,69 @@ +name: CPU Build + +on: + pull_request: + branches: + - main + - upstream + - 'dist-ndarray' + workflow_dispatch: + workflow_call: + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: [self-hosted, icx, glados] + timeout-minutes: 450 + + env: + BUILD_ROOT: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_cpu + HOME_DIR: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_cpu/home + HOME: /github/home + LLVM_SHA_FILE: llvm_version.txt + + steps: + - name: Check build root + run: | + export BUILD_ROOT=$(pwd)/build_cpu + echo BUILD_ROOT=${BUILD_ROOT} >> $GITHUB_ENV + export HOME_DIR=${BUILD_ROOT}/home + echo HOME_DIR=${HOME_DIR} >> $GITHUB_ENV + if [ ! -d "$BUILD_ROOT" ]; then mkdir -p $BUILD_ROOT; fi + + - name: Clear home dir + run: | + mkdir -p $HOME_DIR + cd $HOME_DIR + rm -rf * + + - uses: actions/checkout@v4 + with: + repository: intel-innersource/frameworks.ai.mlir.mlir-extensions + token: ${{secrets.WORKFLOW_TOKEN}} + fetch-depth: 0 + path: ${{env.HOME_DIR}}/frameworks.ai.mlir.mlir-extensions + + - name: Checkout MLIR + run: | + cd $BUILD_ROOT + if [ ! -d "llvm-project" ]; then git clone https://github.com/llvm/llvm-project; fi + cd $BUILD_ROOT/llvm-project + git reset --hard HEAD + export LLVM_SHA=`cat $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/llvm_version.txt` + git fetch --prune + git checkout $LLVM_SHA || exit 1 + if [ -d "$HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches" ]; then git apply $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches/*.patch; fi + + - name: Setup IMEX and run tests + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + cmake -S $BUILD_ROOT/llvm-project/llvm -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_ZSTD=OFF -DLLVM_EXTERNAL_PROJECTS="Imex" -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. -DLLVM_LIT_ARGS="-a -j 4" + set -o pipefail + cmake --build build --target check-imex | tee build/tests.txt + + - name: Upload tests.txt + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: tests_cpu.txt + path: ${{env.HOME_DIR}}/frameworks.ai.mlir.mlir-extensions/build/tests.txt diff --git a/.github/workflows/build_cpu_v2.yml b/.github/workflows/build_cpu_v2.yml new file mode 100644 index 000000000..026775fba --- /dev/null +++ b/.github/workflows/build_cpu_v2.yml @@ -0,0 +1,38 @@ +name: "CPU Build with composite action" + +on: + pull_request: + branches: + - dummy + workflow_dispatch: + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: cpu1 + timeout-minutes: 450 + + env: + BUILD_ROOT: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_cpu + HOME: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_cpu/home + + steps: + - name: Check build root + run: | + if [ ! -d "$BUILD_ROOT" ]; then mkdir -p $BUILD_ROOT; fi + + - name: Clear home dir + run: | + mkdir -p $HOME + cd $HOME + rm -rf * + + - uses: actions/checkout@v3 + with: + token: ${{secrets.WORKFLOW_TOKEN}} + fetch-depth: 0 + path: ${{env.HOME}}/frameworks.ai.mlir.mlir-extensions + - uses: ./build_cpu/home/frameworks.ai.mlir.mlir-extensions/.github/workflows/build-cpu-composite-action + with: + build_root: ${{env.BUILD_ROOT}} + home_dir: ${{env.HOME}} diff --git a/.github/workflows/build_gpu-fs-sim.yml b/.github/workflows/build_gpu-fs-sim.yml new file mode 100644 index 000000000..3524971aa --- /dev/null +++ b/.github/workflows/build_gpu-fs-sim.yml @@ -0,0 +1,97 @@ +name: GPU Build and run tests on FS simulator + +on: + pull_request: + branches: + - main + - upstream + - 'dist-ndarray' + - imex-embargo + workflow_dispatch: + workflow_call: + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: [self-hosted, icx, fs-sim] + timeout-minutes: 450 + + env: + TBB_VER: 2021.6.0 + LEVEL_ZERO_VER: v1.8.1 + TBB_URL_PREFIX: https://github.com/oneapi-src/oneTBB/releases/download/ + LLVM_SHA_FILE: llvm_version.txt + + steps: + - name: Check build root + run: | + export BUILD_ROOT=$(pwd)/build_gpu + echo BUILD_ROOT=${BUILD_ROOT} >> $GITHUB_ENV + export HOME_DIR=${BUILD_ROOT}/home + echo HOME_DIR=${HOME_DIR} >> $GITHUB_ENV + if [ ! -d "$BUILD_ROOT" ]; then mkdir -p $BUILD_ROOT; fi + + - name: Clear home dir + run: | + mkdir -p $HOME_DIR + cd $HOME_DIR + rm -rf * + + - uses: actions/checkout@v3 + with: + repository: intel-innersource/frameworks.ai.mlir.mlir-extensions + token: ${{ secrets.WORKFLOW_TOKEN }} + fetch-depth: 0 + path: ${{ env.HOME_DIR }}/frameworks.ai.mlir.mlir-extensions + + - name: Checkout MLIR + run: | + cd $BUILD_ROOT + if [ ! -d "llvm-project" ]; then git clone https://github.com/llvm/llvm-project; fi + cd $BUILD_ROOT/llvm-project + git reset --hard HEAD + export LLVM_SHA=`cat $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/llvm_version.txt` + git fetch --prune + git checkout $LLVM_SHA || exit 1 + if [ -d "$HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches" ]; then git apply $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches/*.patch; fi + + - name: Setup IMEX and run tests on FS simulator + shell: bash -l {0} + run: | + source /opt/intel/oneapi/setvars.sh + set -x + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + + cmake -S $BUILD_ROOT/llvm-project/llvm -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=gold -DLLVM_ENABLE_ZSTD=OFF -DLLVM_EXTERNAL_PROJECTS="Imex" -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. -DIMEX_ENABLE_SYCL_RUNTIME=1 -DIMEX_ENABLE_L0_RUNTIME=1 -DLLVM_LIT_ARGS="-a -j 1 --debug --timeout=600 --filter=Integration/Dialect/Xe*/*" -DIMEX_ENABLE_FS_SIMULATOR=ON || exit + sed -e 's,-printAllFeatures,,g' -i ${WORK_ROOT}/fs/scripts/run_in_a_loop_rasty.sh + export NEO_BINARIES_ROOT="$HOME"/neo + (cd ${WORK_ROOT}/fs/scripts && source setup.sh && umd_driver_env_variables_export && ./run_in_a_loop_rasty.sh) &> fs-sim.log & + SIM_PID=$! + cmake --build build --target check-static | tee build/tests.txt + TEST_RESULT=${PIPESTATUS[0]} + kill $SIM_PID + wait $SIM_PID + cd ${WORK_ROOT}/fs/scripts + zip -qr9 /tmp/fs-sim-tbx-logs.zip tbx*.log + exit $TEST_RESULT + + - name: Upload tests.txt + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: tests_gpu-fs-sim.txt + path: ${{ env.HOME_DIR }}/frameworks.ai.mlir.mlir-extensions/build/tests.txt + + - name: Upload fs-sim.log + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: fs-sim.log + path: ${{ env.HOME_DIR }}/frameworks.ai.mlir.mlir-extensions/fs-sim.log + + - name: Upload fs-sim-tbx-logs.zip + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: fs-sim-tbx-logs.zip + path: /tmp/fs-sim-tbx-logs.zip diff --git a/.github/workflows/build_gpu.yml b/.github/workflows/build_gpu.yml new file mode 100644 index 000000000..082799e1c --- /dev/null +++ b/.github/workflows/build_gpu.yml @@ -0,0 +1,100 @@ +name: GPU Build + +on: + pull_request: + branches: + - main + - upstream + - 'dist-ndarray' + workflow_dispatch: + workflow_call: + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: [self-hosted, pvc] + timeout-minutes: 450 + + env: + TBB_VER: 2021.6.0 + LEVEL_ZERO_VER: v1.8.1 + TBB_URL_PREFIX: https://github.com/oneapi-src/oneTBB/releases/download/ + LLVM_SHA_FILE: llvm_version.txt + + steps: + - name: Check build root + run: | + export BUILD_ROOT=$(pwd)/build_gpu + echo BUILD_ROOT=${BUILD_ROOT} >> $GITHUB_ENV + export HOME_DIR=${BUILD_ROOT}/home + echo HOME_DIR=${HOME_DIR} >> $GITHUB_ENV + if [ ! -d "$BUILD_ROOT" ]; then mkdir -p $BUILD_ROOT; fi + + - name: Clear home dir + run: | + mkdir -p $HOME_DIR + cd $HOME_DIR + rm -rf * + + - uses: actions/checkout@v4 + with: + repository: intel-innersource/frameworks.ai.mlir.mlir-extensions + token: ${{ secrets.WORKFLOW_TOKEN }} + fetch-depth: 0 + path: ${{ env.HOME_DIR }}/frameworks.ai.mlir.mlir-extensions + + - name: Checkout MLIR + run: | + cd $BUILD_ROOT + if [ ! -d "llvm-project" ]; then git clone https://github.com/llvm/llvm-project; fi + cd $BUILD_ROOT/llvm-project + git reset --hard HEAD + export LLVM_SHA=`cat $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/llvm_version.txt` + git fetch --prune + git checkout $LLVM_SHA || exit 1 + if [ -d "$HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches" ]; then git apply $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches/*.patch; fi + + - name: Setup IMEX and run tests + run: | + source /opt/intel/oneapi/setvars.sh + apt-cache show level-zero + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + + pip install psutil + cmake -S $BUILD_ROOT/llvm-project/llvm -B build -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \ + -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_USE_LINKER=gold \ + -DLLVM_ENABLE_ZSTD=OFF -DLLVM_EXTERNAL_PROJECTS="Imex" -DLLVM_EXTERNAL_IMEX_SOURCE_DIR=. \ + -DIMEX_ENABLE_SYCL_RUNTIME=1 -DIMEX_ENABLE_L0_RUNTIME=1 \ + -DLLVM_LIT_ARGS="-a -j 4 --debug --timeout=1800" -DIMEX_ENABLE_PVC_TARGET=1 + set -o pipefail + cmake --build build --target check-imex | tee build/tests.txt + + - name: Run SG-level XeTile generated cases + run: | + rm -rf $HOME_DIR/frameworks.ai.mlir.mlir-extensions/scripts/xetile-test-gen/GEMM_reports + rm -rf $HOME_DIR/frameworks.ai.mlir.mlir-extensions/scripts/xetile-test-gen/Generated_GEMM + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions/scripts/xetile-test-gen + pip install pandas + pip install argparse + pip install openpyxl + ./run_tests.sh --gen_default_cases=1 --validate=1 --verbose=1 --llvm_build_dir=../../build + + # /home/gta/anaconda3/envs/imex-dev/bin/python $HOME_DIR/mlir-extensions/build/bin/imex-runner.py -i $HOME_DIR/mlir-extensions/test/Integration/Dialect/Linalg/OpenCL/linalg_addf.mlir -e main --pass-pipeline-file=$HOME_DIR/mlir-extensions/test/Integration/Dialect/Linalg/OpenCL/linalg-to-gpux-opencl.pp -entry-point-result=void --shared-libs=$HOME_DIR/llvm-mlir/_mlir_install/lib/libmlir_runner_utils.so,$HOME_DIR/mlir-extensions/build/lib/liblevel-zero-runtime.so + #- name: Run perf script + # run: | + # cd ${{ env.HOME_DIR }}/mlir-extensions/scripts + # ./run_perf_test.sh + + - name: Upload tests.txt + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: tests_gpu.txt + path: ${{ env.HOME_DIR }}/frameworks.ai.mlir.mlir-extensions/build/tests.txt + + #- name: Upload report.txt + # uses: actions/upload-artifact@v2 + #with: + #name: report.txt + #path: ${{ env.HOME_DIR }}/frameworks.ai.mlir.mlir-extensions/scripts/report.txt diff --git a/.github/workflows/build_gpu_v2.yml b/.github/workflows/build_gpu_v2.yml new file mode 100644 index 000000000..f0559335b --- /dev/null +++ b/.github/workflows/build_gpu_v2.yml @@ -0,0 +1,37 @@ +name: "GPU Build with composite action" + +on: + pull_request: + branches: + - dummy + workflow_dispatch: + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: gpu + timeout-minutes: 450 + + env: + BUILD_ROOT: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_gpu + HOME: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/build_gpu/home + + steps: + - name: Check build root + run: | + if [ ! -d "$BUILD_ROOT" ]; then mkdir -p $BUILD_ROOT; fi + + - name: Clear home dir + run: | + mkdir -p $HOME + cd $HOME + rm -rf * + + - uses: actions/checkout@v3 + with: + token: ${{secrets.WORKFLOW_TOKEN}} + path: ${{env.HOME}}/frameworks.ai.mlir.mlir-extensions + - uses: ./build_gpu/home/frameworks.ai.mlir.mlir-extensions/.github/workflows/build-gpu-composite-action + with: + build_root: ${{env.BUILD_ROOT}} + home_dir: ${{env.HOME}} diff --git a/.github/workflows/find_llvm_sha.yml b/.github/workflows/find_llvm_sha.yml new file mode 100644 index 000000000..4d4660db2 --- /dev/null +++ b/.github/workflows/find_llvm_sha.yml @@ -0,0 +1,88 @@ +# create a GHA workflow to run the bisect.py script and upload the results to artifact + +name: Find LLVM SHA +on: +# workflow dispatch and add inputs: last good commit, first known bad commit, branch, repo + workflow_dispatch: + inputs: + last_good_commit: + description: 'The llvm-project git commit number known to be good.' + required: true + default: 'd74f078' + first_bad_commit: + description: 'First known bad commit, default HEAD' + required: false + default: 'HEAD' + branch: + description: 'MLIR Extensions BRANCH' + required: true + default: 'main' + repo: + description: 'MLIR Extensions REPO' + required: false + default: 'intel-innersource/frameworks.ai.mlir.mlir-extensions.git' + host_volume_loc: + description: 'Host volume location' + required: false + default: '/home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions' + +jobs: + bisect: + runs-on: gpu + steps: + - name: Echo bad commit, good commit, repo + run: | + echo "bad commit:" + echo ${{ inputs.first_bad_commit }} + + + echo "good commit" + echo ${{ github.event.inputs.first_bad_commit}} + + # echo all inputs + echo "all inputs:" + echo ${{ github.event.inputs }} + + + echo "github repo running workflow" + echo $GITHUB_REPOSITORY + # !Checkout CI Repo + - name: Checkout + uses: actions/checkout@v2 + with: + repository: 'intel-sandbox/libraries.llvm.mlir-extensions.ci.git' + ref: main + path: ${{ github.event.inputs.host_volume_loc }}/libraries.llvm.mlir-extensions.ci + token: ${{ secrets.WORKFLOW_TOKEN }} + fetch-depth: 0 + + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.branch }} + repository: ${{ github.event.inputs.repo }} + path: ${{ github.event.inputs.host_volume_loc }}/mlir-extensions + token: ${{ secrets.WORKFLOW_TOKEN }} + fetch-depth: 0 + + # - name: Copy docker_build script into repo + - name: Run bisect + run: | + cd ${{ github.event.inputs.host_volume_loc }}/mlir-extensions + + set -e + set -x + + HOST_VOLUME_LOC=${{ github.event.inputs.host_volume_loc }} MLIR_EXTENSIONS_REPO=${{ github.event.inputs.repo }} MLIR_EXTENSIONS_BRANCH=${{ github.event.inputs.branch }} IMEX_ENABLE_GPU_E2E_TESTS=0 START_BAD_COMMIT=${{ github.event.inputs.first_bad_commit}} START_GOOD_COMMIT=${{github.event.inputs.last_good_commit}} bash -x ${{ github.event.inputs.host_volume_loc }}/libraries.llvm.mlir-extensions.ci/jenkins_slave/docker_build_LLVM_SHA.sh + + - name: Upload the full log + uses: actions/upload-artifact@v3.1.1 + with: + name: bisect-results + path: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/mlir-extensions/output.out + + - name: Upload the bad commit + uses: actions/upload-artifact@v3.1.1 + with: + name: bisect-results + path: /home/gta/actions-runner/_work/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions/mlir-extensions/badcommit.log diff --git a/.github/workflows/nightly_report.yml b/.github/workflows/nightly_report.yml new file mode 100644 index 000000000..1fb14b83f --- /dev/null +++ b/.github/workflows/nightly_report.yml @@ -0,0 +1,23 @@ +name: Nightly CI +on: + workflow_dispatch: + schedule: +# - cron: '0 0 * * *' # every 24 hrs + - cron: '30 19 * * *' # runs every day at 19:30 pm UTC which is 11:30 am PST +jobs: + invoke-sync: + name: Invoke Sync + uses: ./.github/workflows/sync.yml + secrets: inherit + + invoke-cpu-tests: + needs: invoke-sync + name: Invoke main Build_CPU Workflow + uses: ./.github/workflows/build_cpu.yml + secrets: inherit + + invoke-gpu-tests: + needs: invoke-sync + name: Invoke main Build_GPU Workflow + uses: ./.github/workflows/build_gpu.yml + secrets: inherit diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 190740595..273dccaba 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -4,13 +4,14 @@ on: pull_request: push: branches: [main] + workflow_dispatch: permissions: read-all jobs: pre-commit: - runs-on: ubuntu-latest + runs-on: gasp steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.0 + - uses: intel-innersource/frameworks.actions.thirdparty.pre-commit-action@v3.0.0 diff --git a/.github/workflows/rebuild_base_docker.yml b/.github/workflows/rebuild_base_docker.yml new file mode 100644 index 000000000..1117f4f06 --- /dev/null +++ b/.github/workflows/rebuild_base_docker.yml @@ -0,0 +1,47 @@ +name: Rebuild base docker image for PVC runners + +on: + workflow_dispatch: + inputs: + image_tag: + description: Docker image tag. Recommended value to use is git hash of main branch and date-time of build. + type: string + required: true + default: 0.0.1 + push: + description: Push image to DockerHub + required: true + type: choice + options: + - false + - true + default: "false" + +env: + DOCKER_REGISTRY: docker-registry.docker-registry.svc.cluster.local:5000 + +jobs: + print_inputs: + runs-on: Linux + steps: + - name: Print Inputs + run: echo "${{ toJSON(github.event.inputs) }}" + + build: + runs-on: + - self-hosted + - glados + - pvc + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner:${{ inputs.image_tag }} + run: | + cd docker + docker build . \ + --tag ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner:${{ inputs.image_tag }} + + - name: Push image ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner:${{ inputs.image_tag }} + if: ${{ inputs.push == 'true' }} + run: docker push ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner:${{ inputs.image_tag }} diff --git a/.github/workflows/rebuild_base_docker_fs_sim.yml b/.github/workflows/rebuild_base_docker_fs_sim.yml new file mode 100644 index 000000000..b0b5f0fa5 --- /dev/null +++ b/.github/workflows/rebuild_base_docker_fs_sim.yml @@ -0,0 +1,50 @@ +name: Rebuild base docker image for FS simulator runners + +on: + workflow_dispatch: + inputs: + image_tag: + description: Docker image tag. Recommended value to use is git hash of main branch and date-time of build. + type: string + required: true + default: latest + dont_push: + description: Don't push image to the registry + required: true + type: choice + options: + - false + - true + default: true + push: + paths: + - docker/Dockerfile.fs-sim + - .github/workflows/rebuild_base_docker_fs_sim.yml + +env: + DOCKER_REGISTRY: docker-registry.docker-registry.svc.cluster.local:5000 + +jobs: + print_inputs: + runs-on: Linux + steps: + - name: Print Inputs + run: echo "${{ toJSON(github.event.inputs) }}" + + build: + runs-on: + - self-hosted + - docker + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag || 'latest' }} + run: | + cd docker + docker build . -f Dockerfile.fs-sim \ + --tag ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag || 'latest' }} + + - name: Push image ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag || 'latest' }} + if: ${{ !inputs.dont_push }} + run: docker push ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag || 'latest' }} diff --git a/.github/workflows/sdl.yml b/.github/workflows/sdl.yml new file mode 100644 index 000000000..c076e06cd --- /dev/null +++ b/.github/workflows/sdl.yml @@ -0,0 +1,215 @@ +name: SDL Process +on: + workflow_dispatch: + inputs: + Bandit: + description: 'Run Bandit Scan' + required: true + default: 'false' + Coverity: + description: 'Run Coverity Scan' + required: true + default: 'false' +jobs: + Bandit: + uses: intel-innersource/frameworks.ai.infrastructure.code-scan-tools/.github/workflows/Scanner_Bandit.yml@one-ci-cd + with: + org: intel-innersource + repo: ${{ github.event.repository.name }} + refs: ${{ github.ref_name }} +# excludes: '-x folder_path' # This is optional, write the folders path you want to skip scan. + secrets: + token: ${{ secrets.WORKFLOW_TOKEN }} + + + Coverity: + runs-on: gpu + defaults: + run: + shell: bash + container: + image: ubuntu:latest + options: --rm --user root --entrypoint bash --privileged + + timeout-minutes: 450 + + env: + TBB_VER: 2021.6.0 + LEVEL_ZERO_VER: v1.6.2 + HOME_DIR: /__w/frameworks.ai.mlir.mlir-extensions/frameworks.ai.mlir.mlir-extensions + GITHUB_HOME: /__w + HOME: /github/home + TBB_URL_PREFIX: https://github.com/oneapi-src/oneTBB/releases/download/ + LLVM_SHA_FILE: llvm_version.txt + + steps: + - name: Clear home dir + run: | + cd $HOME_DIR + rm -rf * + cd $HOME + rm -rf * + + - name: Prepare Docker + run: | + export http_proxy=http://proxy-dmz.intel.com:911 + export https_proxy=http://proxy-dmz.intel.com:912 + apt-get update + DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata + apt-get upgrade -y + apt-get install -y wget gnupg curl ca-certificates apt-transport-https + apt-get install -y vim ninja-build cmake g++ python3 python3-pip ninja-build + apt-get install -y git + apt-get install -y cmake + apt-get install -y wget + apt-get install -y libssl-dev + apt-get install -y libssl11* + apt-get install -y openssl + apt-get install -y netcat + apt-get install -y mesa-utils + apt-get install -y software-properties-common + apt-get install -y pciutils + pip install pytest + wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4.tar.gz + tar -zvxf cmake-3.26.4.tar.gz + cd cmake-3.26.4 && ./bootstrap && make -j64 && make install && cmake --version + wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh + bash -x Anaconda3-2022.10-Linux-x86_64.sh -b -p $HOME/miniconda -f + bash Anaconda3-2022.10-Linux-x86_64.sh -b + rm Anaconda3-2022.10-Linux-x86_64.sh + + - uses: actions/checkout@v3 + with: + repository: intel-innersource/frameworks.ai.mlir.mlir-extensions + token: ${{secrets.WORKFLOW_TOKEN}} + path: ${{env.HOME_DIR}}/frameworks.ai.mlir.mlir-extensions + + - name: Install Build tools onto Conda + shell: bash -l {0} + run: | + export PATH="$HOME/miniconda:$PATH" + source $HOME/miniconda/bin/activate + conda install cmake ninja graphviz conda-forge::lit conda-forge::doxygen + conda list + + - name: Setup TBB + run: | + export HOME_DIR=`pwd` + export TBB_VER='2021.6.0' + export LEVEL_ZERO_VER='v1.6.2' + export TBB_URL_PREFIX='https://github.com/oneapi-src/oneTBB/releases/download/' + cd $HOME_DIR + mkdir -p tbb + cd tbb + echo "INFO: Downloading TBB ${TBB_VER}" + rm -rf * + export TBB_FN=oneapi-tbb-${TBB_VER}-lin.tgz + wget ${TBB_URL_PREFIX}/v${TBB_VER}/${TBB_FN} || exit 1 + tar xf ${TBB_FN} -C . || exit 1 + cat $(find . -name tbb.pc) | grep Version: | cut -d " " -f 2 > bundle_id.txt || rm -rf bundle_id.txt + [ -f bundle_id.txt ] || exit 1 + cd ../ + cd $HOME_DIR + + - name: Setup Level Zero + run: | + cd $HOME_DIR + mkdir -p level-zero + pushd level-zero + if [[ -f bundle_id.txt && ( "$(cat bundle_id.txt)" == "${LEVEL_ZERO_VER}" ) ]]; then + echo "INFO: Using cached build of Level-Zero ${LEVEL_ZERO_VER}" + else + echo "INFO: Downloading and building Level-Zero ${LEVEL_ZERO_VER}" + rm -rf * + echo ${LEVEL_ZERO_VER} > bundle_id.txt || rm -rf bundle_id.txt + cat bundle_id.txt || exit 1 + [ -f bundle_id.txt ] || exit 1 + git clone https://github.com/oneapi-src/level-zero.git || exit 1 + pushd level-zero || exit 1 + git checkout ${LEVEL_ZERO_VER} || exit 1 + mkdir level_zero_install || exit 1 + mkdir build || exit 1 + cd build || exit 1 + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level_zero_install .. || exit 1 + make install || exit 1 + popd + fi + popd + + - name: Build LLVM MLIR + run: | + mkdir -p $HOME_DIR/llvm-mlir + cd $HOME_DIR/llvm-mlir + echo "INFO: Need to rebuild LLVM-MLIR. Previous installation for MLIR not found" + np=`nproc` + if [ -d "llvm-project" ]; then rm -rf llvm-project; fi + git clone https://github.com/llvm/llvm-project || exit 1 + export LLVM_SHA=`cat ../frameworks.ai.mlir.mlir-extensions/build_tools/llvm_version.txt` + cd llvm-project || exit 1 + git checkout $LLVM_SHA || exit 1 + git apply $HOME_DIR/frameworks.ai.mlir.mlir-extensions/build_tools/patches/* || exit 1 + mkdir _build || exit 1 + cd _build || exit 1 + cmake ../llvm -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_USE_LINKER=gold -DLLVM_INSTALL_UTILS=ON -DLLVM_ENABLE_ZSTD=OFF -DCMAKE_INSTALL_PREFIX=$HOME_DIR/llvm-mlir/_mlir_install || exit 1 + cmake --build . -j ${np} || exit 1 + cmake --install . || exit 1 + cp bin/FileCheck $HOME_DIR/llvm-mlir/_mlir_install/bin/ + cp bin/count $HOME_DIR/llvm-mlir/_mlir_install/bin/ + cp bin/not $HOME_DIR/llvm-mlir/_mlir_install/bin/ + + - uses: intel-innersource/frameworks.actions.setup-coverity@v1 + env: + https_proxy: proxy-dmz.intel.com:912 # If the self-hosted runner has issues with the proxy + with: + version: '2022.3.1' + + - name: Check Coverity version + run: coverity --version + + - name: Coverity configure for compilers + run: | + cov-configure --gcc + cov-configure --python + - name: Setup IMEX and Coverity Build + run: | + source $HOME/miniconda/bin/activate + set -e + set -x + + echo "SET EXTERNAL LIT" + external_lit=`which lit` + echo $external_lit + export LEVEL_ZERO_DIR=$HOME_DIR/level-zero/level-zero/level_zero_install/ + export LEVEL_ZERO_VERSION_CHECK_OFF=1 + export TBB_PATH=$HOME_DIR/tbb/oneapi-tbb-${TBB_VER} + + + mkdir -p $HOME_DIR/tmpdir + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + + echo "============Building the app====================" + cov-build --dir cov_dir python3 build_tools/build_imex.py --working-dir $HOME_DIR/tmpdir --llvm-install $HOME_DIR/llvm-mlir/_mlir_install --external-lit ${external_lit} + #echo "============Build done====================" + + #python build_tools/build_imex.py \ + # --working-dir $HOME_DIR/tmpdir \ + # --llvm-install $HOME_DIR/llvm-mlir/_mlir_install \ + #--external-lit ${external_lit} + + - name: Coverity Analysis + run: | + cov-analyze --dir frameworks.ai.mlir.mlir-extensions/cov_dir + echo "Analysis is done" + cov-format-errors --dir frameworks.ai.mlir.mlir-extensions/cov_dir --json-output-v7 coverity_dir_result.json + + - name: Upload Coverity Scan results + uses: actions/upload-artifact@v2 + with: + name: coverity_dir_result.json + path: coverity_dir_result.json + + - name: coverity UI transfer + env: + no_proxy: coverityent.devtools.intel.com, intel.com + run: | + cov-commit-defects --dir frameworks.ai.mlir.mlir-extensions/cov_dir --url https://coverityent.devtools.intel.com/prod5 --user nbpatel --password ${{ secrets.NISHANTPASSWORD }} --stream "MLIR_Prod_main" diff --git a/.github/workflows/sync-embargo.yml b/.github/workflows/sync-embargo.yml new file mode 100644 index 000000000..7cdae1b55 --- /dev/null +++ b/.github/workflows/sync-embargo.yml @@ -0,0 +1,48 @@ +# Sync innersouce repo to upstream mlir-extensions + +name: Sync from main to imex-embargo + +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + workflow_call: + push: + paths: + - .github/workflows/sync-embargo.yml + schedule: + - cron: '30 19 * * *' + +jobs: + sync-embargo: + ### + # Syncs main branch of this repo to open source intel/mlir-extensions + ### + runs-on: [self-hosted, icx] + + steps: + - name: Check build root + run: | + export HOME_DIR=$(pwd)/sync + echo HOME_DIR=${HOME_DIR} >>$GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} + ref: imex-embargo + fetch-depth: 0 + path: ${{env.HOME_DIR}}/frameworks.ai.mlir.mlir-extensions + - name: Fetch Upstream + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git fetch + - name: Merge Upstream to imex-embargo + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git config --global user.email "alexei.fedotov@gmail.com" + git config --global user.name "Alexei Fedotov" + git merge origin/main --no-edit + - name: Push + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git push -f diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 000000000..001445087 --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,49 @@ +# Sync innersouce repo to upstream mlir-extensions + +name: Sync from Upstream Public Repo + +on: + workflow_dispatch: + workflow_call: + push: + paths: + - .github/workflows/sync.yml + +jobs: + sync-main: + ### + # Syncs main branch of this repo to open source intel/mlir-extensions + ### + runs-on: [self-hosted, icx] + + steps: + - name: Check build root + run: | + export HOME_DIR=$(pwd)/sync + echo HOME_DIR=${HOME_DIR} >>$GITHUB_ENV + + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} + ref: main + fetch-depth: 0 + path: ${{env.HOME_DIR}}/frameworks.ai.mlir.mlir-extensions + - name: Add Upstream + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git remote add upstream https://github.com/intel/mlir-extensions.git + - name: Fetch Upstream + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git fetch upstream + - name: Merge Upstream into main + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git config --global user.email "alexei.fedotov@gmail.com" + git config --global user.name "Alexei Fedotov" + git merge upstream/main --no-edit + - name: Push + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + git push -f origin main diff --git a/.gitignore b/.gitignore index 0c4b85f2f..88830cea0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,7 @@ _install/ .idea/ cmake-build-debug/ cmake-build-release/ -.github/ dev_scripts/ -docker/ compile_commands.json *~ diff --git a/CMakeLists.txt b/CMakeLists.txt index f06220661..5d0a10e84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,15 @@ else () set(IMEX_ENABLE_VULKAN_RUNNER 0) endif() +# Run tests using FS simulator +set(IMEX_ENABLE_FS_SIMULATOR 0 CACHE BOOL "Enable FS simulator mode for tests") + +if (IMEX_ENABLE_FS_SIMULATOR) + set(IMEX_ENABLE_FS_SIMULATOR 1) +else () + set(IMEX_ENABLE_FS_SIMULATOR 0) +endif() + if (IMEX_ENABLE_ATS_TARGET) set(IMEX_ENABLE_ATS_TARGET 1) else () @@ -250,7 +259,6 @@ else () set(IMEX_ENABLE_PVC_TARGET 0) endif() - if (NOT (CMAKE_BUILD_TYPE MATCHES Debug)) if (IMEX_ENABLE_DEBUG_BUILD) set (CMAKE_BUILD_TYPE Debug) diff --git a/dev_scripts/DEVELOPMENT.md b/dev_scripts/DEVELOPMENT.md new file mode 100644 index 000000000..568dd17f7 --- /dev/null +++ b/dev_scripts/DEVELOPMENT.md @@ -0,0 +1,70 @@ +# IMEX development flow +## Intro +IMEX currently has two repos. One is the public IMEX repo and other is an innersource IMEX repo. Recommended development model for internal developers is + +Step 0: Do initial setup – see instructions below. + +Step 1: Develop features using a branch and then create a PR against innersource IMEX repo’s “main” branch. Code review and CI checks will be done using innersource repo. + +Step 2: Run “prepare_upstream.sh” script to create a new branch based on public repo “main” and adds a single squashed commit from PR. You would be prompted to edit the squashed commit message. If you PR branch was named “foo” the new branch will be auto named as “foo_for_upstream” +``` +$> ./dev_scripts/prepare_upstream.sh +``` + +Step 3: Push the new branch to public repo “main”. +``` +$> git push upstream foo_for_upstream:main +``` + +Step 4: Delete the new branch. + +## Initial setup +### 1. Setup innersource and checkout innersource IMEX +Step 1: download dt +``` +$> curl -fL https://goto.intel.com/getdt | sh +``` +Step 2: make downloaded dt executable +``` +$> chmod +x dt +``` +Step 3: install a local copy of dt +``` +$> ./dt install +``` +Step 4: remove downloaded dt +``` +$> rm dt +``` +Step 5: setup with installed dt +``` +$> dt setup +``` +Follow instructions on screen. Make sure during dt setup to generate new token. And select netrc. (should be default) This will help setup netrc file with proper credentials + +Step 6: clone imex innersource repo +``` +$> git clone https://github.com/intel-innersource/frameworks.ai.mlir.mlir-extensions.git +``` + +### 2. (Optional) Create personal innersource IMEX fork (Skip this part if you prefer working directly on innersource IMEX branches) + +Step 1: Click “Fork” button on https://github.com/intel-innersource/frameworks.ai.mlir.mlir-extensions + +Step 2: Select your account in the “owner” pull down list and click “Create fork” + +At this point you would see a personal fork on github. Something like https://github.com/silee2/frameworks.ai.mlir.mlir-extensions + +Step 3: add a new remote +``` +$> git remote add silee2 https://github.com/silee2/frameworks.ai.mlir.mlir-extensions +``` + +And you would see a new “remote” is added for the cloned repo + +Step 4: check git remote +``` +$> git remote +origin +silee2 +``` diff --git a/dev_scripts/prepare_upstream.sh b/dev_scripts/prepare_upstream.sh new file mode 100755 index 000000000..daf37aab4 --- /dev/null +++ b/dev_scripts/prepare_upstream.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# This script automates creating a PR for merging to upstream based on +# the PR created for innersource. +# This script is to be run from the innersource PR branch. + +# Step 0: fetch latest changes from innersource and upstream +# If remote for upstream does not exist, add it +if [ `git config remote.upstream.url 2> /dev/null` ] +then + if [ `git config remote.upstream.url 2> /dev/null` != "https://github.com/intel/mlir-extensions.git" ] + then + echo "Remote upstream already exists and does not match public IMEX" + exit 1 + fi +else + git remote add upstream https://github.com/intel/mlir-extensions.git +fi +# fetch from innersource(origin) and upstream +git fetch origin +git fetch upstream +# Checkout origin/main if origin/main is merged into this PR branch +if [ `git merge-base --is-ancestor origin/main HEAD` -ne 0 ] +then + echo "Please merge origin/main first, resolve merge conflicts if any and rerun this script." + exit 1 +fi + +# Step 1: Create a squashed single commit from current PR +curr_branch=`git rev-parse --abbrev-ref HEAD` +echo "Innersource PR branch name: ${curr_branch}" +# Create a temp branch for squashing, if it already exists, delete it first. +if [ `git rev-parse --verify temp_squashed_pr 2>/dev/null` ] +then + git branch -D temp_squashed_pr +fi +git checkout -b temp_squashed_pr origin/main +# Create a single squashed commit on top of innersource main +git merge --squash ${curr_branch} && git commit --no-edit +single_commit=`git rev-parse temp_squashed_pr` + +# Step 2: Create a new PR branch for upstreaming with the single commit +# branch name: _for_upstream +new_branch="${curr_branch}_for_upstream" +echo "Public PR branch name: ${new_branch}" +if [ `git rev-parse --verify ${new_branch} 2>/dev/null` ] +then + git branch -D ${new_branch} +fi +# create a new branch for upstreaming +git checkout -b ${new_branch} upstream/main +# cherry-pick the single commit and ask user to update commit message. +git cherry-pick ${single_commit} && git commit --amend diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..1d494d30e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,20 @@ +FROM summerwind/actions-runner:ubuntu-22.04 + +SHELL ["/bin/bash", "-ex", "-o", "pipefail", "-c"] + +USER root + +RUN export DEBIAN_FRONTEND=noninteractive \ + && curl -s https://repositories.intel.com/gpu/intel-graphics.key \ + | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg \ + && echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy max' \ + | tee /etc/apt/sources.list.d/intel-gpu.list \ + && curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor --output /usr/share/keyrings/oneapi-archive-keyring.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ + | tee /etc/apt/sources.list.d/oneAPI.list \ + && apt-get update --yes \ + && apt-get install build-essential cmake ninja-build intel-opencl-icd intel-level-zero-gpu clinfo intel-basekit --yes \ + && rm -rf /var/lib/apt/lists/* + +USER runner diff --git a/docker/Dockerfile.fs-sim b/docker/Dockerfile.fs-sim new file mode 100644 index 000000000..0d67af753 --- /dev/null +++ b/docker/Dockerfile.fs-sim @@ -0,0 +1,59 @@ +FROM summerwind/actions-runner:ubuntu-22.04 + +SHELL ["/bin/bash", "-ex", "-o", "pipefail", "-c"] + +USER root + +RUN export DEBIAN_FRONTEND=noninteractive \ + && curl -s https://repositories.intel.com/gpu/intel-graphics.key \ + | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg \ + && echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy max' \ + | tee /etc/apt/sources.list.d/intel-gpu.list \ + && curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor --output /usr/share/keyrings/oneapi-archive-keyring.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ + | tee /etc/apt/sources.list.d/oneAPI.list \ + && apt-get update --yes \ + && apt-get install \ + # mlir-extensions requirements + python3-pip \ + build-essential \ + cmake \ + ninja-build \ + clang \ + intel-opencl-icd \ + intel-level-zero-gpu \ + clinfo \ + intel-basekit \ + # Intel GPU requirements + intel-level-zero-gpu \ + level-zero \ + level-zero-dev \ + # FS simulator requirements + openmpi-bin \ + libgdk-pixbuf2.0-0 \ + libglib2.0-0 \ + wget \ + --yes \ + && rm -rf /var/lib/apt/lists/* \ + && pip3 install psutil + +USER runner + +ENV WORK_ROOT=${HOME}/trees +ENV WORKSPACE=${WORK_ROOT}/fs +ENV HVT_OUTPUT_FOLDER=${WORKSPACE}/hvt-output + +RUN mkdir ${HOME}/neo && cd ${HOME}/neo \ + && curl https://artifactory-kfs.habana-labs.com/artifactory/bin-generic-dev-local/NEO/latest/NEO-master.tgz | tar zxf - \ + && sudo dpkg -i -E --force-all *.deb dbgsym/*.ddeb + +RUN sudo apt-get update --yes \ + && mkdir -p ${WORKSPACE} \ + && cd ${WORKSPACE} \ + && curl https://artifactory-kfs.habana-labs.com/artifactory/bin-generic-dev-local/CORAL_FS/latest/CORAL_FS-master.tgz | tar zxf - \ + && export KMD_VERSION=6.8.0-rc6 \ + && export KMD_RELEASE=0.4.0 \ + && source ${WORKSPACE}/scripts/setup.sh \ + && setup_fs_dev \ + && sudo rm -rf /var/lib/apt/lists/* diff --git a/docker/Dockerfile.local b/docker/Dockerfile.local new file mode 100644 index 000000000..38947fd90 --- /dev/null +++ b/docker/Dockerfile.local @@ -0,0 +1,75 @@ +FROM ubuntu:22.04 + +SHELL ["/bin/bash", "-ex", "-o", "pipefail", "-c"] + +USER root + +RUN export DEBIAN_FRONTEND=noninteractive \ + && apt-get update --yes \ + && apt-get install \ + # mlir-extensions requirements + python3-pip \ + build-essential \ + cmake \ + ninja-build \ + clang \ + curl gpg \ + --yes \ + && pip3 install psutil + +RUN export DEBIAN_FRONTEND=noninteractive \ + && curl -s https://repositories.intel.com/gpu/intel-graphics.key \ + | gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg \ + && echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/gpu/ubuntu jammy max' \ + | tee /etc/apt/sources.list.d/intel-gpu.list \ + && curl https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ + | gpg --dearmor --output /usr/share/keyrings/oneapi-archive-keyring.gpg \ + && echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \ + | tee /etc/apt/sources.list.d/oneAPI.list \ + && apt-get update --yes \ + && apt-get install \ + # mlir-extensions requirements + intel-opencl-icd \ + intel-level-zero-gpu \ + clinfo \ + intel-basekit \ + # Intel GPU requirements + intel-level-zero-gpu \ + level-zero \ + level-zero-dev \ + # FS simulator requirements + libopenmpi-dev \ + libgdk-pixbuf2.0-0 \ + libglib2.0-0 \ + wget \ + sudo \ + --yes \ + && rm -rf /var/lib/apt/lists/* + +RUN useradd -m dev && \ + echo "%sudo ALL = (ALL) NOPASSWD: ALL" >>/etc/sudoers && \ + usermod -aG sudo dev + +ENV HOME=/home/dev +USER dev +WORKDIR ${HOME} + +ENV WORK_ROOT=${HOME}/trees +ENV WORKSPACE=${WORK_ROOT}/fs +ENV HVT_OUTPUT_FOLDER=${WORKSPACE}/hvt-output +ENV NEO_BINARIES_ROOT=${HOME}/neo + +RUN mkdir ${HOME}/neo && cd ${HOME}/neo \ + && curl https://artifactory-kfs.habana-labs.com/artifactory/bin-generic-dev-local/NEO/latest/NEO-master.tgz | tar zxf - \ + && sudo dpkg -i -E --force-all *.deb dbgsym/*.ddeb + +RUN mkdir -p ${WORKSPACE} \ + && cd ${WORKSPACE} \ + && curl https://artifactory-kfs.habana-labs.com/artifactory/bin-generic-dev-local/CORAL_FS/latest/CORAL_FS-master.tgz | tar zxf - \ + && export KMD_VERSION=6.8.0-rc6 \ + && export KMD_RELEASE=0.4.0 \ + && source ${WORKSPACE}/scripts/setup.sh \ + && setup_fs_dev + +COPY simulator_check.cpp . +RUN source /opt/intel/oneapi/setvars.sh && icpx -fsycl simulator_check.cpp -o simulator_check diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..6c724c057 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,22 @@ +To build the container use the following command: +``` +$ docker buildx build docker -f docker/Dockerfile.local -t mlir.local +``` + +Or this may take a form of +``` +docker build docker --build-arg "http_proxy=$http_proxy" --build-arg "https_proxy=$https_proxy" --build-arg "no_proxy=.habana-labs.com" -f docker/Dockerfile.local -t mlir.local + +``` + +To run the container use the following command: +``` +$ docker run -ti mlir.local +``` + +To launch the test with the simulator use: +``` +(cd ${WORK_ROOT}/fs/scripts && source setup.sh && umd_driver_env_variables_export && run_coral_fs -r -m umd) &> fs-sim.log & +source /opt/intel/oneapi/setvars.sh +ForceBCSForInternalCopyEngine=1 ForceBcsEngineIndex=1 ForceDeviceId=0B73 HardwareInfoOverride=1x4x8 IGC_Disable512GRFISA=0 NEOReadDebugKeys=1 OverrideSlmSize=320 PrintDebugSettings=1 ProductFamilyOverride=fcs RebuildPrecompiledKernels=1 KNOB_MAX_CORES_PER_NUMA_NODE=3 KNOB_XE3P_ENABLE_IGA_XE3PX=1 SetCommandStreamReceiver=2 TbxPort=1234 ./simulator_check +``` diff --git a/docker/simulator_check.cpp b/docker/simulator_check.cpp new file mode 100644 index 000000000..fad2c675e --- /dev/null +++ b/docker/simulator_check.cpp @@ -0,0 +1,20 @@ +#include +using namespace sycl; + +static const int N = 8; + +int main(){ + queue q; + std::cout << "Device: " << q.get_device().get_info() << std::endl; + + int *data = malloc_shared(N, q); + for(int i=0; i(N), [=] (id<1> i){ + data[i] *= 2; + }).wait(); + + for(int i=0; i { OptionalParameter<"xetile::WorkGroupMapAttr">:$wg_map, DefaultValuedParameter<"mlir::DenseI32ArrayAttr", "mlir::DenseI32ArrayAttr::get($_ctxt, {1, 0})">:$order, OptionalParameter<"mlir::DenseI64ArrayAttr">:$inner_blocks, - OptionalParameter<"mlir::DenseI32ArrayAttr">:$wg_data + OptionalParameter<"mlir::DenseI32ArrayAttr">:$wg_data, + OptionalParameter<"mlir::Attribute">:$memory_scope ); let assemblyFormat = "`<` struct(params) `>`"; let genVerifyDecl = true; @@ -73,27 +74,36 @@ def XeTile_TileAttr : XeTile_Attr<"XeTile", "tile_attr"> { CArg<"xetile::WorkGroupMapAttr", "{}">:$wg_map, CArg<"llvm::ArrayRef", "{1, 0}">:$order, CArg<"llvm::ArrayRef", "{}">:$inner_blocks, - CArg<"llvm::ArrayRef", "{}">:$wg_data), + CArg<"llvm::ArrayRef", "{}">:$wg_data, + CArg<"int", "0">:$memory_scope), [{ + mlir::Type intType = mlir::IntegerType::get($_ctxt, 32); return $_get($_ctxt, sg_map, wg_map, mlir::DenseI32ArrayAttr::get($_ctxt, order), mlir::DenseI64ArrayAttr::get($_ctxt, inner_blocks), - mlir::DenseI32ArrayAttr::get($_ctxt, wg_data)); + mlir::DenseI32ArrayAttr::get($_ctxt, wg_data), + mlir::IntegerAttr::get(intType, memory_scope)); }]>, - AttrBuilder<(ins CArg<"llvm::ArrayRef", "{1, 0}">:$order), + AttrBuilder<(ins CArg<"llvm::ArrayRef", "{1, 0}">:$order, + CArg<"int", "0">:$memory_scope), [{ + mlir::Type intType = mlir::IntegerType::get($_ctxt, 32); return $_get($_ctxt, xetile::SubGroupMapAttr(), xetile::WorkGroupMapAttr(), mlir::DenseI32ArrayAttr::get($_ctxt, order), mlir::DenseI64ArrayAttr::get($_ctxt, {}), - mlir::DenseI32ArrayAttr::get($_ctxt, {})); + mlir::DenseI32ArrayAttr::get($_ctxt, {}), + mlir::IntegerAttr::get(intType, memory_scope)); }]>, AttrBuilder<(ins CArg<"xetile::SubGroupMapAttr", "{}">:$sg_map, CArg<"xetile::WorkGroupMapAttr", "{}">:$wg_map, CArg<"llvm::ArrayRef", "{1, 0}">:$order, - CArg<"llvm::ArrayRef", "{}">:$wg_data), + CArg<"llvm::ArrayRef", "{}">:$wg_data, + CArg<"int", "0">:$memory_scope), [{ + mlir::Type intType = mlir::IntegerType::get($_ctxt, 32); return $_get($_ctxt, sg_map, wg_map, mlir::DenseI32ArrayAttr::get($_ctxt, order), mlir::DenseI64ArrayAttr::get($_ctxt, {}), - mlir::DenseI32ArrayAttr::get($_ctxt, wg_data)); + mlir::DenseI32ArrayAttr::get($_ctxt, wg_data), + mlir::IntegerAttr::get(intType, memory_scope)); }]> ]; } diff --git a/include/imex/Dialect/XeTile/IR/XeTileOps.td b/include/imex/Dialect/XeTile/IR/XeTileOps.td index a2e39e950..89f7ba012 100644 --- a/include/imex/Dialect/XeTile/IR/XeTileOps.td +++ b/include/imex/Dialect/XeTile/IR/XeTileOps.td @@ -197,6 +197,21 @@ def XeTile_InitTileOp : XeTile_Op<"init_tile", [Pure, AttrSizedOperandSegments]> return getDynamicStrides().size(); } + mlir::Attribute getSourceMemorySpace() { + if (isSourceMemRef()) + return mlir::cast(getSourceType()).getMemorySpace(); + return mlir::Attribute(); + } + + unsigned getSourceMemorySpaceAsInt() { + auto attr = getSourceMemorySpace(); + if (attr) { + if (mlir::isa(attr)) + return static_cast(mlir::cast(attr).getInt()); + } + return 0; + } + /// Returns the offsets info to the source. It consolidates /// information from both dynamic_offsets and static_offsets /// parameters. static_offsets parameter always has the expected diff --git a/include/imex/Dialect/XeTile/IR/XeTileTypes.td b/include/imex/Dialect/XeTile/IR/XeTileTypes.td index f088185a1..0ec9ca9e5 100644 --- a/include/imex/Dialect/XeTile/IR/XeTileTypes.td +++ b/include/imex/Dialect/XeTile/IR/XeTileTypes.td @@ -124,6 +124,25 @@ def XeTile : XeTile_Type<"Tile", "tile", [ShapedTypeInterface], return mlir::DenseI32ArrayAttr::get(getContext(), {1, 0}); } + mlir::Attribute getMemoryScope() { + auto encoding = llvm::dyn_cast_if_present(getEncoding()); + if (encoding) + return encoding.getMemoryScope(); + return mlir::Attribute(); + } + + int getMemoryScopeAsInt() { + auto encoding = llvm::dyn_cast_if_present(getEncoding()); + if (encoding && encoding.getMemoryScope()) { + auto memoryScope = encoding.getMemoryScope(); + assert(mlir::isa(memoryScope) && + "Using `getMemorySpaceAsInt` with non-Integer attribute"); + return mlir::cast(memoryScope).getInt(); + } + // return default value 0 indicating Global memory + return 0; + } + }]; let assemblyFormat = "`<` custom($shape, $elementType, $encoding) `>`"; diff --git a/lib/Conversion/XeTileToXeGPU/XeTileOpConversion.cpp b/lib/Conversion/XeTileToXeGPU/XeTileOpConversion.cpp index d456ef8e9..e23ffd143 100644 --- a/lib/Conversion/XeTileToXeGPU/XeTileOpConversion.cpp +++ b/lib/Conversion/XeTileToXeGPU/XeTileOpConversion.cpp @@ -389,6 +389,10 @@ class SgInitTileOpPattern : public XeOneToNConversion { auto shape = llvm::to_vector(tileTy.getShape()); auto indexType = rewriter.getIndexType(); + auto memoryScope = op.getSourceMemorySpaceAsInt() == 3 + ? mlir::xegpu::MemoryScope::SLM + : mlir::xegpu::MemoryScope::Global; + if (tileTy.getRank() != 2) return op.emitOpError("The tile shape should be 2D."); @@ -457,8 +461,7 @@ class SgInitTileOpPattern : public XeOneToNConversion { std::swap(offsetsX, offsetsY); auto tDescTy = mlir::xegpu::TensorDescType::get( - innerBlk, elemTy, array_length, true /*boundary_check*/, - mlir::xegpu::MemoryScope::Global); + innerBlk, elemTy, array_length, true /*boundary_check*/, memoryScope); auto createIndexConstant = [&](mlir::Type type, int64_t value) { auto attr = rewriter.getIndexAttr(value); diff --git a/lib/Dialect/XeTile/IR/XeTileDialect.cpp b/lib/Dialect/XeTile/IR/XeTileDialect.cpp index 9c2e57f69..ddf822998 100644 --- a/lib/Dialect/XeTile/IR/XeTileDialect.cpp +++ b/lib/Dialect/XeTile/IR/XeTileDialect.cpp @@ -116,7 +116,7 @@ mlir::LogicalResult XeTileAttr::verify( ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::imex::xetile::SubGroupMapAttr sg_map, xetile::WorkGroupMapAttr wg_map, mlir::DenseI32ArrayAttr order, mlir::DenseI64ArrayAttr inner_blocks, - mlir::DenseI32ArrayAttr wg_data) { + mlir::DenseI32ArrayAttr wg_data, mlir::Attribute memoryScope) { if (order != mlir::DenseI32ArrayAttr() && order.size() != 2) emitError() << "expect integer array of size 2 for order"; diff --git a/lib/Dialect/XeTile/IR/XeTileOps.cpp b/lib/Dialect/XeTile/IR/XeTileOps.cpp index df61262ed..779fe8826 100644 --- a/lib/Dialect/XeTile/IR/XeTileOps.cpp +++ b/lib/Dialect/XeTile/IR/XeTileOps.cpp @@ -188,6 +188,10 @@ mlir::LogicalResult InitTileOp::verify() { row_major = false; } + if (getSourceMemorySpace() != tileTy.getMemoryScope()) + return emitOpError( + "memory space of the tile doesn't match with the source."); + if (isSourceMemRef() && sourceMemRefHasStaticShape()) { auto memrefType = mlir::dyn_cast(getSourceType()); diff --git a/lib/Dialect/XeTile/Transforms/BlockAligning.cpp b/lib/Dialect/XeTile/Transforms/BlockAligning.cpp index 7924f223c..218a5fcd2 100644 --- a/lib/Dialect/XeTile/Transforms/BlockAligning.cpp +++ b/lib/Dialect/XeTile/Transforms/BlockAligning.cpp @@ -205,7 +205,8 @@ struct InitTileOpPattern auto attr = imex::xetile::XeTileAttr::get( op.getContext(), tileTy.getSgMap(), tileTy.getWgMap(), - tileTy.getOrder(), newBlockSize, tileTy.getWgData()); + tileTy.getOrder(), newBlockSize, tileTy.getWgData(), + tileTy.getMemoryScope()); auto newTileTy = imex::xetile::TileType::get(tileTy.getShape(), tileTy.getElementType(), attr); diff --git a/lib/Dialect/XeTile/Transforms/Blocking.cpp b/lib/Dialect/XeTile/Transforms/Blocking.cpp index 86b6ba382..4e4c896bc 100644 --- a/lib/Dialect/XeTile/Transforms/Blocking.cpp +++ b/lib/Dialect/XeTile/Transforms/Blocking.cpp @@ -848,7 +848,8 @@ struct InitTileOpPattern auto attr = imex::xetile::XeTileAttr::get( op.getContext(), tileTy.getSgMap(), tileTy.getWgMap(), - tileTy.getOrder(), innerBlocks, tileTy.getWgData()); + tileTy.getOrder(), innerBlocks, tileTy.getWgData(), + tileTy.getMemoryScope()); auto newTileTy = imex::xetile::TileType::get(tileTy.getShape(), elemTy, attr); diff --git a/lib/Dialect/XeTile/Transforms/OptimizeTranspose.cpp b/lib/Dialect/XeTile/Transforms/OptimizeTranspose.cpp index 2c26ff76f..957da6bc9 100644 --- a/lib/Dialect/XeTile/Transforms/OptimizeTranspose.cpp +++ b/lib/Dialect/XeTile/Transforms/OptimizeTranspose.cpp @@ -110,11 +110,12 @@ struct InitTileOpPattern final imex::swapLastTwoElements(sourceShape), newStrides); // Create a new initTileOp with the new source by using the order attribute + auto orderAttr = sourceIsRowMajor + ? mlir::DenseI32ArrayAttr::get(getContext(), {0, 1}) + : mlir::DenseI32ArrayAttr::get(getContext(), {1, 0}); auto newTileAttr = imex::xetile::XeTileAttr::get( - getContext(), tileTy.getSgMap(), tileTy.getWgMap(), - (sourceIsRowMajor ? mlir::DenseI32ArrayAttr::get(getContext(), {0, 1}) - : mlir::DenseI32ArrayAttr::get(getContext(), {1, 0})), - tileTy.getInnerBlocks(), tileTy.getWgData()); + getContext(), tileTy.getSgMap(), tileTy.getWgMap(), orderAttr, + tileTy.getInnerBlocks(), tileTy.getWgData(), tileTy.getMemoryScope()); auto transposedTileTy = imex::xetile::TileType::get( imex::swapLastTwoElements(initOp.getType().getShape()), initOp.getElementType(), newTileAttr); diff --git a/test/Conversion/XeTileToXeGPU/sg_mixed_scf.mlir b/test/Conversion/XeTileToXeGPU/sg_mixed_scf.mlir index a417b8abb..d9640d474 100755 --- a/test/Conversion/XeTileToXeGPU/sg_mixed_scf.mlir +++ b/test/Conversion/XeTileToXeGPU/sg_mixed_scf.mlir @@ -99,23 +99,23 @@ gpu.module @postop_reduce_m attributes {spirv.target_env = #spirv.target_env<#sp //CHECK: %{{.*}} = vector.shuffle %{{.*}}, %{{.*}} [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31] : vector<16xf32>, vector<16xf32> %40 = vector.multi_reduction , %39, %cst_1 [0] : vector<32x32xf32> to vector<32xf32> %41 = vector.shape_cast %40 : vector<32xf32> to vector<1x32xf32> - %alloc = memref.alloc() : memref<8x128xf32, #spirv.storage_class> + %alloc = memref.alloc() : memref<8x128xf32, 3> - //CHECK: %{{.*}} = xegpu.create_nd_tdesc %{{.*}} : memref<8x128xf32, #spirv.storage_class> -> !xegpu.tensor_desc<1x16xf32, #xegpu.block_tdesc_attr> + //CHECK: %{{.*}} = xegpu.create_nd_tdesc %{{.*}} : memref<8x128xf32, 3> -> !xegpu.tensor_desc<1x16xf32, #xegpu.block_tdesc_attr> //CHECK: %{{.*}} = arith.addi %{{.*}}, %{{.*}} : index - //CHECK: %{{.*}} = xegpu.create_nd_tdesc %{{.*}} : memref<8x128xf32, #spirv.storage_class> -> !xegpu.tensor_desc<1x16xf32, #xegpu.block_tdesc_attr> - %42 = xetile.init_tile %alloc[%17, %13] : memref<8x128xf32, #spirv.storage_class> -> !xetile.tile<1x32xf32> + //CHECK: %{{.*}} = xegpu.create_nd_tdesc %{{.*}} : memref<8x128xf32, 3> -> !xegpu.tensor_desc<1x16xf32, #xegpu.block_tdesc_attr> + %42 = xetile.init_tile %alloc[%17, %13] : memref<8x128xf32, 3> -> !xetile.tile<1x32xf32, #xetile.tile_attr> //CHECK-COUNT-2: vector.extract_strided_slice %{{.*}} {offsets = {{.*}}, sizes = [1, 16], strides = [1, 1]} : vector<1x32xf32> to vector<1x16xf32> - //CHECK-COUNT-2: xegpu.store_nd %{{.*}}, %{{.*}} <{l1_hint = #xegpu.cache_hint, l2_hint = #xegpu.cache_hint, l3_hint = #xegpu.cache_hint}> : vector<1x16xf32>, !xegpu.tensor_desc<1x16xf32, #xegpu.block_tdesc_attr> - xetile.store_tile %41, %42 : vector<1x32xf32>, !xetile.tile<1x32xf32> + //CHECK-COUNT-2: xegpu.store_nd %{{.*}}, %{{.*}} <{l1_hint = #xegpu.cache_hint, l2_hint = #xegpu.cache_hint, l3_hint = #xegpu.cache_hint}> : vector<1x16xf32>, !xegpu.tensor_desc<1x16xf32, #xegpu.block_tdesc_attr> + xetile.store_tile %41, %42 : vector<1x32xf32>, !xetile.tile<1x32xf32, #xetile.tile_attr> - //CHECK: xegpu.create_nd_tdesc %{{.*}} : memref<8x128xf32, #spirv.storage_class> -> !xegpu.tensor_desc<8x4xf32, #xegpu.block_tdesc_attr> - //CHECK: xegpu.load_nd {{.*}} <{l1_hint = #xegpu.cache_hint, l2_hint = #xegpu.cache_hint, l3_hint = #xegpu.cache_hint}> : !xegpu.tensor_desc<8x4xf32, #xegpu.block_tdesc_attr> -> vector<8x4xf32> + //CHECK: xegpu.create_nd_tdesc %{{.*}} : memref<8x128xf32, 3> -> !xegpu.tensor_desc<8x4xf32, #xegpu.block_tdesc_attr> + //CHECK: xegpu.load_nd {{.*}} <{l1_hint = #xegpu.cache_hint, l2_hint = #xegpu.cache_hint, l3_hint = #xegpu.cache_hint}> : !xegpu.tensor_desc<8x4xf32, #xegpu.block_tdesc_attr> -> vector<8x4xf32> //CHECK-COUNT-8: vector.extract_strided_slice %{{.*}} {offsets = {{.*}}, sizes = [1, 4], strides = [1, 1]} : vector<8x4xf32> to vector<1x4xf32> //CHECK-COUNT-8: arith.addf %{{.*}}, %{{.*}} : vector<1x4xf32> - %43 = xetile.init_tile %alloc[%21, %23] : memref<8x128xf32, #spirv.storage_class> -> !xetile.tile<8x4xf32> - %44 = xetile.load_tile %43 { padding = 0.000000e+00 : f32 } : !xetile.tile<8x4xf32> -> vector<8x4xf32> + %43 = xetile.init_tile %alloc[%21, %23] : memref<8x128xf32, 3> -> !xetile.tile<8x4xf32, #xetile.tile_attr> + %44 = xetile.load_tile %43 { padding = 0.000000e+00 : f32 } : !xetile.tile<8x4xf32, #xetile.tile_attr> -> vector<8x4xf32> %45 = vector.multi_reduction , %44, %cst_2 [0] : vector<8x4xf32> to vector<4xf32> %46 = vector.shape_cast %45 : vector<4xf32> to vector<1x4xf32> %47 = arith.addf %arg5, %46 : vector<1x4xf32> diff --git a/test/Dialect/XeTile/IR/invalid.mlir b/test/Dialect/XeTile/IR/invalid.mlir index 07fe5e58c..597b079b2 100644 --- a/test/Dialect/XeTile/IR/invalid.mlir +++ b/test/Dialect/XeTile/IR/invalid.mlir @@ -213,6 +213,13 @@ func.func @tile_unpack_invalid_output_shape(%in : vector<4x4x16x16xf16>) { %out = xetile.tile_unpack %in {inner_blocks = [16, 16]} : vector<4x4x16x16xf16> -> vector<32x64xf16> } +// ----- +func.func @test_init_tile_with_mismatch_memory_space(%a: memref<1024x1024xf16, 3>) { + // expected-error@+1 {{memory space of the tile doesn't match with the source}} + %1 = xetile.init_tile %a[8, 16] : memref<1024x1024xf16, 3> -> !xetile.tile<32x64xf16> + return +} + // ----- // expected-error@+1 {{expect integer array of size 2 for wi_layout}} #sg_map_2 = #xetile.sg_map< wi_layout = [2, 8, 2], wi_data = [1, 2]> diff --git a/test/Dialect/XeTile/IR/ops.mlir b/test/Dialect/XeTile/IR/ops.mlir index 267b09ce0..2fb6a2afa 100644 --- a/test/Dialect/XeTile/IR/ops.mlir +++ b/test/Dialect/XeTile/IR/ops.mlir @@ -22,6 +22,17 @@ #wg_map_b = #xetile.wg_map #wg_map_b2 = #xetile.wg_map +func.func @test_init_tile_for_slm(%a: memref<1024x1024xf16, 3>) { + //CHECK: xetile.init_tile {{.*}}[8, 16] : memref<1024x1024xf16, 3> -> !xetile.tile<32x64xf16, #xetile.tile_attr> + %1 = xetile.init_tile %a[8, 16] : memref<1024x1024xf16, 3> -> !xetile.tile<32x64xf16, #xetile.tile_attr> + return +} + +func.func @test_init_tile_for_global(%a: memref<1024x1024xf16, 0>) { + //CHECK: xetile.init_tile {{.*}}[8, 16] : memref<1024x1024xf16> -> !xetile.tile<32x64xf16> + %1 = xetile.init_tile %a[8, 16] : memref<1024x1024xf16, 0> -> !xetile.tile<32x64xf16> + return +} // init_tile with a static shaped memref // CHECK-LABEL: func @test_init_tile_using_static_memref({{.*}}) { diff --git a/test/Gen/NDArray/lit.local.cfg b/test/Gen/NDArray/lit.local.cfg new file mode 100644 index 000000000..f6c83d40e --- /dev/null +++ b/test/Gen/NDArray/lit.local.cfg @@ -0,0 +1,7 @@ +slow_simulator_tests = [ + 'unyops.i32.0.mlir', + 'binops.f32.4.mlir', + 'binops.i32.8.mlir', +] +if(config.imex_enable_fs_simulator): + config.excludes.update(slow_simulator_tests) diff --git a/test/Gen/PlaidML/lit.local.cfg b/test/Gen/PlaidML/lit.local.cfg index fca219940..e7497fac5 100644 --- a/test/Gen/PlaidML/lit.local.cfg +++ b/test/Gen/PlaidML/lit.local.cfg @@ -23,8 +23,19 @@ local_excludes = [ 'OpTest.Quantize.bf16.mlir', # rounds to different int value 'CppEdsl.DotF16_AccF32.bf16.mlir', ] +slow_simulator_tests = [ + 'CppEdsl.Convolution.bf16.mlir', + 'CppEdsl.Convolution.f16.mlir', + 'CppEdsl.Convolution.f32.mlir', + 'OpTest.ComplexConv2D.bf16.mlir', + 'OpTest.ComplexConv2D.f16.mlir', + 'OpTest.ComplexConv2D.f32.mlir', +] if(not config.imex_enable_excluded_tests): config.excludes.update(local_excludes) if(not config.imex_enable_bf16_tests): config.excludes.update(bf16_tests) + +if(config.imex_enable_fs_simulator): + config.excludes.update(slow_simulator_tests) diff --git a/test/Integration/Dialect/XeGPU/lit.local.cfg b/test/Integration/Dialect/XeGPU/lit.local.cfg index 7204f51ac..83ade2073 100644 --- a/test/Integration/Dialect/XeGPU/lit.local.cfg +++ b/test/Integration/Dialect/XeGPU/lit.local.cfg @@ -7,15 +7,30 @@ non_pvc_excludes = [ 'load2d-padding-f32.mlir', 'load2d-padding.mlir', 'gemm_4kx4kx4k_f16_f16_f16.mlir', - 'gemm_4kx4kx4k_dpas_sized_loads_f16_f16_f32.mlir' + 'gemm_4kx4kx4k_f16_f16_f16_w_8x32xf16_stores.mlir', + 'gemm_with_transposed_B_1kx1kx1k_f16_f16_f32.mlir', + 'flash_attention_fwd.mlir', + 'gemm_4kx4kx4k_f16_f16_f16_w_simple_B_prefetch.mlir' ] local_excludes = [ + 'gemm_4kx4kx4k_dpas_sized_loads_f16_f16_f32.mlir', # result mismatch 'gemm_SIMT_1024x1024x1024xf16_f16_f32.mlir' ] -if(not config.imex_enable_pvc_target): +if(not config.imex_enable_pvc_target and not config.imex_enable_fs_simulator): local_excludes += non_pvc_excludes +slow_simulator_tests = [ + 'gemm_4kx4kx4k_f16_f16_f16_w_8x32xf16_stores.mlir', + 'gemm_4kx4kx4k_f16_f16_f16.mlir', + 'gemm_4kx4kx4k_f16_f16_f16_w_simple_B_prefetch.mlir', + 'flash_attention_fwd.mlir', +] + +if(config.imex_enable_fs_simulator): + local_excludes += slow_simulator_tests + if(not config.imex_enable_excluded_tests): config.excludes.update(local_excludes) + diff --git a/test/Models/lit.local.cfg b/test/Models/lit.local.cfg index f5f6f7cf5..4f27a046e 100644 --- a/test/Models/lit.local.cfg +++ b/test/Models/lit.local.cfg @@ -1,4 +1,11 @@ local_excludes = ['resnet-50-linalg.mlir', 'resnet-50-linalg-without-tensor-pad.mlir',] +slow_simulator_tests = [ + 'mobilenetv3-linalg-without-tensor-pad.mlir', + 'mobilenetv3-linalg.mlir', +] if(not config.imex_enable_excluded_tests): config.excludes.update(local_excludes) + +if(config.imex_enable_fs_simulator): + config.excludes.update(slow_simulator_tests) diff --git a/test/PlaidML/lit.local.cfg b/test/PlaidML/lit.local.cfg index 664af2633..819cb9c48 100644 --- a/test/PlaidML/lit.local.cfg +++ b/test/PlaidML/lit.local.cfg @@ -12,5 +12,27 @@ local_excludes = [ 'OpTest.EltwiseAdd.dynamic.mlir', 'OpTest.Sum.dynamic.mlir', ] +slow_simulator_tests = [ + 'CppEdsl.Add.mlir', + 'CppEdsl.BigDot.mlir', + 'CppEdsl.Cast.mlir', + 'CppEdsl.Convolution.mlir', + 'CppEdsl.Cos.mlir', + 'CppEdsl.DupOut.mlir', + 'CppEdsl.Dot.mlir', + 'CppEdsl.EltwiseMod.mlir', + 'OpTest.ComplexConv2D.mlir', + 'OpTest.Conv1D.mlir', + 'OpTest.Conv2DDilated.mlir', + 'OpTest.Dot.mlir', + 'OpTest.BroadcastNonNumpy.mlir', + 'OpTest.GEMM_INT32.mlir', + 'OpTest.Layer.mlir', + 'OpTest.LayerEmbeddedConst.mlir', + 'OpTest.Pow.mlir', +] if(not config.imex_enable_excluded_tests): config.excludes.update(local_excludes) + +if(config.imex_enable_fs_simulator): + config.excludes.update(slow_simulator_tests) diff --git a/test/SPIRV/lit.local.cfg b/test/SPIRV/lit.local.cfg index 7c85db38c..b16856e41 100644 --- a/test/SPIRV/lit.local.cfg +++ b/test/SPIRV/lit.local.cfg @@ -9,8 +9,27 @@ bf16_tests = [ local_excludes = [] +slow_simulator_tests = [ + 'CppEdsl.Convolution_BF16.mlir', + 'OpTest.ArgMax_BF16.mlir', + 'OpTest.Argmax_FLOAT32.mlir', + 'OpTest.Conv2D_FLOAT32.mlir', + 'OpTest.EltwiseAdd_BF16.mlir', + 'OpTest.EltwiseAdd_FLOAT32.mlir', + 'OpTest.ExplicitPadding_FLOAT32.mlir', + 'OpTest.Quantize_FLOAT32.mlir', + 'OpTest.SlmDynamic.mlir', + 'OpTest.Softmax_FLOAT32.mlir', + 'OpTest.MaxPool1D_INT64.mlir', + 'OpTest.GEMM_BF16.mlir', + 'OpTest.GEMM_F16_ACC_F32.mlir', +] + if(not config.imex_enable_excluded_tests): config.excludes.update(local_excludes) if(not config.imex_enable_bf16_tests): config.excludes.update(bf16_tests) + +if(config.imex_enable_fs_simulator): + config.excludes.update(slow_simulator_tests) diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in index 829e46573..aac26db4d 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -41,6 +41,7 @@ config.imex_enable_bf16_tests = @IMEX_ENABLE_BF16_TESTS@ config.imex_enable_excluded_tests = @IMEX_ENABLE_EXCLUDED_TESTS@ config.imex_enable_ats_target = @IMEX_ENABLE_ATS_TARGET@ config.imex_enable_pvc_target = @IMEX_ENABLE_PVC_TARGET@ +config.imex_enable_fs_simulator = @IMEX_ENABLE_FS_SIMULATOR@ if sys.platform.startswith('win32'): config.shlib_prefix = "" @@ -66,6 +67,22 @@ if config.imex_enable_igpu: config.igpu_fp64 = "--no-igpu-fp64" except subprocess.TimeoutExpired: config.igpu_fp64 = "--no-igpu-fp64" +if config.imex_enable_fs_simulator: + config.environment.update({ + "ForceBCSForInternalCopyEngine": "1", + "ForceBcsEngineIndex": "1", + "ForceDeviceId": "0B73", + "HardwareInfoOverride": "1x4x8", + "IGC_Disable512GRFISA": "0", + "NEOReadDebugKeys": "1", + "OverrideSlmSize": "320", + "PrintDebugSettings": "1", + "ProductFamilyOverride": "fcs", + "RebuildPrecompiledKernels": "1", + "SetCommandStreamReceiver": "2", + "TbxPort": "1234", + }) + config.imex_runner_utils = os.path.normpath(os.path.join(config.imex_lib_dir, config.shlib_prefix + "imex_runner_utils" + config.llvm_shlib_ext)) # Support substitution of the tools_dir with user parameters. This is