Rate This Document
Findability
Accuracy
Completeness
Readability

Checking Matricization

The matricization check function checks matricizable code fragments and provides modification suggestions.

Command Function

Checks matricizable code snippets.

Syntax

devkit advisor matrix-check [-h | --help] {-i INPUT_PATH | --input INPUT_PATH} [-s SCAN_DIR | --scan-dir SCAN_DIR] [-b {make,cmake} | --build-tool {make,cmake}] [-c COMMAND | --cmd COMMAND] [-j COMPILE_JSON_PATH | --compile-command-json COMPILE_JSON_PATH] [-o OUTPUT_PATH | --output OUTPUT_PATH] [-r {all,html,csv} | --report-type {all,html,csv}] {-p {sme,domain} | --optimization {sme,domain}} [-m {compute,memory_access,communication} | --module {compute,memory_access,communication}] [-l {0,1,2,3} | --log-level {0,1,2,3}][--set-timeout TIMEOUT]

Parameter Description

Table 1 Parameter description

Parameter

Option

Description

-h/--help

-

Obtains help information. This parameter is optional.

-i/--input

-

Absolute path to the source code folder to be scanned. This parameter is mandatory.

-s/--scan-dir

-

Relative path to the file or folder to be scanned in the source folder. Use spaces to separate them if there are multiple paths. This parameter is optional.

-b/--build-tool

make/cmake

Build tool, which defaults to make. Set either -b or -j but not both. This parameter is optional.

-c/--cmd

-

Source code build command, which defaults to make. This parameter is optional. Builds source code. If there are multiple build commands, separate them with semicolons (;) and enclose them with single quotation marks (') or double quotation marks ("). If a command contains spaces, enclose it with single or double quotation marks. Set either -c or -j but not both.

Example: "mkdir build;cd build;cmake ..;make"

NOTE:

The source code build command in the command line tool does not support variable setting and environment variable export.

Example: "CFLAGS='-O0 -g';make" or "export CFLAGS='-O0 -g';make"

-j/--compile-command-json

-

Path to the compile_commands.json file. This parameter is optional. For details about how to generate a JSON file, see Generating a JSON File.

Set either -b/-c or -j but not both.

-o/--output

-

Path for storing scan reports. By default, scan reports are stored in the current execution path. A report name is the format of Module-name_Timestamp. This parameter is optional.

-r/--report-type

all/html/csv

Scan report format, which defaults to all. This parameter is optional.

  • all: generates reports in HTML and CSV formats.
  • html: generates a report only in HTML format.
  • csv: generates a report only in CSV format.

-p/--optimization

sme/domain

Matricization optimization method. This parameter is mandatory.

  • sme: Scalable Matrix Extension (SME)-based matricization, covering Stencil, GEMV, and FFT.
  • domain: domain-specific optimization, which must be used together with the -m option.

-m/--module

compute/memory_access/communication

Domain-specific optimization method. This parameter is optional.

  • compute: computing optimization, covering equivalent transformation, elimination of redundant common operators, unit step calculation optimization, precision-consistent conversion of division to multiplication, search algorithm optimization, parallelization of reduction calculation, directive statement optimization, Sin/Cos operator fusion, exp calculation simplification, loop fusion, cut-off radius branch elimination, iterative calculation and lookup splitting, inter-particle forces iteration optimization, unrolling of intermolecular forces iteration, full unrolling of fixed-length loops, adjacency table aggregation, vectorized calculation of adjacency particle forces, optimized default number of OpenMP threads, and constant calculation elimination.
  • memory_access: memory access optimization, that is, Large data dimension reduction and array dimension transposition.
  • communication: communication optimization, that is, communication hiding.

When you have selected the domain option for matricization optimization, select at least one domain-specific optimization method.

-l/--log-level

0/1/2/3

Log level, which defaults to 1. This parameter is optional.
  • 0: DEBUG
  • 1: INFO
  • 2: WARNING
  • 3: ERROR

--set-timeout

-

Timeout interval of a task, in minutes. If the execution duration exceeds the timeout interval, the task exits. This parameter is optional. By default, there is no timeout interval. The task will be executed until it is complete.

For details about SME-based matricization and domain-specific optimization technologies, see Matricization Check.

Example

In this example, the source code in the /home/test_code/data directory is scanned, the build tool is make, the build command is make, and the matricization optimization methods are sme and domain. Replace the example parameter values with the actual ones.

1
devkit advisor matrix-check -i /home/test_code/data -c make -b make -o /home/out/ -p domain,sme -m compute,memory_access,communication

The following information is displayed and a report is generated:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Scanned time: 2024/06/12 02:18:35
Configuration: 
    Scan source code path: /home/test_code/data
    Generate report path: /home/out
    Generate report type: all
    Task Timeout Interval: The timeout period is not set.
    Log level: info

Summary:
    Scanned 11 files, there are 50 suggestions.

For the details information, please check:
/home/out/matrix-check_20240612021835_2d68.html
/home/out/matrix-check_20240612021835_2d68.csv
After the project analysis is complete, additional optimization files are generated in /home/out/matrix-check_20240612021835_2d68
Download the optimization files and adapt the project build files.
Adapt the project build files to the FFT-SME library, which is located in /home/out/fftm.zip

Output Report

Table 2 Output report parameters

Parameter

Description

Configuration

Displays the software source file path.

Source File to Be Modified

Displays information such as the path to the source file that needs to be modified.