원시데이터 수집 시스템
선정목록으로

Improve the Resolution and Parallel Performance of the Three-Dimensional Refine Algorithm in RELION Using CUDA and MPI

관련 필름·전자재료 · (13) 프리즘 필름

기본 정보

저자
  1. Jingrong Zhang — High Performance Computer Research Center, Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China|||University of Chinese Academy of Sciences, Beijing, China
  2. Zihao Wang — University of Chinese Academy of Sciences, Beijing, China|||High Performance Computer Research Center, Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China
  3. Xiaogang Li — High Performance Computer Research Center, Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China
  4. Fa Zhang — High Performance Computer Research Center, Institute of Computing Technology, Chinese Academy of Sciences, Beijing, China
DOI
10.1109/tcbb.2019.2929171
저널
IEEE/ACM Transactions on Computational Biology and Bioinformatics
발행년도
2019
발행기관
Institute of Electrical and Electronics Engineers
피인용수
6
라이선스
cc-by
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1109/tcbb.2019.2929171
토픽
Electron and X-Ray Spectroscopy Techniques
OpenAlex ID
W2963821882

평가 내용

관련도
관련
사업분야
필름·전자재료 · (13) 프리즘 필름
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '필름·전자재료 > 프리즘 필름' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

In cryo-electron microscopy, RELION is a powerful tool for high-resolution reconstruction. Due to the complicated imaging procedure and the heterogeneity of particles, some of the selected particle images offer more disturbing information than others. However, in the current RELION, all these particle images are treated equally. In our work, we extend RELION’s model with one scalar parameter to score the contribution of a particle depending on the error between the experimental particle and the corresponding reprojection. This scores down weight potentially poor particles, hence accelerating the convergence. Besides, by now there is no sophisticated memory management system for RELION, fragmentation on GPU will increase with iterations, eventually crashing the program. In our work, we designed the stack-based memory management system to guarantee the stability of RELION and to optimize the memory usage condition. Also, to reduce memory usage, we developed a customized compressed data structure for the memory-demanding weight array. In addition, to speed up the GPU version of RELION, we proposed two highly efficient parallel algorithms for weight calculation algorithm and weight selection algorithm. Experiments show that compared with RELION, the optimized three-dimensional refine algorithm can speed up the converge procedure, the memory system can avoid memory fragmentation, and a better speed-up ratio can be obtained.

본문 59,900자

본문 펼치기
## Improve the Resolution and Parallel Performance of the Three-Dimensional Refine Algorithm in RELION Using CUDA and MPI Jingrong Zhang, Zihao Wang, Zhiyong Liu, and Fa Zhang Abstract—In cryo-electron microscopy, RELION is a powerful tool for high-resolution reconstruction. Due to the complicated imaging procedure and the heterogeneity of particles, some of the selected particle images offer more disturbing information than others. However, in the current RELION, all these particle images are treated equally. In our work, we extend RELION’s model with one scalar parameter to score the contribution of a particle depending on the error between the experimental particle and the corresponding reprojection. This scores down weight potentially poor particles, hence accelerating the convergence. Besides, by now there is no sophisticated memory management system for RELION, fragmentation on GPU will increase with iterations, eventually crashing the program. In our work, we designed the stack-based memory management system to guarantee the stability of RELION and to optimize the memory usage condition. Also, to reduce memory usage, we developed a customized compressed data structure for the memorydemanding weight array. In addition, to speed up the GPU version of RELION, we proposed two highly efficient parallel algorithms for weight calculation algorithm and weight selection algorithm. Experiments show that compared with RELION, the optimized threedimensional refine algorithm can speed up the converge procedure, the memory system can avoid memory fragmentation, and a better speed-up ratio can be obtained. Index Terms—cryoEM, RELION, CUDA, statistical method, Top-k selection Ç 1 INTRODUCTION RYO-ELECTRON microscopy (cryoEM) has become a mainstream technology for studying the architecture of # C biological macromolecules [1]. Single-particle analysis (SPA) is an important sub-discipline of cryoEM [2]. Here, “single particles” refers to structurally identical macromolecular complexes (like proteins and viruses). By acquiring thousands and even millions of two-dimensional (2D) projections of randomly oriented particles, SPA uses reconstruction software (like EMAN [3] and RELION [4]) to recover the threedimensional (3D) structure [2]. Among reconstruction software packages, RELION significantly increases the attainable resolution by adopting a Bayesian approach [4], [5]. Many structures have achieved near-atomic resolution using RELION [1], [6], [7], [8], [9], [10], [11]. However, the imaging procedure in cryoEM is quite complicated, with abundant randomness. In general, the noise, artifacts of particles in the same micrograph may differ greatly. The general quality of even selected particles will differ [12]. Particles with severe artifacts and noise (“bad - J. Zhang and Z. Wang are with University of Chinese Academy of Sciences, Beijing 100039, China and also with High Performance Computer Research Center, Institute of Computing Technology, Chinese Academy of Sciences, [Beijing 100190, China. E-mail: {zhangjingrong, zihaowang}@ict.ac.cn.](mailto:) - Z. Liu and F. Zhang are with High Performance Computer Research Center, Institute of Computing Technology, Chinese Academy of Sciences, Beijing [100190, China. E-mail: {zyliu, zhangfa}@ict.ac.cn.](mailto:) Manuscript received 31 Oct. 2018; revised 11 May 2019; accepted 11 June 2019. Date of publication 19 July 2019; date of current version 1 Apr. 2021. (Corresponding author: Fa Zhang.) Digital Object Identifier no. 10.1109/TCBB.2019.2929171 particles”) may negatively influence the reconstruction procedure, a problem that has not received enough attention. In our work, inspired by the training procedure of neural networks, we extended the model parameters of RELION with one scalar parameter and updated it based on the idea of back-propagation. In our method, the scalar of “bad particles” will decrease with iterations, while that of “good particles” will increase. This modification speeds up the converge procedure and boosts the final resolution. The expectationmaximization (EM) algorithm is an iterative method to find the best hypothesis for the probability distribution of hidden parameters in statistical models. However, to estimate the probability distribution of the orientation parameters for each particle (in the expectation step), RELION needs to compare each particle image with every calculated projection [13], leading to a huge computation load [14] and large memory requirement. Taking the dataset used in the tutorial of RELION 2.0 [15] containing 6,496 b-galactosidase 128*128 particles as an example, the 3D refinement stage requires more than 2 GB memory per process and 40 CPU hours even though this dataset is quite small. In addition, RELION adopts a “modified version of the expectation-maximization algorithm”. In its “Expectation step”, RELION performs a two times finer procedure. At the end of the first pass, RELION selects a sub-domain of all orientations for each particle image. The selection rule reserves the orientations with high probability whose sum reaches 99.9 percent of the sum total of the probability value of all orientations. One naive solution for this selection step is to first Thi k i li d d C i C A ib i 4 0 Li F i f i h // i /li /b /4 0/ sort all probability values and then sum them sequentially from largest to smaller until their sum reaches 99.9 percent of the sum total. It is obvious that this method is a sequential algorithm and has high data dependency. The processing times of sorting and summation will increase dramatically as the number of orientations increases. To reduce the time cost of this step, we drew inspiration from the parallel top-k selection and stream compaction algorithms and designed an efficient parallel top selection algorithm. To reduce the running time, many cryoEM software programs [16], [17], [18], [19], [20] have been parallelized on GPUs. The reviews [21], [22], [23] have introduced the advances of the parallelizaiton softwares. For example, CryoSparc utilizes the GPU card to speed up the reconstruction and 3D classification. And it A GPU parallel version of RELION has also been proposed [24]. Also, the software THUNDER [19] accelerates the image processing and calculation of re-projections with GPUs. However, most parallel software in cryoEM overlooks memory-related operational stability and robustness, which heavily relies on GPU hardware characteristics and the memory accessing pattern. For memory-intensive applications like RELION, memoryrelated code will dramatically influence its stability, robustness and performance. One important aspect is memory fragments. Frequently randomly allocating and de-allocating memory on the GPU may divide the successive memory into several pieces of discontinuous memory. We call those small pieces of memory “fragments”. When the program tries to allocate a large piece of memory, even though the total available memory is sufficient, the allocation can still fall and report an “out of memory” error because of the fragments. However, no sophisticated memory management system can prevent the fragmentation problem. In addition, no stable memory management strategy has been introduced to RELION. For example, when processing the dataset EMPIAR-10028 with a particle size of 360*360 on GPU NVIDIA K20c, an “out of memory” error occurs during later iterations. To improve the stability and robustness of RELION, we developed a stabilizing memory management system, especially for large datasets. In this system, we utilize the characteristics of iterative methods to avoid fragmentation. This memory manage system can also be applied to other iterative methods. Moreover, even with a fragment-free memory management system, when the total memory consumption of RELION exceeds the GPU memory, an “out of memory” error will still be reported. If we can reduce the memory consumption, this issue would be eased fundamentally. As we mentioned, the weight array is the data structure that demands the most memory. To reduce its memory consumption, we analyzed the data structure of the weight array and determined that we can reduce its memory requirements by carefully redesigning its structure. In summary, in this work, to speed up the convergence procedure and boost the final resolution, we propose an extended 3D refine algorithm by extending the model parameters with one scalar parameter and updating it based on the idea of back-propagation. In addition, we designed a memory-efficient and memory-stabilizing management sys where Xi is the projection image obtained by experiments, CTFi is its contrast transfer function for the ith image, and V is the underlying structure in the dataset. The operation PL l¼1 <sup>P</sup> jl <sup>fVl</sup> <sup>extracts a slice from V, which is equivalent to the</sup> real-space projection. In RELION, the parameter set Q is Vl; s; t, where s <sup>2</sup> and t <sup>2</sup> are the variance of the noise and the signal component. In this image formation model, the orientation parameters for projection images are unknown, and we use G <sup>ð</sup> if <sup>nÞ</sup> <sup>to</sup> efficiency of GPU memory usage. Then, to reduce the memory usage, we developed a novel data structure. Finally, we developed a weight calculation parallel algorithm and a top selection algorithm to speed up the calculation. Our paper is organized as follows: in Section 2, we introduce related work; in Section 3, we show the extended 3D refine algorithm; in Section 4, we introduce our stabilizing management system and memory-efficient data structure; in Section 5, we present the weight calculation parallel algorithm and the top selection algorithm. The results of the experiments are presented in Section 6. We then conclude the paper. 2 RELATED WORK In this section, we introduce the related work from three aspects: statistical methods used in cryoEM, the basic workflow of the refine algorithm of RELION and efforts to accelerate it, and parallel top-k selection algorithms. 2.1 Statistical Methods As mentioned, the structure determination method used in RELION is a Bayesian-based method and is therefore a statistical method. In general, the method of RELION is less sensitive to the starting model and permits recovery of the underlying signal from noisy data compared to traditional cross-correlation-based methods [25], [26], [27]. In general, statistical methods try to find the best hypothesis for the distribution of parameters in a statistical model given the observations. There have been numerous contributions beyond RELION applying this method based on different kinds of image formation models in cryoEM [25], [28], [29]. For example, in a previous work [28], the data model was Xi ¼ PifAki þ sGi (where Aki indicates the underlying image, Pif is the transformation with the ith image, s is the standard deviation coefficient, and Gi indicates the independent noise). The model aims to find the most likely set of parameters (Q) to construct a model describing structural data through optimization of the following log-likelihood function: Z f LðQÞ ¼ XI i¼1 ln XK k¼1 P ðXijk; f; QÞP ðk; fjQÞdf: (2.1) The reconstruction algorithm in RELION is also a typical statistical method. It is solved by a modified version of the expectation maximization algorithm based on the work of [13]. It formulates the image formation model in Fourier space as follows: Xij ¼ CTFij XL l¼1 Pjl <sup>fVl þ Nij;</sup> (2.2) L l¼1 <sup>P</sup> jl <sup>f</sup> In this image formation model, the orientation parameters for projection images are unknown, and we use G <sup>ð</sup> if <sup>nÞ</sup> <sup>to</sup> Fig. 1. Selecting the 2nd biggest element. f for the ith image in the nth iteration (i 2 ½0; I�). Here, the orientations f 2 ½0; F� (F ¼ ðrRot; rTilt; rPsi; tX; tY Þ) comprise 3 rotation (rRot; rTilt; rPsi) and 2 translation (tX; tY ) parameters. 2.2 Efforts to Accelerate RELION GeRelion [30] is a parallel GPU version 1.4. To port the program to the GPU, GeRelion proposes a four-level schedule model. In addition, the weight array is assumed to be sparse and stored in compressed sparse row (CSR) matrix mode: one continuous vector stores the value, and an aux vector records the indexes of the weight array. Because of the usage of the aux vector, the memory consumption of this structure may exceed that of the original structure when the weight array is not sparse. Based on this consideration, we developed a new data structure that can reduce its memory cost. RELION [24] also proposed a parallel GPU version for its expectation-maximization algorithm. In contrast to its CPU version, the parallel version runs in single precision mode by default to reduce memory consumption. In addition, during the expectation step, accessing the re-projection images consumes a lot of time. RELION stores re-projection images in texture memory to make use of its on-chip cache, which can reduce the memory accessing time. However, this strategy is not always effective. As the size of the re-projection image increases, it may exceed the size of the texture memory cache. In this case, there would be frequent data swapping between the cache and texture memory. Consequently, the performance of the cache will be heavily diminished. Based on this observation, we designed a different data accessing strategy to speed up the memory accessing. Both GeRelion [30] and RELION [24] provided detailed analyses of the performance of each major step. According to their analyses, the expectation step is the most time-consuming step. The most memory-demanding data structure is the weight array G. 2.3 Parallel Top-k Selection Algorithms In our work, we developed a parallel top selection algorithm for RELION based on the idea of parallel top-k selection algorithm. Here we introduce its current research condition. Top-k problem requests to find the top K elements from an un-ordered list [31]. One general kind of algorithm is selecting by Sorting. The basic idea of these algorithms is to sort the entire list and then query the top K elements. Although the top-k selection problem is a different from the top selection problem in RELION, the basic idea of current implementation of RELION is the same. Another kind of algorithm is to select based on partitions. One advantage of such algorithms is that they can avoid the sorting operation. The basic steps of “Bucket Select” are as follows [32]. First, “Bucket Select” determines the size of buckets, assigns each element to a bucket and then identifies the bucket containing the kth order statistic. And it projects the entries in that bucket onto a new set of buckets. After a number of iterations, when the bucket width equals 1, we find the kth element. Fig. 1 shows an example of “Bucket Select”. It uses the linear projection function Formula (2.3) to define the boundary of buckets. - <u>B</u> bucket½i�¼ max � min <sup>ðvec½i��</sup> <sup>minÞ</sup> : (2.3) “Bucket Select” owns two phases. In Phase I, it reduces workload by creating a new vector containing the candidates. In Phase II, the workload is reduced by redefining the max and min. “Bucket Select” can avoid the sorting operation. However, first, its efficiency reduces with the bucket width. Then this method can only find the kth element. There is still one step away from getting the top K elements. So in our method, we first added an small dataset sorting to speedup the boundary converge. Then we implemented one more kernel to get the qualified data out based on the work [33]. 3 EXTEND THE REFINE ALGORITHM TO ESTIMATE THE RELIABILITY OF PARTICLE IMAGE In general, we use statistical method to find the most likely perameter set Q for the model constructed with the observation data and prior information. In work [28], they proposed to extent the model parameter set Q with a multiplicative and an addictive factor for the signal in each experimental image to normalize the noise. In RELION 2.0, the variance of signal and noise has been involved in its statistical model. In Relion 3.0, per-particle CTF correcition and beam-tilt correction is introduced. These parameters can provide more detailed estimation for each particle so as to improve the reconstruction resolution. However, for each particle, the data can be used is so limited to achieve accurate statistical estimation. Besides, in the beginning iterations, the estimation about many particles’ orientaions may be far from accurate. So the corresponding estimation about the signal, noise and CTF parameters are inaccurate. These parameters may be very heplful for high resolution refinement. But, when thay are inaccurate, they will slow down the convergence. Seeing these shortages, we try to estimate each particle in a more general way. Due to the heterogeneity of particle, random noise and some other influence factors, the quality of particle images differs a lot. Some “bad” particles may introduce interference to the reconstruction result. If we can use a more generalized scaler parameter to estimate the realibility of each particle image and its related parameters, it can be used to restrain the influence from “bad particles” and enhance the contribution from “good” ones. And this scaler parameter would help accelarate the convergence of the expectation-maximization Fig. 2. The work flow of the modified algorithm. We desire to design this scaler parameter to reflect this realibilty of the particle images and their related parameters based on the understanding of the iteration procedure of expectation-maximazation algorithm. As we know, during the iterations, the estimation of relating parameter should be gradually getting close to the actual condition with the increase of the resolution. And the re-projections generated from the reconstruction result and these estimated parameters should be becomming more and more similar to the actual particle images. While as for the particles with low realibilty, this phenomenon doesn’t hold. Because these particle didn’t contribute positively to the reconstruction result and gradually the reconstruction may become more and more different to these particles. And these will shown in the error between re-projection and the particle image. So based on this obervation, we desiged the concrete formula for this scalar parameter. For each particle, we store its best orientation and its corresponding error value jXi� PL CTFi l¼1 <sup>P f0</sup> <sup>V j2 and compare it with the re-projection. After</sup> (3.2) ���� l diffi <sup>n</sup> <sup>¼</sup> XJ ���� j¼0 XJ ���� Xij � CTFij X l¼1 LPjl <sup>f</sup> jl <sup>fV</sup> l <sup>ðnÞ</sup> ; <u>i</u> <sup>n</sup> i <sup>¼</sup> <sup><u>diff</u></sup> <sup>n</sup> err <sup>n</sup> i <u>i</u> <sup>n</sup> <sup><u>�</u></sup> <sup><u>diff</u></sup> <u>i</u> <sup>nþ1</sup> <u>i</u> <sup>n</sup> diffi <sup>nþ1</sup> i where diffi <sup>n</sup> i <sup>n</sup> <sup>¼ diff</sup> i <sup>nþ1</sup> i <sup>n</sup> <sup>></sup> <sup>diff</sup> i <sup>nþ1</sup> PL l PL CTFi l¼1 <sup>P f0</sup> <sup>V j2 and compare it with the re-projection. After</sup> one iteration, the error value of one particle will change. And if the error value gets smaller, it indicates that this particle made positive contributions and vice versa. By now we get the Formula (3.1): PJ j R f <sup>G</sup> i <sup>ð</sup> f <sup>nÞ</sup> lj <sup>T</sup> <sup>CTFijsiXij</sup> s <sup>2ðnÞ</sup> Jj¼1 <sup>P f</sup> lj <sup>T</sup> Vl <sup>ðnþ1Þ</sup> ¼ <u>ij</u> ~~P~~ N ~~R~~ ~~P~~ Jj¼1 <sup>P f</sup> lj <sup>T</sup> <sup>CTFij</sup> PN i¼1 ~~R~~ if f <sup>G</sup> i <sup>ð</sup> f <sup>nÞ</sup> ~~P~~ J j lj <sup>T</sup> <sup>CTFij</sup> s <sup>2ðnÞ</sup> Jj¼1 <sup>P f</sup> lj <sup>T</sup> þ <u>1</u> t <sup>2ðnÞ</sup> if X ����Xij � CTFij ij <sup>2</sup> ij <sup>ðnþ1Þ</sup> ¼ <sup><u>1</u></sup> 2 <sup>2</sup> ij <sup>ðnþ1Þ</sup> ¼ <sup><u>1</u></sup> 2 i¼1 Z s <sup>2</sup> ij <sup>ðnþ1Þ</sup> 2 ���� 2 df l LPjl <sup>f</sup> jl <sup>fV</sup> l <sup>ðnÞ</sup> f GifðnÞ l¼1 t <sup>2</sup> ij <sup>ðnþ1Þ</sup> <sup><u>1</u></sup> l j <sup>2</sup> 2 <sup>jV ðnþ1Þ</sup> <u>e</u> <sup>err</sup> i <sup>ðnÞ</sup> <sup><u>3</u></sup> 4 <sup>þ</sup> 2 �ðe <sup>errðnÞ</sup> si ¼ <sup><u>3</u></sup> 4 2 �ðe <sup>err</sup> i <sup>ðnÞ</sup> þ 1Þ i : (3.1) The second and third formulas are the same as RELION’s formula written in work [4]. But, the first formula introduced the scalar parameter si to estimate the realibility of particle images. And the forth formula describes the concrete formula of this scalar parameter, within and err <sup>ð</sup> i <sup>nÞ</sup> is where diffi <sup>n</sup> indicates the difference between the re projection and particle image in the nth iteration. When diffi <sup>n</sup> <sup>¼ diff</sup> i <sup>nþ1</sup>, si would equal to 1, which means the same as the original version. And diffi <sup>n</sup> <sup>></sup> <sup>diff</sup> i <sup>nþ1</sup> indicates the particle has made positive contribution. The corresponding scalar parameter si is larger than 1. As scalar parameter si is a relaxation factor for each particle, to normalize the value of si, we used sigmoid function [34]. In our function, the range of si is [0.75, 1.25]. The general work flow of the modified algorithm is shown in Fig. 2. In the expectation step (shown in the upper left corner of Fig. 2), computer-generated projections (labeled as “re-projection”) of the structure are compared with the experimental images (label as “real particle image”) to acquire the probability distribution over orientations of the images. In the maximization step, the 3D structure is updated combing the prior information (lower left corner of Fig. 2). And according to the updated 3D structure V, we can update the variance of signal t. Then, comparing the new reprojections and particle images we can update the variane of noise sij. Also, comparing real-images with its re-porjection at best orientations of iteration n and n þ 1, we can update the scaler parameter si. 4 MEMORY OPTIMIZATION STRATEGIES To optimize the memory usage of this program, we first designed a new data structure to reduce the memory consumption of the weight array. Then, to ensure the stability of RELION, we proposed a stack-based memory scheduling algorithm that is in charge of the memory operations between the CPU and GPU. 4.1 Customized Compressed Data Structure As we mentioned previously, as the number of sampling points increases, the memory consumption of the weight array grows dramatically. Consequently, reducing the mem Fig. 3. Customized compressed data structure. As RELION adopts a modified expectation-maximization algorithm to iteratively optimize the results, the weight array would be used twice per iteration. In the first pass of one iteration, RELION calculates the difference between each particle and each sampled re-projection, which will fill the weight array densely. However, in the second pass of one iteration, only part of the sampling points will be considered, making the weight array a relatively sparse array. One simple method to reduce the memory consumption of the weight array is to use the classical compressed data structure Compressed Sparse Row. Instead of storing every each one of the elements in the weight array, CSR stores only the non-zero elements and their corresponding subscripts in each row. In general, when the number of nonzero elements (n) is less than half of the total number of elements (N), this array is considered sparse (n < 0:5 � N). However, as for RELION, the weight array cannot always meet this criterion. For example, in the first several iterations, due to the low resolution of the estimated parameters, the weight array tends to be denser than later iterations. Under this condition, the memory consumption of the CSR structure may exceed the original memory consumption, which would damage the performance. To cope with this issue, we designed a customized compressed data structure. The sparse weight array is generated in the second pass, during which only sampling points with high probability are considered with fine sampling steps, and one sampling point would generate 32 fine sampling points in the second pass. The weight of these 32 sampling points is stored successively. Thus, in contrast to the general sparse arrays, as shown in the top half of Fig. 3, the non-zero elements of the sparse weight array are partially continuous. Making use of this trait, we can reduce the memory cost for the subscript. In the bottom half of Fig. 3, instead of recording the column subscript of each non-zero element, we only store the index of the first non-zero elements in the index array. In Fig. 3, we list the details of this data structure. This data structure consists of three parts. The first part is the “Value Array”, which stores all of the non-zero elements of the weight array. Then, the “Indices Array” stores the subscript of the first subscript of the 32 consecutive non-zero elements. Finally, we use “Row Point Array” to indicate the start posi For each particle, we can compare the compression ratio between the CSR and our structure. Let the total number of elements be N and the non-zero elements in the matrix be n. For each particle, size original, size ~~c~~ ompressed and size new refer to the memory cost in bytes for the original version of RELION, CSR and our method. Formula (4.1) shows their concrete memory cost. (Here size ~~v~~ alue and size subscript indicate the number of bytes used for one non-zero element and the subscript.) Based on these formula, we can conclude that when n - 0:67N, the memory consumption of CSR will exceed the original version. However, the memory consumption of our method will not exceed the original version unless n - 0:98N. size ~~v~~ alue ¼ sizeofðdoubleÞ ¼ 8 size ~~s~~ ubscript ¼ sizeofðintÞ ¼ 4 size ~~o~~ riginal ¼ N �ð32 � sizevalueÞ size ~~c~~ onpressed ¼ n �ð32 �ðsizevalue þ sizesubscriptÞÞ size ~~n~~ ew ¼ n �ð32 � sizevalue þ sizesubscriptÞ: (4.1) 4.2 Stack-Based Stabilizing Management System RELION adopts a modified version of the expectationmaximization method to perform reconstruction. During this procedure, numerous parameters (such as the particle images and the current resolution) need to be taken into account. These parameters become different variables used on the CPU and GPU. In addition to the large number of variables, the memory requirements of some of these variables vary during the iterations according to the sampling rate and resolution, among other factors. Consequently, the memory management system needs to handle not only the large number of variables but also the variety of memory requirements of these variables. However, there is no fully automatic memory management system for the GPU. The native memory allocation on the GPU is generally random. Repeated allocation and deallocation will introduce memory fragmentation, which will split the memory space into many small pieces. In the later stage of the iterations, these fragments will introduce mem Fig. 4. Illustration of the memory operation on the GPU. To manage these memory operations, RELION uses a linked list to manage its GPU global memory. In the linked list, each node indicates one piece of the consecutive memory, and the adjacent memory will be merged into one node. Thus, the linked list can reduce fragments to a degree. However, this method cannot prevent the generation of fragments. When available memory is separated by used memories, the issue of fragmentation still exists. Importantly, the GPU memory allocation operation and the kernel running on the GPU are asynchronous. This property leaves us more freedom to manage the GPU memory. One important property of the expectation-maximization algorithm used by RELION is that it is an iterative method. In contrast to direct methods, iterative methods update the estimated parameters based on the estimation generated from previous iterations. Consequently, the algorithm is processed in one round after another. Many of the memory operations within the iteration are predictable and repeatable. For example, the allocation of projection images is only needed at the beginning of each iteration, and de-allocation is performed at the end of each iteration. In addition, within one iteration, hundreds of thousands of particles are processed, but the basic processing procedure of each particle is similar. For example, each of the particle images needs to be transformed from real space to Fourier space first. Therefore, at the beginning of processing one particle, we need to allocate the memories for the particles in Fourier space and free them at the end of processing one particle. Based on the introduction above, we can conclude that the memory operation can be managed in groups based on their life cycle: global scope, iteration scope, and per particle scope. One example is shown in Fig. 4. At the beginning, variables needed by the whole program will be allocated. Then, at the beginning of each iteration, variables in the iteration scope will be allocated. Variables such as the particle images in Fourier space will then be allocated for each particle. Finally, at the end of their life cycle, the particles will be freed. Another consideration is that, under some conditions, the the GPU. In some cases, we can reduce the memory requirement by reducing the number of particles processed at one time. In our program, we also consider the extreme condition. Within the processing of one particle, the particle images need to be compared with many re-projection images from different orientations. When the size of one re-projection grows, the total memory requirement grows rapidly. Therefore, we add one more group for the orientations. When the memory of the GPU is limited, we can process all the re-projections in several batches, and the corresponding variables will be allocated and de-allocated at the beginning and end of the batch. This group is shown in Fig. 4. Based on these rules, we can build a stackbased memory management system thoroughly to avoid memory fragments. This memory management system can also be used in other iterative methods. 5 PARALLEL OPTIMIZATION METHODS In this section, we try to speed up the GPU parallel algorithm of RELION by proposing two highly efficient parallel algorithms: the in-kernel top-sum parallel algorithm and weight calculation parallel algorithm. 5.1 In-kernel Top-Sum Selection Parallel Algorithm As introduced in Section 2.3, in the field of computing technology, there is a traditional problem called “top-k”, which involves selecting the top K (number K is constant) large or small elements from an unordered list. Considerable efforts have focused on the classic “top-k” problem in parallel. In RELION, one similar but more complicated problem occurs. Because RELION implements a modified version of the adaptive expectation maximization algorithm, it first adopts a coarse grid to estimate the contribution of orientations. Then, a sub-domain of orientations f whose total calculated probabilities exceed a fraction (99.9 percent) of the sum of all probabilities is retained. At the end of the first pass, we need to find the stopping point at which the sum of the values larger than the stopping point barely exceeds Fig. 5. The work-flow of the in-kernel top-sum solution. Instead of selecting the top k largest elements, we need to select the largest elements whose sum reaches 99.9 percent of the sum total. We define this problem as “Top-sum” selection. To the best of our knowledge, no effective parallel solution has been achieved. <u>Algorithm 1. In-kernel Top-Sum Algorithm</u> Require: Unsorted weight Array W Require: Length of array n and Number of buckets m Require: Sum of weight array tSum 1: tNum totalNumberOfThreadsðÞ 2: nCandidates 1000 3: tId threadIdðÞ 4: while nCandidates < tNum do 5: p pivotsðÞ 6: for ði ¼ 0; i < n; i ¼ i þ tNumÞ do 7: bId LocateBucketðW ½i�; P Þ 8: C½bId� C½bId�þ 1 9: S½bId� S½bId�þ W ½i� 10: pSum convertSumtoPreSumðSÞ 11: end for 12: stopBucketId locateStoppingPointðpSum; tSumÞ 13: nCandidates C½stopId� 14: end while 15: synchronize() 16: sharedArr selectCandidateðW; tId; stopBucketIdÞ 17: synchronize() 18: sortedArr BitonicSortðsharedArrÞ 19: stoppingPoint getStoppingPointðsortedArr; tSumÞ To acquire the correct stopping point, the sequential version of RELION first allocates a block of memory to store the weight array of one particle and then eliminates zero elements from the array. RELION then sorts the array. Finally, the elements are summed in descending order one by one until the sum exceeds 99.9 percent of the sum of the total probability. The basic idea of the parallel version is similar. The data are sorted, and the elements are then selected sequentially. This approach has two weaknesses. First, this method requires a lot of memory to store a complete copy of the weight array on the GPU. As we discussed above, the size of the weight array may increase significantly in some iterations, while the memory of the GPU is quite limited. Second, the sorting operation is quite timeconsuming and unnecessary. Sorting on the GPU costs many synchronization and write operations which is very time consuming. We only need to know the stopping point, so sorting is unnecessary. Based on the consideration above, we propose our own parallel method based on the following considerations: 1. We should not sort all of the data. 2. To obtain the partial 99.9 percent of the total probability, the data must be partially sequential. 3. During the process of summation, the information about partial sums will be lost. <u>Algorithm 2. Select Candidates within One Bucket</u> Require: Unsorted weight Array W Require: The bucket index containing stopping point stopBucketId 1: tNum 256 2: tId threadIdðÞ 3: C½tId� 0 4: S½bId� 0 5: p pivotsðÞ 6: for ði ¼ 0; i < n; i ¼ i þ tNumÞ do 7: bId LocateBucketðW ½i�; P Þ 8: if bId ¼¼ stopBucketId then 9: if C½bId�¼¼ 0 then 10: S½bId� W ½i� 11: else 12: nId hashToNewLocðCÞ 13: S½nId� W ½i� 14: end if 15: end if 16: end for With these considerations, we propose a parallel top-sum algorithm. In general, this algorithm has four basic steps (1. Bucket select, 2. Locate bucket, 3. Select data, 4. Use bucket sort to obtain stop point). We show the basic work-flow of our method in Fig. 5. We summarize our in-kernel top-sum algorithm with pseudo code in Algorithm 1. In Algorithm 1, Lines 5 to 10 shows Step 1, and Lines 11 to 13 show Step 2. Then Step 4 is shown in line 18 to 19. We also use Algorithm 2 to show the details of Step 3. First, in the “Bucket select” step, we choose some values as the pivots ðP1; P2; P3:::Pm þ 1Þ to split the data into different buckets (B1; B2:::Bm). For example, if wi is larger than pivot P3 and smaller than pivot P4, wi belongs to bucket B3. In this method, we select these pivots uniformly Pj ¼ <sup><u>j�ðmaxðwi</u></sup> m <sup><u>Þ�minðwiÞÞ</u></sup> þ minðwiÞ. In practice, we use a thread to process wi in parallel Fig. 6. Compare each component of the particle image and re-projection image. As shown in the left part of Fig. 5. First, we locate the bucket that wi belongs to. Then, we record the sum (S½m�) and number (C½m�) of each bucket. Finally, we convert the sum of each bucket to the prefix sum (Ps½m�). With the prefix sum array (Ps½m�), we can determine which bucket (B½t�) contains the stopping point. If the number of elements in the corresponding bucket is less than the total number of threads tNum, we can enter step 3. Otherwise, we will repeat step 1 and step 2. In step 3, we select the candidates (wis) in bucket B½t�. In contrast to the traditional parallel algorithm, because the number of candidates is less than tNum, the shared memory array S can store all candidates. We use a hash algorithm to load these candidates to shared memory. In step 4, we sort these candidates using a Bitonic sort algorithm so that we can locate the precise stopping point. 5.2 Weight Calculation Parallel Algorithm As we mentioned, RELION compares each particle image with the re-projection images and then estimates the particle orientations based on the differences. One important function used to compare the particle image with re-projection images is “getAllSquaredDifferencesðÞ”. In this function, we can calculate the squared difference of every component of the particle image and re-projection image and generate the weight value to indicate the difference. Fig. 6a illustrates this comparison, where wif indicate that the ith particle image is compared with the re-projection at orientation f. We can use Equation (5.1) to describe this procedure: To calculate one weight value wif in parallel on the GPU, the most straightforward method is loading one whole particle image and one re-projection in one thread. If we use sizeimage to indicate the size of the image, calculating the weight value requires sizeimage � sizeimage times of global memory accessing, which makes the performance of this algorithm rely heavily on the memory accessing speed. As for the GPU, global memory accessing is 100 times slower than shared memory [35]. Thus, if we can replace this global memory accessing with shared memory, the running time can be greatly reduced. However, one shortage of shared memory is that its size is quite limited. Based on these observations, we designed a new weight calculation parallel algorithm. We use Fig. 7 to show the details of this method. First, we can load only a part of several particle and re-projection images. In the upper left corner of Fig. 7, the white part shows the part loaded from global memory to shared memory. Using the data marked in white color, we can only calculate part of wif. However, one benefit is that we can calculate many different wifs. For the example shown in Fig. 7, the first part of weights value S1 ¼ fw11�1; w12�1:::w21�1; w22�1:::w31�1; w32�1:::w44�1g. After loading the second (in light gray color) part of the data to shared memory, we can acquire the second part S2 ¼ fw11�2:::w44�2g. Similarly, the third (in dark gray color) part is loaded to shared memory to calculate S3 ¼ fw11�3:::w44�3g. After that, we can acquire the complete weight value (w11 ¼ w11�1 þ w11�2 þ w11�3), and at this point, several weight values w11; w12:::w44 can be acquired. The most important advantage of this method is that the time spent accessing global memory is reduced. Take the example shown in Fig. 7 as one example. In total, it can calculate 4 � 4 ¼ 16 different weight values. Furthermore, it only requires 4 � 2 � sizeimage global memory. Consequently, for each weight value wif, the required duration of global mem ory access is only 4�2�size16 <u>image</u> ¼ sizeimage2 ~~.~~ Compared with the original method, it reduced the time spent accessing global memory by sizeimage �ðsizeimage � 2Þ. As shared memory is available for all threads of one block, we can reuse the data and reduce the data accessing time. Taking a 32*32 block as an example, the global memory accessing time can be reduced by 32 times. For the step “Get Squared Differences (GSD)”, the majority of the time is spent in the expectation step, and reducing global memory accessing can efficiently reduce the <sup>ð</sup> if <sup>nÞ</sup> <sup>¼</sup> <sup><u>1</u></sup> 2 w <sup>ð</sup> if <sup>nÞ</sup> 2 XN ððReðpFkÞ � ReðXikÞÞ <sup>2</sup> þ ðImðpFkÞ � ImðXikÞÞ <sup>2</sup> Þ; k¼1 (5.1) where Xik is the kth component for the ith particle image and pfk is the kth component of the re-projection at orientation f. One detail to explain is that the calculation of the first iteration differs from Equation (5.1) by calculating the difference with normalized cross-correlation. However, both crosscorrelations and squared differences contain two parts: comparing each component and reducing to one weight result. This procedure is shown from one particle’s perspective. As illustrated in Fig. 6b, we need to calculate the weight for each re-projection. In this whole procedure, as shown in Fig. 6c, each re-projection needs to be compared with each ory access is only 4�2�sizeimage 16 ¼ sizeimage Fig. 7. Using shared memory to compare the particle image and re-projection image. 6 EXPERIMENTS 6.1 Environment and Test Dataset In our experiments, we adopted three different datasets from the EMPIAR [36]. The first dataset is 6,496 b-galactosidase (EMPIAR-10017 [15]). The size of each particle is 128 � 128. Th second dataset is “Plasmodium falciparum 80S ribosome bound to the anti-protozoan drug emetine”, which contains 100,000 particles with particle size 360 � 360 (EMPIAR-10028 [9], [1]). The third dataset is also b-galactosidase (EMPIAR-10204) with 5000 particle with size 100 � 100. The experiments are carried out on a machine running the Ubuntu operating system 14.04, 64-bit with an Intel(R) Xeon(R) CPU E5-2680 v3 at 2.50 GHz. The GPU card is NVIDIA GeForce GTX Titan X, with 3072 stream processers and 12288 MB global memory. 6.2 Performance of the Extended Refine Algorithm of RELION In this section, we compared our algorithm with the original version of RELION. To illustrate the performance, we recorded the resolution after each iteration for the three datasets mentioned above. The corresponding results are shown in Fig. 8. From these three images, in general, we can find that our method converge faster than the original version during the iterations. Especially in the middle iterations, our method can reach better resolution in less iterations. Take the dataset EMPIAR-10204 as example, in the Fig. 8c, we can find that from the seventh iteration, our method starts to get better resolution compared with the original verison. In the middle iterations, these advantages become more and more obvious. This is caused by the scalar parameter we introduced. During the first iterations, the projection error of all the particles are quite similar, the corresponding scalar parameter value is also quite close to each other. However, the estimation grows more and more accurate with the iterations. The difference between particles become evident. Especially, in the middle iterations, the value of scalar parameters for different particles differs with each other. And this is the stage where these scalar parameters make more significant contribution to the refinement procedure. And we can see around the fifteenth iterations, the differences between the resolution of our method and the original method becomes quite small. The resolution generally converge to the final resolution. As for the final resolution, the dataset EMPIAR-10017 can acquire 7.25 A� and 7.69 A� for dataset EMPIAR-10017 can acquire 7.25 A� and 7.69 A� for our method and the original version. For the Plasmodium falciparum 80S ribosome, the final resolution is 3.25 A� (our ciparum 80S ribosome, the final resolution is 3.25 A� (our method) and 3.45 A� (the original version). And for dataset method) and 3.45 A� (the original version). And for dataset EMPIAR-10204, its final resolution is 3.80 A� (our method) EMPIAR-10204, its final resolution is 3.80 A� (our method) and 3.93 A� (the original version), respectively. Based on the and 3.93 A� (the original version), respectively. Based on the final resolution, we can see that our method can increase the resolution in a certain degree. 6.3 Performance of Stack-Based Memory Management System We proposed the stack-based memory management system for RELION, here we use the dataset EMPIAR-10028 to show the running procedure of the memory management system. Different from the original version of RELION who allocates the GPU memory randomly, our system allocates Fig. 8. The resolution after each iteration for both our extended algorithm and original RELION algorithm. (a)b-galactosidase (EMPIAR-10017) (b) Fig. 9. The top pointer of used memory. the memories without fragment. So we can use the top pointer of the “stack” to indicate the used GPU global memory. The memory before the “top pointer” is used memory. And memory with the larger address is continuous free memory. In Fig. 9, the horizontal axis indicates each allocation operation during the running of RELION. And the vertical axis indicates the memory address. As we can see, the memory consumption of RELION shows the general cyclical pattern due to its iterative method. Also, our method can help group these memory usages with our stack-based memory management system. 6.4 Memory Consumption Optimization We modified the data structure of weight array, which saves a substantial amount of memory. To show the performance of our customized data strucuture, we use the data set EMPIAR-10017 as benchmark. In Fig. 10, we record the max memory consumption of the weight array of one particle of one iterations. As shown in Fig. 10, the most memorydemanding array appears in the middle of the iterations. In these iterations, our structure significantly reduces the memory requirements. The upper bound of the size of weight array is mainly the sampling number in the first pass in both float mode and double mode. The memory consumption of weight array is generally 1/32 of the original version. Fig 10 Maximum memory consumption of the weight array for one parti 6.5 The Speedup of Top-Sum Parallel Solution To test the performance of our parallel top-sum algorithm, in this part, we compared our method with the original “sort and select” method. To show the performance, we record the average running time for different size of unsorted weight arrays. From Fig. 11, we can see that for the weight array with a small number of elements (N ¼ 44640; 62400; 104160; 479232), the running time of both methods is quite similar. However, for weight array with a larger number of elements, the running time of the naive “sort and select” method increases significantly. While the running time of the parallel time of our method didn’t, which means our method can acquire better performance when processing larger weight array. Besides, as our method can process multiple particles at the same time, the overall performance would be much better comparing to processing only one particle at one time. 6.6 The Speedup Ratio of Weight Calculation Parallel Algorithm In this section, we test the performance of our weight calculation parallel algorithm. In contrast to the texture memory, the performance of our method is not restricted by the total size of the re-projection. We compared our method with original GPU version of RELION. Fig. 12 shows the speedup ratio of our method compared with original RELION. We tested these two methods on dataset EMPIAR-10028. In TABLE 1 The Speedup Ratio with Different Nodes and Particle per Process Number <u>of Particles</u> Number <u>of Process</u> EMPIAR-10017 <u>Speedup Ratio</u> EMPIAR-10204 <u>Speedup Ratio</u> Fig. 12. Speedup ratio of the weight calculation parallel algorithm. Fig. 12, the horizontal axis indicates the iteration number and the vertical axis shows the speedup ratio. As the number of sampling points for orientations and traslations may vary, the size of weight array changes accordingly. In the first few iterations, the sampling points number is quite small. Around the fifteenth iteration, the number of sampling points increases significantly. The calculation amount of the function also raises, correspondingly. So that we can make better use of computing resources of GPUs at these iterations, which would lead to better speedup ratio. As shown in Fig. 12, in the first few iteratiosn, the performance of the two methods is similar. However, in iterations of larger datasets (around the fifteenth iteration), the speedup ratio increases and the advantage of reusing shared memory becomes apparent. 6.7 The General Speedup Ratio We summarize the total speedup ratio for each and record the results in Fig. 13. As our program is based on the MPI version of RELION, we don’t modify the master-slave MPI 8 3 1.17 1.15 8 5 1.19 1.15 8 7 1.18 1.16 32 3 1.21 1.18 32 5 1.22 1.19 32 7 1.21 1.19 parallel model. In this experiment, we compare the CUDA +MPI version with MPI version using five processes and one thread for each process. Different from the MPI version, each slave process utilize one GPU to calculate it. For the first sixteenth iterations, the general speedup ratio is around 25x. And between iteration 20 and 23, its speed up ratio can acquire about 75x speedup ratio. This speedup ratio is caused by the larger number of sampling points. To compare the performance of RELION’s parallel version and our method, we recorded the general speedup ratio using dataset EMPIAR-10017 and EMPIAR-10204. In Table 1, we show the speedup ratio with different number of processes (in the second column) and particles per job (in the first column) in column “EMPIAR-10204 Speedup Ratio” and “EMPIAR-10017 Speedup Ratio”. In general, we find that the speedup ratio is quite stable with the variation of number of processes. This is caused by the fact that we actually didn’t change the architecture of the MPI processes. The speedup ratio is mainly due to the optimization of the weight calculation and selection step. As for dataset EMPIAR-10017, it speedup ratio is about 1.19 and EMPIAR10017 owns about 1.17 speedup ratio. And, comparing the first three rows with the rest, we can find the speedup ratio are larger with more particles in each job. This is caused by the fact that more particles lead to more calculation amount to be processed in parallel. 7 CONCLUSION In this work, we optimized the 3D refine algorithm from three aspects: the reconstruction algorithm, memory usage, and time performance. 1. We optimized the 3D refine algorithm by extending the model parameter and updated it based on the idea of back-propagation. 2. To optimize the memory usage condition, we designed a memory-efficient and memory-stabilizing management system to guarantee the robustness of our program and the efficiency of GPU memory usage. Then, we developed a novel data structure for RELION to reduce the memory consumption. 3. To speed up the GPU parallel algorithm of RELION, we proposed two highly efficient parallel algorithms: an in-kernel top-sum parallel algorithm and a weight calculation parallel algorithm. Experiments showed that the optimized 3D refine algorithm can speed up the converge procedure and increase the final resolution and that the memory system can avoid memory fragments. We achieved a better ACKNOWLEDGMENTS This research was supported by the National Key Research and Development Program of China (2017YFA0504702); NSFC projects Grant Nos. U1611263, U1611261, 61232001, 61472397, 61502455, and 61672493; and the Special Program for Applied Research on Super Computation of the NSFCGuangdong Joint Fund (the second phase). REFERENCES [1] X.-c. Bai, G. McMullan, and S. H. Scheres, “How cryo-em is revolutionizing structural biology,” Trends Biochemical Sci., vol. 40, no. 1, pp. 49–57, 2015. [2] X. Li, N. Grigorieff, and Y. Cheng, “Gpu-enabled frealign: Accelerating single particle 3d reconstruction and refinement in fourier space on graphics processors,” J. Structural Biol., vol. 172, no. 3, pp. 407–412, 2010. [3] G. Tang, L. Peng, P. R. Baldwin, D. S. Mann, W. Jiang, I. Rees, and S. J. Ludtke, “Eman2: An extensible image processing suite for electron microscopy,” J. Structural Biol., vol. 157, no. 1, pp. 38–46, 2007. [4] S. H. Scheres, “A bayesian view on cryo-em structure determination,” J. Molecular Biol., vol. 415, no. 2, pp. 406–418, 2012. [5] S. H. Scheres, “Relion: Implementation of a bayesian approach to cryo-em structure determination,” J. Structural Biol., vol. 180, no. 3, pp. 519–530, 2012. [6] Y. Z. Tan, S. Aiyer, M. Mietzsch, J. A. Hull, R. McKenna, J. Grieger, R. J. Samulski, T. S. Baker, M. Agbandje-McKenna, and D. Lyumkis, “Sub-2 a� ewald curvature corrected structure of an aav2 capsid variant,” Nature Commun., vol. 9, 2018, Art. no. 3628. [7] R. Zhou, G. Yang, X. Guo, Q. Zhou, J. Lei, and Y. Shi, “Recognition of the amyloid precursor protein by human g-secretase,” Sci., vol. 363, 2019, Art. no. eaaw0930. [8] M. M. Shaik, H. Peng, J. Lu, S. Rits-Volloch, C. Xu, M. Liao, and B. Chen, “Structural basis of coreceptor recognition by hiv-1 envelope spike,” Nature, vol. 565, no. 7739, 2019, Art. no. 318. [9] W. Wong, X.-c. Bai, A. Brown, I. S. Fernandez, E. Hanssen, M. Condron, Y. H. Tan, J. Baum, and S. H. Scheres, “Cryo-em structure of the plasmodium falciparum 80s ribosome bound to the anti-protozoan drug emetine,” Elife, vol. 3, 2014, Art. no. e03080. [10] A. Amunts, A. Brown, X.-c. Bai, J. L. Ll�acer, T. Hussain, P. Emsley, F. Long, G. Murshudov, S. H. Scheres, and V. Ramakrishnan, “Structure of the yeast mitochondrial large ribosomal subunit,” Sci., vol. 343, no. 6178, pp. 1485–1489, 2014. [11] M. Liao, E. Cao, D. Julius, and Y. Cheng, “Structure of the trpv1 ion channel determined by electron cryo-microscopy,” Nature, vol. 504, no. 7478, pp. 107–112, 2013. [12] Y. Chen, F. Ren, X. Wan, X. Wang, and F. Zhang, An Improved Correlation Method Based on Rotation Invariant Feature for Automatic Particle Selection. New York, NY, USA: Springer International Publishing, 2014. [13] H. D. Tagare, A. Barthel, and F. J. Sigworth, “An adaptive expecta tion–maximization algorithm with gpu implementation for electron cryomicroscopy,” J. Structural Biol., vol. 171, no. 3, pp. 256–265, 2010. [14] F. J. Sigworth, P. C. Doerschuk, J. Carazo, and S. H. W. Scheres, “Maximum-likelihood methods in cryo-em. part i: theoretical basis and overview of existing approaches,” Methods Enzymology, vol. 482, 2010, Art. no. 263. [15] S. H. Scheres, “Single-particle processing in relion-1.3,” 2014. [Online]. Available: [ftp://ftp.mrc-lmb.cam.ac.uk/pub/scheres/](ftp://ftp.mrc-lmb.cam.ac.uk/pub/scheres/relion30_tutorial.pdf) [relion30_tutorial.pdf, Art. no. 5](ftp://ftp.mrc-lmb.cam.ac.uk/pub/scheres/relion30_tutorial.pdf) [16] Y. Chen, Z. Wang, J. Zhang, L. Li, X. Wan, F. Sun, and F. Zhang, “Accelerating electron tomography reconstruction algorithm icon with gpu,” Biophysics Rep., vol. 3, no. 1, pp. 36–42, 2017. [17] F. Zhang, J. Zhang, A. Lawrence, F. Ren, X. Wang, Z. Liu, and X. Wan, “Bsirt: A block-iterative sirt parallel algorithm using curvilinear projection model,” IEEE Trans Nanobioscience, vol. 14, no. 2, pp. 229–236, Mar. 2015. [18] Z. Wang, Y. Chen, J. Zhang, L. Li, X. Wan, Z. Liu, F. Sun, and F. Zhang, “Accelerating electron tomography reconstruction algorithm icon using the intel xeon phi coprocessor on tianhe-2 supercomputer,” in Proc. Int. Symp. Bioinf. Res. Appl., 2017, pp 258–269 [19] M. Hu, H. Yu, K. Gu, Z. Wang, H. Ruan, K. Wang, S. Ren, B. Li, L. Gan, S. Xu, et al., “A particle-filter framework for robust cryoem 3d reconstruction,” Nature Methods, vol. 15, no. 12, 2018, Art. no. 1083. [20] A. Punjani, J. L. Rubinstein, D. J. Fleet, and M. A. Brubaker, “cryosparc: Algorithms for rapid unsupervised cryo-em structure determination,” Nature Methods, vol. 14, no. 3, 2017, Art. no. 290. [21] J. J. Fernandez, “High performance computing in structural deter mination by electron cryomicroscopy,” J. Structural Biol., vol. 164, no. 1, pp. 1–6, 2008. [22] M. Schmeisser, B. C. Heisen, M. Luettich, B. Busche, F. Hauer, T. Koske, K.-H. Knauber, and H. Stark, “Parallel, distributed and gpu computing technologies in single-particle electron microscopy,” Acta Crystallographica Section D: Biological Crystallography, vol. 65, no. 7, pp. 659–671, 2009. [23] P. Cossio and G. Hummer, “Likelihood-based structural analysis of electron microscopy images,” Current Opinion Structural Biol., vol. 49, pp. 162–168, 2018. [24] D. Kimanius, B. O. Forsberg, S. H. Scheres, and E. Lindahl, “Accelerated cryo-em structure determination with parallelisation using gpus in relion-2,” eLife, vol. 5, 2016, Art. no. e18722. [25] F. J. Sigworth, P. C. Doerschuk, J. M. Carazo, and S. H. W. Scheres, “An introduction to maximum-likelihood methods in cryo-em,” Methods Enzymology, vol. 482, pp. 263–294, 2010. [26] N. C. Dvornek, F. J. Sigworth, and H. D. Tagare, “Subspaceem: A fast maximum-a-posteriori algorithm for cryo-em single particle reconstruction,” J. Struct. Biol., vol. 190, no. 2, pp. 200–214, 2015. [27] G. H. Shan, J. Liu, and X. B. Chi, “Local maximum absorp tion method for structure fitting in cryoem,” Key Eng. Mater., vol. 460–461, pp. 77–82, 2011. [28] S. H. W. Scheres, H. Gao, M. Valle, G. T. Herman, P. P. B. Eggermont, et al. “Disentangling conformational states of macromolecules in 3d-em through likelihood optimization,” Nature Methods, vol. 4, no. 1, pp. 27–29, Jan. 2007. [29] S. H. W. Scheres, M. Valle, P. Grob, E. Nogales, and J. M. Carazo, “Maximum likelihood refinement of electron microscopy data with normalization errors,” J. Struct. Biol., vol. 166, no. 2, pp. 234–240, 2009. [30] H. Su, W. Wen, X. Du, X. Lu, M. Liao, and D. Li, “Gerelion: Gpu-enhanced parallel implementation of single particle cryo-em [image processing,” bioRxiv, 2016, doi: 10.1101/075887.](http://dx.doi.org/10.1101/075887) [31] G. Das, “Top-k algorithms and applications,” in Database Systems for Advanced Applications. New York, NY, USA: Springer, 2009, pp. 789–792. [32] T. Alabi, J. D. Blanchard, B. Gordon, and R. Steinbach, “Fast k-selection algorithms for graphics processing units,” J. Exp. Algorithmics, vol. 17, pp. 4–2, 2012. [33] U. A. Markus Billeter, Ola Olsson, “Efficient stream compaction on wide simd many-core architectures,” vol. 2009, pp. 159–166, 2009. [34] J. Han and C. Moraga, “The influence of the sigmoid function parameters on the speed of backpropagation learning,” vol. 930, pp. 195–201, Jun. 1995. [35] N. Corporation, “Cuda in c best practices guide,” 2016. [Online]. [Available: https://docs.nvidia.com/cuda/pdf/CUDA_C_Best_](https://docs.nvidia.com/cuda/pdf/CUDA_C_Best_Practices_Guide.pdf) [Practices_Guide.pdf](https://docs.nvidia.com/cuda/pdf/CUDA_C_Best_Practices_Guide.pdf) [36] A. Iudin, P. K. Korir, J. Salavert-Torres, G. J. Kleywegt, and A. Patwardhan, “Empiar: A public archive for raw electron microscopy image data,” Nature Methods, vol. 13, no. 5, 2016, Art. no. 387. Jingrong Zhang received the BS degree in computer science from Yanshan University, China. She is working toward the PhD degree in the Institute of Computing Technology (ICT) and University of the Chinese Academy of Sciences (UCAS). Her current research interests include bioinformatics, biomedical image processing, and high-performance computing. Zihao Wang received the BS degree in software engineering from Xiamen University, China. He is working toward the PhD degree in the Institute of Computing Technology and Chinese Academy of Sciences, Beijing, China. His current research interests include bioinformatics, image processing and high-performance computing. Zhiyong Liu received the PhD degree in computer science from the Institute of Computing Technology (ICT), Chinese Academy of Sciences (CAS). He is the chair professor of ICT, CAS. His current research interests include highperformance algorithms and architecture, parallel processing and bioinformatics. Fa Zhang received the PhD degree in computer science from the Institute of Computing Technology (ICT), Chinese Academy of Sciences (CAS). He is a professor at ICT, CAS. His current research interests include bioinformatics, biomedical image processing, and high-performance computing. " For more information on this or any other computing topic, please visit our Digital Library at www.computer.org/csdl.

섹션 본문 70문단 · 44,728자

(제목 없음)

1In cryo-electron microscopy, RELION is a powerful tool for high-resolution reconstruction. Due to the complicated imaging procedure and the heterogeneity of particles, some of the selected particle images offer more disturbing information than others. However, in the current RELION, all these particle images are treated equally. In our work, we extend RELION's model with one scalar parameter to score the contribution of a particle depending on the error between the experimental particle and the corresponding reprojection. This scores down weight potentially poor particles, hence accelerating the convergence. Besides, by now there is no sophisticated memory management system for RELION, fragmentation on GPU will increase with iterations, eventually crashing the program. In our work, we designed the stack-based memory management system to guarantee the stability of RELION and to optimize the memory usage condition. Also, to reduce memory usage, we developed a customized compressed data structure for the memorydemanding weight array. In addition, to speed up the GPU version of RELION, we proposed two highly efficient parallel algorithms for weight calculation algorithm and weight selection algorithm. Experiments show that compared with RELION, the optimized threedimensional refine algorithm can speed up the converge procedure, the memory system can avoid memory fragmentation, and a better speed-up ratio can be obtained.

INTRODUCTION

2C RYO-ELECTRON microscopy (cryoEM) has become a mainstream technology for studying the architecture of biological macromolecules [1]. Single-particle analysis (SPA) is an important sub-discipline of cryoEM [2]. Here, "single particles" refers to structurally identical macromolecular complexes (like proteins and viruses). By acquiring thousands and even millions of two-dimensional (2D) projections of randomly oriented particles, SPA uses reconstruction software (like EMAN [3] and RELION [4]) to recover the threedimensional (3D) structure [2]. Among reconstruction software packages, RELION significantly increases the attainable resolution by adopting a Bayesian approach [4], [5]. Many structures have achieved near-atomic resolution using RELION [1], [6], [7], [8], [9], [10], [11].

3However, the imaging procedure in cryoEM is quite complicated, with abundant randomness. In general, the noise, artifacts of particles in the same micrograph may differ greatly. The general quality of even selected particles will differ [12]. Particles with severe artifacts and noise ("bad particles") may negatively influence the reconstruction procedure, a problem that has not received enough attention. In our work, inspired by the training procedure of neural networks, we extended the model parameters of RELION with one scalar parameter and updated it based on the idea of back-propagation. In our method, the scalar of "bad particles" will decrease with iterations, while that of "good particles" will increase. This modification speeds up the converge procedure and boosts the final resolution.

4The expectationmaximization (EM) algorithm is an iterative method to find the best hypothesis for the probability distribution of hidden parameters in statistical models. However, to estimate the probability distribution of the orientation parameters for each particle (in the expectation step), RELION needs to compare each particle image with every calculated projection [13], leading to a huge computation load [14] and large memory requirement. Taking the dataset used in the tutorial of RELION 2.0 [15] containing 6,496 b-galactosidase 128*128 particles as an example, the 3D refinement stage requires more than 2 GB memory per process and 40 CPU hours even though this dataset is quite small.

5In addition, RELION adopts a "modified version of the expectation-maximization algorithm". In its "Expectation step", RELION performs a two times finer procedure. At the end of the first pass, RELION selects a sub-domain of all orientations for each particle image. The selection rule reserves the orientations with high probability whose sum reaches 99.9 percent of the sum total of the probability value of all orientations. One naive solution for this selection step is to first sort all probability values and then sum them sequentially from largest to smaller until their sum reaches 99.9 percent of the sum total. It is obvious that this method is a sequential algorithm and has high data dependency. The processing times of sorting and summation will increase dramatically as the number of orientations increases. To reduce the time cost of this step, we drew inspiration from the parallel top-k selection and stream compaction algorithms and designed an efficient parallel top selection algorithm.

6To reduce the running time, many cryoEM software programs [16], [17], [18], [19], [20] have been parallelized on GPUs. The reviews [21], [22], [23] have introduced the advances of the parallelizaiton softwares. For example, CryoSparc utilizes the GPU card to speed up the reconstruction and 3D classification. And it A GPU parallel version of RELION has also been proposed [24]. Also, the software THUNDER [19] accelerates the image processing and calculation of re-projections with GPUs. However, most parallel software in cryoEM overlooks memory-related operational stability and robustness, which heavily relies on GPU hardware characteristics and the memory accessing pattern. For memory-intensive applications like RELION, memoryrelated code will dramatically influence its stability, robustness and performance. One important aspect is memory fragments. Frequently randomly allocating and de-allocating memory on the GPU may divide the successive memory into several pieces of discontinuous memory. We call those small pieces of memory "fragments". When the program tries to allocate a large piece of memory, even though the total available memory is sufficient, the allocation can still fall and report an "out of memory" error because of the fragments. However, no sophisticated memory management system can prevent the fragmentation problem. In addition, no stable memory management strategy has been introduced to RELION. For example, when processing the dataset EMPIAR-10028 with a particle size of 360*360 on GPU NVI-DIA K20c, an "out of memory" error occurs during later iterations. To improve the stability and robustness of RELION, we developed a stabilizing memory management system, especially for large datasets. In this system, we utilize the characteristics of iterative methods to avoid fragmentation. This memory manage system can also be applied to other iterative methods.

7Moreover, even with a fragment-free memory management system, when the total memory consumption of RELION exceeds the GPU memory, an "out of memory" error will still be reported. If we can reduce the memory consumption, this issue would be eased fundamentally. As we mentioned, the weight array is the data structure that demands the most memory. To reduce its memory consumption, we analyzed the data structure of the weight array and determined that we can reduce its memory requirements by carefully redesigning its structure.

8In summary, in this work, to speed up the convergence procedure and boost the final resolution, we propose an extended 3D refine algorithm by extending the model parameters with one scalar parameter and updating it based on the idea of back-propagation. In addition, we designed a memory-efficient and memory-stabilizing management system to guarantee the robustness of our program and the efficiency of GPU memory usage. Then, to reduce the memory usage, we developed a novel data structure. Finally, we developed a weight calculation parallel algorithm and a top selection algorithm to speed up the calculation.

9Our paper is organized as follows: in Section 2, we introduce related work; in Section 3, we show the extended 3D refine algorithm; in Section 4, we introduce our stabilizing management system and memory-efficient data structure; in Section 5, we present the weight calculation parallel algorithm and the top selection algorithm. The results of the experiments are presented in Section 6. We then conclude the paper.

RELATED WORK

10In this section, we introduce the related work from three aspects: statistical methods used in cryoEM, the basic workflow of the refine algorithm of RELION and efforts to accelerate it, and parallel top-k selection algorithms.

Statistical Methods

11As mentioned, the structure determination method used in RELION is a Bayesian-based method and is therefore a statistical method. In general, the method of RELION is less sensitive to the starting model and permits recovery of the underlying signal from noisy data compared to traditional cross-correlation-based methods [25], [26], [27]. In general, statistical methods try to find the best hypothesis for the distribution of parameters in a statistical model given the observations. There have been numerous contributions beyond RELION applying this method based on different kinds of image formation models in cryoEM [25], [28], [29].

12For example, in a previous work [28], the data model was X i ¼ P if A ki þ sG i (where A ki indicates the underlying image, P if is the transformation with the ith image, s is the standard deviation coefficient, and G i indicates the independent noise). The model aims to find the most likely set of parameters (Q) to construct a model describing structural data through optimization of the following log-likelihood function:

13The reconstruction algorithm in RELION is also a typical statistical method. It is solved by a modified version of the expectation maximization algorithm based on the work of [13]. It formulates the image formation model in Fourier space as follows:

14where X i is the projection image obtained by experiments, CTFi is its contrast transfer function for the ith image, and V is the underlying structure in the dataset. The operation P L l¼1 P f jl V l extracts a slice from V , which is equivalent to the real-space projection. In RELION, the parameter set Q is V l ; s; t, where s 2 and t 2 are the variance of the noise and the signal component.

15In this image formation model, the orientation parameters for projection images are unknown, and we use G ðnÞ if to indicate the posterior probability of orientation assignment f for the ith image in the nth iteration (i 2 ½0; I). Here, the orientations f 2 ½0; F (F ¼ ðrRot; rTilt; rPsi; tX; tY Þ) comprise 3 rotation (rRot; rTilt; rPsi) and 2 translation (tX; tY ) parameters.

Efforts to Accelerate RELION

16GeRelion [30] is a parallel GPU version 1.4. To port the program to the GPU, GeRelion proposes a four-level schedule model. In addition, the weight array is assumed to be sparse and stored in compressed sparse row (CSR) matrix mode: one continuous vector stores the value, and an aux vector records the indexes of the weight array. Because of the usage of the aux vector, the memory consumption of this structure may exceed that of the original structure when the weight array is not sparse. Based on this consideration, we developed a new data structure that can reduce its memory cost.

17RELION [24] also proposed a parallel GPU version for its expectation-maximization algorithm. In contrast to its CPU version, the parallel version runs in single precision mode by default to reduce memory consumption. In addition, during the expectation step, accessing the re-projection images consumes a lot of time. RELION stores re-projection images in texture memory to make use of its on-chip cache, which can reduce the memory accessing time. However, this strategy is not always effective. As the size of the re-projection image increases, it may exceed the size of the texture memory cache. In this case, there would be frequent data swapping between the cache and texture memory. Consequently, the performance of the cache will be heavily diminished. Based on this observation, we designed a different data accessing strategy to speed up the memory accessing.

18Both GeRelion [30] and RELION [24] provided detailed analyses of the performance of each major step. According to their analyses, the expectation step is the most time-consuming step. The most memory-demanding data structure is the weight array G.

Parallel Top-k Selection Algorithms

19In our work, we developed a parallel top selection algorithm for RELION based on the idea of parallel top-k selection algorithm. Here we introduce its current research condition. Top-k problem requests to find the top K elements from an un-ordered list [31]. One general kind of algorithm is selecting by Sorting. The basic idea of these algorithms is to sort the entire list and then query the top K elements. Although the top-k selection problem is a different from the top selection problem in RELION, the basic idea of current implementation of RELION is the same.

20Another kind of algorithm is to select based on partitions. Many parallel selection algorithms are based on partitions.

21One advantage of such algorithms is that they can avoid the sorting operation. The basic steps of "Bucket Select" are as follows [32]. First, "Bucket Select" determines the size of buckets, assigns each element to a bucket and then identifies the bucket containing the kth order statistic. And it projects the entries in that bucket onto a new set of buckets. After a number of iterations, when the bucket width equals 1, we find the kth element. Fig. 1 shows an example of "Bucket Select". It uses the linear projection function Formula (2.3) to define the boundary of buckets.

22"Bucket Select" owns two phases. In Phase I, it reduces workload by creating a new vector containing the candidates. In Phase II, the workload is reduced by redefining the max and min.

23"Bucket Select" can avoid the sorting operation. However, first, its efficiency reduces with the bucket width. Then this method can only find the kth element. There is still one step away from getting the top K elements.

24So in our method, we first added an small dataset sorting to speedup the boundary converge. Then we implemented one more kernel to get the qualified data out based on the work [33].

EXTEND THE REFINE ALGORITHM TO ESTIMATE THE RELIABILITY OF PARTICLE IMAGE

25In general, we use statistical method to find the most likely perameter set Q for the model constructed with the observation data and prior information. In work [28], they proposed to extent the model parameter set Q with a multiplicative and an addictive factor for the signal in each experimental image to normalize the noise. In RELION 2.0, the variance of signal and noise has been involved in its statistical model. In Relion 3.0, per-particle CTF correcition and beam-tilt correction is introduced. These parameters can provide more detailed estimation for each particle so as to improve the reconstruction resolution. However, for each particle, the data can be used is so limited to achieve accurate statistical estimation. Besides, in the beginning iterations, the estimation about many particles' orientaions may be far from accurate. So the corresponding estimation about the signal, noise and CTF parameters are inaccurate. These parameters may be very heplful for high resolution refinement. But, when thay are inaccurate, they will slow down the convergence. Seeing these shortages, we try to estimate each particle in a more general way. Due to the heterogeneity of particle, random noise and some other influence factors, the quality of particle images differs a lot. Some "bad" particles may introduce interference to the reconstruction result. If we can use a more generalized scaler parameter to estimate the realibility of each particle image and its related parameters, it can be used to restrain the influence from "bad particles" and enhance the contribution from "good" ones. And this scaler parameter would help accelarate the convergence of the expectation-maximization algorthm, especially for the begining iterations. We desire to design this scaler parameter to reflect this realibilty of the particle images and their related parameters based on the understanding of the iteration procedure of expectation-maximazation algorithm. As we know, during the iterations, the estimation of relating parameter should be gradually getting close to the actual condition with the increase of the resolution. And the re-projections generated from the reconstruction result and these estimated parameters should be becomming more and more similar to the actual particle images. While as for the particles with low realibilty, this phenomenon doesn't hold. Because these particle didn't contribute positively to the reconstruction result and gradually the reconstruction may become more and more different to these particles. And these will shown in the error between re-projection and the particle image.

26So based on this obervation, we desiged the concrete formula for this scalar parameter. For each particle, we store its best orientation and its corresponding error value jX i À CTF i P L l¼1 P f 0 V j 2 and compare it with the re-projection. After one iteration, the error value of one particle will change. And if the error value gets smaller, it indicates that this particle made positive contributions and vice versa. By now we get the Formula (3.1):

27:

28The second and third formulas are the same as RELION's formula written in work [4]. But, the first formula introduced the scalar parameter s i to estimate the realibility of particle images. And the forth formula describes the concrete formula of this scalar parameter, within and err ðnÞ i is calculated by the following formula:

29where diff n i indicates the difference between the reprojection and particle image in the nth iteration. When

30, s i would equal to 1, which means the same as the original version. And diff n i > diff nþ1 i indicates the particle has made positive contribution. The corresponding scalar parameter s i is larger than 1. As scalar parameter s i is a relaxation factor for each particle, to normalize the value of s i , we used sigmoid function [34]. In our function, the range of s i is [0.75, 1.25].

31The general work flow of the modified algorithm is shown in Fig. 2. In the expectation step (shown in the upper left corner of Fig. 2), computer-generated projections (labeled as "re-projection") of the structure are compared with the experimental images (label as "real particle image") to acquire the probability distribution over orientations of the images.

32In the maximization step, the 3D structure is updated combing the prior information (lower left corner of Fig. 2). And according to the updated 3D structure V , we can update the variance of signal t. Then, comparing the new reprojections and particle images we can update the variane of noise s ij . Also, comparing real-images with its re-porjection at best orientations of iteration n and n þ 1, we can update the scaler parameter s i .

MEMORY OPTIMIZATION STRATEGIES

33To optimize the memory usage of this program, we first designed a new data structure to reduce the memory consumption of the weight array. Then, to ensure the stability of RELION, we proposed a stack-based memory scheduling algorithm that is in charge of the memory operations between the CPU and GPU.

Customized Compressed Data Structure

34As we mentioned previously, as the number of sampling points increases, the memory consumption of the weight array grows dramatically. Consequently, reducing the memory consumption of the weight array is of great importance. As RELION adopts a modified expectation-maximization algorithm to iteratively optimize the results, the weight array would be used twice per iteration. In the first pass of one iteration, RELION calculates the difference between each particle and each sampled re-projection, which will fill the weight array densely. However, in the second pass of one iteration, only part of the sampling points will be considered, making the weight array a relatively sparse array.

35One simple method to reduce the memory consumption of the weight array is to use the classical compressed data structure Compressed Sparse Row. Instead of storing every each one of the elements in the weight array, CSR stores only the non-zero elements and their corresponding subscripts in each row. In general, when the number of nonzero elements (n) is less than half of the total number of elements (N), this array is considered sparse (n < 0:5 Ã N). However, as for RELION, the weight array cannot always meet this criterion. For example, in the first several iterations, due to the low resolution of the estimated parameters, the weight array tends to be denser than later iterations. Under this condition, the memory consumption of the CSR structure may exceed the original memory consumption, which would damage the performance.

36To cope with this issue, we designed a customized compressed data structure. The sparse weight array is generated in the second pass, during which only sampling points with high probability are considered with fine sampling steps, and one sampling point would generate 32 fine sampling points in the second pass. The weight of these 32 sampling points is stored successively. Thus, in contrast to the general sparse arrays, as shown in the top half of Fig. 3, the non-zero elements of the sparse weight array are partially continuous. Making use of this trait, we can reduce the memory cost for the subscript. In the bottom half of Fig. 3, instead of recording the column subscript of each non-zero element, we only store the index of the first non-zero elements in the index array.

37In Fig. 3, we list the details of this data structure. This data structure consists of three parts. The first part is the "Value Array", which stores all of the non-zero elements of the weight array. Then, the "Indices Array" stores the subscript of the first subscript of the 32 consecutive non-zero elements. Finally, we use "Row Point Array" to indicate the start position of each particle's non-zero elements in "Value Array".

38For each particle, we can compare the compression ratio between the CSR and our structure. Let the total number of elements be N and the non-zero elements in the matrix be n. For each particle, size original, size compressed and size new refer to the memory cost in bytes for the original version of RELION, CSR and our method. Formula (4.1) shows their concrete memory cost. (Here size value and size subscript indicate the number of bytes used for one non-zero element and the subscript.) Based on these formula, we can conclude that when n > 0:67N, the memory consumption of CSR will exceed the original version. However, the memory consumption of our method will not exceed the original version unless n > 0:98N.

Stack-Based Stabilizing Management System

39RELION adopts a modified version of the expectationmaximization method to perform reconstruction. During this procedure, numerous parameters (such as the particle images and the current resolution) need to be taken into account. These parameters become different variables used on the CPU and GPU. In addition to the large number of variables, the memory requirements of some of these variables vary during the iterations according to the sampling rate and resolution, among other factors. Consequently, the memory management system needs to handle not only the large number of variables but also the variety of memory requirements of these variables.

40However, there is no fully automatic memory management system for the GPU. The native memory allocation on the GPU is generally random. Repeated allocation and deallocation will introduce memory fragmentation, which will split the memory space into many small pieces. In the later stage of the iterations, these fragments will introduce memory allocation failure and cause the program to crash. To manage these memory operations, RELION uses a linked list to manage its GPU global memory. In the linked list, each node indicates one piece of the consecutive memory, and the adjacent memory will be merged into one node. Thus, the linked list can reduce fragments to a degree. However, this method cannot prevent the generation of fragments. When available memory is separated by used memories, the issue of fragmentation still exists.

41Importantly, the GPU memory allocation operation and the kernel running on the GPU are asynchronous. This property leaves us more freedom to manage the GPU memory. One important property of the expectation-maximization algorithm used by RELION is that it is an iterative method. In contrast to direct methods, iterative methods update the estimated parameters based on the estimation generated from previous iterations. Consequently, the algorithm is processed in one round after another. Many of the memory operations within the iteration are predictable and repeatable. For example, the allocation of projection images is only needed at the beginning of each iteration, and de-allocation is performed at the end of each iteration.

42In addition, within one iteration, hundreds of thousands of particles are processed, but the basic processing procedure of each particle is similar. For example, each of the particle images needs to be transformed from real space to Fourier space first. Therefore, at the beginning of processing one particle, we need to allocate the memories for the particles in Fourier space and free them at the end of processing one particle.

43Based on the introduction above, we can conclude that the memory operation can be managed in groups based on their life cycle: global scope, iteration scope, and per particle scope. One example is shown in Fig. 4. At the beginning, variables needed by the whole program will be allocated. Then, at the beginning of each iteration, variables in the iteration scope will be allocated. Variables such as the particle images in Fourier space will then be allocated for each particle. Finally, at the end of their life cycle, the particles will be freed.

44Another consideration is that, under some conditions, the memory requirement exceeds the total available memory on the GPU. In some cases, we can reduce the memory requirement by reducing the number of particles processed at one time. In our program, we also consider the extreme condition. Within the processing of one particle, the particle images need to be compared with many re-projection images from different orientations. When the size of one re-projection grows, the total memory requirement grows rapidly. Therefore, we add one more group for the orientations. When the memory of the GPU is limited, we can process all the re-projections in several batches, and the corresponding variables will be allocated and de-allocated at the beginning and end of the batch. This group is shown in Fig. 4. Based on these rules, we can build a stackbased memory management system thoroughly to avoid memory fragments. This memory management system can also be used in other iterative methods.

PARALLEL OPTIMIZATION METHODS

45In this section, we try to speed up the GPU parallel algorithm of RELION by proposing two highly efficient parallel algorithms: the in-kernel top-sum parallel algorithm and weight calculation parallel algorithm.

In-kernel Top-Sum Selection Parallel Algorithm

46As introduced in Section 2.3, in the field of computing technology, there is a traditional problem called "top-k", which involves selecting the top K (number K is constant) large or small elements from an unordered list. Considerable efforts have focused on the classic "top-k" problem in parallel.

47In RELION, one similar but more complicated problem occurs. Because RELION implements a modified version of the adaptive expectation maximization algorithm, it first adopts a coarse grid to estimate the contribution of orientations. Then, a sub-domain of orientations f whose total calculated probabilities exceed a fraction (99.9 percent) of the sum of all probabilities is retained. At the end of the first pass, we need to find the stopping point at which the sum of the values larger than the stopping point barely exceeds 99.9 percent of the total probability. Instead of selecting the top k largest elements, we need to select the largest elements whose sum reaches 99.9 percent of the sum total. We define this problem as "Top-sum" selection. To the best of our knowledge, no effective parallel solution has been achieved. To acquire the correct stopping point, the sequential version of RELION first allocates a block of memory to store the weight array of one particle and then eliminates zero elements from the array. RELION then sorts the array. Finally, the elements are summed in descending order one by one until the sum exceeds 99.9 percent of the sum of the total probability. The basic idea of the parallel version is similar. The data are sorted, and the elements are then selected sequentially. This approach has two weaknesses. First, this method requires a lot of memory to store a complete copy of the weight array on the GPU. As we discussed above, the size of the weight array may increase significantly in some iterations, while the memory of the GPU is quite limited. Second, the sorting operation is quite timeconsuming and unnecessary. Sorting on the GPU costs many synchronization and write operations, which is very time consuming. We only need to know the stopping point, so sorting is unnecessary.

Algorithm 1. In-kernel Top-Sum Algorithm

48Based on the consideration above, we propose our own parallel method based on the following considerations: 1. We should not sort all of the data. 2. To obtain the partial 99.9 percent of the total probability, the data must be partially sequential. 3. During the process of summation, the information about partial sums will be lost. With these considerations, we propose a parallel top-sum algorithm. In general, this algorithm has four basic steps (1. Bucket select, 2. Locate bucket, 3. Select data, 4. Use bucket sort to obtain stop point). We show the basic work-flow of our method in Fig. 5. We summarize our in-kernel top-sum algorithm with pseudo code in Algorithm 1. In Algorithm 1, Lines 5 to 10 shows Step 1, and Lines 11 to 13 show Step 2. Then Step 4 is shown in line 18 to 19. We also use Algorithm 2 to show the details of Step 3. First, in the "Bucket select" step, we choose some values as the pivots ðP 1 ; P 2 ; P 3 :::P m þ 1Þ to split the data into different buckets (B 1 ; B 2 :::B m ). For example, if w i is larger than pivot P 3 and smaller than pivot P 4 , w i belongs to bucket B 3 . In this method, we select these pivots uniformly P j ¼ jÃðmaxðw i ÞÀminðw i ÞÞ m þ minðw i Þ. In practice, we use a thread to process w i in parallel. As shown in the left part of Fig. 5. First, we locate the bucket that w i belongs to. Then, we record the sum (S½m) and number (C½m) of each bucket. Finally, we convert the sum of each bucket to the prefix sum (Ps½m).

Algorithm 2. Select Candidates within One Bucket

49With the prefix sum array (Ps½m), we can determine which bucket (B½t) contains the stopping point. If the number of elements in the corresponding bucket is less than the total number of threads tNum, we can enter step 3. Otherwise, we will repeat step 1 and step 2.

50In step 3, we select the candidates (w i s) in bucket B½t. In contrast to the traditional parallel algorithm, because the number of candidates is less than tNum, the shared memory array S can store all candidates. We use a hash algorithm to load these candidates to shared memory. In step 4, we sort these candidates using a Bitonic sort algorithm so that we can locate the precise stopping point.

Weight Calculation Parallel Algorithm

51As we mentioned, RELION compares each particle image with the re-projection images and then estimates the particle orientations based on the differences. One important function used to compare the particle image with re-projection images is "getAllSquaredDifferencesðÞ". In this function, we can calculate the squared difference of every component of the particle image and re-projection image and generate the weight value to indicate the difference. Fig. 6a illustrates this comparison, where w if indicate that the ith particle image is compared with the re-projection at orientation f. We can use Equation (5.1) to describe this procedure:

52ððReðp Fk Þ À ReðX ik ÞÞ 2 þ ðImðp Fk Þ À ImðX ik ÞÞ 2 Þ;

53where X ik is the kth component for the ith particle image and p fk is the kth component of the re-projection at orientation f. One detail to explain is that the calculation of the first iteration differs from Equation (5.1) by calculating the difference with normalized cross-correlation. However, both crosscorrelations and squared differences contain two parts: comparing each component and reducing to one weight result.

54This procedure is shown from one particle's perspective. As illustrated in Fig. 6b, we need to calculate the weight for each re-projection. In this whole procedure, as shown in Fig. 6c, each re-projection needs to be compared with each particle image.

55To calculate one weight value w if in parallel on the GPU, the most straightforward method is loading one whole particle image and one re-projection in one thread. If we use size image to indicate the size of the image, calculating the weight value requires size image à size image times of global memory accessing, which makes the performance of this algorithm rely heavily on the memory accessing speed. As for the GPU, global memory accessing is 100 times slower than shared memory [35]. Thus, if we can replace this global memory accessing with shared memory, the running time can be greatly reduced.

56However, one shortage of shared memory is that its size is quite limited. Based on these observations, we designed a new weight calculation parallel algorithm. We use Fig. 7 to show the details of this method. First, we can load only a part of several particle and re-projection images. In the upper left corner of Fig. 7, the white part shows the part loaded from global memory to shared memory. Using the data marked in white color, we can only calculate part of w if . However, one benefit is that we can calculate many different w if s. For the example shown in Fig. 7, the first part of weights value S 1 ¼ fw 11À1 ; w 12À1 :::w 21À1 ; w 22À1 :::w 31À1 ; w 32À1 :::w 44À1 g. After loading the second (in light gray color) part of the data to shared memory, we can acquire the second part S 2 ¼ fw 11À2 :::w 44À2 g. Similarly, the third (in dark gray color) part is loaded to shared memory to calculate S 3 ¼ fw 11À3 :::w 44À3 g. After that, we can acquire the complete weight value (w 11 ¼ w 11À1 þ w 11À2 þ w 11À3 ), and at this point, several weight values w 11 ; w 12 :::w 44 can be acquired.

57The most important advantage of this method is that the time spent accessing global memory is reduced. Take the example shown in Fig. 7 . Compared with the original method, it reduced the time spent accessing global memory by size image à ðsize image À 2Þ. As shared memory is available for all threads of one block, we can reuse the data and reduce the data accessing time. Taking a 32*32 block as an example, the global memory accessing time can be reduced by 32 times. For the step "Get Squared Differences (GSD)", the majority of the time is spent in the expectation step, and reducing global memory accessing can efficiently reduce the processing time of this step.

Environment and Test Dataset

58In our experiments, we adopted three different datasets from the EMPIAR [36]. The first dataset is 6,496 b-galactosidase (EMPIAR-10017 [15]). The size of each particle is 128 Ã 128. Th second dataset is "Plasmodium falciparum 80S ribosome bound to the anti-protozoan drug emetine", which contains 100,000 particles with particle size 360 Ã 360 (EMPIAR-10028 [9], [1]). The third dataset is also b-galactosidase (EMPIAR-10204) with 5000 particle with size 100 Ã 100. The experiments are carried out on a machine running the Ubuntu operating system 14.04, 64-bit with an Intel(R) Xeon(R) CPU E5-2680 v3 at 2.50 GHz. The GPU card is NVIDIA GeForce GTX Titan X, with 3072 stream processers and 12288 MB global memory.

Performance of the Extended Refine Algorithm of RELION

59In this section, we compared our algorithm with the original version of RELION. To illustrate the performance, we recorded the resolution after each iteration for the three datasets mentioned above. The corresponding results are shown in Fig. 8. From these three images, in general, we can find that our method converge faster than the original version during the iterations. Especially in the middle iterations, our method can reach better resolution in less iterations. Take the dataset EMPIAR-10204 as example, in the Fig. 8c, we can find that from the seventh iteration, our method starts to get better resolution compared with the original verison. In the middle iterations, these advantages become more and more obvious. This is caused by the scalar parameter we introduced. During the first iterations, the projection error of all the particles are quite similar, the corresponding scalar parameter value is also quite close to each other. However, the estimation grows more and more accurate with the iterations. The difference between particles become evident. Especially, in the middle iterations, the value of scalar parameters for different particles differs with each other. And this is the stage where these scalar parameters make more significant contribution to the refinement procedure.

60And we can see around the fifteenth iterations, the differences between the resolution of our method and the original method becomes quite small. The resolution generally converge to the final resolution. As for the final resolution, the dataset EMPIAR-10017 can acquire 7.25 A and 7.69 A for our method and the original version. For the Plasmodium falciparum 80S ribosome, the final resolution is 3.25 A (our method) and 3.45 A (the original version). And for dataset EMPIAR-10204, its final resolution is 3.80 A (our method) and 3.93 A (the original version), respectively. Based on the final resolution, we can see that our method can increase the resolution in a certain degree.

Performance of Stack-Based Memory Management System

61We proposed the stack-based memory management system for RELION, here we use the dataset EMPIAR-10028 to show the running procedure of the memory management system. Different from the original version of RELION who allocates the GPU memory randomly, our system allocates the memories without fragment. So we can use the top pointer of the "stack" to indicate the used GPU global memory. The memory before the "top pointer" is used memory. And memory with the larger address is continuous free memory. In Fig. 9, the horizontal axis indicates each allocation operation during the running of RELION. And the vertical axis indicates the memory address. As we can see, the memory consumption of RELION shows the general cyclical pattern due to its iterative method. Also, our method can help group these memory usages with our stack-based memory management system.

Memory Consumption Optimization

62We modified the data structure of weight array, which saves a substantial amount of memory. To show the performance of our customized data strucuture, we use the data set EMPIAR-10017 as benchmark. In Fig. 10, we record the max memory consumption of the weight array of one particle of one iterations. As shown in Fig. 10, the most memorydemanding array appears in the middle of the iterations. In these iterations, our structure significantly reduces the memory requirements. The upper bound of the size of weight array is mainly the sampling number in the first pass in both float mode and double mode. The memory consumption of weight array is generally 1/32 of the original version.

The Speedup of Top-Sum Parallel Solution

63To test the performance of our parallel top-sum algorithm, in this part, we compared our method with the original "sort and select" method. To show the performance, we record the average running time for different size of unsorted weight arrays. From Fig. 11, we can see that for the weight array with a small number of elements (N ¼ 44640; 62400; 104160; 479232), the running time of both methods is quite similar. However, for weight array with a larger number of elements, the running time of the naive "sort and select" method increases significantly. While the running time of the parallel time of our method didn't, which means our method can acquire better performance when processing larger weight array. Besides, as our method can process multiple particles at the same time, the overall performance would be much better comparing to processing only one particle at one time.

The Speedup Ratio of Weight Calculation Parallel Algorithm

64In this section, we test the performance of our weight calculation parallel algorithm. In contrast to the texture memory, the performance of our method is not restricted by the total size of the re-projection. We compared our method with original GPU version of RELION. Fig. 12 shows the speedup ratio of our method compared with original RELION. We tested these two methods on dataset EMPIAR-10028. In Fig. 9. The top pointer of used memory. Fig. 10. Maximum memory consumption of the weight array for one particle for b-galactosidase in double mode. Fig. 11. The average processing time of different weight arrays. As the number of sampling points for orientations and traslations may vary, the size of weight array changes accordingly. In the first few iterations, the sampling points number is quite small. Around the fifteenth iteration, the number of sampling points increases significantly. The calculation amount of the function also raises, correspondingly. So that we can make better use of computing resources of GPUs at these iterations, which would lead to better speedup ratio. As shown in Fig. 12, in the first few iteratiosn, the performance of the two methods is similar. However, in iterations of larger datasets (around the fifteenth iteration), the speedup ratio increases and the advantage of reusing shared memory becomes apparent.

The General Speedup Ratio

65We summarize the total speedup ratio for each and record the results in Fig. 13. As our program is based on the MPI version of RELION, we don't modify the master-slave MPI parallel model. In this experiment, we compare the CUDA +MPI version with MPI version using five processes and one thread for each process. Different from the MPI version, each slave process utilize one GPU to calculate it.

66For the first sixteenth iterations, the general speedup ratio is around 25x. And between iteration 20 and 23, its speed up ratio can acquire about 75x speedup ratio. This speedup ratio is caused by the larger number of sampling points.

67To compare the performance of RELION's parallel version and our method, we recorded the general speedup ratio using dataset EMPIAR-10017 and EMPIAR-10204. In Table 1, we show the speedup ratio with different number of processes (in the second column) and particles per job (in the first column) in column "EMPIAR-10204 Speedup Ratio" and "EMPIAR-10017 Speedup Ratio". In general, we find that the speedup ratio is quite stable with the variation of number of processes. This is caused by the fact that we actually didn't change the architecture of the MPI processes. The speedup ratio is mainly due to the optimization of the weight calculation and selection step. As for dataset EMPIAR-10017, it speedup ratio is about 1.19 and EMPIAR-10017 owns about 1.17 speedup ratio. And, comparing the first three rows with the rest, we can find the speedup ratio are larger with more particles in each job. This is caused by the fact that more particles lead to more calculation amount to be processed in parallel.

CONCLUSION

68In this work, we optimized the 3D refine algorithm from three aspects: the reconstruction algorithm, memory usage, and time performance. 1. We optimized the 3D refine algorithm by extending the model parameter and updated it based on the idea of back-propagation. 2. To optimize the memory usage condition, we designed a memory-efficient and memory-stabilizing management system to guarantee the robustness of our program and the efficiency of GPU memory usage. Then, we developed a novel data structure for RELION to reduce the memory consumption. 3. To speed up the GPU parallel algorithm of RELION, we proposed two highly efficient parallel algorithms: an in-kernel top-sum parallel algorithm and a weight calculation parallel algorithm. Experiments showed that the optimized 3D refine algorithm can speed up the converge procedure and increase the final resolution and that the memory system can avoid memory fragments. We achieved a better speedup ratio compared to RELION. Zhiyong Liu received the PhD degree in computer science from the Institute of Computing Technology (ICT), Chinese Academy of Sciences (CAS). He is the chair professor of ICT, CAS. His current research interests include highperformance algorithms and architecture, parallel processing and bioinformatics.

69Fa Zhang received the PhD degree in computer science from the Institute of Computing Technology (ICT), Chinese Academy of Sciences (CAS). He is a professor at ICT, CAS. His current research interests include bioinformatics, biomedical image processing, and high-performance computing.

70" For more information on this or any other computing topic, please visit our Digital Library at www.computer.org/csdl.

참고문헌 33건

  1. An Introduction to Maximum-Likelihood Methods in Cryo-EM Methods in enzymology on CD-ROM/Methods in enzymology · Academic Press · 2010 10.1016/s0076-6879(10)82011-7
  2. The influence of the sigmoid function parameters on the speed of backpropagation learning Lecture notes in computer science · Springer Science+Business Media · 1995 10.1007/3-540-59497-3_175
  3. Top-k Algorithms and Applications Lecture notes in computer science · Springer Science+Business Media · 2009 10.1007/978-3-642-00887-0_74
  4. An Improved Correlation Method Based on Rotation Invariant Feature for Automatic Particle Selection Lecture notes in computer science · Springer Science+Business Media · 2014 10.1007/978-3-319-08171-7_11
  5. GPU-enabled FREALIGN: Accelerating single particle 3D reconstruction and refinement in Fourier space on graphics processors Journal of Structural Biology · Elsevier BV · 2010 10.1016/j.jsb.2010.06.010
  6. Maximum likelihood refinement of electron microscopy data with normalization errors Journal of Structural Biology · Elsevier BV · 2009 10.1016/j.jsb.2009.02.007
  7. A Bayesian View on Cryo-EM Structure Determination Journal of Molecular Biology · Elsevier BV · 2011 10.1016/j.jmb.2011.11.010
  8. Local Maximum Absorption Method for Structure Fitting in CryoEM Key engineering materials · Trans Tech Publications · 2011 10.4028/www.scientific.net/kem.460-461.77
  9. High performance computing in structural determination by electron cryomicroscopy Journal of Structural Biology · Elsevier BV · 2008 10.1016/j.jsb.2008.07.005
  10. Fast &lt;it&gt;k&lt;/it&gt;-selection algorithms for graphics processing units ACM Journal of Experimental Algorithmics · Association for Computing Machinery · 2012 10.1145/2133803.2345676
  11. Disentangling conformational states of macromolecules in 3D-EM through likelihood optimization Nature Methods · Nature Portfolio · 2006 10.1038/nmeth992
  12. How cryo-EM is revolutionizing structural biology Trends in Biochemical Sciences · Elsevier BV · 2014 10.1016/j.tibs.2014.10.005
  13. EMAN2: An extensible image processing suite for electron microscopy Journal of Structural Biology · Elsevier BV · 2006 10.1016/j.jsb.2006.05.009
  14. RELION: Implementation of a Bayesian approach to cryo-EM structure determination Journal of Structural Biology · Elsevier BV · 2012 10.1016/j.jsb.2012.09.006
  15. BSIRT: A Block-Iterative SIRT Parallel Algorithm Using Curvilinear Projection Model IEEE Transactions on NanoBioscience · Institute of Electrical and Electronics Engineers · 2015 10.1109/tnb.2015.2393377
  16. Cryo-EM structure of the Plasmodium falciparum 80S ribosome bound to the anti-protozoan drug emetine eLife · eLife Sciences Publications Ltd · 2014 10.7554/elife.03080
  17. Structure of the Yeast Mitochondrial Large Ribosomal Subunit Science · American Association for the Advancement of Science · 2014 10.1126/science.1249410
  18. Parallel, distributed and GPU computing technologies in single-particle electron microscopy Acta Crystallographica Section D Biological Crystallography · Wiley · 2009 10.1107/s0907444909011433
  19. Structure of the TRPV1 ion channel determined by electron cryo-microscopy Nature · Nature Portfolio · 2013 10.1038/nature12822
  20. Efficient stream compaction on wide SIMD many-core architectures 2009 10.1145/1572769.1572795
  21. SubspaceEM: A fast maximum-a-posteriori algorithm for cryo-EM single particle reconstruction Journal of Structural Biology · Elsevier BV · 2015 10.1016/j.jsb.2015.03.009
  22. An adaptive Expectation–Maximization algorithm with GPU implementation for electron cryomicroscopy Journal of Structural Biology · Elsevier BV · 2010 10.1016/j.jsb.2010.06.004
  23. EMPIAR: a public archive for raw electron microscopy image data Nature Methods · Nature Portfolio · 2016 10.1038/nmeth.3806
  24. Accelerated cryo-EM structure determination with parallelisation using GPUs in RELION-2 eLife · eLife Sciences Publications Ltd · 2016 10.7554/elife.18722
  25. GeRelion: GPU-enhanced parallel implementation of single particle cryo-EM image processing bioRxiv (Cold Spring Harbor Laboratory) · Cold Spring Harbor Laboratory · 2016 10.1101/075887
  26. cryoSPARC: algorithms for rapid unsupervised cryo-EM structure determination Nature Methods · Nature Portfolio · 2017 10.1038/nmeth.4169
  27. Accelerating Electron Tomography Reconstruction Algorithm ICON Using the Intel Xeon Phi Coprocessor on Tianhe-2 Supercomputer Lecture notes in computer science · Springer Science+Business Media · 2017 10.1007/978-3-319-59575-7_23
  28. Accelerating electron tomography reconstruction algorithm ICON with GPU Biophysics Reports · Springer Science+Business Media · 2017 10.1007/s41048-017-0041-z
  29. Likelihood-based structural analysis of electron microscopy images Current Opinion in Structural Biology · Elsevier BV · 2018 10.1016/j.sbi.2018.03.004
  30. Sub-2 Å Ewald curvature corrected structure of an AAV2 capsid variant Nature Communications · Nature Portfolio · 2018 10.1038/s41467-018-06076-6
  31. Recognition of the amyloid precursor protein by human gamma-secretase. Science · American Association for the Advancement of Science · 2019 10.2210/pdb6iyc/pdb
  32. A particle-filter framework for robust cryo-EM 3D reconstruction Nature Methods · Nature Portfolio · 2018 10.1038/s41592-018-0223-8
  33. Structural basis of coreceptor recognition by HIV-1 envelope spike Nature · Nature Portfolio · 2018 10.1038/s41586-018-0804-9