Skip to content

Repository files navigation

Language: English | 中文

What is FindTOPS

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 via CMakeTOPSCompiler.cmake.in / CMakeDetermineTOPSCompiler.cmake / CMakeTestTOPSCompiler.cmake, so that .tops source files can be added to add_executable / add_library exactly like .cpp or .cu files.
  • Automatic TOPS toolkit discovery: it locates the topscc compiler, the TOPS runtime (libtopsrt.so), and toolkit include directories, with sensible search paths (/usr/bin, /opt/tops/bin) and overridable via CMAKE_TOPS_COMPILER_TOOLKIT_ROOT.
  • Built-in TOPS target features such as tops_std_11 / tops_std_14 / tops_std_17 via target_tops_compile_features(), and a add_tops_compile_flags() helper.
  • A cross-compilation friendly layout that handles host/TOPS compiler separation and target-specific include directories.

Comparison with FindCUDA

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.


Prerequisites

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.

Docker

The easiest way to get started is using the pre-built Docker image with all dependencies included.

  1. 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
  2. Enter the container and verify:

    docker exec -it findtops bash
    topscc --version

how to build FindTOPS

# 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

how to install FindTOPS

ubuntu/debian

dpkg -i findtops_1.1.7-1_all.deb

centos/redhat

rpm -ivh findtops-1.1.7-1.noarch.rpm

how to use FindTOPS

add below in your CMakeLists.txt

Method 1: Default (Recommended)

list(APPEND CMAKE_MODULE_PATH "/opt/tops/cmake_modules")
include(FindTOPS)
project(TargetLinkLibraries CXX TOPS)

Method 2: Use enable_language(TOPS) after project line

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 Ninja

If 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 Ninja

detail usage please refer samples

MixedCppAndTops

1. cmake MixedCppAndTops -B cmake_build -G Ninja
2. cd cmake_build
3. ninja

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages