CN106250245B - 一种去除粒子模拟算法并行运算中数据竞争的方法 - Google Patents

一种去除粒子模拟算法并行运算中数据竞争的方法 Download PDF

Info

Publication number
CN106250245B
CN106250245B CN201610564482.2A CN201610564482A CN106250245B CN 106250245 B CN106250245 B CN 106250245B CN 201610564482 A CN201610564482 A CN 201610564482A CN 106250245 B CN106250245 B CN 106250245B
Authority
CN
China
Prior art keywords
grid
particle
data contention
grids
particle simulation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610564482.2A
Other languages
English (en)
Other versions
CN106250245A (zh
Inventor
黄桃
金晓林
朱小芳
李斌
胡玉禄
胡权
徐立
杨中海
贺国贤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
University of Electronic Science and Technology of China
Original Assignee
University of Electronic Science and Technology of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by University of Electronic Science and Technology of China filed Critical University of Electronic Science and Technology of China
Priority to CN201610564482.2A priority Critical patent/CN106250245B/zh
Publication of CN106250245A publication Critical patent/CN106250245A/zh
Application granted granted Critical
Publication of CN106250245B publication Critical patent/CN106250245B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms

Abstract

本发明属于粒子模拟方法并行技术领域,具体为一种去除粒子模拟算法并行运算中数据竞争的方法。本发明通过设定求解:一维粒子模拟算法中一个网格的数据竞争影响范围Ns=2×nMax+1网格,nMax为一维粒子模拟算法中一个网格的数据竞争影响范围的最大值;然后对所有网格新增一个为后续应用去除数据竞争方法的编号,编号规则以长度为Ns数目的网格集合为单元,依次编号为1‑Ns,并以此循环,直至遍历所有网格为止;再将编号相同的网格提取出来放入一个集合中,产生Ns个集合,这Ns个集合中的每一个集合,其中的所有网格均不存在数据竞争;最后将Ns个集合串行执行。本发明使得对粒子模拟算法并行的效率因去除数据竞争而明显提高。

Description

一种去除粒子模拟算法并行运算中数据竞争的方法
技术领域
本发明属于粒子模拟方法并行技术领域。在通过计算机程序实现二维粒子模拟算法及其并行化过程中,涉及一种在二维算法并行过程中如何去除数据竞争的并行方法,具体为一种去除粒子模拟算法并行运算中数据竞争的方法。
背景技术
在气体放电、真空电子器件等涉及场与带电粒子相互作用的领域中,带电粒子在场的作用下运动,从而改变带电粒子在空间中的分布状态。粒子的状态反过来影响空间的场分布。在上述场与带电粒子相互作用过程中,有时结构和物理特性是满足轴对称的,或者有某一个方向的物理特性可以通过理论解析的方法得到,则对该类场与带电粒子相互作用的数值模拟可以采用二维粒子模拟方法来实现。利用二维粒子模拟方法对场与粒子相互作用问题的描述中,由于模拟粒子数目较多、时间和空间步长较小等基于数值模拟精确度的要求,导致计算机模拟负担很大,而通过将模拟程序并行化,可以大大缩短运行时间。但在并行过程中,由于存在数据竞争,极大地抑制了并行程序的并行效率。
当多个线程对同一块内存进行修改的时候就会带来数据竞争,而二维粒子模拟程序计算过程中,如果以网格为单元分配线程,则遇到的数据竞争一般有三种情况:
1、不同线程中粒子跨越到同一网格的时候。该种情况的具体实例如图1所示,当线程i中的粒子和线程j中的粒子同时跨越到线程k中的网格时,线程i使线程k中的网格的粒子数从n变到n+1,线程j也使得线程k的网格的粒子数从n变到n+1,这就使得线程i和线程j对线程k的网格的粒子数统计出现了数据竞争。
2、不同线程中粒子对同一网格内电流密度均有贡献的时候。该种情况的具体实例如图2所示,当线程i中的粒子和线程j中的粒子同时对线程k中的网格的电流密度均有贡献时,对于线程k中的网格的电流密度的求解会存在数据竞争。
3、不同线程中粒子对同一网格内电荷密度均有贡献的时候。该种情况的具体实例如图3所示,当线程i中的粒子和线程j中的粒子同时对线程k中的网格的电荷密度均有贡献时,对于线程k中的网格的电荷密度的求解会存在数据竞争。
对于带有上述数据竞争的二维粒子模拟程序,为了保证计算的准确性,对其并行的常规方法有两种。第一种方法是不并行具有竞争的部分,即包含数据竞争部分的程序串行执行;第二种方法是用锁或者原子操作来对并行程序进行控制,即包含数据竞争部分的程序在无竞争时并行、在竞争发生时串行。采用第一种方法对二维粒子模拟程序进行并行时,由于存在数据竞争部分的程序是串行的,而数据竞争部分占总体程序的比例很高,所以第一种方法的并行效率很低,加速比很小。采用第二种方法对二维粒子模拟程序进行并行时,数据竞争部分采用锁或者原子操作来控制,当竞争未发生时并行效率高,但当竞争发生时实质也是串行执行的,而竞争发生的频率在二维粒子模拟程序中很高,所以第二种方法的并行效率也很低。
发明内容
针对上述存在问题或不足,为了解决二维粒子模拟程序在并行过程中由于存在数据竞争导致并行效率低的问题,本发明提供了一种去除粒子模拟算法并行运算中数据竞争的方法。
具体技术方案如下:
步骤1、
设定粒子在单位时间步长内的运动最多可以跨越L个网格;
设定求解网格上电流密度时,某一个网格中的粒子对电流密度的贡献最多影响与粒子所在网格相邻的M个网格;
设定求解网格上电荷密度时,某一个网格中的粒子对电荷密度的贡献最多影响与粒子所在网格相邻的N个网格;
步骤2、由以上三个假设可知,二维粒子模拟算法中一个网格的数据竞争影响范围取决于L、M、N中的最大值。假设L、M、N中的最大值为nMax,则二维粒子模拟算法中一个网格的数据竞争影响范围为Nc=Ns×Ns个网格,其中Ns=2×nMax+1。然后对所有网格新增一个为后续应用去除数据竞争方法的编号,编号规则是以长宽为Ns数目的网格集合为单元,依次编号为1、2、……、Nc,并以此循环,直至遍历所有网格为止。
步骤3、待所有网格均被赋予编号之后,将编号相同的网格提取出来放入一个集合中,则最终可以产生Nc个集合。这Nc个集合中的每一个集合,其中的所有网格均不存在数据竞争,可以直接并行。最后将Nc个集合串行执行。
综上所述,本发明通过采用如上的面分配并行方法使得对粒子模拟算法并行的效率因去除数据竞争而明显提高。
附图说明
图1为粒子跨越网格时产生的数据竞争;
图2为求解电流密度时产生的数据竞争;
图3为求解电荷密度时产生的数据竞争;
图4为去除数据竞争的面分配方法中的网格编号实例;
图5为去除数据竞争的面分配方法中的网格分组实例。
具体实施方式
下面结合附图和实施例对本发明作进一步详细说明。
假设nMax=2,则Ns=5,Nc=25。
首先以长宽各为Ns=5的连续网格集合为单元,依次编号为1、2、……、25,并以此循环,直至遍历所有网格为止。如图4所示。
然后将编号相同的网格提取出来放入一个集合中,则最终可以产生25个集合,如图5所示。其中编号为1的所有网格形成第1个集合,编号为2的所有网格形成第2个集合,以此类推,直至编号为25的所有网格形成第25个集合。
这25个集合中的每一个集合,其中的所有网格均不存在数据竞争,因此集合内部可以直接并行。最后25个集合之间串行执行。
综上可见,本发明通过采用如上的面分配并行方法去除了对粒子模拟算法并行中的数据竞争,明显提高了粒子模拟算法的并行效率。

Claims (1)

1.一种去除粒子模拟算法并行运算中数据竞争的方法,具体技术方案如下:
步骤1、
设定粒子在单位时间步长内的运动最多可以跨越L个网格;
设定求解网格上电流密度时,某一个网格中的粒子对电流密度的贡献最多影响与粒子所在网格相邻的M个网格;
设定求解网格上电荷密度时,某一个网格中的粒子对电荷密度的贡献最多影响与粒子所在网格相邻的N个网格;
步骤2、
设定L、M、N中的最大值为nMax,则二维粒子模拟算法中一个网格的数据竞争影响范围为Nc=Ns×Ns个网格,其中Ns=2×nMax+1;然后对所有网格新增一个为后续应用去除数据竞争方法的编号,编号规则是以长宽为Ns数目的网格集合为单元,依次编号为1、2、……、Nc,并以此循环,直至遍历所有网格为止;
步骤3、
待所有网格均被赋予编号之后,将编号相同的网格提取出来放入一个集合中,则最终可以产生Nc个集合,这Nc个集合中的每一个集合,其中的所有网格均不存在数据竞争,最后将Nc个集合串行执行。
CN201610564482.2A 2016-07-18 2016-07-18 一种去除粒子模拟算法并行运算中数据竞争的方法 Active CN106250245B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610564482.2A CN106250245B (zh) 2016-07-18 2016-07-18 一种去除粒子模拟算法并行运算中数据竞争的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610564482.2A CN106250245B (zh) 2016-07-18 2016-07-18 一种去除粒子模拟算法并行运算中数据竞争的方法

Publications (2)

Publication Number Publication Date
CN106250245A CN106250245A (zh) 2016-12-21
CN106250245B true CN106250245B (zh) 2019-05-14

Family

ID=57613773

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610564482.2A Active CN106250245B (zh) 2016-07-18 2016-07-18 一种去除粒子模拟算法并行运算中数据竞争的方法

Country Status (1)

Country Link
CN (1) CN106250245B (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107704266B (zh) * 2017-08-28 2021-03-30 电子科技大学 一种应用于解决粒子模拟并行数据竞争的归约方法

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760095A (zh) * 2011-04-25 2012-10-31 清华大学 基于静态共享变量识别的动态数据竞争检测方法
CN103729291A (zh) * 2013-12-23 2014-04-16 华中科技大学 一种基于同步关系的并行动态数据竞争检测系统

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102760095A (zh) * 2011-04-25 2012-10-31 清华大学 基于静态共享变量识别的动态数据竞争检测方法
CN103729291A (zh) * 2013-12-23 2014-04-16 华中科技大学 一种基于同步关系的并行动态数据竞争检测系统

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Maotai 2.0: Data Race Prevention in View-Oriented Parallel Programming";K. Leung 等;《2009 International Conference on Parallel and Distributed Computing, Applications and Technologies》;20100217;第263-271页 *
"三维面向对象的并行粒子模拟程序PLASIM3D";马燕云 等;《计算物理》;20040525(第03期);第305-311页 *
"电磁粒子模拟软件并行算法的研究";廖臣;《中国优秀硕士学位论文全文数据库 基础科学辑》;20080115(第01期);第A005-84页 *

Also Published As

Publication number Publication date
CN106250245A (zh) 2016-12-21

Similar Documents

Publication Publication Date Title
Sekizawa et al. Time-dependent Hartree-Fock calculations for multinucleon transfer and quasifission processes in the Ni 64+ U 238 reaction
Grote et al. The warp code: modeling high intensity ion beams
Adams et al. Provably optimal parallel transport sweeps on regular grids
Hawkins et al. Efficient massively parallel transport sweeps
Halyo et al. GPU Enhancement of the Trigger to Extend Physics Reach at the LHC
CN107704266B (zh) 一种应用于解决粒子模拟并行数据竞争的归约方法
CN106250245B (zh) 一种去除粒子模拟算法并行运算中数据竞争的方法
CN106201732B (zh) 在粒子模拟算法并行中去除数据竞争的线分配并行方法
CN106250584B (zh) 在粒子模拟算法并行中去除数据竞争的体分配并行方法
Huang et al. Software test cases generation based on improved particle swarm optimization
Hu et al. Data optimization cnn accelerator design on fpga
CN102930102A (zh) 一种微波部件二次电子倍增仿真中粒子合并方法
Staar et al. Taking a quantum leap in time to solution for simulations of high-Tc superconductors
Chan et al. Supersolid and charge-density-wave states from anisotropic interaction in an optical lattice
Vasileska et al. Particle-in-cell code for gpu systems
Veras et al. A scale-free structure for power-law graphs
Quell et al. Parallelized level-set velocity extension algorithm for nanopatterning applications
CN111967178B (zh) 在粒子模拟算法并行中减少数据竞争的粒子排序发射方法
Łodyga et al. Parallel implementation of a Particle-in-Cell code in Julia programming language
Kisel New approaches for data reconstruction and analysis in the CBM experiment
Basalama et al. A versatile systolic array for transposed and dilated convolution on FPGA
Du et al. Research on Acceleration of a Electron Gun Simulation Module
Yeo et al. GPU Tracking in the COMET Phase-I Cylindrical Drift Chamber
Akishina et al. 4D cellular automaton track finder in the CBM experiment
Agarwal Clustering Algorithms for Jet Reconstruction in HEP

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant