Methods, devices, vehicles, equipment, and media for adjusting the number of simulation threads.

By dynamically adjusting the number of simulation threads based on their resource consumption status, the problem of wasted computing resources in existing technologies is solved, and the utilization rate of simulation resources is improved.

CN116414517BActive Publication Date: 2026-06-30GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUOKE FOUNDATION STONE (CHONGQING) SOFTWARE CO LTD
Filing Date
2022-12-16
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

In existing technologies, the number of parallel simulations can only be manually set before the simulation software runs, resulting in wasted computing resources and low utilization of computing resources.

Method used

Based on the CPU and GPU resource consumption status of the simulation threads and the corresponding resource consumption of the simulation, the number of simulation threads is dynamically adjusted, including adding, reducing, or maintaining the number of threads, in order to optimize resource utilization.

Benefits of technology

By adaptively adjusting the number of simulation threads, the resource utilization of CPU and GPU is improved, thereby maximizing the use of computing resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116414517B_ABST
    Figure CN116414517B_ABST
Patent Text Reader

Abstract

This disclosure relates to a method, apparatus, vehicle, device, and medium for adjusting the number of simulation threads. The method includes: determining the number of simulation threads to run based on the CPU resource consumption status and GPU resource consumption status of the simulation tasks run by the created simulation threads, as well as the resource consumption corresponding to the simulation. The CPU and GPU resource consumption status of the simulation tasks run by the created simulation threads usually differs from the saturation state of the resource consumption corresponding to the simulation during actual operation. Therefore, this difference can be used to determine the number of simulation threads to run. The number of simulation threads is adjusted based on the created simulation threads. This adjustment includes: adding or reducing the number of simulation threads, or keeping the number of simulation threads unchanged, thereby improving the resource utilization of the CPU and GPU by the simulation threads and adaptively adjusting towards maximizing the resource utilization of the CPU and GPU.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of simulation technology, and in particular to a method, apparatus, vehicle, device, and medium for adjusting the number of simulation threads. Background Technology

[0002] Simulation technology is a technique that uses simulation hardware and software to simulate system behavior or processes within a simulation model using numerical calculations and problem-solving methods. Currently, simulation technology is widely used in fields such as aerospace, power, manufacturing, nuclear energy, and autonomous driving.

[0003] Taking autonomous driving simulation as an example, simulation software on electronic devices utilizes the computing resources of the central processing unit (CPU) and graphics processing unit (GPU) to simulate autonomous driving scenarios, such as braking, lane changing, and reaction scenarios to unexpected situations. However, currently, the number of parallel simulations can only be manually set before the simulation software runs. Simulating scenarios with a fixed number of parallel simulations wastes some computing resources, and the utilization rate of computing resources needs to be improved. Summary of the Invention

[0004] To overcome the following technical problems in related technologies: Currently, the number of parallel simulations can only be manually set before the simulation software runs, and simulating a scene with a fixed number of parallel simulations wastes some computing resources, and the utilization rate of computing resources needs to be improved. Embodiments of this disclosure provide a method, apparatus, vehicle, device, and medium for adjusting the number of simulation threads.

[0005] According to a first aspect of the present disclosure, a method for adjusting the number of simulation threads is provided. The method includes: determining the number of simulation threads to run based on the CPU resource consumption status and GPU resource consumption status of the simulation tasks executed by the created simulation threads, as well as the resource consumption corresponding to the simulation; wherein the created simulation threads, during their execution, include an adjustable computing portion capable of allocating computation between the CPU and GPU.

[0006] In some embodiments, the number of simulation threads to run is determined based on the CPU resource consumption status, GPU resource consumption status, and resource consumption corresponding to the simulation tasks run by the created simulation threads. This includes determining the number of simulation threads to run based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads to run the simulation tasks.

[0007] In some embodiments, the method further includes: determining the simulation cycle of the simulation task based on a set frame rate; and creating a number of simulation threads corresponding to the initial set value of the number of simulation threads. Specifically, determining the number of simulation threads based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task includes: during the execution of the simulation task, for a period when the number of simulation threads can be adjusted, repeatedly executing the following steps: determining whether to adjust the number of simulation threads and increasing or decreasing the number based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task; and continuing to create or close a corresponding number of simulation threads based on the increased or decreased number, resulting in a number of simulation threads after adjustment. Specifically, in the first loop, the number of simulation threads corresponding to the initial set value is considered as the created simulation threads; in subsequent loops, the number of simulation threads after adjustment obtained in the previous loop is considered as the created simulation threads in the next loop.

[0008] In some embodiments, determining whether to adjust the number of simulation threads and increase or decrease them based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task includes: calculating the total CPU time required for the created simulation threads to run the simulation task based on the CPU time consumed by each created simulation thread in running the simulation task; calculating the total GPU time required for the created simulation threads to run the simulation task based on the GPU time consumed by each created simulation thread in running the simulation task; determining the predicted CPU time and predicted GPU time for the newly added single simulation thread to run the simulation task based on the distribution of the CPU time and GPU time; and determining whether the simulation cycle meets the addition condition for adding at least one new single simulation thread, wherein the addition condition includes: the simulation cycle is greater than or equal to the sum of the total time after addition and a preset adjustment constant; wherein the total time after addition is equal to the sum of the total CPU time, the total GPU time, and the predicted CPU time and predicted GPU time of the single simulation thread corresponding to the number of new additions.

[0009] In some embodiments, determining whether to adjust the number of simulation threads and the number to be increased or decreased based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task further includes: determining whether the simulation cycle meets the shutdown condition for reducing at least one simulation thread among the created simulation threads, the shutdown condition including: the simulation cycle being less than the sum of the total CPU time and the total GPU time; if the shutdown condition is met, determining the number of simulation threads to be reduced and the simulation threads to be shut down based on the sum of the CPU time and the GPU time of each simulation thread; the sum of the CPU time and GPU time of the simulation threads to be shut down is greater than or equal to a calculated difference, the calculated difference being the difference between the sum of the total CPU time and the total GPU time and the simulation cycle.

[0010] In some embodiments, determining the predicted CPU time and predicted GPU time for a newly added single simulation thread to run the simulation task based on the distribution of CPU time and GPU time includes: calculating the average CPU time and average GPU time of the created simulation thread based on the distribution of CPU time and GPU time, determining the average CPU time as the predicted CPU time, and determining the average GPU time as the predicted GPU time.

[0011] In some embodiments, determining the predicted CPU time and predicted GPU time for a newly added single simulation thread to run the simulation task based on the distribution of CPU time and GPU time includes: calculating the maximum CPU time and maximum GPU time of the created simulation thread based on the distribution of CPU time and GPU time, determining the maximum CPU time as the predicted CPU time, and determining the maximum GPU time as the predicted GPU time.

[0012] In some embodiments, determining the predicted CPU time and predicted GPU time for a newly added single simulation thread to run the simulation task based on the distribution of CPU time and GPU time includes: calculating the median CPU time and median GPU time of the created simulation thread based on the distribution of CPU time and GPU time, determining the median CPU time as the predicted CPU time, and determining the median GPU time as the predicted GPU time.

[0013] In some embodiments, determining the simulation period of the simulation task based on the set frame rate includes: determining the reciprocal of the set frame rate as the simulation period of the simulation task.

[0014] In some embodiments, the method further includes: determining task allocation information for the created simulation threads, wherein the task allocation information indicates that each of the created simulation threads corresponds to a sub-computation task of the simulation task, and the union of the sub-computation tasks is the entire set or a subset of the simulation task; according to the task allocation information, each of the created simulation threads runs its corresponding sub-computation task; monitoring the running status of the created simulation threads; and determining the CPU resource consumption status and GPU resource consumption status of each of the created simulation threads running its corresponding sub-computation task based on the monitored running status.

[0015] In some embodiments, determining the CPU resource consumption status and GPU resource consumption status of the corresponding sub-computation tasks run by each of the created simulation threads based on the monitored operating status includes: determining the CPU time and GPU time consumed by each of the created simulation threads running the corresponding sub-computation tasks based on the monitored operating status.

[0016] In some embodiments, during the execution of the simulation task by the created simulation thread, the simulation thread allocates the workload proportionally between the CPU and GPU according to an allocation coefficient, which is adjustable. The method further includes: determining adjustment information for the allocation coefficient based on the CPU resource consumption status and the GPU resource consumption status; the adjustment information is used to ensure that the CPU resource consumption level and the GPU resource consumption level are equal.

[0017] In some embodiments, if the total CPU time and total GPU time required for the simulation task to run by the simulation thread are the same within a preset error tolerance range, the CPU resource consumption and GPU resource consumption are considered to be the same.

[0018] According to a second aspect of the present disclosure, a vehicle is provided. The vehicle stores a set of instructions that are executed by the vehicle's system modules to implement the method for adjusting the number of simulation threads provided in the first aspect of the present disclosure.

[0019] In some embodiments, the system module is further configured to perform the following steps: creating a first number of simulation threads based on the simulation task of the target scene data, each simulation thread having its own state module, the first number being at least two; determining a second number and display position of simulation windows to be displayed within the page display window, the simulation windows being used to display the simulation results of the simulation threads, the simulation windows having a preset window size; determining the timing simulation state corresponding to each of the simulation threads based on the target scene data, the simulation task, and the simulation parameters, and storing it in their respective corresponding state modules; rendering the timing simulation states to obtain a rendered image; and displaying the rendered image in the corresponding simulation window within the page display window based on the display position, the preset window size, and the latest simulation state value in the state module.

[0020] According to a third aspect of the present disclosure, an apparatus for adjusting the number of simulation threads is provided. The apparatus includes a thread number adjustment module. The thread number adjustment module is used to determine the number of simulation threads to run based on the CPU resource consumption status, GPU resource consumption status, and resource consumption corresponding to the simulation in the simulation tasks run by the created simulation threads; wherein the created simulation threads, during operation, include an adjustable computing portion capable of allocating computation between the CPU and GPU.

[0021] According to a fourth aspect of the present disclosure, an electronic device is provided. The electronic device includes: a processor; a memory for storing processor-executable instructions; and the processor for reading the executable instructions from the memory and executing the instructions to implement the method for adjusting the number of simulation threads provided in the first aspect of the present disclosure.

[0022] According to a fifth aspect of the present disclosure, a computer-readable storage medium is provided having computer program instructions stored thereon, which, when executed by a processor, implement the method for adjusting the number of simulation threads provided in the first aspect of the present disclosure.

[0023] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:

[0024] The CPU and GPU resource consumption states of the simulation threads running simulation tasks in actual operation are usually different from the saturation state of the corresponding resource consumption in the simulation. Therefore, this difference can be used to determine the number of simulation threads to run. Based on the existing simulation threads, the number of simulation threads can be adjusted. The above adjustments include: adding simulation threads, reducing simulation threads, or keeping the number of simulation threads unchanged, so as to improve the utilization of CPU and GPU resources by simulation threads and adaptively adjust towards maximizing the utilization of CPU and GPU resources.

[0025] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0026] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0027] Figure 1 This is an implementation scenario diagram illustrating a method for adjusting the number of simulation threads according to an exemplary embodiment.

[0028] Figure 2 This is a flowchart illustrating a method for adjusting the number of simulation threads according to an exemplary embodiment.

[0029] Figure 3 This is a detailed implementation flowchart of step S231 according to an exemplary embodiment.

[0030] Figure 4 This is a flowchart illustrating a method for adjusting the number of simulation threads according to another exemplary embodiment.

[0031] Figure 5 This is a flowchart illustrating a method for adjusting the number of simulation threads according to yet another exemplary embodiment.

[0032] Figure 6 This is a block diagram illustrating an apparatus for adjusting the number of simulation threads according to an exemplary embodiment.

[0033] Figure 7 This is a block diagram of a vehicle according to an exemplary embodiment.

[0034] Figure 8 This is a block diagram of an electronic device according to an exemplary embodiment. Detailed Implementation

[0035] The exemplary embodiments will now be described in detail with reference to the accompanying drawings.

[0036] It should be noted that the relevant embodiments and accompanying drawings are only for describing and illustrating exemplary embodiments provided by this disclosure, and not all embodiments of this disclosure, nor should this disclosure be understood to be limited to the relevant exemplary embodiments.

[0037] It should be noted that the terms "first," "second," etc., used in this disclosure are only used to distinguish different steps, devices, or modules. These terms do not represent any specific technical meaning, nor do they indicate any order or interdependence between them.

[0038] It should be noted that the terms “a,” “a plurality of,” and “at least one” used in this disclosure are illustrative rather than restrictive. Unless otherwise expressly indicated in the context, they should be understood as “one or more.”

[0039] It should be noted that the term "and / or" used in this disclosure is used to describe the relationship between related objects, and generally indicates that there are at least three relationships. For example, A and / or B can at least indicate: the existence of A alone, the existence of both A and B, and the existence of B alone.

[0040] It should be noted that the various steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Unless otherwise specified, the scope of this disclosure is not limited by the order in which the steps are described in the relevant embodiments.

[0041] It should be noted that all actions involving the acquisition of signals, information, or data in this disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the location is situated, and with authorization from the owner of the relevant device.

[0042] Technical Terminology Explanation

[0043] A thread is the smallest unit of computation that an operating system can schedule. It is contained within a process and is the actual unit of operation within a process. A thread is an entity within a process; a process contains one or more threads; multiple threads within the same process can execute concurrently.

[0044] A simulation thread is a thread used to implement simulation functions.

[0045] Exemplary methods

[0046] Figure 1 This is an implementation scenario diagram illustrating a method for adjusting the number of simulation threads according to an exemplary embodiment.

[0047] Reference Figure 1As shown, the method for adjusting the number of simulation threads provided in this embodiment includes the following step S110: determining the number of simulation threads to run based on the CPU resource consumption status, GPU resource consumption status, and resource consumption corresponding to the simulation of the created simulation threads running simulation tasks. The created simulation threads, during their operation, include an adjustable computational portion that can allocate computation between the CPU and GPU.

[0048] The above method can be executed by electronic devices with computing capabilities and can be applied to scenarios that require simultaneous data processing using both CPU and GPU.

[0049] For example, application scenarios could include image rendering computation scenarios, pure matrix computation scenarios, or scenarios that can be transformed into matrix computation scenarios, such as mathematical formula calculations and mathematical algorithm operations.

[0050] In the embodiments of this disclosure, the simulation thread used to perform the simulation task runs only in one of the CPU and GPU at any given time. During the execution of the adjustable computing portion of the same simulation thread across the CPU and GPU, the two computing portions in the CPU and GPU have a sequential execution order. For example, if the adjustable computing portion A+B of the same simulation thread is allocated as computing portion A in the CPU and computing portion B in the GPU, computing portion A is executed first using the CPU's computing resources to obtain the calculation result, and then computing portion B in the GPU is executed using the GPU's computing resources.

[0051] Furthermore, in the embodiments of this disclosure, the simulation threads are user threads. Logically, all created simulation threads are parallel. When utilizing CPU and GPU resources, the simulation threads achieve parallel operation through the sequential allocation of time slices. For either the CPU or GPU, only one simulation thread can be occupied at any given time; that is, the CPU cannot run different simulation threads simultaneously, and the GPU cannot run different simulation threads simultaneously.

[0052] The CPU resource consumption status of a simulation thread running a simulation task refers to the state of CPU computing resources occupied by the simulation thread during the execution of the simulation task.

[0053] The GPU resource consumption status of a simulation thread running a simulation task refers to the state of GPU computing resources occupied by the simulation thread during the execution of the simulation task.

[0054] The resource consumption corresponding to the simulation refers to the overall resource consumption of the electronic device by the simulation threads created during the simulation process. In some embodiments, it can be measured by time, using the simulation cycle as the resource consumption corresponding to the simulation. For example, the simulation cycle is the time consumed in generating and transmitting one frame of data.

[0055] In one embodiment, the reciprocal of the set frame rate is determined as the simulation period of the aforementioned simulation task. The set frame rate can be the minimum acceptable simulation frame rate for the user, or it can be a frame rate preset by the system engineer based on system resource availability. For example, if the set frame rate is 20 frames per second, the simulation period is 50 ms.

[0056] In some embodiments, the CPU and GPU resource consumption states of the created simulation threads running simulation tasks are usually different from the saturation state of the resource consumption corresponding to the simulation during actual operation. Therefore, the number of simulation threads can be adjusted by utilizing this difference. The adjustment includes: adding more simulation threads, reducing the number of simulation threads, or keeping the number of simulation threads unchanged.

[0057] Reference Figure 1 As shown, the diagram illustrates the first simulation thread 110 that has already been created and the second simulation thread 120 that needs to be adjusted. The number of the first simulation thread 110 and the total number of the second simulation thread 120 that needs to be adjusted constitute the number of simulation threads running. (Refer to...) Figure 1 As shown by the single-dot-dash arrow, in Figure 1 The plus sign "+" is used to indicate the number of additional simulation threads added based on the already created first simulation thread 110; see reference. Figure 1 The double-dotted arrow indicates a reduction in the number of existing simulation threads within the first simulation thread 110, indicated by the minus sign "-". (Refer to...) Figure 1 The solid arrow indicates that the number of threads in the first simulation thread 110 remains unchanged.

[0058] In some embodiments, the CPU resource consumption state includes multiple dimensions. The first dimension considers the CPU core as a resource, determining the resource usage of the CPU core by the simulation thread to obtain the CPU resource consumption state of the simulation thread running the simulation task. For example, a CPU with 2, 4, or 6 cores can handle 2, 4, or 6 threads simultaneously. With Hyper-Threading / Synchronous Multithreading (SMT / HT) enabled, a CPU can process even more threads in parallel by allocating time slices. The time each simulation thread occupies a CPU core can be considered as the corresponding CPU resource consumption state. The second dimension can be the resource usage of a single core, dividing the processing time into multiple time intervals. Each time interval corresponds to a different CPU state, such as user mode, kernel mode, and idle mode. The duration of each CPU state within the statistical period is considered as the resource consumption state. The third dimension can be allocating different time slices to each thread within a process in user mode, with the computational resources used by each thread in different time slices considered as the resource consumption state.

[0059] The GPU schedules all tasks and then batches similar tasks. In some embodiments, GPU resource consumption can be measured over time, for example, by measuring the GPU processing time for each simulation thread to run the simulation task.

[0060] In some embodiments, the number of simulation threads refers to the number of threads that are adaptively adjusted based on the CPU resource consumption status, GPU resource consumption status, and resource consumption of the simulation tasks during the simulation process of the created simulation threads. This number of threads improves the utilization of CPU and GPU resources by the simulation threads, and is adaptively adjusted towards maximizing the utilization of CPU and GPU resources.

[0061] In some embodiments, the CPU resource consumption status of a simulation thread can be assessed by evaluating the amount of task the simulation thread allows the CPU to process. For example, the CPU resource consumption status can be calculated as follows: CPU resource consumption status = CPU utilization (e.g., the CPU utilization of the simulation thread over time) × CPU clock frequency × number of CPU cores. Correspondingly, the GPU resource consumption status of a simulation thread can be measured by combining one or more of the following factors: GPU utilization, GPU batch processing capacity, or GPU computing density. The resource consumption corresponding to a simulation thread represents a preset resource consumption status for running a simulation task, such as the total CPU and GPU resources required to process the simulation task, or the CPU and GPU resource utilization rates.

[0062] In some embodiments, the CPU and GPU resource consumption status of a simulation thread is measured by the CPU and GPU usage time of the simulation thread. In this case, determining the number of simulation threads to run based on the CPU and GPU resource consumption status of the simulation tasks run by the created simulation threads, as well as the resource consumption corresponding to the simulation, includes: determining the number of simulation threads to run based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads to run the simulation tasks.

[0063] Figure 2 This is a flowchart illustrating a method for adjusting the number of simulation threads according to an exemplary embodiment.

[0064] In some embodiments, refer to Figure 2 As shown, the method for adjusting the number of simulation threads includes the following steps: S210, S220, and S230. Step S230 includes: during the execution of the simulation task, for a period of time when the number of simulation threads is adjustable, repeatedly executing the following steps S231 and S232.

[0065] In some embodiments, the period during which the number of simulation threads can be adjusted can be a portion of the entire lifecycle of the simulation task, such as during the period when the CPU is running the simulation task and is not preempted by other user threads (e.g., some user threads with higher priority than the simulation threads).

[0066] In step S210, the simulation cycle of the simulation task is determined according to the set frame rate.

[0067] The simulation period is used to represent the time consumed in generating and transmitting one frame of data. In some embodiments, determining the simulation period of the simulation task based on a set frame rate includes: determining the reciprocal of the set frame rate as the simulation period of the simulation task.

[0068] For example, the frame rate can be set to the minimum acceptable frame rate for the user during simulation, or it can be a frame rate preset by the system engineer based on system resource availability. For instance, setting the frame rate to 20 frames per second corresponds to a simulation period of 50ms.

[0069] In step S220, a number of simulation threads corresponding to the initial setting value of the number of simulation threads are created.

[0070] The aforementioned initial quantity settings can be set by the user according to simulation requirements; or automatically set by the electronic device based on the type of simulation task and the number of historical simulation threads. For example, if the simulation task is to render an autonomous driving scene, the historical record stores the number of historical threads corresponding to autonomous driving rendering operations, and the electronic device automatically generates the aforementioned initial quantity settings based on this number of historical threads.

[0071] In step S230, the number of simulation threads to run is determined based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation tasks. Step S230 can be a specific implementation of the aforementioned step S110.

[0072] The CPU and GPU time consumed by the created simulation threads in running simulation tasks usually differs from the saturation state of the corresponding simulation cycle during actual operation. Therefore, this difference can be used to adjust the number of simulation threads. The adjustments include: adding more simulation threads, reducing the number of simulation threads, or keeping the number of simulation threads unchanged.

[0073] Based on the above steps S210 to S230, the number of threads can be adaptively adjusted according to the actual resource consumption of the CPU and GPU and the saturation state corresponding to the preset resource consumption (e.g., the simulation cycle, as an example of the resource consumption corresponding to the simulation) during the simulation thread's execution of the simulation task, so that the resource utilization rate can be maximized.

[0074] Reference Figure 2 As shown, in step S230, during the process of running the simulation task, the following steps S231 and S232 are executed cyclically for a period of time when the number of simulation threads can be adjusted.

[0075] In step S231, based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the above simulation tasks, it is determined whether the number of simulation threads needs to be adjusted and whether the number needs to be increased or decreased.

[0076] In step S232, based on the above increase or decrease in quantity, continue to create or close the corresponding number of simulation threads to obtain the simulation threads with adjusted quantity.

[0077] In the first loop, the number of simulation threads corresponding to the above-mentioned quantity setting value is regarded as the already created simulation threads; in subsequent loops, the simulation threads with the above-mentioned quantity adjusted from the previous loop are regarded as the already created simulation threads in the next loop.

[0078] By repeatedly executing steps S231 and S232, a closed loop is constructed in which the number of simulation threads is dynamically adjusted based on feedback from actual resource consumption. This avoids the situation where the resource consumption after adjusting the number of simulation threads within a single loop is uncertain in advance, which could lead to a situation where the resource utilization after the thread number adjustment does not actually follow the optimization direction. This embodiment, by setting multiple loops, helps to continuously adjust and optimize according to the actual situation, ensuring that the utilization of computing resources reaches a true optimization and can continuously maintain a good state of resource utilization.

[0079] Figure 3 This is a detailed implementation flowchart of step S231 according to an exemplary embodiment.

[0080] In some embodiments, refer to Figure 3 As shown, in step S231 above, based on the CPU time, GPU time, and simulation cycle consumed by the created simulation thread to run the above simulation task, it is determined whether the number of simulation threads needs to be adjusted and increased or decreased, including the following steps: S310, S320, S330, and S341.

[0081] In step S310, the total CPU time required for the created simulation threads to run the above simulation tasks is calculated based on the CPU time consumed by each created simulation thread in running the above simulation tasks.

[0082] In some embodiments, during the actual execution of a simulation task, the electronic device can read the CPU time corresponding to each simulation thread from the status parameters of the simulation thread.

[0083] For example, each created simulation thread comprises three parts: a first part Px that can only run on the CPU, a second part Py that can run on both the CPU and GPU, and a third part Pz that can only run on the GPU. In some embodiments, for one or more simulation threads, there may be a part of these three parts with a value of zero. This second part is an adjustable computational part, which can allocate computation between the CPU and GPU, and the allocation coefficient is adjustable. For example, the proportion of computation in the CPU for this second part is 'a', and the proportion of computation in the GPU is 1-a, where 'a' is the allocation coefficient, and the value of 'a' is in the range of 0 ≤ a ≤ 1. For example, matrix operations can be performed entirely on the CPU (when a = 1), entirely on the GPU (when a = 0), or allocated between the CPU and GPU (when 0 < a < 1).

[0084] For the i-th thread that has been created, the CPU time consumed by this thread in running the above simulation task is expressed as follows:

[0085] Tc i =T1(Px i )+T2(Py i ×a i (1)

[0086] Where i represents the thread number, and the value of i is 1, 2, 3, ..., N, where N represents the total number of threads that have been created; Tc i Px represents the CPU time consumed by the i-th thread in running the simulation task; i This indicates that the i-th thread can only run the first part of the CPU; T1(Px) i ) indicates that the i-th thread runs the first part Px i Corresponding CPU time; Py i ×a i This represents the portion of the second part of the i-th thread that is allocated for computation in the CPU, Py i This represents the second part that the i-th thread needs to compute, a. i This represents the allocation coefficient corresponding to the CPU computational load of the second part; T2(Py i ×a i ) indicates that the i-th thread is running on the CPU portion of the Py code. i ×a i The corresponding CPU time.

[0087] The total CPU time required for the created simulation threads to run the above simulation task is obtained by summing the CPU time of each of the created simulation threads. The total CPU time is expressed as follows:

[0088]

[0089] Here, TC represents the total CPU time required for the created simulation thread to run the above simulation task.

[0090] In step S320, the total GPU time required for the created simulation threads to run the above simulation task is calculated based on the GPU time consumed by each created simulation thread in running the above simulation task.

[0091] In some embodiments, during the actual execution of a simulation task, the electronic device can read the GPU time consumption corresponding to each simulation thread from the status parameters of the simulation thread.

[0092] For the i-th thread that has been created, the GPU time consumed by this thread in running the above simulation task is expressed as follows:

[0093] Tg i =T3(Py i ×(1-a i ))+T4(Pz i (3)

[0094] Among them, Tg i This represents the GPU time consumed by the i-th thread running the simulation task; Py i ×(1-a i ) represents the second part of Py in the i-th thread. i The portion of computation allocated in the GPU, 1-a i This represents the allocation coefficient corresponding to the computational cost of the second part on the GPU; T3(Py i ×(1-a i )) indicates that the i-th thread runs on the GPU portion of the Py code. i ×(1-a i The corresponding GPU time; Pz i This indicates that the i-th thread can only run in the third part of the GPU; T4(Pz) i ) indicates that the i-th thread is running the third part Pz. i The corresponding GPU time consumption.

[0095] The total GPU time required for the created simulation threads to run the above simulation task is obtained by summing the GPU time of each of the created simulation threads. The total GPU time is expressed as follows:

[0096]

[0097] Here, TG represents the total GPU time required for the created simulation thread to run the above simulation task.

[0098] In step S330, based on the distribution of CPU time and GPU time, the predicted CPU time and predicted GPU time for the newly added single simulation thread to run the simulation task are determined.

[0099] The workload being computed by the created simulation threads can be a portion of the workload of the simulation task. During the actual operation of each simulation thread, the CPU time and GPU time for processing their respective computational workloads will differ.

[0100] In some embodiments, determining the predicted CPU time and predicted GPU time for a newly added single simulation thread to run the simulation task based on the distribution of CPU time and GPU time includes: calculating the average CPU time and average GPU time of the created simulation thread based on the distribution of CPU time and GPU time, determining the average CPU time as the predicted CPU time, and determining the average GPU time as the predicted GPU time.

[0101] For example, CPU prediction time and CPU prediction time satisfy the following expression:

[0102]

[0103]

[0104] Among them, Tc pre Tg represents the CPU prediction time. pre This indicates the time taken for GPU prediction.

[0105] In this embodiment, the average CPU time of the created simulation threads is used as the predicted CPU time of a single simulation thread, and the average GPU time of the created simulation threads is used as the predicted GPU time of a single simulation thread. The strategy of using the average level to estimate the CPU and GPU resource consumption of a single simulation thread reflects the average state of the overall resource consumption value. The number of new simulation threads is determined based on the resource consumption assessment of the new simulation threads to be added, which in most cases helps to reduce the deviation of the number of new threads from the actual situation.

[0106] In other embodiments, determining the predicted CPU time and predicted GPU time for a newly added single simulation thread to run the simulation task based on the distribution of CPU time and GPU time includes: calculating the maximum CPU time and maximum GPU time of the created simulation thread based on the distribution of CPU time and GPU time, determining the maximum CPU time as the predicted CPU time, and determining the maximum GPU time as the predicted GPU time.

[0107] For example, the CPU prediction time and the GPU prediction time satisfy the following expression:

[0108] Tc pre =max(Tc1, Tc2, ..., Tc i , ..., Tc N (7)

[0109] Tg pre =max(Tg1, Tg2, ..., Tg i, ..., Tg N (8)

[0110] Here, max represents the operation of finding the maximum value.

[0111] In this embodiment, by using the maximum CPU time of the created simulation thread as the predicted CPU time of a single simulation thread, and the maximum GPU time of the created simulation thread as the predicted GPU time of a single simulation thread, the strategy of using the maximum value distribution to estimate the CPU and GPU resource consumption of a single simulation thread helps to strictly control the number of new simulation threads during the process of determining the number of new simulation threads, and reduces the situation where newly created simulation threads need to be shut down because the estimated resource consumption of the new simulation threads is lower than the actual situation.

[0112] In some other embodiments, determining the predicted CPU time and predicted GPU time for a newly added single simulation thread to run the simulation task based on the distribution of CPU time and GPU time includes: calculating the median CPU time and median GPU time of the created simulation thread based on the distribution of CPU time and GPU time, determining the median CPU time as the predicted CPU time, and determining the median GPU time as the predicted GPU time.

[0113] For example, the CPU prediction time and the GPU prediction time satisfy the following expression:

[0114] Tc pre =MEDIAN(Tc1,Tc2,...,Tc i , ..., Tc N (9)

[0115] Tg pre =MEDIAN(Tg1,Tg2,...,Tg i , ..., Tg N (10)

[0116] MEDIAN represents the operation of finding the median.

[0117] In this embodiment, the median CPU time of the created simulation threads is used as the predicted CPU time of a single simulation thread, and the median GPU time of the created simulation threads is used as the predicted GPU time of a single simulation thread. This strategy, which uses the median distribution to estimate the CPU resource consumption of a single simulation thread, addresses the situation where the maximum and minimum values ​​of CPU and GPU times differ significantly among the created simulation threads. This approach helps to ensure that the estimated CPU and GPU resource consumption of a single simulation thread is based on the overall resource consumption distribution, reflecting a representative state within the overall resource consumption value distribution. The number of new simulation threads is determined based on the resource consumption assessment, which in most cases helps reduce the deviation between the number of new threads and the actual situation.

[0118] In step S341, it is determined whether the above simulation cycle meets the new condition of adding at least one of the above single simulation threads.

[0119] The above-mentioned new conditions include: the above-mentioned simulation cycle is greater than or equal to the sum of the total time consumed after the addition and the preset adjustment constant; wherein, the above-mentioned total time consumed after the addition is equal to the sum of the above-mentioned total CPU time, the above-mentioned total GPU time, and the CPU prediction time and GPU prediction time of the above-mentioned single simulation thread corresponding to the number of additions.

[0120] For example, the above-mentioned new condition satisfies the following expression:

[0121] TC+kTc pre +TG+kTg pre +L≤T, (11)

[0122] Where k represents the number of newly added single simulation threads; L represents a preset adjustment constant; and T represents the simulation period. In some embodiments, the number of newly added simulation threads can be determined based on the value of k in the above-mentioned addition conditions.

[0123] Reference Figure 3 As shown, in addition to steps S310, S320, S330 and S341, step S231 may also include the following steps: S342 and S352.

[0124] In step S342, it is determined whether the above simulation cycle meets the shutdown condition of reducing the number of created simulation threads.

[0125] The above shutdown conditions include: the above simulation cycle is less than the sum of the above total CPU time and the above total GPU time.

[0126] For example, the above closing condition satisfies the following expression:

[0127] TC+TG>T. (12)

[0128] In step S352, if the above-mentioned shutdown conditions are met, the number of simulation threads to be reduced and the simulation threads to be shut down are determined based on the sum of the CPU time and GPU time of each of the above-mentioned simulation threads.

[0129] The sum of the CPU time and GPU time of the simulation thread to be closed is greater than or equal to the calculated difference, which is the sum of the total CPU time and the total GPU time minus the difference of the simulation cycle.

[0130] For example, the relationship between the reduction in the number of simulation threads to be shut down and the shutdown condition can be expressed as:

[0131]

[0132] Where j represents the sequence number of the simulation thread to be shut down. j is the sequence number that is reassigned to the corresponding thread to be shut down after the thread with sequence number i is determined to be the thread to be shut down. The value of j is 1, 2, ..., m, where m represents the number of simulation threads to be reduced and m is a positive integer.

[0133] Figure 4 This is a flowchart illustrating a method for adjusting the number of simulation threads according to another exemplary embodiment.

[0134] Reference Figure 4 As shown, in some embodiments, the method for adjusting the number of simulation threads includes, in addition to the above-described step S110, the following steps: S410, S420, S430 and S440.

[0135] In some embodiments, the above method may further include steps S210 and S220, and step S110 is specifically implemented as step S230, as described in the preceding embodiments. In this case, steps S410 to S440 may be performed after S210 and S220.

[0136] In step S410, the task allocation information of the created simulation thread is determined.

[0137] The task allocation information mentioned above indicates that each of the simulation threads created corresponds to a sub-computation task of the simulation task, and the union of the sub-computation tasks is the whole set or a subset of the simulation task.

[0138] In embodiments that include steps S210 to S230, and where step S230 includes cyclically executing steps S231 and S232, the aforementioned created simulation thread includes: the simulation thread created in the initial state, corresponding to the simulation thread created in step S220; in some embodiments, the aforementioned created simulation thread further includes: the created simulation thread corresponding to the number of runs obtained after executing at least one cycle of step S230.

[0139] Correspondingly, the task allocation information of the simulation thread is also a concept that changes dynamically as the simulation thread is created or closed.

[0140] For example, task allocation information has at least two states, with corresponding states in different loops. As simulation threads are added or closed, the corresponding task allocation information changes dynamically.

[0141] For example, for the first loop: determine the first task allocation information for N (N is a set value for the number) simulation threads. The first task allocation information is used to indicate that each of the N simulation threads corresponds to the first sub-computation task of the simulation task. The union of the first sub-computation tasks corresponding to the N simulation threads is the whole set or a subset of the simulation task.

[0142] For example, in the second loop, N+2 simulation threads have been created. Then, for the second loop: determine the second task allocation information for the N+2 (number of runs) simulation threads. This second task allocation information indicates that each of the N+2 simulation threads corresponds to a second sub-computation task of the simulation task. The union of the second sub-computation tasks corresponding to the N+2 simulation threads is the entire set or a subset of the simulation task.

[0143] In step S420, according to the task allocation information mentioned above, each of the simulation threads created above runs its corresponding sub-computation task.

[0144] For example, for the first loop: according to the first task allocation information, the above N simulation threads each run the corresponding first sub-computation task.

[0145] For example, for the second round of the loop: according to the second task allocation information, the above N+2 simulation threads each run the corresponding second sub-computation task.

[0146] In step S430, the running status of the simulation thread that has been created is monitored.

[0147] For example, for the first loop: monitor the first running state of the above N simulation threads.

[0148] For example, for the second loop: monitor the second running state of the above N+2 simulation threads.

[0149] In step S440, based on the monitored operating status, the CPU resource consumption status and GPU resource consumption status of the corresponding sub-computation tasks run by the simulation threads created above are determined.

[0150] In some embodiments, in step S440 above, determining the CPU resource consumption status and GPU resource consumption status of each of the created simulation threads running their corresponding sub-computation tasks based on the monitored operating status includes: determining the CPU time and GPU time consumed by each of the created simulation threads running their corresponding sub-computation tasks based on the monitored operating status.

[0151] For example, for the first loop: based on the monitored first running state, determine the first CPU time and first GPU time for each of the above N simulation threads to run the corresponding first sub-computation task.

[0152] In one embodiment, after the first loop completes step S230, based on the first CPU time, the first GPU time, and the simulation cycle, it is determined that the number of simulation threads to be increased is 2, and 2 more simulation threads are created.

[0153] Therefore, in the second loop, N+2 simulation threads have been created.

[0154] For example, for the second round of the loop: based on the monitored second running state, determine the second CPU time and the second GPU time for each of the above N+2 simulation threads to run the corresponding second sub-computation task.

[0155] In embodiments including steps S410-S440 and S110, the CPU resource consumption state and GPU resource consumption state corresponding to the simulation threads created in the initial state can be determined at least. In embodiments including steps S410-S440, S210, S220, and S230, where S230 includes the cyclically executed S231 and S232, the task allocation information corresponding to each simulation thread can be adjusted according to the dynamically adjusted number of threads. This enables the task allocation information to be adaptively adjusted with the number of threads, which helps to further optimize the matching between the resources of each simulation thread and the allocated subtasks, so that the resource utilization state reaches the optimal level.

[0156] For example, in some embodiments, during the execution of the simulation task by the aforementioned created simulation thread, the simulation thread includes an adjustable computational portion capable of allocating computation between the CPU and GPU, with the allocation coefficient being adjustable. The allocation coefficient can be referenced in the preceding section on Py, which describes how each simulation thread can run on both the CPU and GPU.

[0157] Figure 5 This is a flowchart illustrating a method for adjusting the number of simulation threads according to yet another exemplary embodiment.

[0158] In some embodiments, during the execution of the simulation tasks by the created simulation thread, the simulation thread allocates a proportion of the task workload between the CPU and GPU according to an allocation coefficient, which is adjustable. In some embodiments, the created simulation thread may be a simulation thread created according to the initial quantity setting value in step S220; in other embodiments, the created simulation thread may also be a simulation thread corresponding to the quantity after adjustment.

[0159] In some embodiments, the adjustment information of the allocation coefficient is determined based on the CPU resource consumption state and the GPU resource consumption state. By adjusting the allocation coefficient, the resource consumption levels of the CPU resource consumption state and the GPU resource consumption state are approximately the same.

[0160] Since the simulation threads that have been created include an adjustable computing portion that can be allocated between the CPU and GPU during operation, the allocation ratio of the adjustable computing portion to the CPU and GPU can be adjusted during the process of adjusting the number of threads, so that the resource consumption of the CPU and GPU is the same, thereby further improving the resource utilization of the CPU and GPU.

[0161] Reference Figure 5 As shown, the method for adjusting the number of simulation threads provided in this embodiment of the present disclosure, in addition to the above-described step S110, also includes the following steps: S510 and S520.

[0162] In step S510, adjustment information for the allocation coefficient is determined based on the CPU resource consumption status and the GPU resource consumption status. This adjustment information is used to ensure that the CPU resource consumption level and the GPU resource consumption level are equal.

[0163] In some embodiments, if the total CPU time and total GPU time required for the simulation task to run by the created simulation thread are the same within a preset error tolerance range, the resource consumption of the CPU and GPU are considered to be the same. In some embodiments, if TC is less than TG, it indicates that the GPU consumes more time, and the GPU performance will be limited first; conversely, the CPU performance will be limited. By adjusting the allocation coefficient to keep TC and TG the same within the error tolerance range, the resource consumption of the CPU and GPU are considered to be the same. This helps to balance the resource utilization of the CPU and GPU and facilitates the improvement of the overall resource utilization of the electronic device.

[0164] In step S520, the allocation coefficients are adjusted according to the adjustment information to obtain the adjusted computational workload of the created simulation thread.

[0165] By adjusting the allocation coefficients according to the adjustment information, the task allocation of the second part of the simulation thread is essentially carried out, and the adjusted computing task volume of each created simulation thread is obtained. This realizes the adaptation and optimization adjustment between the resources of each simulation thread and the allocated sub-tasks, so that the resource utilization state reaches the optimal.

[0166] It is understood that steps S510 and S520 provided in this embodiment can also be combined with one or more of the above steps S210 to S230 and S410 to S440 to form a new embodiment.

[0167] Exemplary device

[0168] Figure 6 This is a block diagram illustrating an apparatus for adjusting the number of simulation threads according to an exemplary embodiment.

[0169] Reference Figure 6 As shown, the apparatus 600 for adjusting the number of simulation threads includes a thread number adjustment module 610. The thread number adjustment module 610 determines the number of simulation threads to run based on the CPU resource consumption status, GPU resource consumption status, and resource consumption corresponding to the simulation tasks performed by the created simulation threads. During operation, each created simulation thread includes an adjustable computational portion that can allocate computation between the CPU and GPU.

[0170] In some embodiments, refer to Figure 6 As shown, the aforementioned device 600 further includes: a simulation cycle determination module and a thread creation module. The simulation cycle determination module is used to determine the simulation cycle of the simulation task based on a set frame rate. The thread creation module is used to create a number of simulation threads corresponding to a set number of simulation threads.

[0171] In some embodiments, the number of simulation threads to run is determined based on the CPU resource consumption status, GPU resource consumption status, and resource consumption corresponding to the simulation tasks run by the created simulation threads. This includes determining the number of simulation threads to run based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads to run the simulation tasks.

[0172] The thread number adjustment module 610 includes an adjustment determination module 611 and a thread adjustment module 612.

[0173] The aforementioned thread quantity adjustment module 610, based on the adjustment determination module and the thread adjustment module, cyclically executes the following process until the simulation task is completed. The adjustment determination module determines whether the number of simulation threads needs adjustment, and if so, whether to increase or decrease it, based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads running the simulation task. The thread adjustment module then creates or closes a corresponding number of simulation threads based on the increased or decreased number, resulting in an adjusted number of simulation threads. In the first loop, the number of simulation threads corresponding to the set quantity is considered as the created simulation threads; in subsequent loops, the adjusted number of simulation threads obtained in the previous loop is considered as the created simulation threads for the next loop.

[0174] In some embodiments, the adjustment determination module includes: a total CPU time determination module, a total GPU time determination module, a CPU time prediction module, a GPU time prediction module, a new condition determination module, and a shutdown condition determination module.

[0175] The aforementioned total CPU time determination module is used to calculate the total CPU time required for the created simulation threads to run the aforementioned simulation tasks based on the CPU time consumed by each created simulation thread in running the aforementioned simulation tasks.

[0176] The aforementioned total GPU time determination module is used to calculate the total GPU time required for the created simulation threads to run the aforementioned simulation tasks based on the GPU time consumed by each created simulation thread in running the aforementioned simulation tasks.

[0177] The CPU time prediction module is used to determine the predicted CPU time for a newly added single simulation thread to run the simulation task based on the CPU time distribution.

[0178] The GPU time prediction module is used to determine the predicted GPU time for a newly added single simulation thread to run the simulation task based on the GPU time distribution.

[0179] The aforementioned new condition determination module is used to determine whether the aforementioned simulation cycle meets the new condition of adding at least one of the aforementioned single simulation threads. The aforementioned new condition includes: the aforementioned simulation cycle is greater than or equal to the sum of the total time consumed after the addition and the preset adjustment constant; wherein, the aforementioned total time consumed after the addition is equal to the sum of the aforementioned total CPU time, the aforementioned total GPU time, and the CPU prediction time and GPU prediction time of the newly added number of the aforementioned single simulation threads.

[0180] In some embodiments, the shutdown condition determination module is used to determine whether the simulation cycle meets the shutdown condition of reducing at least one simulation thread among the created simulation threads; and, if the shutdown condition is met, to determine the number of simulation threads to be reduced and the simulation threads to be shut down based on the sum of the CPU time and GPU time of each simulation thread. The shutdown condition includes: the simulation cycle being less than the sum of the total CPU time and the total GPU time; and the sum of the CPU time and GPU time of the simulation threads to be shut down being greater than or equal to a calculated difference, where the calculated difference is the sum of the total CPU time and the total GPU time minus the simulation cycle.

[0181] In some embodiments, the above-described apparatus 600 further includes: a task allocation information determination module, an operation module, a status monitoring module, and a resource consumption status determination module.

[0182] The task allocation information determination module is used to determine the task allocation information of the created simulation threads. The task allocation information indicates that each of the created simulation threads corresponds to a sub-computation task of the simulation task, and the union of the sub-computation tasks is the whole set or a subset of the simulation task.

[0183] The aforementioned running module is located in the simulation thread. The created simulation thread runs the corresponding sub-computation tasks based on the aforementioned running module and according to the aforementioned task allocation information.

[0184] The aforementioned status monitoring module is used to monitor the running status of the simulation threads that have been created.

[0185] The resource consumption status determination module is used to determine the CPU resource consumption status and GPU resource consumption status of the corresponding sub-computation tasks run by the aforementioned created simulation threads based on the monitored operating status.

[0186] In some embodiments, determining the CPU resource consumption status and GPU resource consumption status of the corresponding sub-computation tasks run by each of the created simulation threads based on the monitored operating status includes: determining the CPU time and GPU time consumed by each of the created simulation threads running the corresponding sub-computation tasks based on the monitored operating status.

[0187] In some embodiments, during the execution of the simulation task in the simulation thread that has been created, the workload is allocated proportionally between the CPU and GPU according to an allocation coefficient, which is adjustable.

[0188] In some embodiments, the apparatus 600 further includes: an allocation adjustment information determination module and a task adjustment module. The allocation adjustment information determination module is used to determine adjustment information for the allocation coefficient based on the CPU resource consumption state and the GPU resource consumption state. The adjustment information is used to adjust the CPU resource consumption level and the GPU resource consumption level to be the same. The task adjustment module is used to adjust the allocation coefficient according to the adjustment information to obtain the adjusted computational task amount of the created simulation thread.

[0189] In some embodiments, if the total CPU time and total GPU time required for the simulation task to run by the simulation thread are the same within a preset error tolerance range, the CPU resource consumption and GPU resource consumption are considered to be the same.

[0190] The specific execution details of each module in this embodiment can be referred to in the detailed description of the first embodiment, and the content of the first embodiment can be incorporated into this embodiment.

[0191] Exemplary vehicle

[0192] Figure 7 This is a block diagram of a vehicle according to an exemplary embodiment.

[0193] Reference Figure 7 As shown, the vehicle 700 provided in this embodiment can be a fuel vehicle, a hybrid vehicle, an electric vehicle, a fuel cell vehicle, or other types of vehicles.

[0194] The vehicle stores a set of instructions, which are executed by the vehicle's system modules to implement the method for adjusting the number of simulation threads provided in this embodiment.

[0195] In some embodiments, the above system module is further configured to perform the following steps:

[0196] Based on the simulation task of the target scene data, a first number of simulation threads are created, and each simulation thread is configured with its own state module. The first number is at least two.

[0197] Determine the second number and display position of the simulation windows to be displayed within the page display window. The simulation windows are used to display the simulation results of the simulation thread. The simulation windows have a preset window size.

[0198] Based on the target scenario data, simulation tasks and simulation parameters, determine the timing simulation state corresponding to each of the simulation threads and store it in their respective state modules.

[0199] The above-mentioned timing simulation state is rendered to obtain the rendered screen;

[0200] Based on the above display position, the above preset window size, and the latest simulation status value in the above status module, the above rendered screen is displayed in the corresponding simulation window of the above page display window.

[0201] Reference Figure 7 As shown, vehicle 700 may include multiple subsystems, such as drive system 710, control system 720, perception system 730, communication system 740, information display system 750, and computing processing system 760. Vehicle 700 may also include more or fewer subsystems, and each subsystem may include multiple components, which will not be described in detail here.

[0202] The drive system 710 includes components that provide power to the vehicle 700. These include, for example, an engine, an energy source, and a transmission.

[0203] The control system 720 includes components that provide control for the vehicle 700. These include, for example, vehicle control, cockpit equipment control, and driver assistance control.

[0204] The perception system 730 includes components that provide the vehicle 700 with perception of its surroundings. These include, for example, a vehicle positioning system, a laser sensor, a voice sensor, an ultrasonic sensor, and camera equipment.

[0205] The communication system 740 includes components that provide communication connectivity for the vehicle 700. These may include, for example, mobile communication networks (e.g., 3G, 4G, 5G networks), WiFi, Bluetooth, and vehicle-to-everything (V2X) connectivity.

[0206] The information display system 750 includes components that provide various information displays for the vehicle 700. These include, for example, vehicle information displays, navigation information displays, and entertainment information displays.

[0207] The computing processing system 760 includes components that provide data computing and processing capabilities for the vehicle 700. The computing processing system 760 may include at least one processor 761 and a memory 762. The processor 761 can execute instructions stored in the memory 762.

[0208] The processor 761 can be any conventional processor, such as a commercially available CPU. The processor may also include, for example, a Graphics Processing Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.

[0209] The memory 762 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0210] In this embodiment of the disclosure, a set of instructions is stored in the memory 762, and the processor 761 can execute the set of instructions to implement all or part of the steps of the method for adjusting the number of simulation threads as described in any of the exemplary embodiments above.

[0211] Exemplary electronic devices

[0212] Figure 8 This is a block diagram illustrating an electronic device 800 according to an exemplary embodiment. The electronic device 800 may be a vehicle controller, an in-vehicle terminal, an in-vehicle computer, or other types of electronic devices.

[0213] Reference Figure 8 As shown, the electronic device 800 may include at least one processor 810 and a memory 820. The processor 810 can execute instructions stored in the memory 820. The processor 810 is communicatively connected to the memory 820 via a data bus. In addition to the memory 820, the processor 810 can also be communicatively connected to an input device 830, an output device 840, and a communication device 850 via the data bus.

[0214] The processor 810 can be any conventional processor, such as a commercially available CPU. The processor may also include, for example, a Graphics Processing Unit (GPU), a Field Programmable Gate Array (FPGA), a System on Chip (SOC), an Application Specific Integrated Circuit (ASIC), or a combination thereof.

[0215] The memory 820 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0216] In this embodiment of the present disclosure, the memory 820 stores executable instructions, and the processor 810 can read the executable instructions from the memory 820 and execute the instructions to implement all or part of the steps of the method for adjusting the number of simulation threads as described in any of the exemplary embodiments above.

[0217] Exemplary computer-readable storage media

[0218] In addition to the methods and apparatus described above, exemplary embodiments of this disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product. The computer product includes computer program instructions that can be executed by a processor to perform all or part of the steps described in any of the methods in the exemplary embodiments described above.

[0219] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this application. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages, and scripting languages ​​(e.g., Python). The program code can be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0220] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include: static random access memory (SRAM) having one or more electrically connected wires, electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk, or any suitable combination thereof.

[0221] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of this disclosure. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0222] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A method of regulating the number of emulated threads, characterized by, include: The number of simulation threads to run is determined based on the CPU and GPU resource consumption status of the simulation tasks run by the created simulation threads and the corresponding resource consumption of the simulation. The created simulation thread, during its execution, includes an adjustable computational component capable of allocating computation between the CPU and GPU; The step of determining the number of simulation threads to run based on the CPU resource consumption status, GPU resource consumption status, and corresponding resource consumption of the simulation tasks run by the created simulation threads includes: The number of simulation threads to run is determined based on the CPU time, GPU time, and simulation cycle consumed by the simulation tasks run by the created simulation threads. Also includes: The simulation cycle of the simulation task is determined based on the set frame rate; Create a number of simulation threads corresponding to the initial set value for the number of simulation threads; The step of determining the number of simulation threads to run based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation tasks includes: During the execution of the simulation task, the following steps are executed cyclically for a period of time when the number of simulation threads can be adjusted: Based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task, determine whether it is necessary to adjust the number of simulation threads and whether to increase or decrease the number of threads. Based on the increase or decrease in quantity, continue to create or close the corresponding number of simulation threads to obtain the simulation threads with adjusted quantity; In the first loop, the number of simulation threads corresponding to the initial set value of the quantity is regarded as the created simulation threads; in subsequent loops, the simulation threads with the adjusted quantity obtained in the previous loop are regarded as the created simulation threads in the next loop.

2. The method of claim 1, wherein, The step of determining whether to adjust the number of simulation threads and to increase or decrease them based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task includes: Calculate the total CPU time required for the created simulation threads to run the simulation task based on the CPU time consumed by each of the created simulation threads in running the simulation task; Calculate the total GPU time required for the created simulation threads to run the simulation task based on the GPU time consumed by each of the created simulation threads in running the simulation task; Based on the distribution of CPU time and GPU time, determine the predicted CPU time and predicted GPU time for the single simulation thread to run the simulation task. Determine whether the simulation cycle meets the addition condition of adding at least one of the single simulation threads. The addition condition includes: the simulation cycle is greater than or equal to the sum of the total time after the addition and the preset adjustment constant; wherein, the total time after the addition is equal to the sum of the total CPU time, the total GPU time, and the CPU prediction time and GPU prediction time of the single simulation thread corresponding to the number of additions.

3. The method of claim 2, wherein, The step of determining whether to adjust the number of simulation threads and increase or decrease them based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task also includes: Determine whether the simulation cycle meets the shutdown condition of reducing at least one simulation thread among the created simulation threads, the shutdown condition including: the simulation cycle is less than the sum of the total CPU time and the total GPU time; If the shutdown condition is met, the number of simulation threads to be reduced and the simulation threads to be shut down are determined based on the sum of the CPU time and GPU time of each simulation thread; the sum of the CPU time and GPU time of the simulation threads to be shut down is greater than or equal to the calculated difference, which is the difference between the sum of the total CPU time and the total GPU time and the simulation cycle.

4. The method according to claim 2, characterized in that, Based on the distribution of CPU time and GPU time, determine the predicted CPU time and predicted GPU time for the single simulation thread to run the simulation task, including: Based on the distribution of CPU time and GPU time, calculate the average CPU time and average GPU time of the created simulation thread, determine the average CPU time as the predicted CPU time, and determine the average GPU time as the predicted GPU time.

5. The method according to claim 2, characterized in that, Based on the distribution of CPU time and GPU time, determine the predicted CPU time and predicted GPU time for the single simulation thread to run the simulation task, including: Based on the distribution of CPU time and GPU time, the maximum CPU time and the maximum GPU time of the created simulation thread are calculated. The maximum CPU time is determined as the predicted CPU time, and the maximum GPU time is determined as the predicted GPU time.

6. The method according to claim 2, characterized in that, Based on the distribution of CPU time and GPU time, determine the predicted CPU time and predicted GPU time for the single simulation thread to run the simulation task, including: Based on the distribution of CPU time and GPU time, the median CPU time and median GPU time of the created simulation thread are calculated. The median CPU time is determined as the predicted CPU time, and the median GPU time is determined as the predicted GPU time.

7. The method according to claim 1, characterized in that, The step of determining the simulation cycle of the simulation task based on the set frame rate includes: The reciprocal of the set frame rate is determined as the simulation cycle of the simulation task.

8. The method according to claim 1, characterized in that, Also includes: Determine the task allocation information of the created simulation threads, wherein the task allocation information is used to indicate that each of the created simulation threads corresponds to a sub-computation task of the simulation task, and the union of the sub-computation tasks is the whole set or a subset of the simulation task; According to the task allocation information, each of the created simulation threads runs its corresponding sub-computation task. Monitor the running status of the created simulation threads; Based on the monitored operating status, the CPU resource consumption status and GPU resource consumption status of each of the created simulation threads running their corresponding sub-computation tasks are determined.

9. The method according to claim 8, characterized in that, Based on the monitored operating status, determine the CPU resource consumption status and GPU resource consumption status of each of the created simulation threads running its corresponding sub-computation tasks, including: Based on the monitored operating status, determine the CPU time and GPU time consumed by each of the created simulation threads in running its corresponding sub-computation task.

10. The method according to any one of claims 1-9, characterized in that, During the execution of the simulation task by the created simulation thread, the simulation thread allocates the workload proportionally between the CPU and GPU according to an allocation coefficient, which is adjustable. The method further includes: Based on the CPU resource consumption status and the GPU resource consumption status, adjustment information for the allocation coefficient is determined; the adjustment information is used to adjust the CPU resource consumption level and the GPU resource consumption level to be the same.

11. The method according to claim 10, characterized in that, If the total CPU time and total GPU time required for the simulation task to run in the created simulation thread are the same within a preset error tolerance range, then the CPU resource consumption and GPU resource consumption are considered to be the same.

12. A vehicle, characterized in that, A set of instructions is stored, which is executed by the system modules of the vehicle to implement the method described in any one of claims 1-11.

13. The vehicle according to claim 12, characterized in that, The system module is also used to perform the following steps: Based on the simulation task of the target scene data, a first number of simulation threads are created, and each simulation thread is configured with its own state module. The first number is at least two. Determine a second number and display position of simulation windows to be displayed within the page display window, wherein the simulation windows are used to display the simulation results of the simulation thread, and the simulation windows have a preset window size; Based on the target scene data, the simulation task, and the simulation parameters, determine the timing simulation state corresponding to each simulation thread and store it in its respective state module; The timing simulation state is rendered to obtain a rendered image; Based on the display position, the preset window size, and the latest simulation status value in the status module, the rendered screen is displayed in the corresponding simulation window of the page display window.

14. A device for adjusting the number of simulation threads, characterized in that, include: The thread number adjustment module is used to determine the number of simulation threads to run based on the CPU resource consumption status, GPU resource consumption status, and resource consumption corresponding to the simulation tasks of the created simulation threads. The created simulation thread, during its execution, includes an adjustable computational component capable of allocating computation between the CPU and GPU; The step of determining the number of simulation threads to run based on the CPU resource consumption status, GPU resource consumption status, and corresponding resource consumption of the simulation tasks run by the created simulation threads includes: The number of simulation threads to run is determined based on the CPU time, GPU time, and simulation cycle consumed by the simulation tasks run by the created simulation threads. Also includes: The simulation cycle of the simulation task is determined based on the set frame rate; Create a number of simulation threads corresponding to the initial set value for the number of simulation threads; The step of determining the number of simulation threads to run based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation tasks includes: During the execution of the simulation task, the following steps are executed cyclically for a period of time when the number of simulation threads can be adjusted: Based on the CPU time, GPU time, and simulation cycle consumed by the created simulation threads in running the simulation task, determine whether it is necessary to adjust the number of simulation threads and whether to increase or decrease the number of threads. Based on the increase or decrease in quantity, continue to create or close the corresponding number of simulation threads to obtain the simulation threads with adjusted quantity; In the first loop, the number of simulation threads corresponding to the initial set value of the quantity is regarded as the created simulation threads; in subsequent loops, the simulation threads with the adjusted quantity obtained in the previous loop are regarded as the created simulation threads in the next loop.

15. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the method of any one of claims 1-11.

16. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method of any one of claims 1-11.