CUDA-Based Data Processing Method, Computing Device, and Storage Medium

By combining continuous space application and data serialization processing of memory and video memory, the problem of multiple applications and copying in the CUDA environment is solved, and data access and task computing efficiency is improved.

CN116243845BActive Publication Date: 2025-08-01SHENZHEN JINGTAI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111485569.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-07
Publication Date
2025-08-01
Estimated Expiration
2041-12-07

AI Technical Summary

Technical Problem

In HPC software development based on CUDA, the prior art requires different data types to be applied for memory and video memory respectively, resulting in an increase in multiple applications and data copy times, affecting video memory access efficiency.

Method used

By obtaining the total storage space of the pending task, combining the memory and video memory to apply for continuous space, serializing the input data and copying it to video memory for storage, and deserializing it for task calculation.

Benefits of technology

Reduces the number of requests for memory and video memory, improves cache utilization and data access efficiency, and improves task computing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116243845B_ABST
    Figure CN116243845B_ABST
Patent Text Reader

Abstract

The present application discloses a CUDA-based data processing method, a computing device, and a storage medium. Among them, the method includes: obtaining input data of at least one task to be processed, where the input data includes data of at least two different data types; determining the total storage space size required for the input data of the at least one task to be processed; applying for a first storage space from the memory of the computing device and a second storage space from the video memory of the computing device according to the total storage space size; serializing the input data of the at least one task to be processed and storing it in the first storage space; copying the serialized input data from the first storage space to the second storage space for storage; deserializing the input data stored in the second storage space, and using the deserialized input data to perform task calculations on the at least one task to be processed. The present invention can reduce the number of data copies and improve data access efficiency and computing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and particularly relates to a CUDA-based data processing method, a computing device, and a storage medium. Background Art

[0002] In the process of developing HPC (High Performance Computing) software based on CUDA (Compute Unified Device Architecture), data cannot be directly loaded into the video memory. It is necessary to pre-apply for corresponding memory space in the memory to store the input data, and the same size of video memory space also needs to be applied in the video memory to store the input data for the graphics card to access during calculation.

[0003] The usual calculation process is to first copy the input data from the memory to the video memory, the graphics card performs the calculation, then store the output result in the video memory, and finally copy the result from the video memory to the memory.

[0004] Currently, when applying for memory and video memory space for input data, it is necessary to apply separately according to different data types, and the data copy between the memory and the video memory is also carried out separately according to different data types.

[0005] The above operation methods mainly have the following disadvantages:

[0006] 1. Multiple memory and video memory applications. The application of video memory is a time-consuming overhead. According to the traditional development mode, different data types need to apply for corresponding resources separately.

[0007] 2. Increase the number of data copies between the memory and the video memory. The data copy between the memory and the video memory is also a time-consuming overhead. Due to disadvantage 1, the number of data copies has to increase.

[0008] 3. It is not conducive to the combined access of the video memory. Applying separately in this way easily leads to scattered storage of data. When the graphics card calculates, it cannot make good use of the bandwidth advantage of video memory access and needs to fetch data from multiple places, resulting in low video memory access efficiency. Summary of the Invention

[0009] To solve or partially solve the problems existing in the related art, this application provides a CUDA-based data processing method, a computing device, and a storage medium, which can reduce the number of data copies and improve data access efficiency and calculation efficiency.

[0010] The first aspect of this application provides a CUDA-based data processing method, which is applied to a computing device, and the method includes:

[0011] Obtain the input data of at least one task to be processed, where the input data includes data of at least two different data types;

[0012] Determine the total storage space size required for the input data of the at least one task to be processed;

[0013] According to the total storage space size, apply for a first storage space from the memory of the computing device and a second storage space from the video memory of the computing device;

[0014] Serialize the input data of the at least one task to be processed and store it in the first storage space;

[0015] Copy the serialized input data from the first storage space to the second storage space for storage;

[0016] Deserialize the input data stored in the second storage space, and use the deserialized input data to perform task calculations on the at least one task to be processed.

[0017] Preferably, when the at least one task to be processed includes multiple tasks to be processed, determining the total storage space size required for the input data of the at least one task to be processed includes:

[0018] According to a preset task calculation algorithm, determine the task type of each task to be processed;

[0019] When the multiple tasks to be processed are all of the same task type, calculate the storage space size required for the input data of the target task to be processed among the multiple tasks to be processed;

[0020] According to the number of tasks of the multiple tasks to be processed and the storage space size required for the input data of the target task to be processed, calculate the total storage space size required for the input data of the multiple tasks to be processed.

[0021] Preferably, the method further includes:

[0022] When the task types of the multiple tasks to be processed are all different, calculate the storage space size required for the input data of each task to be processed and sum them to obtain the total storage space size required for the input data of the multiple tasks to be processed.

[0023] Preferably, the sizes of the first storage space and the second storage space are equal, and both are greater than or equal to the total storage space size.

[0024] Preferably, the method further includes:

[0025] After performing task calculations on the at least one task to be processed, corresponding output data is obtained respectively;

[0026] Based on the output data of the at least one task to be processed, a third storage space is applied for in the memory of the computing device, and a fourth storage space is applied for in the video memory of the computing device;

[0027] The output data of the at least one task to be processed is stored in the fourth storage space;

[0028] The output data of the at least one task to be processed is copied from the fourth storage space to the third storage space for storage.

[0029] Preferably, determining the total storage space size required for the input data of the at least one task to be processed includes:

[0030] According to a preset task calculation algorithm, determine the data type of the output data of each of the tasks to be processed;

[0031] Calculate the total storage space size required for the input data and output data of the at least one task to be processed.

[0032] Preferably, the method further includes:

[0033] After performing task calculations on the at least one task to be processed, corresponding output data is obtained respectively;

[0034] The output data of the at least one task to be processed is stored in the second storage space;

[0035] The output data of the at least one task to be processed is copied from the second storage space to the first storage space for storage.

[0036] Preferably, serializing the input data of the at least one task to be processed and storing it in the first storage space includes:

[0037] Determine the starting address of the first storage space and the basic pointer indicating the starting address;

[0038] According to the data type and data size of the input data of the at least one task to be processed, obtain the storage addresses of each input data through the transformation and offset of the basic pointer;

[0039] According to the storage addresses of each input data, store each input data in the first storage space.

[0040] A second aspect of the present application provides a computing device, including:

[0041] A data acquisition module, configured to acquire input data of at least one task to be processed, where the input data includes data of at least two different data types;

[0042] A space determination module, configured to determine the total storage space size required for the input data of the at least one task to be processed;

[0043] A space application module, configured to apply for a first storage space from the memory of the computing device and a second storage space from the video memory of the computing device according to the total storage space size;

[0044] A data storage module, configured to serialize the input data of the at least one task to be processed and store it in the first storage space;

[0045] A data copy module, configured to copy the serialized input data from the first storage space to the second storage space for storage;

[0046] A task calculation module, configured to deserialize the input data stored in the second storage space, and use the deserialized input data to perform task calculation on the at least one task to be processed.

[0047] A third aspect of the present application provides a computing device, including:

[0048] A processor; and

[0049] A memory, on which executable code is stored, and when the executable code is executed by the processor, the processor is caused to execute the method as described above.

[0050] A fourth aspect of the present application provides a computer-readable storage medium, on which executable code is stored, and when the executable code is executed by a processor of a computing device, the processor is caused to execute the method as described above.

[0051] The technical solution of the present application, after acquiring the input data of different data types of the task to be processed, can first acquire the total storage space size required for the input data, and apply for a continuous storage space for each of the memory and video memory of the computing device according to the total storage space size; serialize the input data and store it in the storage space of the memory, and then copy it to the storage space of the video memory for storage; further, the input data can be deserialized in the video memory for task calculation. The present application can integrate the input data of different data types and store them on a continuous memory and video memory, which not only reduces the number of applications for the storage space of the memory and video memory, improves the cache utilization rate, reduces the overhead caused by memory and video memory applications, but also reduces the number of data copy times, and thus can improve the data access efficiency and task calculation efficiency. Description of the Drawings

[0052] Figure 1 Schematic flow diagram of a CUDA-based data processing method provided by an embodiment of the present invention;

[0053] Figure 2 Schematic diagram of memory arrangement during data serialization provided by an embodiment of the present invention;

[0054] Figure 3 Another schematic diagram of memory arrangement during data serialization provided by an embodiment of the present invention;

[0055] Figure 4 Schematic flow diagram of another CUDA-based data processing method provided by an embodiment of the present invention;

[0056] Figure 5 Schematic diagram of the structure of a computing device provided by an embodiment of the present invention;

[0057] Figure 6 Another schematic diagram of the structure of a computing device provided by an embodiment of the present invention. Detailed implementation manners

[0058] The embodiments of the present application will be described in more detail with reference to the accompanying drawings. Although the embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.

[0059] An embodiment of the present application provides a CUDA-based data processing method, which can be applied to a computing device, such as a computer. As Figure 1 shown, the method may include the following steps:

[0060] S110. Obtain input data of at least one task to be processed, where the input data includes data of at least two different data types.

[0061] In an embodiment of the present application, a task to be processed may include one or more input data, and the data types of different input data may be different.

[0062] For example, if the task to be processed is to calculate the energy of a chemical bond, it is necessary to know which two atoms (ID, integer type) form the chemical bond, the coordinates of these two atoms (3D, floating-point type), the elastic coefficient k of the chemical bond (floating-point type), and the equilibrium value b0 of the bond length (floating-point type). Then the input data for this task to be processed are respectively the IDs of the two atoms (integers), the coordinates of the two atoms {floating-point number, floating-point number, floating-point number}, k {floating-point number}, and b0 {floating-point number}. That is, the input data for this task to be processed contains two types of data: integer type and floating-point type.

[0063] It can be understood that the number of data type categories included in the input data of the task to be processed is related to this task to be processed. The number of data types can be 2, 3, 4, 5 or other values, and the embodiments of this application do not limit this.

[0064] S120. Determine the total storage space size required for the input data of the above at least one task to be processed.

[0065] In the embodiments of this application, when there is only one task to be processed, the storage space size required for the input data of different data types of this task to be processed can be determined first, and then by summing, the total storage space size required for all the input data of this task to be processed can be obtained. Among them, the storage space sizes occupied by the input data of different data types are different, and the size of each data type can be obtained by sizeof(type). When there are multiple tasks to be processed, the total storage space size required for the input data of all tasks to be processed can be calculated according to the task types of each task to be processed.

[0066] In an optional implementation manner, the task type of each task to be processed can be determined according to a preset task calculation algorithm; when multiple tasks to be processed are all of the same task type, calculate the storage space size required for the input data of the target task to be processed among the multiple tasks to be processed; according to the number of tasks of the multiple tasks to be processed and the storage space size required for the input data of the target task to be processed, calculate the total storage space size required for the input data of the multiple tasks to be processed.

[0067] Among them, the calculation algorithm of each task to be processed can be set in advance, such as calculating the energy of a chemical bond, calculating the angle between two chemical bonds, calculating the distance between atoms, and so on. When the calculation algorithms of multiple tasks to be processed are the same, such as all for calculating the energy of a single chemical bond, these tasks to be processed can be classified into the same task type. For tasks to be processed of the same task type, the data types included in their input data are the same, so the storage space sizes required for the input data of tasks to be processed of the same task type are the same. When the calculation algorithms of two tasks to be processed are different, such as one for calculating the energy of a chemical bond and one for calculating the angle between chemical bonds, the two tasks to be processed belong to different task types.

[0068] When the task types of all tasks to be processed are the same, one or any task to be processed can be obtained therefrom as the target task to be processed, and the storage space size n required for the input data of the target task to be processed is calculated. According to the number m of tasks to be processed, the total storage space size m*n required for the input data of all tasks to be processed is obtained. In this way, for multiple tasks to be processed of the same type, the total storage space size required for them can be quickly calculated in batches.

[0069] In an optional implementation manner, when the task types of multiple tasks to be processed are different, the storage space size required for the input data of each task to be processed is calculated and summed to obtain the total storage space size required for the input data of the multiple tasks to be processed.

[0070] Among them, for tasks to be processed of different task types, the data types included in their input data are generally different, so the required storage space sizes are also different. The storage space size required for the input data of each task to be processed can be calculated separately, and then the storage space sizes required for each task to be processed are added together to obtain the total storage space size.

[0071] It can be understood that when some of the tasks to be processed have the same task type and some are different, the same ones can use the method in the previous implementation manner to calculate the storage space size, and the different ones can use the method in the latter implementation manner to calculate the storage space size, and finally sum them to obtain the total storage space size.

[0072] S130. Apply for a first storage space from the memory of the computing device and a second storage space from the video memory of the computing device according to the total storage space size.

[0073] In the embodiments of the present application, according to the total storage space size required for all input data, a continuous storage space can be applied for from the memory and the video memory of the computing device respectively to store the input data. Compared with the traditional technology where memory and video memory spaces need to be applied for separately according to different data types when applying for memory and video memory spaces for input data, the present application can reduce the overhead caused by applying for memory and video memory spaces by combining the applications for memory and video memory spaces. Moreover, storing all input data in a continuous space can improve the cache utilization rate compared with separate storage.

[0074] Among them, the size of the first storage space applied for in the memory and the size of the second storage space applied for in the video memory can be equal, and both are greater than or equal to the total storage space size required for the input data.

[0075] S140. Serialize the input data of the at least one task to be processed and store it in the first storage space.

[0076] In an alternative embodiment, the starting address of the first storage space and a base pointer for indicating the starting address may be determined; according to the data types and data sizes of the input data of the at least one task to be processed, the storage addresses of the respective input data are obtained through the transformation and offset of the base pointer; and the respective input data are stored in the first storage space according to the storage addresses of the respective input data.

[0077] Among them, a pointer can be used to represent a memory address. Since input data of different data types need to be stored in the same storage space, the input data of different data types can be converted to the smallest data unit, and then different types of data are stored through pointer transformation and offset.

[0078] Specifically, the starting address of the first storage space can be represented by a base pointer. Since the memory is a continuously addressed space in bytes, the base pointer can be a char* pointer. According to the data types and sizes of the input data to be stored, for example, a char type occupies 1 byte, an int type occupies 4 bytes, a float type occupies 4 bytes, a double type occupies 8 bytes, etc., the starting positions of the respective input data are obtained through the transformation and offset calculation of the starting address pointer, and the starting positions are stored in the corresponding data pointers, thereby completing the process of data serialization.

[0079] As Figure 2 shown, through the above operations, an int-type data (data_1) and a double-type data (data_2) are stored in the same continuous memory space. When storing each data, the data is linearly distributed. The data size can be stored first, and then the specific content of the data. When there are too many tasks to be processed, to distinguish the input data of different tasks, a task ID can be added before the data size. Through data serialization, different types of data can be integrated and stored in a continuous storage space.

[0080] S150. Copy the serialized input data from the first storage space to the second storage space for storage.

[0081] Among them, when copying the input data from the memory to the video memory, the input data stored in the continuous storage space in the memory can be copied to the video memory for storage at one time, and stored in a continuous storage space allocated in the video memory. Compared with the separate storage and multiple copies in the traditional method, only one copy operation is required in this application, improving the data operation efficiency.

[0082] S160. Deserialize the input data stored in the second storage space, and perform task calculations on the at least one task to be processed by using the input data obtained by deserialization.

[0083] In the embodiment of the present application, when the computing device enters the task calculation stage, only the starting address of the second storage space needs to be obtained, and each input data is read through data deserialization for task calculation.

[0084] By using continuous video memory, the input data of adjacent tasks are placed together, enabling the video memory to be accessed in a combined manner without having to fetch data from multiple locations. This can fully utilize the video memory bandwidth and improve the video memory access efficiency. Storing the input data of multiple tasks in a continuous space enables batch (high-throughput) calculation, thereby improving the task calculation efficiency.

[0085] According to the operating mechanisms of the CPU and GPU of the computing device, more content will be pre-loaded into the cache for continuous memory and video memory. According to the mechanism during the operation of NVIDIA graphics cards, putting data together can improve the access efficiency.

[0086] In the embodiment of the present application, the output data obtained from task calculation can be saved in the continuous storage space that has already been applied for in the memory and video memory, or additional storage space can be applied for in the memory and video memory for saving.

[0087] In an optional implementation manner, the output data obtained from task calculation can be stored separately. The implementation method can include: after performing task calculation on the above-mentioned at least one task to be processed, obtaining the corresponding output data respectively; according to the output data of the above-mentioned at least one task to be processed, applying for a third storage space in the memory of the computing device and a fourth storage space in the video memory of the computing device; storing the output data of the above-mentioned at least one task to be processed in the fourth storage space; and copying the output data of the above-mentioned at least one task to be processed from the fourth storage space to the third storage space for storage.

[0088] Among them, after calculating the output data of all tasks, the total storage space size of all output data can be calculated. According to this total storage space size, a continuous storage space is applied for in the memory and video memory again. First, the output data is saved in the video memory and then copied to the memory once again.

[0089] In an optional implementation manner, the input data and output data can be stored together. Therefore, when applying for memory and video memory space, the storage space size required for the output data needs to be considered together. At this time, the implementation method for step S120 to determine the total storage space size required for the input data of the above-mentioned at least one task to be processed can include: determining the data type of the output data of each task to be processed according to a preset task calculation algorithm; and calculating the total storage space size required for the input data and output data of the above-mentioned at least one task to be processed.

[0090] For example, if the task to be processed is to calculate the energy of a chemical bond, the input data includes the IDs (integers) of the two atoms that form the chemical bond, the coordinates of these two atoms {floating-point number, floating-point number, floating-point number}, the elastic coefficient k (floating-point number) of the chemical bond, and the equilibrium value b0 (floating-point number) of the bond length. First, calculate the spatial distance between the two atoms based on their coordinates to obtain b, and then calculate the energy of the chemical bond as k*(b - b0)*(b - b0) according to the preset task calculation algorithm, that is, the output data is the energy {floating-point number}.

[0091] Among them, the total storage space size required to calculate the input data and output data of all tasks to be processed can refer to the method for calculating the total storage space size required for the input data described above, which will not be elaborated here.

[0092] Furthermore, after performing task calculations on the above-mentioned at least one task to be processed, the corresponding output data is obtained respectively; the output data of the above-mentioned at least one task to be processed is stored in the second storage space; and the output data of the above-mentioned at least one task to be processed is copied from the second storage space to the first storage space for storage.

[0093] As Figure 3 shown, when the task to be processed is to calculate the energy of a chemical bond, the input data can be stored first in a continuous storage space. Here, the input data includes the IDs (int type) of the two atoms, the coordinates of the two atoms (double type), the force field parameters k (double type) and b0 (double type), and then the output data energy value (double type) is stored. Figure 3 The storage method shown is only an example. In actual applications, the arrangement order of the input data can be exchanged. When storing the data of multiple tasks to be processed, the input data of each task to be processed can be stored first, and finally a space is reserved to store the output data uniformly.

[0094] By combining the storage of input data and output data, the number of storage space application times can be further reduced, and the application overhead can be reduced.

[0095] For example, as Figure 4As shown in the figure, the input data of all tasks to be processed is stored on the disk in the form of files. The input files are parsed to obtain the total number of tasks to be processed and the preset task calculation algorithms for the tasks to be processed (the general task calculation algorithms are specified by the user). Calculate the memory and video memory storage space sizes required for the tasks. According to the storage space sizes, apply for a continuous storage space in the memory and the video memory respectively. Serialize the input data and store it in the storage space in the memory, and then copy the input data from the memory to the storage space in the video memory at one time for storage. When the GPU starts task calculation, first deserialize the input data in the video memory, and after performing task calculation through the GPU, obtain the output data. First, save the output data in the video memory (it can be the storage space already applied for in the video memory, or another storage space can be applied for to store the output data). Then, copy the output data from the video memory to the memory for storage at one time (it can be the storage space already applied for in the memory, or another storage space can be applied for to store the output data). Convert the output data into the output format specified by the user and output it from the memory to the disk to obtain the output file.

[0096] The method provided by the embodiment of the present application can integrate the input data of different data types and store them on a continuous memory and video memory, which not only reduces the number of applications for the storage space of the memory and the video memory, improves the cache utilization rate, reduces the overhead caused by the application of the memory and the video memory, but also reduces the number of data copies, and thus can improve the data access efficiency and task calculation efficiency.

[0097] The embodiment of the present application provides a computing device, which can be used to execute the CUDA-based data processing method provided by the above embodiment. As Figure 5 shown, the computing device may include:

[0098] A data acquisition module 510, configured to acquire the input data of at least one task to be processed, where the input data includes data of at least two different data types;

[0099] A space determination module 520, configured to determine the total storage space size required for the input data of the at least one task to be processed;

[0100] A space application module 530, configured to apply for a first storage space from the memory of the computing device and a second storage space from the video memory of the computing device according to the total storage space size;

[0101] A data storage module 540, configured to serialize the input data of the at least one task to be processed and store it in the first storage space;

[0102] A data copy module 550, configured to copy the serialized input data from the first storage space to the second storage space for storage;

[0103] The task calculation module 560 is configured to deserialize the input data stored in the second storage space, and perform task calculation on the at least one task to be processed by using the input data obtained by deserialization.

[0104] Optionally, when the at least one task to be processed includes multiple tasks to be processed, the space determination module 520 may include:

[0105] A task determination sub-module, configured to determine the task type of each task to be processed according to a preset task calculation algorithm;

[0106] A first calculation sub-module, configured to calculate the storage space size required for the input data of the target task to be processed among the multiple tasks to be processed when the multiple tasks to be processed are all of the same task type;

[0107] A second calculation sub-module, configured to calculate the total storage space size required for the input data of the multiple tasks to be processed according to the number of tasks to be processed and the storage space size required for the input data of the target task to be processed.

[0108] Optionally, the space determination module 520 may further include:

[0109] A third calculation sub-module, configured to calculate the storage space size required for the input data of each task to be processed and sum them to obtain the total storage space size required for the input data of the multiple tasks to be processed when the task types of the multiple tasks to be processed are all different.

[0110] Optionally, the sizes of the first storage space and the second storage space may be equal, and both are greater than or equal to the total storage space size.

[0111] Optionally, Figure 5 The illustrated computing device may further include:

[0112] A first data generation module, configured to respectively obtain corresponding output data after the task calculation module 560 performs task calculation on the at least one task to be processed;

[0113] A first data processing module, configured to apply for a third storage space from the memory of the computing device and apply for a fourth storage space from the video memory of the computing device according to the output data of the at least one task to be processed; store the output data of the at least one task to be processed in the fourth storage space; and copy the output data of the at least one task to be processed from the fourth storage space to the third storage space for storage.

[0114] Optionally, the space determination module 520 includes:

[0115] A data determination sub-module, configured to determine the data type of the output data of each task to be processed according to a preset task calculation algorithm;

[0116] A fourth calculation sub-module, configured to calculate the total storage space size required for the input data and output data of the at least one task to be processed.

[0117] Correspondingly, Figure 5 The computing device shown may further include:

[0118] A second data generation module, configured to respectively obtain corresponding output data after the task calculation module 560 performs task calculations on the at least one task to be processed;

[0119] A second data processing module, configured to store the output data of the at least one task to be processed in a second storage space; copy the output data of the at least one task to be processed from the second storage space to the first storage space for storage.

[0120] Optionally, the data storage module 540 includes:

[0121] An address determination sub-module, configured to determine the starting address of the first storage space and a basic pointer indicating the starting address;

[0122] An address acquisition sub-module, configured to obtain the storage addresses of the respective input data through the transformation and offset of the basic pointer according to the data type and data size of the input data of the at least one task to be processed;

[0123] A data storage sub-module, configured to store the respective input data in the first storage space according to the storage addresses of the respective input data.

[0124] The computing device provided by the embodiment of the present application can fuse input data of different data types and store them on a continuous memory and video memory, which not only reduces the number of applications for the storage space of the memory and video memory, improves the cache utilization rate, reduces the overhead caused by memory and video memory applications, but also reduces the number of data copy times, and thus can improve the data access efficiency and task calculation efficiency.

[0125] The embodiment of the present application further provides a computing device, which can be used to execute the CUDA-based data processing method provided by the above embodiment. As Figure 6 shown, the computing device 600 may include: a memory 610 and a processor 620.

[0126] Processor 620 may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0127] Memory 610 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. Among them, the ROM may store static data or instructions required by processor 620 or other modules of the computer. The permanent storage device may be a readable and writable storage device. The permanent storage device may be a non-volatile storage device that does not lose the stored instructions and data even when the computer is powered off. In some embodiments, the permanent storage device uses a mass storage device (such as a magnetic or optical disk, flash memory) as the permanent storage device. In some other embodiments, the permanent storage device may be a removable storage device (such as a floppy disk, optical drive). The system memory may be a readable and writable storage device or a volatile readable and writable storage device, such as dynamic random access memory. The system memory may store some or all of the instructions and data required by the processor during operation. In addition, memory 610 may include any combination of computer-readable storage media, including various types of semiconductor storage chips (such as DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and magnetic disks and / or optical disks may also be used. In some embodiments, memory 610 may include a removable storage device that is readable and / or writable, such as a compact disc (CD), read-only digital versatile disc (such as DVD-ROM, dual-layer DVD-ROM), read-only Blu-ray disc, super density disc, flash memory card (such as SD card, min SD card, Micro-SD card, etc.), magnetic floppy disk, etc. The computer-readable storage medium does not include carrier waves and instantaneous electronic signals transmitted wirelessly or wired.

[0128] An executable code is stored on memory 610. When the executable code is processed by processor 620, it may cause processor 620 to execute some or all of the steps in the methods described above.

[0129] Since this application is based on the CUDA platform, in addition to the memory 610 and the processor 620, the computing device 600 also includes a heterogeneous calculator (not shown in the figure). The heterogeneous calculator can be a GPU (Graphics Processing Unit), or an FPGA, etc. In one implementation, the above-mentioned processor 620 may include the heterogeneous calculator. For example, the processor 620 may include a CPU and a GPU at the same time.

[0130] Correspondingly, the computing device 600 also includes video memory for storing data required for GPU computing. In one implementation, the memory 610 may include both a memory and a video memory structure at the same time.

[0131] In addition, the method according to the present application can also be implemented as a computer program or a computer program product, which includes computer program code instructions for executing some or all of the steps in the above method of the present application.

[0132] Alternatively, the present application can also be implemented as a computer-readable storage medium (or a non-transitory machine-readable storage medium or a machine-readable storage medium), on which executable code (or a computer program or computer instruction code) is stored. When the executable code (or the computer program or computer instruction code) is executed by the processor of a computing device (such as a server, etc.), the processor is caused to execute some or all of the steps of the above method according to the present application.

[0133] The various embodiments of the present application have been described above. The above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations are obvious to those of ordinary skill in the art in the technical field without departing from the scope and spirit of the described embodiments. The selection of the terms used herein is intended to best explain the principles of the embodiments, the practical application, or the improvement of the technology in the market, or to enable other ordinary skill in the art in the technical field to understand the embodiments disclosed herein.

Claims

1. A CUDA-based data processing method, characterized in that, The method is applied to a computing device, and the method includes: Obtain input data of at least one task to be processed, where the input data includes data of at least two different data types; Determine the total storage space size required for the input data of the at least one task to be processed; According to the total storage space size, apply for a first storage space from the memory of the computing device and apply for a second storage space from the video memory of the computing device; Serialize the input data of the at least one task to be processed and store it in the first storage space; Copy the serialized input data from the first storage space to the second storage space for storage; Deserialize the input data stored in the second storage space, and use the deserialized input data to perform task calculations on the at least one task to be processed.

2. The method according to claim 1, wherein When the at least one task to be processed includes multiple tasks to be processed, determining the total storage space size required for the input data of the at least one task to be processed includes: Determine the task type of each task to be processed according to a preset task calculation algorithm; When the multiple tasks to be processed are all of the same task type, calculate the storage space size required for the input data of the target task to be processed among the multiple tasks to be processed; According to the number of tasks of the multiple tasks to be processed and the storage space size required for the input data of the target task to be processed, calculate the total storage space size required for the input data of the multiple tasks to be processed.

3. The method according to claim 2, wherein The method further includes: When the task types of the multiple tasks to be processed are all different, calculate the storage space size required for the input data of each task to be processed and sum them to obtain the total storage space size required for the input data of the multiple tasks to be processed.

4. The method according to claim 1, characterized in that, The sizes of the first storage space and the second storage space are equal and are both greater than or equal to the total storage space size.

5. The method according to claim 1, wherein The method further includes: After performing task calculations on the at least one task to be processed, obtain corresponding output data respectively; According to the output data of the at least one task to be processed, apply for a third storage space from the memory of the computing device and apply for a fourth storage space from the video memory of the computing device; Store the output data of the at least one task to be processed in the fourth storage space; Copy the output data of the at least one task to be processed from the fourth storage space to the third storage space for storage.

6. The method according to claim 1, wherein Determining the total storage space size required for the input data of the at least one task to be processed includes: Determine the data type of the output data of each task to be processed according to a preset task calculation algorithm; Calculate the total storage space size required for the input data and output data of the at least one task to be processed.

7. The method according to claim 6, wherein The method further includes: After performing task calculations on the at least one task to be processed, obtain corresponding output data respectively; Store the output data of the at least one task to be processed in the second storage space; Copy the output data of the at least one task to be processed from the second storage space to the first storage space for storage.

8. The method according to any one of claims 1-7, characterized in that, Serializing the input data of the at least one task to be processed and storing the serialized data in the first storage space includes: Determining a starting address of the first storage space and a base pointer indicating the starting address; Obtaining storage addresses of the input data through casting and offsetting of the base pointer according to the data types and data sizes of the input data of the at least one task to be processed; Storing the input data in the first storage space according to the storage addresses of the input data.

9. A computing device, characterized in that, Including: A data acquisition module configured to acquire input data of at least one task to be processed, where the input data includes data of at least two different data types; A space determination module configured to determine a total storage space size required for the input data of the at least one task to be processed; A space application module configured to apply for a first storage space from the memory of the computing device and apply for a second storage space from the video memory of the computing device according to the total storage space size; A data storage module configured to serialize the input data of the at least one task to be processed and store the serialized data in the first storage space; A data copy module configured to copy the serialized input data from the first storage space to the second storage space for storage; A task calculation module configured to deserialize the input data stored in the second storage space and perform task calculation on the at least one task to be processed by using the deserialized input data.

10. A computing device, characterized in that, Including: A processor; And A memory storing executable code that, when executed by the processor, causes the processor to execute the method according to any one of claims 1-8.

11. A computer-readable storage medium storing executable code that, when executed by a processor of a computing device, causes the processor to execute the method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Ophthalmologic frequency-domain optical coherence tomography (OCT) system based on graphics processing unit (GPU) platform and processing method

    CN102934986A

  • Video memory processing method and device based on convolutional neural network, and storage medium

    CN110377342A