节点文献
基于CUDA的三维离散元法仿真软件的实现与优化
Implementation and Optimization of 3D Discrete Element Method Simulation Software Based on CUDA
【作者】 王月;
【导师】 付宏;
【作者基本信息】 吉林大学 , 计算机技术(专业学位), 2019, 硕士
【摘要】 无论是在自然界还是在工农业生产中,都存在着大量的散粒物料,如土壤、沙石、农作物产品等。由于使用有限元法研究散粒物料动力学问题存在局限性,相较之下离散元法有着诸多优势,因此离散元法已广泛应用于散粒物料的模拟仿真研究。虽然该方法为计算复杂散粒物料运动提供了更好的解决途径,并尽可能地降低了计算所需的存储空间,但是随着模拟仿真实验中材料规模和颗粒数量的不断增加,计算量也将呈指数增长,因此对离散元法仿真软件的计算效率提出了更高的要求。摩尔定律发展至今已经到达了一个瓶颈,提升计算机计算能力的主要途径从追求CPU单核的高性能,转为通过使用多个复杂度适当、相对低功耗的内核进行并行计算的方式。与CPU相比,GPU处理单元多,内存带宽高,计算速度快,因此GPU并发运行多个内核时的计算性能比CPU强大很多。同时,NVIDIA公司为其生产的GPU增加了易用的编程接口,并提供了通用的并行计算平台和编程模型CUDA,使得研究人员能够更加高效地利用GPU强大的计算能力。随着CUDA并行计算架构逐渐成熟,使用CUDA技术解决离散元法计算量较大的问题也成为了实现离散元法仿真软件的新途径。本文在课题组自主研发的三维离散元法仿真软件Agri DEM及其应用Open MP技术设计的CPU并行计算模块的基础上,应用CUDA技术,利用GPU并行计算架构,为软件增加了CUDA仿真计算模块,并进行了多项改进与优化。首先,根据CUDA特性,设计并实现了CUDA仿真计算模块的数据结构与计算流程。主要数据结构包括:颗粒、边界、接触信息、力学模型等数据结构,主要计算流程包括:GPU数据初始化、颗粒间接触计算、颗粒与边界接触计算、组合球受力计算、颗粒与边界刷新、输出计算结果到文件等。其中在接触计算部分,阐述了一种适用于GPU的基于排序的网格划分方式和基于网格的邻居搜索方法。此时的CUDA仿真计算模块已经在一定程度上提高了软件仿真计算的效率。其次,改进了CUDA仿真计算模块中的部分算法,包括:三角形边界除重算法、颗粒间接触计算算法、邻居搜索网格设置算法。对于三角形边界除重算法的改进使得仿真结果更加准确,对于颗粒间接触计算算法的改进有效减少了计算量并提高了计算效率,使用双重网格的方法改进邻居搜索网格设置算法,解决了颗粒与边界尺寸相差较大时计算效率低的问题。除此以外,还根据CUDA的特性进行了多项优化,包括:线程数设置优化、使用多CUDA流、零拷贝、CPU-GPU异步结构等,进一步提高了CUDA仿真计算模块的计算效率。最后,对于CUDA仿真计算模块进行了集成测试。通过对比CUDA计算模块与CPU计算模块球颗粒测试和非球颗粒测试的测试结果,验证了CUDA仿真计算模块功能的正确性。并且将CPU计算模块和CUDA计算模块处理不同数量级颗粒进行仿真计算的时间进行了对比,结果表明,CUDA仿真计算模块大大缩短了仿真计算的时间,实现了提高计算效率的目的。
【Abstract】 Whether in nature or in industrial and agricultural production,there are a large number of bulk materials,such as soil,sand,crop products and so on.Because of the limitations of using the finite element method to study the dynamics of bulk materials,the discrete element method has many advantages.Therefore,the discrete element method has been widely used in the simulation of bulk materials.Although this method provides a better solution for calculating the movement of complex granular materials,and reduces the storage space required for calculation as much as possible,with the increase of material size and particle number in the simulation experiment,the calculation amount will also increase exponentially,so it puts higher requirements on the computational efficiency of the discrete element method simulation software.The development of Moore’s Law has reached a bottleneck.The main way to improve computer computing power is from pursuing the high performance of CPU single core switch to parallel computing by using multiple cores with appropriate complexity and relatively low power consumption.Compared with the CPU,the GPU has many processing units,high memory bandwidth,and fast calculation speed.Therefore,the computing performance of the GPU running multiple cores concurrently is much stronger than that of the CPU.At the same time,NVIDIA has added an easy-to-use programming interface to its GPUs,and provides a common parallel computing platform and programming model CUDA,enabling researchers to utilize the powerful computing power of the GPU more efficiently.With the maturity of CUDA parallel computing architecture,the use of CUDA technology to solve the problem of large computational complexity of discrete element method has become a new way to implement discrete element method simulation software.Based on the three-dimensional discrete element simulation software AgriDEM developed by our research group and the CPU parallel computing module designed by OpenMP technology,this paper applies CUDA technology,uses GPU parallel computing architecture,adds CUDA simulation calculation module for the software,and carries out a lot of improvements and optimizations.Firstly,according to the CUDA characteristics,the data structure and calculation flow of the CUDA simulation calculation module are designed and implemented.The main data structures include: data structures such as particles,boundaries,contact information,and mechanical models.The main calculation processes include: GPU data initialization,interparticle contact calculation,particle and boundary contact calculation,combined ball force calculation,particle and boundary refresh and output the calculation results to a file,etc.In the contact calculation part,a sort-based meshing method and a grid-based neighbor search method for GPU are described.At this time,the CUDA simulation calculation module has improved the efficiency of software simulation calculation to some extent.Secondly,some algorithms in the CUDA simulation calculation module are improved,including: triangle boundary deduplication algorithm,interparticle contact calculation algorithm,and neighbor search grid setting algorithm.The improvement of the triangle boundary deduplication algorithm makes the simulation result more accurate.The improvement of the interparticle contact calculation algorithm reduces the computational complexity and improves the computational efficiency.The dual grid method is used to improve the neighbor search grid setting algorithm and solve the problem of low computational efficiency when the difference of the size between particles and boundaries is large.In addition,a number of optimizations are performed according to the characteristics of CUDA,including: optimization of thread number setting,use of multiple CUDA streams,zero copy,CPU-GPU asynchronous structure,etc.The computational efficiency of the CUDA simulation calculation module is further improved.Finally,an integration test was performed on the CUDA simulation calculation module.By comparing the test results of the CUDA calculation module and the CPU calculation module for ball particle test and the aspheric particle test,it verified the correctness of the function of the CUDA simulation calculation module.The comparison between the CPU calculation module and the CUDA calculation module for processing different orders of magnitude particles is carried out.The results show that the CUDA simulation calculation module greatly shortens the simulation calculation time and achieves the purpose of improving the calculation efficiency.
【Key words】 CUDA; Discrete Element; GPU; Simulation; Parallel Computing;