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..7a6f9d717 --- /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, pvc, 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@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 + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions || exit 1 + 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=. || 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_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..ec05100a7 --- /dev/null +++ b/.github/workflows/build_gpu-fs-sim.yml @@ -0,0 +1,99 @@ +name: GPU Build and run tests on FS simulator + +on: + workflow_dispatch: + workflow_call: + +jobs: + build: + if: github.repository == 'intel-innersource/frameworks.ai.mlir.mlir-extensions' + runs-on: [self-hosted, fs-sim, glados] + 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: Setup 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 + cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level-zero-install + cmake --build build --target install + + - 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 -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=$HOME_DIR/level-zero-install/ -DLLVM_LIT_ARGS="-j 1 --debug --timeout=600" -DIMEX_ENABLE_FS_SIMULATOR=ON || exit + sed -e 's,-printAllFeatures,,g' -i ${WORK_ROOT}/fs/scripts/run_in_a_loop_xesim.sh + (cd ${WORK_ROOT}/fs/scripts && source setup.sh && umd_driver_env_variables_export && umd_driver_rasty_backend_env_variables_export && ./run_in_a_loop_xesim.sh) &> fs-sim.log & + SIM_PID=$! + cmake --build build --target check-imex | 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@v3 + 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@v3 + 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@v3 + 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..529fd29e9 --- /dev/null +++ b/.github/workflows/build_gpu.yml @@ -0,0 +1,92 @@ +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, glados] + 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: Setup 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 + cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../level-zero-install + cmake --build build --target install + + - 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 + 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=. -DIMEX_ENABLE_SYCL_RUNTIME=1 -DIMEX_ENABLE_L0_RUNTIME=1 -DLEVEL_ZERO_DIR=$HOME_DIR/level-zero-install/ || exit + set -o pipefail + cmake --build build --target check-imex | tee build/tests.txt + + # /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@v3 + 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..e33f13841 --- /dev/null +++ b/.github/workflows/rebuild_base_docker_fs_sim.yml @@ -0,0 +1,47 @@ +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: 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 + - fs-sim + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag }} + run: | + cd docker + docker build . -f Dockerfile.fs-sim \ + --tag ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag }} + + - name: Push image ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag }} + if: ${{ inputs.push == 'true' }} + run: docker push ${{ env.DOCKER_REGISTRY }}/mlir-extensions-actions-runner-fs-sim:${{ inputs.image_tag }} diff --git a/.github/workflows/sdl.yml b/.github/workflows/sdl.yml new file mode 100644 index 000000000..d7d69c324 --- /dev/null +++ b/.github/workflows/sdl.yml @@ -0,0 +1,214 @@ +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: + repos: ${{ 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.yml b/.github/workflows/sync.yml new file mode 100644 index 000000000..23084d7d0 --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,62 @@ +# Sync innersouce repo to upstream mlir-extensions + +name: Sync to Upstream Public Repo + +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + workflow_call: + +jobs: + sync-main: + ### + # Syncs main branch of this repo to open source intel/mlir-extensions + ### + runs-on: [self-hosted, pvc, glados] + + steps: + - name: Check build root + run: | + export BUILD_ROOT=$(pwd)/sync + 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 * + + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} + ref: main + fetch-depth: 0 + path: ${{env.HOME_DIR}}/frameworks.ai.mlir.mlir-extensions + - name: Remove Upstream + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + if git remote | grep upstream; then + git remote remove upstream + else + echo "upstream does not exist" + fi + - 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 with git merge + run: | + cd $HOME_DIR/frameworks.ai.mlir.mlir-extensions + 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 f556e081c..e8319477b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,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 (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..30eaad328 --- /dev/null +++ b/dev_scripts/prepare_upstream.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# This scripts automates created a PR for upstream base on +# PR created for innersource + +# Step 0: fetch latest changes from innersource and upstream +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 +git fetch origin +git fetch upstream + +# 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}" +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 +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 +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 +git checkout -b ${new_branch} upstream/main +git cherry-pick ${single_commit} + +# Step 3: Update commit message +git commit --amend diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..4bbd14b1e --- /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/graphics/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/graphics/ubuntu jammy max' \ + | tee /etc/apt/sources.list.d/intel-graphics.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..5b4fb06e3 --- /dev/null +++ b/docker/Dockerfile.fs-sim @@ -0,0 +1,55 @@ +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/graphics/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/graphics/ubuntu jammy max' \ + | tee /etc/apt/sources.list.d/intel-graphics.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 \ + 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 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 - \ + # Remove following line after Habana fixes their setup script \ + && sed -e 's, export KMD_VERSION="6.6.0-rc3", export KMD_VERSION="6.7.0-rc5",g' -i ${WORKSPACE}/scripts/setup.sh \ + && source ${WORKSPACE}/scripts/setup.sh \ + && setup_fs_dev \ + && umd_driver_install \ + && sudo rm -rf /var/lib/apt/lists/* diff --git a/lib/Conversion/XeGPUToSPIRV/XeGPUToSPIRV.cpp b/lib/Conversion/XeGPUToSPIRV/XeGPUToSPIRV.cpp index dcfd9a1cf..2f7cba231 100644 --- a/lib/Conversion/XeGPUToSPIRV/XeGPUToSPIRV.cpp +++ b/lib/Conversion/XeGPUToSPIRV/XeGPUToSPIRV.cpp @@ -20,6 +20,7 @@ #include "mlir/IR/BuiltinAttributes.h" #include "mlir/Support/LogicalResult.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" #include @@ -281,13 +282,33 @@ class CreateNdDescToSPIRV : public OpConversionPattern { // fixme: support memref for now auto memType = cast(op.getSource().getType()); unsigned bitWidth = memType.getElementType().getIntOrFloatBitWidth(); - auto surfaceWidth = memType.getShape()[1] * (bitWidth / 8) - 1; - auto surfaceHeight = memType.getShape()[0] - 1; - // fixme: pitch = width for now - auto surfacePitch = surfaceWidth; - auto surfaceW = createIntConstant(i32Type, surfaceWidth); - auto surfaceH = createIntConstant(i32Type, surfaceHeight); - auto surfaceP = createIntConstant(i32Type, surfacePitch); + Value surfaceW, surfaceH, surfaceP; + if (memType.hasStaticShape()) { + auto surfaceWidth = memType.getShape()[1] * (bitWidth / 8) - 1; + auto surfaceHeight = memType.getShape()[0] - 1; + // fixme: pitch = width for now + auto surfacePitch = surfaceWidth; + surfaceW = createIntConstant(i32Type, surfaceWidth); + surfaceH = createIntConstant(i32Type, surfaceHeight); + surfaceP = createIntConstant(i32Type, surfacePitch); + + } else { + // get the surfaceWidth and Height from the op attributes + // compute surface width + auto bytesPerElem = createIntConstant(i32Type, bitWidth / 8); + auto one = createIntConstant(i32Type, 1); + surfaceW = rewriter.create( + loc, i32Type, adaptor.getDynamicShape()[1]); + surfaceW = rewriter.create(loc, surfaceW, bytesPerElem); + surfaceW = rewriter.create(loc, surfaceW, one); + // compute surface height + surfaceH = rewriter.create( + loc, i32Type, adaptor.getDynamicShape()[0]); + surfaceH = rewriter.create(loc, surfaceH, one); + // fixme: pitch = width for now + surfaceP = surfaceW; + } + payLoad = rewriter.create(loc, payLoad, surfaceW, idx2); payLoad = rewriter.create(loc, payLoad, 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/dynamic_memref.vc.mlir b/test/Integration/Dialect/XeGPU/dynamic_memref.vc.mlir new file mode 100644 index 000000000..4548b268a --- /dev/null +++ b/test/Integration/Dialect/XeGPU/dynamic_memref.vc.mlir @@ -0,0 +1,57 @@ +// RUN: %python_executable %imex_runner --requires=l0-runtime -i %s --pass-pipeline-file=%p/xegpu-to-llvm.pp \ +// RUN: --runner imex-cpu-runner -e main \ +// RUN: --entry-point-result=void \ +// RUN: --shared-libs=%irunner_utils,%mlir_runner_utils,%mlir_c_runner_utils,%levelzero_runtime --filecheck +// RUN: %python_executable %imex_runner --requires=sycl-runtime -i %s --pass-pipeline-file=%p/xegpu-to-llvm.pp \ +// RUN: --runner imex-cpu-runner -e main \ +// RUN: --entry-point-result=void \ +// RUN: --shared-libs=%irunner_utils,%mlir_runner_utils,%mlir_c_runner_utils,%sycl_runtime --filecheck +module @gemm attributes {gpu.container_module} { + func.func @test(%A : memref<8x16xf16>) -> memref<8x16xf32> attributes {llvm.emit_c_interface} { + %c1 = arith.constant 1 : index + %memref_0 = gpu.alloc host_shared () : memref<8x16xf16> + memref.copy %A, %memref_0 : memref<8x16xf16> to memref<8x16xf16> + %memref_1 = gpu.alloc host_shared () : memref<8x16xf32> + %memref_0_cast = memref.cast %memref_0 : memref<8x16xf16> to memref + %memref_1_cast = memref.cast %memref_1 : memref<8x16xf32> to memref + gpu.launch_func @test_kernel::@test_kernel blocks in (%c1, %c1, %c1) threads in (%c1, %c1, %c1) args(%memref_0_cast : memref, %memref_1_cast : memref) + gpu.dealloc %memref_0 : memref<8x16xf16> + return %memref_1 : memref<8x16xf32> + } + gpu.module @test_kernel attributes {spirv.target_env = #spirv.target_env<#spirv.vce, api=OpenCL, #spirv.resource_limits<>>} { + gpu.func @test_kernel(%arg0 : memref, %arg1: memref) kernel attributes {VectorComputeFunctionINTEL, spirv.entry_point_abi = #spirv.entry_point_abi<>} { + %c1 = arith.constant 1 : index + %c8 = arith.constant 8 : index + %c16 = arith.constant 16 : index + %1 = xegpu.create_nd_tdesc %arg0[0, 0], [%c8, %c16], [%c16, %c1] {mode = vc} : memref -> !xegpu.tensor_desc<8x16xf16> + %2 = xegpu.load_nd %1 {vnni_axis = 1, l1_hint = cached, l2_hint = cached, mode = vc} : !xegpu.tensor_desc<8x16xf16> -> vector<8x8x2xf16> + %3 = vector.shape_cast %2 : vector<8x8x2xf16> to vector<128xf16> + %5 = arith.extf %3 : vector<128xf16> to vector<128xf32> + %4 = vector.shape_cast %5 : vector<128xf32> to vector<8x16xf32> + %6 = xegpu.create_nd_tdesc %arg1[0, 0], [%c8, %c16], [%c16, %c1] { mode = vc } : memref -> !xegpu.tensor_desc<8x16xf32> + xegpu.store_nd %4, %6 {mode = vc} : vector<8x16xf32>, !xegpu.tensor_desc<8x16xf32> + gpu.return + } + } + func.func @main() attributes {llvm.emit_c_interface} { + %A = memref.alloc() : memref<8x16xf16> + %A_ = memref.collapse_shape %A [[0, 1]] : memref<8x16xf16> into memref<128xf16> + %A_random = memref.cast %A_ : memref<128xf16> to memref + call @fillMatrixRandomF16(%A_random) : (memref) -> () + %B = call @test(%A) : (memref<8x16xf16>) -> memref<8x16xf32> + %B_cast = memref.cast %B : memref<8x16xf32> to memref<*xf32> + %A_cast = memref.cast %A : memref<8x16xf16> to memref<*xf16> + // call @printMemrefF16(%A_cast) : (memref<*xf16>) -> () + // call @printMemrefF32(%B_cast) : (memref<*xf32>) -> () + // CHECK: [ALLCLOSE: TRUE] + call @printAllcloseF16(%A_cast, %B_cast) : (memref<*xf16>, memref<*xf32>) -> () + + memref.dealloc %A : memref<8x16xf16> + return + } + func.func private @printMemrefF16(memref<*xf16>) attributes {llvm.emit_c_interface} + func.func private @printMemrefF32(memref<*xf32>) attributes {llvm.emit_c_interface} + func.func private @fillMatrixRandomF16(memref) attributes {llvm.emit_c_interface} + func.func private @fillResource1DF16(memref, f32) attributes {llvm.emit_c_interface} + func.func private @printAllcloseF16(memref<*xf16>, memref<*xf32>) attributes {llvm.emit_c_interface} +} diff --git a/test/Integration/Dialect/XeGPU/lit.local.cfg b/test/Integration/Dialect/XeGPU/lit.local.cfg index a5f88c328..ad6dc49c6 100644 --- a/test/Integration/Dialect/XeGPU/lit.local.cfg +++ b/test/Integration/Dialect/XeGPU/lit.local.cfg @@ -9,5 +9,13 @@ local_excludes = [ 'gemm_4kx4kx4k_f16_f16_f16.mlir', 'gemm_4kx4kx4k_dpas_sized_loads_f16_f16_f32.mlir' ] +slow_simulator_tests = [ + 'gemm_4kx4kx4k_f16_f16_f16_w_8x32xf16_stores.mlir', + 'large_stores_8x32xf16_w_1d_vector_shuffle.vc.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/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 16cf1ce34..48daecb24 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -39,6 +39,7 @@ config.imex_enable_l0_runtime = @IMEX_ENABLE_L0_RUNTIME@ config.imex_enable_sycl_runtime = @IMEX_ENABLE_SYCL_RUNTIME@ config.imex_enable_bf16_tests = @IMEX_ENABLE_BF16_TESTS@ config.imex_enable_excluded_tests = @IMEX_ENABLE_EXCLUDED_TESTS@ +config.imex_enable_fs_simulator = @IMEX_ENABLE_FS_SIMULATOR@ if sys.platform.startswith('win32'): config.shlib_prefix = "" @@ -64,6 +65,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