Rate This Document
Findability
Accuracy
Completeness
Readability

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. See Figure 2.
    Figure 2 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.

    After the modification is complete, click Save in the upper right corner to save the file.

Modifying the Makefile

On the Source Code Porting Suggestions page, view the suggestions for modifying the Makefile. See Figure 3.

Figure 3 Suggestions for porting the Makefile source code

Figure 4 and Figure 5 show the suggestions.

Figure 4 Source code suggestion 1
Figure 5 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.

Figure 6 shows the new code (x86_64 and AArch64 are distinguished from each other).

Figure 6 Updated Makefile

Modifying the ksw.c File

On the Source Code Porting Suggestions page, view the suggestions for modifying the ksw.c file. See Figure 7 and Figure 8.

Figure 7 Suggestions for porting the ksw.c file
Figure 8 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 8 is displayed, you need to visit the corresponding website to obtain the corresponding files and perform operations according to the suggestion.