当前位置:网站首页>[play with Huawei cloud] take you through the Kunpeng code migration tool to realize source code migration

[play with Huawei cloud] take you through the Kunpeng code migration tool to realize source code migration

2022-06-10 22:57:00 Hua Weiyun

1. Introduction to source code migration

In the context of domestic substitution , Kunpeng computing platform is a very potential industry . In order to solve the problem that developers are x86 A series of pain points encountered in the process of platform application porting to Kunpeng platform , Huawei has launched the Kunpeng code migration tool (Porting Advisor), Help developers speed up the x86 Applications in the environment are migrated to the Kunpeng platform . This paper is based on the instrumental software migration experience of Huawei Kunpeng computing tool chain project team , The practical experience of Kunpeng code migration tool is summarized , It is expected to help developers understand how to use the tool , Improve the software migration efficiency of developers .

1.1 Introduction to source code migration

In the context of domestic substitution , Kunpeng computing platform is a very potential industry . In order to solve the problem that developers are x86 A series of pain points encountered in the process of platform application porting to Kunpeng platform , Huawei has launched the Kunpeng code migration tool (Porting Advisor)
Help developers speed up the x86 In the environment
Use to migrate to Kunpeng platform . This paper is based on the instrumental software migration experience of Huawei Kunpeng computing tool chain project team , It summarizes the practical application of Kunpeng code migration tool F Experience , It is expected to help developers understand how to use the tool , Improve the software migration efficiency of developers .

1.2 Tool features supported by the tool

image-20220609190637877

1.3 Introduction to source code migration

When users can provide source code for migration analysis , You can use the source code migration function to complete the migration. The source code migration function mainly solves the difficulty of manual troubleshooting of user code compatibility 、 Rely heavily on personal experience of migration 、 It is necessary to repeatedly rely on compilation to debug and locate errors, which leads to low execution efficiency . According to the different translation methods from source code to binary file , Code migration tools divide programming languages into two categories : One is compiled ,— Classes are interpretive .

Support source code types

image-20220609191229870

1.4 Migration process

image-20220609191459019

2. Practical project one

2.1 Prerequisite

1. The server and operating system are running normally .
2.Pc The end has been installed sSH Remote login tools .
3.Porting Advisor Already in preparation x86 Complete installation and normal operation in the platform environment and Kunpeng platform environment .4 Relevant software packages to be migrated 、 The source code is ready .

2.2 Relocation plan

1. utilize Porting Advisor The source code migration function of smartdenovo Source code scanning , Get its $o Library dependencies 、 Portability 、 Migration workload and other analysis results .
2 according to Porting Advisor From the analysis of source code migration function smartdenovo Dependency to prepare the corresponding sO library .
3. Check smartdenovo Source code analysis report of source code , Get the compile build file 、.h/.c And other source code files , And modify according to the modification suggestions .
4. Compile with the modified source code , Generate Kunpeng version smartdenovo Software .5. Use Kunpeng version smartdenovo Software deployment and simple validation .

image-20220609191853587

2.3 Open source software smartdenovo-master The actual battle of migration

step 1 from https://github.com/ruanjue/smartdenovo Download and obtain the software source code package to be used smartdenovo-
master.zip.
step 2︰ Get into Porting Advisor“ Source code migration ” Menu for scanning analysis . In the related configuration items and buttons that appear later , As shown in the figure 1 Strike “ Upload ”, Upload the previously downloaded smartdenovo-master.zip, And click the input box , Select the source package as "smartdenovo-master”. Several other options are selected according to our actual situation

image-20220609191902848

stay “ Suggestions for source code migration ” page , see Makefile Suggestions on modification of documents , Pictured 1 The migration proposal is shown in
According to the above suggestions ,Makefile The document needs to give CFLAGS Variable increase option inner Valley marcn=avo-a -iightea , i To delete CFLAGS Options in variables “-mpopcnt” and “-msse3". The modified code ( The modification was made x86_64 Branches and aarch64 Branch differentiation ), Pictured 2 The modified makefile Shown .

image-20220609192636707

stay “ Suggestions for source code migration ” page , see ksw.c Suggestions on modification of documents , Pictured 1 The migration proposal is shown in
These tips are all about intrinsic Function usage . Based on the advice provided , Need to increase the ‘#include 'avx2neon.h” To ksw.c To include avx2neon.h, And aim at x86 and aarch64 Set the branch definitions contained in the header file respectively , To ensure that the code fits at the same time x86 and arch64 Complete the code modification in the case of two architectures , Pictured 2 The code is modified as shown in . meanwhile , Need to download avx2neon Related header files to ksw.c In the directory . Due to avx2neon There are some directional open source functions in open source projects , When these open source functions appear in the code , It will appear as shown in the figure 1 Suggestions shown in the source code . here , Users need to access github Website through README.md To learn how to get the code files for these directed open source functions . After obtaining this part of the code header file , Place it in avx2neon.h In the directory .image-20220609193352636

At the completion of the right Makefilb and ksw.c After the modification of , You can download the whole modified source code to Kunpeng ring, as shown in the figure 1 List file information and figures 2 In the world , perform make clean && make command , Complete the compilation action ,make In the figure shown in the command smartdenovo-master Is the source code file we need to download .

image-20220609193411691

step 2︰ take smartdenovo-master After downloading to local , Clean up the local directory smartdenovo-master Tool generation in
In between Makefile.20210104220958.bak.0、ksw.c.20210104220958.bak.0.
step 3 Put the local directory smartdenovo-master Upload to Kunpeng server , Execute the compile and install actions . step 4Make After success , It can be executed make install Command execution installation , Check the installation results as shown in the figure 3 Shown

image-20220609193500069

3. Practical project II

image-20220609193532804

From the dependency library information provided in the scan report , The source package does not depend on the basic environment (OS The basic installation of the environment depends on , Such as GLIBC etc. ) Other dependent files besides .

image-20220609194106995

image-20220609194118706

image-20220609194521148

4. summary

In this software migration practice , Through the complete simulation of the software migration process , It covers the pre analysis of the migration process by using the code migration tool 、 Intermediate modification and late compilation 、 restructure 、 The process of verification . In the migration of other software , You can refer to the idea and operation process of this practice .

原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101620233928.html