In the Ascend C programming model, the core elements of the parallel programming paradigm are a group of parallel compute tasks, synchronization between tasks through queues, and custom scheduling of parallel compute tasks and resources. This section describes the design principles of the programming model, helping you better understand the design and advantages of the programming model and facilitating subsequent in-depth development.
The programming paradigm of each parallel task stage is as follows:
Take the simplest vector programming paradigm as an example. When the preceding APIs are called, some instructions are actually delivered to each execution unit, as shown in the following figure.

EnQue/DeQue mainly solves the problem of synchronous control of read-after-write of parallel execution units when data dependency exists.


AllocTensor/FreeTensor mainly solves the problem of synchronous control of write-after-read of parallel execution units when data dependency exists.

In conclusion, complex synchronization control needs to be considered for asynchronous parallel programs. The Ascend C programming model encapsulates these processes and uses EnQue/DeQue/AllocTensor/FreeTensor to simplify programming and facilitate understanding.