Kernel function calling method, device, equipment, storage medium and program product
Patent Information
- Application Number
- CN202311177303.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-12
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2043-09-12
AI Technical Summary
[0003]相关技术在实现核函数的递归调用时,通常是基于HIP(Heterogeneous-ComputeInterface for Portability,并行编程模型),将具有递归调用关系的多个核函数转换为非递归调用关系,使得具有递归调用关系的核函数能够进行非递归调用,但是,具有递归调用关系的核函数进行非递归调用时存在执行复杂度高的问题
[0036] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method described in the first aspect above.
Smart Images

Figure CN117389697B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of high-performance computer technology, and in particular to a kernel function calling method, apparatus, device, storage medium, and program product. Background Technology
[0002] With the development of computer technology, high-performance computers have been widely used. Among them, the high-performance computer architecture with heterogeneous accelerators as the main computing units has become the main structure of high-performance computers. Heterogeneous accelerators, such as GPUs (Graphics Processing Units), MICs (Microchips), DSPs (Digital Signal Processors), and FPGAs (Field-Programmable Gate Arrays), typically use specific instruction sets to execute parallel algorithms with high concurrency and simple logic, thus achieving low-power, high-float computing performance. In parallel algorithms, recursive calls are a very common calling method, where a kernel function calls a kernel function that includes itself.
[0003] When implementing recursive calls to kernel functions, related technologies typically rely on HIP (Heterogeneous-Compute Interface for Portability), which converts multiple kernel functions with recursive call relationships into non-recursive call relationships, enabling non-recursive calls to kernel functions with recursive call relationships. However, performing non-recursive calls to kernel functions with recursive call relationships results in high execution complexity. Summary of the Invention
[0004] Therefore, it is necessary to provide a kernel function calling method, apparatus, device, storage medium, and program product that can reduce the execution complexity of kernel function calls with recursive calling relationships, in order to address the above-mentioned technical problems.
[0005] Firstly, this application provides a kernel function calling method. This method is used in a server configured with a GPU. The method includes:
[0006] The GPU retrieves the first kernel function from the task queue to execute the task, and checks whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to indicate whether other kernel functions need to be called during the execution of the current kernel function.
[0007] If there is a recursive call relationship in the current kernel function, the GPU will execute the second kernel function execution task corresponding to the other kernel function, and continue to execute the first kernel function execution task after the second kernel function execution task is completed.
[0008] In the above embodiments, if the current kernel function corresponding to the first kernel function execution task has a recursive call relationship, the GPU first executes the second kernel function execution task corresponding to other kernel functions recursively called by the current kernel function. Only after the second kernel function execution task is completed will the first kernel function execution task be executed to complete the recursive call of the current kernel function. This avoids the problem of high execution complexity caused by non-recursive calls to kernel functions with recursive call relationships in traditional technologies. In this embodiment, the GPU executes the kernel function execution tasks corresponding to each kernel function with a recursive call relationship to realize the recursive call of kernel functions. The recursive call of other kernel functions can be realized within the current kernel function body, reducing the execution complexity of kernel functions with recursive call relationships.
[0009] In one embodiment, there are multiple other kernel functions, and there are recursive call relationships between these other kernel functions. The GPU executes the second kernel function execution task corresponding to the other kernel function, and after the second kernel function execution task is completed, it continues to execute the first kernel function execution task, including:
[0010] The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and continues to execute the first kernel function execution tasks after the second kernel function execution tasks have been completed.
[0011] In this embodiment, when the recursive call relationship in the current kernel function is a multi-level nested recursive call, the GPU executes the second kernel function execution task corresponding to each other kernel function in sequence, so as to recursively call multiple other kernel functions with recursive call relationships. The depth of recursive calls is deeper, which is conducive to improving the implementation and promotion of the embodiments of this application.
[0012] In one embodiment, the server is also equipped with a CPU, and the method further includes:
[0013] The GPU generates recursive call requests corresponding to other kernel functions and writes the recursive call requests into a preset buffer. The recursive call requests carry execution configuration data packets corresponding to other kernel functions.
[0014] If the CPU detects that data has been updated in the preset buffer, it will lock other GPU access operations to the preset buffer and read recursive call requests from the preset buffer.
[0015] The CPU sends a second core function execution task to the task queue based on the recursive call request. The second core function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to other core functions.
[0016] In this embodiment, the CPU receives recursive call requests for other kernel functions sent by the GPU through a preset buffer, generates a second kernel function execution task corresponding to the other kernel function, and then sends the second kernel function execution task to the task queue. This allows the GPU to complete the recursive call of the current kernel function to other kernel functions by executing the second kernel function execution task in the task queue. The logic of the recursive call is simple, and locking the preset buffer prevents other GPUs from accessing the preset buffer, thus improving the accuracy of the CPU in obtaining the data content in the preset buffer.
[0017] In one embodiment, the method further includes:
[0018] The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into a preset buffer;
[0019] If the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates the corresponding confirmation information and writes the confirmation information into the preset buffer.
[0020] When the CPU reads confirmation information from the preset buffer, it clears the data content in the preset buffer and unlocks the access operation to the preset buffer.
[0021] In this embodiment, after the CPU successfully sends the second core function to execute the task, it clears the data content in the preset buffer and unlocks the access operation of the preset buffer, allowing other GPUs to access the preset buffer. This ensures the security of the data content in the preset buffer and improves the accuracy when recursively calling the core function.
[0022] In one embodiment, before the GPU executes the second kernel function corresponding to other kernel functions to perform the task, the method further includes:
[0023] The GPU marks the first kernel function execution task as blocked. The blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task.
[0024] After the GPU continues executing the task using the first kernel function, the method also includes:
[0025] Once the first kernel function execution task is completed, the GPU marks the first kernel function execution task as completed.
[0026] In this embodiment, by marking the execution task of the first kernel function, it is determined whether the recursive call of the current kernel function has been completed, which increases the security of the recursive call.
[0027] In one embodiment, the method further includes:
[0028] The CPU retrieves the current kernel function file;
[0029] During the compilation of the kernel function file, if the CPU determines that there is a recursive call relationship in the kernel function corresponding to the kernel function file, it adds an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file. The implicit parameter is an address pointer, which is used to point to a preset buffer.
[0030] In this embodiment, after the CPU obtains multiple kernel function files, it adds address pointers to kernel functions with recursive call relationships. The address pointers point to a preset buffer, which enables the GPU to determine the address of the preset buffer, making it easier for the GPU to recursively call kernel functions with recursive call relationships in the future.
[0031] Secondly, this application also provides a kernel function calling apparatus. This apparatus is used in a server configured with multiple GPUs. The apparatus includes:
[0032] The GPU detection module is used to obtain the first kernel function execution task from the task queue and detect whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function.
[0033] The GPU execution module is used to execute the second kernel function execution task corresponding to other kernel functions if there is a recursive call relationship in the current kernel function, and continue to execute the first kernel function execution task after the second kernel function execution task is completed.
[0034] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method described in the first aspect above.
[0035] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.
[0036] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method described in the first aspect above.
[0037] The aforementioned kernel function calling method, device, equipment, storage medium, and program product obtain a first kernel function execution task from the task queue through the GPU, and detect whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function. If there is a recursive call relationship in the current kernel function, the GPU executes the second kernel function execution task corresponding to the other kernel function, and continues to execute the first kernel function execution task after the second kernel function execution task is completed. In this way, if the current kernel function corresponding to the first kernel function execution task has a recursive call relationship, the GPU first executes the second kernel function execution task corresponding to other kernel functions recursively called by the current kernel function. Only after the second kernel function execution task is completed will the first kernel function execution task be executed to complete the recursive call of the current kernel function. This avoids the problem of high execution complexity caused by non-recursive calls to kernel functions with recursive call relationships in traditional technologies. In this embodiment, the GPU realizes the recursive call of kernel functions by executing the kernel function execution tasks corresponding to each kernel function with a recursive call relationship. The recursive call of other kernel functions can be realized within the current kernel function body, reducing the execution complexity of kernel functions with recursive call relationships. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a diagram illustrating the application environment of a kernel function call method in one embodiment;
[0040] Figure 2 This is a flowchart illustrating the kernel function call method in one embodiment;
[0041] Figure 3 This is a flowchart illustrating step 202 in another embodiment;
[0042] Figure 4 This is a flowchart illustrating the process of generating a second kernel function to execute a task in another embodiment;
[0043] Figure 5 This is a schematic diagram illustrating the process of the CPU performing access operations, locking, and clearing data content in a preset buffer in another embodiment.
[0044] Figure 6This is a schematic diagram illustrating the process of the CPU sending kernel functions to the GPU in another embodiment;
[0045] Figure 7 This is a block diagram of a kernel function calling device in one embodiment;
[0046] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0047] 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.
[0048] With the development of computer technology, high-performance computers have been widely used. Among them, the high-performance computer architecture with heterogeneous accelerators as the main computing units has become the main structure of high-performance computers. Heterogeneous accelerators, such as GPUs, MICs, DSPs, and FPGAs, typically use specific instruction sets to execute parallel algorithms with high concurrency and simple logic, thus achieving low-power, high-float-point computing performance.
[0049] In parallel algorithms, recursive calls are a very common calling method. The core of recursive calls lies in solving problems by repeatedly decomposing them into subproblems of the same kind. For example, the Fibonacci function, the Hanoi problem, and graph traversal search are all classic recursive algorithms. Recursive calls of kernel functions mean that a kernel function calls a kernel function that includes itself.
[0050] When designing kernel functions with recursive call relationships, the mainstream CUDA parallel programming model is typically used to call the kernel functions on the GPU through Dynamic Parallelism to achieve recursive calls. However, Dynamic Parallelism is a closed-source feature developed by NVIDIA and is not suitable for the design and development of kernel functions on all GPUs. For GPUs that cannot use Dynamic Parallelism, related technologies use the HIP parallel programming model to design kernel functions with recursive call relationships. However, since kernel functions are declared as "__global__" and their return values must be declared as "void", kernel functions cannot call other kernel functions, including themselves. In order to achieve recursive calls, the recursive call relationship between kernel functions is usually converted into a non-recursive call relationship, which increases the design complexity of kernel functions. Furthermore, executing kernel functions with recursive call relationships in a non-recursive manner results in high execution complexity.
[0051] In view of this, embodiments of this application provide a kernel function calling method, apparatus, device, storage medium, and program product. The GPU obtains a first kernel function execution task from the task queue and detects whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function. If there is a recursive call relationship in the current kernel function, the GPU executes a second kernel function execution task corresponding to other kernel functions, and continues to execute the first kernel function execution task after the second kernel function execution task is completed. In this way, if the current kernel function corresponding to the first kernel function execution task has a recursive call relationship, the GPU first executes the second kernel function execution task corresponding to other kernel functions recursively called by the current kernel function. Only after the second kernel function execution task is completed will the first kernel function execution task be executed to complete the recursive call of the current kernel function. This avoids the problem of high execution complexity caused by non-recursive calls to kernel functions with recursive call relationships in traditional technologies. In this embodiment, the GPU realizes the recursive call of kernel functions by executing the kernel function execution tasks corresponding to each kernel function with a recursive call relationship. The recursive call of other kernel functions can be realized within the current kernel function body, reducing the execution complexity of kernel functions with recursive call relationships.
[0052] The kernel function calling method provided in this application embodiment can be applied to, for example, Figure 1 The implementation environment shown includes computer equipment, which can be a server or other high-performance devices equipped with CPUs and GPUs.
[0053] Computer devices contain a CPU (Central Processing Unit) and a GPU; the number of GPUs can be one or more. Figure 1 (Only one GPU is shown as an example). Exemplarily, in the kernel function calling method of this application embodiment, the GPU obtains a first kernel function execution task from the task queue and detects whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function. If there is a recursive call relationship in the current kernel function, the GPU executes the second kernel function execution task corresponding to the other kernel function, and continues to execute the first kernel function execution task after the second kernel function execution task is completed.
[0054] In one exemplary embodiment, such as Figure 2 As shown, a kernel function calling method is provided. Taking the application of this method to a computer device as an example, the method includes steps 201 and 202.
[0055] Step 201: The GPU retrieves the first kernel function execution task from the task queue and checks whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task.
[0056] A kernel function is a program specifically written for the GPU. Optionally, a kernel function may have a recursive call relationship, or it may not. The recursive call relationship is used to indicate whether other kernel functions need to be called during the execution of the current kernel function.
[0057] In one possible implementation, the GPU can execute the kernel function corresponding to the kernel function execution task. For example, the kernel function execution task includes the kernel function execution structure, kernel function execution data, etc. The GPU can input the kernel function execution data into the kernel function program according to the kernel function execution structure and execute the kernel function according to the kernel function execution structure.
[0058] The GPU can retrieve kernel function execution tasks from the task queue. A task queue is a queue data structure used to store kernel function execution tasks; one task queue corresponds to one GPU, and the task queue can be a stream queue. In one possible implementation, the task queue can be a non-blocking queue, meaning that individual kernel function execution tasks in the task queue do not need to wait for any other kernel function task to complete before they can begin execution.
[0059] For the execution task of the first kernel function, after the GPU retrieves the execution task from the task queue, it can determine the current kernel function corresponding to the execution task. Then, the GPU checks the current kernel function to determine whether there is a recursive call relationship. Optionally, the kernel function execution task also includes a recursive call identifier. The GPU can determine whether there is a recursive call relationship in the current kernel function based on the recursive call identifier contained in the execution task of the first kernel function. Optionally, the parameter list of the kernel function includes implicit parameters. The GPU can determine whether there is a recursive call relationship in the kernel function based on the implicit parameters. Optionally, the GPU obtains the kernel function name of each kernel function and performs matching processing based on each kernel function name and the program code contained in the current kernel function. If the program code contained in the current kernel function includes any kernel function name, the GPU determines that the current kernel function has a recursive call relationship. If the program code contained in the kernel function does not contain any kernel function name, the GPU determines that the current kernel function does not have a recursive call.
[0060] Step 202: If there is a recursive call relationship in the current kernel function, the GPU executes the second kernel function execution task corresponding to other kernel functions, and continues to execute the first kernel function execution task after the second kernel function execution task is completed.
[0061] In one possible implementation, for a current kernel function with a recursive call relationship, the GPU can determine other kernel functions recursively called by the current kernel function based on the recursive call relationship. For example, when the GPU detects whether the current kernel function has a recursive call relationship, for a current kernel function with a recursive call relationship, the GPU can detect the kernel function names of other kernel functions recursively called by the current kernel function in the program code contained in the current kernel function. Then, the GPU can determine the second kernel function corresponding to the other kernel function to execute the task based on the kernel function names of the other kernel functions.
[0062] In one possible implementation, after the GPU determines the other kernel functions that the current kernel function recursively calls, before executing the second kernel function execution task corresponding to the other kernel function, the GPU marks the first kernel function execution task as blocked, wherein the blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task.
[0063] When the GPU executes the second kernel function task, it can detect whether other kernel functions have recursive call relationships. Optionally, if other kernel functions have recursive call relationships, the GPU executes the other kernel function tasks corresponding to the recursive call relationships in sequence. Only after the other kernel function tasks are completed can the GPU continue to execute the second kernel function task. Optionally, if other kernel functions do not have recursive call relationships, the GPU will only continue to execute the first kernel function task after the second kernel function task is completed.
[0064] In another possible implementation, after the GPU completes the execution of the second kernel function, it sets the execution task flag of the first kernel function to continue execution, and then continues to execute the first kernel function. If the first kernel function is completed, the GPU marks the first kernel function as completed.
[0065] The kernel function calling method described above obtains the first kernel function execution task from the task queue through the GPU, and checks whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to indicate whether other kernel functions need to be called during the execution of the current kernel function. If there is a recursive call relationship in the current kernel function, the GPU executes the second kernel function execution task corresponding to the other kernel function, and continues to execute the first kernel function execution task after the second kernel function execution task is completed. In this way, if the current kernel function corresponding to the first kernel function execution task has a recursive call relationship, the GPU first executes the second kernel function execution task corresponding to other kernel functions recursively called by the current kernel function. Only after the second kernel function execution task is completed will the first kernel function execution task be executed to complete the recursive call of the current kernel function. This avoids the problem of high execution complexity caused by non-recursive calls to kernel functions with recursive call relationships in traditional technologies. In this embodiment, the GPU realizes the recursive call of kernel functions by executing the kernel function execution tasks corresponding to each kernel function with a recursive call relationship. The recursive call of other kernel functions can be realized within the current kernel function body, reducing the execution complexity of kernel functions with recursive call relationships.
[0066] In one embodiment, based on the above Figure 2 The illustrated embodiment can be found in [reference]. Figure 3 This embodiment involves the GPU executing the second kernel function execution task corresponding to other kernel functions, and then continuing to execute the first kernel function execution task after the second kernel function execution task has been completed. For example... Figure 3 As shown, step 202 may include step 301.
[0067] Step 301: The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and after the execution of each second kernel function execution task is completed, it continues to execute the first kernel function execution task.
[0068] In this embodiment, there are multiple other kernel functions, and there is a recursive call relationship between each other kernel function. That is, there is a recursive call relationship between other kernel functions, and other kernel functions need to be called recursively.
[0069] In one possible implementation, when the GPU executes the second kernel function to perform a task, it can detect whether there is a recursive call relationship among other kernel functions that are recursively called by the current kernel function. If there is a recursive call relationship among other kernel functions, the GPU will detect whether there is a recursive call relationship among other kernel functions that are recursively called by the other kernel function. This process continues until the GPU detects that there is no recursive call relationship among a certain other kernel function. At this point, the number of other kernel functions detected by the GPU is the recursion depth of the recursive call, and the current kernel function corresponding to the first kernel function execution task is the entry point of the recursive call.
[0070] For each of the other kernel functions that are determined to have a recursive call relationship, the GPU executes the second kernel function execution task corresponding to each of the other kernel functions in turn. For example, the GPU first executes the second kernel function execution task corresponding to the other kernel functions that do not have a recursive call relationship. After the execution is completed, the GPU then executes the second kernel function execution task corresponding to the other kernel functions that recursively call the other kernel functions, and so on. After the GPU completes the second kernel function execution task corresponding to each of the other kernel functions, it continues to execute the first kernel function execution task corresponding to the current kernel function.
[0071] In this embodiment, when the recursive call relationship in the current kernel function is a multi-level nested recursive call, the GPU executes the second kernel function execution task corresponding to each other kernel function in sequence, so as to recursively call multiple other kernel functions with recursive call relationships. The depth of recursive calls is deeper, which is conducive to improving the implementation and promotion of the embodiments of this application.
[0072] In one embodiment, based on the above Figure 2 The illustrated embodiment can be found in [reference]. Figure 4 In this embodiment, the server is also equipped with a CPU, and this embodiment involves the process of generating a second core function to execute tasks. For example... Figure 4 As shown, based on Figure 2 In the embodiment shown, the kernel function call method further includes steps 401 to 403.
[0073] Step 401: The GPU generates recursive call requests for other kernel functions and writes the recursive call requests into a preset buffer.
[0074] In one possible implementation, the preset buffer is a buffer that can be operated by the GPU and the CPU, and its memory size can be determined according to a preset. The preset buffer is located on the CPU.
[0075] When the GPU detects a recursive call request in the current kernel function, it generates the corresponding recursive call request and accesses a preset buffer. Optionally, when the preset buffer is created, its address is sent to the GPU. Alternatively, the parameter list of the current kernel function contains implicit parameters, which are address pointers whose values are the addresses of the preset buffers. After the current kernel function is sent, the GPU can determine the address of the preset buffer through the implicit parameters in its parameter list and then access the preset buffer with the recursive call request.
[0076] In one possible implementation, the recursive call request carries an execution configuration data packet corresponding to other kernel functions. This execution configuration data packet is constructed according to a protocol and includes at least the execution parameters, arguments, and addresses of the other kernel functions. The addresses of the other kernel functions are provided by the compiler and are typically offset addresses of the binary program. The execution parameters of the other kernel functions are a quadruple, including execution grid dimension information, execution block dimension information, shared memory size, and execution stream. The second kernel function execution task can be generated accordingly based on the data content contained in the execution configuration data packet.
[0077] Step 402: If the CPU detects that data has been updated in the preset buffer, it locks other GPUs' access operations to the preset buffer and reads recursive call requests from the preset buffer.
[0078] In one possible implementation, when the CPU and GPU start running, the CPU establishes a daemon thread and a preset buffer. The daemon thread is used by the CPU to monitor in real time whether data updates have occurred in the preset buffer.
[0079] When data is updated in the preset buffer, in one possible implementation, the CPU locks access operations of other GPUs besides the current GPU to the preset buffer. At this time, other GPUs cannot access the preset buffer. Then, the CPU reads the updated data content in the preset buffer and analyzes the data content.
[0080] In one possible implementation, when the data content in the preset buffer is updated, this data content is not necessarily a recursive call request sent by the GPU; it could be a request operation such as kernel function execution, Stream creation, or Event creation. In this case, the CPU needs to determine the updated content in the preset buffer. For example, the CPU performs matching processing on the read data content according to a preset recursive call request format, and determines whether the updated data content in the preset buffer includes a recursive call request based on the matching result. Optionally, if the matching fails, it means that the updated content in the preset buffer does not include a recursive call request, and the CPU clears the data content in the preset buffer and unlocks access to the preset buffer. Optionally, if the matching succeeds, it means that the GPU accessed the preset buffer with a recursive call request. In this case, the CPU generates a second kernel function execution task corresponding to another kernel function based on the execution configuration data packet contained in the recursive call request.
[0081] Step 403: The CPU sends the second core function to the task queue to execute the task based on the recursive call request.
[0082] When the CPU reads the recursive call request, it generates a second kernel function execution task based on the execution configuration data packet contained in the recursive call request. The second kernel function execution task includes the execution configuration data packet and execution incomplete marker information corresponding to other kernel functions.
[0083] The marker information corresponds to a kernel function execution task and includes multiple states to characterize the status of the corresponding kernel function execution task. When the marker information is "execution incomplete", it means that the second kernel function execution task corresponding to the marker information has not been executed. When the CPU sends the second kernel function execution task to the task queue, in order to ensure the accuracy of the execution of the second kernel function execution task, the marker information corresponding to the second kernel function execution task will be initialized, that is, the marker information corresponding to the second kernel function execution task will be set to "execution incomplete". After the GPU completes the execution of the second kernel function execution task, the marker information corresponding to the second kernel function execution task will be set to "execution completed".
[0084] In one possible implementation, the execution parameters of the execution configuration data package, including other kernel functions, include at least execution configuration Grid dimension information, execution configuration Block dimension information, shared memory size, task queue flags, etc. In another possible implementation, when the CPU and GPU are running, the GPU will create multiple task queues. The CPU can send the generated second kernel function execution task to the task queue corresponding to the task queue flag in the execution parameters of other kernel functions according to the task queue flag. For example, when the task queue flag is 0, the CPU will use the default stream corresponding to the GPU as the task queue and send the second kernel function execution task to the corresponding task queue.
[0085] Thus, in the above embodiment, the CPU receives recursive call requests for other kernel functions sent by the GPU through a preset buffer, generates a second kernel function execution task corresponding to the other kernel function, and then sends the second kernel function execution task to the task queue. This allows the GPU to complete the recursive call of the current kernel function to other kernel functions by executing the second kernel function execution task in the task queue. The logic of the recursive call is simple, and locking the preset buffer prevents other GPUs from accessing the preset buffer, thereby improving the accuracy of the CPU in obtaining the data content in the preset buffer.
[0086] In one embodiment, based on the above Figure 4 The illustrated embodiment can be found in [reference]. Figure 5 This embodiment describes the process after the CPU sends the second core function execution task to the task queue. For example... Figure 5 As shown, based on Figure 4 In the embodiment shown, the kernel function call method further includes steps 501 to 503.
[0087] Step 501: The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into a preset buffer.
[0088] In one possible implementation, after the CPU successfully sends the second kernel function execution task to the task queue, the CPU generates a success feedback message. This success feedback message is used by the GPU to determine that the second kernel function execution tasks corresponding to other kernel functions have been sent to the task queue. At this time, the CPU accesses a preset buffer with the success feedback message, and the GPU can read the success feedback message from the preset buffer. For the method by which the GPU determines that the content in the preset buffer is the success feedback message, for example, according to a preset feedback message format, the GPU reads the updated data content in the preset buffer after the access operation is locked, compares the read data content with the feedback message format, and determines whether the success feedback message has been read based on the comparison result.
[0089] Step 502: If the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates the confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer.
[0090] Once the GPU reads the successful transmission feedback information from the preset buffer, it indicates that the GPU has determined that the second kernel function execution task has been successfully sent to the task queue. The GPU only needs to execute the second kernel function execution task to complete the recursive calls of the current kernel function to other kernel functions. At this time, the GPU generates confirmation information corresponding to the second kernel function execution task. This confirmation information is used by the CPU to determine that the GPU knows that the second kernel function execution task has been successfully sent.
[0091] Step 503: If the CPU reads the confirmation information from the preset buffer, it clears the data content in the preset buffer and releases the access operation lock for the preset buffer.
[0092] In one possible implementation, after the GPU sends the confirmation information to the preset buffer, the CPU reads the confirmation information in the preset buffer through a daemon thread. The CPU determines that the GPU has received the successful transmission feedback information based on the confirmation information. At this time, the CPU clears all the data content in the preset buffer and then releases the lock on the access operation of the preset buffer. At this time, each GPU can access the preset buffer.
[0093] Thus, in the above embodiment, after the CPU successfully sends the second core function to execute the task, it clears the data content in the preset buffer and unlocks the access operation of the preset buffer, allowing other GPUs to access the preset buffer, ensuring the security of the data content in the preset buffer and improving the accuracy when recursively calling the core function.
[0094] In one embodiment, based on the above Figure 2 to Figure 4 The illustrated embodiment can be found in [reference]. Figure 6 This embodiment involves the process of the CPU sending kernel functions to the GPU. For example... Figure 6 As shown, based on Figure 2 to Figure 4 In the embodiment shown, the kernel function call method further includes steps 601 and 602.
[0095] Step 601: The CPU obtains the kernel function file corresponding to the kernel function.
[0096] When a high-performance computer needs to solve a target problem, it needs to design multiple kernel functions and corresponding kernel function files based on the problem. After the CPU sends the kernel function files to the GPU, the GPU runs the kernel functions to solve the target problem.
[0097] Step 602: During the compilation of the kernel function file, if the CPU determines that there is a recursive call relationship in the kernel function corresponding to the kernel function file, it adds an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file. The implicit parameter is an address pointer, which is used to point to a preset buffer.
[0098] In one possible implementation, the CPU compiles each kernel function file using a compiler. During the compilation process, for each kernel function file, the CPU checks whether there are recursive call relationships within the kernel functions corresponding to that kernel function file. Optionally, if the CPU detects that the program code contained in the kernel function includes the `hipLaunchKernelGGL` function, it indicates that there is a recursive call relationship within that kernel function. Alternatively, if the CPU detects that the program code contained in the kernel function includes the names of each kernel function, it indicates that there is a recursive call relationship within that kernel function.
[0099] For kernel functions with recursive call relationships, in one possible implementation, the CPU adds an implicit parameter to the kernel function parameter list corresponding to the kernel function file. The implicit parameter is an address pointer. Optionally, the CPU sets the value of the implicit parameter to null. After the preset buffer is established, the address pointer is made to point to the preset buffer.
[0100] Thus, in the above embodiment, after the CPU obtains multiple kernel function files, it adds address pointers to kernel functions with recursive call relationships. The address pointers point to a preset buffer, which enables the GPU to determine the address of the preset buffer, making it easier for the GPU to recursively call kernel functions with recursive call relationships in the future.
[0101] When a high-performance computer needs to solve a target problem, it needs to design multiple kernel functions and corresponding kernel function files based on that problem. In one possible implementation, the design process for each kernel function and its corresponding kernel function file includes:
[0102] Step 1: Construct a target problem model based on the target problem.
[0103] Step 2: Divide the multi-objective problem model into units and determine multiple algorithm units.
[0104] Step 3: Based on the dependencies between the algorithm units, determine the recursive algorithm units that need to be recursively called in each algorithm unit.
[0105] Step 4: Based on the characteristics of each algorithm unit and the dependencies between them, determine the GPU algorithm units that need to be executed on the GPU and the CPU algorithm units that need to be executed on the CPU. For example, algorithm units with intensive computation and high data concurrency are designated as GPU algorithm units, and other algorithm units are designated as CPU algorithm units. GPU algorithm units may include recursive algorithm units that require return calls. A GPU algorithm unit includes at least one kernel function.
[0106] Step 5: Design each algorithm unit according to the dependencies between them. The design content of each GPU algorithm unit includes the name of each kernel function, parameter structure, kernel function calculation process, control flow and memory access structure.
[0107] Step 6: Determine the recursive call relationship between each kernel function in the recursive algorithm unit. Based on the recursive call relationship, design the recursive call process between each kernel function, including the parameter association design between kernel functions with recursive call relationships, the execution parameter design of each kernel function, and the parameter structure design.
[0108] Step 7: Determine the number of kernel functions with recursive call relationships within an algorithm unit, i.e., determine the number of tasks executed by each kernel function. The number of tasks executed by a kernel function is the depth of the recursive call. Verify that the depth of the recursive call is less than the maximum number of tasks that the task queue can hold, which is limited by the GPU hardware. If the depth of the recursive call is verified to be less than the maximum number of tasks that the task queue can hold, it indicates that the recursive call process design is successful, resulting in multiple designed kernel functions with recursive call relationships and the corresponding function files for each kernel function.
[0109] In one embodiment, an exemplary kernel function call method is provided for a server configured with multiple GPUs, the method comprising:
[0110] Step a: The CPU obtains the kernel function file.
[0111] Step b: During the compilation of each kernel function file, if the CPU determines that there is a recursive call relationship in the kernel function corresponding to the kernel function file, it adds implicit parameters to the parameter list of the kernel function corresponding to the kernel function file.
[0112] The implicit parameter is an address pointer, which is used to point to a preset buffer.
[0113] Step c: The GPU retrieves the first kernel function execution task from the task queue and checks whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task.
[0114] The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function.
[0115] Step d: If there is a recursive call relationship in the current kernel function, the GPU generates recursive call requests for other kernel functions and writes the recursive call requests into a preset buffer.
[0116] The recursive call request carries the execution configuration data package corresponding to other kernel functions.
[0117] The server is also equipped with a CPU.
[0118] In step e, if the CPU detects a data update in the preset buffer, it locks other GPUs' access operations to the preset buffer and reads recursive call requests from the preset buffer.
[0119] Step f: The CPU sends a second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to other kernel functions.
[0120] Step g: The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into a preset buffer.
[0121] In step h, if the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates the confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer.
[0122] In step i, if the CPU reads the confirmation information from the preset buffer, it clears the data content in the preset buffer and releases the lock on the access operation to the preset buffer.
[0123] In step j, the GPU marks the first kernel function execution task as blocked. The blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task.
[0124] In step k, the GPU sequentially executes the second kernel function corresponding to each of the other kernel functions to perform the task.
[0125] Step 1: After the execution tasks of each second kernel function have been completed, continue executing the execution tasks of the first kernel function.
[0126] There are multiple other kernel functions, and there are recursive call relationships between these other kernel functions.
[0127] In step m, if the first kernel function execution task is completed, the GPU marks the first kernel function execution task as completed.
[0128] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0129] Based on the same inventive concept, this application also provides a kernel function calling apparatus for implementing the kernel function calling method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations of the one or more kernel function calling apparatus embodiments provided below can be found in the limitations of the kernel function calling method described above, and will not be repeated here.
[0130] In one exemplary embodiment, such as Figure 7 As shown, a kernel function calling device is provided for a server, wherein the server is configured with a GPU, including: a GPU detection module 701 and a GPU execution module 702, wherein:
[0131] GPU detection module 701 is used for the GPU to obtain a first kernel function execution task from the task queue and detect whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function.
[0132] GPU execution module 702 is configured to, if the recursive call relationship exists in the current kernel function, execute the second kernel function execution task corresponding to the other kernel function, and continue to execute the first kernel function execution task after the second kernel function execution task is completed.
[0133] In one embodiment, the number of other kernel functions is multiple, and there is a recursive call relationship among the other kernel functions. The GPU execution module 702 includes:
[0134] The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and continues to execute the first kernel function execution task after each second kernel function execution task has been completed.
[0135] In one embodiment, the server is further configured with a CPU, and the device further includes:
[0136] The writing module is used to generate recursive call requests corresponding to the other kernel functions by the GPU, and write the recursive call requests into a preset buffer. The recursive call requests carry execution configuration data packets corresponding to the other kernel functions.
[0137] The locking module, if the CPU detects that data has been updated in the preset buffer, locks other GPU access operations to the preset buffer and reads the recursive call request from the preset buffer;
[0138] The second kernel function execution task sending module is used by the CPU to send the second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to the other kernel functions.
[0139] In one embodiment, the apparatus further includes:
[0140] The feedback module is used by the CPU to generate a successful transmission feedback message and write the successful transmission feedback message into the preset buffer.
[0141] The confirmation module is used so that if the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer.
[0142] The unlocking module is used to clear the data content in the preset buffer and release the access operation lock for the preset buffer when the CPU reads the confirmation information from the preset buffer.
[0143] In one embodiment, before the GPU execution module 702 completes the GPU's execution of the second kernel function corresponding to the other kernel functions, the apparatus further includes:
[0144] A blocking flag module is used for the GPU to mark the first kernel function execution task as blocked, the blocking state being used to indicate that the GPU is prohibited from executing the first kernel function execution task;
[0145] After the GPU execution module 702 completes the GPU's task of continuing to execute the first core function, the device further includes:
[0146] The completion marking module is used to mark the first kernel function execution task as completed when the first kernel function execution task is completed.
[0147] In one embodiment, the apparatus further includes:
[0148] The acquisition module is used by the CPU to acquire the kernel function file;
[0149] An implicit parameter addition module is used by the CPU to add an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file if it is determined that there is a recursive call relationship in the kernel function corresponding to the kernel function file during the compilation process of each kernel function file. The implicit parameter is an address pointer, which is used to point to the preset buffer.
[0150] Each module in the aforementioned kernel function calling device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0151] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores kernel function call data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a kernel function call method.
[0152] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0153] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0154] The GPU retrieves a first kernel function execution task from the task queue and detects whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function.
[0155] If the recursive call relationship exists in the current kernel function, the GPU executes the second kernel function execution task corresponding to the other kernel function, and continues to execute the first kernel function execution task after the second kernel function execution task is completed.
[0156] In one embodiment, there are multiple other kernel functions, and there are recursive call relationships among these other kernel functions. When the processor executes the computer program, it also performs the following steps:
[0157] The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and continues to execute the first kernel function execution task after each second kernel function execution task has been completed.
[0158] In one embodiment, the server is further configured with a CPU, which, when executing a computer program, also performs the following steps:
[0159] The GPU generates recursive call requests corresponding to the other kernel functions and writes the recursive call requests into a preset buffer. The recursive call requests carry execution configuration data packets corresponding to the other kernel functions.
[0160] If the CPU detects that data has been updated in the preset buffer, it locks other GPUs' access operations to the preset buffer and reads the recursive call request from the preset buffer.
[0161] The CPU sends the second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to the other kernel functions.
[0162] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0163] The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into the preset buffer;
[0164] If the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer.
[0165] When the CPU reads the confirmation information from the preset buffer, it clears the data content in the preset buffer and releases the access operation lock for the preset buffer.
[0166] In one embodiment, before the GPU executes the second kernel function corresponding to the other kernel functions to execute the task, the processor also performs the following steps when executing the computer program:
[0167] The GPU marks the first kernel function execution task as blocked, and the blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task.
[0168] After the GPU continues to execute the first kernel function execution task, the processor also performs the following steps when executing the computer program: when the first kernel function execution task is completed, the GPU marks the first kernel function execution task as completed.
[0169] When a processor executes a computer program, it also performs the following steps:
[0170] The CPU acquires the kernel function file;
[0171] During the compilation process of each kernel function file, if the CPU determines that there is a recursive call relationship in the kernel function corresponding to the kernel function file, it adds an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file. The implicit parameter is an address pointer, which is used to point to the preset buffer.
[0172] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0173] The GPU retrieves a first kernel function execution task from the task queue and detects whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function.
[0174] If the recursive call relationship exists in the current kernel function, the GPU executes the second kernel function execution task corresponding to the other kernel function, and continues to execute the first kernel function execution task after the second kernel function execution task is completed.
[0175] In one embodiment, there are multiple other kernel functions, and there are recursive call relationships among these other kernel functions. When the computer program is executed by the processor, it further implements the following steps:
[0176] The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and continues to execute the first kernel function execution task after each second kernel function execution task has been completed.
[0177] In one embodiment, the server is further configured with a CPU, and when the computer program is executed by the processor, it further performs the following steps:
[0178] The GPU generates recursive call requests corresponding to the other kernel functions and writes the recursive call requests into a preset buffer. The recursive call requests carry execution configuration data packets corresponding to the other kernel functions.
[0179] If the CPU detects that data has been updated in the preset buffer, it locks other GPUs' access operations to the preset buffer and reads the recursive call request from the preset buffer.
[0180] The CPU sends the second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to the other kernel functions.
[0181] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0182] The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into the preset buffer;
[0183] If the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer.
[0184] When the CPU reads the confirmation information from the preset buffer, it clears the data content in the preset buffer and releases the access operation lock for the preset buffer.
[0185] In one embodiment, before the GPU executes the second kernel function corresponding to the other kernel functions to perform the task, the computer program, when executed by the processor, also performs the following steps:
[0186] The GPU marks the first kernel function execution task as blocked, and the blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task.
[0187] After the GPU continues to execute the task of the first core function, the computer program, when executed by the processor, also performs the following steps:
[0188] When the first kernel function execution task is completed, the GPU marks the first kernel function execution task as completed.
[0189] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0190] The CPU acquires multi-core function files;
[0191] During the compilation process of each kernel function file, if the CPU determines that there is a recursive call relationship in the kernel function corresponding to the kernel function file, it adds an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file. The implicit parameter is an address pointer, which is used to point to the preset buffer.
[0192] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0193] The GPU retrieves a first kernel function execution task from the task queue and detects whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function.
[0194] If the recursive call relationship exists in the current kernel function, the GPU executes the second kernel function execution task corresponding to the other kernel function, and continues to execute the first kernel function execution task after the second kernel function execution task is completed.
[0195] In one embodiment, there are multiple other kernel functions, and there are recursive call relationships among these other kernel functions. When the computer program is executed by the processor, it further implements the following steps:
[0196] The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and continues to execute the first kernel function execution task after each second kernel function execution task has been completed.
[0197] In one embodiment, the server is further configured with a CPU, and when the computer program is executed by the processor, it further performs the following steps:
[0198] The GPU generates recursive call requests corresponding to the other kernel functions and writes the recursive call requests into a preset buffer. The recursive call requests carry execution configuration data packets corresponding to the other kernel functions.
[0199] If the CPU detects that data has been updated in the preset buffer, it locks other GPUs' access operations to the preset buffer and reads the recursive call request from the preset buffer.
[0200] The CPU sends the second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to the other kernel functions.
[0201] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0202] The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into the preset buffer;
[0203] If the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer.
[0204] When the CPU reads the confirmation information from the preset buffer, it clears the data content in the preset buffer and releases the access operation lock for the preset buffer.
[0205] In one embodiment, before the GPU executes the second kernel function corresponding to the other kernel functions to perform the task, the computer program, when executed by the processor, also performs the following steps:
[0206] The GPU marks the first kernel function execution task as blocked, and the blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task.
[0207] After the GPU continues to execute the task of the first core function, the computer program, when executed by the processor, also performs the following steps:
[0208] When the first kernel function execution task is completed, the GPU marks the first kernel function execution task as completed.
[0209] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0210] The CPU acquires multi-core function files;
[0211] During the compilation process of each kernel function file, if the CPU determines that there is a recursive call relationship in the kernel function corresponding to the kernel function file, it adds an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file. The implicit parameter is an address pointer, which is used to point to the preset buffer.
[0212] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0213] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0214] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0215] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A kernel function calling method, characterized in that, For a server, the server being configured with a GPU and a CPU, the method includes: The GPU retrieves a first kernel function execution task from the task queue and detects whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function. If the recursive call relationship exists in the current kernel function, the GPU generates a recursive call request corresponding to the other kernel function and writes the recursive call request into a preset buffer. The recursive call request carries an execution configuration data packet corresponding to the other kernel function. If the CPU detects that data has been updated in the preset buffer, it locks other GPUs' access operations to the preset buffer and reads the recursive call request from the preset buffer. The CPU sends a second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and the execution incomplete flag information corresponding to the other kernel functions. The GPU then executes the second kernel function execution task corresponding to the other kernel functions, and continues to execute the first kernel function execution task after the second kernel function execution task is completed.
2. The method according to claim 1, characterized in that, There are multiple other kernel functions, and there is a recursive call relationship between them. The GPU executes the second kernel function execution task corresponding to the other kernel function, and after the second kernel function execution task is completed, it continues to execute the first kernel function execution task, including: The GPU sequentially executes the second kernel function execution tasks corresponding to each of the other kernel functions, and continues to execute the first kernel function execution task after each second kernel function execution task has been completed.
3. The method according to claim 1, characterized in that, The method further includes: The CPU generates a successful transmission feedback message and writes the successful transmission feedback message into the preset buffer; If the GPU reads the successful transmission feedback information from the preset buffer, the GPU generates confirmation information corresponding to the successful transmission feedback information and writes the confirmation information into the preset buffer. When the CPU reads the confirmation information from the preset buffer, it clears the data content in the preset buffer and releases the access operation lock for the preset buffer.
4. The method according to claim 3, characterized in that, Before the GPU executes the second kernel function corresponding to the other kernel functions to perform the task, the method further includes: The GPU marks the first kernel function execution task as blocked, and the blocked state is used to indicate that the GPU is prohibited from executing the first kernel function execution task. After the GPU continues to execute the task using the first kernel function, the method further includes: When the first kernel function execution task is completed, the GPU marks the first kernel function execution task as completed.
5. The method according to any one of claims 3-4, characterized in that, The method further includes: The CPU acquires the kernel function file; During the compilation of the kernel function file, if the CPU determines that the recursive call relationship exists in the kernel function corresponding to the kernel function file, it adds an implicit parameter to the parameter list of the kernel function corresponding to the kernel function file. The implicit parameter is an address pointer, which is used to point to the preset buffer.
6. The method according to claim 5, characterized in that, The implicit parameter is an address pointer in the kernel function parameter list.
7. A kernel function calling device, characterized in that, For use in a server, the server being configured with a GPU and a CPU, the device includes: The GPU detection module is used to obtain a first kernel function execution task from the task queue and detect whether there is a recursive call relationship in the current kernel function corresponding to the first kernel function execution task. The recursive call relationship is used to characterize whether other kernel functions need to be called during the execution of the current kernel function. The writing module is used to, if the recursive call relationship exists in the current kernel function, generate a recursive call request corresponding to the other kernel function in the GPU, and write the recursive call request into a preset buffer, wherein the recursive call request carries an execution configuration data packet corresponding to the other kernel function; A locking module is used to lock other GPUs' access operations to the preset buffer if the CPU detects that data has been updated in the preset buffer, and to read the recursive call request from the preset buffer. The second kernel function execution task sending module is used by the CPU to send a second kernel function execution task to the task queue according to the recursive call request. The second kernel function execution task includes the execution configuration data packet and execution incomplete flag information corresponding to the other kernel functions. The GPU execution module is used to execute the second kernel function execution task corresponding to the other kernel functions, and to continue executing the first kernel function execution task after the second kernel function execution task has been completed.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.