Compilation Using CMake

In a project, you can use CMake to more easily use the BiSheng Compiler to compile Ascend C SIMT operators and generate executable files.

The following is an example of the CMake script and its core steps:
cmake_minimum_required(VERSION 3.16)

# 1. find_package(ASC) is a command used in CMake to search for and configure the Ascend C compilation toolchain.
find_package(ASC)  

# 2. Specify that the project supports the ASC and CXX languages. ASC indicates that the Ascend C programming language can be compiled using the BiSheng Compiler.
project(kernel_samples LANGUAGES ASC CXX)

# 3. Use the CMake API to compile executable files.
add_executable(demo
    add_custom.asc
)
#.....
target_compile_options(demo PRIVATE
    # --npu-arch specifies the NPU architecture version. The string following dav- is the architecture version number.
    # <COMPILE_LANGUAGE:ASC>: indicates that the compilation option takes effect only for the ASC language.
    $<$<COMPILE_LANGUAGE:ASC>: --npu-arch=dav-3510>
    # Enable the compilation function of the SIMT programming model.
    --enable-simt   
)

The following table lists the default link libraries when CMake is used for compilation.

Table 1 Default link libraries

Name

Description

libascendc_runtime.a

Assembly library for Ascend C operator parameters.

libruntime.so

Runtime library.

libprofapi.so

Library for collecting running performance data of Ascend C operators.

libunified_dlog.so

CANN log collection library.

libmmpa.so

CANN system API library.

libascend_dump.so

CANN maintenance and test information library.

libc_sec.so

CANN security function library.

liberror_manager.so

CANN error information management library.

libascendcl.so

ACL-related API library.