GPU Monte Carlo acceleration method based on particle transport optimization

By optimizing the egsnrc code logic, setting uniform media scattering and loop threshold jumping, the problem of low computational efficiency of particle scattering simulation is solved, and a significant improvement in computing speed is achieved.

CN119692145APending Publication Date: 2025-03-25GUANGZHOU RAYDOSE MEDICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411846262.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-03-25

Smart Images

  • Figure CN119692145A_ABST
    Figure CN119692145A_ABST
Patent Text Reader

Abstract

The invention aims to provide a GPU Monte Carlo acceleration method based on particle transport optimization. The method comprises the following steps: optimizing a logic sequence of egsnrc codes; scattering of the particles is set to be performed in a homogeneous medium, and coordinates of the particles after scattering are recorded; and setting a circulation threshold value, and forcibly jumping out when the transportation circulation reaches the circulation threshold value. According to the method, simulation of the particle transport process can be optimized, the parallel efficiency is greatly improved, and therefore the calculation speed of the GPU Monte Carlo is increased, and the speed is increased by two to three times compared with a traditional method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of scattering simulation, and in particular to a GPU Monte Carlo acceleration method based on particle transport optimization. Background Art

[0002] Particle scattering simulation refers to the use of computer simulation technology to study the scattering behavior of particles in a specific environment. This simulation method can help scientists better understand the process of particle-matter interaction and the physical mechanism of scattering phenomena. Particle scattering simulation is based on physical laws and mathematical models, and predicts and explains scattering phenomena by calculating particle motion trajectories and energy changes. For example, the Monte Carlo method can be used to simulate multiple scattering and single scattering processes of particles. This method approximates the solution of complex physical problems through random sampling. The Monte Carlo method is a numerical calculation method based on probability and statistical theory that solves problems through random sampling. The basic idea of ​​the Monte Carlo method is to use random numbers (or pseudo-random numbers) to solve computational problems. Its working principle is to gradually approach the solution of the problem through continuous sampling.

[0003] In radiotherapy, accurately determining the absorbed dose produced by radiation is one of the foundations for ensuring the effect of radiotherapy. The Monte Carlo method is a computational method recognized as the most effective for simulating particle migration and is now widely used in medical physics. Due to the long operation time, its application and promotion in the dose calculation of clinical treatment plans are limited. GPU general computing provides a powerful way to establish a fast Monte Carlo dose calculation platform. In GPU computing, threads in the same warp execute the same instruction stream. If there are branches during the execution process, the threads executing different branches need to wait for each other, which affects the computational efficiency. The Monte Carlo method is a random algorithm with a large number of natural branches. There are mature Monte Carlo programs on the CPU side, such as egsnrc, but their code optimization is for the CPU and may not be optimal on the GPU. Since the electron transport process of the code in the prior art is extremely cumbersome, it accounts for nearly 80% of the simulation time, which greatly reduces the simulation efficiency. The free paths of particles vary greatly. When simulating in parallel, the simulation can only end after the particle with the longest free path is completed. A large number of threads are in a waiting state, which affects the computational efficiency. Summary of the invention

[0004] The purpose of the present invention is to provide a GPU Monte Carlo acceleration method based on particle transport optimization, which can optimize the simulation of particle transport process, greatly improve the parallel efficiency, and thus speed up the calculation speed of GPU Monte Carlo, which is two to three times faster than traditional methods. A GPU Monte Carlo acceleration method based on particle transport optimization, comprising: Optimize the logical order of egsnrc code; Set the particle scattering to be carried out in a uniform medium and record the particle coordinates at the end of scattering; Set the loop threshold and force the transport loop to exit when it reaches the loop threshold.

[0005] Preferably, the logic sequence of optimizing the egsnrc code includes: Restructure the logic order of the egsnrc code to reduce the number of branches in the program without changing the results.

[0006] Preferably, the scattering of the particles is set to be performed in a uniform medium, and recording the coordinates of the particles at the end of the scattering comprises: Single scattering is performed in a homogeneous medium; Update the particle's position coordinates with the voxel coordinates of the end position.

[0007] Preferably, the setting of the cycle threshold and the forced exit when the transport cycle reaches the cycle threshold comprises: Count the scattering times of all particles; When all particles exceeding the preset value have been scattered, the current number of cycles is selected as the cycle threshold; When the transport loop reaches the loop threshold, it is forced to exit the loop.

[0008] Preferably, the setting of the cycle threshold, after the transport cycle is forced to exit when the cycle threshold is reached, further comprises: Record the free path of particles that have not been scattered completely; The particles that have not been scattered are simulated together with the next batch of particles to be scattered.

[0009] Preferably, when all particles exceeding the preset value have been scattered, selecting the current number of cycles as the cycle threshold comprises: Set the cycle threshold to 20; When the number of loops exceeds 20, the loop is forced to exit.

[0010] Preferably, the scattering of particles is set to be performed in a uniform medium, and before recording the coordinates of particles at the end of scattering, the method further comprises: Ignore voxel boundary treatment during electron multiple scattering.

[0011] A GPU Monte Carlo acceleration system based on particle transport optimization, comprising: Program optimization module, used to optimize the logical order of egsnrc code; The scattering simulation module is used to set the particle scattering in a uniform medium and record the particle coordinates at the end of scattering; The scattering cycle module is used to set the cycle threshold and force the transport cycle to exit when it reaches the cycle threshold.

[0012] An electronic device comprises: a chip, a processor and a memory, wherein the memory is used to store computer program code, and the computer program code comprises computer instructions. When the chip executes the computer instructions, the electronic device executes a GPU Monte Carlo acceleration method based on particle transport optimization.

[0013] A computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor of an electronic device, the processor executes a GPU Monte Carlo acceleration method based on particle transport optimization.

[0014] The beneficial effects of the present invention are as follows: 1. The present invention reduces the branches in the program without changing the results by reconstructing the logical order of the egsnrc part of the code. 2. The present invention ignores the boundary processing during multiple electron scattering, and the single scattering is approximately performed in a uniform medium. After the scattering is completed, the position index of the particle is updated with the voxel index of the end position. 3. The present invention sets a loop threshold in the transport cycle, and forces the loop to exit when the threshold is exceeded. The uncompleted free path of the particles that have not been transported is recorded and simulated together with the next batch of particles, greatly improving the parallel synchronization rate. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention. In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor. Figure 1 A flow chart of a GPU Monte Carlo acceleration method based on particle transport optimization of the present invention; Figure 2 It is a schematic diagram of the particle scattering cycle process of the present invention; Figure 3 The figure is a schematic diagram of the hardware structure of an electronic device of the present invention. DETAILED DESCRIPTION

[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0017] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0018] In addition, the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0019] In radiotherapy, accurately determining the absorbed dose produced by radiation is one of the foundations for ensuring the effect of radiotherapy. The Monte Carlo method is a computational method recognized as the most effective for simulating particle migration and is now widely used in medical physics. Due to the long operation time, its application and promotion in the dose calculation of clinical treatment plans are limited. GPU general computing provides a powerful way to establish a fast Monte Carlo dose calculation platform. In GPU computing, threads in the same warp execute the same instruction stream. If there are branches during the execution process, the threads executing different branches need to wait for each other, which affects the computational efficiency. The Monte Carlo method is a random algorithm with a large number of natural branches. There are mature Monte Carlo programs on the CPU side, such as egsnrc, but their code optimization is for the CPU and may not be optimal on the GPU, because the electron transport process of the original code is extremely cumbersome and accounts for nearly 80% of the simulation time. Simplifying this process will greatly improve the computational efficiency. The free paths of particles vary greatly. When simulating in parallel, the simulation can only end after the particle with the longest free path is completed. A large number of threads are in a waiting state, which affects the computational efficiency.

[0020] The present invention reduces the branches in the program without changing the results by reconstructing the logical order of the egsnrc part of the code. The present invention ignores the boundary processing during multiple electron scattering, and the single scattering is approximately performed in a uniform medium. After the scattering is completed, the position index of the particle is updated with the voxel index of the end position. The present invention sets a cycle threshold in the transport cycle, and forces the exit when the threshold is exceeded. The uncompleted free path of the particles that have not been transported is recorded and simulated together with the next batch of particles, which greatly improves the parallel synchronization rate.

[0021] Example 1 A GPU Monte Carlo acceleration method based on particle transport optimization, reference Figure 1 ,include: S100, optimize the logic order of egsnrc code; ‌egsnrc‌ is a software toolkit for Monte Carlo simulation of ionizing radiation transport, mainly used to simulate the transport of photons and electrons. ‌egsnrc improves the accuracy of charged particle transport and atomic scattering cross sections‌. ‌egsnrc can simulate the transport of photons and positrons and electrons in the medium with kinetic energy in the energy range of 1keV to 10GeV. Photons interact with matter mainly in four basic forms: electron pair effect, photoelectric effect, Compton scattering and Rayleigh scattering. The interaction between electrons and matter involves inelastic collisions of electrons with extranuclear electrons, inelastic collisions with atomic nuclei, bremsstrahlung and the generation of annihilation photons‌. ‌egsnrc‌ can also be used to simulate linear accelerators or radiation sources, generate phase space files at specific locations, and calculate depth dose curves within the phantom, and calculate doses in voxel phantoms.

[0022] S200, setting the particle scattering to be performed in a uniform medium, and recording the particle coordinates at the end of the scattering; S300, setting a cycle threshold, and forcing the transport cycle to exit when the cycle threshold is reached.

[0023] In GPU computing, threads in the same warp execute the same instruction stream. If there are branches during the execution process, threads executing different branches need to wait for each other, which affects the computing efficiency. The Monte Carlo method is a random algorithm with a large number of branches. Among them, a warp is a fixed-size thread group in GPU computing. A thread is the smallest unit of GPU work. Usually 32 threads form a warp. Threads in the same warp execute the same instruction stream, that is, the thread operations in the same warp are completely synchronized. These threads are executed in parallel on the GPU, sharing the same instruction stream but processing different data. This mechanism is also called a single instruction multiple data model or a single instruction multiple thread model. The scheduling unit of the GPU is scheduled in units of warps, not single threads, which means that the entire warp will be assigned to a processor for parallel execution. If all threads in the warp take the same branch path, they will continue to execute synchronously. However, if the threads have different paths on the branch, the warp will execute each path, but not all threads will be active on each path, which may lead to reduced efficiency because even if some threads are idling, the entire warp must wait for the path to complete, which may lead to reduced efficiency.

[0024] The present invention reduces the branches in the program without changing the results by reconstructing the logical order of the egsnrc part of the code. The present invention ignores the boundary processing during multiple electron scattering, and the single scattering is approximately performed in a uniform medium. After the scattering is completed, the position index of the particle is updated with the voxel index of the end position. The present invention sets a cycle threshold in the transport cycle, and forces the exit when the threshold is exceeded. The uncompleted free path of the particles that have not been transported is recorded and simulated together with the next batch of particles, which greatly improves the parallel synchronization rate.

[0025] Preferably, S100, optimizing the logic sequence of the egsnrc code includes: Restructure the logic order of the egsnrc code to reduce the number of branches in the program without changing the results.

[0026] ‌Egsnrc is an advanced code library for simulating electron beam radiation effects‌, mainly used to simulate the interaction between electron beams and matter through the Monte Carlo method. The purpose of EGSnrc is to provide an easy-to-use tool for simulating the propagation, absorption and scattering processes of electron beams in various media‌. A data block is a function that encapsulates a piece of data and can be called and executed elsewhere in the simulation program. A data block consists of multiple threads. The number of data blocks can include the number of data blocks specified in the simulation program, and the number of threads can include the number of threads in each data block. egsnrc uses advanced physical models to describe the interaction between electron beams and matter, so it can provide very accurate results.

[0027] The logical order of the code mainly includes three basic structures: sequential structure, branch structure and loop structure. The sequential structure is the most basic form of code execution, and is executed from top to bottom in the order in which the code is written. This structure is simple and intuitive, and is suitable for scenarios without conditional judgment and repeated execution. The branch structure is used to select different execution paths based on conditional judgment. The loop structure is used to repeatedly execute a section of code until a specific condition is met. In an embodiment of the present invention, by reconstructing the logical order of the egsnrc part of the code, the branches in the program are reduced without changing the result, a lot of calculations are reduced, and the running speed of the program is greatly accelerated.

[0028] Preferably, S200, setting the scattering of particles to be performed in a uniform medium, and recording the coordinates of particles at the end of scattering includes: S210, performing single scattering in a homogeneous medium; ‌Single scattering occurs in a homogeneous medium when the simulated particle (photon, electron, positron) collides with only one atom or molecule and then changes its direction of propagation. Single scattering occurs when a photon collides with only one atom or molecule and then changes its direction of propagation while passing through a medium. Single scattering usually occurs when light passes through a medium, such as air or water.

[0029] S220, updating the position coordinates of the particle with the voxel coordinates of the end position.

[0030] The Monte Carlo method is a numerical calculation method based on random numbers, which is often used to simulate multiple scattering and single scattering processes of particles. In the multiple scattering process, the particle collides with the atoms or molecules in the medium multiple times, which changes the direction and energy of the particle, determines the initial position and initial energy of the particle in the medium, and randomly selects an interaction process according to the properties of the medium and the probability of the particle interacting with the medium. According to the selected interaction process, the scattering angle and energy loss of the particle in the process are calculated, the position and energy of the particle are updated, and the above steps are repeated until the specified number of simulations is reached or other termination conditions are met. In the single scattering process, the particle collides with an atom or molecule in the medium once, which changes the direction and energy of the particle, determines the initial position and initial energy of the particle in the medium, and randomly selects an interaction process according to the properties of the medium and the probability of the particle interacting with the medium. According to the selected interaction process, the scattering angle and energy loss of the particle in the process are calculated, and the position and energy of the particle are updated.

[0031] The present invention sets the number of times that most particles can complete scattering as the number of cycles, which can reduce thread idling, end the simulation more quickly, and obtain accurate simulation data.

[0032] Preferably, reference Figure 2 , S300, setting a cycle threshold, when the transport cycle reaches the cycle threshold, forced exit includes: S310, counting the scattering times of all particles; ‌The number of scatterings of a particle‌ refers to the number of times a particle is scattered during the interaction between the particle and the medium. According to the number of scatterings, scattering can be divided into single scattering and multiple scattering. In the single scattering process, the particle collides with an atom or molecule in the medium once, changing the direction and energy of the particle. The calculation of the Monte Carlo method to simulate single scattering includes: determining the initial position and initial energy of the particle in the medium. According to the properties of the medium and the probability of the particle interacting with the medium, a random interaction process is selected. According to the selected interaction process, the scattering angle and energy loss of the particle in the process are calculated. Update the position and energy of the particle. ‌In the multiple scattering process, the particle collides with multiple atoms or molecules in the medium multiple times, and each collision changes the direction and energy of the particle. The Monte Carlo method to simulate multiple scattering includes: determining the initial position and initial energy of the particle in the medium. According to the properties of the medium and the probability of the particle interacting with the medium, a random interaction process is selected. According to the selected interaction process, the scattering angle and energy loss of the particle in the process are calculated. Update the position and energy of the particle, and repeat the above steps until the specified number of simulations is reached or other termination conditions are met.

[0033] S320, when all particles exceeding the preset value have been scattered, selecting the current number of cycles as a cycle threshold; In an embodiment of the present invention, the cycle threshold is the maximum number of cycles when performing particle scattering simulation. Because in particle scattering simulation, the scattering times of very few particles may reach tens of thousands, but the scattering times of most particles are within dozens. Therefore, a suitable cycle threshold should be set to allow most particles to jump out of the cycle after scattering. If all particles are required to complete the cycle, the simulation time will be greatly increased, and the scattering data of very few particles do not have much research significance. Therefore, the present invention sets the number of current cycles to be the cycle threshold when all particles exceeding the preset value are scattered. Obviously, compared with tens of cycles, a large amount of simulation time can be saved. The present invention arranges particles that need to be scattered multiple times into multiple simulations, which can save time for each simulation and allow all particles to complete the transport simulation. Compared with conventional particle simulation, the present invention can save a large amount of simulation time while having the same accuracy.

[0034] S330, when the transport cycle reaches the cycle threshold, the cycle is forced to be exited.

[0035] The Monte Carlo method can study the behavior and characteristics of particles in a medium by simulating the motion trajectories and interactions of a large number of particles. The Monte Carlo loop is an iterative process based on random sampling, which is used to solve various computational problems. The basic idea is to estimate the solution of a problem through a large number of random samplings, and gradually approach the true value. The core of the Monte Carlo loop is to continuously perform random sampling until a certain accuracy requirement is met or a preset number of iterations is reached. If all particles are to complete scattering, then the number of scatterings of individual particles will be very large, which seriously affects the speed of the simulation. Therefore, in an embodiment of the present invention, as long as most of the particles complete scattering, the loop can be jumped out without waiting for individual particles that have not yet completed scattering. When jumping out of the loop, the uncompleted free path of the particles that have not yet completed scattering is recorded, and then enter the next simulation together with the next batch of particles that need to be simulated for scattering. This can save a lot of simulation time and complete the scattering simulation of all particles. Preferably, in S300, after setting a cycle threshold and forcibly exiting the transport cycle when the cycle threshold is reached, the method further includes: S410, recording the free path of the particles that have not been scattered completely; The free path of a particle refers to the distance a particle can move freely before colliding with other particles under certain conditions. The free path refers to the average of the free paths that a particle may pass between two consecutive collisions. For gas molecules, the average distance between two adjacent collisions is called the mean free path of the molecule. The free path refers to the distance a particle can move freely before colliding with other particles. In an ideal gas, molecules will elastically collide with other molecules and suddenly change direction and speed. The free path describes the process of this random movement. In an embodiment of the present invention, it is only necessary to record the free path of particles that have not yet completed scattering, and then send the particles that have not yet completed scattering to the next simulation to obtain complete experimental data. This operation can not only save the time of this particle scattering simulation, but also obtain complete particle simulation data, greatly improve the efficiency of particle simulation, and save a lot of research costs and time.

[0036] S420, simulating the particles that have not been scattered completely together with the next batch of particles to be simulated for scattering.

[0037] The free paths of particles vary greatly. Taking electron multiple scattering as an example, most particles scatter less than 20 times, but some can reach tens of thousands of times. The present invention counts the number of scatterings of all particles. When the cycle exceeds 20 times, it is forced to jump out. The particles that have not been scattered will record the unfinished free paths and simulate them together with the next batch of particles, greatly improving the parallel synchronization rate. If the particles that have not been scattered are still unable to complete the scattering in the next simulation, they will be input into the third simulation, and so on, until all particles have completed the simulation and the operation is terminated.

[0038] Preferably, in S320, when all particles exceeding the preset value have been scattered, selecting the current number of cycles as the cycle threshold comprises: S321, setting the cycle threshold to 20; In the embodiment of the present invention, it is known through multiple experiments that under the condition of 20 transport cycles, most of the particles have completed scattering, and only a very small number of particles have not completed scattering. Therefore, the present invention sets the cycle threshold to 20 so that most of the particles can complete scattering. After most of the particles have completed scattering, the cycle can be ended.

[0039] S322: When the number of loops exceeds 20, the loop is forced to exit.

[0040] In the embodiment of the present invention, when the number of cycles exceeds 20, the current cycle is stopped, and the particles that have not been scattered are recorded and then simulated together with the next batch of particles. Because the scattering times of most particles are within 20, but some may reach tens of thousands of times, it is obviously not necessary to complete the simulation of all particles because of the tens of thousands of scatterings of individual particles. Therefore, it is only necessary for most particles to complete the scattering within 20 cycles to stop the current simulation. In addition, the absorbed dose generated by the rays can be accurately determined to ensure the therapeutic effect and save a lot of simulation time.

[0041] Preferably, the scattering of particles is performed in a uniform medium, and before recording the coordinates of the particles after the scattering is completed, the method further includes: Ignore voxel boundary treatment during electron multiple scattering.

[0042] ‌‌Since the free path of electrons is shorter (much shorter than that of photons), electrons scatter many times. If they are simulated one by one, it will be extremely time-consuming and waste a lot of resources. This is why there are multiple electron scattering and corresponding complex boundary processing. Photon scattering does not have these complex processes.

[0043] Voxel boundary processing refers to the way voxel boundaries are handled when processing voxel data. Voxels are the basic units in three-dimensional space, usually represented as small cubes, and each voxel represents a point or a small area in space. When processing voxel data, the processing of boundary voxels is particularly important because they are located at the edge of the object, and improper processing may cause errors in rendering or analysis results.

[0044] However, in the case of multiple electron scattering, the boundary processing of EGS is very complicated, and it is necessary to judge the distance from the voxel boundary in each direction, and to process in different branches for different situations such as parallel direction and vertical direction. In view of the fact that the distance of single electron scattering is very short, even if it crosses the voxel boundary, the error introduced is relatively small. The present invention ignores the voxel boundary processing in the process of multiple electron scattering, and single scattering is performed in a uniform medium, and the material type and density at the starting point of scattering are used as the type and density of the medium. After the scattering is completed, the position index of the particle is updated with the voxel index at the end position.

[0045] Example 2 A GPU Monte Carlo acceleration system based on particle transport optimization, comprising: Program optimization module, used to optimize the logical order of egsnrc code; The scattering simulation module is used to set the particle scattering in a uniform medium and record the particle coordinates at the end of scattering; The scattering cycle module is used to set the cycle threshold and force the transport cycle to exit when it reaches the cycle threshold.

[0046] Example 3 An electronic device comprises: a chip, a processor and a memory, wherein the memory is used to store computer program code, and the computer program code comprises computer instructions. When the chip executes the computer instructions, the electronic device executes a GPU Monte Carlo acceleration method based on particle transport optimization.

[0047] refer to Figure 3 , the electronic device 2 includes a processor 21, a memory 22, an input device 23, and an output device 24. The processor 21, the memory 22, the input device 23, and the output device 24 are coupled via a connector, and the connector includes various interfaces, transmission lines, or buses, etc., which are not limited in the embodiments of the present invention. It should be understood that in various embodiments of the present invention, coupling refers to mutual connection in a specific manner, including direct connection or indirect connection through other devices, for example, through various interfaces, transmission lines, buses, etc.

[0048] The processor 21 may be one or more graphics processing units (GPUs). When the processor 21 is a GPU, the GPU may be a single-core GPU or a multi-core GPU. Optionally, the processor 21 may be a processor group consisting of multiple GPUs, and the multiple processors are coupled to each other via one or more buses. Optionally, the processor may also be other types of processors, etc., which are not limited in the embodiments of the present invention.

[0049] The memory 22 can be used to store computer program instructions and various computer program codes including program codes for executing the scheme of the present invention. Optionally, the memory includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM), or portable read only memory (CD-ROM), which is used for related instructions and data.

[0050] The input device 23 is used to input data and / or signals, and the output device 24 is used to output data and / or signals. The output device 24 and the input device 23 may be independent devices or an integrated device.

[0051] Example 4 A computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor of an electronic device, the processor executes a GPU Monte Carlo acceleration method based on particle transport optimization.

[0052] The present invention reduces the branches in the program without changing the results by reconstructing the logical order of the egsnrc part of the code. The present invention ignores the boundary processing during multiple electron scattering, and the single scattering is approximately performed in a uniform medium. After the scattering is completed, the position index of the particle is updated with the voxel index of the end position. The present invention sets a cycle threshold in the transport cycle, and forces the exit when the threshold is exceeded. The uncompleted free path of the particles that have not been transported is recorded and simulated together with the next batch of particles, which greatly improves the parallel synchronization rate.

[0053] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A GPU Monte Carlo acceleration method based on particle transport optimization, characterized in that: include: Optimize the logical order of egsnrc code; Set the particle scattering to be carried out in a uniform medium and record the particle coordinates at the end of scattering; Set the loop threshold and force the transport loop to exit when it reaches the loop threshold.

2. The GPU Monte Carlo acceleration method based on particle transport optimization according to claim 1, characterized in that: The logic sequence of optimizing the egsnrc code includes: Restructure the logic order of the egsnrc code to reduce the number of branches in the program without changing the results.

3. The GPU Monte Carlo acceleration method based on particle transport optimization according to claim 1, characterized in that: The step of setting the particle scattering to be performed in a uniform medium and recording the particle coordinates after the scattering is completed comprises: Single scattering is performed in a homogeneous medium; Update the particle's position coordinates with the voxel coordinates of the end position.

4. The GPU Monte Carlo acceleration method based on particle transport optimization according to claim 1, characterized in that: The setting of the cycle threshold and the forced exit when the transport cycle reaches the cycle threshold include: Count the scattering times of all particles; When all particles exceeding the preset value have been scattered, the current number of cycles is selected as the cycle threshold; When the transport loop reaches the loop threshold, it is forced to exit the loop.

5. The GPU Monte Carlo acceleration method based on particle transport optimization according to claim 1, characterized in that: The setting of the cycle threshold, after the transport cycle is forced to exit when the cycle threshold is reached, further includes: Record the free path of particles that have not been scattered completely; The particles that have not been scattered are simulated together with the next batch of particles to be scattered.

6. The GPU Monte Carlo acceleration method based on particle transport optimization according to claim 4 is characterized in that: When all particles exceeding the preset value have been scattered, selecting the current number of cycles as the cycle threshold comprises: Set the cycle threshold to 20; When the number of loops exceeds 20, the loop is forced to exit.

7. The GPU Monte Carlo acceleration method based on particle transport optimization according to claim 1, characterized in that: The step of setting the particle scattering to be performed in a uniform medium and recording the particle coordinates after the scattering is completed also includes: Ignore voxel boundary treatment during electron multiple scattering.

8. A GPU Monte Carlo acceleration system based on particle transport optimization, characterized in that: include: Program optimization module, used to optimize the logical order of egsnrc code; The scattering simulation module is used to set the particle scattering in a uniform medium and record the particle coordinates at the end of scattering; The scattering cycle module is used to set the cycle threshold and force the transport cycle to exit when it reaches the cycle threshold.

9. An electronic device, characterized in that: include: A chip, a processor and a memory, wherein the memory is used to store computer program code, wherein the computer program code includes computer instructions. When the chip executes the computer instructions, the electronic device executes a GPU Monte Carlo acceleration method based on particle transport optimization as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor of an electronic device, the processor executes a GPU Monte Carlo acceleration method based on particle transport optimization as described in any one of claims 1 to 7.