Language: English | 中文
FindTOPS is a CMake module set designed and implemented in the spirit of CMake's FindCUDA module. It enables CMake to build TOPS (the Enflame GPGPU compute framework) source files (.tops) in a first-class way, similar to how CMake natively supports CXX, C, Fortran, and CUDA languages.
Concretely, FindTOPS provides:
- A first-class CMake language
TOPS, registered viaCMakeTOPSCompiler.cmake.in/CMakeDetermineTOPSCompiler.cmake/CMakeTestTOPSCompiler.cmake, so that.topssource files can be added toadd_executable/add_libraryexactly like.cppor.cufiles. - Automatic TOPS toolkit discovery: it locates the
topscccompiler, the TOPS runtime (libtopsrt.so), and toolkit include directories, with sensible search paths (/usr/bin,/opt/tops/bin) and overridable viaCMAKE_TOPS_COMPILER_TOOLKIT_ROOT. - Built-in TOPS target features such as
tops_std_11/tops_std_14/tops_std_17viatarget_tops_compile_features(), and aadd_tops_compile_flags()helper. - A cross-compilation friendly layout that handles host/TOPS compiler separation and target-specific include directories.
| Aspect | FindCUDA (CMake builtin) |
FindTOPS (this project) |
|---|---|---|
| Goal | Build .cu files with nvcc |
Build .tops files with topscc |
| Usage style | find_package(CUDA) + cuda_add_executable |
enable_language(TOPS) (or project(... CXX TOPS)) — .tops is added to targets just like .cpp/.cu |
| Status | Deprecated since CMake 3.10, removed in 3.27; replaced by first-class CUDA language |
Already a first-class language (TOPS) registered through CMake's compiler infrastructure |
| Compiler detection | CUDA_NVCC_EXECUTABLE |
TOPSToolkit_TOPSCC_EXECUTABLE / CMAKE_TOPS_COMPILER (auto-detected) |
| Standard control | CUDA_STANDARD / CUDA_STANDARD_REQUIRED |
CMAKE_TOPS_STANDARD / CMAKE_TOPS_STANDARD_REQUIRED (supports C++11/14/17) |
| Extra helpers | cuda_select_nvcc_arch_flags, etc. |
add_tops_compile_flags(), target_tops_compile_features(), update_tops_flags() |
| Custom toolkit path | CUDA_TOOLKIT_ROOT |
CMAKE_TOPS_COMPILER_TOOLKIT_ROOT |
In short: FindTOPS is to topscc what FindCUDA was to nvcc — and it does so by promoting TOPS to a first-class CMake language, so the legacy find_package + custom macro style is no longer needed.
findtops depends on the Enflame TOPS software stack. Before installing findtops, ensure the following components are installed:
| Component | Description |
|---|---|
| TopsRider | Enflame AI development toolkit (recommended: install all components via the TopsRider installer) |
| TopsRuntime | GCU runtime library |
Recommended: Use the TopsRider installer for one-click setup of all dependencies. Refer to the TopsRider installation documentation for details.
The easiest way to get started is using the pre-built Docker image with all dependencies included.
-
Pull and start the container:
IMAGE=registry-egc.enflame-tech.com/artifacts/torch_gcu:v2.10.0-TR3.7.107-ubuntu2204 docker run --name findtops -d \ -v /home:/home \ --shm-size 8G \ --ipc=host --network host \ --cap-add SYS_PTRACE \ --security-opt seccomp=unconfined \ --privileged \ "$IMAGE" \ tail -f /dev/null -
Enter the container and verify:
docker exec -it findtops bash topscc --version
# package version 1.1.7 for example
cmake findtops -G Ninja -B cmake_build -DPACKAGE_VERSION=1.1.7
cd cmake_build
ninja package_all
dpkg -i findtops_1.1.7-1_all.deb
rpm -ivh findtops-1.1.7-1.noarch.rpm
list(APPEND CMAKE_MODULE_PATH "/opt/tops/cmake_modules")
include(FindTOPS)
project(TargetLinkLibraries CXX TOPS)list(APPEND CMAKE_MODULE_PATH "/opt/tops/cmake_modules")
include(FindTOPS)
project(TargetLinkLibraries CXX)
enable_language(TOPS)CMake will search topscc in /usr/bin or /opt/tops/bin by default, so you can execute cmake like this:
cmake TestProject -B cmake_build -G NinjaIf you want to use topscc in your own path, please use -DCMAKE_TOPS_COMPILER_TOOLKIT_ROOT in cmake configuration:
cmake TestProject -DCMAKE_TOPS_COMPILER_TOOLKIT_ROOT=/path/to/opt/tops -B cmake_build -G Ninja1. cmake MixedCppAndTops -B cmake_build -G Ninja
2. cd cmake_build
3. ninja