我要评分
获取效率
正确性
完整性
易理解

Modifying the Source Code

  1. In the Source Files to Be Ported area of the report page, click View Suggested Source Code in the Operation column. See Figure 1.
    Figure 1 Viewing suggested source code
  2. Select a source file and go to the porting suggestions page.
    • VS Code
      Figure 2 Source code porting suggestions
    • WebUI
      Figure 3 Source code porting suggestions
  3. The porting report indicates that two files must be modified. On the Source Code Porting Suggestions page, check the modification suggestions for each file and modify the source code based on the suggestions.
    1. Select makefile. Based on the red wavy line, modify the Makefile.
    2. Select ksw.c. Based on the red wavy line, modify the ksw.c file.
    • VS Code: After modifying the code, press Ctrl+S to save the modification.
    • WebUI: After modifying the code, click Save.

Modifying the Makefile

On the Source Code Porting Suggestions page, view the suggestions for modifying the Makefile file. See the following figure:

  • VS Code
    Figure 4 Suggestions for porting the Makefile source code
  • WebUI
    Figure 5 Suggestions for porting the Makefile source code

For suggestion details, see the following figures:

  • VS Code
    Figure 6 Source code suggestion 1
    Figure 7 Source code suggestion 2
  • WebUI
    Figure 8 Source code suggestion 1
    Figure 9 Source code suggestion 2

According to the preceding suggestions, add the -march=armv8.2-a -fsigned-char option to the CFLAGS variable in the makefile, and delete the -mpopcnt and -msse3 options of the CFLAGS variable. After obtaining and installing the Kunpeng System Library (BoostKit-ksl_2.3.1.zip), add -I /usr/local/ksl/include/ -L /usr/local/ksl/lib/ -lavx2ki to the GLIBS variable.

In this example, the compiler is GCC 4.8.5. For a later version, the -march=armv8.2-a -fsigned-char option needs to be modified as prompted.

The following figures show the updated code (x86_64 and AArch64 are distinguished from each other).

  • VS Code
    Figure 10 Updated Makefile
  • WebUI
    Figure 11 Updated Makefile

Modifying the ksw.c File

On the Source Code Porting Suggestions page, view the suggestions for modifying the ksw.c file. See the following figures:

  • VS Code
    Figure 12 Suggestions for porting the ksw.c file
    Figure 13 Source code suggestion
  • WebUI
    Figure 14 Suggestions for porting the ksw.c file
    Figure 15 Source code suggestion

The suggestion is about how to use the intrinsic function. According to the suggestion, click Quick Fix and add #include "avx2ki.h" to the ksw.c file. Set the branch definitions contained in the header files for x86 and AArch64. This ensures that the code is adapted to both x86 and AArch64. The following information is displayed (using GCC 4.8.5 as an example):

1    #if defined(__aarch64__)
2       #include "avx2ki.h"
3    #endif
...
31   #if defined(__x86_64__)
32      #include <emmintrin.h>
33   #endif

When the suggestion shown in Figure 15 or Figure 13 is displayed, you need to visit the corresponding website to obtain the corresponding files and perform operations according to the suggestion.