Heterogeneous system parallel application development method
By calling operator library and OpenMP parallel statements in heterogeneous systems, combining MPI and OpenMP APIs to build a task parallel environment, the problem of low efficiency in parallel application development in heterogeneous systems is solved, and efficient task parallelism and resource utilization are achieved.
Patent Information
- Application Number
- CN202510017555.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-06
AI Technical Summary
In heterogeneous systems, how to effectively improve the development efficiency of parallel applications, faces complex structures and different programming models of multiple computing devices, users have a heavy burden when developing applications.
The task description file is generated by calling the operator library and OpenMP parallel statements, combining the MPI and OpenMP API to build a task parallel environment in the main program, configure scheduling strategies and parsing functions, and converting them into a DAG task model to achieve parallel and efficient execution of tasks.
It realizes the rapid construction of parallel applications on large-scale heterogeneous systems, improves the development efficiency of parallel applications of heterogeneous systems, simplifies the development process of users, and makes full use of the computing resources of coprocessors.
Smart Images

Figure CN119806493A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and more specifically, relates to a method for developing parallel applications for heterogeneous systems. Background Art
[0002] With the continuous development of science and technology, high-performance computing has penetrated into quantum physics, weather forecasting, climate research, oil and gas exploration, biopharmaceuticals and other fields. In order to meet this demand, the design concept of high-performance computing systems has undergone profound changes with the rapid development of technology. Since the single-core scalar processor has encountered bottlenecks in frequency increase and instruction-level parallelism due to power consumption, the structure of high-performance computing systems has gradually developed towards the trend of multi-core parallel computing under heterogeneous systems. Heterogeneous systems refer to computing systems in which processors with different functions or performances, that is, different dedicated fields, are connected through a certain interconnection structure. Currently popular heterogeneous systems are usually composed of one or more computing nodes, and a computing node in a heterogeneous system is usually composed of a general-purpose processor (general-purpose multi-core CPU, etc.) and a coprocessor. The coprocessor can be a graphics processing unit (GPU), a neural processing unit (NPU), a digital signal processor (DSP) or a field-programmable gate array (FPGA). Heterogeneous systems based on this type of structure can rely on general-purpose processors to provide general computing capabilities to cope with various types of applications. On the other hand, they can use coprocessors to accelerate applications in specific fields and achieve higher performance with lower power consumption.
[0003] However, while heterogeneous systems achieve high computing performance, how to make use of this performance in practical applications still faces huge challenges. On the one hand, the increase in the scale of heterogeneous systems places higher requirements on the applications themselves. In order to utilize the huge number of computing cores in heterogeneous systems, users will face a huge challenge in developing tasks with unprecedented parallelism. On the other hand, heterogeneous systems have complex structures, and the various computing devices inside them each have different system structures, instruction combinations, and programming models. Users need to master a variety of different and complex programming specifications, which will greatly increase the burden on users to develop applications. How to effectively improve the development efficiency of parallel applications in heterogeneous systems is a technical problem that needs to be solved in this field. Summary of the invention
[0004] In view of the defects of the prior art, the purpose of this application is to effectively improve the development efficiency of parallel applications of heterogeneous systems.
[0005] To achieve the above objectives, in a first aspect, the present application provides a method for developing parallel applications in heterogeneous systems, the method comprising: By calling the operator library and OpenMP parallel statements, a task description file (.omp file) is generated. The operator library is based on the OpenCL encapsulation. The task description file is used to represent the relationship between each task and different tasks (including but not limited to the data flow, control flow, parallel relationship and other information between tasks). The algorithm used by the task is obtained by calling the operator library API, and the parallel operation of the task is constructed by calling the OpenMP parallel statement; In the main program (.c file), use the MPI API to build a task parallel environment between nodes (implemented by multiple processes), use the OpenMP API to build a task parallel environment within a node (implemented by multiple threads), configure the scheduling strategy, and configure the parsing function of the task description file; Among them, the parallel application includes a task description file and a main program. The parsing function is used to parse the task description file and convert it into a DAG (directed acyclic graph) task model; the scheduling strategy is used to instruct the task scheduler to determine the mapping relationship between each task in the DAG task model and the coprocessor of the node.
[0006] The task parallel environment between nodes is used to allocate tasks in the DAG task model to the task launch queue of the corresponding node based on the mapping relationship, and the task parallel environment within the node is used to allocate tasks in the task launch queue to the corresponding coprocessor based on the mapping relationship.
[0007] It can be understood that by calling the operator library and OpenMP parallel statements, calling the MPI API and OpenMP API in the main program, and configuring the scheduling strategy, it is possible to quickly build parallel applications, assist parallel application task developers to develop efficiently, and effectively improve the development efficiency of parallel applications in heterogeneous systems.
[0008] At the same time, the MPI inter-process communication mechanism is used to realize cross-node task parallelism and data transmission, and OpenMP and OpenCL technologies are used to give full play to the computing resources inside the coprocessor, providing effective support for the development of parallel applications on large-scale heterogeneous systems.
[0009] In a possible implementation, the above-mentioned task parallel environment between nodes is built through the MPI API, including: Create management processes corresponding to each node through the MPI API; Among them, different management processes communicate through message passing, and based on the mapping relationship between each task in the DAG task model and the coprocessor of the node, the tasks in the DAG task model are allocated to the task emission queue of the corresponding node.
[0010] In a possible implementation, the above-mentioned task parallel environment within the node is built through the OpenMP API, including: Through the OpenMP API, create management threads corresponding to each coprocessor in the node; The management thread in the node is used to receive tasks from the task launch queue of the node based on the mapping relationship between each task and the coprocessor of the node in the DAG task model, and allocate the tasks to the corresponding coprocessor.
[0011] In a possible implementation, the method further includes: Generate operator files based on OpenCL; The dynamic link library mechanism of the C programming language is used to compile the operator file into a dynamic library file. The algorithm of the corresponding operator file can be obtained by calling the API provided by the dynamic library file. The operator library includes the dynamic library files corresponding to each operator file.
[0012] In a possible implementation, the scheduling policy is specifically used to indicate a candidate coprocessor set corresponding to each task, the candidate processor set is composed of all or part of the coprocessors on the specified node, and the task scheduler selects a coprocessor from the candidate processor set corresponding to the task; The above-mentioned mapping relationship between each task and the coprocessor of the node in the DAG task model is determined, including: Based on the priority of each task, determine the current task to be scheduled. The priority of each task is determined by performing inverse topological sorting on each task in the DAG task model; Based on the scheduling policy, determine the set of candidate processors corresponding to the current task to be scheduled; For the coprocessors in the candidate processor set corresponding to the task to be scheduled currently, estimate the worst response time after the task to be scheduled currently is mapped to each coprocessor; A coprocessor with the shortest worst response time is determined to execute the current task.
[0013] Exemplarily, the scheduling strategy may be global scheduling, group scheduling, etc. Global scheduling specifically means that the candidate coprocessor set corresponding to each task is composed of all coprocessors on all nodes. Group scheduling specifically means that each task is grouped, and the candidate coprocessor set corresponding to the tasks in the same group is composed of some coprocessors on the specified node.
[0014] It can be understood that in DAG, reverse topological sorting refers to arranging the task nodes in the DAG task model in a certain order so that for each directed edge (u, v), u appears before v in the sequence. The result of reverse topological sorting can be used to determine the execution order of tasks. The implementation of reverse topological sorting can usually use depth-first search (DFS).
[0015] In a possible implementation, the estimation of the worst response time of the current task to be scheduled after being mapped to each coprocessor in the candidate processor set corresponding to the current task to be scheduled includes: For the coprocessors in the candidate processor set corresponding to the task to be scheduled currently, by monitoring the number of tasks executed by each coprocessor, the worst waiting time after the task to be scheduled currently is mapped to each coprocessor is estimated; For the coprocessor in the candidate processor set corresponding to the current task to be scheduled, the worst response time (the sum of the worst execution time and the worst waiting time) after the current task to be scheduled is mapped to each coprocessor is estimated based on the worst execution time and the worst waiting time. The worst execution time is obtained by testing the task on the coprocessor in advance.
[0016] In a second aspect, the present application provides a device for developing parallel applications for heterogeneous systems, comprising: The task description file generation module is used to generate a task description file by calling the operator library and the OpenMP parallel statement. The operator library is based on the OpenCL encapsulation. The task description file is used to represent the relationship between each task and different tasks. The algorithm used by the task is obtained by calling the API of the operator library, and the parallel operation of the task is constructed by calling the OpenMP parallel statement. The main program configuration module is used to build a task parallel environment between nodes through the MPI API, build a task parallel environment within a node through the OpenMP API, configure the scheduling strategy, and configure the parsing function of the task description file in the main program; The parallel application includes a task description file and a main program. The parsing function is used to parse the task description file and convert it into a DAG task model. The scheduling strategy is used to instruct the task scheduler to determine the mapping relationship between each task in the DAG task model and the coprocessor of the node.
[0017] In a third aspect, the present application provides an electronic device comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory. When the program stored in the memory is executed, the processor is used to execute the method described in the first aspect or any possible implementation of the first aspect.
[0018] In a fourth aspect, the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method described in the first aspect or any possible implementation of the first aspect.
[0019] In a fifth aspect, the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method described in the first aspect or any possible implementation of the first aspect.
[0020] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here.
[0021] In general, the above technical solutions conceived by this application have the following beneficial effects compared with the prior art: (1) Through the hybrid programming model MPI+OpenMP+OpenCL, MPI is used to provide an inter-process communication mechanism between nodes, and OpenMP threads are used within the nodes to manage the parallel task scheduling framework of multiple types of coprocessors. OpenCL is used to load coprocessor kernel tasks and allocate computing resources, which can achieve parallel and efficient execution of tasks on large-scale heterogeneous systems.
[0022] (2) The main bodies of application development on heterogeneous systems are divided into Task Developer and System Developer. Task Developer focuses on the development of task applications, while System Developer optimizes the resource scheduling of heterogeneous systems. Through this model, the development process of parallel applications in heterogeneous systems is standardized, and the overall development efficiency is significantly improved.
[0023] (3) Users can convert parallel applications into DAG task models by calling OpenCL kernel operators to write task description files, and perform real-time scheduling and analysis of tasks at runtime, thereby improving the flexibility of task scheduling and execution efficiency.
[0024] (4) By decoupling task scheduling from application development programs, there is no need to design different schedulers for different application development programs, and fully automatic mapping of heterogeneous parallel applications to heterogeneous processor coprocessors can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a flowchart of a method for developing parallel applications for heterogeneous systems provided in an embodiment of the present application; Figure 2 It is a general architecture diagram of the parallel programming framework provided in the embodiment of the present application; Figure 3 It is a schematic diagram of collaborative development of a parallel programming framework provided in an embodiment of the present application; Figure 4 It is a schematic diagram of the heterogeneous system structure provided in an embodiment of the present application; Figure 5 is a schematic diagram of a task parallel environment provided in an embodiment of the present application; Figure 6 It is a schematic diagram of a runtime task scheduling framework provided by an embodiment of the present application; Figure 7 It is a DAG graph obtained by parsing a common serial task provided in an embodiment of the present application during operation; Figure 8 It is a DAG graph obtained by parsing a typical parallel task provided in an embodiment of the present application during runtime; Fig. 9 It is a DAG diagram obtained by parsing a typical seismic data analysis task provided in an embodiment of the present application during operation; Fig.10 It is a DAG graph obtained by parsing the astronomical image calculation task provided in the embodiment of the present application during operation; Fig.11 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0027] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0028] In the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two. For example, multiple processing units refer to two or more processing units, etc.; multiple elements refer to two or more elements, etc.
[0029] First, the technical terms involved in the embodiments of the present application are introduced.
[0030] (1) MPI (Message Passing Interface): used to implement inter-node communication and is suitable for large-scale distributed memory systems. MPI is a widely used standard for inter-process communication in distributed memory systems. It allows messages to be passed between multiple computing nodes, enabling parallel computing to run efficiently on large-scale clusters. MPI provides a series of functions and interfaces that support point-to-point communication, collective communication, and synchronization mechanisms, and is suitable for applications that require high performance and scalability.
[0031] (2) OpenMP (Open Multi-Processing): used to implement multi-threaded parallel computing in shared memory systems. OpenMP is a programming model for shared memory multiprocessing that mainly implements multi-threaded parallel computing through compilation instructions, library routines, and environment variables. It allows developers to easily insert parallelization instructions into existing serial code to utilize the computing power of multi-core CPUs. OpenMP is suitable for applications that require parallel processing on a single node, such as numerical computing, image processing, and data analysis, and can significantly improve the execution efficiency of programs.
[0032] (3) OpenCL (Open Computing Language): used to implement parallel computing on GPUs, FPGAs and other devices in heterogeneous systems. OpenCL is a framework for heterogeneous computing that allows developers to write parallel programs on a variety of computing devices (such as CPUs, GPUs and FPGAs). OpenCL provides a unified programming model that enables developers to leverage the computing power of different hardware for efficient data parallel processing.
[0033] The embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application.
[0034] Figure 1 is a flow chart of a method for developing a heterogeneous system parallel application provided in an embodiment of the present application, such as Figure 1 As shown, the method includes the following steps S101 and S102.
[0035] Step S101, generating a task description file (.omp file) by calling an operator library and an OpenMP parallel statement. The operator library is based on the OpenCL encapsulation. The task description file is used to represent the association between each task and different tasks (including but not limited to the data flow, control flow, parallel relationship and other information between tasks). The algorithm used by the task is obtained by calling the API of the operator library, and the parallel operation of the task is constructed by calling the OpenMP parallel statement. Step S102, in the main program (.c file), build a task parallel environment between nodes (implemented by multiple processes) through the MPI API, build a task parallel environment within a node (implemented by multiple threads) through the OpenMP API, configure the scheduling strategy, and configure the parsing function of the task description file; Among them, the parallel application includes a task description file and a main program. The parsing function is used to parse the task description file and convert it into a DAG (directed acyclic graph) task model; the scheduling strategy is used to instruct the task scheduler to determine the mapping relationship between each task in the DAG task model and the coprocessor of the node.
[0036] The task parallel environment is exemplarily explained here. The task parallel environment between nodes is used to allocate tasks in the DAG task model to the task launch queue of the corresponding node based on the mapping relationship, and the task parallel environment within the node is used to allocate tasks in the task launch queue to the corresponding coprocessor based on the mapping relationship.
[0037] Here, the scheduling strategy is exemplified. The scheduling strategy is specifically used to indicate the candidate coprocessor set corresponding to each task. The candidate processor set consists of all or part of the coprocessors on the specified node. The task scheduler selects a coprocessor from the candidate processor set corresponding to the task. Accordingly, the mapping relationship between each task and the coprocessor of the node in the DAG task model is determined as follows: Based on the priority of each task, determine the current task to be scheduled. The priority of each task is determined by performing inverse topological sorting on each task in the DAG task model; Based on the scheduling policy, determine the set of candidate processors corresponding to the current task to be scheduled; For the coprocessors in the candidate processor set corresponding to the task to be scheduled currently, estimate the worst response time after the task to be scheduled currently is mapped to each coprocessor; A coprocessor with the shortest worst response time is determined to execute the current task.
[0038] Exemplarily, the scheduling strategy may be global scheduling, group scheduling, etc. Global scheduling specifically means that the candidate coprocessor set corresponding to each task is composed of all coprocessors on all nodes. Group scheduling specifically means that each task is grouped, and the candidate coprocessor set corresponding to the tasks in the same group is composed of some coprocessors on the specified node.
[0039] Furthermore, the estimation of the worst response time of the current task to be scheduled after being mapped to each coprocessor in the candidate processor set corresponding to the current task to be scheduled includes: For the coprocessors in the candidate processor set corresponding to the task to be scheduled currently, by monitoring the number of tasks executed by each coprocessor, the worst waiting time after the task to be scheduled currently is mapped to each coprocessor is estimated; For the coprocessor in the candidate processor set corresponding to the current task to be scheduled, the worst response time (the sum of the worst execution time and the worst waiting time) after the current task to be scheduled is mapped to each coprocessor is estimated based on the worst execution time and the worst waiting time. The worst execution time is obtained by testing the task on the coprocessor in advance.
[0040] It can be understood that a parallel application includes a task description file and a main program. By calling the API of the operator library, the algorithm required for the task can be obtained, and by calling the OpenMP parallel statement, the parallel operation of the task can be constructed. Therefore, by calling the operator library and the OpenMP parallel statement, the task description file can be quickly generated.
[0041] Furthermore, in the main program (.c file), the task parallel environment, scheduling strategy and task description file parsing function are configured. The task description file can be parsed through the parsing function and converted into a DAG task model, and then through the task scheduler, the mapping relationship between each task in the DAG task model and the coprocessor of the node can be determined based on the scheduling strategy, and then through the task parallel environment between nodes, the tasks in the DAG task model can be assigned to the task launch queue of the corresponding node based on the mapping relationship, and then through the task parallel environment within the node, the tasks in the task launch queue can be assigned to the corresponding processor.
[0042] Therefore, by calling the operator library and OpenMP parallel statements, calling the MPI API and OpenMP API in the main program, and configuring the scheduling strategy, it is possible to quickly build parallel applications, assist parallel application task developers to develop efficiently, and effectively improve the development efficiency of parallel applications in heterogeneous systems.
[0043] At the same time, the MPI inter-process communication mechanism is used to realize cross-node task parallelism and data transmission, and OpenMP and OpenCL technologies are used to give full play to the computing resources inside the coprocessor, providing effective support for the development of parallel applications on large-scale heterogeneous systems.
[0044] The following is an illustrative description of the method for developing parallel applications for heterogeneous systems provided by the present application with reference to several examples.
[0045] The heterogeneous system parallel application development method provided in the present application can specifically be an MPI+OpenMP+OpenCL heterogeneous system parallel application development process based on the collaborative development mode, and the parallel programming model MPI+OpenMP+OpenCL hybrid programming (MPCL for short) is used to realize application development on large-scale heterogeneous systems. Specifically, MPI is used between nodes to provide an inter-process communication mechanism to realize parallelism, synchronization and data transmission between tasks. OpenMP threads are used inside the node to manage the task queues, launch queues, and recycling queues of multiple types of coprocessors in the CPU-side parallel task scheduling framework to realize task parallelism within the node. The loading of the coprocessor kernel task within the node is realized by the OpenCL heterogeneous parallel programming framework. The kernel function allocates computing resources within the device based on the OpenCL programming specification, and data parallelism is realized within the device, wherein the runtime management is maintained by the OpenMP thread and the OpenCL runtime library.
[0046] The collaborative development model proposed in this application divides the main body of application development on heterogeneous systems into Task_Developer (task developer) and System_Developer (system developer) and designs the structure of the MPCL heterogeneous parallel programming framework based on the collaborative development model, including the application development layer, the heterogeneous system layer, and the runtime support layer. Specifically, the application development layer mainly provides encapsulated parallel operation sets, typical algorithm operators, scheduling optimization strategy configurations, etc. in the form of programming interfaces to hide the details of the hardware structure of the heterogeneous system and ignore the complex implementation of various optimization solutions, so that Task_Developer can focus on the development and implementation of applications for tasks. In the heterogeneous system layer, System_Developer implements interface encapsulation for typical parallel operations, typical algorithm operators, scheduling strategy configurations, etc., while ignoring various complex mathematical relationships called by the upper layer. The runtime support layer provides various runtime scheduling strategies, device runtime task loading and unloading, data exchange and resource collaboration between devices, and load balancing between and within nodes.
[0047] There are five key components involved in building parallel applications for heterogeneous systems.
[0048] (1) Introduce two types of development entities: Task_Developer and System_Developer. Task_Developer is responsible for the design and writing of task applications, while System_Developer is responsible for optimizing the resource usage of heterogeneous systems, designing and adapting task schedulers, and improving development efficiency.
[0049] (2) When the program is running, the parallel application is converted into an abstract DAG task model based on the compilation tool, and real-time task scheduling is performed through the runtime support layer to improve the efficiency and flexibility of task execution.
[0050] (3) Task_Developer implements inter-node parallelism based on the MPI library, and builds a task parallel scheduling framework (transmission queue, management queue, recycling queue, etc.) within a node by deriving threads through OpenMP command statements, thereby making full use of multi-node, multi-coprocessor, and multi-core computing resources. Task_Developer can define task parallel operation types through simple data structures and OpenMP statements, and configure simple parameters to define task parallel scheduling strategies. The scheduler and parallel task scheduling framework in the runtime support layer perform scheduling optimization based on user configuration to achieve efficient task scheduling and resource utilization.
[0051] (4) System_Developer allocates host and device memory based on the OpenCL heterogeneous parallel programming framework for coprocessors such as GPU, NPU, DSP, and FPGA, writes kernel code, encapsulates classic algorithm operator libraries, and designs heterogeneous system schedulers. Task_Developer implements the definition of task nodes by calling APIs, and System_Developer configures data parallelism within coprocessor devices based on algorithm characteristics, and implements high-parallel computing task execution in different coprocessor devices.
[0052] (5) Design a task scheduler for parallel applications in heterogeneous systems to achieve the mapping of task nodes to coprocessors in the DAG task model, and adapt to various configurable scheduling strategies to efficiently implement task scheduling. Maintain and implement the components and databases required for the relevant scheduler.
[0053] Figure 2 This is the overall architecture diagram of the parallel programming framework provided by the embodiment of the present application, such as Figure 2 As shown, the development model of the hierarchical hardware model of the heterogeneous system architecture is divided into three layers, namely, the application development layer, the heterogeneous system layer, and the runtime support layer.
[0054] Exemplarily, a heterogeneous collaborative parallel development process based on MPI, OpenMP, and OpenCL proposed in this application includes the following steps 1 to 5.
[0055] Step 1: Introduce two types of development entities: Task_Developer and System_Developer. Figure 3As shown in Figure 1, the task developer is responsible for the design and implementation of the task application, ensuring that it meets the functional and performance requirements. This includes writing efficient code, managing dependencies, and integrating various components into a complete application.
[0056] System Developers focus on optimizing resource usage of heterogeneous systems, designing and adapting Task Schedulers to efficiently allocate and manage system resources (such as CPU, GPU, and memory). By optimizing the interaction between the hardware and software layers, the overall performance and development efficiency of the system are improved, ensuring that the system does not experience performance degradation when processing multiple tasks at the same time.
[0057] like Figure 4 As shown, a heterogeneous system is usually composed of one or more computing nodes, and a computing node in a heterogeneous system is usually composed of a general-purpose processor (general-purpose multi-core CPU, etc.) and a coprocessor. The coprocessor can specifically be a GPU, NPU, DSP or FPGA, etc.
[0058] Step 2: Task_Developer initializes the inter-node processes and configures related parameters according to the current number of computing nodes (configured in the main program .c file), and then initializes the intra-node threads and configures related parameters according to the number of coprocessor devices inside the node (configured in the main program .c file).
[0059] like Figure 5 As shown, specifically, the first layer is inter-node parallelism, where nodes complete process-level parallelism by calling the MPI library. MPI (Message Passing Interface) is a widely used parallel programming interface that aims to achieve communication between multiple processes through message passing. The specific sub-steps are as follows.
[0060] MPI initialization: Call the MPI_Init function to initialize the MPI environment and set the number of processes and communication domain.
[0061] Process division and task allocation: According to the characteristics of the computing task and the computing power of each node, the tasks are reasonably divided and assigned to each node. The data is distributed to each computing node through the MPI_Scatter function.
[0062] Task synchronization and data transmission: During the calculation process, the MPI_Barrier function is used to synchronize tasks between nodes, ensuring that each node starts or ends tasks at the same time. The MPI_Send and MPI_Recv functions are used to transmit data, ensuring data exchange and collaborative work between nodes.
[0063] MPI environment release: After the calculation is completed, call the MPI_Finalize function to release the MPI environment and end the parallel calculation.
[0064] The second layer is the parallelism between computing devices within the node. Each process derives a group of threads through the OpenMP instruction command to build a parallel scheduling framework for tasks during runtime within the node, such as Figure 5 As shown in the figure, since each node has four different heterogeneous computing resources, the four cores of the CPU are designated as control cores. Each MPI process first generates four OpenMP threads (called management threads), which are deployed and run on four CPU cores respectively. Four of the threads are deployed on four CPU cores to manage and use the GPU, NPU, DSP, and FPGA inside the node through the OpenCL programming interface. Each thread implements the acquisition of the corresponding coprocessor platform and device, and the creation of context and command queues. These four management threads dynamically receive the DAG graph task nodes without pre-dependencies in the task launch queue in the runtime support layer, and assign the computing tasks to the GPU, NPU, DSP, and FPGA for parallel execution.
[0065] like Figure 6 As shown, the task emission queue provides tasks to the corresponding management queue (implemented by management threads), the management queue allocates tasks to the corresponding coprocessor for processing, and the recycling queue (implemented by threads) recycles the memory of completed tasks.
[0066] Task_Developer writes code for task applications, calls the API and OpenMP parallel statements in the classic algorithm operator library based on OpenCL encapsulation to describe the serial and parallel relationship between tasks, and defines the task description file .omp file, whose content includes but is not limited to information such as data flow, control flow, and parallel relationship between task nodes. The scheduling of each task node among various coprocessors is based on Task_Developer calling the relevant configuration API in the main program to build the task parallel environment between nodes and within nodes and configure different scheduling strategy parameters to be implemented in the runtime support layer.
[0067] Step 3: Based on the task description file .omp written in step 2 and the configuration of the parallel task scheduling framework in the main program .c, call the function in the main program .c file to parse the .omp file and convert the parallel application into an abstract DAG (Directed Acyclic Graph) task model. The parallel operations of the application are abstracted as nodes. , abstracting data dependencies into edges ,in and They represent task nodes respectively. Indicates the task and Generate DAG task model ,in is a set of nodes, is a set of edges. The goal of task scheduling is to minimize the total execution time , total execution time It is expressed by the following formula: ; in Represents a task node The execution function is called in the main program to implement the real-time operation and processing of the DAG graph task model in the parallel task scheduling framework of the runtime support layer, and by optimizing the DAG scheduling strategy, the efficiency of task scheduling and execution is improved while ensuring the smooth execution of tasks. Specifically, for ordinary serial tasks, typical parallel tasks, typical seismic data analysis tasks, and astronomical image calculation tasks, serial.omp, parallel.omp, Cybershake.omp, and Motage.omp task description files can be written accordingly. The runtime parsing DAG graph is as follows Figure 7-10 shown.
[0068] Step 4: Based on a heterogeneous collaborative parallel development process based on MPI, OpenMP, and OpenCL proposed in this application, the content that needs to be developed for System_Developer is to encapsulate the relevant algorithm operators according to different tasks. This application is designed based on the OpenCL heterogeneous programming framework for the programming framework in the process of operator encapsulation for System_Developer. In order to realize that the encapsulated operator function can be dynamically executed on different coprocessors, a heterogeneous system layer operator function programming framework is designed based on the OpenCL platform model, execution model, kernel programming model, and memory model. Based on the operator file written by the above System_Developer, the dynamic link library (Shared Library) mechanism provided by the C programming language is used to embed the OpenCL kernel code into the dynamic library, provide the corresponding API for the upper layer to call, and realize the compilation of the function operator into a dynamic library file (.so). The underlying details of the OpenCL API are hidden through the encapsulation of the dynamic library, and a more advanced and easier-to-use function interface is provided for the upper layer to call. And add functions such as error handling and performance optimization in the dynamic library to realize the modularization and reuse of computing tasks and provide development efficiency for upper-level applications.
[0069] Step 5: System_Developer designs a task scheduler to implement the mapping of task nodes to coprocessors in the DAG task model. The task scheduler determines the priority of each task in the DAG model based on the inverse topological sorting. When assigning the coprocessor mapping relationship to each task, it determines the worst execution time (WCET) of the current task on each processor based on the coprocessor worst execution time database, and monitors the number of tasks executed in each coprocessor in the current heterogeneous system to determine the worst waiting time after the current task is mapped to each coprocessor. The sum of the two is the worst response time (WCRT) of the current processing task mapped to each coprocessor. Different mapping relationship selections are implemented based on different scheduling strategies (global scheduling, group scheduling). The coprocessor worst execution time database predicts offline WCET for deterministic tasks in the embedded task environment, and completes the filling of the coprocessor worst execution time database. At this point, the mapping relationship from the DAG task model to the coprocessor is realized, and the process automatically follows the scheduling strategy algorithm, decoupled from the specific task type, and realizes efficient heterogeneous parallel application development.
[0070] As for filling the coprocessor worst execution time database, specifically, for various types of tasks, tasks are provided to the coprocessor, and the execution time of the coprocessor is tested to determine the worst execution time for the coprocessor to handle tasks of a specified type, and the worst execution time of the specified type of tasks is filled into the coprocessor worst execution time database.
[0071] The heterogeneous system parallel application development device provided by the present application is described below. The heterogeneous system parallel application development device described below and the heterogeneous system parallel application development method described above can be referenced to each other.
[0072] The present application provides a device for developing parallel applications for heterogeneous systems, including: a task description file generation module and a main program configuration module. The task description file generation module is used to generate a task description file by calling the operator library and the OpenMP parallel statement. The operator library is based on the OpenCL encapsulation. The task description file is used to represent the relationship between each task and different tasks. The algorithm used by the task is obtained by calling the API of the operator library, and the parallel operation of the task is constructed by calling the OpenMP parallel statement. The main program configuration module is used to build a task parallel environment between nodes through the MPI API, build a task parallel environment within a node through the OpenMP API, configure the scheduling strategy, and configure the parsing function of the task description file in the main program; The parallel application includes a task description file and a main program. The parsing function is used to parse the task description file and convert it into a DAG task model. The scheduling strategy is used to instruct the task scheduler to determine the mapping relationship between each task in the DAG task model and the coprocessor of the node.
[0073] It can be understood that the detailed functional implementation of each of the above-mentioned units / modules can be found in the introduction of the aforementioned method embodiment, and will not be repeated here.
[0074] It should be understood that the above-mentioned device is used to execute the method in the above-mentioned embodiment. The implementation principle and technical effect of the corresponding program module in the device are similar to those described in the above-mentioned method. The working process of the device can refer to the corresponding process in the above-mentioned method, which will not be repeated here.
[0075] Based on the method in the above embodiment, an embodiment of the present application provides an electronic device, Fig.11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Fig.11 As shown, the electronic device may include: a processor (Processor) 810, a communication interface (Communications Interface) 820, a memory (Memory) 830 and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 can call the logic instructions in the memory 830 to execute the method in the above embodiment.
[0076] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0077] Based on the method in the above embodiment, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program runs on a processor, the processor executes the method in the above embodiment.
[0078] Based on the method in the above embodiment, an embodiment of the present application provides a computer program product. When the computer program product runs on a processor, the processor executes the method in the above embodiment.
[0079] It is understandable that the processor in the embodiment of the present application may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0080] The method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0081] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
[0082] It should be understood that the various numerical numbers involved in the embodiments of the present application are only used for the convenience of description and are not used to limit the scope of the embodiments of the present application.
[0083] It will be easily understood by those skilled in the art that the above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for developing parallel applications in heterogeneous systems, characterized in that: include: By calling the operator library and OpenMP parallel statements, a task description file is generated. The operator library is based on the OpenCL encapsulation. The task description file is used to represent the relationship between each task and different tasks. The algorithm used by the task is obtained by calling the operator library API, and the parallel operation of the task is constructed by calling the OpenMP parallel statement. In the main program, build the task parallel environment between nodes through the MPI API, build the task parallel environment within the node through the OpenMP API, configure the scheduling strategy, and configure the parsing function of the task description file; The parallel application includes a task description file and a main program. The parsing function is used to parse the task description file and convert it into a DAG task model. The scheduling strategy is used to instruct the task scheduler to determine the mapping relationship between each task in the DAG task model and the coprocessor of the node.
2. The method for developing parallel applications for heterogeneous systems according to claim 1, characterized in that: The task parallel environment between nodes is built through the MPI API, including: Create management processes corresponding to each node through the MPI API; Among them, different management processes communicate through message passing, and based on the mapping relationship between each task in the DAG task model and the coprocessor of the node, the tasks in the DAG task model are allocated to the task emission queue of the corresponding node.
3. The method for developing parallel applications for heterogeneous systems according to claim 2, characterized in that: The task parallel environment in the node is established by using the OpenMP API, including: Through the OpenMP API, create management threads corresponding to each coprocessor in the node; The management thread in the node is used to receive tasks from the task launch queue of the node based on the mapping relationship between each task and the coprocessor of the node in the DAG task model, and allocate the tasks to the corresponding coprocessor.
4. The method for developing parallel applications for heterogeneous systems according to claim 1, characterized in that: Also includes: Generate operator files based on OpenCL; The dynamic link library mechanism of the C programming language is used to compile the operator file into a dynamic library file. The algorithm of the corresponding operator file can be obtained by calling the API provided by the dynamic library file. The operator library includes dynamic library files corresponding to each operator file.
5. The method for developing parallel applications for heterogeneous systems according to any one of claims 1 to 4, characterized in that: The scheduling strategy is specifically used to indicate a candidate processor set corresponding to each task, the candidate processor set is composed of all or part of the coprocessors on the specified node, and the task scheduler selects a coprocessor from the candidate processor set corresponding to the task to execute the task; Determining the mapping relationship between each task in the DAG task model and the coprocessor of the node includes: Based on the priority of each task, determine the current task to be scheduled. The priority of each task is determined by performing inverse topological sorting on each task in the DAG task model; Based on the scheduling strategy, determine a set of candidate processors corresponding to the task currently to be scheduled; For the coprocessors in the candidate processor set corresponding to the task to be scheduled currently, estimate the worst response time after the task to be scheduled currently is mapped to each coprocessor; A coprocessor with the shortest worst response time is determined to execute the task currently to be scheduled.
6. The method for developing parallel applications for heterogeneous systems according to claim 5, characterized in that: The estimating the worst response time of the current task to be scheduled after being mapped to each coprocessor in the candidate processor set corresponding to the current task to be scheduled includes: For the coprocessors in the candidate processor set corresponding to the task to be scheduled currently, by monitoring the number of tasks executed by each coprocessor, the worst waiting time after the task to be scheduled currently is mapped to each coprocessor is estimated; For the coprocessors in the candidate processor set corresponding to the current task to be scheduled, the worst response time after the current task to be scheduled is mapped to each coprocessor is estimated based on the worst execution time and the worst waiting time. The worst execution time is obtained by testing the task on the coprocessor in advance.
7. A device for developing parallel applications in heterogeneous systems, characterized in that: include: The task description file generation module is used to generate a task description file by calling the operator library and the OpenMP parallel statement. The operator library is based on the OpenCL encapsulation. The task description file is used to represent the relationship between each task and different tasks. The algorithm used by the task is obtained by calling the API of the operator library, and the parallel operation of the task is constructed by calling the OpenMP parallel statement. The main program configuration module is used to build a task parallel environment between nodes through the MPI API, build a task parallel environment within a node through the OpenMP API, configure the scheduling strategy, and configure the parsing function of the task description file in the main program; The parallel application includes a task description file and a main program. The parsing function is used to parse the task description file and convert it into a DAG task model. The scheduling strategy is used to instruct the task scheduler to determine the mapping relationship between each task in the DAG task model and the coprocessor of the node.
8. An electronic device, characterized in that: include: at least one memory for storing a computer program; At least one processor is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program runs on a processor, the processor is caused to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that When the computer program product runs on a processor, the processor is caused to execute the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Seismic processing multi-core heterogeneous parallel mode adaptive matching general computation module
CN104572256A
A construction method of a software radar cross-platform universal parallel computing library
CN109947416A
Quantum computing simulation principle verification method based on high-performance heterogeneous cluster
CN114462612A
Heterogeneous architecture parallel programming model optimization system
CN117032647A
The method of designing parallel embedded software with common intermediate code
KR1020080066402A
Cited By
Parallel application development method for heterogeneous system
WO2026144647A1