Go to the Ascend samples repository on Gitee or GitHub and download the sample package that matches the required version. For the version mapping, see "Release Notes" in the README file. Find the "gemm" sample in the cplusplus/level1_single_api/1_acl/4_blas/gemm directory.
This sample implements matrix-matrix multiplication: C = αAB + βC, where, A, B, and C are 16 x 16 matrices, meaning that m = 16, n = 16, and k = 16. The result is also a 16 x 16 matrix.
The following table lists the key functions involved in this sample. For details about the APIs, see AscendCL API Reference.
Initialization |
|
|---|---|
Device Management |
|
Stream Management |
|
Memory Management |
|
Data Transfer |
aclrtMemcpy (used when the app runs on the host):
Data transfer is not required if your app runs in the board environment. |
Single-Operator Execution |
|
The sample directory is organized as follows:
├── inc
│ ├── common.h //Header file that declares common functions (such as the file reading function)
│ ├── gemm_runner.h //Header file that declares the functions related to matrix multiplication
├── run
│ ├── out
│ │ ├──test_data
│ │ │ ├── config
│ │ │ │ ├── acl.json //Configuration file for system initialization
│ │ │ │ ├── gemm.json //Description information file of the matrix multiplication operator
│ │ │ ├── data
│ │ │ │ ├── generate_data.py //Script for generating the data of matrix A and matrix B
├── src
│ ├── CMakeLists.txt //Build script
│ ├── common.cpp //Implementation file of common functions (such as the file reading function)
│ ├── gemm_main.cpp //Implementation file of the main function
│ ├── gemm_runner.cpp //Implementation file for executing functions related to matrix multiplication