An algorithm adaptation device supporting different hardware platforms and an algorithm library adaptation method
Through the data type naming and interface function unified module of the algorithm adapter device, the problem of non-universal information processing methods of different hardware platforms is solved, and the algorithm library adaptation and information processing are realized among hardware platforms is generalized.
Patent Information
- Application Number
- CN202210606427.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2042-05-31
AI Technical Summary
The information processing methods of different hardware platforms in the prior art cannot be generalized, resulting in the need to redesign or adaptively adjust the information processing methods, which are time-consuming and requires professional personnel.
An algorithm adaptation device is provided, including a data type naming module, a header file unified module and an adaptation module. Through the unified data type name and interface function header file flag, the unified interface function is called, and the algorithm library to be adapted is connected to the target hardware platform.
It realizes algorithm library adaptation between different hardware platforms, simplifies the generalization of information processing methods, and reduces the time and professional requirements for design and adjustment.
Smart Images

Figure CN114970534B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to an algorithm adaptation device and an algorithm library adaptation method supporting different hardware platforms. Background Art
[0002] At present, the information processing of software-based radar is in a period of vigorous development. Many manufacturers design the information processing methods of software-based radar according to the hardware platforms they use. When the hardware platforms used are different, the information processing methods are often not universal.
[0003] At present, the hardware platforms for information processing methods are different, and it is often necessary to redesign the information processing methods of new hardware platforms, or to adaptively adjust the original information processing methods to meet the use of different hardware platforms.
[0004] However, redesigning the information processing method for the new hardware platform takes a lot of time and requires experienced staff to handle it, while adaptively adjusting the original information processing method also requires certain professionalism of the staff. Therefore, there is an urgent need for a method that can meet the information processing needs of different hardware platforms. Summary of the invention
[0005] In view of this, it is necessary to provide an algorithm adaptation device and an adaptation method that support different hardware platforms, so as to solve the problem in the prior art that information processing on different hardware processing platforms cannot be universal.
[0006] In order to achieve the above technical objectives, the present invention adopts the following technical solutions:
[0007] In a first aspect, the present invention provides an algorithm adaptation device supporting different hardware platforms, which is applied to the adaptation of a first hardware platform algorithm library and a second hardware platform algorithm library. The algorithm adaptation device includes a data type naming module, a header file unification module, and an adaptation module:
[0008] A data type naming module, used to uniformly name data in the to-be-adapted algorithm library of the first hardware platform that have the same data structure type as that in the target algorithm library of the second hardware platform;
[0009] A header file unification module, used to unify the header files of the interface functions with the same functions of the first hardware platform and the second hardware platform;
[0010] The adaptation module is used to call the interface function with unified flags to connect the algorithm library to be adapted to the second hardware platform to adapt the target algorithm library.
[0011] Preferably, the data type naming module includes a same type determination module and a unified naming module;
[0012] A same type determination module, used to determine data of the same data structure type in the to-be-adapted algorithm library of the first hardware platform and in the target algorithm library of the second hardware platform;
[0013] The unified naming module is used to uniformly name data of the same data structure type according to preset rules.
[0014] Preferably, the header file unification module includes a header file flag determination module and an interface function naming module;
[0015] A header file flag determination module, used to determine the header file of the interface function in the to-be-adapted algorithm library of the first hardware platform and the target algorithm library of the second hardware platform having the same function;
[0016] The interface function naming module is used to uniformly name interface functions with the same functions starting with a preset name.
[0017] Preferably, the adaptation module includes an interface function determination module and a data conversion module;
[0018] An interface function determination module, used to determine the type of interface function to be called according to the algorithm library to be adapted of the first hardware platform;
[0019] The data conversion module is used to call the interface function to be called and convert the data to be processed into the data of the target algorithm library of the second hardware platform.
[0020] Preferably, the interface function determination module also includes an interface function parameter determination module; the interface function parameter determination module is used to determine the parameter type of the interface function to be called according to the type of the interface function to be called.
[0021] Preferably, the data conversion module also includes a conversion judgment module; the conversion judgment module is used to generate a conversion return value according to the result of the conversion of the data to be processed.
[0022] Preferably, the interface function includes a memory management function; the memory management function is used to allocate memory space for the data to be processed.
[0023] Preferably, the memory management function includes a memory application function and an application judgment function;
[0024] A memory application function, used to determine the size of the memory space to be applied for according to the parameters of the first hardware platform, and to apply for the memory space to be allocated accordingly;
[0025] The application judgment function is used to generate an application return value based on whether the application for the memory space to be allocated is successful.
[0026] Preferably, it also includes an initialization module; the initialization module is used to initialize the environment of the algorithm adaptation device and set the execution mode of the thread.
[0027] In a second aspect, the present invention further provides an adaptation method supporting different hardware platforms, based on the algorithm adaptation device supporting different hardware platforms as described above, comprising:
[0028] The data names in the to-be-adapted algorithm library of the first hardware platform and the data structure types in the target algorithm library of the second hardware platform are uniformly named by the data type naming module;
[0029] Unifying the header files of the interface functions with the same functions of the first hardware platform and the second hardware platform through the header file unification module;
[0030] The algorithm library to be adapted is connected to the second hardware platform by calling the interface function with unified flags through the adaptation module to adapt the target algorithm library.
[0031] The beneficial effect of adopting the above-mentioned embodiment is: an algorithm adaptation device supporting different hardware platforms provided by the present invention unifies the names of data structure types of different hardware platforms through a data type naming module, and unifies the symbols of interface functions of different hardware platforms through a header file unification module, so that the same data structure type in the algorithm library of different hardware platforms can be identified, and the corresponding interface function can be called to adapt the same type of data structure type of different hardware platforms, thereby realizing information processing of different hardware platforms.
[0032] Furthermore, the present invention provides an adaptation method for an algorithm adaptation device supporting different hardware platforms, which unifies the data structure type names and header files in different hardware platforms, converts data by calling interface functions through an adaptation module, and realizes information processing of different hardware platforms. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A schematic diagram of the structure of an embodiment of an algorithm adaptation device supporting different hardware platforms provided by the present invention;
[0034] Figure 2 A flowchart of an embodiment of an adaptation method supporting different hardware platforms provided by the present invention. DETAILED DESCRIPTION
[0035] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0036] In the description of the present application, “plurality” means two or more than two, unless otherwise clearly and specifically defined.
[0037] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0038] The present invention provides an algorithm adaptation device and an adaptation method supporting different hardware platforms, which are respectively described below.
[0039] See also Figure 1 , Figure 1 A schematic diagram of the structure of an embodiment of an algorithm adaptation device supporting different hardware platforms provided by the present invention. A specific embodiment of the present invention discloses an algorithm adaptation device 10 supporting different hardware platforms, which is applied to the adaptation of the algorithm library of the first hardware platform and the second hardware platform. The algorithm adaptation device 10 includes a data type naming module 101, a header file unification module 102 and an adaptation module 103:
[0040] The data type naming module 101 is used to uniformly name the data names in the to-be-adapted algorithm library of the first hardware platform that have the same data structure type as that in the target algorithm library of the second hardware platform;
[0041] The header file unification module 102 is used to unify the header files of the interface functions with the same functions of the first hardware platform and the second hardware platform;
[0042] The adaptation module 103 is used to call the interface function with unified flags to connect the algorithm library to be adapted to the second hardware platform to adapt the target algorithm library.
[0043] In the above embodiment, the algorithm adaptation device 10 established by the present invention is also connected to the interface 20, wherein the interface 20 is used to connect to two different hardware platforms and can be used as an input of data of one hardware platform or an output of data of another hardware platform.
[0044] It is understandable that the embodiment of the present invention adapts the first hardware platform algorithm library to the second hardware platform algorithm library, and in actual use, the second hardware platform algorithm library can also be adapted to the first hardware platform algorithm library. In addition, the embodiment of the present invention can also add several hardware platform algorithm libraries for adaptation conversion, and there is no limit on the number of hardware platform algorithm libraries, and the adaptation conversion process is not unidirectional, but bidirectional.
[0045] It should be noted that in the algorithm libraries of different hardware platforms, the names of the header files for the same type of data and interface functions are different. When a program under a certain hardware platform is run directly through another platform, the data type and interface function cannot be recognized. However, when the two use the same data type name and header file name, the description of the header file for the same data type and interface function is consistent, then it can be determined that the processed objects and processing methods are the same, so the two can be converted to each other.
[0046] Compared with the prior art, this embodiment provides an algorithm adaptation device 10 that supports different hardware platforms. The algorithm adaptation device 10 is established, and the data structure type names of different hardware platforms are unified through the data type naming module 101. The symbols of the interface functions of different hardware platforms are unified through the header file unification module 102, so that the same data structure type in the algorithm library of different hardware platforms can be identified, and the corresponding interface function can be called to adapt the same type of data structure type of different hardware platforms, thereby realizing information processing of different hardware platforms.
[0047] In some embodiments of the present invention, the data type naming module includes a same type determination module and a unified naming module;
[0048] A same type determination module, used to determine data of the same data structure type in the to-be-adapted algorithm library of the first hardware platform and in the target algorithm library of the second hardware platform;
[0049] The unified naming module is used to uniformly name data of the same data structure type according to preset rules.
[0050] In the above embodiment, the data type naming module first determines the data with the same data structure type in the algorithm library to be adapted of the first hardware platform and the target algorithm library of the second hardware platform through the same type determination module, and then the unified naming module uniformly names the data with the same data structure type according to the preset rules. Among them, the preset rules are the naming methods of the same data type names that are determined in advance, which can be adjusted according to the actual situation, and the present invention does not make further restrictions here.
[0051] In some embodiments of the present invention, the header file unification module includes a header file flag determination module and an interface function naming module;
[0052] A header file flag determination module, used to determine the header file of the interface function in the to-be-adapted algorithm library of the first hardware platform and the target algorithm library of the second hardware platform having the same function;
[0053] The interface function naming module is used to uniformly name the header files of interface functions with the same functions starting with a preset name.
[0054] In the above embodiment, the header file unification module first determines the header file of the interface function with the same function in the algorithm library to be adapted of the first hardware platform and the target algorithm library of the second hardware platform through the header file flag determination module, and then the interface function naming module uniformly names the interface functions with the same function starting with a preset name. Among them, the preset name beginning is the beginning of the name of the header file of the interface function with the same function that has been determined in advance, which can be adjusted according to the actual situation, and the present invention does not make further restrictions here. There is also a character identifier at the end of the interface function name, and the type and precision of the current data are identified according to the end character identifier of the interface function.
[0055] In some embodiments of the present invention, the adaptation module includes an interface function determination module and a data conversion module;
[0056] An interface function determination module, used to determine the type of interface function to be called according to the algorithm library to be adapted of the first hardware platform;
[0057] The data conversion module is used to call the interface function to be called and convert the data to be processed into the data of the target algorithm library of the second hardware platform.
[0058] In the above embodiment, the data to be processed in the algorithm library of the first hardware platform is input into the adaptation module in the algorithm adaptation device 10, the interface function to be called is determined by the interface function determination module, the data conversion module calls the corresponding interface function in the algorithm adaptation device 10, converts the data to be processed, and stores the processed data in the applied memory space to obtain the data of the second hardware platform, and finally completes the adaptation conversion.
[0059] In some embodiments of the present invention, the interface function determination module further includes an interface function parameter determination module; the interface function parameter determination module is used to determine the parameter type of the interface function to be called according to the type of the interface function to be called.
[0060] In the above embodiment, the parameters input by different interface functions are different, and the call of the interface function can be realized according to the input parameters. When the algorithm adaptation device 10 interface is used for calculation, the algorithm library of the hardware platform has been determined before, and it is only necessary to select the type of interface function from the algorithm library, and then input the data to be processed into the algorithm adaptation device 10 according to the parameter type prompted by the interface. After adaptation and conversion by the adaptation module 103, the adaptation data of the target hardware platform is finally obtained.
[0061] It should be noted that the interface functions mainly include the following six categories:
[0062] Memory management: including memory allocation and release on different platforms. Confirm the allocated data alignment length and allocated space size.
[0063] System environment initialization: including setting the number of runtime threads of the current environment.
[0064] Vector operations: modulus, sum, difference, product, conjugate multiplication, dot multiplication.
[0065] Matrix operations: matrix multiplication, matrix conjugate multiplication, matrix inversion.
[0066] Basic data operations: data type conversion, db to mag.
[0067] Signal processing operations: FFT forward operation, FFT reverse operation. FFT mainly consists of three stages: creation, operation, and destruction.
[0068] In some embodiments of the present invention, the data conversion module further includes a conversion judgment module; the conversion judgment module is used to generate a conversion return value according to the result of the conversion of the data to be processed.
[0069] In the above embodiment, the algorithm adaptation device 10 performs adaptation conversion. If the interface function has a return value after the adaptation conversion, there are two main types of return values, and the conversion judgment module is used to judge whether the conversion is successful. The first type is that if the function return value is a pointer, if the function return value is a null pointer, it means that the execution failed, such as the memory allocation function Srdar_malloc, if the function return value is NULL, it means that the application for memory allocation failed. The second type is that the function return value is an integer value, if the function return value is 0, it means that the execution is successful, and if the function return value is other values other than 0, it means that the execution is wrong, such as the matrix inverse function Srdar_pinv.
[0070] In some embodiments of the present invention, the interface function includes a memory management function; the memory management function is used to allocate memory space for data to be processed.
[0071] In the above embodiment, when adapting data of different hardware platforms, the user calls the memory adaptation function in advance to allocate memory space for the data to be processed, which is used to store the data to be processed after the adaptation and conversion. The memory space needs to be applied for, and the size of the memory space is related to the type of data.
[0072] In some embodiments of the present invention, the memory management function includes a memory application function and an application determination function;
[0073] A memory application function, used to determine the size of the memory space to be applied for according to the parameters of the first hardware platform, and to apply for the memory space to be allocated accordingly;
[0074] The application judgment function is used to generate an application return value based on whether the application for the memory space to be allocated is successful.
[0075] In the above embodiment, before using the front interface function, the user calls the memory application adapter function in advance to provide a unified memory space for the data involved in the interface operation. The memory management functions used in the algorithm libraries of two different hardware platforms are different. For the memory application function, three parameters need to be set in MKL, the number of elements in the application space, the element size, and the minimum number of memory alignment bytes. For the openblas interface, it is only necessary to inform the total size of the application memory space, and the alignment size is not set in the application memory function interface. The parameters reflect the difference between the memory management functions of different hardware platforms. When allocating memory space, the specific parameters of the memory management function are first determined according to the unified adapter function interface in the function database. After obtaining a memory block of a preset size, the user decides what type of data to store in the memory block and its purpose.
[0076] In some embodiments of the present invention, an initialization module is further included; the initialization module is used to initialize the environment of the algorithm adaptation device and set the execution mode of the thread.
[0077] In the above embodiment, the environment of the algorithm adapter device 10 is initialized, and the initialization function is init_set_num_threads. Before executing any mathematical operation in the interface of the algorithm adapter device 10, it is necessary to call the function init_set_num_threads to initialize the environment. For the openblas environment, it is necessary to set the number of core operations of the internal function in advance. Here, each internal function executed uses a single thread. For the mkl environment, multi-threading within the function is implemented based on OpenMP, and an interface is provided to set the number of threads to execute the function. OpenMP programming is not recommended here. The calculation functions of the algorithm adapter device 10 are all thread-safe, and the multi-threaded execution algorithm interface is implemented by the user himself, and the algorithm interface is executed by a single thread.
[0078] See also Figure 2 , Figure 2 The present invention is a flowchart of an embodiment of an adaptation method for supporting different hardware platforms provided by the present invention. The present invention also provides an adaptation method for algorithm libraries supporting different hardware platforms, based on the algorithm adaptation device 10 supporting different hardware platforms as described above, comprising:
[0079] S201, uniformly naming the data names in the to-be-adapted algorithm library of the first hardware platform that have the same data structure type as the data names in the target algorithm library of the second hardware platform through a data type naming module;
[0080] S202, unifying the header files of the interface functions with the same functions of the first hardware platform and the second hardware platform through a header file unification module;
[0081] S203 , the adaptation module calls the interface function with unified flags to connect the algorithm library to be adapted to the second hardware platform, so as to adapt the target algorithm library.
[0082] In an embodiment of the present invention, step S201 unifies the data names of data structure types in algorithm libraries of different hardware platforms through a data type naming module. After unified naming, even if the data names of data structure types in the algorithm library of the original hardware platform are different, the same data structure types can be identified and adapted and converted.
[0083] In an embodiment of the present invention, step S202 unifies the naming marks of the header files of the interface functions in the algorithm libraries of different hardware platforms through the header file unification module. After the marks are unified, the interface functions with the same functions can be used in the algorithm libraries of different hardware platforms. The marks have a beginning mark and an ending identifier, which can identify the function of the interface function.
[0084] In the embodiment of the present invention, after the data names of the data structure types are uniformly named and the naming marks of the header files of the interface functions are unified in step S203, the adaptation module can smoothly carry out the adaptation conversion process. The data to be processed is input into the algorithm adaptation device 10, and the corresponding interface function in the algorithm adaptation device 10 is called to convert the data to be processed. The converted data is the data type corresponding to the algorithm of the current hardware platform. The converted data is input as the parameter of the function. The unified function interface of the two hardware platforms is obtained through step S202. Finally, the corresponding algorithm library is selected according to the hardware platform in S203 to complete the platform adaptation.
[0085] A specific embodiment provided by the present invention is described by taking the ARM hardware platform and the X86 hardware platform as examples:
[0086] The environment of the algorithm adaptation device 10 is initialized through the initialization function init_set_num_threads. The calculation functions of the algorithm adaptation device 10 are all thread-safe. Then the user implements the multi-threaded execution algorithm interface by himself, and the algorithm interface is executed by a single thread. Initialization requires setting the number of core operations of the internal function and the number of threads of the execution function. After that, it is necessary to apply for memory space according to the type of data to be processed, adapt and convert the data to be processed through the interface function, and store the data after conversion in the applied memory space, so as to achieve the adaptation and conversion of data on different hardware platforms.
[0087] Since the function algorithm libraries used by the ARM hardware platform and the X86 hardware platform are different, it is necessary to select the appropriate function algorithm libraries for the ARM hardware platform and the X86 hardware platform. If the processor architecture is X86, select the library functions related to Intel MKL. If the processor architecture is ARM, select the openblas, fftw and other function libraries in this environment. fftw is a single-threaded library that supports single precision. Selection of macro definitions: For environments using MKL, it is necessary to determine the non-floating-point data type model, including LP64, LLP64, and ILP64. This affects the size of the data object and the boundary alignment. For environments that select openblas, it is necessary to determine the complex structure type, including LAPACK_COMPLEX_STRUCTURE, LAPACK_COMPLEX_C99, LAPACK_COMPLEX_CPP, and LAPACK_COMPLEX_CUSTOM.
[0088] Please refer to Table 1, which is a naming rule table of an embodiment of the data structure type naming rule provided by the present invention. Under the ARM and X86 hardware platforms, the name descriptions of the same type of data used by the library function are different, and a unified and friendly data type name needs to be provided externally. The data structure types under different platforms are set to have a unified name externally, and during the adaptation process of the algorithm adaptation device 10, adaptation errors caused by different hardware platforms can be avoided. It can be understood that the unified name externally embodied is only used in the adaptation process. After the data of different hardware platforms are adapted, their specific names under different hardware platforms can be identified.
[0089] Table 1
[0090]
[0091] The interface functions of the ARM hardware platform and the X86 hardware platform also need to be unified, and here it is only necessary to set a unified identification identifier for the different interface functions. The function interface of the algorithm adapter device 10 all starts with Srdar, and the last character of the function identifies the current data type and precision. _c represents a single-precision complex number, and _z represents a double-precision complex number. For example, Srdar_malloc allocates memory, and Srdar_free releases memory space. Srdar_get_A_mul_B_z represents the multiplication of two double-precision complex matrices.
[0092] Determine the memory parameters of the data to be processed according to the hardware platform environment of the data to be processed;
[0093] The memory parameters of the data to be processed are input into the preset memory function to obtain the memory space of the data to be processed.
[0094] The memory parameters of the data to be processed are input into the preset memory function to obtain the memory space of the data to be processed. If the preset memory function configures the memory space successfully, a preset memory space configuration success pointer is returned.
[0095] It is necessary to shield the differences that may be caused by inconsistent interfaces. The return type for successful application is , that is, a pointer of type void pointing to the requested memory block. Based on the returned type, it can be determined whether the interface has successfully obtained the memory space, so as to avoid not reserving memory space to store the data after the adaptation when adapting data of different hardware platforms.
[0096] According to the ARM hardware platform and X86 hardware platform environment after the data to be processed is initialized, the data to be processed is converted and processed by the algorithm adaptation device 10 to obtain the data of the target hardware platform, including:
[0097] Determine the type of interface function to be called by the algorithm adaptation device 10 according to the hardware platform environment of the data to be processed;
[0098] Determine the parameter type of the interface function according to the interface function type of the algorithm adaptation device 10;
[0099] The parameter type of the interface function corresponding to the data to be processed is input into the interface function to obtain the data of the target hardware platform.
[0100] When using the algorithm adapter 10 interface to perform calculations, the function database of the hardware platform has been determined before. It is only necessary to select the type of interface function from the function database, and then pass in the corresponding type of variable according to the parameter type prompted by the interface, and judge whether the memory space is successfully allocated. When the memory block to be passed in is a pointer, the input data type of the parameter is The data to be processed is input into the algorithm adaptation device 10 according to the parameter type prompted by the interface, and after being adapted and converted by the adaptation module 103, the adaptation data of the target hardware platform is finally obtained.
[0101] According to the hardware platform environment of the data to be processed, the type of the interface function to be called by the algorithm adaptation device 10 is determined, including:
[0102] If the function database used by the environment type of the hardware platform contains the type of the interface function to be called, the interface function to be called is called from the function database;
[0103] If the function database used by the environment type of the hardware platform does not include the interface function type to be called, the interface function to be called is configured according to the data type and data alignment mode of the function database corresponding to the environment type of the hardware platform.
[0104] Determine whether the function database used contains the type of the interface function to be called. For pointer parameters, users must ensure the validity of the input parameters themselves and cannot pass in null pointers. Secondly, users do not need to pay attention to the specific type of data used by the math function library in the current platform. Use a unified Type pointer identification. In the specific implementation of the function, the function interface used is distinguished according to the current specific platform. If it is available in the basic function library, the algorithm in the basic function library is directly called. If not, the algorithm is implemented for the data type and data alignment of the corresponding function library in the current platform.
[0105] Finally, after the algorithm adaptation device 10 converts the data to be processed and obtains the data of the target hardware platform, it is also necessary to determine the conversion return value, including:
[0106] If there is a return value, determine the type of the return value;
[0107] When the return value is a pointer, determine whether the return value is a null pointer. If the return value is a null pointer, it means the execution failed; if the return value is not a null pointer, it means the execution succeeded.
[0108] When the return value is an integer, determine whether the return value is zero. If the return value is zero, it means the execution is successful; if the return value is not zero, it means an execution error.
[0109] In summary, the present invention provides an algorithm adaptation device 10 and an adaptation method that support different hardware platforms. The algorithm adaptation device 10 is established, and the data structure type names of different hardware platforms are uniformly named through the data type naming module 101. The symbols of the interface functions of different hardware platforms are unified through the interface function unification module 102, so that the same data structure type in the algorithm library of different hardware platforms can be identified, and the corresponding interface function can be called to adapt the same type of data structure type of different hardware platforms, thereby realizing information processing of different hardware platforms.
[0110] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. An algorithm adaptation device supporting different hardware platforms, applied to the adaptation of the algorithm library of a first hardware platform and the algorithm library of a second hardware platform, characterized in that: The algorithm adaptation device includes a data type naming module, a header file unification module and an adaptation module; The data type naming module is used to uniformly name the data names in the to-be-adapted algorithm library of the first hardware platform that have the same data structure type as that in the target algorithm library of the second hardware platform; The header file unification module is used to unify the header files of the interface functions with the same functions as those of the first hardware platform and the second hardware platform; The adaptation module is used to call the interface function after the flag is unified to connect the algorithm library to be adapted to the second hardware platform to adapt the target algorithm library; Wherein, the header file unification module includes a header file flag determination module and an interface function naming module; The header file flag determination module is used to determine the header file of the interface function in the to-be-adapted algorithm library of the first hardware platform and the target algorithm library of the second hardware platform having the same function; The interface function naming module is used to uniformly name the header files of the interface functions with the same functions starting with a preset name, and to set a character identifier at the end of the interface function name, wherein the character identifier is used to identify the type and precision of the current data.
2. The algorithm adaptation device supporting different hardware platforms according to claim 1, characterized in that: The data type naming module includes a same type determination module and a unified naming module; The same type determination module is used to determine data of the same data structure type in the to-be-adapted algorithm library of the first hardware platform and in the target algorithm library of the second hardware platform; The unified naming module is used to uniformly name the data with the same data structure type according to preset rules.
3. The algorithm adaptation device supporting different hardware platforms according to claim 1, characterized in that: The adaptation module includes an interface function determination module and a data conversion module; The interface function determination module is used to determine the type of interface function to be called according to the algorithm library to be adapted of the first hardware platform; The data conversion module is used to call the interface function to be called to convert the data to be processed into data of the target algorithm library of the second hardware platform.
4. The algorithm adaptation device supporting different hardware platforms according to claim 3, characterized in that: The interface function determination module also includes an interface function parameter determination module; The interface function parameter determination module is used to determine the parameter type of the interface function to be called according to the type of the interface function to be called.
5. The algorithm adaptation device supporting different hardware platforms according to claim 3, characterized in that: The data conversion module also includes a conversion judgment module; The conversion judgment module is used to generate a conversion return value according to the result of the conversion of the data to be processed.
6. The algorithm adaptation device supporting different hardware platforms according to claim 1, characterized in that: The interface function includes a memory management function; The memory management function is used to allocate memory space for the data to be processed.
7. The algorithm adaptation device supporting different hardware platforms according to claim 6, characterized in that: The memory management function includes a memory application function and an application judgment function; The memory application function is used to determine the size of the memory space to be applied for and the data alignment rule according to the parameters of the first hardware platform, and to apply for the memory space to be allocated accordingly; The application judgment function is used to generate an application return value according to the result of whether the application for the memory space to be allocated is successful.
8. The algorithm adaptation device supporting different hardware platforms according to claim 1, characterized in that: It also includes an initialization module; the initialization module is used to initialize the environment of the algorithm adaptation device and set the execution mode of the thread.
9. An adaptation method for supporting algorithm libraries of different hardware platforms, based on the algorithm adaptation device supporting different hardware platforms as described in any one of claims 1 to 8, characterized in that: include: The data type naming module uniformly names the data in the to-be-adapted algorithm library of the first hardware platform that have the same data structure type as the data in the target algorithm library of the second hardware platform; Unifying the header files of the interface functions with the same functions as those of the first hardware platform and the second hardware platform through the header file unification module; By calling the unified header file, the current running hardware platform is automatically identified, and the algorithm library on the corresponding hardware platform is executed to complete the adaptation; The step of unifying the header files of the interface functions with the same functions as those of the first hardware platform and the second hardware platform by using the header file unification module includes: Determine a header file of an interface function in the algorithm library to be adapted of the first hardware platform and in the target algorithm library of the second hardware platform having the same function; The header files of the interface functions with the same functions are uniformly named starting with a preset name, and a character identifier is set at the end of the interface function name, and the character identifier is used to identify the type and precision of the current data.
Citation Information
Patent Citations
Computing middleware-based radar signal processing module library construction method and application thereof
CN103019744A