This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch refactor in repository https://gitbox.apache.org/repos/asf/tvm.git
commit bb3bd391f79cd94237c7248381abade954d6711e Author: Siyuan Feng <[email protected]> AuthorDate: Mon Feb 17 14:38:07 2025 +0800 remove aocl and sdaccel --- CMakeLists.txt | 21 +-- cmake/config.cmake | 9 - cmake/modules/LibInfo.cmake | 1 - cmake/modules/OpenCL.cmake | 24 --- .../install/ubuntu_install_vitis_ai_packages_ci.sh | 29 --- golang/src/device.go | 7 - include/tvm/runtime/c_runtime_api.h | 6 +- include/tvm/runtime/packed_func.h | 4 - jvm/core/src/main/java/org/apache/tvm/Device.java | 2 +- python/tvm/__init__.py | 2 +- python/tvm/_ffi/runtime_ctypes.py | 7 - python/tvm/contrib/sdaccel.py | 99 ----------- python/tvm/testing/utils.py | 2 +- rust/tvm-sys/build.rs | 3 - src/runtime/module.cc | 2 +- src/runtime/opencl/aocl/aocl_common.h | 61 ------- src/runtime/opencl/aocl/aocl_device_api.cc | 58 ------ src/runtime/opencl/aocl/aocl_module.cc | 67 ------- src/runtime/opencl/aocl/aocl_module.h | 49 ----- src/runtime/opencl/sdaccel/sdaccel_common.h | 61 ------- src/runtime/opencl/sdaccel/sdaccel_device_api.cc | 56 ------ src/runtime/opencl/sdaccel/sdaccel_module.cc | 81 --------- src/runtime/opencl/sdaccel/sdaccel_module.h | 49 ----- src/support/libinfo.cc | 5 - src/target/opt/build_aocl_off.cc | 36 ---- src/target/opt/build_sdaccel_off.cc | 36 ---- src/target/source/codegen_aocl.cc | 102 ----------- src/target/source/codegen_vhls.cc | 198 --------------------- src/target/source/codegen_vhls.h | 50 ------ src/target/source/intrin_rule_aocl.cc | 107 ----------- src/target/source/intrin_rule_vhls.cc | 95 ---------- src/target/target_kind.cc | 9 - src/tir/analysis/verify_memory.cc | 4 +- tests/scripts/task_python_integration_gpuonly.sh | 2 +- tests/scripts/task_python_unittest_gpuonly.sh | 2 +- 35 files changed, 9 insertions(+), 1337 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab01cd5f47..1edb821086 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -583,20 +583,6 @@ if(USE_IOS_RPC) add_subdirectory("apps/ios_rpc") endif() -if(USE_RELAY_DEBUG) - message(STATUS "Building Relay in debug mode...") - target_compile_definitions(tvm_objs PRIVATE "USE_RELAY_DEBUG") - target_compile_definitions(tvm_objs PRIVATE "TVM_LOG_DEBUG") - target_compile_definitions(tvm_runtime_objs PRIVATE "USE_RELAY_DEBUG") - target_compile_definitions(tvm_runtime_objs PRIVATE "TVM_LOG_DEBUG") - target_compile_definitions(tvm_libinfo_objs PRIVATE "USE_RELAY_DEBUG") - target_compile_definitions(tvm_libinfo_objs PRIVATE "TVM_LOG_DEBUG") -else() - target_compile_definitions(tvm_objs PRIVATE "NDEBUG") - target_compile_definitions(tvm_runtime_objs PRIVATE "NDEBUG") - target_compile_definitions(tvm_libinfo_objs PRIVATE "NDEBUG") -endif(USE_RELAY_DEBUG) - if(TVM_DEBUG_WITH_ABI_CHANGE) message(STATUS "Building with debug code that may cause ABI changes...") target_compile_definitions(tvm_objs PRIVATE "TVM_DEBUG_WITH_ABI_CHANGE") @@ -699,12 +685,7 @@ if(GTEST_FOUND) endif() set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_ALL 1) set_target_properties(cpptest PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) - if(USE_RELAY_DEBUG) - target_compile_definitions(cpptest PRIVATE "USE_RELAY_DEBUG") - target_compile_definitions(cpptest PRIVATE "TVM_LOG_DEBUG") - else() - target_compile_definitions(cpptest PRIVATE "NDEBUG") - endif() + target_compile_definitions(cpptest PRIVATE "NDEBUG") if(TVM_DEBUG_WITH_ABI_CHANGE) target_compile_definitions(cpptest PRIVATE "TVM_DEBUG_WITH_ABI_CHANGE") endif(TVM_DEBUG_WITH_ABI_CHANGE) diff --git a/cmake/config.cmake b/cmake/config.cmake index d420fe54ab..856803898a 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -78,12 +78,6 @@ set(USE_ROCM OFF) # - /path/to/rccl: use specific path to rccl set(USE_RCCL OFF) -# Whether enable SDAccel runtime -set(USE_SDACCEL OFF) - -# Whether enable Intel FPGA SDK for OpenCL (AOCL) runtime -set(USE_AOCL OFF) - # Whether enable OpenCL runtime # # Possible values: @@ -294,9 +288,6 @@ set(USE_CLML_GRAPH_EXECUTOR OFF) # - /path/to/antlr-*-complete.jar: path to specific ANTLR jar file set(USE_ANTLR OFF) -# Whether use Relay debug mode -set(USE_RELAY_DEBUG OFF) - # Whether to enable debug code that may cause ABI changes set(TVM_DEBUG_WITH_ABI_CHANGE OFF) diff --git a/cmake/modules/LibInfo.cmake b/cmake/modules/LibInfo.cmake index 2010043909..3881247ae1 100644 --- a/cmake/modules/LibInfo.cmake +++ b/cmake/modules/LibInfo.cmake @@ -102,7 +102,6 @@ function(add_lib_info src_file) TVM_INFO_USE_OPENMP="${USE_OPENMP}" TVM_INFO_USE_PAPI="${USE_PAPI}" TVM_INFO_USE_RANDOM="${USE_RANDOM}" - TVM_INFO_USE_RELAY_DEBUG="${USE_RELAY_DEBUG}" TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE="${TVM_DEBUG_WITH_ABI_CHANGE}" TVM_INFO_TVM_LOG_BEFORE_THROW="${TVM_LOG_BEFORE_THROW}" TVM_INFO_USE_ROCBLAS="${USE_ROCBLAS}" diff --git a/cmake/modules/OpenCL.cmake b/cmake/modules/OpenCL.cmake index 67d739bb63..c5c8eae721 100644 --- a/cmake/modules/OpenCL.cmake +++ b/cmake/modules/OpenCL.cmake @@ -15,30 +15,6 @@ # specific language governing permissions and limitations # under the License. -if(USE_SDACCEL) - message(STATUS "Build with SDAccel support") - tvm_file_glob(GLOB RUNTIME_SDACCEL_SRCS src/runtime/opencl/sdaccel/*.cc) - list(APPEND RUNTIME_SRCS ${RUNTIME_SDACCEL_SRCS}) - if(NOT USE_OPENCL) - message(STATUS "Enable OpenCL support required for SDAccel") - set(USE_OPENCL ON) - endif() -else() - list(APPEND COMPILER_SRCS src/target/opt/build_sdaccel_off.cc) -endif(USE_SDACCEL) - -if(USE_AOCL) - message(STATUS "Build with Intel FPGA SDK for OpenCL support") - tvm_file_glob(GLOB RUNTIME_AOCL_SRCS src/runtime/opencl/aocl/*.cc) - list(APPEND RUNTIME_SRCS ${RUNTIME_AOCL_SRCS}) - if(NOT USE_OPENCL) - message(STATUS "Enable OpenCL support required for Intel FPGA SDK for OpenCL") - set(USE_OPENCL ON) - endif() -else() - list(APPEND COMPILER_SRCS src/target/opt/build_aocl_off.cc) -endif(USE_AOCL) - if(USE_OPENCL) tvm_file_glob(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc) list(APPEND COMPILER_SRCS src/target/spirv/spirv_utils.cc) diff --git a/docker/install/ubuntu_install_vitis_ai_packages_ci.sh b/docker/install/ubuntu_install_vitis_ai_packages_ci.sh deleted file mode 100755 index 569df12a37..0000000000 --- a/docker/install/ubuntu_install_vitis_ai_packages_ci.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 -set -o pipefail - -export PYXIR_HOME=/opt/pyxir -mkdir "$PYXIR_HOME" - -pip3 install progressbar - -git clone --recursive --branch v0.3.5 --depth 1 https://github.com/Xilinx/pyxir.git "${PYXIR_HOME}" -cd "${PYXIR_HOME}" && python3 setup.py install diff --git a/golang/src/device.go b/golang/src/device.go index b2203a38d8..1a40b77f49 100644 --- a/golang/src/device.go +++ b/golang/src/device.go @@ -41,8 +41,6 @@ var KDLMetal = int32(C.kDLMetal) var KDLVPI = int32(C.kDLVPI) // KDLROCM is golang enum correspond to TVM device type kDLROCM. var KDLROCM = int32(C.kDLROCM) -// KDLSDAccel is golang enum correspond to TVM device type kDLSDAccel. -var KDLSDAccel = int32(C.kDLSDAccel) // KDLVulkan is golang enum correspond to TVM device type kDLVulkan. var KDLVulkan = int32(C.kDLVulkan) // KOpenGL is golang enum correspond to TVM device type kOpenGL. @@ -91,11 +89,6 @@ func ROCM(index int32) Device { return Device{KDLROCM, index} } -// SDAccel returns the Device object for SDAccel target on given index -func SDAccel(index int32) Device { - return Device{KDLSDAccel, index} -} - // Vulkan returns the Device object for Vulkan target on given index func Vulkan(index int32) Device { return Device{KDLVulkan, index} diff --git a/include/tvm/runtime/c_runtime_api.h b/include/tvm/runtime/c_runtime_api.h index 24ff61811a..00a7964230 100644 --- a/include/tvm/runtime/c_runtime_api.h +++ b/include/tvm/runtime/c_runtime_api.h @@ -119,9 +119,7 @@ typedef enum { // To help avoid accidental conflicts between `DLDeviceType` // and this enumeration, start numbering the new enumerators // a little higher than (currently) seems necessary. - kDLAOCL = 32, - kDLSDAccel, - kOpenGL, + kOpenGL = 34, kDLMicroDev, TVMDeviceExtType_End, // sentinel value } TVMDeviceExtType; @@ -149,8 +147,6 @@ static_assert(kDLOneAPI == 14, TVM_HARCODED_INTEGER_CHANGED_MSG); static_assert(kDLWebGPU == 15, TVM_HARCODED_INTEGER_CHANGED_MSG); static_assert(kDLHexagon == 16, TVM_HARCODED_INTEGER_CHANGED_MSG); -static_assert(kDLAOCL == 32, TVM_HARCODED_INTEGER_CHANGED_MSG); -static_assert(kDLSDAccel == 33, TVM_HARCODED_INTEGER_CHANGED_MSG); static_assert(kOpenGL == 34, TVM_HARCODED_INTEGER_CHANGED_MSG); static_assert(kDLMicroDev == 35, TVM_HARCODED_INTEGER_CHANGED_MSG); #undef TVM_HARCODED_INTEGER_CHANGED_MSG diff --git a/include/tvm/runtime/packed_func.h b/include/tvm/runtime/packed_func.h index 7c1b08e490..b7eca8be1e 100644 --- a/include/tvm/runtime/packed_func.h +++ b/include/tvm/runtime/packed_func.h @@ -1460,10 +1460,6 @@ inline const char* DLDeviceType2Str(int type) { return "cuda_managed"; case kDLOpenCL: return "opencl"; - case kDLSDAccel: - return "sdaccel"; - case kDLAOCL: - return "aocl"; case kDLVulkan: return "vulkan"; case kDLMetal: diff --git a/jvm/core/src/main/java/org/apache/tvm/Device.java b/jvm/core/src/main/java/org/apache/tvm/Device.java index a5f341a690..edea0b75df 100644 --- a/jvm/core/src/main/java/org/apache/tvm/Device.java +++ b/jvm/core/src/main/java/org/apache/tvm/Device.java @@ -29,7 +29,7 @@ public class Device { static final int kDLCPU = 1, kDLCUDA = 2, kDLCUDAHost = 3, kDLOpenCL = 4, kDLVulkan = 7, kDLMetal = 8, kDLVPI = 9, kDLROCM = 10, kDLROCMHost = 11, kDLExtDev = 12, kDLCUDAManaged = 13, kDLOneAPI = 14, kDLWebGPU = 15, kDLHexagon = 16, - kDLAOCL = 32, kDLSDAccel = 33, kOpenGL = 34, kDLMicroDev = 35; + kOpenGL = 34, kDLMicroDev = 35; private static final Map<Integer, String> MASK2STR = new HashMap<Integer, String>(); private static final Map<String, Integer> STR2MASK = new HashMap<String, Integer>(); diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py index a622df4969..abbab3ad6d 100644 --- a/python/tvm/__init__.py +++ b/python/tvm/__init__.py @@ -64,7 +64,7 @@ from . import arith from . import support # Contrib initializers -from .contrib import rocm as _rocm, nvcc as _nvcc, sdaccel as _sdaccel +from .contrib import rocm as _rocm, nvcc as _nvcc # Relay and Relax contain modules that are only available in compiler package # Do not import them if TVM is built with runtime only diff --git a/python/tvm/_ffi/runtime_ctypes.py b/python/tvm/_ffi/runtime_ctypes.py index 03dc18ea6e..f3b02ed569 100644 --- a/python/tvm/_ffi/runtime_ctypes.py +++ b/python/tvm/_ffi/runtime_ctypes.py @@ -264,8 +264,6 @@ class Device(ctypes.Structure): kDLOneAPI = 14 kDLWebGPU = 15 kDLHexagon = 16 - kDLAOCL = 32 - kDLSDAccel = 33 kOpenGL = 34 kDLMicroDev = 35 @@ -285,8 +283,6 @@ class Device(ctypes.Structure): kDLOneAPI: "oneapi", kDLWebGPU: "webgpu", kDLHexagon: "hexagon", - kDLAOCL: "aocl", - kDLSDAccel: "sdaccel", kOpenGL: "opengl", kDLMicroDev: "microdev", } @@ -303,9 +299,6 @@ class Device(ctypes.Structure): "nvptx": kDLCUDA, "cl": kDLOpenCL, "opencl": kDLOpenCL, - "sdaccel": kDLOpenCL, - "aocl": kDLAOCL, - "aocl_sw_emu": kDLAOCL, "vulkan": kDLVulkan, "metal": kDLMetal, "vpi": kDLVPI, diff --git a/python/tvm/contrib/sdaccel.py b/python/tvm/contrib/sdaccel.py deleted file mode 100644 index 478436e3d5..0000000000 --- a/python/tvm/contrib/sdaccel.py +++ /dev/null @@ -1,99 +0,0 @@ -# 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. -"""Utility for Interacting with SDAccel Tools""" -import os -import subprocess - -import tvm._ffi - -from . import utils - - -@tvm._ffi.register_func("tvm_callback_sdaccel_compile") -def compile_vhls(kernel_info, target): - """Compile Vivado HLS code for SDAccel. - - Parameters - ---------- - kernel_info : list of (str, str) - List of kernel information. The kernel information is a tuple of - function name and source code. - - target : tvm.target.Target - The compilation target - - Return - ------ - xclbin : bytearray - The bytearray of the xclbin - """ - device_name = target.attrs.get("device", "") - tmp_dir = utils.tempdir() - - sdk = os.environ.get("XILINX_SDX", None) - xocc = os.path.join(sdk, "bin/xocc") if sdk else "xocc" - target = os.environ.get( - "XCL_TARGET", "sw_emu" if os.environ.get("XCL_EMULATION_MODE") else "hw" - ) - advanced_params = [ - "--xp", - "param:compiler.preserveHlsOutput=1", - "--xp", - "param:compiler.generateExtraRunData=true", - ] - platform = device_name - if not platform: - platform = os.environ.get("XCL_PLATFORM", os.environ.get("AWS_PLATFORM")) - - if platform is None: - raise RuntimeError("No Xilinx device specified.") - - tmp_xo_files = [] - for funcname, code in kernel_info: - funcname = funcname.value - code = code.value - - tmp_cpp = tmp_dir.relpath(funcname + ".cpp") - tmp_xo = tmp_dir.relpath(funcname + ".xo") - - with open(tmp_cpp, "wb") as out_file: - out_file.write(bytes(code)) - - # build xo - args = ( - [xocc, "-c", "-t", target, "--platform", platform, "-o", tmp_xo, "-k", funcname] - + advanced_params - + [tmp_cpp] - ) - returncode = subprocess.call(args) - if returncode != 0: - raise RuntimeError("Compile error") - - tmp_xo_files.append(tmp_xo) - - # build xclbin - tmp_xclbin = tmp_dir.relpath("output.xclbin") - args = ( - [xocc, "-l", "-t", target, "--platform", platform, "-o", tmp_xclbin] - + tmp_xo_files - + advanced_params - ) - returncode = subprocess.call(args) - if returncode != 0: - raise RuntimeError("Link error") - - return bytearray(open(tmp_xclbin, "rb").read()) diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py index b01f7bf5dc..9eb0c23db4 100644 --- a/python/tvm/testing/utils.py +++ b/python/tvm/testing/utils.py @@ -456,7 +456,7 @@ DEFAULT_TEST_TARGETS = [ "nvptx", "vulkan -from_device=0", "opencl", - "opencl -device=mali,aocl_sw_emu", + "opencl -device=mali", "opencl -device=intel_graphics", "metal", "rocm", diff --git a/rust/tvm-sys/build.rs b/rust/tvm-sys/build.rs index 3b19f56fb1..2f30afb4b0 100644 --- a/rust/tvm-sys/build.rs +++ b/rust/tvm-sys/build.rs @@ -102,9 +102,6 @@ fn find_using_tvm_build() -> Result<TVMInstall> { if cfg!(feature = "use-openmp") { build_config.settings.use_openmp = Some(true); } - if cfg!(feature = "use-relay-debug") { - build_config.settings.use_relay_debug = Some(true); - } if cfg!(feature = "use-rtti") { build_config.settings.use_rtti = Some(true); } diff --git a/src/runtime/module.cc b/src/runtime/module.cc index de372e5de0..4e60a0d0a2 100644 --- a/src/runtime/module.cc +++ b/src/runtime/module.cc @@ -143,7 +143,7 @@ bool RuntimeEnabled(const String& target_str) { return true; } else if (target == "cuda" || target == "gpu") { f_name = "device_api.cuda"; - } else if (target == "cl" || target == "opencl" || target == "sdaccel") { + } else if (target == "cl" || target == "opencl") { f_name = "device_api.opencl"; } else if (target == "mtl" || target == "metal") { f_name = "device_api.metal"; diff --git a/src/runtime/opencl/aocl/aocl_common.h b/src/runtime/opencl/aocl/aocl_common.h deleted file mode 100644 index 448f5d0ac6..0000000000 --- a/src/runtime/opencl/aocl/aocl_common.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -/*! - * \file aocl_common.h - * \brief AOCL common header - */ -#ifndef TVM_RUNTIME_OPENCL_AOCL_AOCL_COMMON_H_ -#define TVM_RUNTIME_OPENCL_AOCL_AOCL_COMMON_H_ - -#include <memory> - -#include "../opencl_common.h" - -namespace tvm { -namespace runtime { -namespace cl { - -/*! - * \brief Process global AOCL workspace. - */ -class AOCLWorkspace final : public OpenCLWorkspace { - public: - // override OpenCL device API - void Init() final; - bool IsOpenCLDevice(Device dev) final; - OpenCLThreadEntry* GetThreadEntry() final; - // get the global workspace - static OpenCLWorkspace* Global(); -}; - -/*! \brief Thread local workspace for AOCL */ -class AOCLThreadEntry : public OpenCLThreadEntry { - public: - // constructor - AOCLThreadEntry() - : OpenCLThreadEntry(static_cast<DLDeviceType>(kDLAOCL), AOCLWorkspace::Global()) {} - - // get the global workspace - static AOCLThreadEntry* ThreadLocal(); -}; -} // namespace cl -} // namespace runtime -} // namespace tvm -#endif // TVM_RUNTIME_OPENCL_AOCL_AOCL_COMMON_H_ diff --git a/src/runtime/opencl/aocl/aocl_device_api.cc b/src/runtime/opencl/aocl/aocl_device_api.cc deleted file mode 100644 index e407837f6a..0000000000 --- a/src/runtime/opencl/aocl/aocl_device_api.cc +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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. - */ - -/*! - * \file aocl_device_api.cc - */ -#include <dmlc/thread_local.h> -#include <tvm/runtime/registry.h> - -#include "aocl_common.h" - -namespace tvm { -namespace runtime { -namespace cl { - -OpenCLThreadEntry* AOCLWorkspace::GetThreadEntry() { return AOCLThreadEntry::ThreadLocal(); } - -OpenCLWorkspace* AOCLWorkspace::Global() { - static OpenCLWorkspace* inst = new AOCLWorkspace(); - return inst; -} - -void AOCLWorkspace::Init() { - OpenCLWorkspace::Init("aocl", "accelerator", "Intel(R) FPGA SDK for OpenCL(TM)"); -} - -bool AOCLWorkspace::IsOpenCLDevice(Device dev) { - return dev.device_type == static_cast<DLDeviceType>(kDLAOCL); -} - -typedef dmlc::ThreadLocalStore<AOCLThreadEntry> AOCLThreadStore; - -AOCLThreadEntry* AOCLThreadEntry::ThreadLocal() { return AOCLThreadStore::Get(); } - -TVM_REGISTER_GLOBAL("device_api.aocl").set_body([](TVMArgs args, TVMRetValue* rv) { - DeviceAPI* ptr = AOCLWorkspace::Global(); - *rv = static_cast<void*>(ptr); -}); - -} // namespace cl -} // namespace runtime -} // namespace tvm diff --git a/src/runtime/opencl/aocl/aocl_module.cc b/src/runtime/opencl/aocl/aocl_module.cc deleted file mode 100644 index cb86533561..0000000000 --- a/src/runtime/opencl/aocl/aocl_module.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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. - */ - -/*! - * \file aocl_module.cc - */ -#include "aocl_module.h" - -#include <dmlc/memory_io.h> -#include <tvm/runtime/registry.h> - -#include <string> -#include <unordered_map> -#include <vector> - -#include "aocl_common.h" - -namespace tvm { -namespace runtime { - -class AOCLModuleNode : public OpenCLModuleNode { - public: - explicit AOCLModuleNode(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source) - : OpenCLModuleNode(data, fmt, fmap, source) {} - cl::OpenCLWorkspace* GetGlobalWorkspace() final; -}; - -cl::OpenCLWorkspace* AOCLModuleNode::GetGlobalWorkspace() { return cl::AOCLWorkspace::Global(); } - -Module AOCLModuleCreate(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source) { - auto n = make_object<AOCLModuleNode>(data, fmt, fmap, source); - n->Init(); - return Module(n); -} - -Module AOCLModuleLoadFile(const std::string& file_name, const std::string& format) { - std::string data; - std::unordered_map<std::string, FunctionInfo> fmap; - std::string fmt = GetFileFormat(file_name, format); - std::string meta_file = GetMetaFilePath(file_name); - LoadBinaryFromFile(file_name, &data); - LoadMetaDataFromFile(meta_file, &fmap); - return AOCLModuleCreate(data, fmt, fmap, std::string()); -} - -TVM_REGISTER_GLOBAL("runtime.module.loadfile_aocx").set_body_typed(AOCLModuleLoadFile); - -} // namespace runtime -} // namespace tvm diff --git a/src/runtime/opencl/aocl/aocl_module.h b/src/runtime/opencl/aocl/aocl_module.h deleted file mode 100644 index 199a94decd..0000000000 --- a/src/runtime/opencl/aocl/aocl_module.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -/*! - * \file aocl_module.h - * \brief Execution handling of OpenCL kernels for AOCL - */ -#ifndef TVM_RUNTIME_OPENCL_AOCL_AOCL_MODULE_H_ -#define TVM_RUNTIME_OPENCL_AOCL_AOCL_MODULE_H_ - -#include <tvm/runtime/packed_func.h> - -#include <memory> -#include <string> -#include <unordered_map> -#include <vector> - -#include "../../meta_data.h" - -namespace tvm { -namespace runtime { -/*! - * \brief create a opencl module for AOCL from data. - * - * \param data The module data. - * \param fmt The format of the data, can be "aocx" - * \param fmap The map function information map of each function. - */ -Module AOCLModuleCreate(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source); -} // namespace runtime -} // namespace tvm -#endif // TVM_RUNTIME_OPENCL_AOCL_AOCL_MODULE_H_ diff --git a/src/runtime/opencl/sdaccel/sdaccel_common.h b/src/runtime/opencl/sdaccel/sdaccel_common.h deleted file mode 100644 index 80bc770cc0..0000000000 --- a/src/runtime/opencl/sdaccel/sdaccel_common.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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. - */ - -/*! - * \file sdaccel_common.h - * \brief SDAccel common header - */ -#ifndef TVM_RUNTIME_OPENCL_SDACCEL_SDACCEL_COMMON_H_ -#define TVM_RUNTIME_OPENCL_SDACCEL_SDACCEL_COMMON_H_ - -#include <memory> - -#include "../opencl_common.h" - -namespace tvm { -namespace runtime { -namespace cl { - -/*! - * \brief Process global SDAccel workspace. - */ -class SDAccelWorkspace final : public OpenCLWorkspace { - public: - // override OpenCL device API - void Init() final; - bool IsOpenCLDevice(Device dev) final; - OpenCLThreadEntry* GetThreadEntry() final; - // get the global workspace - static OpenCLWorkspace* Global(); -}; - -/*! \brief Thread local workspace for SDAccel*/ -class SDAccelThreadEntry : public OpenCLThreadEntry { - public: - // constructor - SDAccelThreadEntry() - : OpenCLThreadEntry(static_cast<DLDeviceType>(kDLSDAccel), SDAccelWorkspace::Global()) {} - - // get the global workspace - static SDAccelThreadEntry* ThreadLocal(); -}; -} // namespace cl -} // namespace runtime -} // namespace tvm -#endif // TVM_RUNTIME_OPENCL_SDACCEL_SDACCEL_COMMON_H_ diff --git a/src/runtime/opencl/sdaccel/sdaccel_device_api.cc b/src/runtime/opencl/sdaccel/sdaccel_device_api.cc deleted file mode 100644 index 7d4b673324..0000000000 --- a/src/runtime/opencl/sdaccel/sdaccel_device_api.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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. - */ - -/*! - * \file sdaccel_device_api.cc - */ -#include <dmlc/thread_local.h> -#include <tvm/runtime/registry.h> - -#include "sdaccel_common.h" - -namespace tvm { -namespace runtime { -namespace cl { - -OpenCLThreadEntry* SDAccelWorkspace::GetThreadEntry() { return SDAccelThreadEntry::ThreadLocal(); } - -OpenCLWorkspace* SDAccelWorkspace::Global() { - static OpenCLWorkspace* inst = new SDAccelWorkspace(); - return inst; -} - -void SDAccelWorkspace::Init() { OpenCLWorkspace::Init("sdaccel", "accelerator", "Xilinx"); } - -bool SDAccelWorkspace::IsOpenCLDevice(Device dev) { - return dev.device_type == static_cast<DLDeviceType>(kDLSDAccel); -} - -typedef dmlc::ThreadLocalStore<SDAccelThreadEntry> SDAccelThreadStore; - -SDAccelThreadEntry* SDAccelThreadEntry::ThreadLocal() { return SDAccelThreadStore::Get(); } - -TVM_REGISTER_GLOBAL("device_api.sdaccel").set_body([](TVMArgs args, TVMRetValue* rv) { - DeviceAPI* ptr = SDAccelWorkspace::Global(); - *rv = static_cast<void*>(ptr); -}); - -} // namespace cl -} // namespace runtime -} // namespace tvm diff --git a/src/runtime/opencl/sdaccel/sdaccel_module.cc b/src/runtime/opencl/sdaccel/sdaccel_module.cc deleted file mode 100644 index 4736e1ef35..0000000000 --- a/src/runtime/opencl/sdaccel/sdaccel_module.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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. - */ - -/*! - * \file sdaccel_module.cc - */ -#include "sdaccel_module.h" - -#include <dmlc/memory_io.h> -#include <tvm/runtime/registry.h> - -#include <string> -#include <unordered_map> -#include <vector> - -#include "sdaccel_common.h" - -namespace tvm { -namespace runtime { - -class SDAccelModuleNode : public OpenCLModuleNode { - public: - explicit SDAccelModuleNode(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source) - : OpenCLModuleNode(data, fmt, fmap, source) {} - cl::OpenCLWorkspace* GetGlobalWorkspace() final; -}; - -cl::OpenCLWorkspace* SDAccelModuleNode::GetGlobalWorkspace() { - return cl::SDAccelWorkspace::Global(); -} - -Module SDAccelModuleCreate(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source) { - auto n = make_object<SDAccelModuleNode>(data, fmt, fmap, source); - n->Init(); - return Module(n); -} - -Module SDAccelModuleLoadFile(const std::string& file_name, const String& format) { - std::string data; - std::unordered_map<std::string, FunctionInfo> fmap; - std::string fmt = GetFileFormat(file_name, format); - std::string meta_file = GetMetaFilePath(file_name); - LoadBinaryFromFile(file_name, &data); - LoadMetaDataFromFile(meta_file, &fmap); - return SDAccelModuleCreate(data, fmt, fmap, std::string()); -} - -Module SDAccelModuleLoadBinary(void* strm) { - dmlc::Stream* stream = static_cast<dmlc::Stream*>(strm); - std::string data; - std::unordered_map<std::string, FunctionInfo> fmap; - std::string fmt; - stream->Read(&fmt); - stream->Read(&fmap); - stream->Read(&data); - return SDAccelModuleCreate(data, fmt, fmap, std::string()); -} - -TVM_REGISTER_GLOBAL("runtime.module.loadfile_xclbin").set_body_typed(SDAccelModuleLoadFile); - -TVM_REGISTER_GLOBAL("runtime.module.loadfile_awsxclbin").set_body_typed(SDAccelModuleLoadFile); -} // namespace runtime -} // namespace tvm diff --git a/src/runtime/opencl/sdaccel/sdaccel_module.h b/src/runtime/opencl/sdaccel/sdaccel_module.h deleted file mode 100644 index 322decc446..0000000000 --- a/src/runtime/opencl/sdaccel/sdaccel_module.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -/*! - * \file sdaccel_module.h - * \brief Execution handling of OPENCL kernels for SDAccel FPGAs - */ -#ifndef TVM_RUNTIME_OPENCL_SDACCEL_SDACCEL_MODULE_H_ -#define TVM_RUNTIME_OPENCL_SDACCEL_SDACCEL_MODULE_H_ - -#include <tvm/runtime/packed_func.h> - -#include <memory> -#include <string> -#include <unordered_map> -#include <vector> - -#include "../../meta_data.h" - -namespace tvm { -namespace runtime { -/*! - * \brief create a opencl module for SDAccel from data. - * - * \param data The module data. - * \param fmt The format of the data, can be "xclbin", "awsxclbin" - * \param fmap The map function information map of each function. - */ -Module SDAccelModuleCreate(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source); -} // namespace runtime -} // namespace tvm -#endif // TVM_RUNTIME_OPENCL_SDACCEL_SDACCEL_MODULE_H_ diff --git a/src/support/libinfo.cc b/src/support/libinfo.cc index 065eaf503f..fd77427c70 100644 --- a/src/support/libinfo.cc +++ b/src/support/libinfo.cc @@ -123,10 +123,6 @@ #define TVM_INFO_USE_OPENMP "NOT-FOUND" #endif -#ifndef TVM_INFO_USE_RELAY_DEBUG -#define TVM_INFO_USE_RELAY_DEBUG "NOT-FOUND" -#endif - #ifndef TVM_INFO_DEBUG_WITH_ABI_CHANGE #define TVM_INFO_DEBUG_WITH_ABI_CHANGE "NOT-FOUND" #endif @@ -343,7 +339,6 @@ TVM_DLL Map<String, String> GetLibInfo() { {"USE_OPENMP", TVM_INFO_USE_OPENMP}, {"USE_PAPI", TVM_INFO_USE_PAPI}, {"USE_RANDOM", TVM_INFO_USE_RANDOM}, - {"USE_RELAY_DEBUG", TVM_INFO_USE_RELAY_DEBUG}, {"TVM_DEBUG_WITH_ABI_CHANGE", TVM_INFO_TVM_DEBUG_WITH_ABI_CHANGE}, {"TVM_LOG_BEFORE_THROW", TVM_INFO_TVM_LOG_BEFORE_THROW}, {"USE_ROCBLAS", TVM_INFO_USE_ROCBLAS}, diff --git a/src/target/opt/build_aocl_off.cc b/src/target/opt/build_aocl_off.cc deleted file mode 100644 index 9f9d098b7a..0000000000 --- a/src/target/opt/build_aocl_off.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -/*! - * Optional module when build aocl is switched to off - */ -#include "../../runtime/opencl/opencl_module.h" -#include "../source/codegen_source_base.h" - -namespace tvm { -namespace runtime { - -Module AOCLModuleCreate(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source) { - LOG(WARNING) << "AOCL runtime not enabled, return a source module..."; - return codegen::DeviceSourceModuleCreate(data, fmt, fmap, "aocl"); -} - -} // namespace runtime -} // namespace tvm diff --git a/src/target/opt/build_sdaccel_off.cc b/src/target/opt/build_sdaccel_off.cc deleted file mode 100644 index 0de305c2a3..0000000000 --- a/src/target/opt/build_sdaccel_off.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -/*! - * Optional module when build opencl is switched to off - */ -#include "../../runtime/opencl/opencl_module.h" -#include "../source/codegen_source_base.h" - -namespace tvm { -namespace runtime { - -Module SDAccelModuleCreate(std::string data, std::string fmt, - std::unordered_map<std::string, FunctionInfo> fmap, std::string source) { - LOG(WARNING) << "OpenCL runtime not enabled, return a source module..."; - return codegen::DeviceSourceModuleCreate(data, fmt, fmap, "sdaccel"); -} - -} // namespace runtime -} // namespace tvm diff --git a/src/target/source/codegen_aocl.cc b/src/target/source/codegen_aocl.cc deleted file mode 100644 index dc3ba08751..0000000000 --- a/src/target/source/codegen_aocl.cc +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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. - */ - -/*! - * \file codegen_aocl.cc - */ -#include <tvm/target/target.h> - -#include <string> -#include <vector> - -#include "../../runtime/file_utils.h" -#include "../../runtime/opencl/aocl/aocl_module.h" -#include "../build_common.h" -#include "codegen_opencl.h" - -namespace tvm { -namespace codegen { - -runtime::Module BuildAOCL(IRModule mod, Target target, bool emulation) { - // Get code. - using tvm::runtime::Registry; - bool output_ssa = false; - CodeGenOpenCL cg; - cg.Init(output_ssa); - - Map<GlobalVar, PrimFunc> functions; - for (auto [gvar, base_func] : mod->functions) { - ICHECK(base_func->IsInstance<PrimFuncNode>()) << "CodegenOpenCL: Can only take PrimFunc"; - auto prim_func = Downcast<PrimFunc>(base_func); - auto calling_conv = prim_func->GetAttr<Integer>(tvm::attr::kCallingConv); - ICHECK(calling_conv == CallingConv::kDeviceKernelLaunch) - << "CodegenOpenCL: expect calling_conv equals CallingConv::kDeviceKernelLaunch"; - functions.Set(gvar, prim_func); - } - - for (auto [gvar, prim_func] : functions) { - cg.DeclareFunction(gvar, prim_func); - } - - for (auto [gvar, prim_func] : functions) { - cg.AddFunction(gvar, prim_func); - } - - std::string code = cg.Finish(); - if (const auto* f = Registry::Get("tvm_callback_opencl_postproc")) { - code = (*f)(code, target).operator std::string(); - } - - // Write a .cl file. - runtime::SaveBinaryToFile("aocl.cl", code.c_str()); - - // Compile the .cl file. - std::string cmd = "aoc aocl.cl"; - // AOCL supports fp64. - cmd += " -Dcl_khr_fp64"; - Optional<String> device = target->GetAttr<String>("device"); - if (device.defined()) { - cmd += " -board=" + device.value(); - } - if (emulation) { - cmd += " -march=emulator"; - } - if (system(cmd.c_str()) != 0) { - LOG(FATAL) << "OpenCL offline compilation error."; - } - - // Read .aocx file - std::string aocxbin; - runtime::LoadBinaryFromFile("aocl.aocx", &aocxbin); - - return AOCLModuleCreate(aocxbin, "aocx", ExtractFuncInfo(mod), code); -} - -TVM_REGISTER_GLOBAL("target.build.aocl") - .set_body_typed([](IRModule mod, Target target) -> runtime::Module { - return BuildAOCL(mod, target, false); - }); - -TVM_REGISTER_GLOBAL("target.build.aocl_sw_emu") - .set_body_typed([](IRModule mod, Target target) -> runtime::Module { - return BuildAOCL(mod, target, true); - }); - -} // namespace codegen -} // namespace tvm diff --git a/src/target/source/codegen_vhls.cc b/src/target/source/codegen_vhls.cc deleted file mode 100644 index e4ea1db347..0000000000 --- a/src/target/source/codegen_vhls.cc +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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. - */ - -/*! - * \file codegen_vhls.cc - */ -#include "codegen_vhls.h" - -#include <string> - -#include "../../runtime/opencl/sdaccel/sdaccel_module.h" -#include "../build_common.h" - -namespace tvm { -namespace codegen { - -void CodeGenVivadoHLS::Init(bool output_ssa) { - CodeGenC::Init(output_ssa); - - this->stream << "#include <ap_int.h>\n\n"; - this->stream << "#include <algorithm>\n\n"; -} - -void CodeGenVivadoHLS::PrintType(DataType t, std::ostream& os) { - if (t.is_uint()) { - switch (t.bits()) { - case 8: - os << "unsigned char"; - break; - case 16: - os << "unsigned short"; - break; - case 32: - os << "unsigned int"; - break; - case 64: - os << "unsigned long long"; - break; - default: - os << "ap_uint<" << t.bits() << ">"; - break; - } - } else if (t.is_int()) { - switch (t.bits()) { - case 8: - os << "char"; - break; - case 16: - os << "short"; - break; - case 32: - os << "int"; - break; - case 64: - os << "long long"; - break; - default: - os << "ap_int<" << t.bits() << ">"; - break; - } - } else { - CodeGenC::PrintType(t, os); - } -} - -void CodeGenVivadoHLS::PrintFuncPrefix(std::ostream& os) { os << "extern \"C\" "; } - -void CodeGenVivadoHLS::PreFunctionBody(const PrimFunc& f) { - for (size_t i = 0; i < f->params.size(); ++i) { - Var v = f->params[i]; - std::string vid = GetVarID(v.get()); - if (v.dtype().is_handle()) { - this->stream << "#pragma HLS INTERFACE m_axi port=" << vid << " offset=slave bundle=gmem\n"; - } - this->stream << "#pragma HLS INTERFACE s_axilite port=" << vid << " bundle=control\n"; - } - this->stream << "#pragma HLS INTERFACE s_axilite port=return bundle=control\n\n"; -} - -template <typename T> -inline void PrintBinaryExpr(const T* op, const char* opstr, - std::ostream& os, // NOLINT(*) - CodeGenVivadoHLS* p) { - os << opstr << '('; - p->PrintExpr(op->a, os); - os << ", "; - p->PrintExpr(op->b, os); - os << ')'; -} - -void CodeGenVivadoHLS::VisitExpr_(const MinNode* op, std::ostream& os) { // NOLINT(*) - const char* opstr = "std::min"; - if (op->dtype.is_float()) { - switch (op->dtype.bits()) { - case 32: - opstr = "fminf"; - break; - case 64: - opstr = "fmin"; - break; - } - } - - PrintBinaryExpr(op, opstr, os, this); -} - -void CodeGenVivadoHLS::VisitExpr_(const MaxNode* op, std::ostream& os) { // NOLINT(*) - const char* opstr = "std::max"; - if (op->dtype.is_float()) { - switch (op->dtype.bits()) { - case 32: - opstr = "fmaxf"; - break; - case 64: - opstr = "fmax"; - break; - } - } - - PrintBinaryExpr(op, opstr, os, this); -} - -runtime::Module BuildSDAccel(IRModule mod, Target target) { - using tvm::runtime::Registry; - bool output_ssa = false; - CodeGenVivadoHLS cg; - - // Generate source code for get_source(). - cg.Init(output_ssa); - - Map<GlobalVar, PrimFunc> functions; - for (auto [gvar, base_func] : mod->functions) { - ICHECK(base_func->IsInstance<PrimFuncNode>()) << "CodeGenVHLS: Can only take PrimFunc"; - auto prim_func = Downcast<PrimFunc>(base_func); - auto calling_conv = prim_func->GetAttr<Integer>(tvm::attr::kCallingConv); - ICHECK(calling_conv == CallingConv::kDeviceKernelLaunch) - << "CodeGenVLHS: expect calling_conv equals CallingConv::kDeviceKernelLaunch"; - functions.Set(gvar, prim_func); - } - - for (auto [gvar, prim_func] : functions) { - cg.DeclareFunction(gvar, prim_func); - } - for (auto [gvar, prim_func] : functions) { - cg.AddFunction(gvar, prim_func); - } - - std::string whole_code = cg.Finish(); - - // Generate source code for compilation. - Array<Array<runtime::String>> kernel_info; - - for (auto [gvar, prim_func] : functions) { - CodeGenVivadoHLS cg; - cg.Init(output_ssa); - - for (auto [other_gvar, other_prim_func] : functions) { - cg.DeclareFunction(other_gvar, other_prim_func); - } - cg.AddFunction(gvar, prim_func); - std::string code = cg.Finish(); - if (const auto* f = runtime::Registry::Get("tvm_callback_vhls_postproc")) { - code = (*f)(code, target).operator std::string(); - } - - auto function_name = cg.GetFunctionName(gvar); - kernel_info.push_back({function_name, code}); - } - - std::string xclbin; - if (const auto* f = Registry::Get("tvm_callback_sdaccel_compile")) { - xclbin = (*f)(kernel_info, target).operator std::string(); - } else { - LOG(FATAL) << "Cannot compile Vivado HLS code."; - } - return SDAccelModuleCreate(xclbin, "xclbin", ExtractFuncInfo(mod), whole_code); -} - -TVM_REGISTER_GLOBAL("target.build.sdaccel").set_body_typed(BuildSDAccel); - -} // namespace codegen -} // namespace tvm diff --git a/src/target/source/codegen_vhls.h b/src/target/source/codegen_vhls.h deleted file mode 100644 index d8ba2b6874..0000000000 --- a/src/target/source/codegen_vhls.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. -5B5B */ - -/*! - * \file codegen_vhls.h - * \brief Utility to generate vhls code - */ -#ifndef TVM_TARGET_SOURCE_CODEGEN_VHLS_H_ -#define TVM_TARGET_SOURCE_CODEGEN_VHLS_H_ - -#include <tvm/target/codegen.h> -#include <tvm/target/target.h> -#include <tvm/tir/expr.h> - -#include "codegen_c.h" - -namespace tvm { -namespace codegen { - -class CodeGenVivadoHLS final : public CodeGenC { - public: - void Init(bool output_ssa); - void PrintType(DataType t, std::ostream& os); - - void PrintFuncPrefix(std::ostream& os) final; - void PreFunctionBody(const PrimFunc& f) final; - void VisitExpr_(const MinNode* op, std::ostream& os) final; - void VisitExpr_(const MaxNode* op, std::ostream& os) final; -}; - -} // namespace codegen -} // namespace tvm - -#endif // TVM_TARGET_SOURCE_CODEGEN_VHLS_H_ diff --git a/src/target/source/intrin_rule_aocl.cc b/src/target/source/intrin_rule_aocl.cc deleted file mode 100644 index 599e62f3f3..0000000000 --- a/src/target/source/intrin_rule_aocl.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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. - */ - -/*! - * \file intrin_rule_aocl.cc - * \brief AOCL intrinsic rules. - */ -#include <tvm/tir/op_attr_types.h> - -#include "../intrin_rule.h" - -namespace tvm { -namespace codegen { -namespace intrin { -using tir::FLowerIntrinsic; - -TVM_REGISTER_OP("tir.floor") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.ceil") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.trunc") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.fabs") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.round") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.nearbyint") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.exp").set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.log").set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.tanh") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.sqrt") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.pow").set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.popcount") - .set_attr<FLowerIntrinsic>("aocl.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.floor") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.ceil") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.trunc") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.fabs") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.round") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.nearbyint") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.exp").set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.log").set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.tanh") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.sqrt") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.pow").set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.popcount") - .set_attr<FLowerIntrinsic>("aocl_sw_emu.FLowerIntrinsic", DispatchPureExtern<Direct>); - -} // namespace intrin -} // namespace codegen -} // namespace tvm diff --git a/src/target/source/intrin_rule_vhls.cc b/src/target/source/intrin_rule_vhls.cc deleted file mode 100644 index 7bfd7cd136..0000000000 --- a/src/target/source/intrin_rule_vhls.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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. - */ - -/*! - * \file intrin_rule_vhls.cc - * \brief VHLS intrinsic rules. - */ -#include <tvm/tir/op_attr_types.h> - -#include "../intrin_rule.h" - -namespace tvm { -namespace codegen { -namespace intrin { -using tir::FLowerIntrinsic; - -TVM_REGISTER_OP("tir.floor") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.ceil") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.trunc") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.fabs") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.round") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.nearbyint") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.exp").set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.exp2") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.exp10") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.log").set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.log2") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.log10") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.tanh") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.sqrt") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.pow").set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.popcount") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.sin").set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.sinh") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.cos").set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", - DispatchPureExtern<Direct>); - -TVM_REGISTER_OP("tir.cosh") - .set_attr<FLowerIntrinsic>("sdaccel.FLowerIntrinsic", DispatchPureExtern<Direct>); - -} // namespace intrin -} // namespace codegen -} // namespace tvm diff --git a/src/target/target_kind.cc b/src/target/target_kind.cc index 3605831da1..62ba2787a3 100644 --- a/src/target/target_kind.cc +++ b/src/target/target_kind.cc @@ -425,15 +425,6 @@ TVM_REGISTER_TARGET_KIND("webgpu", kDLWebGPU) .add_attr_option<runtime::Int>("max_num_threads", runtime::Int(256)) .set_default_keys({"webgpu", "gpu"}); -TVM_REGISTER_TARGET_KIND("sdaccel", kDLOpenCL) // line break - .set_default_keys({"sdaccel", "hls"}); - -TVM_REGISTER_TARGET_KIND("aocl", kDLAOCL) // line break - .set_default_keys({"aocl", "hls"}); - -TVM_REGISTER_TARGET_KIND("aocl_sw_emu", kDLAOCL) // line break - .set_default_keys({"aocl", "hls"}); - TVM_REGISTER_TARGET_KIND("hexagon", kDLHexagon) .add_attr_option<Array<String>>("mattr") .add_attr_option<String>("mcpu") diff --git a/src/tir/analysis/verify_memory.cc b/src/tir/analysis/verify_memory.cc index a990230e04..4f9c3e5edd 100644 --- a/src/tir/analysis/verify_memory.cc +++ b/src/tir/analysis/verify_memory.cc @@ -57,7 +57,7 @@ class MemoryAccessVerifier final : protected StmtExprVisitor { /// Interface to perform memory access verification void Run() { - if (!IsGPUDevice(dev_type_) && !IsFPGADevice(dev_type_)) return; + if (!IsGPUDevice(dev_type_)) return; StmtExprVisitor::VisitStmt(func_->body); } @@ -152,8 +152,6 @@ class MemoryAccessVerifier final : protected StmtExprVisitor { return kDLCUDA == dev_type || kDLOpenCL == dev_type || kDLVulkan == dev_type || kDLMetal == dev_type || kDLROCM == dev_type || kOpenGL == dev_type; } - /// Check if a given DLDeviceType/TVMDeviceExtType value denotes FPGA device. - static bool IsFPGADevice(int dev_type) { return kDLSDAccel == dev_type || kDLAOCL == dev_type; } private: /// Status of visitor diff --git a/tests/scripts/task_python_integration_gpuonly.sh b/tests/scripts/task_python_integration_gpuonly.sh index 432984c955..b01320db1f 100755 --- a/tests/scripts/task_python_integration_gpuonly.sh +++ b/tests/scripts/task_python_integration_gpuonly.sh @@ -18,7 +18,7 @@ set -exo pipefail -export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali,aocl_sw_emu,adreno" +export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali,adreno" export PYTEST_ADDOPTS="-m gpu $PYTEST_ADDOPTS" export TVM_RELAY_TEST_TARGETS="cuda" export TVM_RELAY_OPENCL_TEXTURE_TARGETS="opencl -device=adreno" diff --git a/tests/scripts/task_python_unittest_gpuonly.sh b/tests/scripts/task_python_unittest_gpuonly.sh index 6c4e642b0c..6d28d8f30f 100755 --- a/tests/scripts/task_python_unittest_gpuonly.sh +++ b/tests/scripts/task_python_unittest_gpuonly.sh @@ -21,7 +21,7 @@ set -euxo pipefail export PYTEST_ADDOPTS="-m gpu ${PYTEST_ADDOPTS:-}" # Test most of the enabled runtimes here. -export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali,aocl_sw_emu" +export TVM_TEST_TARGETS="cuda;opencl;metal;rocm;nvptx;opencl -device=mali" export TVM_UNITTEST_TESTSUITE_NAME=python-unittest-gpu ./tests/scripts/task_python_unittest.sh
