Heterogeneous Computing

Ascend C programming involves developing code on two different platforms (host and device). This chapter briefly describes the differences between the host and device to help you understand the heterogeneous system. It also describes the operator data flow, to help you further understand how to properly arrange the executions of operator code in the heterogeneous architecture.

Differences Between the Host CPU and Device NPU

How to Properly Arrange Operator Code

The host and device can be deemed as a collaborative heterogeneous system for allocating the work that they are good at to each processing unit. Non-computing-intensive tasks (usually scalar tasks) are recommended on the host. Computing-intensive tasks are recommended on the device. The Single Instruction/Multiple Data (SIMD) of the device NPU can be used to efficiently implement matrix and vector operations for batch data.

Ascend C operator implementation consists of two parts:

Operator Data Flow

Data exchanges between the host and device happen during operator execution. The following provides the specific data flow for the passing of tiling parameters. First, the tiling algorithm on the host computes tiling parameters based on the operator input and output and stores the parameters in the tiling structure. Then, the tiling structure on the host is sent to the device. Finally, the operator on the device obtains and parses the tiling structure, and executes the subsequent operator compute logic based on the information.

Figure 1 Operator tiling data flow