A software stack compatibility method, device, storage medium and program product
By calling the header files of the target software stack and performing macro substitution during the compilation process, the compilation error caused by the private permissions of the CUDA software stack header files was resolved, achieving efficient operation and correct compilation of CPU code on domestic GPUs and avoiding namespace conflicts.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI BIREN TECH CO LTD
- Filing Date
- 2026-03-30
- Publication Date
- 2026-06-26
AI Technical Summary
The header files of the CUDA software stack have private permissions and do not support the definition and transformation of the CUDA API in the header files, which leads to compilation errors.
By obtaining the original program code, the header files defined in the target software stack are called during the compilation process, and the native interface is transformed into the interface defined in the target software stack through macro substitution, thus avoiding the calling of the native software stack's header files and ensuring the correctness of the compilation process.
It enables CPU-written program code to run efficiently on domestically produced GPUs, avoiding namespace pollution issues and simplifying the compilation process.
Smart Images

Figure CN122285010A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence chip technology, and in particular to a software stack compatible method, device, storage medium and program product. Background Technology
[0002] CUDA (Compute Unified Device Architecture), as a general-purpose computing architecture for graphics processing units (GPUs), establishes a mapping between central processing unit (CPU) tasks and GPUs. In other words, the CUDA software stack allows CPU-written program code (i.e., CUDA code) to run efficiently on the GPU. If domestically produced GPUs need to efficiently run CPU-written program code, they need to be compatible with the CUDA software stack.
[0003] In related technologies, to ensure compatibility with the CUDA software stack, a backend implementation of a domestic software stack is typically added on top of the CUDA software stack. During the compilation of CUDA code, the header files of the CUDA software stack are loaded first, and then the CUDA Application Programming Interface (API) in the header files is converted into the API under the domestic software stack.
[0004] However, the header files of the CUDA software stack have private permissions and do not support the definition and transformation of the CUDA API in the header files, which leads to compilation errors. Summary of the Invention
[0005] This invention provides a software stack compatibility method, device, storage medium, and program product to solve the problem that the CUDA software stack header files cannot be defined and converted due to private permissions, which leads to compilation errors.
[0006] On one hand, embodiments of this application provide a software stack compatibility method, the method comprising: Obtain the original program code; During the compilation of the original program code, the first header file defined in the target software stack is called. The first header file has the same name as the second header file in the native software stack. The first header file is used to include the target header file in the target software stack. Each native interface in the target header file is converted into a target interface defined by the target software stack, wherein the native interface is an interface defined by the native software stack.
[0007] On one hand, embodiments of this application provide a software stack compatible device, the device comprising: The acquisition module is used to acquire the original program code; The calling module is used to call a first header file defined in the target software stack during the compilation process of the original program code. The first header file has the same name as the second header file in the native software stack. The first header file is used to import the target header file in the target software stack. The conversion module is used to convert each native interface in the target header file into a target interface defined by the target software stack, wherein the native interface is an interface defined by the native software stack.
[0008] Optionally, the conversion module is specifically used for: The native interfaces in the target header file are transformed into target interfaces defined by the target software stack through macro substitution.
[0009] Optionally, the conversion module is further configured to: During the compilation of the original program code, each native interface in the original program code is transformed into the target interface defined by the target software stack through macro substitution.
[0010] Optionally, the target header file includes: sub-header files that define the various data types under the target software stack.
[0011] Optionally, the calling module is specifically used for: During the compilation of the original program code, if the compatibility control switch of the compiler executing the compilation process is turned on, the first header file defined in the target software stack is called.
[0012] Optionally, the calling module is further configured to: During the compilation of the original program code, if the compiler's compatibility control switch is off, the second header file in the native software stack is called.
[0013] Optionally, the native software stack is a CUDA software stack; the target header file includes: each native interface in the second header file.
[0014] On one hand, embodiments of this application provide a computer device, including: Memory, used to store program instructions; An artificial intelligence chip is used to run program instructions stored in the memory and execute the steps of the above-described software stack compatible method according to the obtained program.
[0015] On one hand, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a computer device, which, when run on a computer device, causes the computer to perform the steps of the above-described software stack compatible method.
[0016] On one hand, embodiments of this application provide a computer program product, including a computer program stored on a computer-readable storage medium, the computer program including program instructions, which, when executed by a computer device, cause the computer device to perform the steps of the above-described software stack compatible method.
[0017] In this embodiment, firstly, the user's original program code is obtained. During the compilation of the original program code, the first header file defined in the target software stack is called. The first header file has the same name as the second header file in the native software stack to ensure compatibility with the native software stack. At the same time, the target header file in the target software stack is introduced through the first header file. That is, the second header file in the native software stack is no longer called during the compilation process, but the target header file in the target software stack is called. The target header file in the target software stack is not restricted by the private permissions of the native software stack. In this way, the native interfaces in the target header file can be directly converted into target interfaces defined by the target software stack. The native interfaces are the interfaces defined by the native software stack, thereby ensuring the correctness of compilation and enabling the program code written by the CPU to run efficiently on the domestic GPU (corresponding to the target software stack).
[0018] Secondly, this application no longer calls the second header file in the native software stack, that is, it no longer imports the native software stack. In this way, the definition of related structures or APIs in the target software stack will no longer conflict with the definition of structures or APIs in the native software stack, effectively avoiding the problem of namespace pollution in the target software stack. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of a chip architecture provided in an embodiment of this application; Figure 2 A flowchart illustrating a software stack compatibility method provided in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of a software stack compatible device provided in an embodiment of this application; Figure 4 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0021] To make the objectives, technical solutions, and beneficial effects of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.
[0022] refer to Figure 1 This is a structural diagram of an artificial intelligence chip applicable to the embodiments of this application. The artificial intelligence chip 100 includes at least: video memory 101, computing unit 102, and thread scheduler 103. This application does not specifically limit the number of video memory 101, computing unit 102, and thread scheduler 103.
[0023] The computing unit 102 can be a streaming processing cluster (SPC). The computing unit 102 includes an on-chip cache 104.
[0024] Video memory 101 can be high-bandwidth memory (HBM) or other types of memory. On-chip cache 104 is a temporary memory with a smaller capacity than video memory 101, but a faster data exchange speed. On-chip cache 104 can be a general-purpose matrix main buffer (GMB) or other types of memory.
[0025] During the compilation phase, the native software stack (such as the CUDA software stack) is no longer introduced; instead, only the target software stack (such as a domestically developed software stack) is used. Specifically, the CPU compiler calls the first header file defined in the target software stack according to the original program code. The first header file has the same name as the second header file in the native software stack to ensure compatibility with the native software stack. At the same time, the first header file is used to import the target header files in the target software stack. This allows the native interfaces in the target header files to be converted into target interfaces defined in the target software stack, thus no longer being restricted by the private permissions of the native software stack and ensuring the accuracy of compilation. Since the native software stack is no longer introduced, and only the target software stack is retained, the definitions of related structures or APIs in the target software stack no longer conflict with the definitions of structures or APIs in the native software stack, effectively avoiding the namespace pollution problem in the target software stack.
[0026] During the runtime phase, the central processing unit loads the kernel function instructions corresponding to the original program code obtained from compilation into memory, and calls the driver interface of the target software stack to copy the kernel function instructions into the video memory 101 of the artificial intelligence chip. The thread scheduler 103 receives the "execute kernel function" instruction, loads the kernel function instructions from the video memory 101 into the on-chip cache 104, and the computing unit 102 reads the kernel function instructions from the on-chip cache 104 and executes the kernel function instructions, so as to realize the efficient operation of the program code written by the central processing unit on the domestic artificial intelligence chip (corresponding to the target software stack).
[0027] In addition to the structure described above, the artificial intelligence chip 100 in this application may also include other structures, and this application does not specifically limit such structures.
[0028] Artificial intelligence chips 100 can be: Graphics Processing Unit (GPU), General-purpose computing on graphics processing units (GPGPU), Domain Specific Architecture (DSA), etc.
[0029] It should be noted that in this application, "first" and "second" are used for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated.
[0030] The following is based on Figure 1 The diagram shown illustrates the architecture of an AI chip and details a software stack compatibility method. (See attached image.) Figure 2 This method is performed by a computer device, which includes... Figure 1 The artificial intelligence chip shown includes the following steps: Step 201: Obtain the original program code.
[0031] Specifically, the software stack compatibility method in this application embodiment can be applied to various scenarios, such as image processing, speech processing, and text processing. In different application scenarios, the physical meaning of the data processed by the original program code can be different.
[0032] For example, in a text processing scenario, the data processed by the original program code can be text data used in tasks such as text generation and text recognition.
[0033] For example, in a speech processing scenario, the data processed by the original program code can be speech data used in tasks such as speech enhancement, speech recognition, and speech synthesis.
[0034] For example, in image processing scenarios, the data processed by the original program code can be image data used in tasks such as image preprocessing, image segmentation, and object detection.
[0035] In this embodiment of the application, the original program code is code written by the customer based on their own needs and the ecosystem of the native software stack.
[0036] Step 202: During the compilation of the original program code, the first header file defined in the target software stack is called. The first header file has the same name as the second header file in the native software stack. The first header file is used to import the target header file in the target software stack.
[0037] Specifically, the native software stack can be the CUDA software stack. The original program code includes the name of the second header file of the native software stack. The second header file records the native interfaces exposed by the native software stack, as well as the interface rules and declarations of the native interfaces. If the first header file defined in the target software stack has the same name as the second header file of the native software stack, then during compilation, the first header file with the same name can be called according to the name of the second header file included in the original program code. The first header file includes the target header file of the target software stack. The target header file records the target interface of the target software stack, the interface rules of the target interface, and the interface declarations of the target interface, thereby achieving indirect calling of the target header file. This allows the compiler to support the compilation of the original program code through the target interface of the target software stack and the interface rules and declarations of the target interface.
[0038] For example, if the original program code contains a second header file named A_runtime.h, and the target software stack defines a first header file named A_runtime.h, and the first header file includes the target header file B_runtime.h, then when the original program code is compiled, it can be based on the fact that the first and second header files have the same name, and by calling A_runtime.h, it can actually call the target header file B_runtime.h.
[0039] In this embodiment, by defining a first header file with the same name as the second header file of the native software stack, the target header file under the first header file can be called without any modification to the client's original program code, so that the original program code is compiled based on the target interface of the target software stack.
[0040] Step 203: Convert the native interfaces in the target header file into target interfaces defined by the target software stack.
[0041] Specifically, native interfaces are interfaces defined by the native software stack. Since the compiler corresponding to the target software stack can only recognize the target interfaces defined by the target software stack, for each native interface contained in the target header file, the native interface is first converted into the target interface defined by the target software stack before subsequent compilation operations are performed.
[0042] In the implementation of this application, the original interface and the target interface can be APIs or other interfaces, and this application does not make any specific restrictions on them.
[0043] In this embodiment, firstly, the user's original program code is obtained. During the compilation of the original program code, the first header file defined in the target software stack is called. The first header file has the same name as the second header file in the native software stack to ensure compatibility with the native software stack. At the same time, the target header file in the target software stack is introduced through the first header file. That is, the second header file in the native software stack is no longer called during the compilation process, but the target header file in the target software stack is called. The target header file in the target software stack is not restricted by the private permissions of the native software stack. In this way, the native interfaces in the target header file can be directly converted into target interfaces defined by the target software stack. The native interfaces are the interfaces defined by the native software stack, thereby ensuring the correctness of compilation and enabling the program code written by the CPU to run efficiently on the domestic GPU (corresponding to the target software stack).
[0044] Secondly, this application no longer calls the second header file in the native software stack, that is, it no longer imports the native software stack. In this way, the definition of related structures or APIs in the target software stack will no longer conflict with the definition of structures or APIs in the native software stack, effectively avoiding the problem of namespace pollution in the target software stack.
[0045] In some embodiments, the native interfaces in the target header file are transformed into target interfaces defined by the target software stack through macro substitution.
[0046] Specifically, macro substitution refers to the plain text replacement operation performed by the compiler on macros defined by "#define" in the code before the actual compilation. The compiler scans the code and replaces all macro names with the text content of the macro definition to achieve string replacement.
[0047] For example, in "#define AB", A is the macro name appearing in the code, and B is the text content of the macro definition. That is, replace A with B in the code.
[0048] In this embodiment of the application, the target header file includes: each native interface in the second header file; the native interface contained in the target header file corresponds to the interface name under the native software stack; the interface name cannot be adapted to other software stacks besides the native software stack, therefore, for the native interface in the target header file, the interface name under the native software stack corresponding to the native interface is replaced with the interface name under the target software stack by macro substitution to obtain the target interface.
[0049] In some cases, a native interface may correspond not only to the interface name in the native software stack, but also to the interface parameters and return value rules in the native software stack. If the interface parameters and return value rules are also not compatible with other software stacks besides the native software stack, then a macro substitution method is used to replace the interface name, interface parameters, and return value rules in the native software stack corresponding to the native interface with the interface name, interface parameters, and return value rules in the target software stack to obtain the target interface.
[0050] In this embodiment, the native interface adapted to the native software stack is replaced with the target interface adapted to the target software stack in the target header file by a simple and quick method such as macro replacement, making the target header file easy to process in scripts and distributed management.
[0051] In some embodiments, during the compilation of the original program code, each native interface in the original program code is transformed into a target interface defined by the target software stack through macro substitution.
[0052] Specifically, the original program code is written based on the native software stack ecosystem. In other words, the interface names of the native interfaces appearing in the original program code are adapted to the native software stack ecosystem. The compiler of the target software stack cannot recognize the interface names of the native interfaces. Therefore, this application replaces the interface names of each native interface in the original program code with the interface names of the target interface through macro substitution, so as to achieve dynamic switching of interfaces without modifying the original program code.
[0053] For example, if the original program code contains a native interface named cudaGetDevice, then the macro "#difine cudaGetDevice supaGetDevice" will be used to replace the native interface name "cudaGetDevice" with the target interface name "supaGetDevice".
[0054] Similarly, if the interface parameters and return value rules of the native interface cannot be adapted to the target software stack, the interface parameters and return value rules of the native interface are also replaced by macro substitution, which will not be elaborated here.
[0055] In this embodiment, the native interfaces in the original program code are transformed into target interfaces defined by the target software stack through a simple and quick method such as macro substitution. This eliminates the need to modify the original program code and simplifies the compilation process.
[0056] In some embodiments, the target header file includes sub-header files that define the data types under the target software stack.
[0057] Specifically, the data types defined in the sub-header files include floating-point types, integer types, etc. The second header file of the native software stack includes sub-header files that define the various data types under the native software stack; most of the data type names included are globally defined. When both the native and target software stacks are included, if a globally defined data type name in the native software stack is the same as a data type name defined in the target software stack, a naming conflict will be triggered directly during compilation.
[0058] Therefore, in this embodiment, the target header file is indirectly introduced by defining a first header file with the same name as the second header file, thereby introducing sub-header files that define the data types under the target software stack; no macros need to be defined to introduce the data types under the target software stack; and this application no longer introduces the native software stack, that is, no longer introduces the sub-header files that define the data types under the native software stack, so there will be no redefinition problem.
[0059] For example, `float3` represents a three-dimensional floating-point vector in both the native and target software stacks. In the native stack, it's defined in the `vector_types.h` file, while in the target stack, it's defined in the `supa_vector_types.h` file. Therefore, when both the native and target software stacks are used simultaneously, a naming conflict occurs during compilation of the original program code for the same `float3`.
[0060] In this application, the native software stack is no longer introduced; only the target software stack is retained. Then, the vector_types.h file is defined under the target software stack. The vector_types.h file in the target software stack directly includes the supa_vector_types.h file. The float3 type under the target software stack can be introduced without defining any macros, and there will be no redefinition problem.
[0061] In this embodiment, a first header file with the same name as the second header file of the native software stack is defined in the target software stack. The sub-header files that define the data types under the target software stack are imported through the first header file. This allows the data defined by the target software stack to be imported without having to define any additional macros in the client's original program code, and without any redefinition issues.
[0062] In some embodiments, during the compilation of the original program code, if the compatibility control switch of the compiler executing the compilation process is turned on, the first header file defined in the target software stack is called.
[0063] During the compilation of the original program code, if the compiler's compatibility control switch is off, the second header file in the native software stack is called.
[0064] Specifically, a compatibility control switch is set in the compiler to control whether the native software stack is included. When the compatibility control switch is on, the native software stack cannot be included when compiling the original program code. Instead, the first header file with the same name as the second header file defined in the target software stack is called. When the compatibility control switch is off, the native software stack is included, that is, the second header file in the native software stack is called for compilation.
[0065] In this embodiment, a compatibility control switch is set in the compiler to determine whether to call the second header file of the native software stack or the first header file of the target software stack. No additional code needs to be added to the original program code. This lightweight design simplifies the compilation process of the original program code.
[0066] Based on the same technical concept, this application provides a schematic diagram of the structure of a software stack compatible device, such as... Figure 3 As shown, the software stack compatible device 300 includes: Module 301 is used to acquire the original program code; Module 302 is used to call a first header file defined in the target software stack during the compilation process of the original program code. The first header file has the same name as the second header file in the native software stack. The first header file is used to import the target header file in the target software stack. The conversion module 303 is used to convert each native interface in the target header file into a target interface defined by the target software stack, wherein the native interface is an interface defined by the native software stack.
[0067] Optionally, the conversion module 303 is specifically used for: The native interfaces in the target header file are transformed into target interfaces defined by the target software stack through macro substitution.
[0068] Optionally, the conversion module 303 is further configured to: During the compilation of the original program code, each native interface in the original program code is transformed into the target interface defined by the target software stack through macro substitution.
[0069] Optionally, the target header file includes: sub-header files that define the various data types under the target software stack.
[0070] Optionally, the calling module 302 is specifically used for: During the compilation of the original program code, if the compatibility control switch of the compiler executing the compilation process is turned on, the first header file defined in the target software stack is called.
[0071] Optionally, the calling module 302 is further configured to: During the compilation of the original program code, if the compiler's compatibility control switch is off, the second header file in the native software stack is called.
[0072] Optionally, the native software stack is a CUDA software stack; the target header file includes: each native interface in the second header file.
[0073] In this embodiment, firstly, the user's original program code is obtained. During the compilation of the original program code, the first header file defined in the target software stack is called. The first header file has the same name as the second header file in the native software stack to ensure compatibility with the native software stack. At the same time, the target header file in the target software stack is introduced through the first header file. That is, the second header file in the native software stack is no longer called during the compilation process, but the target header file in the target software stack is called. The target header file in the target software stack is not restricted by the private permissions of the native software stack. In this way, the native interfaces in the target header file can be directly converted into target interfaces defined by the target software stack. The native interfaces are the interfaces defined by the native software stack, thereby ensuring the correctness of compilation and enabling the program code written by the CPU to run efficiently on the domestic GPU (corresponding to the target software stack).
[0074] Secondly, this application no longer calls the second header file in the native software stack, that is, it no longer imports the native software stack. In this way, the definition of related structures or APIs in the target software stack will no longer conflict with the definition of structures or APIs in the native software stack, effectively avoiding the problem of namespace pollution in the target software stack.
[0075] Based on the same technical concept, embodiments of this application provide a computer device, such as... Figure 4 As shown, it includes at least one artificial intelligence chip 100 and a memory 401 connected to at least one artificial intelligence chip 100. In this embodiment, the specific connection medium between the artificial intelligence chip 100 and the memory 401 is not limited. Figure 4 Taking the connection between the AI chip 100 and the memory 401 via a bus as an example, the bus can be divided into address bus, data bus, control bus, etc.
[0076] In this embodiment of the application, the memory 401 stores instructions that can be executed by at least one artificial intelligence chip 100. By executing the instructions stored in the memory 401, at least one artificial intelligence chip 100 can perform the steps of the above-described software stack compatible method.
[0077] The artificial intelligence chip 100 serves as the control center of the computer device, connecting various parts of the device via various interfaces and lines. It achieves software stack compatibility by running or executing instructions stored in the memory 401 and accessing data stored in the memory 401. Optionally, the artificial intelligence chip 100 may include one or more processing units. It may integrate an application processor and a modem processor, where the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may not be integrated into the artificial intelligence chip 100. In some embodiments, the artificial intelligence chip 100 and the memory 401 may be implemented on the same chip; in other embodiments, they may be implemented on separate chips.
[0078] The artificial intelligence chip 100 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0079] Memory 401, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 401 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 401 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer device, but is not limited thereto. In the embodiments of this application, memory 401 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0080] Based on the same inventive concept, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a computer device, which, when run on the computer device, causes the computer device to perform the steps of the above-described software stack compatible method.
[0081] Based on the same inventive concept, this application provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, which, when executed by a computer device, cause the computer device to perform the steps of the above-described software stack compatible method.
[0082] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0083] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0084] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0085] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0086] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations. Those skilled in the art should understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0087] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0088] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0089] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0090] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A software stack compatibility method, characterized by, include: Obtain the original program code; During the compilation of the original program code, the first header file defined in the target software stack is called. The first header file has the same name as the second header file in the native software stack. The first header file is used to include the target header file in the target software stack. Each native interface in the target header file is converted into a target interface defined by the target software stack, wherein the native interface is an interface defined by the native software stack.
2. The method of claim 1, wherein, The step of converting the native interfaces in the target header file into target interfaces defined by the target software stack includes: The native interfaces in the target header file are transformed into target interfaces defined by the target software stack through macro substitution.
3. The method as described in claim 1, characterized in that, Also includes: During the compilation of the original program code, each native interface in the original program code is transformed into the target interface defined by the target software stack through macro substitution.
4. The method as described in claim 1, characterized in that, The target header file includes sub-header files that define the data types under the target software stack.
5. The method according to any one of claims 1 to 4, characterized in that, The process of compiling the original program code, including calling the first header file defined in the target software stack, includes: During the compilation of the original program code, if the compatibility control switch of the compiler executing the compilation process is turned on, the first header file defined in the target software stack is called.
6. The method as described in claim 5, characterized in that, Also includes: During the compilation of the original program code, if the compiler's compatibility control switch is off, the second header file in the native software stack is called.
7. The method according to any one of claims 1 to 4, characterized in that, The native software stack is the CUDA software stack; the target header file includes: each native interface in the second header file.
8. A computer device comprising a memory, an artificial intelligence chip, and a computer program stored in the memory and running on the artificial intelligence chip, characterized in that, When the artificial intelligence chip executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, It stores a computer program that is executed by a computer device, which, when run on the computer device, causes the computer device to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer program product, characterized in that, The computer program product includes a computer program stored on a computer-readable storage medium, the computer program including program instructions that, when executed by a computer device, cause the computer device to perform the steps of the method as described in any one of claims 1-7.