A Parallel Application Development Method for Heterogeneous Systems
By calling operator libraries and OpenMP parallel statements to generate task description files in heterogeneous systems, building a parallel environment using MPI and OpenMP APIs, and optimizing task scheduling with OpenCL technology, the problem of low efficiency in parallel application development in heterogeneous systems is solved, and efficient task scheduling and resource utilization are achieved.
Patent Information
- Application Number
- CN202510017555.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-06
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-01-06
AI Technical Summary
How to improve the development efficiency of parallel applications in heterogeneous systems, facing the challenges of complex system architectures and multiple programming standards, especially the parallelism development and resource scheduling of large-scale heterogeneous systems.
Task description files are generated by calling operator libraries and OpenMP parallel statements. A task parallel environment is built using MPI and OpenMP APIs. OpenCL technology is combined to achieve cross-node and intra-node task parallelism and data transmission. A scheduling strategy is adopted to optimize task mapping and construct a DAG task model to achieve efficient task scheduling and resource utilization.
It significantly improves the development efficiency of parallel applications on heterogeneous systems, simplifies the user development process, enhances the flexibility and efficiency of task scheduling, and realizes efficient parallel computing on heterogeneous systems.
Smart Images

Figure CN119806493B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and more specifically, relates to a method for developing parallel applications for heterogeneous systems. Background Technology
[0002] With the continuous development of science and technology, high-performance computing has penetrated into fields such as quantum physics, weather forecasting, climate research, oil and gas exploration, and biopharmaceuticals. To meet this demand, the design philosophy of high-performance computing systems is undergoing profound changes with the rapid advancement of technology. Because single-core scalar processors face bottlenecks in frequency increases and instruction-level parallelism due to power consumption limitations, the architecture of high-performance computing systems is gradually evolving towards multi-core parallel computing in heterogeneous systems. A heterogeneous system refers to a computing system composed of processors with different functions or performance characteristics, each specializing in a different domain, connected through a specific interconnect structure. Currently popular heterogeneous systems typically consist of one or more computing nodes. A computing node in a heterogeneous system usually consists of a general-purpose processor (such as a general-purpose multi-core CPU) and a coprocessor. The coprocessor can specifically be a Graphics Processing Unit (GPU), a Neural Processing Unit (NPU), a Digital Signal Processor (DSP), or a Field-Programmable Gate Array (FPGA), etc. Heterogeneous systems based on this architecture can, on the one hand, rely on general-purpose processors to provide general computing capabilities to handle various types of applications, and on the other hand, utilize coprocessors to accelerate applications in specific fields, achieving high performance with lower power consumption.
[0003] However, while heterogeneous systems achieve high computational performance, leveraging this performance in practical applications remains a significant challenge. On one hand, the increasing scale of heterogeneous systems places higher demands on applications themselves. Developing tasks with unprecedented parallelism to utilize the vast number of computing cores in heterogeneous systems presents a tremendous challenge for users. On the other hand, heterogeneous systems possess complex structures, with various computing devices each having different system architectures, instruction sets, and programming models. Users need to master multiple different and complex programming standards, which greatly increases the burden of application development. How to effectively improve the development efficiency of parallel applications on heterogeneous systems is a pressing technical problem that needs to be solved in this field. Summary of the Invention
[0004] In view of the shortcomings of the existing technology, the purpose of this application is to effectively improve the development efficiency of parallel applications for heterogeneous systems.
[0005] To achieve the above objectives, in a first aspect, this application provides a method for developing parallel applications for heterogeneous systems, the method comprising:
[0006] By calling the operator library and OpenMP parallel statements, a task description file (.omp file) is generated. The operator library is based on OpenCL and is used to represent the relationships between various tasks and different tasks (including but not limited to information such as data flow, control flow, and parallel relationships 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 OpenMP parallel statements.
[0007] In the main program (.c file), an inter-node task parallel environment (implemented by multiple processes) is built using the MPI API, and an intra-node task parallel environment (implemented by multiple threads) is built using the OpenMP API. The scheduling strategy and the parsing function for the task description file are also configured.
[0008] 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 policy is used to instruct the task scheduler to determine the mapping relationship between each task and the coprocessor of the node in the DAG task model.
[0009] The inter-node task parallel environment is used to allocate tasks in the DAG task model to the task launch queue of the corresponding node based on the mapping relationship, while the intra-node task parallel environment is used to allocate tasks in the task launch queue to the corresponding coprocessor based on the mapping relationship.
[0010] It is understandable that by calling operator libraries and OpenMP parallel statements, as well as by calling MPI APIs and OpenMP APIs in the main program and configuring scheduling strategies, parallel applications can be built quickly, assisting parallel application task developers in efficient development and effectively improving the development efficiency of parallel applications for heterogeneous systems.
[0011] Meanwhile, the MPI inter-process communication mechanism is used to achieve cross-node task parallelism and data transmission, and OpenMP and OpenCL technologies are adopted to fully utilize the internal computing resources of the coprocessor, providing effective support for the development of parallel applications on large-scale heterogeneous systems.
[0012] In one possible implementation, the above-mentioned method of building a task-parallel environment between nodes using the MPI API includes:
[0013] Create management processes for each node using the MPI API;
[0014] In this process, different management processes communicate through message passing, and based on the mapping relationship between each task and the coprocessor of the node in the DAG task model, the tasks in the DAG task model are assigned to the task launch queue of the corresponding node.
[0015] In one possible implementation, the above-mentioned construction of an in-node task parallelization environment via the OpenMP API includes:
[0016] Using the OpenMP API, management threads corresponding to each coprocessor are created in the node;
[0017] 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 to allocate the tasks to the corresponding coprocessors.
[0018] One possible implementation also includes:
[0019] Operator files are generated based on OpenCL;
[0020] The C programming language's dynamic link library mechanism is used to compile operator files into dynamic library files. By calling the APIs provided by the dynamic library files, the algorithm of the corresponding operator file can be obtained.
[0021] The operator library includes the dynamic library files corresponding to each operator file.
[0022] In one possible implementation, the scheduling policy is specifically used to indicate the set of candidate coprocessors corresponding to each task. The set of candidate coprocessors consists of all or part of the coprocessors on the specified node. The task scheduler selects a coprocessor from the set of candidate coprocessors corresponding to the task.
[0023] The above-mentioned determination of the mapping relationship between each task and the coprocessor of each node in the DAG task model includes:
[0024] Based on the priority of each task, the task to be scheduled is determined. The priority of each task is determined by performing an inverse topological sort on each task in the DAG task model.
[0025] Based on the scheduling policy, determine the set of candidate processors corresponding to the currently scheduled task;
[0026] For each coprocessor in the set of candidate processors corresponding to the currently scheduled task, estimate the worst-case response time after the currently scheduled task is mapped to each coprocessor.
[0027] The coprocessor with the shortest worst-case response time is selected to execute the current task.
[0028] For example, the scheduling strategy can be global scheduling, group scheduling, etc. Global scheduling specifically involves the set of candidate coprocessors for each task consisting of all coprocessors on all nodes. Group scheduling specifically involves grouping tasks, with the set of candidate coprocessors for tasks within the same group consisting of a subset of coprocessors on designated nodes.
[0029] In a Directed Acyclic Graph (DAG), inverse topological sorting refers to arranging the task nodes in the DAG task model in a certain order, such that for every directed edge (u, v), u always appears before v in the sequence. The result of inverse topological sorting can be used to determine the execution order of tasks. Inverse topological sorting is typically implemented using depth-first search (DFS).
[0030] In one possible implementation, the above-mentioned estimation of the worst-case response time of the currently scheduled task after mapping to each coprocessor in the set of candidate processors corresponding to the current task to be scheduled includes:
[0031] For the coprocessors in the set of candidate processors corresponding to the currently scheduled task, the worst-case waiting time after the currently scheduled task is mapped to each coprocessor is estimated by monitoring the number of tasks executed by each coprocessor.
[0032] For the coprocessors in the set of candidate processors corresponding to the currently scheduled task, the worst response time (the sum of the worst execution time and the worst waiting time) after the currently scheduled task 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.
[0033] Secondly, this application provides a heterogeneous system parallel application development apparatus, comprising:
[0034] The task description file generation module is used to generate task description files by calling the operator library and OpenMP parallel statements. The operator library is based on OpenCL and the task description file is used to represent the relationships between 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 OpenMP parallel statements.
[0035] 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 scheduling strategies, and configure the parsing function for task description files in the main program.
[0036] 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 policy is used to instruct the task scheduler to determine the mapping relationship between each task and the coprocessor of the node in the DAG task model.
[0037] Thirdly, this application provides an electronic device, comprising: at least one memory for storing a program; and at least one processor for executing the program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to execute the method described in the first aspect or any possible implementation thereof.
[0038] Fourthly, this application provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.
[0039] Fifthly, this application provides a computer program product that, when run on a processor, causes the processor to perform the method described in the first aspect or any possible implementation thereof.
[0040] It is understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here.
[0041] Overall, the technical solutions conceived in this application have the following beneficial effects compared with the prior art:
[0042] (1) Through the hybrid programming model MPI+OpenMP+OpenCL, MPI is used to provide inter-process communication mechanism between nodes, OpenMP is used to manage the parallel task scheduling framework of multiple coprocessors within the node, and OpenCL is used to load coprocessor kernel tasks and allocate computing resources, which can realize the parallel and efficient execution of tasks on large-scale heterogeneous systems.
[0043] (2) The main body of application development on heterogeneous systems is 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. This model standardizes the development process of parallel applications on heterogeneous systems and significantly improves the overall development efficiency.
[0044] (3) Users can convert parallel applications into DAG task models by calling OpenCL kernel operators to write task description files, and perform real-time task scheduling and parsing at runtime, thereby improving the flexibility of task scheduling and execution efficiency.
[0045] (4) By decoupling task scheduling from application development programs, it is not necessary to design different schedulers for different application development programs, thus achieving fully automatic mapping from heterogeneous parallel applications to heterogeneous processor coprocessors. Attached Figure Description
[0046] Figure 1 This is a flowchart illustrating the heterogeneous system parallel application development method provided in the embodiments of this application;
[0047] Figure 2 This is a diagram illustrating the overall architecture of the parallel programming framework provided in this application embodiment;
[0048] Figure 3 This is a schematic diagram of collaborative development of the parallel programming framework provided in the embodiments of this application;
[0049] Figure 4 This is a schematic diagram of the heterogeneous system structure provided in the embodiments of this application;
[0050] Figure 5 This is a schematic diagram of the task parallel environment provided in the embodiments of this application;
[0051] Figure 6 This is a schematic diagram of the runtime task scheduling framework provided in the embodiments of this application;
[0052] Figure 7 This is the DAG graph parsed during runtime by a normal serial task provided in the embodiments of this application;
[0053] Figure 8 This is a DAG graph parsed at runtime for a typical parallel task provided in the embodiments of this application;
[0054] Figure 9 This is a DAG diagram obtained by parsing a typical seismic data analysis task during runtime, as provided in the embodiments of this application.
[0055] Figure 10 This is a DAG diagram obtained by parsing the astronomical image calculation task provided in this application during runtime;
[0056] Figure 11 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0058] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0059] In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more, for example, multiple processing units means two or more processing units, multiple elements means two or more elements, etc.
[0060] First, the technical terms involved in the embodiments of this application will be introduced.
[0061] (1) MPI (Message Passing Interface): Used to implement inter-node communication, 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, suitable for applications requiring high performance and scalability.
[0062] (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, which mainly achieves multi-threaded parallel computing through compiler instructions, library routines, and environment variables. It allows developers to easily insert parallelization instructions into existing serial code, thereby utilizing the computing power of multi-core CPUs. OpenMP is suitable for applications that require parallel processing on a single node, such as numerical computation, image processing, and data analysis, and can significantly improve program execution efficiency.
[0063] (3) OpenCL (Open Computing Language): Used to implement parallel computing on devices such as GPUs and FPGAs in heterogeneous systems. OpenCL is a framework for heterogeneous computing that allows developers to write parallel programs on various 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 to perform efficient data parallel processing.
[0064] The embodiments of this application are described below with reference to the accompanying drawings.
[0065] Figure 1 This is a flowchart illustrating the heterogeneous system parallel application development method provided in the embodiments of this application, such as... Figure 1 As shown, the method includes the following steps S101 and S102.
[0066] Step S101: By calling the operator library and OpenMP parallel statements, a task description file (.omp file) is generated. The operator library is based on OpenCL and the task description file is used to represent the relationships between various tasks and different tasks (including but not limited to information such as data flow, control flow, and parallel relationships 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 OpenMP parallel statements.
[0067] Step S102: In the main program (.c file), a task parallel environment between nodes is built using the MPI API (implemented by multiple processes), a task parallel environment within a node is built using the OpenMP API (implemented by multiple threads), a scheduling strategy is configured, and a function for parsing task description files is configured.
[0068] 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 policy is used to instruct the task scheduler to determine the mapping relationship between each task and the coprocessor of the node in the DAG task model.
[0069] This section provides an example of a task parallel environment. The inter-node task parallel environment is used to allocate tasks in the DAG task model to the task launch queue of the corresponding node based on the mapping relationship. The intra-node task parallel environment is used to allocate tasks in the task launch queue to the corresponding coprocessor based on the mapping relationship.
[0070] This section provides an illustrative example of a scheduling strategy. Specifically, the scheduling strategy indicates the set of candidate coprocessors corresponding to each task. This set consists of all or some of the coprocessors on a specified node. The task scheduler selects a coprocessor from this set of candidate coprocessors corresponding to a task. Accordingly, determining the mapping relationship between each task and the coprocessor of a node in the DAG task model includes:
[0071] Based on the priority of each task, the task to be scheduled is determined. The priority of each task is determined by performing an inverse topological sort on each task in the DAG task model.
[0072] Based on the scheduling policy, determine the set of candidate processors corresponding to the currently scheduled task;
[0073] For each coprocessor in the set of candidate processors corresponding to the currently scheduled task, estimate the worst-case response time after the currently scheduled task is mapped to each coprocessor.
[0074] The coprocessor with the shortest worst-case response time is selected to execute the current task.
[0075] For example, the scheduling strategy can be global scheduling, group scheduling, etc. Global scheduling specifically involves the set of candidate coprocessors for each task consisting of all coprocessors on all nodes. Group scheduling specifically involves grouping tasks, with the set of candidate coprocessors for tasks within the same group consisting of a subset of coprocessors on designated nodes.
[0076] Furthermore, the above-mentioned estimation of the worst-case response time of the coprocessors in the candidate processor set corresponding to the currently scheduled task, after mapping the task to each coprocessor, includes:
[0077] For the coprocessors in the set of candidate processors corresponding to the currently scheduled task, the worst-case waiting time after the currently scheduled task is mapped to each coprocessor is estimated by monitoring the number of tasks executed by each coprocessor.
[0078] For the coprocessors in the set of candidate processors corresponding to the currently scheduled task, the worst response time (the sum of the worst execution time and the worst waiting time) after the currently scheduled task 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.
[0079] It is understandable that parallel applications include task description files and main programs. By calling the API of the operator library, the algorithms required for the task can be obtained, and by calling OpenMP parallel statements, the parallel operations of the task can be constructed. Therefore, by calling the operator library and OpenMP parallel statements, task description files can be generated quickly.
[0080] Furthermore, the main program (.c file) configures the task parallel environment, scheduling policy, and parsing function for the task description file. The parsing function parses the task description file, converting it into a DAG task model. Then, the task scheduler determines the mapping relationship between each task in the DAG task model and the coprocessors of the nodes based on the scheduling policy. Next, the inter-node task parallel environment allocates tasks in the DAG task model to the corresponding node's task launch queue based on the mapping relationship. Finally, the intra-node task parallel environment allocates tasks in the task launch queue to the corresponding processor.
[0081] Therefore, by calling the operator library and OpenMP parallel statements, as well as by calling the MPI API and OpenMP API in the main program and configuring the scheduling strategy, parallel applications can be built quickly, assisting parallel application task developers in efficient development and effectively improving the development efficiency of parallel applications for heterogeneous systems.
[0082] Meanwhile, the MPI inter-process communication mechanism is used to achieve cross-node task parallelism and data transmission, and OpenMP and OpenCL technologies are adopted to fully utilize the internal computing resources of the coprocessor, providing effective support for the development of parallel applications on large-scale heterogeneous systems.
[0083] The following examples illustrate the parallel application development method for heterogeneous systems provided in this application.
[0084] The heterogeneous system parallel application development method provided in this application can be specifically a heterogeneous system parallel application development process based on a collaborative development model of MPI+OpenMP+OpenCL. It adopts a parallel programming model of MPI+OpenMP+OpenCL hybrid programming (MPCL for short) to realize application development on large-scale heterogeneous systems. Specifically, MPI is used between nodes to provide inter-process communication mechanisms, enabling parallelism, synchronization, and data transmission between tasks. Inside each node, OpenMP threads manage the task queues, issue queues, and reclaim queues of multiple coprocessors in the CPU-side parallel task scheduling framework to achieve task parallelism within the node. The loading of coprocessor kernel tasks within the node is implemented by the OpenCL heterogeneous parallel programming framework. The kernel functions allocate computing resources within the device based on the OpenCL programming specification, achieving data parallelism within the device. Runtime management is maintained by OpenMP threads and the OpenCL runtime library.
[0085] This application proposes a collaborative development model that divides the main entities developing applications on heterogeneous systems into Task Developers and System Developers. It also designs the structure of an MPCL heterogeneous parallel programming framework based on this collaborative development model, including an application development layer, a heterogeneous system layer, and a runtime support layer. Specifically, the application development layer primarily provides encapsulated sets of parallel operations, typical algorithm operators, and scheduling optimization strategy configurations through programming interfaces. This hides the hardware structure details of the heterogeneous system and ignores the complex implementations of various optimization schemes, allowing Task Developers to focus on developing and implementing applications for specific tasks. In the heterogeneous system layer, System Developers encapsulate interfaces for typical parallel operations, typical algorithm operators, and scheduling strategy configurations, while ignoring the complex mathematical relationships involved in upper-layer calls. The runtime support layer provides implementations for various runtime scheduling strategies, task loading and unloading at device runtime, data exchange and resource coordination between devices, and load balancing between and within nodes.
[0086] The following five key parts are involved in building parallel applications for heterogeneous systems.
[0087] (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.
[0088] (2) When the program runs, 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.
[0089] (3) Task_Developer implements inter-node parallelism based on the MPI library. It constructs an intra-node task parallel scheduling framework (launch queue, management queue, reclaim queue, etc.) by deriving threads from OpenMP command statements, thereby making full use of the computing resources of multiple nodes, multiple coprocessors, and multiple cores. 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. In the runtime support layer, the scheduler and parallel task scheduling framework optimize scheduling according to user configuration to achieve efficient task scheduling and resource utilization.
[0090] (4) System_Developer allocates host and device memory, writes kernel code, encapsulates classic algorithm operator libraries, and designs heterogeneous system schedulers for coprocessors such as GPUs, NPUs, DSPs, and FPGAs based on the OpenCL heterogeneous parallel programming framework. Task_Developer defines task nodes by calling APIs, and System_Developer configures data parallelism within coprocessor devices according to algorithm characteristics, enabling high-parallelism computational task execution in different coprocessor devices.
[0091] (5) Design a heterogeneous system parallel application task scheduler to realize the mapping from task nodes to coprocessors in the DAG task model, while adapting to various configurable scheduling strategies to efficiently realize task scheduling. Maintain and implement the components and database required by the scheduler.
[0092] Figure 2 This is a diagram of the overall architecture of the parallel programming framework provided in the embodiments of this 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: application development layer, heterogeneous system layer, and runtime support layer.
[0093] For example, the heterogeneous collaborative parallel development process based on MPI, OpenMP, and OpenCL proposed in this application includes the following steps 1-5.
[0094] Step 1: Introduce two development entities: Task_Developer and System_Developer. For example... Figure 3As shown, the Task Developer is responsible for the design and implementation of the task application, ensuring it meets functional and performance requirements. This includes writing efficient code, managing dependencies, and integrating the various components into a complete application.
[0095] System developers focus on optimizing resource utilization in 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 hardware and software layers, they improve overall system performance and development efficiency, ensuring that the system does not experience performance degradation when handling multiple tasks simultaneously.
[0096] like Figure 4 As shown, a heterogeneous system typically consists of one or more computing nodes, and a computing node in a heterogeneous system typically consists of a general-purpose processor (such as a general-purpose multi-core CPU) and a coprocessor. The coprocessor can be a GPU, NPU, DSP, or FPGA, etc.
[0097] Step 2: Task_Developer initializes inter-node processes and configures relevant parameters based on the current number of compute nodes (configured in the main program .c file). Then, it initializes intra-node threads and configures relevant parameters based on the number of coprocessor devices within the node (configured in the main program .c file).
[0098] like Figure 5 As shown, specifically, the first layer is inter-node parallelism. Nodes achieve process-level parallelism by calling the MPI library. MPI (Message Passing Interface) is a widely used parallel programming interface designed to achieve communication between multiple processes through message passing. The specific sub-steps are as follows.
[0099] MPI initialization: The MPI_Init function is called to initialize the MPI environment, setting the number of processes and the communication domain.
[0100] Process partitioning and task allocation: Based on the characteristics of the computing tasks and the computing capabilities of each node, tasks are rationally partitioned and allocated to each node. Data shards are distributed to each computing node using the MPI_Scatter function.
[0101] Task Synchronization and Data Transfer: During computation, the MPI_Barrier function is used to synchronize tasks among nodes, ensuring that each node starts or ends its task at the same time. The MPI_Send and MPI_Recv functions are used to transfer data, ensuring data exchange and collaborative work among nodes.
[0102] MPI environment release: After the computation is complete, the MPI_Finalize function is called to release the MPI environment and end the parallel computation.
[0103] The second layer involves parallelism between computing devices within a node. Each process uses OpenMP to derive a set of threads from commands, constructing a runtime task parallel scheduling framework within the node, such as... Figure 5 As shown, since each node possesses four different heterogeneous computing resources, the four CPU cores are designated as control cores. Each MPI process first generates four OpenMP threads (called management threads), which are deployed and run on the four CPU cores respectively. These four threads, deployed on the four CPU cores, manage and utilize the node's internal GPU, NPU, DSP, and FPGA through the OpenCL programming interface. Each thread acquires the corresponding coprocessor platform and device, and creates the context and command queue. These four management threads dynamically receive DAG graph task nodes without pre-dependent dependencies from the task launch queue in the runtime support layer, and then distribute the computing tasks to the GPU, NPU, DSP, and FPGA for parallel execution.
[0104] like Figure 6 As shown, the task launch queue provides tasks to the corresponding management queue (implemented through a management thread), the management queue allocates tasks to the corresponding coprocessors for processing, and the reclaim queue (implemented through a thread) reclaims the memory of completed tasks.
[0105] Task_Developer is used for writing code for task applications. It calls APIs from classic algorithm operator libraries based on OpenCL and OpenMP parallel statements to describe the serial-parallel relationships between tasks. It defines task description files (.omp files), whose contents include, but are not limited to, information on data flow, control flow, and parallel relationships between task nodes. The scheduling of each task node across various coprocessors is implemented in the runtime support layer by Task_Developer's main program, which calls relevant configuration APIs to build the task parallel environment between and within nodes and configure different scheduling strategy parameters.
[0106] 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) 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 task and Data dependencies between them. Generating a DAG task model. ,in For a set of nodes, Let the set be an edge. The goal of task scheduling is to minimize the total execution time. Total execution time This can be expressed by the following formula:
[0107] ;
[0108] in Represents task nodes The end time. The main program calls the execution function to implement real-time processing of the DAG graph task model within the parallel task scheduling framework of the runtime support layer. By optimizing the DAG scheduling strategy, it ensures smooth task execution while improving the efficiency of task scheduling and execution. Specifically, for ordinary serial tasks, typical parallel tasks, typical seismic data analysis tasks, and astronomical image calculation tasks, corresponding task description files such as serial.omp, parallel.omp, Cybershake.omp, and Motage.omp can be written. Their runtime DAG graph parsing is as follows... Figure 7-10 As shown.
[0109] Step 4: Based on the heterogeneous collaborative parallel development process based on MPI, OpenMP, and OpenCL proposed in this application, the content to be developed for System_Developer involves encapsulating relevant algorithm operators according to different tasks. This application designs the programming framework for the operator encapsulation process in System_Developer based on the OpenCL heterogeneous programming framework. To enable the encapsulated operator functions to be dynamically executed on different coprocessors, a heterogeneous system-level operator function programming framework is designed based on the OpenCL platform model, execution model, kernel programming model, and memory model. Based on the operator files written in System_Developer, the OpenCL kernel code is embedded into the dynamic library using the shared library mechanism provided by the C programming language, providing corresponding APIs for upper-layer calls, and compiling the function operators into dynamic library files (.so). By encapsulating the OpenCL API in the dynamic library, the underlying details are hidden, providing a more advanced and easier-to-use function interface for upper-layer calls. Error handling and performance optimization functions are added to the dynamic library, realizing the modularization and reuse of computing tasks and improving the development efficiency of upper-layer applications.
[0110] Step 5: System_Developer designs a task scheduler to implement the mapping from task nodes to coprocessors in the DAG task model. The task scheduler determines the priority of each task in the DAG model based on inverse topological sorting. Specifically, when assigning coprocessor mapping relationships for each task, it determines the worst-case execution time (WCET) of the current task on various types of processors based on the coprocessor worst-case execution time database. It also monitors the number of tasks executing on each coprocessor in the current heterogeneous system to determine the worst-case waiting time after the current task is mapped to each coprocessor. The sum of these two factors yields the worst-case response time (WCRT) of the current task mapped to each coprocessor. Different mapping relationships are selected based on different scheduling strategies (global scheduling, group scheduling). The coprocessor worst-case execution time database is used to predict the WCET of deterministic tasks in the embedded task environment, thus filling the database. This completes the mapping relationship from the DAG task model to coprocessors, with the process fully automated and following the scheduling strategy algorithm, decoupled from specific task types, enabling efficient heterogeneous parallel application development.
[0111] Specifically, the filling of the worst execution time database for coprocessors can be done by providing tasks to the coprocessor for various types of tasks, testing the coprocessor's execution time to determine the worst execution time for the coprocessor to handle a specified type of task, and then filling the worst execution time of the specified type of task into the coprocessor's worst execution time database.
[0112] The heterogeneous system parallel application development apparatus provided in this application is described below. The heterogeneous system parallel application development apparatus described below and the heterogeneous system parallel application development method described above can be referred to in correspondence.
[0113] This application provides a heterogeneous system parallel application development device, including: a task description file generation module and a main program configuration module. Wherein:
[0114] The task description file generation module is used to generate task description files by calling the operator library and OpenMP parallel statements. The operator library is based on OpenCL and the task description file is used to represent the relationships between 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 OpenMP parallel statements.
[0115] 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 scheduling strategies, and configure the parsing function for task description files in the main program.
[0116] 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 policy is used to instruct the task scheduler to determine the mapping relationship between each task and the coprocessor of the node in the DAG task model.
[0117] It is understood that the detailed functional implementation of each of the above units / modules can be found in the description in the aforementioned method embodiments, and will not be repeated here.
[0118] It should be understood that the above-described device is used to execute the methods in the above embodiments. The implementation principle and technical effect of the corresponding program modules in the device are similar to those described in the above methods. The working process of the device can be referred to the corresponding process in the above methods, and will not be repeated here.
[0119] Based on the methods in the above embodiments, this application provides an electronic device. Figure 11 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 11 As shown, the electronic device may include a processor 810, a communications interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communications interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 can call logical instructions in the memory 830 to execute the methods in the above embodiments.
[0120] Furthermore, the logical instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0121] Based on the methods in the above embodiments, this application provides a computer-readable storage medium storing a computer program that, when run on a processor, causes the processor to execute the methods in the above embodiments.
[0122] Based on the methods in the above embodiments, this application provides a computer program product that, when run on a processor, causes the processor to execute the methods in the above embodiments.
[0123] It is understood that the processor in the embodiments of this application can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. A general-purpose processor can be a microprocessor or any conventional processor.
[0124] The method steps in this application embodiment can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which 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, portable hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from 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 reside in an ASIC.
[0125] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as 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, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).
[0126] It is understood that the various numerical designations used in the embodiments of this application are merely for the convenience of description and are not intended to limit the scope of the embodiments of this application.
[0127] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A method for developing parallel applications for 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 OpenCL and the task description file is used to represent the relationships between 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 OpenMP parallel statements. In the main program, the task parallel environment between nodes is built through the MPI API, the task parallel environment within a node is built through the OpenMP API, the scheduling strategy is configured, and the parsing function for the task description file is configured. 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 policy is used to instruct the task scheduler to determine the mapping relationship between each task and the coprocessor of the node in the DAG task model.
2. The heterogeneous system parallel application development method according to claim 1, characterized in that, The method of building a task parallelization environment between nodes through the MPI API includes: Create management processes for each node using the MPI API; In this process, different management processes communicate through message passing, and based on the mapping relationship between each task and the coprocessor of the node in the DAG task model, the tasks in the DAG task model are assigned to the task launch queue of the corresponding node.
3. The heterogeneous system parallel application development method according to claim 2, characterized in that, The process of building an in-node task parallel environment using the OpenMP API includes: Using the OpenMP API, management threads corresponding to each coprocessor are created 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 to allocate the tasks to the corresponding coprocessors.
4. The heterogeneous system parallel application development method according to claim 1, characterized in that, Also includes: Generating operator files based on OpenCL; The C programming language's dynamic link library mechanism is used to compile operator files into dynamic library files. By calling the APIs provided by the dynamic library files, the algorithm of the corresponding operator file can be obtained. 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-4, characterized in that, The scheduling strategy is specifically used to indicate the set of candidate processors corresponding to each task. The set of candidate processors consists of all or part of the coprocessors on the specified node. The task scheduler selects a coprocessor from the set of candidate processors corresponding to the task to execute the task. Determining the mapping relationship between each task and the coprocessor of each node in the DAG task model includes: Based on the priority of each task, the task to be scheduled is determined. The priority of each task is determined by performing an inverse topological sort on each task in the DAG task model. Based on the scheduling strategy, determine the set of candidate processors corresponding to the task to be scheduled. For each coprocessor in the set of candidate processors corresponding to the currently scheduled task, estimate the worst-case response time after the currently scheduled task is mapped to each coprocessor. The coprocessor with the shortest worst-case response time is selected to execute the currently scheduled task.
6. The heterogeneous system parallel application development method according to claim 5, characterized in that, The step of estimating the worst-case response time of the currently scheduled task after mapping it to each coprocessor from the set of candidate coprocessors includes: For the coprocessors in the set of candidate processors corresponding to the currently scheduled task, the worst-case waiting time after the currently scheduled task is mapped to each coprocessor is estimated by monitoring the number of tasks executed by each coprocessor. For the coprocessors in the set of candidate processors corresponding to the currently scheduled task, the worst response time after the currently scheduled task 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 heterogeneous system parallel application development device, characterized in that, include: The task description file generation module is used to generate task description files by calling the operator library and OpenMP parallel statements. The operator library is based on OpenCL and the task description file is used to represent the relationships between 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 OpenMP parallel statements. 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 scheduling strategies, and configure the parsing function for task description files 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 policy is used to instruct the task scheduler to determine the mapping relationship between each task and the coprocessor of the node in the DAG task model.
8. An electronic device, characterized in that, include: At least one memory for storing computer programs; At least one processor is configured to execute a program stored in the memory, wherein when the program stored in the memory is executed, the processor is configured to perform the method as described in any one of claims 1-6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is run on the processor, it causes the processor to perform the method as described in any one of claims 1-6.
10. A computer program product, characterized in that, When the computer program product is run on a processor, the processor causes the processor to perform the method as described in any one of claims 1-6.
Citation Information
Patent Citations
Seismic processing multi-core heterogeneous parallel mode adaptive matching general computation module
CN104572256A
Heterogeneous architecture parallel programming model optimization system
CN117032647A