You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/09/20 15:18:42 UTC

[GitHub] [tvm] driazati commented on a diff in pull request #12833: [DOCKER][Adreno]Docker infra for Adreno target with CLML support

driazati commented on code in PR #12833:
URL: https://github.com/apache/tvm/pull/12833#discussion_r975501478


##########
tests/scripts/task_build_adreno_bins.sh:
##########
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+set -u

Review Comment:
   ```suggestion
   set -u
   set -x
   ```



##########
tests/scripts/task_build_adreno_bins.sh:
##########
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+set -u
+
+output_directory=$(realpath ${PWD}/build-adreno-target)
+rm -rf ${output_directory}
+
+mkdir -p ${output_directory}
+cd ${output_directory}
+
+cp ../cmake/config.cmake .
+
+echo set\(USE_CLML ON\) >> config.cmake
+echo set\(USE_CLML_GRAPH_EXECUTOR "${ADRENO_OPENCL}"\) >> config.cmake
+echo set\(USE_RPC ON\) >> config.cmake
+echo set\(USE_CPP_RPC ON\) >> config.cmake
+echo set\(USE_GRAPH_EXECUTOR ON\) >> config.cmake
+echo set\(USE_LIBBACKTRACE AUTO\) >> config.cmake
+
+echo set\(ANDROID_ABI arm64-v8a\) >> config.cmake
+echo set\(ANDROID_PLATFORM android-28\) >> config.cmake
+echo set\(MACHINE_NAME aarch64-linux-gnu\) >> config.cmake
+
+cmake -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake" \
+      -DANDROID_ABI=arm64-v8a \
+      -DANDROID_PLATFORM=android-28 \
+      -DCMAKE_SYSTEM_VERSION=1 \
+      -DCMAKE_FIND_ROOT_PATH="${ADRENO_OPENCL}" \
+      -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
+      -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
+      -DCMAKE_CXX_COMPILER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++" \
+      -DCMAKE_C_COMPILER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang" \
+      -DMACHINE_NAME="aarch64-linux-gnu" ..
+
+make -j$(nproc) tvm_rpc

Review Comment:
   Could you look into using `tests/scripts/task_build.py` here instead? That handles setting up sccache which we need in CI for all TVM builds



##########
tests/scripts/task_python_adreno.sh:
##########
@@ -0,0 +1,65 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -euxo pipefail
+
+export TVM_TEST_TARGETS="opencl"
+export TVM_RELAY_OPENCL_TEXTURE_TARGETS="opencl -device=adreno"
+
+source tests/scripts/setup-pytest-env.sh
+export PYTHONPATH=${PYTHONPATH}:${TVM_PATH}/apps/extension/python
+export LD_LIBRARY_PATH="build:${LD_LIBRARY_PATH:-}"
+export TVM_INTEGRATION_TESTSUITE_NAME=python-integration-adreno
+
+export TVM_TRACKER_HOST=127.0.0.1
+export TVM_TRACKER_PORT=$(((RANDOM % 100) + 9100))
+export RPC_TARGET="adreno"
+export TVM_NDK_CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang"
+
+env PYTHONPATH=python python3 -m tvm.exec.rpc_tracker --host "${TVM_TRACKER_HOST}" --port "${TVM_TRACKER_PORT}" &
+TRACKER_PID=$!
+sleep 5   # Wait for tracker to bind
+
+export ANDROID_SERIAL=$1
+
+adb shell "mkdir -p /data/local/tmp/tvm_ci"
+adb push build-adreno-target/tvm_rpc /data/local/tmp/tvm_ci/tvm_rpc_ci
+adb push build-adreno-target/libtvm_runtime.so /data/local/tmp/tvm_ci
+
+adb reverse tcp:${TVM_TRACKER_PORT} tcp:${TVM_TRACKER_PORT}
+adb forward tcp:5000 tcp:5000
+adb forward tcp:5001 tcp:5001
+adb forward tcp:5002 tcp:5002
+env adb shell "cd /data/local/tmp/tvm_ci; killall -9 tvm_rpc_ci; sleep 2; LD_LIBRARY_PATH=/data/local/tmp/tvm_ci/ ./tvm_rpc_ci server --host=0.0.0.0 --port=5000 --port-end=5010 --tracker=127.0.0.1:${TVM_TRACKER_PORT} --key=android" &
+DEVICE_PID=$!
+sleep 5 # Wait for the device connections
+
+# cleanup pycache
+find . -type f -path "*.pyc" | xargs rm -f
+
+# Test TVM
+make cython3
+
+# OpenCL texture test on Adreno
+run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-opencl-texture tests/python/relay/opencl_texture
+
+# Adreno CLML test
+run_pytest ctypes ${TVM_INTEGRATION_TESTSUITE_NAME}-openclml tests/python/contrib/test_clml
+
+kill ${TRACKER_PID}
+kill ${DEVICE_PID}

Review Comment:
   Can you put these in a `trap` so they run even when pytest fails?



##########
docker/bash.sh:
##########
@@ -453,6 +453,12 @@ if [ -f "${REPO_DIR}/.git" ]; then
     fi
 fi
 
+if [[ "${DOCKER_IMAGE_NAME}" == *"ci_adreno"* && ! -z "${ADRENO_OPENCL}" ]]; then
+    DOCKER_MOUNT+=( --volume ${ADRENO_OPENCL}:/adreno-opencl)
+    DOCKER_ENV+=( --env ADRENO_OPENCL=/adreno-opencl )
+    DOCKER_ENV+=( --net=host)

Review Comment:
   Why is `--nest=host` needed? We've typically avoided it in `bash.sh` in the past since its usually overly permissive 



##########
tests/scripts/task_build_adreno_bins.sh:
##########
@@ -0,0 +1,52 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+set -u
+
+output_directory=$(realpath ${PWD}/build-adreno-target)
+rm -rf ${output_directory}
+
+mkdir -p ${output_directory}
+cd ${output_directory}
+
+cp ../cmake/config.cmake .
+
+echo set\(USE_CLML ON\) >> config.cmake

Review Comment:
   Are these settings different than the ones in `task_config_build_adreno.sh`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org