TECHNICAL FIELD

The disclosure relates to the field of computer application technologies, and partically relates to a method for acquiring an executable file of a heterogeneous computing system, a method for running the heterogeneous computing system, and related products.

BACKGROUND

With the development of electronic device technologies, the computing performance of CPU in electronic devices encounters bottlenecks as the quantity of data processed by electronic devices is becoming larger. Therefore, a heterogeneous computing system has appeared. The heterogeneous computing system refers to a system built with one or more general-purpose computing units (such as CPU) plus one or more dedicated computing units (such as Graphics Processing Unit, abbreviated as GPU). Heterogeneous computing refers to the general-purpose computing units and the dedicated computing units working together to perform general computing tasks, so as to accelerate processing capacity of the data.

Artificial intelligence processing units (such as Machine Learning Unit, abbreviated as MLU) can be combined with CPU to build a heterogeneous computing system for processing artificial intelligence processing unit programs written in neural network programming languages, so as to accelerate processing speed of various machine learning or deep learning algorithms. In conventional technologies, an electronic device is generally used to call preset operators that support required functions in a machine learning library, or a plurality of preset operators that support different functions in a machine learning library are spliced to achieve required functions.

However, since the above method of calling a single operator or a spliced operator in the machine learning library cannot fully implement new functions required by users, the application scope of the method may be narrow.

SUMMARY

In view of this, it is necessary to provide a method for acquiring an executable file of a heterogeneous computing system, a method for running the heterogeneous computing system, and related products to solve the above problem of the conventional technologies.

In a first aspect, examples of the present disclosure provide a method for acquiring an executable file of a heterogeneous computing system, where the heterogeneous computing system includes a general-purpose processing unit CPU and an artificial intelligence processing unit, and the method includes:

acquiring an artificial intelligence processing unit program and a CPU program, where the artificial intelligence processing unit program includes an entry function, and the CPU program includes an identifier of the entry function and an interface function set;

compiling the artificial intelligence processing unit program to generate a first compiling file, and linking the first compiling file to a link library of a machine learning library; and

compiling the CPU program to acquire a second compiling file, and linking the second compiling file to the link library to generate an executable file of the heterogeneous computing system.

In the method for acquiring an executable file of a heterogeneous computing system provided in the example, an electronic device may acquire an artificial intelligence processing unit program and a CPU program, where the artificial intelligence processing unit program includes an entry function, and the CPU program includes an identifier of the entry function and an interface function set; may compile the artificial intelligence processing unit program to generate a first compiling file, and link the first compiling file to a link library of a machine learning library; and compile the CPU program to acquire a second compiling file, and link the second compiling file to the link library to generate an executable file of the heterogeneous computing system. In this example, the electronic device allows users to write artificial intelligence processing unit programs corresponding to operators that can implement required functions. The electronic device can also receive data required by the artificial intelligence processing unit program input by users by using an interface function set composed of multiple interface functions in the machine learning library. In this way, when executing the executable file, CPU in the electronic device can call a target artificial intelligence processing unit to execute the artificial intelligence processing unit program. Therefore, corresponding functions of the artificial intelligence processing unit may be implemented. In other words, the electronic device allows users to customize new operators according to required functions by using interface functions in the machine learning library, which may solve the problem in the prior art that the method of calling a single operator or a spliced operator in the machine learning library cannot fully implement new functions required by users, and expand the application scope of machine learning library.

In an example, the interface function set is configured to acquire a parameter required for running the artificial intelligence processing unit program.

In an example, the interface function set configured to acquire a parameter required for running the artificial intelligence processing unit program includes:

an initialization declaration interface function in the interface function set configured to declare a struct variable;

an input address interface function in the interface function set configured to acquire an input address in the struct variable;

an output address interface function in the interface function set configured to acquire an output address in the struct variable;

a static address interface function in the interface function set configured to acquire a static address in the struct variable; and

a constant parameter interface function in the interface function set configured to acquire a constant parameter in the struct variable.

In an example, the interface function set is further configured to acquire an identifier of the artificial intelligence processing unit program, where the identifier of the artificial intelligence processing unit program is acquired according to a parameter in the struct variable acquired by the interface function set, a number and a descriptor of the parameter in the struct variable, and the identifier of the entry function of the artificial intelligence processing unit program.

In an example, the interface function set is further configured to acquire an identifier of an artificial intelligence processing unit, so as to make the artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit execute the artificial intelligence processing unit program.

In an example, the compiling the artificial intelligence processing unit program to generate a first compiling file, and linking the first compiling file to a link library of a machine learning library includes:

acquiring a preset artificial intelligence compiler and a linker;

compiling the artificial intelligence processing unit program according to the artificial intelligence compiler to generate the first compiling file; and

linking, by the linker, the compiling file to the link library.

In an example, the compiling the CPU program to acquire a second compiling file, and linking the second compiling file to the link library to generate an executable file of the heterogeneous computing system includes:

acquiring a preset CPU compiler;

compiling the CPU program according to the CPU compiler to acquire the second compiling file; and

linking, by the linker, the second compiling file to the link library to generate an executable file of the heterogeneous computing system.

In a second aspect, examples of the present disclosure provides a method for running a heterogeneous computing system, where the method includes:

acquiring an executable file described in any of the above examples;

running an initialization declaration interface function, an input address interface function, an output address interface function, a static address interface function, and a constant parameter interface function in the executable file, and outputting a parameter required for running an artificial intelligence processing unit program in the executable file;

running an interface function for acquiring an identifier of the artificial intelligence processing unit program in the executable file according to a parameter in the struct variable acquired by the interface function set, the number and the descriptor of the parameter in the struct variable, and an identifier of an entry function of the artificial intelligence processing unit program, and outputting an identifier of the artificial intelligence processing unit program; and

transferring the identifier of the artificial intelligence processing unit program to the interface function configured to acquire the identifier of the artificial intelligence processing unit program in the executable file, and transferring the artificial intelligence processing unit program to a target artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit according to the identifier of the artificial intelligence processing unit in the interface function for acquiring the identifier of the artificial intelligence processing unit, so as to make the target artificial intelligence processing unit execute the artificial intelligence processing unit program.

In the method for running a heterogeneous computing system provided in the example, an electronic device may acquire an executable file described in any of the above examples; run an initialization declaration interface function, an input address interface function, an output address interface function, a static address interface function, and a constant parameter interface function in the executable file, and output a parameter required for running the artificial intelligence processing unit program in the executable file; run an interface function configured to acquire an identifier of the artificial intelligence processing unit program in the executable file according to a parameter in the struct variable acquired by the interface function set, a number and a descriptor of the parameter in the struct variable, and an identifier of an entry function of the artificial intelligence processing unit program, and output the identifier of the artificial intelligence processing unit program; and transfer the identifier of the artificial intelligence processing unit program to the interface function configured to acquire an identifier of the artificial intelligence processing unit program in the executable file, and transfer the artificial intelligence processing unit program to a target artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit according to the identifier of the artificial intelligence processing unit in the interface function configured to acquire the identifier of the artificial intelligence processing unit, so as to make the target artificial intelligence processing unit execute the artificial intelligence processing unit program. In the example, the electronic device can call a target artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit program to execute the artificial intelligence processing unit program corresponding to the identifier of the artificial intelligence processing unit program when executing an executable file according to data required by the artificial intelligence processing unit program in the interface function set composed of multiple interface functions in the executable file. The data includes a name of the entry function, an input address, the identifier of the artificial intelligence processing unit program, and the identifier of the artificial intelligence processing unit, and the like. Therefore, corresponding functions of the artificial intelligence processing unit written by users may be implemented. In this way, the electronic device allows users to customize new operators according to required functions by using interface functions in the machine learning library, which may solve the problem in the prior art that the method of calling a single operator or a spliced operator in the machine learning library cannot fully implement new functions required by users, and expand the application scope of machine learning library.

In a third aspect, examples of the present disclosure provide a device for acquiring an executable file of a heterogeneous computing system, where the heterogeneous computing system includes a general-purpose processing unit CPU and an artificial intelligence processing unit, and the device includes:

a first acquiring module configured to acquire an artificial intelligence processing unit program and a CPU program, where the artificial intelligence processing unit program includes an entry function, and the CPU program includes an identifier of the entry function and an interface function set;

a first generating module configured to compile the artificial intelligence processing unit program to generate a first compiling file, and link the first compiling file to a link library of a machine learning library; and

a second generating module configured to compile the CPU program to acquire a second compiling file, and link the second compiling file to the link library to generate an executable file of the heterogeneous computing system.

In an example, the interface function set is configured to acquire a parameter required for running the artificial intelligence processing unit program.

In an example, the interface function set configured to acquire a parameter required for running the artificial intelligence processing unit program includes:

an initialization declaration interface function in the interface function set configured to declare a struct variable;

an input address interface function in the interface function set configured to acquire an input address in the struct variable;

an output address interface function in the interface function set configured to acquire an output address in the struct variable;

a static address interface function in the interface function set configured to acquire a static address in the struct variable; and

a constant parameter interface function in the interface function set configured to acquire a constant parameter in the struct variable.

In an example, the interface function set is further configured to acquire an identifier of the artificial intelligence processing unit program, where the identifier of the artificial intelligence processing unit program is acquired according to a parameter in the struct variable acquired by the interface function set, a number and a descriptor of the parameter in the struct variable, and the identifier of the entry function of the artificial intelligence processing unit program.

In an example, the interface function set is further configured to acquire an identifier of an artificial intelligence processing unit, so as to make the artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit execute the artificial intelligence processing unit program.

In an example, the first generating module includes:

a first acquiring unit configured to acquire a preset artificial intelligence compiler and a linker;

a first generating unit configured to compile the artificial intelligence processing unit program according to the artificial intelligence compiler to generate a first compiling file; and

a first linking unit configured to link the compiling file to the link library by using the linker.

In an example, the second generating module includes:

a second acquiring unit configured to acquire a preset CPU compiler;

a second generating unit configured to compile the CPU program according to the CPU compiler to acquire a second compiling file; and

a second linking unit configured to link the second compiling file to the link library to generate an executable file of the heterogeneous computing system.

In a fourth aspect, examples of the present disclosure provide a device for running a heterogeneous computing system, where the device includes:

a second acquiring module configured to acquire an executable file described in any of the above examples;

a first processing module configured to run an initialization declaration interface function, an input address interface function, an output address interface function, a static address interface function, and a constant parameter interface function in the executable file, and output a parameter required for running the artificial intelligence processing unit program in the executable file;

a second processing module configured to run an interface function for acquiring an identifier of the artificial intelligence processing unit program in the executable file according to a parameter in the struct variable acquired by the interface function set, a number and a descriptor of the parameter in the struct variable, and an identifier of an entry function of the artificial intelligence processing unit program, and output an identifier of the artificial intelligence processing unit program; and

a third processing module configured to transfer the identifier of the artificial intelligence processing unit program to the interface function configured to acquire an identifier of the artificial intelligence processing unit program in the executable file, and transfer the artificial intelligence processing unit program to a target artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit according to the identifier of the artificial intelligence processing unit in the interface function for acquiring the identifier of the artificial intelligence processing unit, so as to make the target artificial intelligence processing unit execute the artificial intelligence processing unit program.

In a fifth aspect, examples of the present disclosure provide a CPU, where the CPU and an artificial intelligence processing unit constitute a heterogeneous computing system, and the CPU is configured to implement following steps:

acquiring an artificial intelligence processing unit program and a CPU program, where the artificial intelligence processing unit program includes an entry function, and the CPU program includes an identifier of the entry function and an interface function set;

compiling the artificial intelligence processing unit program to generate a first compiling file, and linking the first compiling file to a link library of a machine learning library; and

compiling the CPU program to acquire a second compiling file, and linking the second compiling file to the link library to generate an executable file of the heterogeneous computing system.

The CPU is further configured to implement the following steps:

acquiring the executable file described in any of the above examples;

running an initialization declaration interface function, an input address interface function, an output address interface function, a static address interface function, and a constant parameter interface function in the executable file, and outputting a parameter required for running the artificial intelligence processing unit program in the executable file;

running an interface function for acquiring an identifier of the artificial intelligence processing unit program in the executable file according to a parameter in a struct variable acquired by the interface function set, a number and a descriptor of the parameter in the struct variable, and an identifier of an entry function of the artificial intelligence processing unit program, and outputting an identifier of the artificial intelligence processing unit program; and

transferring the identifier of the artificial intelligence processing unit program to the interface function configured to acquire an identifier of the artificial intelligence processing unit program in the executable file, and transferring the artificial intelligence processing unit program to a target artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit according to the identifier of the artificial intelligence processing unit in the interface function for acquiring the identifier of the artificial intelligence processing unit, so as to make the target artificial intelligence processing unit execute the artificial intelligence processing unit program.

In a sixth aspect, examples of the present disclosure provide a motherboard applied to a heterogeneous computing system, where the motherboard includes: the CPU described in the above examples, a first memory connected to the CPU, an artificial intelligence processing unit, and a second memory connected to the artificial intelligence processing unit; where

the first memory is configured to store a CPU program and an artificial intelligence processing unit program, the second memory is configured to store input data and output data required by the artificial intelligence processing unit, and the artificial intelligence processing unit is configured to execute the artificial intelligence processing unit program.

In a seventh aspect, examples of the present disclosure provides an electronic device applied to a heterogeneous computing system, where the electronic device includes the motherboard described in the above example, and CPU in the motherboard is configured to implement the following steps:

acquiring an artificial intelligence processing unit program and a CPU program, where the artificial intelligence processing unit program includes an entry function, and the CPU program includes an identifier of the entry function and an interface function set;

compiling the artificial intelligence processing unit program to generate a first compiling file, and linking the first compiling file to a link library of a machine learning library; and

compiling the CPU program to acquire a second compiling file, and linking the second compiling file to the link library to generate an executable file of the heterogeneous computing system.

The CPU is further configured to implement the following steps:

acquiring the executable file described in any of the above examples;

running an initialization declaration interface function, an input address interface function, an output address interface function, a static address interface function, and a constant parameter interface function in the executable file, and outputting a parameter required for running the artificial intelligence processing unit program in the executable file;

running an interface function for acquiring an identifier of the artificial intelligence processing unit program in the executable file according to a parameter in a struct variable acquired by the interface function set, a number and a descriptor of the parameter in the struct variable, and an identifier of an entry function of the artificial intelligence processing unit program, and outputting an identifier of the artificial intelligence processing unit program; and

transferring the identifier of the artificial intelligence processing unit program to the interface function configured to acquire an identifier of the artificial intelligence processing unit program in the executable file, and transferring the artificial intelligence processing unit program to a target artificial intelligence processing unit corresponding to the identifier of the artificial intelligence processing unit according to the identifier of the artificial intelligence processing unit in the interface function for acquiring the identifier of the artificial intelligence processing unit, so as to make the target artificial intelligence processing unit execute the artificial intelligence processing unit program.

In the executable file acquiring device of the heterogeneous computing system, the device for running the heterogeneous computing system, CPU, the motherboard, and the electronic device provided in the examples, the electronic device is configured to acquire an artificial intelligence processing unit program and a CPU program, where the artificial intelligence processing unit program includes an entry function, and the CPU program includes an identifier of the entry function and an interface function set; compile the artificial intelligence processing unit program to generate a first compiling file, and link the first compiling file to a link library of a machine learning library; and compile the CPU program to acquire a second compiling file, and link the second compiling file to the link library to generate an executable file of the heterogeneous computing system. In this example, the electronic device allows users to write artificial intelligence processing unit programs corresponding to operators that can implement required functions, and receives data required by the artificial intelligence processing unit program input by users by using an interface function set composed of multiple interface functions in the machine learning library, so that CPU in the electronic device can call a target artificial intelligence processing unit to execute the artificial intelligence processing unit program to execute the artificial intelligence processing unit program when executing the executable file. Therefore, corresponding functions of the artificial intelligence processing unit may be implemented, that is, the electronic device allows users to customize new operators according to required functions by using interface functions in the machine learning library, which may solve the problem in the prior art that the method of calling a single operator or a spliced operator in the machine learning library cannot fully implement new functions required by users, and expand the application scope of machine learning library.

