Time conversion method and device, electronic equipment, storage medium and program product

By updating the time conversion relationship between the device to be converted and the reference device, the problem of time out of synchronization of multiple devices is solved, and high-precision time synchronization and accuracy of performance analysis is achieved.

CN119937727APending Publication Date: 2025-05-06NANJING ILUVATAR COREX TECH CO LTD (DBA ILUVATAR COREX INC NANJING)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411996002.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

Time synchronization of multiple devices leads to inaccurate parallel program performance analysis and data presentation.

Method used

By determining whether the time conversion relationship between the device to be converted and the reference device needs to be updated, obtain the respective sample values ​​at the current time, and update the time conversion relationship to eliminate the accumulation of errors caused by time lapse.

Benefits of technology

High-precision time synchronization between each device is achieved, ensuring that data is processed and analyzed under the same time benchmark, and improving the accuracy of performance analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119937727A_ABST
    Figure CN119937727A_ABST
Patent Text Reader

Abstract

The invention relates to a time conversion method and device, electronic equipment, a storage medium and a program product, and belongs to the field of computers. The time conversion method comprises the following steps: judging whether a time conversion relationship between to-be-converted equipment and reference equipment at the current moment needs to be updated or not; if yes, acquiring respective sampling values of the to-be-converted equipment and the reference equipment at the current moment; updating a time conversion relationship between the to-be-converted equipment and the reference equipment based on the sampling values of the to-be-converted equipment and the reference equipment at the current moment; wherein the updated time conversion relation is used for converting the time of the equipment to be converted into the time under the time system of the reference equipment. According to the method and the device, time synchronization between the devices (such as the to-be-converted device and the reference device) can be ensured, so that the data of the devices can be processed and analyzed under the same time reference.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computers, and specifically relates to a time conversion method, device, electronic device, storage medium and program product. Background Art

[0002] With the advent of the era of artificial intelligence (AI), the development of high-performance computing systems based on acceleration devices has become a trend, but designing efficient parallel computing programs is still a complex and high-threshold task. Therefore, parallel program performance analysis becomes particularly important. Since the program may run in parallel on multiple different devices, and each device runs an independent clock, the time information (including time) generated is also different. Therefore, an efficient and accurate method is needed to achieve time synchronization between multiple devices to ensure that the data of each device can be processed and analyzed under the same time reference. A synchronization method with fixed parameters will accumulate errors over time, resulting in the inability to accurately synchronize between multiple devices, which in turn affects the accuracy of parallel program performance analysis. Summary of the invention

[0003] In view of this, the purpose of the present application is to provide a time conversion method, apparatus, electronic device, storage medium and program product to solve the defect of inaccurate performance analysis and data display caused by time asynchrony of multiple devices in the related art.

[0004] The embodiment of the present application is implemented as follows:

[0005] In the first aspect, an embodiment of the present application provides a time conversion method, including: determining whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated; if yes, obtaining the sampling values ​​of the device to be converted and the reference device at the current moment; updating the time conversion relationship between the device to be converted and the reference device based on the sampling values ​​of the device to be converted and the reference device at the current moment; wherein the updated time conversion relationship is used to convert the time of the device to be converted into the time under the time system of the reference device.

[0006] In the above embodiment, when converting the time of the device to be converted into the time under the time system of the reference device, it is first determined whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated. When updating is required, it is only necessary to obtain the sampling values ​​of the device to be converted and the reference device at the current moment, so as to accurately and quickly update the time conversion relationship between the device to be converted and the reference device, so as to eliminate the error accumulation generated over time, so that the conversion method has higher accuracy, thereby ensuring the time synchronization between each device (such as the device to be converted and the reference device), thereby ensuring that the data of each device can be processed and analyzed under the same time reference, so as to solve the defect of inaccurate performance analysis and data display caused by the time asynchrony of multiple devices in the related technology.

[0007] In combination with a possible implementation manner of the embodiment of the first aspect, it is determined whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated, including: obtaining the sampling time points of the device to be converted and the reference device at the current moment; determining whether the ratios of the sampling time points of the device to be converted and the reference device at the current moment relative to the target sampling time points of the device to be converted are within a preset range; if the ratios of the sampling time points of the device to be converted and the reference device at the current moment relative to the target sampling time points of the device to be converted are both within the preset range, it is determined that the time conversion relationship between the device to be converted and the reference device needs to be updated.

[0008] In the above embodiment, when judging whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated, the abnormal timeSample value (sampling value) can be eliminated by judging whether the ratio of the sampling time points of the device to be converted and the reference device at the current moment relative to the target sampling time point of the device to be converted is within a preset range, thereby ensuring that the time of the reference device for conversion alignment is monotonically increasing.

[0009] In combination with a possible implementation method of the first aspect, obtaining the sampling time points of the device to be converted and the reference device at the current moment includes: continuously sampling the time of the device to be converted and the reference device N times, where N is an integer greater than or equal to 2; selecting the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted to obtain the sampling time point of the device to be converted at the current moment; selecting the shortest interval time from the N-1 adjacent sampling intervals of the reference device to obtain the sampling time point of the reference device at the current moment.

[0010] In the above embodiment, by performing multiple samplings continuously and selecting the shortest interval time among multiple sampling intervals as the current sampling time point, random errors in sampling can be eliminated, thereby improving the accuracy of sampling.

[0011] In combination with a possible implementation method of the first aspect, the sampling values ​​of the device to be converted and the reference device at the current moment are obtained, including: selecting a first sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtaining the sampling value of the device to be converted at the current moment based on the first sampling time pair; selecting a second sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the reference device, and obtaining the sampling value of the reference device at the current moment based on the second sampling time pair.

[0012] In the above embodiment, by continuous multiple sampling, the sampling time pair corresponding to the shortest interval time among multiple sampling intervals is selected to obtain the sampling value. For example, the sampling value can be the average value of the two times included in the sampling time pair to improve the sampling accuracy.

[0013] In combination with a possible implementation manner of the embodiment of the first aspect, after the time conversion relationship between the device to be converted and the reference device needs to be updated, the method further includes: updating the target sampling time point according to the sampling time point of the device to be converted at the current moment to obtain an updated target sampling time point, wherein the updated target sampling time point is used for subsequent determination of whether the time conversion relationship needs to be updated.

[0014] In the above embodiment, after the time conversion relationship between the device to be converted and the reference device needs to be updated, the target sampling time point is also required to eliminate the error accumulation generated over time, and then based on the updated target sampling time point, it is determined whether the subsequent time conversion relationship needs to be updated, so that the conversion method has higher accuracy.

[0015] In combination with a possible implementation manner of the embodiment of the first aspect, the time conversion relationship includes a conversion coefficient, and the method further includes: obtaining a benchmark historical time of the device to be converted and the reference device at a first historical moment, and obtaining a relative historical time of the device to be converted and the reference device at a second historical moment; determining a first difference between the relative historical time of the device to be converted and the benchmark historical time; determining a second difference between the relative historical time of the reference device and the benchmark historical time; and determining the conversion coefficient based on the first difference and the second difference.

[0016] In the above embodiment, by obtaining sampling values ​​at two historical moments (reference historical time, relative historical time), a conversion coefficient can be determined according to the first difference and the second difference, thereby providing a general conversion method for subsequent time conversion.

[0017] In combination with a possible implementation manner of the embodiment of the first aspect, a benchmark historical time of the device to be converted and the reference device at the first historical moment is obtained, including: at the first historical moment, continuously sampling the time of the device to be converted and the reference device N times, where N is an integer greater than or equal to 2; selecting a first historical sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtaining the benchmark historical time of the device to be converted at the first historical moment based on the first historical sampling time pair; selecting a second historical sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the reference device, and obtaining the benchmark historical time of the reference device at the first historical moment based on the second historical sampling time pair.

[0018] In the second aspect, an embodiment of the present application also provides a time conversion device, including: a judgment module, an acquisition module and an update module; the judgment module is used to judge whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated; the acquisition module is used to obtain the sampling values ​​of the device to be converted and the reference device at the current moment when the judgment is yes; the update module is used to update the time conversion relationship between the device to be converted and the reference device based on the sampling values ​​of the device to be converted and the reference device at the current moment; wherein the updated time conversion relationship is used to convert the time of the device to be converted into the time under the time system of the reference device.

[0019] In the third aspect, an embodiment of the present application also provides an electronic device, comprising: a memory and a processor, the processor being connected to the memory; the memory being used to store programs; the processor being used to call the programs stored in the memory to execute a time conversion method provided in any possible implementation manner of the above-mentioned first aspect embodiment.

[0020] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the time conversion method provided in any possible implementation manner of the embodiment of the first aspect described above is executed.

[0021] In a fifth aspect, an embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements a time conversion method provided in any possible implementation manner of the embodiment of the first aspect described above.

[0022] Other features and advantages of the present application will be described in the following description. The purpose and other advantages of the present application can be realized and obtained through the structures specifically pointed out in the written description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings. The above and other purposes, features and advantages of the present application will be more clearly shown in the drawings.

[0024] Figure 1 A schematic flow chart of a time conversion method provided in an embodiment of the present application is shown.

[0025] Figure 2 A schematic diagram showing the principle of obtaining time provided in an embodiment of the present application is shown.

[0026] Figure 3 A schematic diagram showing a principle of obtaining a conversion coefficient provided in an embodiment of the present application is shown.

[0027] Figure 4 A schematic diagram showing the principle of a time conversion method provided in an embodiment of the present application is shown.

[0028] Figure 5 A schematic diagram showing the principle of obtaining a sampling time point and a sampling value provided in an embodiment of the present application is shown.

[0029] Figure 6 A module schematic diagram of a time conversion device provided in an embodiment of the present application is shown.

[0030] Figure 7 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The following embodiments can be used as examples to more clearly illustrate the technical solutions of the present application, and cannot be used to limit the scope of protection of the present application. It will be appreciated by those skilled in the art that, in the absence of conflict, the features in the following embodiments and embodiments can be combined with each other.

[0032] It should be noted that similar numbers and letters represent similar items in the following figures, so once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0033] Furthermore, the term "and / or" in this application is merely a term used to describe the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone.

[0034] In the description of the embodiments of the present application, unless otherwise clearly specified or limited, the technical term "connection" may refer to a direct connection or an indirect connection through an intermediate medium.

[0035] An embodiment of the present application provides a time conversion method for dynamically updating parameters at runtime, which can ensure time synchronization between various devices (such as the device to be converted and the reference device), thereby ensuring that the data of each device can be processed and analyzed under the same time reference, so as to solve the defect of inaccurate performance analysis and data display caused by time asynchrony of multiple devices in related technologies.

[0036] The devices to be converted in this application include but are not limited to graphics processing units (GPUs), and the reference devices include but are not limited to central processing units (CPUs). In the following examples of this application, the conversion of GPU time to CPU time is taken as an example, but the time conversion of this application is not limited to aligning different GPU time axes in the system to the CPU time axis.

[0037] Combine the following Figure 1 The time conversion method provided in the embodiment of the present application is described.

[0038] S1: Determine whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated.

[0039] When it is necessary to convert the time of the device to be converted, it can be determined first whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated. If the time conversion relationship needs to be updated, execute S2; otherwise, the time of the device to be converted is directly converted based on the time conversion relationship between the device to be converted and the reference device at the current moment.

[0040] In a possible implementation, when determining whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated, the process may include: determining whether the sampling values ​​of the device to be converted and the reference device at the current moment are equivalent to the distance of the straight line where the time conversion relationship is located, to determine whether the current time conversion relationship needs to be updated, if the sampling value is equivalent to the distance of the straight line where the time conversion relationship is located is greater than the target threshold (configurable), then the time conversion relationship is not updated, indicating that the sampling value at the current moment is an abnormal value. Otherwise, the time conversion relationship needs to be updated.

[0041] In another possible implementation, when determining whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated, the process may include: obtaining the sampling time points of the device to be converted and the reference device at the current moment; determining whether the ratios of the sampling time points of the device to be converted and the reference device at the current moment relative to the target sampling time points of the device to be converted are within a preset range; if the ratios of the sampling time points of the device to be converted and the reference device at the current moment relative to the target sampling time points of the device to be converted are both within the preset range, it is determined that the time conversion relationship between the device to be converted and the reference device needs to be updated.

[0042] For example, taking the reference device as the CPU, the sampling time point of the device to be converted is represented by TempMinDevDiff, the sampling time point of the reference device is represented by TempMinCPUDiff, and the target sampling time point of the device to be converted is represented by MinDevDiff. Then the update condition can be expressed as:

[0043] TempMinDevDiff≤(MinDevDiff*a)&&≤

[0044] (MinDevDiff*a), where a is a preset coefficient, which is usually between 1 and 1.2 and may include endpoint values. In some embodiments, a is preferably an empirical value of 1.03. If the sampling time points of the device to be converted and the reference device at the current moment meet the above update conditions, the time conversion relationship needs to be updated. The above update conditions can ensure that the result of the conversion alignment is monotonically increasing and more accurate.

[0045] In some possible implementations, when obtaining the sampling time points of the device to be converted and the reference device at the current moment, the process may include: calling the loop function func_get_timesample() to continuously sample the time of the device to be converted and the reference device N times, where N is an integer greater than or equal to 2; selecting the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted to obtain the sampling time point of the device to be converted at the current moment, that is, TempMinDevDiff; selecting the shortest interval time from the N-1 adjacent sampling intervals of the reference device to obtain the sampling time point of the reference device at the current moment, that is, TempMinCPUDiff.

[0046] Among them, when continuously sampling the time of the device to be converted and the reference device N times, the time sampling command (denoted as CMD_GET_TIMESTAMP) can be called N times in a loop to sample the time of the device to be converted and the reference device N times, wherein each call to the time sampling command completes the sampling of the time of the device to be converted and the reference device once.

[0047] In some possible implementations, the system can also enable the system to disable the preemption function each time the time sampling command is called. After obtaining the corresponding time, the system can disable the preemption function. When the time sampling command is called next time, the system can enable the system to disable the preemption function. The schematic diagram is as follows: Figure 2 In the process of obtaining the respective times of the device to be converted and the reference device, by enabling the system to disable the preemption function, the program currently used to obtain the timestamp can be prevented from being interrupted by interrupts or other kernel tasks, thereby eliminating the error introduced by CPU scheduling.

[0048] In some possible implementations, after the time conversion relationship between the device to be converted and the reference device needs to be updated, the above-mentioned time conversion method also includes: updating the target sampling time point according to the sampling time point of the device to be converted at the current moment, to obtain an updated target sampling time point, wherein the updated target sampling time point can be used for subsequent judgment whether the time conversion relationship needs to be updated.

[0049] In one implementation, the target sampling time point may be updated based on the following update formula: (MinDevDiff before update + TempMinDevDiff).

[0050] Each time the time conversion relationship is updated, MinDevDiff is updated. The initial value of MinDevDiff can be the shortest interval time selected from the N-1 adjacent sampling intervals of the device to be converted for the first time, that is, the initial value of MinDevDiff is equal to the first TempMinDevDiff. Before the first TempMinDevDiff is obtained, the initial value of MinDevDiff is 0.

[0051] S2: Obtain the sampling values ​​of the device to be converted and the reference device at the current moment.

[0052] When the time conversion relationship needs to be updated, the sampling values ​​of the device to be converted and the reference device at the current moment are obtained.

[0053] In one possible implementation, when obtaining the sampling values ​​(i.e., timeSample) of the device to be converted and the reference device at the current moment, the process may be to select a first sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtain the sampling value of the device to be converted at the current moment based on the first sampling time pair; select a second sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the reference device, and obtain the sampling value of the reference device at the current moment based on the second sampling time pair. In this implementation, the sampling value of the device to be converted at the current moment may be the average value of the two times included in the first sampling time pair, and similarly, the sampling value of the reference device at the current moment may be the average value of the two times included in the second sampling time pair.

[0054] In one possible implementation, when obtaining the sampling values ​​of the device to be converted and the reference device at the current moment, they can be directly obtained from the database. In one possible implementation, when obtaining the sampling values ​​of the device to be converted and the reference device at the current moment, the process may include: according to the time of continuously sampling the device to be converted and the reference device N times, the sampling values ​​of the device to be converted and the reference device at the current moment are obtained. For example, the sampling value of the device to be converted at the current moment is equal to the average value of the sampling values ​​of the continuous N samplings. Similarly, the sampling value of the reference device at the current moment is equal to the average value of the sampling values ​​of the continuous N samplings.

[0055] S3: Based on the sampling values ​​of the device to be converted and the reference device at the current moment, the time conversion relationship between the device to be converted and the reference device is updated.

[0056] After obtaining the sampling values ​​of the device to be converted and the reference device at the current moment, the time conversion relationship between the device to be converted and the reference device can be updated based on the sampling values ​​of the device to be converted and the reference device at the current moment. The updated time conversion relationship is used to convert the time of the device to be converted into the time under the time system of the reference device.

[0057] The time conversion relationship includes a conversion coefficient, such as represented by factor K. In one implementation, the conversion coefficient can be calculated using the following formula:

[0058]

[0059] Among them, when updating the time conversion relationship, the conversion coefficient can be updated. For example, the value of EndSample.devTime in the formula can be replaced with the sampling value of the device to be converted at the current moment, and the value of EndSample.cpuTime in the formula can be replaced with the sampling value of the device to be referenced at the current moment. The values ​​of StartSample.cpuTime and StartSample.devTime in the formula are both fixed values. EndSample.devTime represents the relative historical time obtained by sampling the device to be converted at the second historical moment; EndSample.cpuTime represents the relative historical time obtained by sampling the reference device at the second historical moment; StartSample.devTime represents the benchmark historical time obtained by sampling the device to be converted at the first historical moment; StartSample.cpuTime represents the benchmark historical time obtained by sampling the reference device at the first historical moment. Relative historical time and benchmark historical time are relative concepts. The value of benchmark historical time is fixed, and the value of relative historical time can be updated.

[0060] In some implementations, the time conversion relationship may be: cpuTime=factorK*(-StartSample.devTime)+StartSample.cpuTime, wherein devTime is the time of the device to be converted, and cpuTime represents the time of the device to be converted converted into the time system of the reference device.

[0061] In a possible implementation, the above-mentioned time conversion method may also include: obtaining the benchmark historical time of the device to be converted and the reference device at the first historical moment, and obtaining the relative historical time of the device to be converted and the reference device at the second historical moment; determining the first difference between the relative historical time of the device to be converted and the benchmark historical time; determining the second difference between the relative historical time of the reference device and the benchmark historical time; and determining the conversion coefficient according to the first difference and the second difference. For example, the conversion coefficient may be the second difference / the first difference. This process is the process of obtaining the initial conversion coefficient. After the initial conversion coefficient is obtained, when the conversion coefficient is subsequently updated, only the values ​​of EndSample.devTime and EndSample.cpuTime in the formula need to be updated.

[0062] The first difference is EndSample.devTime-StartSample.devTime; the second difference is EndSample.cpuTime-StartSample.cpuTime.

[0063] In some possible implementations, multiple conversion coefficients may be calculated in the above manner, and then an average value of the multiple conversion coefficients may be taken as the initial conversion coefficient, which may further improve the conversion accuracy.

[0064] The process of obtaining the benchmark historical time of the device to be converted and the reference device at the first historical moment can be the same as the process of obtaining the relative historical time of the device to be converted and the reference device at the second historical moment, and can be similar to the above-mentioned process of obtaining the sampling values ​​of the device to be converted and the reference device at the current moment. Here, the process of obtaining the benchmark historical time of the device to be converted and the reference device at the first historical moment is explained.

[0065] In one possible implementation, when obtaining the benchmark historical time of the device to be converted and the reference device at the first historical moment, the process may include: at the first historical moment, continuously sampling the time of the device to be converted and the reference device N times, where N is an integer greater than or equal to 2; selecting a first historical sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtaining the benchmark historical time of the device to be converted at the first historical moment based on the first historical sampling time pair; selecting a second historical sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the reference device, and obtaining the benchmark historical time of the reference device at the first historical moment based on the second historical sampling time pair.

[0066] At the first historical moment, the process of continuously sampling the time of the device to be converted and the reference device N times is similar to the process of continuously sampling the time of the device to be converted and the reference device N times at the current moment mentioned above, and will not be explained here.

[0067] When obtaining the reference historical time of the device to be converted at the first historical moment according to the first historical sampling time pair, the reference historical time of the device to be converted may be the average value of the two times included in the first historical sampling time pair. Similarly, when obtaining the reference historical time of the reference device at the first historical moment according to the second historical sampling time pair, the reference historical time of the reference device may be the average value of the two times included in the second historical sampling time pair.

[0068] The first historical moment and the second historical moment are relative to the current moment. The second historical moment is the moment after the first historical moment and may differ from the first historical moment by a specified delay. In one implementation, the process of obtaining the initial conversion coefficient may be as follows: Figure 3 As shown. This process will obtain two timeSamples, recorded as StartSample and EndSample, that is, first call the loop function func_get_timesample() to obtain S, then delay for a specified time, and then call the loop function func_get_timesample() to obtain EndS. After that, factorK can be calculated according to the above formula. Among them, S includes StartSample.devTime and StartSample.cpuTime; EndS includes EndSample.cpuTime and EndSample.devTime. Before the first TempMinDevDiff is obtained, the initial value of MinDevDiff is 0. When the first TempMinDevdiff is obtained, the value of MinDevDiff is assigned to the first TempMinDevDiff. After that, MinDevDiff will be updated every time the above factOrK is updated.

[0069] In a possible implementation manner, the principle diagram of the time conversion method provided in the embodiment of the present application can be as follows: Figure 4 Get the gpuTime to be converted, call the loop function func_get_timesample() to get the current timeSample, and get TempMinDevDiff and TempMincpuDiff. For details of the process, refer to Figure 5As shown. Then determine whether the update condition is met, that is, determine whether TempMinDevDiff≤(MinDevDiff*a)&&≤(MinDevDiff*a). If the update condition is met, use the timeSample at the current moment to replace EndSample, and calculate the new factorK. Then, cpuTime is calculated using the above conversion formula. Update MinDevDiff at the same time. timeSample can be the average of the two times contained in the sampling time pair corresponding to the shortest interval time in the N-1 sampling intervals. Among them, when obtaining the gpuTime to be converted, a time sampling command can be called once to obtain the gpuTime to be converted.

[0070] Based on the same inventive concept, Figure 6 As shown, the embodiment of the present application further provides a time conversion device 100 , including a determination module 110 , an acquisition module 120 and an update module 130 .

[0071] The judgment module 110 is used to judge whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated.

[0072] The acquisition module 120 is used to acquire the sampling values ​​of the device to be converted and the reference device at the current moment when the answer is yes.

[0073] The updating module 130 is used to update the time conversion relationship between the device to be converted and the reference device based on the sampling values ​​of the device to be converted and the reference device at the current moment; wherein the updated time conversion relationship is used to convert the time of the device to be converted into the time under the time system of the reference device.

[0074] Optionally, the acquisition module 120 is further used to obtain the respective sampling time points of the device to be converted and the reference device at the current moment; the judgment module 110 is used to judge whether the ratios of the respective sampling time points of the device to be converted and the reference device at the current moment to the target sampling time points of the device to be converted are within a preset range; if the ratios of the respective sampling time points of the device to be converted and the reference device at the current moment to the target sampling time points of the device to be converted are both within the preset range, it is determined that the time conversion relationship between the device to be converted and the reference device needs to be updated.

[0075] Optionally, the acquisition module 120 is specifically used to continuously sample the time of the device to be converted and the reference device for N times, where N is an integer greater than or equal to 2; select the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted to obtain the sampling time point of the device to be converted at the current moment; select the shortest interval time from the N-1 adjacent sampling intervals of the reference device to obtain the sampling time point of the reference device at the current moment.

[0076] Optionally, the acquisition module 120 is specifically used to select a first sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtain the sampling value of the device to be converted at the current moment based on the first sampling time pair; select a second sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the reference device, and obtain the sampling value of the reference device at the current moment based on the second sampling time pair.

[0077] Optionally, the updating module 130 is used to update the target sampling time point according to the sampling time point of the device to be converted at the current moment to obtain an updated target sampling time point, wherein the updated target sampling time point is used to subsequently determine whether the time conversion relationship needs to be updated.

[0078] The time conversion relationship includes a conversion coefficient. Optionally, the acquisition module 120 is also used to obtain the benchmark historical time of the device to be converted and the reference device at a first historical moment, and to obtain the relative historical time of the device to be converted and the reference device at a second historical moment; determine a first difference between the relative historical time of the device to be converted and the benchmark historical time; determine a second difference between the relative historical time of the reference device and the benchmark historical time; and determine the conversion coefficient based on the first difference and the second difference.

[0079] Optionally, the acquisition module 120 is specifically used to continuously sample the time of the device to be converted and the reference device N times at a first historical moment, where N is an integer greater than or equal to 2; select a first historical sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtain a benchmark historical time of the device to be converted at the first historical moment based on the first historical sampling time pair; select a second historical sampling time pair corresponding to the shortest interval time from the N-1 adjacent sampling intervals of the reference device, and obtain a benchmark historical time of the reference device at the first historical moment based on the second historical sampling time pair.

[0080] The time conversion device 100 provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.

[0081] like Figure 7 As shown, Figure 7 The electronic device 200 provided in the embodiment of the present application is shown in the structural block diagram. The electronic device 200 comprises: a transceiver 210, a memory 220, a communication bus 230 and a processor 240.

[0082] The transceiver 210, the memory 220, and the processor 240 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses 230 or signal lines. The transceiver 210 is used to send and receive data. The memory 220 is used to store computer programs, such as storing Figure 6 The software function module shown in the figure is the time conversion device 100. The time conversion device 100 includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or fixed in the operating system (OS) of the electronic device 200. The processor 240 is used to execute the executable module stored in the memory 220, such as the software function module or computer program included in the time conversion device 100. For example, the processor 240 is used to execute the above-mentioned time conversion method.

[0083] Among them, the memory 220 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.

[0084] The processor 240 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), a graphics processor, an accelerated processing unit (Accelerated Processing Unit), a multimedia application processor (Multimedia Application Processor, MAP), a microprocessor, etc.; it may also be a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. Or the processor 240 may also be any conventional processor, etc.

[0085] The above-mentioned electronic device 200 includes but is not limited to a computer, a server, etc.

[0086] An embodiment of the present application further provides a non-volatile computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored. When the computer program is run by a computer such as the above-mentioned electronic device 200, the time conversion method shown above is executed.

[0087] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a computer, the time conversion method as described above is performed.

[0088] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0089] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0090] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0091] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a computer-readable storage medium, including several instructions for enabling a computer device (which can be a personal computer, a laptop, a server, or an electronic device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned computer-readable storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0092] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A time conversion method, characterized in that: include: Determine whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated; When the answer is yes, obtain the sampling values ​​of the device to be converted and the reference device at the current moment; Based on the sampling values ​​of the device to be converted and the reference device at the current moment, the time conversion relationship between the device to be converted and the reference device is updated; The updated time conversion relationship is used to convert the time of the device to be converted into the time under the time system of the reference device.

2. The method according to claim 1, characterized in that Determine whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated, including: Obtain the sampling time points of the device to be converted and the reference device at the current moment; Determine whether the ratio of the sampling time points of the device to be converted and the reference device at the current moment to the target sampling time point of the device to be converted is within a preset range; If the ratios of the current sampling time points of the device to be converted and the reference device to the target sampling time points of the device to be converted are both within a preset range, it is determined that the time conversion relationship between the device to be converted and the reference device needs to be updated.

3. The method according to claim 2, characterized in that Get the sampling time points of the device to be converted and the reference device at the current moment, including: Continuously sampling the time of the device to be converted and the reference device for N times, where N is an integer greater than or equal to 2; Select the shortest interval time from the N-1 adjacent sampling intervals of the device to be converted, and obtain the sampling time point of the device to be converted at the current moment; The shortest interval time is selected from the N-1 adjacent sampling intervals of the reference device to obtain the sampling time point of the reference device at the current moment.

4. The method according to claim 3, characterized in that Get the sampling values ​​of the device to be converted and the reference device at the current moment, including: Selecting a first sampling time pair corresponding to the shortest interval time from N-1 adjacent sampling intervals of the device to be converted, and acquiring a sampling value of the device to be converted at the current moment according to the first sampling time pair; A second sampling time pair corresponding to the shortest interval time is selected from N-1 adjacent sampling intervals of the reference device, and a sampling value of the reference device at the current moment is acquired according to the second sampling time pair.

5. The method according to claim 2, characterized in that: After the time conversion relationship between the device to be converted and the reference device needs to be updated, the method further includes: According to the sampling time point of the device to be converted at the current moment, the target sampling time point is updated to obtain an updated target sampling time point, wherein the updated target sampling time point is used to subsequently determine whether the time conversion relationship needs to be updated.

6. The method according to any one of claims 1 to 5, characterized in that The time conversion relationship includes a conversion coefficient, and the method further includes: Obtaining the reference historical time of the device to be converted and the reference device at the first historical moment, and obtaining the relative historical time of the device to be converted and the reference device at the second historical moment; Determine a first difference between the relative historical time of the device to be converted and the reference historical time; determining a second difference between the relative historical time of the reference device and the benchmark historical time; The conversion coefficient is determined according to the first difference and the second difference.

7. The method according to claim 6, characterized in that Obtain the benchmark historical time of the device to be converted and the reference device at the first historical moment, including: At the first historical moment, the time of the device to be converted and the time of the reference device are sampled N times continuously, where N is an integer greater than or equal to 2; Selecting a first historical sampling time pair corresponding to the shortest interval time from N-1 adjacent sampling intervals of the device to be converted, and acquiring a reference historical time of the device to be converted at a first historical moment according to the first historical sampling time pair; A second historical sampling time pair corresponding to the shortest interval time is selected from N-1 adjacent sampling intervals of the reference device, and a reference historical time of the reference device at the first historical moment is obtained according to the second historical sampling time pair.

8. A time conversion device, characterized in that: include: A judgment module, used to judge whether the time conversion relationship between the device to be converted and the reference device at the current moment needs to be updated; An acquisition module, used for acquiring the sampling values ​​of the device to be converted and the reference device at the current moment when the answer is yes; The updating module is used to update the time conversion relationship between the device to be converted and the reference device based on the sampling values ​​of the device to be converted and the reference device at the current moment; wherein the updated time conversion relationship is used to convert the time of the device to be converted into the time under the time system of the reference device.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is executed.

11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.