我要评分
获取效率
正确性
完整性
易理解

Introduction

This document provides the installation guide, detailed interface definition, and sample code of the Kunpeng System Library (KSL).

KSL is a high-performance system function library provided by Huawei and optimized for the Kunpeng platform. It offers capabilities such as x86 instruction migration, memory allocation, multi-threading, encoding and decoding, and character string matching on Kunpeng. By utilizing Kunpeng hardware advantages, KSL highlights better performance and usability than the open source implementation. All KSL interfaces are implemented in C, C++, and assembly languages. Table 1 shows the composition of KSL.

Table 1 KSL composition

No.

Library

Description

Application Scenario

1

AVX2KI

Arm implementation of Intel intrinsics. AVX To Kunpeng Intrinsic (AVX2KI) is an interface collection library that re-implements the intrinsic interface collection on a conventional platform using Kunpeng instructions and encapsulates the intrinsic interface collection as an independent interface module (in C language header file mode) to reduce the workload of repeated development of porting projects. Users can continue to use the intrinsic functions of a conventional platform by importing the header file into the application.

Adaptation and migration of Intel intrinsics to Kunpeng processors

2

KQMalloc

The Kunpeng Quick Malloc library (KQMalloc) is a memory allocator designed for Kunpeng 920 series processors. The allocator has two versions, one for single-threaded applications and the other for multi-threaded applications. It minimizes internal cache usage and cache misses to dramatically improve application performance.

Memory application and releasing

3

HTL

The Hyper Thread Library (HTL) is a user-level thread library built on kernel-mode threads. It is used to solve the problem that application performance deteriorates and the system resources are insufficient when a large number of kernel-mode threads are used, especially when the performance is extremely low in nested parallel scenarios. This library improves concurrency and performance while reducing resource usage.

Multi-thread parallel application

4

KSL_ASN1

Abstract Syntax Notation One (ASN.1) defines a formalism for the specification of abstract data types. This notation is used to flexibly describe data representation, encoding, transmission, and decoding. The KSL_ASN1 library is optimized based on open source ASN.1 software for the Kunpeng platform and has higher performance compared with asn1c. KSL_ASN1 supports the Basic Encoding Rules (BER), Distinguished Encoding Rules (DER), Packed Encoding Rules (PER), and XML Encoding Rules (XER).

ASN.1 file parsing, encoding, and decoding

5

KHSEL

The Kunpeng Hyperscan Enhanced Library (KHSEL) is a software enhancement package for open source Hyperscan based on Kunpeng 920 series processors. It includes the KHSEL_ops and KHSEL_core sub-libraries, a hybrid model with a short-rule bypass, and a false-positive blocking model.

  • KHSEL_ops provides the ReplaceAllAcc function, which accelerates the ReplaceAll function of the C++ standard library in a fixed rule. The optimization effect can be obtained on Kunpeng 920 series processors.
  • KHSEL_core optimizes the large-pattern matching algorithm FDR and small-pattern quick matching algorithm Shufti, and enhances the scan performance of Hyperscan for processing datasets such as snort_literal and snort_pcre.
  • The hybrid model with a short-rule bypass significantly improves the matching performance for rule sets containing short rules.
  • The false-positive blocking model greatly improves the matching performance for rule sets that contain bad string fragments. "Bad strings" refer to a small number of rules with special fragments, causing excessive false positives in multi-pattern matching. This triggers a large number of interpreter calls and inefficient long-rule verification, but yields zero true matches. These unnecessary interpreter calls become computing hotspots, undermining the pre-filtering capability of multi-pattern matching.

Regular expression matching

Match functions

6

kpglibc

The Kunpeng GNU C Library (kpglibc) uses a vectorized instruction set to optimize the performance of string, memory, and time operation functions for Kunpeng 920 series processors.

String, memory, and time operation functions

KSL is available only for Kunpeng processors. To achieve better performance, complete input parameter verification is not performed in KSL interfaces. Use valid input parameters, and invalid input parameters may cause errors.