A heterogeneous platform computing task scheduling method, system and application based on a machine learning algorithm
By collecting and analyzing program and hardware features on heterogeneous platforms and using machine learning algorithms for scheduling, the problems of the lack of model portability and inconvenient interfaces in existing technologies are solved, and efficient computing task scheduling and performance improvement are achieved.
Patent Information
- Application Number
- CN202411445439.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-10-16
AI Technical Summary
Existing technologies fail to fully analyze the dynamic characteristics of applications and hardware platform characteristics on heterogeneous computing platforms, resulting in a lack of portability of scheduling models and insufficient performance improvement. In addition, there is a lack of effective integration with the OpenCL runtime and an inconvenient user scheduler interface.
It uses machine learning algorithms combined with static and dynamic features of the program to collect hardware features. Through feature engineering and model training, it provides efficient scheduling strategies and extends the OpenCL API to support custom schedulers and strategies.
Improves the accuracy and performance of computing task scheduling on heterogeneous platforms, achieving a 17%-35% performance improvement, meeting the performance requirements of specific applications while maintaining compatibility with the OpenCL API.
Smart Images

Figure CN119597444B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of heterogeneous computing and performance optimization, and relates to a method, system and application for scheduling computing tasks on heterogeneous platforms based on machine learning algorithms. Background Art
[0002] Heterogeneous computing refers to a computing approach in which multiple computing units with different instruction set architectures and different architectures are combined within a single system to perform collaborative computations. The development of heterogeneous computing is driven by real-world workloads. In recent years, the global rise of next-generation artificial intelligence (AI) technologies has brought new demands and high standards for computing power. General-purpose processors (CPUs) have been widely used for many years. Researchers have addressed performance bottlenecks by increasing CPU clock speeds and the number of computing units. However, facing massive amounts of data, CPU computing power is relatively low. Graphics processing units (GPUs) are typically designed for high-performance graphics processing and general-purpose computing tasks. Their computing power is typically much higher than that of CPUs due to their greater number of parallel processing units, making them ideal for both big data and simple computations. AI-specific chips (such as NPUs and TPUs) are specifically optimized for AI applications and typically offer higher energy efficiency and computing power for AI tasks. In addition to the common chips mentioned above, there are also specialized accelerator cards and processors that can be optimized for specific domains to achieve even higher performance. By shifting away from the traditional single-architecture model and leveraging the strengths of diverse architectures, higher computing power, higher throughput, lower latency, lower energy consumption, and lower costs can be achieved. Specifically, heterogeneous platforms should be able to leverage the CPU's flexibility in general computing, combined with the GPU's high computing power and the ability of special-domain processors to handle domain-specific tasks, to rationally allocate computing resources and improve overall performance.
[0003] As early as the early 20th century, developers realized that completing general-purpose parallel computing tasks required a unified standard. OpenCL (Open Computing Language) was proposed as a framework for writing programs for heterogeneous platforms. As of July 2024, OpenCL is still widely used, and dozens of major hardware vendors, including NVIDIA, Intel, and AMD, have designed OpenCL implementations following the OpenCL standard. OpenCL's application scenarios also cover multiple fields such as high-performance computing, artificial intelligence, and image processing. Moreover, as the OpenCL specification is updated, the relevant implementations of various companies are quickly updated and released. The advantages of OpenCL lie in its cross-platform support, openness, and broad community support. In terms of cross-platform support, OpenCL can run on a variety of devices and platforms, supporting multiple types of processors including NVIDIA, Intel, and ARM, and can support parallel code running on CPUs. It also has a unique parallel task execution mode that can better support heterogeneous computing. The popularity of OpenCL is closely tied to its openness: any company can be invited to join Khronos, contributing to and influencing the development of its specifications; any company can implement the Khronos specification, and participating implementers can obtain trademark licenses for their compliant implementations; and developers are free to use Khronos implementations. Furthermore, OpenCL supports multiple programming languages, including C, C++, and Java, and enjoys extensive community support and resources. In summary, OpenCL is a cross-platform, open-source, highly flexible and scalable heterogeneous computing framework, with significant room for performance optimization.
[0004] In a heterogeneous system defined by OpenCL, the device model consists of a host machine (usually a CPU) and several hardware devices in the system (which can be GPUs or CPUs). Tasks running on the devices are called OpenCL kernel tasks, and they are managed uniformly by a runtime scheduler running on the host. Due to the diverse hardware devices that may exist on a platform, scheduling multiple kernels from multiple applications on the platform is a very important and manageable performance issue. Although previous research has proposed solutions for scheduling on heterogeneous systems, these solutions have the following problems:
[0005] 1. When considering the characteristics of program code, the existing technology does not fully analyze the dynamic characteristics of the application program, nor does it consider the characteristics of the hardware platform, making the model not portable.
[0006] 2. The scheduling strategies used by some existing technologies are relatively simple, including only traditional heuristic algorithms such as FIFO and priority FIFO. These algorithms do not consider the compile-time characteristics of the program or the processing characteristics of the processor, and cannot bring significant performance improvements.
[0007] 3. The existing technology does not combine the model with the open source and widely used OpenCL runtime, and does not provide users with a convenient scheduler interface. Summary of the Invention
[0008] To address the shortcomings of the existing technology, the present invention provides a method, system, and application for scheduling computing tasks on heterogeneous platforms based on machine learning algorithms. This invention provides an OpenCL runtime system that can run on heterogeneous platforms, combines the dynamic and static characteristics of programs, and schedules computing tasks based on machine learning algorithms.
[0009] The present invention provides a method for scheduling computing tasks on heterogeneous platforms based on a machine learning algorithm, the method comprising the following steps:
[0010] Step 1: Analyze and collect the static and dynamic features of the dataset program and the hardware features of the running platform;
[0011] Step 2: Select an appropriate machine learning scheduling model and optimize hyperparameters, and evaluate the performance of the scheduling model using multiple metrics;
[0012] Step 3: Select the best hardware device at runtime based on the model prediction results to achieve efficient task scheduling.
[0013] In step 1, the static characteristics of the data set program include: the number of instructions of different code types, the number of basic blocks, etc.; the dynamic characteristics of the data set program include: input data size, loop upper bound, memory access amount, etc.; the hardware characteristics of the running platform include CPU characteristics and GPU characteristics, etc.; and / or,
[0014] The CPU characteristics include the number of CPU cores, BogoMIPS, L1 data cache size, L1 instruction cache size, L2 cache size, and L3 cache size; the GPU characteristics include video memory clock frequency, video memory bus width, video memory bandwidth peak, total video memory, the amount of shared memory available for each thread block, and the number of threads contained in each thread warp.
[0015] The BogoMIPS is a measure of Linux processor speed that can indicate whether the system options are at optimal performance when the system is booted.
[0016] Step one further comprises the following steps:
[0017] Step 1.1: Compile the kernel code in the benchmark suite using the LLVM toolchain; the benchmark suite is pre-collected data that is widely used in the field of heterogeneous computing;
[0018] Step 1.2: Perform static feature analysis on the LLVM intermediate representation compiled in step 1.1 to obtain static features including the number of intermediate representation (IR) instruction classifications. Also, estimate dynamic features including loop upper bounds and memory accesses by constructing LLVMPass.
[0019] The LLVM Pass refers to the compilation strategy or optimization process in LLVM, which acts on LLVM IR and is used to optimize the program at compile time, link time, runtime, and "idle" time to improve the performance and efficiency of the program.
[0020] and / or,
[0021] Use bash commands to extract CPU features in hardware, and use CUDA interface functions to extract GPU features in hardware;
[0022] Step 1.3: Perform feature engineering on the static features, dynamic features, CPU features, and GPU features obtained in step 1.2.
[0023] After static feature analysis of the compiled LLVM intermediate representation, the program abstract syntax tree is parsed to obtain the type and number of statements and expressions, control flow structure, and function call chain information;
[0024] The loop upper bound is estimated through LoopBoundAnalysis in LLVM Pass, and AccessMemoryAnalysis identifies memory access patterns and estimates memory access volume;
[0025] and / or,
[0026] The feature engineering process includes: data preprocessing and feature selection; the data preprocessing includes introducing dummy variables into hardware features and standardizing and normalizing the features; the feature selection refers to using correlation analysis method, presetting screening thresholds, screening features according to the thresholds, and retaining the best feature subset.
[0027] Step 2 further includes the following steps:
[0028] Step 2.1: Select an appropriate machine learning model based on the target problem; the machine learning model includes linear regression model, decision tree regressor, support vector machine regressor, K nearest neighbor regressor, random forest regressor, AdaBoost regressor, gradient boosted random forest regressor, bagging regressor, and ExtraTree regressor;
[0029] Step 2.2: Use grid search and / or random search to select the hyperparameters that optimize performance.
[0030] Step 2.3: Evaluate the performance of the machine learning model to obtain the final machine learning model, which is the scheduling model used in step 3. The evaluation indicators include comparative mean square error, mean absolute error, R squared, and adjusted R squared.
[0031] Step three further includes the following steps:
[0032] Step 3.1: During the pre-compilation phase of the OpenCL runtime, add a bash script to run an analysis program for the kernel code and hardware platform.
[0033] Step 3.2: Obtain the static features, dynamic feature estimates, and hardware platform features of the kernel code, input them into the trained scheduling model, and obtain the scheduling prediction results;
[0034] Step 3.3: Before creating the command object queue, select hardware devices based on the inference results of the scheduling model and execute the scheduling strategy.
[0035] The scheduling strategy is based on a trained scheduling model and uses prediction results generated by multiple machine learning algorithms to select the best device from multiple hardware devices to perform the computing task; and / or,
[0036] Extending the OpenCL API to provide a scheduling interface allows users to select custom schedulers and scheduling strategies to meet the performance requirements of specific applications; and / or,
[0037] Perform offline training on computing tasks on heterogeneous platforms, collect benchmark data, and generate feature subsets for training; and / or,
[0038] Hyperparameter optimization and evaluation of multiple candidate models are performed using the feature subset to select the optimal scheduling model.
[0039] The present invention also provides a scheduling system for implementing the above scheduling method, the scheduling system comprising: a data collection module, a feature engineering module, a model training and selection module, a runtime scheduling module, and a scheduling interface module;
[0040] The data collection module is responsible for collecting static features, dynamic features, and hardware features of the program, providing basic data for model training and scheduling decisions;
[0041] The feature engineering module processes and optimizes the collected feature data to improve the training effect and generalization ability of the model;
[0042] The model training and selection module uses machine learning algorithms to train models, optimize hyperparameters, select the best model and evaluate its performance;
[0043] The runtime scheduling module selects the most suitable hardware device for each computing task based on the trained model and real-time feature data when the task is running;
[0044] The scheduling interface module provides users with a flexible interface and extended functions, allows the selection of different scheduling strategies and models, and ensures compatibility with the existing OpenCL API.
[0045] The present invention also provides the application of the above-mentioned scheduling method or the above-mentioned scheduling system in artificial intelligence model training and reasoning, big data efficient processing and analysis, graphics and image rendering processing, etc.
[0046] For the scenarios of artificial intelligence model training and inference, during the model training and inference process, the method of the present invention can analyze the computing requirements of the task and the characteristics of the hardware platform, and dynamically select the best CPU, GPU or other dedicated accelerators to optimize the training speed and inference performance, and improve resource utilization.
[0047] For scenarios requiring efficient processing and analysis of big data, the method of the present invention can intelligently analyze the computing requirements for processing large amounts of data and match the most suitable hardware resources, such as high-performance computing clusters, to achieve efficient processing and analysis of data and reduce processing delays and power consumption.
[0048] For the scenario of graphics and image rendering processing, in graphics rendering and image processing tasks, the method of the present invention can intelligently schedule tasks to the most suitable graphics processor or dedicated image processing unit according to the complexity of the task and the parallel processing capability of the hardware, so as to accelerate the speed of graphics rendering and image processing and improve the user experience.
[0049] The present invention designs a heterogeneous platform scheduling method based on machine learning, which includes processes such as extracting program features, training machine learning models, and designing OpenCL runtime scheduling API, which brings beneficial effects to program performance on heterogeneous platforms.
[0050] From the design of the method of the present invention, the beneficial effects mainly include but are not limited to the following aspects:
[0051] 1. Integrity, reliability and representativeness of features: The present invention has done a series of work in the data set collection stage to ensure that the data is complete and reliable. Compared with previous technologies, the influence of platform hardware features and dynamic features is taken into account, and an approximate estimate of dynamic features is obtained through the latest technology. In order to deal with the data missing caused by the hardware itself, feature engineering methods are used to deal with it. Finally, the present invention screens variables through correlation analysis. The correlation coefficient between features is calculated to determine the degree of correlation between any two features. A negative correlation coefficient indicates that the two features have a complementary relationship, a positive correlation coefficient indicates that the two features have a substitution relationship, and a correlation coefficient of 0 indicates that there is no correlation between the two. If the correlation between two features is strong, only one of the features can be retained. Therefore, the absolute value of the correlation coefficient is taken here, and any feature of the pairwise features with an absolute value of the correlation coefficient greater than 90% is eliminated to obtain a more suitable feature subset.
[0052] 2. Model Accuracy: During the model selection phase, this invention considers as many regression models as possible and also performs hyperparameter estimation and model evaluation according to common machine learning processes. Compared to previous technologies that commonly use heuristic algorithms and OpenCL runtimes that don't consider scheduling, this invention provides effective prediction for program scheduling on heterogeneous platforms.
[0053] 3. Interface consistency and extensibility: This invention adds extensions to allow users to select custom schedulers and scheduling policies within the OpenCL runtime to meet the performance requirements of specific applications. The new extensions are designed as a flexible interface to support the addition of more schedulers and scheduling policies while maintaining compatibility with the existing OpenCL API.
[0054] Test data shows that the AdaBoost regressor, gradient boosted random forest regressor, and ExtraTree regressor used in this invention achieved accuracies of 73%, 78%, and 86%, respectively. This means that, relative to a perfect scenario, more than 70% of the kernels were scheduled to the appropriate hardware devices. Compared to the OpenCL runtime without a scheduler, the inclusion of these schedulers resulted in performance improvements of 17%, 14%, and 35%, respectively, including runtime reductions. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0056] Figure 1 This is a system architecture diagram of the offline training phase of the present invention.
[0057] Figure 2 This is a system architecture diagram of the runtime reasoning phase of the present invention.
[0058] Figure 3 It is a flowchart of program analysis and feature collection of the present invention.
[0059] Figure 4 It is a schematic diagram of the model training and model selection process of the present invention.
[0060] Figure 5 This is a flow chart of adding an OpenCL runtime scheduling interface in the present invention.
[0061] Figure 6 This is a reference diagram for implementing Example 1 of the present invention.
[0062] Figure 7 This is a reference diagram for implementing embodiment 2 of the present invention.
[0063] Figure 8 This is a reference diagram for implementing embodiment 3 of the present invention.
[0064] Figure 9 This is a reference diagram for implementing embodiment 4 of the present invention.
[0065] Figure 10 This is a reference diagram for implementing embodiment 5 of the present invention. DETAILED DESCRIPTION
[0066] The present invention is further described in detail with reference to the following specific examples and accompanying drawings. The processes, conditions, experimental methods, etc. for implementing the present invention, except for those specifically mentioned below, are common knowledge and common common sense in the art and are not particularly limited by the present invention.
[0067] The present invention provides a method for scheduling computing tasks on heterogeneous platforms based on a machine learning algorithm. The first technical problem addressed by the present invention is the acquisition, screening, and application of program features. Most existing technologies only consider static program features in this regard, such as the number of instructions of different code types and the number of basic blocks. These static features do not fully represent the characteristics of the application, and scheduling based solely on static features will obviously lead to prediction errors. Dynamic program features, on the other hand, refer to features that can be acquired during program runtime, such as input data size, loop upper bounds, and memory access capacity. Dynamic features can only be accurately acquired during runtime. If dynamic feature data is only available after execution in a scheduling policy, it significantly increases scheduler overhead and does not always produce optimal device mapping. Therefore, the present invention focuses on how to obtain approximate estimates of dynamic features through estimation methods. Furthermore, program performance is also related to hardware device characteristics. Existing models trained without considering the hardware characteristics of the training platform, resulting in a high probability that the resulting model will not be transferable. Therefore, the present invention also collects as many hardware features as possible and performs feature engineering on all of them to prepare for subsequent model training. In this part, the present invention solves the problem that the prior art does not fully analyze the dynamic characteristics of the application program when considering the characteristics of the program code, nor does it consider the characteristics of the hardware platform, making the model not portable.
[0068] In addition, the present invention focuses on the reliability of the scheduler algorithm. The scheduling algorithms used by different existing technologies can be divided into two categories, namely heuristic algorithms and machine learning algorithms. In general, the effect of heuristic algorithms is relatively poor, while fewer existing technologies use machine learning algorithms, but the overall process still has room for optimization. For example, AUGONNET [1] et al. designed STARPU, a runtime system whose primary goal is to provide numerical kernel designers with a convenient way to generate parallel tasks on heterogeneous hardware and an interface for developing and adjusting scheduling algorithms. It developed several strategies that can be seamlessly selected at runtime, but the scheduling strategies are relatively simple, including only FIFO and priority FIFO. The scheduling algorithm does not consider the compile-time characteristics of the program or the processing characteristics of the processor, and cannot bring significant performance improvements. WEN [2]et al. proposed a runtime framework that schedules multi-user OpenCL tasks to the most appropriate devices in a CPU / GPU system. They used a machine learning-based prediction model at runtime to detect whether to merge OpenCL kernels or schedule them individually to the most appropriate device, without prior analysis. This work achieved some performance improvements over the state-of-the-art work at the time, but it did not fully analyze the dynamic characteristics of the application or consider hardware platform characteristics, making the model non-transferable. Furthermore, there was room for optimization in the model selection and training process. As with all machine learning tasks, different models exhibit varying performance on different datasets and tasks. Choosing the right model is crucial for ultimate prediction accuracy. For example, in some cases, a decision tree model may be more effective than a neural network, while in others, the opposite may be true. Furthermore, most machine learning algorithms have hyperparameters that require manual configuration, such as the learning rate, tree depth, and regularization parameter. The selection of these hyperparameters has a significant impact on model performance and convergence speed. Incorrect hyperparameter selection can lead to overfitting, underfitting, or unstable training. Therefore, correctly selecting a model, optimizing hyperparameters, and evaluating the model are critical steps to ensure the success of machine learning tasks. These steps need to be combined with domain knowledge, experimental design, and data analysis skills to ensure that the final selected model can perform well in practical applications. This part solves the problem that the scheduling strategies used in some existing technologies are relatively simple. The feature engineering mentioned in the first technical problem also has a great impact on the accuracy of the model. The present invention also adds additional hardware features, resulting in hardware-related missing data values in each data. Appropriate data preprocessing methods are required to help the model better understand and utilize classification information, thereby improving the performance and generalization ability of the model.
[0069] The third core problem solved by the present invention is how to combine the scheduling model with an open source, complete and influential OpenCL runtime to provide users with a convenient scheduling selection interface. POCL (Portable Computing Language) is an open source project that aims to provide a cross-platform OpenCL implementation, so that OpenCL can be used for parallel computing on different hardware. It is also an OpenCL implementation with a wide range of users. Therefore, POCL will serve as the basis of the open source tool framework of the present invention. The present invention will add reasonable extensions to POCL, allowing users to select customized schedulers and scheduling strategies to meet the performance requirements of specific applications. At the same time, the new extensions should provide a flexible interface so that more schedulers and scheduling strategies can be easily added in the future, maintaining compatibility with the existing OpenCL API. This part solves the problem that the existing technology does not combine the model with the open source and widely used OpenCL runtime, and does not provide users with a convenient scheduler interface.
[0070] This paper proposes a machine learning-based scheduling method for heterogeneous platforms to schedule tasks on heterogeneous platforms, improving the overall system's performance under load. For simple, computationally intensive tasks, scheduling them on the GPU is beneficial for the entire system. Conversely, when the task is well-suited for the CPU, scheduling on the CPU is more beneficial. Current OpenCL implementations do not provide a scheduling interface; the device to which kernel tasks are scheduled must be user-specified or randomly assigned to an idle device. The scheduling method proposed in this paper uses an efficient and reliable scheduling algorithm to provide device recommendations and presents the prediction results to the user via a suitable interface, guiding the matching of computing tasks with hardware devices and improving overall system performance. Regarding feature extraction, this paper analyzes program static features, estimates program dynamic features, and collects hardware platform features. Feature engineering is performed based on these features to prepare for subsequent model training. The machine learning model aims to predict the execution time of a computing task kernel. This paper applies the complete machine learning training process to complete model selection, hyperparameter selection, and model evaluation. Using the model's predicted labels, the scheduler selects the best available device for the kernel. This prediction is provided to OpenCL before execution. The present invention ultimately extends the API of POCL to support optional schedulers and scheduling strategies.
[0071] 5.1 System Architecture
[0072] The architecture diagram of the present invention is as follows Figure 1 、 Figure 2As shown. In the offline training stage, the present invention first collects benchmark test suites widely used in the field of heterogeneous computing, runs the OpenCL kernel code of the test cases on the GPU and CPU respectively, and counts the running time as the target feature of the model training. Next, the present invention converts the OpenCL kernel code into LLVM IR with the help of LLVM tools to complete static feature analysis. For the dynamic features of the program that can only be determined after running, the present invention uses the Libtooling tool to perform abstract syntax tree matching and completes the approximate estimation of the dynamic features of the program by constructing LLVM Pass. In addition, the present invention also collects the hardware device features of the training platform as model input. After that, a suitable feature subset is obtained through feature engineering, a suitable regression model and suitable hyperparameters are selected for model training, and the results of the model evaluation are given. In the runtime reasoning stage, when the user provides an application on a heterogeneous platform, the present invention will complete the kernel task feature analysis work in the pre-compilation part of the OpenCL runtime POCL, obtain the static features, dynamic feature estimation and hardware features of the kernel code in the same way, and use the trained model to obtain the reasoning result. When the user does not specify a running device and turns on the scheduler, the present invention helps the user schedule application kernel tasks to the hardware device with the best performance through the modified OpenCL command queue interface.
[0073] 5.2 System Process and Implementation Steps
[0074] The specific steps of the task scheduling method implemented by the scheduling system in the present invention are as follows:
[0075] Step 1: Collect the dynamic and static characteristics of the dataset program and the hardware characteristics of the running platform
[0076] The process of this step is as follows Figure 3 The heterogeneous computing test benchmark suites used in this invention include Parboil, Polybench, AMD samples and Rodinia, etc. These test benchmark suites are widely used in the research of heterogeneous computing performance analysis. [1]-[3] There is a certain degree of representativeness in it.
[0077] For the hardware features of the operating platform that need to be extracted, on the model training platform, the present invention uses the bash command lscpu to extract the CPU architecture and information, including the number of CPU cores, BogoMIPS, the size of the first-level data cache, the size of the first-level instruction cache, the size of the second-level cache, and the size of the third-level cache; and uses the CUDA API (i.e., the cudaGetDeviceProperties function) to obtain the GPU architecture and information. The obtained hardware features include the video memory clock frequency, the video memory bus width, the peak video memory bandwidth, the total amount of video memory, the amount of shared memory available for each thread block, and the number of threads contained in each thread bundle.
[0078] To characterize the program code, LLVM is first used to compile the OpenCL kernel code into an LLVM intermediate representation (IR). Based on this, the IR is analyzed to obtain eight types of static features, including the number of aggregate instructions, arithmetic instructions, function call instructions, conversion instructions, floating-point operation instructions, memory access instructions, terminator instructions, and vector instructions. Furthermore, the program's abstract syntax tree is parsed using the Libtooling tool to further obtain information such as the type and number of statements and expressions, control flow structure, and function call chains. Finally, the present invention constructs an LLVM Pass to obtain approximate estimates of two program dynamic features: loop upper bounds and memory access volume. LLVMPassLoopBoundAnalysis uses LLVM's ScalarEvolution analysis to obtain the number of executions of each loop. If the loop number is not constant, the loop upper bound is estimated using an abstract interpretation method. LLVMPassAccessMemoryAnalysis can identify memory access patterns in the code and estimate memory access volume. For example, given an array, the memory access volume can be roughly estimated by calculating the index range and frequency of accesses.
[0079] During the data preprocessing phase of feature engineering, this paper attempts to fill missing values by selecting the mean or median of all samples for that feature value, but the results are less than ideal when introducing dummy variables. Introducing dummy variables for hardware features allows the model to understand that these missing data are reasonable. This paper also introduces feature standardization and normalization, scaling the data so that it falls into a specific region, facilitating comprehensive analysis.
[0080] In the feature engineering stage, the present invention also performs feature selection by correlation analysis to retain the best feature subset. Using the correlation analysis method, the correlation of each feature is first calculated, and then according to the threshold, the feature with variance greater than the threshold is selected. In this example, there is a feature variance of 0, that is, all samples have the same value of this feature (the limitation of the hardware platform causes some features to have the same value), then this feature has no effect on model training and can be directly discarded. Finally, the feature subset of the present invention retains 17 categories, including the number of arithmetic instructions, the number of function call instructions, the number of conversion instructions, the number of floating-point operation instructions, the number of memory access instructions, the number of terminator instructions, the number of vector instructions, the loop upper bound, the amount of memory access, the number of CPU cores, BogoMIPS, the size of the first-level data cache, the size of the first-level instruction cache, the size of the second-level cache, the clock frequency of the video memory, the peak value of the video memory bandwidth, and the total amount of video memory.
[0081] Step 2: Model selection, hyperparameter selection, and model evaluation of the scheduler model
[0082] The process of this step is as follows Figure 4 shown.
[0083] Since the target problem is a regression problem, suitable candidate linear models include linear regression model, decision tree regressor, support vector machine regressor, K nearest neighbor regressor, random forest regressor, AdaBoost regressor, gradient boosted random forest regression, bagging regressor, ExtraTree regressor, etc.
[0084] For each model, hyperparameter selection is a key step in model training, which directly affects the performance and generalization ability of the model. Hyperparameters are parameters that need to be set before model training. They cannot be learned through training data and need to be manually adjusted or an automated hyperparameter optimization algorithm is used to search for the optimal value. The present invention uses grid search and / or random search in this process to select the hyperparameters that optimize the performance of each type of model, and compares all models under the premise of setting the optimal hyperparameters.
[0085] In a specific implementation, a grid search method and a random search method may be used simultaneously, and then the one with better effect is selected for use.
[0086] Finally, in the model evaluation process, the present invention performs model evaluation by comparing four indicators: mean square error, mean absolute error, R square, and adjusted R square. The mean absolute error (MAE) is used to measure the average absolute error between the predicted value and the true value. It is a non-negative value. The smaller the MAE, the better the model. The mean square error (MSE) also measures the gap between the predicted value and the true value. When the dimensions are different, MAE and MSE are sometimes difficult to measure the effectiveness of the model. At this time, the coefficient of determination R square is needed. R square reflects the proportion of the total variation of the dependent variable that can be explained by the independent variable through the regression relationship. However, R square will exaggerate the degree to which the independent variable explains the variation of the dependent variable, and the more independent variables in the model, the larger the R square. Adjusted R square eliminates the influence of the number of independent variables. In summary, when comparing models through these four indicators, adjusted R square is given a higher weight.
[0087] Based on this, AdaBoost regressor, gradient boosted random forest regressor and ExtraTree regressor were selected as candidate models for the scheduling scheme.
[0088] Step 3: User opens the scheduling option and applies the device recommendation of the scheduler
[0089] The process of this step is as follows Figure 5 As shown. The kernel code is uniformly compiled, loaded and scheduled by the OpenCL runtime on the host. The present invention adds a bash script in the pre-compilation stage of the runtime, and runs analysis programs for the kernel code and hardware platform. These analysis programs are consistent with the analysis in the offline training stage, and can obtain the static features, dynamic feature estimation and hardware platform features of the kernel code, and hand these data to the scheduling model to obtain scheduling prediction results. In the runtime stage, the present invention proposes a new attribute called SCHEDULER, which can be used as a parameter for creating a command queue. Currently, the present invention supports three scheduler strategies, corresponding to AdaBoost regressor, gradient boosting random forest regressor and ExtraTree regressor. When the scheduler is triggered, it binds the command queue to the available devices recommended by the model.
[0090] The following examples describe in detail the specific implementation of the technical means of the three stages of the present invention in different application scenarios. Example 1 describes the implementation of performance evaluation related work using only the data set collected by the present invention; Example 2 describes the implementation of program running time evaluation using the dynamic feature estimation method; Example 3 describes the implementation of the present invention on a heterogeneous platform when the scheduling policy is set to OFF; Example 4 describes the implementation of the scheduling policy set to use different machine learning models and a single program running on a heterogeneous platform; Example 5 describes the implementation of the scheduling policy set to use different machine learning models and multiple programs running on a heterogeneous platform.
[0091] Example 1: Using the dataset of the present invention to perform performance evaluation related work
[0092] like Figure 6 As shown, the dataset includes three types of features: program static features, program dynamic features, and hardware features, totaling 22 categories. After feature engineering in the model training phase of the present invention, 17 categories remain, containing 308 data items. The specific implementation steps are as follows:
[0093] 1. The user downloads the dataset.
[0094] 2. Preprocess the dataset according to the actual application scenario, for example, convert the file format, change the data type, remove unnecessary features, etc.
[0095] 3. The last column of the dataset is the target feature, which represents the runtime of the kernel program on a specific platform. This can be used to further evaluate performance.
[0096] Example 2: Using dynamic feature estimation method to evaluate program running time
[0097] like Figure 7 As shown, users can use the dynamic feature estimation method to estimate the relative running time of the program, and based on this, provide a reference for real-time task scheduling, task priority arbitration, resource conflict arbitration, and inter-task communication. The specific steps of the embodiment are as follows:
[0098] 1. The user uses the clang-emit-llvm command to compile the kernel code into LLVMIR.
[0099] 2. Use the Libtooling tool for code checking and semantic analysis, collect information related to the abstract syntax tree through the AST matcher, and obtain more static features of the kernel program.
[0100] 3. Estimate program dynamics using LLVMPass. This paper constructs a new LLVMPass. LoopBoundAnalysis uses LLVM's ScalarEvolution analysis to obtain the execution count of each loop. If the loop count is not constant, an abstract interpretation method is used to estimate the loop upper bound. AccessMemoryAnalysis identifies memory access patterns in the code and estimates the amount of memory accesses. For example, given an array, the memory access count can be roughly estimated by calculating the index range and frequency of accesses.
[0101] 4. Based on the obtained dynamic characteristics, the relative running time of kernel programs can be compared, providing a reference for other tasks such as real-time scheduling of tasks, task priority arbitration, resource conflict arbitration, and inter-task communication.
[0102] Example 3: Implementation of the present invention on a heterogeneous platform when the scheduling policy is set to OFF
[0103] like Figure 8 As shown, when the user uses the scheduling strategy of OFF, the system selects the first available device among the idle devices. The specific implementation steps are as follows:
[0104] 1. At the OpenCL platform level, the OpenCL implementation first queries the platform for information. When building an OpenCL application, you must rely on a specific platform, which means knowing the vendor's device and corresponding SDK. This function returns the most recently supported OpenCL version, confirms that the platform supports full or embedded OpenCL, and returns the extensions supported by the platform.
[0105] 2. At the OpenCL platform layer, the second step is to query device information, including the device name, device global memory size, whether the device is available, and the device's maximum computing unit.
[0106] 3. At the OpenCL platform level, the final step is to create a context and command queue. The context object manages devices on the same platform, while the command queue is responsible for sending commands from the host to the device. Each command queue object and context is associated with a device (specified during creation). A command queue can contain multiple commands, and commands are generally executed sequentially. Since no scheduling policy is set at this time, the command queue is directly bound to the first idle device on the platform.
[0107] 4. In the OpenCL runtime part, the command queue now knows which device the kernel is bound to, and it can create the cache, create the application object, compile the kernel, set parameters and run the kernel in order.
[0108] 5. The program ends.
[0109] Example 4: Implementation of Scheduling Strategy Using Different Machine Learning Models and Running a Single Program on a Heterogeneous Platform
[0110] like Figure 9 As shown, compared with the third embodiment, the setting of the startup scheduling model mainly involves a major change in the pre-compilation phase, which does not affect the runtime of the application. The specific embodiment steps are as follows:
[0111] 1. At the OpenCL platform level, the OpenCL implementation first queries the platform for information. When building an OpenCL application, you must rely on a specific platform, which means knowing the vendor's device and corresponding SDK. This function returns the most recently supported OpenCL version, confirms that the platform supports full or embedded OpenCL, and returns the extensions supported by the platform.
[0112] 2. At the OpenCL platform layer, the second step is to query device information, including the device name, device global memory size, whether the device is available, and the device's maximum computing unit.
[0113] 3. At the OpenCL platform level, the third step is to collect features to prepare for model inference. Features include kernel code static features, dynamic feature estimation, and platform hardware features. These features are obtained in the same way as the dataset collection.
[0114] 4. At the OpenCL platform level, model inference is then performed. For each idle device, three different machine learning models are applied, and the relative program runtime results of the model inference are passed to the command queue.
[0115] 5. Before creating the command object queue, select the hardware device based on the model inference results.
[0116] 6. In the OpenCL runtime part, the command queue now knows which device the kernel is bound to, and it can create the cache, create the application object, compile the kernel, set parameters and run the kernel in order.
[0117] 7. The program ends.
[0118] Example 5: Implementation of Scheduling Strategy Using Different Machine Learning Models and Multiple Programs Running on Heterogeneous Platforms
[0119] like Figure 10 As shown, when there are multiple OpenCL tasks running, the scheduler will find the most suitable device among the idle devices without affecting the operation of the occupied devices. The specific implementation steps are as follows:
[0120] 1. At the OpenCL platform level, the OpenCL implementation first queries the platform for information. When building an OpenCL application, you must rely on a specific platform, which means knowing the vendor's device and corresponding SDK. This function returns the most recently supported OpenCL version, confirms that the platform supports full or embedded OpenCL, and returns the extensions supported by the platform.
[0121] 2. At the OpenCL platform layer, the second step is to query device information, including the device name, device global memory size, whether the device is available, and the device's maximum computing unit.
[0122] 3. At the OpenCL platform level, the third step is to collect features to prepare for model inference. Features include kernel code static features, dynamic feature estimation, and platform hardware features. These features are obtained in the same way as the dataset collection.
[0123] 4. At the OpenCL platform level, model inference is then performed. For each idle device, three different machine learning models are applied, and the relative program runtime results of the model inference are passed to the command queue.
[0124] 5. Before creating the command queue, select the hardware device based on the model inference results. If there are no data dependencies between tasks, set the command queue object's properties when creating it to allow for out-of-order execution. This allows kernel tasks on one device to be started while another is pending. Already occupied devices are marked as unavailable for new kernel tasks.
[0125] 6. In the OpenCL runtime part, the command queue now knows which device the kernel is bound to, and it can create the cache, create the application object, compile the kernel, set parameters and run the kernel in order.
[0126] 7. The program ends.
[0127] References
[0128] [1]AUGONNET C,THIBAULT S,NAMYST R,et al.StarPU:a unified platform fortaskschedulingon heterogeneous multicore architectures[C] / / Euro-Par2009Parallel Processing:15thInternational Euro-Par Conference,Delft,TheNetherlands,August 25-28,2009.Proceedings15.Springer Berlin Heidelberg,2009:863-874.
[0129] [2]WEN Y,WANG Z,O'BOYLE MF P.Smart multi-task scheduling for OpenCLprograms on CPU / GPUheterogeneous platforms[C] / / 201421st Internationalconference on highperformance computing(HiPC).IEEE,2014:1-10.
[0130] [3]AHMED U,LIN JCW,SRIVASTAVA G,et al.A load balance multi-scheduling model forOpenCL kernel tasks in an integrated cluster[J].SoftComputing,2021,25(1):407-420.
[0131] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiment of the present application can be implemented in various computer languages, for example, object-oriented programming language Java and literal translation scripting language JavaScript, etc.
[0132] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0133] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0135] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0136] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.
[0137] The protection content of the present invention is not limited to the above embodiments. Without departing from the spirit and scope of the present invention, changes and advantages that can be thought of by those skilled in the art are included in the present invention and are protected by the appended claims.
Claims
1. A method for scheduling computing tasks on heterogeneous platforms based on machine learning algorithms, characterized in that: The scheduling method comprises the following steps: Step 1: Analyze and collect the static and dynamic features of the dataset program and the hardware features of the running platform; Step one further comprises the following steps: Step 1.1: Compile the kernel code in the benchmark suite using the LLVM toolchain. Step 1.2: Perform static feature analysis on the LLVM intermediate representation obtained by compiling in step 1.1 to obtain static features including the number of intermediate representation IR instruction classifications; Estimating dynamic features including loop upper bounds and memory accesses by building an LLVM Pass; Use bash commands to extract CPU features in the hardware, and use CUDA interface functions to extract GPU features in the hardware; After static feature analysis of the compiled LLVM intermediate representation, the program abstract syntax tree is parsed to obtain the type and number of statements and expressions, control flow structure, and function call chain information; The loop upper bound is estimated through LoopBoundAnalysis in LLVM Pass, and AccessMemoryAnalysis identifies memory access patterns and estimates memory access volume; Step 1.3: Perform feature engineering on the static features, dynamic features, CPU features, and GPU features obtained in step 1.2; The feature engineering process includes: data preprocessing and feature selection; the data preprocessing includes introducing dummy variables into hardware features and standardizing and normalizing the features; The feature selection refers to using a correlation analysis method, presetting a screening threshold, screening features according to the threshold, and retaining the best feature subset; Step 2: Select an appropriate machine learning scheduling model and optimize hyperparameters, and evaluate the performance of the scheduling model using multiple metrics; Step 3: Select the best hardware device to achieve efficient task scheduling at runtime based on the prediction results of the scheduling model; Step three further includes the following steps: Step 3.1: During the pre-compilation phase of the OpenCL runtime, add a bash script to run an analysis program for the kernel code and hardware platform. Step 3.2: Obtain the static features, dynamic feature estimates, and hardware platform features of the kernel code, input them into the trained scheduling model, and obtain the scheduling prediction results; Step 3.3: Before creating the command object queue, select hardware devices based on the inference results of the scheduling model and execute the scheduling strategy.
2. The scheduling method according to claim 1, wherein: In step 1, the static characteristics of the data set program include: the number of instructions of different code types and the number of basic blocks; the dynamic characteristics of the data set program include: input data size, loop upper bound, memory access amount; the hardware characteristics of the running platform include CPU characteristics and GPU characteristics; and / or, The CPU characteristics include the number of CPU cores, BogoMIPS, L1 data cache size, L1 instruction cache size, L2 cache size, and L3 cache size; the GPU characteristics include video memory clock frequency, video memory bus width, video memory bandwidth peak, total video memory, the amount of shared memory available for each thread block, and the number of threads contained in each thread warp.
3. The scheduling method according to claim 1, wherein: Step 2 further includes the following steps: Step 2.1: Select an appropriate machine learning model based on the target problem; the machine learning model includes linear regression model, decision tree regressor, support vector machine regressor, K nearest neighbor regressor, random forest regressor, AdaBoost regressor, gradient boosted random forest regressor, bagging regressor, and ExtraTree regressor; Step 2.2: Use grid search and / or random search to select the hyperparameters that optimize performance. Step 2.3: Evaluate the performance of the machine learning model to obtain the final machine learning model; the evaluation indicators include comparative mean square error, mean absolute error, R squared, and adjusted R squared.
4. The scheduling method according to claim 1, wherein: The scheduling strategy is based on a trained scheduling model and uses prediction results generated by multiple machine learning algorithms to select the best device from multiple hardware devices to perform the computing task; and / or, Provides a scheduling interface by extending the OpenCL API, allowing users to select custom schedulers and scheduling strategies to meet the performance requirements of specific applications; and / or, Perform offline training on computing tasks on heterogeneous platforms, collect benchmark data, and generate feature subsets for training; and / or, Hyperparameter optimization and evaluation of multiple candidate models are performed using the feature subset to select the optimal scheduling model.
5. A heterogeneous platform computing task scheduling system based on machine learning algorithm, characterized in that: The scheduling system is used to implement the scheduling method according to any one of claims 1 to 4, comprising: a data collection module, a feature engineering module, a model training and selection module, a runtime scheduling module, and a scheduling interface module; The data collection module is responsible for collecting static features, dynamic features, and hardware features of the program, providing basic data for model training and scheduling decisions; The feature engineering module processes and optimizes the collected feature data to improve the training effect and generalization ability of the model; The model training and selection module uses machine learning algorithms to train models, optimize hyperparameters, select the best model and evaluate its performance; The runtime scheduling module selects the most suitable hardware device for each computing task based on the trained model and real-time feature data when the task is running; The scheduling interface module provides users with a flexible interface and extended functions, allows the selection of different scheduling strategies and models, and ensures compatibility with the existing OpenCL API.
Citation Information
Patent Citations
Network resource scheduling optimization system of cloud environment
CN117931424A
Programming Flow for Multi-Processor System
US20190138365A1