C APIs at the SIMD Language Extension Layer
C APIs open the complete programming capabilities of the chip, support memory allocation in array format, and generally use pointer-based programming, providing a consistent C language programming experience with the industry.
The asc_simd.h file needs to be included to call the corresponding C APIs. Unless otherwise specified, including this header file meets the API calling requirements. If there are special notes in the API documentation, follow the specific instructions for the API.
#include "c_api/asc_simd.h"
C APIs are classified into the following types:
- Vector compute APIs: These APIs are used to call the Vector Unit to perform computation.
- Data movement APIs: The compute APIs perform computation based on data in the local memory. Therefore, data needs to be moved from the global memory to the local memory, computed by calling the compute APIs, and then moved from the local memory to the global memory. The APIs that move data are called data movement APIs.
- Synchronization control APIs, such as the asc_sync_notify and asc_sync_wait APIs, are used to implement communication and synchronization between tasks. Different API instructions may depend on each other. It can be learned from Abstract Hardware Architecture that different instructions are executed asynchronously in parallel. To ensure that instructions in different instruction queues are executed according to correct logic, synchronization instructions need to be sent to different units. Synchronization control APIs complete the process of sending synchronization instructions internally.
- System variable APIs: These APIs are used to access and obtain built-in system variables and assist in compute APIs.
Compute APIs can be classified into the following types:
- Computation of the first n data elements: This type of API uses a "closely arranged" data reading mode during computation. That is, the required data is sequentially and continuously obtained from the start position. For example, if N data elements need to be processed, the data is sequentially obtained from the 0th position to the (N-1)th position of the source operand.
- High-dimensional sharding computation: This type of API skips some data based on the specified rules. These APIs are suitable for scenarios that require interval sampling and offers high flexibility. However, additional parameters need to be configured.
- Synchronous computation: This type of API automatically inserts synchronization operations, making it easier to use.
Parent topic: Language Extension Layer