diff --git a/.github/actions/do_build_icd/action.yml b/.github/actions/do_build_icd/action.yml new file mode 100644 index 000000000..7416a934b --- /dev/null +++ b/.github/actions/do_build_icd/action.yml @@ -0,0 +1,106 @@ +name: pull and build icd loader +description: pull icd loader and build with a particular toolchain + +inputs: + toolchain: + description: 'path to toolchain' + default: '' + #$GITHUB_WORKSPACE/ock/platform/x86_64-linux.cmake + build_type: + description: 'build type' + default: Release + name: + description: 'artifact name' + default: ubuntu-22.04-x86_64 + shell_to_use: + description: "which shell to use (default bash)" + default: bash + +runs: + # We don't want a new docker just a list of steps, so mark as composite + using: "composite" + steps: + # - name: clone ock platform + # uses: actions/checkout@v4 + # with: + # sparse-checkout: | + # platform + # path: ock + + - name: check paths + shell: ${{ inputs.shell_to_use }} + run: | + pwd + ls -d * + + - name: clone headers + uses: actions/checkout@v4 + with: + repository: KhronosGroup/OpenCL-Headers + path: headers + - name: build headers + shell: ${{ inputs.shell_to_use }} + run: | + pwd + ls -d * + cmake headers -Bheaders/build ${{ inputs.toolchain }} -DCMAKE_INSTALL_PREFIX=$PWD/headers_install -GNinja + ninja -v -C headers/build + ninja -v -C headers/build install + + + - name: clone icd + uses: actions/checkout@v4 + with: + repository: KhronosGroup/OpenCL-ICD-Loader + path: icd + + - name: icd cmake + shell: ${{ inputs.shell_to_use }} + run: + cmake icd -B icd/build ${{ inputs.toolchain }} + -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCMAKE_INSTALL_PREFIX=$PWD/install_icd + -DOpenCLHeaders_DIR=$PWD/headers_install/share/cmake/OpenCLHeaders -GNinja + + - name: icd build + shell: ${{ inputs.shell_to_use }} + run: | + ninja -v -C icd/build + ninja -v -C icd/build install + pwd + ls icd/ + + - name: upload icd artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.name }} + path: install_icd + retention-days: 1 + + # - name: cmake_ock + # shell: ${{ inputs.shell_to_use }} + # - mkdir -p $CI_PROJECT_DIR/build + # - cd $CI_PROJECT_DIR/build + # - git -c advice.detachedHead=false + # clone https://github.com/KhronosGroup/OpenCL-Headers + # --single-branch --depth 1 + # - cd OpenCL-Headers + # - git log -1 + # - mkdir build + # - cmake -Bbuild ${{ inputs.toolchain }} . + # "-DCMAKE_INSTALL_PREFIX=$OPENCL_HEADERS_PATH" -GNinja + # - ninja -v -C build + # - ninja -v -C build install + # - cd .. + + # - git -c advice.detachedHead=false + # clone https://github.com/KhronosGroup/OpenCL-ICD-Loader + # --single-branch --depth 1 + # - cd OpenCL-ICD-Loader + # - git log -1 + # - mkdir build + # - cmake -Bbuild . ${{ inputs.toolchain }} + # "-DCMAKE_BUILD_TYPE=$ICD_BUILD_TYPE" -DCMAKE_INSTALL_PREFIX=$ICD_LOADER_INSTALL_PATH + # "-DOpenCLHeaders_DIR=$OPENCL_HEADERS_PATH/share/cmake/OpenCLHeaders" -GNinja + # - ninja -v -C build + # - ninja -v -C build install + # - cd $CI_PROJECT_DIR \ No newline at end of file diff --git a/.github/workflows/planned_testing.yml b/.github/workflows/planned_testing.yml index 1a3376768..146700e51 100644 --- a/.github/workflows/planned_testing.yml +++ b/.github/workflows/planned_testing.yml @@ -53,17 +53,17 @@ jobs: echo 'os_list=${{ inputs.os_list }}' >> "$GITHUB_OUTPUT" cat $GITHUB_OUTPUT - create_ock_artefacts: - needs: calc_matrix - strategy: - matrix: - target: ${{ fromJson(needs.calc_matrix.outputs.target_list) }} - os: ${{ fromJson(needs.calc_matrix.outputs.os_list) }} - build_type: [RelAssert] - exclude: - - os: windows-2019 - - target: riscv64 - # - target: aarch64 + # create_ock_artefacts: + # needs: calc_matrix + # strategy: + # matrix: + # target: ${{ fromJson(needs.calc_matrix.outputs.target_list) }} + # os: ${{ fromJson(needs.calc_matrix.outputs.os_list) }} + # build_type: [RelAssert] + # exclude: + # - os: windows-2019 + # - target: riscv64 + # # - target: aarch64 runs-on: ${{ matrix.os }} steps: @@ -92,7 +92,6 @@ jobs: # For now target and arch match arch: ${{ matrix.target }} save: ${{ inputs.update_cache }} - toolchain_file: scripts/../platform/arm-linux/${{ matrix.target }}-toolchain.cmake" - name: build ock x86 if: ${{ matrix.target == 'x86_64' }} @@ -100,7 +99,6 @@ jobs: with: build_targets: install offline_kernel_tests: OFF - install_dir: install_ock_${{matrix.os}}_${{matrix.target}} - name: build ock other ${{ matrix.target }} if: ${{ matrix.target != 'x86_64' }} @@ -113,7 +111,6 @@ jobs: extra_flags: -DCA_BUILTINS_TOOLS_DIR=${{ github.workspace }}/llvm_install_native/bin # Do we need the offline kernel as an artefact? If so currently this requires an external clc or qemu to be installed. offline_kernel_tests: OFF - install_dir: install_ock_${{matrix.os}}_${{matrix.target}} host_fp16: ON # Prune it as there is too much things in there we don't want to use @@ -121,14 +118,14 @@ jobs: - name: prune ock artefact ${{ matrix.target }} run: | # delete all but city runner and the python associated file under bin - find install_ock_${{matrix.os}}_${{matrix.target}}/bin -maxdepth 0 -type f ! -name "*.py" -delete + find install_ock_${{matrix.os}}_${{matrix.target}}/bin -maxdepth 1 -type f ! -name "*.py" -delete rm -rf install_ock_${{matrix.os}}_${{matrix.target}}/share - name: upload ock artefact uses: actions/upload-artifact@v4 with: name: ock_${{matrix.os}}_${{matrix.target}} - path: install_ock_${{matrix.os}}_${{matrix.target}} + path: install retention-days: 1 @@ -146,8 +143,42 @@ jobs: # target: riscv64 - use_ock_artefacts: - needs: [ calc_matrix, create_ock_artefacts ] + build_icd: + needs: [ calc_matrix ] + strategy: + matrix: + target: ${{ fromJson(needs.calc_matrix.outputs.target_list) }} + os: ${{ fromJson(needs.calc_matrix.outputs.os_list) }} + build_type: [RelAssert] + exclude: + - os: windows-2019 + - target: riscv64 + runs-on: ${{ matrix.os }} + steps: + - name: Install Ninja + uses: llvm/actions/install-ninja@main + + - name: clone ock platform + uses: actions/checkout@v4 + with: + sparse-checkout: | + platform + .github + + # todo look into setting variables in a common way so we can pass toolchains in for different jobs + - name : build and upload icd + # if: ${{ matrix.target != 'x86_64' }} + uses: ./.github/actions/do_build_icd + with: + # Todo : not just support linux here + toolchain: ${{ matrix.target == 'aarch64' && '--toolchain $GITHUB_WORKSPACE/platform/arm-linux/aarch64-toolchain.cmake' || '' }} + name: icd_${{matrix.os}}_${{matrix.target}} + + + # Todo do as an action + build_tornado: + needs: [ calc_matrix, build_icd ] + # needs: [ calc_matrix ] strategy: matrix: target: ${{ fromJson(needs.calc_matrix.outputs.target_list) }} @@ -158,14 +189,125 @@ jobs: - target: riscv64 runs-on: ${{ matrix.os }} steps: - - name: Download ock artefact - uses: actions/download-artifact@v4 - with: - name: ock_${{matrix.os}}_${{matrix.target}} + # - name: Install Ninja + # uses: llvm/actions/install-ninja@main - - name: print ock artefact - run: | - ls -R . + - name: clone ock platform + uses: actions/checkout@v4 + with: + sparse-checkout: | + platform + .github + + - name: download icd artifact + uses: actions/download-artifact@v4 + with: + name: icd_${{matrix.os}}_${{matrix.target}} + path: install_icd + + # Get maven + - name: fetch maven + run: | + wget https://archive.apache.org/dist/maven/maven-3/3.9.3/binaries/apache-maven-3.9.3-bin.tar.gz + tar xf apache-maven-3.9.3-bin.tar.gz + # for x86, we'll need to do something else for aarch64 + - name: select jdk21 + run: | + sudo update-java-alternatives -s temurin-21-jdk-amd64 + pip install tqdm + + - name: build tornadovm + run: | + git clone https://github.com/beehive-lab/TornadoVM.git -b develop --depth 1 TornadoVM_build + export JAVA_HOME=`readlink -f $(command -v java) | sed 's/\/bin\/java//'` + export TORNADO_SDK=$GITHUB_WORKSPACE/TornadoVM_build/bin/sdk + export PATH=$PWD/apache-maven-3.9.3/bin:$PATH + mvn -v + java --version + + cd TornadoVM_build + # The tornado build system links in OpenCL assuming it's in a known place. This gets around + # this by pass CXX as an environment variable as it's difficult to change the build system + # even if we don't use this script. + CXX="g++ -L$GITHUB_WORKSPACE/install_icd/lib" make -j8 jdk21 BACKEND=opencl + # # Not sure if gitlab ci does not follow symbolic links so copy for the artefact + # cp -r -L $TORNADO_SDK $GITHUB_WORKSPACE/TornadoVM_SDK + + - name: Download ock artefact + uses: actions/download-artifact@v4 + with: + name: ock_${{matrix.os}}_${{matrix.target}} + path: ock + + - name: Run tornado example + run: | + export ARETEFACT_CHECKOUT_PATH=$GITHUB_WORKSPACE/ock + echo ARTEFACT_CHECKOUT_PATH is $ARTEFACT_CHECKOUT_PATH + ls $ARTEFACT_CHECKOUT_PATH + export ICD_LOADER_INSTALL_PATH=$GITHUB_WORKSPACE/icd + echo ICD_LOADER_INSTALL_PATH is $ICD_LOADER_INSTALL_PATH + ls $ICD_LOADER_INSTALL_PATH + + export LD_LIBRARY_PATH=$ICD_LOADER_INSTALL_PATH/lib:$LD_LIBRARY_PATH + echo $LD_LIBRARY_PATH + export OCL_ICD_FILENAMES=$ARTEFACT_CHECKOUT_PATH/lib/libCL.so + export JAVA_HOME=`readlink -f $(command -v java) | sed 's/\/bin\/java//'` + export TORNADO_SDK=$GITHUB_WORKSPACE/TornadoVM_build/bin/sdk + export PATH=$TORNADO_SDK/bin:$PATH + + git clone https://github.com/beehive-lab/TornadoVM.git -b develop --depth 1 + cd TornadoVM + tornado-test -V "uk.ac.manchester.tornado.unittests.TestHello" + + # todo : download ock artefact + + # Run tornado example + # at some point we will make an artefact if we want to do more, but it is enough to show it working using the created files. + # - name: run tornado example + # run: | + # echo ARTEFACT_CHECKOUT_PATH is $ARTEFACT_CHECKOUT_PATH + # ls $ARTEFACT_CHECKOUT_PATH + # export LD_LIBRARY_PATH=$ICD_LOADER_INSTALL_PATH/lib:$LD_LIBRARY_PATH + # echo $LD_LIBRARY_PATH + # export OCL_ICD_FILENAMES=$ARTEFACT_CHECKOUT_PATH/lib/libCL.so + # export JAVA_HOME=`readlink -f $(command -v java) | sed 's/\/bin\/java//'` + # export TORNADO_SDK=$CI_PROJECT_DIR/TornadoVM_SDK + # export PATH=$TORNADO_SDK/bin:$PATH + + # git clone https://github.com/beehive-lab/TornadoVM.git -b develop --depth 1 + # cd TornadoVM + + # toolchain: + # description: 'path to toolchain' + # default: $GITHUB_WORKSPACE/ock/platform/x86_64-linux.cmake + # build_type: + # description: 'path to toolchain' + # default: ock/platform/x86_64-linux.cmake + # name: + # description: 'artifact name' + # default: ubuntu-22.04-x86_64 + + # use_ock_artefacts: + # needs: [ calc_matrix, create_ock_artefacts ] + # strategy: + # matrix: + # target: ${{ fromJson(needs.calc_matrix.outputs.target_list) }} + # os: ${{ fromJson(needs.calc_matrix.outputs.os_list) }} + # build_type: [RelAssert] + # exclude: + # - os: windows-2019 + # - target: riscv64 + # runs-on: ${{ matrix.os }} + # steps: + # - name: Download ock artefact + # uses: actions/download-artifact@v4 + # with: + # name: ock_${{matrix.os}}_${{matrix.target}} + # path: ock_${{matrix.os}}_${{matrix.target}} + + # - name: print ock artefact + # run: | + # ls -R . # echo "${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.arch }}" > foo.txt # --define CA_CL_ENABLE_ICD_LOADER=ON diff --git a/.github/workflows/planned_testing_caller.yml b/.github/workflows/planned_testing_caller.yml index f3d8e5d90..0f91ba6a8 100644 --- a/.github/workflows/planned_testing_caller.yml +++ b/.github/workflows/planned_testing_caller.yml @@ -4,6 +4,8 @@ on: pull_request: paths: - '.github/workflows/planned_testing.yml' + branches: + - main # schedule: # # Run Mon-Fri at 7pm # - cron: '00 19 * * 1-5' @@ -16,7 +18,8 @@ jobs: uses: ./.github/workflows/planned_testing.yml with: # target_list: '["x86_64", "aarch64", "riscv64"]' - target_list: '["x86_64", "aarch64"]' + target_list: '["x86_64"]' + # target_list: '["aarch64"]' # os_list: '["ubuntu-22.04", "windows-2019"]' # target_list: '["x86_64"]' os_list: '["ubuntu-22.04"]' diff --git a/platform/x86_64-linux/x86_64-linux.cmake b/platform/x86_64-linux/x86_64-linux.cmake new file mode 100644 index 000000000..535ebc5b7 --- /dev/null +++ b/platform/x86_64-linux/x86_64-linux.cmake @@ -0,0 +1,4 @@ +set(CMAKE_C_COMPILER gcc) +set(CMAKE_C_FLAGS -m64) +set(CMAKE_CXX_COMPILER g++) +set(CMAKE_CXX_FLAGS -m64)