diff --git a/mace/BUILD b/mace/BUILD index 784be7c57c3cf52ca8472286f8a95bbb9e6e9652..98a9ab0510c4a1bf9a659402e071aec1f6963102 100644 --- a/mace/BUILD +++ b/mace/BUILD @@ -24,14 +24,6 @@ config_setting( visibility = ["//visibility:public"], ) -config_setting( - name = "profiling_enabled", - define_values = { - "profiling": "true", - }, - visibility = ["//visibility:public"], -) - config_setting( name = "production_mode", define_values = { diff --git a/mace/core/BUILD b/mace/core/BUILD index be9e15d7ca9802f351beb009bb95356b2dc1ed54..97cf8dd19bf378a4d16e230a90ac5ff0239f9f54 100644 --- a/mace/core/BUILD +++ b/mace/core/BUILD @@ -10,7 +10,6 @@ licenses(["notice"]) # Apache 2.0 load( "//mace:mace.bzl", "if_android", - "if_profiling_enabled", "if_hexagon_enabled", "if_not_hexagon_enabled", "if_production_mode", @@ -43,7 +42,6 @@ cc_library( "runtime/opencl/*.h", "runtime/hexagon/*.h", ]), - copts = if_profiling_enabled(["-DMACE_OPENCL_PROFILING"]) + if_hexagon_enabled(["-DMACE_HEXAGON_ENABLED"]), linkopts = if_android([ "-pie", "-ldl", diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index 90387f3150e82d15b8750d18b7e404a6c64e0724..3c8b013ac51bfd219afef3a91ab600e195c0b99e 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -91,9 +91,11 @@ OpenCLRuntime::OpenCLRuntime() { cl_command_queue_properties properties = 0; -#ifdef MACE_OPENCL_PROFILING - properties |= CL_QUEUE_PROFILING_ENABLE; -#endif + const char *profiling = getenv("MACE_OPENCL_PROFILING"); + if (Tuner::Get()->IsTuning() || + (profiling != nullptr && strlen(profiling) == 1 && profiling[0] == '1')) { + properties |= CL_QUEUE_PROFILING_ENABLE; + } // a context is like a "runtime link" to the device and platform; // i.e. communication is possible diff --git a/mace/mace.bzl b/mace/mace.bzl index c4e696862303e180b9fc0af73609352100c96b82..e9002885b80e153db7e1f2a529549434fd669a87 100644 --- a/mace/mace.bzl +++ b/mace/mace.bzl @@ -24,12 +24,6 @@ def if_android_arm64(a): "//conditions:default": [], }) -def if_profiling_enabled(a): - return select({ - "//mace:profiling_enabled": a, - "//conditions:default": [], - }) - def if_production_mode(a): return select({ "//mace:production_mode": a, diff --git a/tools/bazel-adb-run.sh b/tools/bazel-adb-run.sh index 6865fd194c59a0b967bf30f456067fc1310245b9..0a4188411b7e2fe23d5cbeecb0f37bff6f543332 100755 --- a/tools/bazel-adb-run.sh +++ b/tools/bazel-adb-run.sh @@ -22,7 +22,7 @@ ANDROID_ABI=arm64-v8a ANDROID_ABI=armeabi-v7a STRIP="--strip always" VLOG_LEVEL=0 -PROFILINE="--define profiling=true" +PROFILING="1" echo "Step 1: Generate encrypted opencl source" python mace/python/tools/encrypt_opencl_codegen.py \ @@ -58,5 +58,5 @@ for device in `adb devices | grep "^[A-Za-z0-9]\+[[:space:]]\+device$"| cut -f1` adb -s ${device} shell "mkdir -p $DEVICE_PATH" adb -s ${device} shell "mkdir -p $DEVICE_PATH/cl" adb -s ${device} push $BAZEL_BIN_PATH/$BIN_NAME $DEVICE_PATH && \ - adb -s ${device} shell "MACE_KERNEL_PATH=$DEVICE_CL_PATH MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL $DEVICE_PATH/$BIN_NAME $@" + adb -s ${device} shell "MACE_OPENCL_PROFILING=$PROFILING MACE_KERNEL_PATH=$DEVICE_CL_PATH MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL $DEVICE_PATH/$BIN_NAME $@" done diff --git a/tools/validate_gcn.sh b/tools/validate_gcn.sh index 775d9473a4243c7224fe1d5cc41686d05a4188a3..9a12c96995cf6199ef95a80c3965b0415b6999e2 100755 --- a/tools/validate_gcn.sh +++ b/tools/validate_gcn.sh @@ -5,7 +5,7 @@ Usage() { echo 'Usage: bash tools/validate_gcn.sh tools/gcn.config tf_model_path model_tag image_size runtime[gpu/dsp] [tuning]' } -if [ $# -lt 4 ];then +if [ $# -lt 5 ];then Usage exit -1 fi @@ -50,7 +50,6 @@ build_and_run() fi if [[ "${TUNING_OR_NOT}" != "0" && "$PRODUCTION_MODE" != true ]];then - TUNING_MODE_BUILD_FLAGS="--define profiling=true" tuning_flag=1 round=0 # only warm up else @@ -68,7 +67,7 @@ build_and_run() --copt="-DMACE_MODEL_TAG=${MODEL_TAG}" \ --copt="-DMACE_OBFUSCATE_LITERALS" \ $PRODUCTION_MODE_BUILD_FLAGS \ - $TUNING_MODE_BUILD_FLAGS --define hexagon=true || exit -1 + --define hexagon=true || exit -1 adb shell "mkdir -p ${PHONE_DATA_DIR}" || exit -1 if [ "$PRODUCTION_MODE" = false ]; then