Data transmission method, device, readable storage medium and terminal device

By introducing a task queue processing mechanism between the main processor and the AI ​​co-processor chip, the problem of low data transmission efficiency in the existing technology is solved, efficient data transmission is achieved, coordination management is simplified, and complex task processing efficiency is improved. .

CN114691581BActive Publication Date: 2024-08-23SHENZHEN INTELLIFUSION TECHNOLOGIES CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202011614094.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-29
Publication Date
2024-08-23
Estimated Expiration
2040-12-29

AI Technical Summary

Technical Problem

The existing technology has low data transmission efficiency between the main processor and the AI ​​co-processor chip, which requires complicated coordination and management, especially when processing a large number of complex tasks.

Method used

By creating a data transmission channel between the host side and the slave side, introducing a task queue processing mechanism, using the sending task queue, sending port and receiving port to encapsulate and transmit data processing tasks, realizing the communication between the host side and the slave side threads. Coordinate management and avoid complicated control operations.

Benefits of technology

It greatly improves the processing efficiency of a large number of complex tasks, simplifies the data transmission process, and improves the efficiency of cross-platform data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114691581B
    Figure CN114691581B
Patent Text Reader

Abstract

The present application belongs to the field of chip technology, and in particular, relates to a data transmission method, device, computer-readable storage medium and terminal equipment. The method includes: creating a data transmission channel between a host end and a slave end, the data transmission channel including a sending task queue, a sending port and a receiving port; sending the data processing task of the source thread to the sending task queue; reading the data processing task from the sending task queue through the sending port, encapsulating the data processing task into a data packet and sending it to the receiving port; receiving the data packet through the receiving port, parsing the data processing task from the data packet and sending it to the destination thread. Through the present application, a task queue processing mechanism is introduced in the data transmission channel to realize the coordinated management between the threads of the host end and the threads of the slave end, which greatly improves the processing efficiency of a large number of complex tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of chip technology, and in particular relates to a data transmission method, device, computer-readable storage medium and terminal equipment. Background Art

[0002] With the popularity of various artificial intelligence (AI) chips, AI coprocessor chip solutions have gradually become the main application scenarios of solutions in the field of artificial intelligence. In the existing technology, when performing cross-platform data transmission between the main processor and the AI ​​coprocessor chip, most of them are implemented by directly calling the general USB interface. However, this method requires complicated coordination and management of the data transmission process, and is less efficient when faced with a large number of complex tasks. Summary of the invention

[0003] In view of this, embodiments of the present application provide a data transmission method, apparatus, computer-readable storage medium, and terminal device to solve the problem of low efficiency of existing data transmission methods.

[0004] A first aspect of an embodiment of the present application provides a data transmission method, which may include:

[0005] Creating a data transmission channel between the host end and the slave end, wherein the data transmission channel includes a sending task queue, a sending port and a receiving port;

[0006] Sending a data processing task of a source thread to the sending task queue; the source thread is a data flow output party among the data processing thread of the host end and the data processing thread of the slave end;

[0007] Reading the data processing task from the sending task queue through the sending port, encapsulating the data processing task into a data packet and sending it to the receiving port;

[0008] The data packet is received through the receiving port, the data processing task is parsed from the data packet and sent to a destination thread; the destination thread is a data stream input party between the data processing thread on the host side and the data processing thread on the slave side.

[0009] Furthermore, the step of creating a data transmission channel between the host end and the slave end may include:

[0010] Passing the channel name and channel parameters of the data transmission channel to a channel creation module in a preset channel management component;

[0011] Calling the USB endpoint resource management module in the channel management component through the channel creation module to create a USB endpoint logical channel corresponding to the channel name and the channel parameters;

[0012] The channel creation module creates a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel at the host end and the slave end.

[0013] Further, the data transmission channel is a channel from the host end to the slave end; the creation of a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel on the host end and the slave end by the channel creation module may include:

[0014] Creating a sending port and a sending task queue corresponding to the sending port on the host side through the channel creation module;

[0015] A receiving port is created on the slave side by using a preset remote procedure call module through the channel creation module.

[0016] Further, the data transmission channel is a channel from the slave end to the host end; the creation of a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel on the host end and the slave end by the channel creation module may include:

[0017] Using a preset remote procedure call module through the channel creation module, a sending port and a sending task queue corresponding to the sending port are created on the slave end;

[0018] A receiving port is created on the host side through the channel creation module.

[0019] Furthermore, after the channel name and channel parameters of the data transmission channel are transferred to the channel creation module in the preset channel management component, the method may further include:

[0020] Calling a channel resource management module in the channel management component through the channel creation module to query whether a target channel exists, where the target channel is a data transmission channel corresponding to the channel name and channel parameters;

[0021] If the target channel exists, the channel creation process is stopped.

[0022] Furthermore, sending the data processing task of the source thread to the sending task queue may include:

[0023] Serializing the data processing tasks to obtain serialized data processing tasks;

[0024] compose a new data processing task according to the serialized data processing task, the task type and the pointer of the task queue of the destination thread;

[0025] The new data processing task is sent to the sending task queue.

[0026] Further, encapsulating the data processing task into a data packet and sending the data packet to the receiving port may include:

[0027] Encapsulating the data processing task into a data packet according to a preset packaging format;

[0028] If the data length of the data packet is greater than a preset threshold, sending the data packet to the receiving port;

[0029] If the data length of the data packet is less than or equal to the threshold, a plurality of the data packets are encapsulated into a polypacket and sent to the receiving port.

[0030] A second aspect of an embodiment of the present application provides a data transmission device, which may include various functional modules for implementing any of the above-mentioned data transmission methods.

[0031] A third aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned data transmission methods are implemented.

[0032] A fourth aspect of an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any one of the above-mentioned data transmission methods when executing the computer program.

[0033] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the steps of any one of the above-mentioned data transmission methods.

[0034] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application create a data transmission channel between the host end and the slave end, the data transmission channel includes a sending task queue, a sending port and a receiving port; the data processing task of the source thread is sent to the sending task queue; the data processing task is read from the sending task queue through the sending port, the data processing task is encapsulated into a data packet and sent to the receiving port; the data packet is received through the receiving port, the data processing task is parsed from the data packet and sent to the destination thread. Through the embodiments of the present application, the existing USB interface is further encapsulated as a data transmission channel between the host end and the slave end, and a task queue processing mechanism is introduced therein to realize the coordinated management between the threads of the host end and the threads of the slave end, without the need for the user to perform complicated control operations, which greatly improves the processing efficiency of a large number of complex tasks. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0036] Figure 1 A schematic diagram of a task queue for inter-thread task communication;

[0037] Figure 2 It is a schematic diagram of the USB endpoint logical channel;

[0038] Figure 3 A schematic diagram of a point-to-point channel from a host end to a slave end;

[0039] Figure 4 A schematic diagram of a channel management component for performing point-to-point channel management;

[0040] Figure 5 This is a flow chart of an embodiment of a data transmission method in an embodiment of the present application;

[0041] Figure 6 A schematic diagram of cross-platform data transmission through a data transmission channel;

[0042] Figure 7 A schematic diagram of the package format;

[0043] Figure 8 is a schematic diagram of a poly package;

[0044] Fig. 9 This is a structural diagram of an embodiment of a data transmission device in an embodiment of the present application;

[0045] Fig.10 This is a schematic block diagram of a terminal device in an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0048] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0049] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0050] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0051] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0052] In the present application embodiment, the following can be used: Figure 1The task queue (denoted as TaskQueue) shown in the figure is used to communicate between tasks (denoted as Task) between data processing threads (denoted as Node). TaskQueue uses a fixed-size First Input First Output (FIFO) queue to store Task information between threads. Task information includes Task type information and Task pointer information. Figure 1 In the example shown, the sending threads A and B dynamically apply for Task objects in the heap space, and send tasks X and Y through the TaskQueue object. The receiving thread C reads and processes the Tasks from the TaskQueue object in turn. The Task type is represented by a numerical value, and the type information of the Task pointer is agreed upon. After processing, the Task object is released in the heap space. If the TaskQueue FIFO queue is full when the sending thread sends a task, the sending thread will be blocked until the receiving thread takes the Task out of the FIFO queue; if the TaskQueue FIFO queue is empty when the receiving thread receives a task, the receiving thread will be blocked waiting for the sending thread to send the Task.

[0053] In the embodiment of the present application, a USB endpoint (denoted as Endpoint) can be used to communicate data between a host end (denoted as Host) and a slave end (denoted as Device). Generally, USB supports up to 16 endpoints, and each endpoint can be configured with a maximum transfer block, a transfer direction, and a transfer mode. Among them, the Host is generally a main processor based on X86 or ARM, and the Device is generally a device for a specific purpose, such as an AI coprocessor chip. Figure 2 The figure shows a schematic diagram of a USB endpoint logical channel. The USB endpoint logical channel can be divided into two directions of point-to-point channels (referred to as P2P Channel), namely, a point-to-point channel from Host to Device (referred to as Host→Device P2P Channel), and a point-to-point channel from Device to Host (referred to as Device→Host P2P Channel).

[0054] P2P Channel is an application communication channel carried on the logical channel connection of the USB endpoint, which uses the transmission characteristics of USB to efficiently transmit user data to the other end.

[0055] by Figure 3 Taking the channel from Host to Device as an example, a P2P Channel may include:

[0056] (1) The TaskQueue of the Host's P2P sending port is used to receive Task sending requests from other threads of the Host. The sent Task content includes: Device's TaskQueue information, Task serialization stream information, and Task type information. The Task type information is used to inform the Device how to deserialize the received stream information.

[0057] (2) Host's P2P sending port (denoted as TxChannel), used to retrieve tasks from TaskQueue and assemble them for sending;

[0058] (3) The P2P receiving port of the Device (denoted as RxChannel) is used to receive and unpack data packets. After unpacking, the receiving TaskQueue and Task type information of the Task are obtained and pushed to the TaskQueue corresponding to the Device.

[0059] The P2P Channel from Device to Host is similar to this. It is only necessary to swap Device and Host in the above content, and this embodiment of the present application will not be described in detail.

[0060] In the embodiment of the present application, the host can Figure 4 The channel management component shown (denoted as P2PChannelWrapper) manages the P2P Channel. P2P ChannelWrapper may specifically include the following modules:

[0061] H2D (Host to Device) channel creation module and channel deletion module are responsible for the creation and deletion of P2P channels from Host to Device;

[0062] The D2H (Device to Host) channel creation module and channel deletion module are responsible for the creation and deletion of the P2P Channel from Device to Host;

[0063] Channel resource management module, used to maintain the created P2P Channel resource information and support P2PChannel multiplexing;

[0064] The USB endpoint resource management module is used to manage the use of USB endpoint resources and supports dynamic application and release of USB endpoints in pairs.

[0065] See also Figure 5 , an embodiment of a data transmission method in an embodiment of the present application may include:

[0066] Step S501: Create a data transmission channel between the host end and the slave end.

[0067] In the embodiment of the present application, a P2P Channel may be used as a data transmission channel between a Host and a Device, and the specific creation process thereof may include the following steps:

[0068] (1) The channel name and channel parameters of the data transmission channel to be created are passed to the channel creation module in the channel management component.

[0069] The channel name and the channel parameters can be set by the user according to actual conditions. The channel name can be a combination of numbers, letters and symbols. For example, the channel name can be set to: "H2D VideoStream#1". The channel parameters can include specific parameters such as the maximum transmission block, transmission direction and transmission mode. For example, the maximum transmission block in the channel parameters can be set to 1MB, that is, the maximum data block that can be transmitted in the channel is 1MB.

[0070] If the data transmission channel to be created is a channel from Host to Device, the channel name and the channel parameters need to be passed to the channel creation module of H2D; if the data transmission channel to be created is a channel from Device to Host, the channel name and the channel parameters need to be passed to the channel creation module of D2H.

[0071] (2) calling a channel resource management module in the channel management component through the channel creation module to query whether there is a target channel, where the target channel is a data transmission channel corresponding to the channel name and channel parameters.

[0072] For example, if the channel name is "H2D VideoStream#1", the channel parameter is a maximum transmission block of 1MB, and a channel with the same name is found to exist, and the maximum transmission block of the channel is not less than 1MB, then the channel can be determined as the target channel.

[0073] If the target channel exists, the channel can be used directly without creating a new channel, and the consumption of channel resources can be reduced by reusing the existing channels. At this time, the channel resource management module is called to increase the reference count of the target channel by 1, and step (3) is executed; if the target channel does not exist, a new channel needs to be created, that is, step (4) is continued.

[0074] (3) Stop the channel creation process and return the pointer of the sending task queue of the target channel so that the sending task queue can be directly called when it is needed later.

[0075] (4) Calling the USB endpoint resource management module in the channel management component through the channel creation module to create a USB endpoint logical channel corresponding to the channel name and the channel parameters.

[0076] The USB endpoint resource management module can call the general USB interface and pass specific parameters such as the maximum transmission block, transmission direction and transmission mode in the channel parameters to the API function provided by the USB interface, thereby creating a new USB endpoint logical channel and naming it with the channel name.

[0077] If the USB endpoint resources are insufficient, a message indicating that the channel application has failed is returned, and the reason for the failure, which is that the USB endpoint resources are exhausted, may be included in the message; if the USB endpoint resources are sufficient, step (5) is continued.

[0078] (5) Creating a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel on the Host and Device ends through the channel creation module.

[0079] If the data transmission channel to be created is a channel from the Host to the Device, a sending port and a sending task queue corresponding to the sending port can be created on the Host side through the channel creation module, and a receiving port can be created on the Device side using a preset remote procedure call module (RPC) through the channel creation module, thereby establishing a data transmission channel from the Host to the Device.

[0080] If the data transmission channel to be created is a channel from Device to Host, a sending port and a sending task queue corresponding to the sending port can be created on the Device side using RPC through the channel creation module, and a receiving port can be created on the Host side through the channel creation module, thereby establishing a data transmission channel from Device to Host.

[0081] Through the process of step S501, a cross-platform data transmission channel can be established between the host end and the slave end, thereby providing a basis for subsequent data transmission.

[0082] After completing the above channel creation process, the channel resource management module can be called to increase the reference count of the newly created data transmission channel by 1, and return the pointer of the created sending task queue so that the sending task queue can be directly called when it is needed later.

[0083] Step S502: Send the data processing task of the source thread to the sending task queue.

[0084] The source thread is the data flow output side of the data processing thread on the host side and the data processing thread on the slave side; correspondingly, the destination thread is the data flow input side of the data processing thread on the host side and the data processing thread on the slave side. Figure 6 As shown in the example, the host's thread A sends TaskX1 and TaskX2 type tasks to the device's thread B, and sends TaskY type tasks to the device's thread C. Then thread A is the source thread, and threads B and C are the destination threads.

[0085] Before data transmission, the source thread can obtain the following information through RPC:

[0086] (1) TaskQueue pointer of the destination thread;

[0087] (2) The task type agreement between the source thread and the destination thread is Figure 6 Taking the example shown in the figure, it can be agreed that TaskType 0 in the TaskQueue sent to thread B represents a serialized code stream of type TaskX1, and TaskType 1 represents a serialized code stream of type TaskX2; it is agreed that TaskType 0 in the TaskQueue sent to thread C represents a serialized code stream of type TaskY.

[0088] After obtaining the above information, the source thread can then send the Task data stream. First, according to the task type, the data processing task to be transmitted is serialized to obtain a serialized data processing task, or a Task serialization code stream. Then, a new data processing task is formed according to the serialized data processing task, the task type and the TaskQueue pointer of the destination thread, and the new data processing task is sent to the sending task queue.

[0089] Step S503: read the data processing task from the sending task queue through the sending port, encapsulate the data processing task into a data packet and send it to the receiving port.

[0090] The content read by the sending port includes Task serialization code stream, task type and TaskQueue pointer of the destination thread. After reading these contents, they can be packaged into data packets according to the preset packet format, and the USB endpoint driver is called to send the data packets. The specific packet format can be set according to the actual situation. Figure 7 The figure shows a schematic diagram of a packet format, which adds a transmission header including the following content before the Task serialization code stream:

[0091] Magic word: used for data transmission header detection;

[0092] Data area description: including the length information of Task serialization code stream, etc.

[0093] Task type: Task type identification (id) information. The destination thread deserializes based on the Task type id.

[0094] Destination thread Queue pointer: that is, the TaskQueue pointer of the destination thread;

[0095] Aggregate Packet Number: The number of packets in a transmission block. P2P Channel supports aggregating multiple small data packets and sending them together. See the following detailed instructions for details.

[0096] Cyclic Redundancy Check (CRC) information: optional. If CRC check is supported, CRC calculation is performed on the data area of ​​the transmission header or the transmission header + Task serialization stream to ensure data transmission integrity.

[0097] This packet format makes it easier for the receiver to detect the received data packets and promptly remove invalid data packets that may appear therein, thereby improving the accuracy of the data.

[0098] Preferably, in order to reduce data copying, the embodiment of the present application can allocate a cache (buffer) with a continuous physical address to the user when the user applies for the memory (memory) required for Task serialization, and reserve storage space for the transmission header in front of the buffer. Through such special processing, there is no need to copy data during the transmission packet assembly process.

[0099] After the packet is assembled, if the data length of the data packet is greater than the preset threshold, the data packet can be directly sent to the receiving port without the packet assembly process; if the data length of the data packet is less than or equal to the threshold, several data packets can be encapsulated into one data packet (recorded as a packet assembly) and sent to the receiving port, thereby improving the USB transmission efficiency. Specifically, the sending port can allocate a maximum transmission block buffer supported on the USB endpoint during the initialization phase for the transmission of packet assembly data, and then periodically read Tasks from the TaskQueue continuously, and assemble the packets into the buffer. If the buffer is full, USB transmission is called. The threshold can be set according to the actual situation, and the embodiment of the present application does not specifically limit this.

[0100] Figure 8The figure shows the format of encapsulating two data packets into one aggregate packet for sending. The data length in the transmission header of the aggregate packet is the total length of the transmission headers of the two data packets and the Task serialization code stream. The Task type and the TaskQueue pointer of the destination thread are both -1, which means invalid.

[0101] Step S504: receiving the data packet through the receiving port, parsing the data processing task from the data packet and sending it to the destination thread.

[0102] The receiving port can parse the data packet according to the agreed packet format, and use the magic word and CRC information to determine the validity of the data packet transmission. If invalid, the data packet is discarded. If a packet consisting of multiple data packets is received, it is unpacked according to the indication of the number of packets. For each valid data packet received, the TaskQueue pointer and Task type in the transmission header are read, and the Task is sent to the TaskQueue of the corresponding destination thread. The destination thread reads the Task in its TaskQueue, deserializes it according to the indication of the Task type, and performs subsequent processing.

[0103] After completing the data transfer, you can delete the P2P Channel by following the steps below:

[0104] (1) The channel name of the data transmission channel to be deleted is passed to the channel deletion module in the channel management component.

[0105] If the data transmission channel to be deleted is the channel from Host to Device, the channel name needs to be passed to the channel deletion module of H2D; if the data transmission channel to be deleted is the channel from Device to Host, the channel name needs to be passed to the channel deletion module of D2H.

[0106] (2) The channel resource management module in the channel management component is called by the channel deletion module to query whether there is a target channel, where the target channel is a data transmission channel corresponding to the channel name.

[0107] For example, if the channel name is "H2D VideoStream#1", and a channel with the same name is found to exist, the found channel can be determined as the target channel.

[0108] If the target channel does not exist, a message indicating that the deletion failed is returned, and the reason for the failure may be attached to the message, which is that the non-existent P2P Channel is deleted; if the target channel exists, step (3) is continued.

[0109] (3) The channel resource management module is called by the channel deletion module to reduce the reference count of the target channel by 1. If the reference count is non-zero, a message indicating successful deletion is returned; if the reference count is zero, step (4) is continued.

[0110] (4) The channel deletion module calls the channel resource management module to clear the record of the target channel, and calls the USB endpoint resource management module to release the USB endpoint resources occupied by the target channel, and returns a message indicating that the channel is successfully deleted.

[0111] To sum up, through the embodiments of the present application, the existing USB interface is further encapsulated as a data transmission channel between the host and the slave, and a task queue processing mechanism is introduced therein to realize the coordinated management between the threads of the host and the threads of the slave without the need for the user to perform complicated control operations, thereby greatly improving the processing efficiency of a large number of complex tasks.

[0112] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0113] Corresponding to a data transmission method described in the above embodiment, Fig. 9 A structural diagram of an embodiment of a data transmission device provided in an embodiment of the present application is shown.

[0114] In this embodiment, a data transmission device may include:

[0115] A channel creation module 901 is used to create a data transmission channel between the host end and the slave end, wherein the data transmission channel includes a sending task queue, a sending port and a receiving port;

[0116] A data sending module 902 is used to send the data processing task of the source thread to the sending task queue; the source thread is the data flow output party among the data processing thread of the host end and the data processing thread of the slave end;

[0117] A data encapsulation module 903 is used to read the data processing task from the sending task queue through the sending port, encapsulate the data processing task into a data packet and send it to the receiving port;

[0118] The data receiving module 904 is used to receive the data packet through the receiving port, parse the data processing task from the data packet and send it to the destination thread; the destination thread is the data flow input party between the data processing thread on the host side and the data processing thread on the slave side.

[0119] Furthermore, the channel creation module may include:

[0120] Creating an information transfer unit, used to transfer the channel name and channel parameters of the data transmission channel to a channel creation module in a preset channel management component;

[0121] A resource management unit, configured to call the USB endpoint resource management module in the channel management component through the channel creation module to create a USB endpoint logical channel corresponding to the channel name and the channel parameters;

[0122] The channel creation unit is used to create a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel on the host side and the slave side through the channel creation module.

[0123] Further, the channel creation unit may include:

[0124] The first creation subunit is used to create a sending port and a sending task queue corresponding to the sending port on the host side through the channel creation module; and to create a receiving port on the slave side using a preset remote procedure call module through the channel creation module.

[0125] The second creation subunit is used to create a sending port and a sending task queue corresponding to the sending port on the slave side through the channel creation module using a preset remote procedure call module; and to create a receiving port on the host side through the channel creation module.

[0126] Furthermore, the channel creation module may also include:

[0127] A channel query unit, configured to call a channel resource management module in the channel management component through the channel creation module to query whether a target channel exists, wherein the target channel is a data transmission channel corresponding to the channel name and channel parameters;

[0128] The creation stopping unit is used to stop the channel creation process if the target channel exists.

[0129] Furthermore, the data sending module may include:

[0130] A serialization unit, used for serializing the data processing tasks to obtain serialized data processing tasks;

[0131] A packaging unit, used to compose a new data processing task according to the serialized data processing task, the task type and the pointer of the task queue of the destination thread;

[0132] A sending unit is used to send the new data processing task to the sending task queue.

[0133] Furthermore, the data encapsulation module may include:

[0134] A packaging unit, used for packaging the data processing task into a data packet according to a preset packaging format;

[0135] A first processing unit, configured to send the data packet to the receiving port if the data length of the data packet is greater than a preset threshold;

[0136] The second processing unit is configured to encapsulate a plurality of the data packets into a polypacket and send the polypacket to the receiving port if the data length of the data packet is less than or equal to the threshold.

[0137] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0138] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0139] Fig.10 A schematic block diagram of a terminal device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0140] like Fig.10 As shown, the terminal device 10 of this embodiment includes: a processor 100, a memory 101, and a computer program 102 stored in the memory 101 and executable on the processor 100. When the processor 100 executes the computer program 102, the steps in the above-mentioned various data transmission method embodiments are implemented, for example Figure 5 Alternatively, when the processor 100 executes the computer program 102, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Fig. 9 The functions of modules 901 to 904 are shown.

[0141] Exemplarily, the computer program 102 may be divided into one or more modules / units, which are stored in the memory 101 and executed by the processor 100 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 102 in the terminal device 10.

[0142] The terminal device 10 may be a computing device such as a desktop computer, a notebook, a PDA, a smart phone, a smart TV, etc. Those skilled in the art will appreciate that Fig.10 It is only an example of the terminal device 10 and does not constitute a limitation of the terminal device 10. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device 10 may also include input and output devices, network access devices, buses, etc.

[0143] The processor 100 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc. The processor 100 may be the nerve center and command center of the terminal device 10. The processor 100 may generate an operation control signal according to an instruction operation code and a timing signal to complete the control of fetching and executing instructions.

[0144] The memory 101 may be an internal storage unit of the terminal device 10, such as a hard disk or memory of the terminal device 10. The memory 101 may also be an external storage device of the terminal device 10, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 10. Further, the memory 101 may also include both an internal storage unit of the terminal device 10 and an external storage device. The memory 101 is used to store the computer program and other programs and data required by the terminal device 10. The memory 101 may also be used to temporarily store data that has been output or is to be output.

[0145] The terminal device 10 may also include a communication module, which may provide communication solutions including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth, Zigbee, mobile communication networks, global navigation satellite systems (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to network devices. The communication module may be one or more devices integrating at least one communication processing module. The communication module may include an antenna, which may have only one array element or an antenna array including multiple array elements. The communication module may receive electromagnetic waves through the antenna, frequency modulate and filter the electromagnetic wave signals, and send the processed signals to the processor. The communication module may also receive the signal to be sent from the processor, frequency modulate and amplify it, and convert it into electromagnetic waves for radiation through the antenna.

[0146] The terminal device 10 may further include a power management module, which may receive input from an external power source, a battery, and / or a charger to supply power to the processor, the memory, the communication module, and the like.

[0147] The terminal device 10 may further include a display module, which may be used to display information input by a user or information provided to a user. The display module may include a display panel, and optionally, the display panel may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel may cover the display panel, and when the touch panel detects a touch operation on or near it, it is transmitted to the processor to determine the type of the touch event, and then the processor provides a corresponding visual output on the display panel according to the type of the touch event.

[0148] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0149] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0150] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0151] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0154] An embodiment of the present application provides a computer program product. When the computer program product runs on the terminal device, the terminal device can implement the steps in the above-mentioned various method embodiments.

[0155] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0156] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A data transmission method, characterized in that: include: A data transmission channel is created between a host end and a slave end, wherein the data transmission channel includes a sending task queue, a sending port, and a receiving port; the host end is a main processor; and the slave end is an AI coprocessor chip; Sending a data processing task of a source thread to the sending task queue; the source thread is a data flow output party among the data processing thread of the host end and the data processing thread of the slave end; Reading the data processing task from the sending task queue through the sending port, encapsulating the data processing task into a data packet and sending it to the receiving port; Receiving the data packet through the receiving port, parsing the data processing task from the data packet and sending it to the task queue corresponding to the destination thread; The task queue is used to communicate tasks between data processing threads; The destination thread is a data stream input party among the data processing thread on the host side and the data processing thread on the slave side.

2. The data transmission method according to claim 1, characterized in that: The step of creating a data transmission channel between the host end and the slave end includes: Passing the channel name and channel parameters of the data transmission channel to a channel creation module in a preset channel management component; Calling the USB endpoint resource management module in the channel management component through the channel creation module to create a USB endpoint logical channel corresponding to the channel name and the channel parameters; The channel creation module creates a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel at the host end and the slave end.

3. The data transmission method according to claim 2, characterized in that: The data transmission channel is a channel from the host end to the slave end; The creating, at the host end and the slave end, a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel by the channel creation module includes: Creating a sending port and a sending task queue corresponding to the sending port on the host side through the channel creation module; A receiving port is created on the slave side by using a preset remote procedure call module through the channel creation module.

4. The data transmission method according to claim 2, characterized in that: The data transmission channel is a channel from the slave end to the host end; The creating, at the host end and the slave end, a sending task queue, a sending port and a receiving port corresponding to the USB endpoint logical channel by the channel creation module includes: Using a preset remote procedure call module through the channel creation module, a sending port and a sending task queue corresponding to the sending port are created on the slave end; A receiving port is created on the host side through the channel creation module.

5. The data transmission method according to claim 2, characterized in that: After the channel name and channel parameters of the data transmission channel are transferred to the channel creation module in the preset channel management component, the method further includes: Calling a channel resource management module in the channel management component through the channel creation module to query whether a target channel exists, where the target channel is a data transmission channel corresponding to the channel name and channel parameters; If the target channel exists, the channel creation process is stopped.

6. The data transmission method according to claim 1, characterized in that: The sending of the data processing task of the source thread to the sending task queue includes: Serializing the data processing tasks to obtain serialized data processing tasks; composing a new data processing task according to the serialized data processing task, the task type and the pointer of the task queue of the destination thread; The new data processing task is sent to the sending task queue.

7. The data transmission method according to any one of claims 1 to 6, characterized in that: The step of encapsulating the data processing task into a data packet and sending the data packet to the receiving port includes: Encapsulating the data processing task into a data packet according to a preset packaging format; If the data length of the data packet is greater than a preset threshold, sending the data packet to the receiving port; If the data length of the data packet is less than or equal to the threshold, a plurality of the data packets are encapsulated into a polypacket and sent to the receiving port.

8. A data transmission device, characterized in that: include: A channel creation module is used to create a data transmission channel between a host end and a slave end, wherein the data transmission channel includes a sending task queue, a sending port and a receiving port; the host end is a main processor; and the slave end is an AI coprocessor chip; A data sending module, used for sending the data processing task of a source thread to the sending task queue; the source thread is the data flow output party among the data processing thread of the host end and the data processing thread of the slave end; A data encapsulation module, used for reading the data processing task from the sending task queue through the sending port, encapsulating the data processing task into a data packet and sending the data packet to the receiving port; A data receiving module, used for receiving the data packet through the receiving port, parsing the data processing task from the data packet and sending the task to the task queue corresponding to the destination thread; The task queue is used to communicate tasks between data processing threads; The destination thread is a data stream input party among the data processing thread on the host side and the data processing thread on the slave side.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the data transmission method according to any one of claims 1 to 7 are implemented.

10. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data transmission method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • A method and apparatus for providing a picture in picture service

    CN101371570A

  • H264-based real-time mobile video service control method

    CN103051978A

  • RDMA data processing method and related device

    CN110399329A

  • Method of master-slave communication in OLT system

    CN111131932A

  • Method, device, and system for information processing based on distributed buses

    WO2014082562A1