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

Computing integrals for electron molecule scattering on heterogeneous accelerator systems

관련 산업용 섬유 · (9) 타이어코드

기본 정보

저자
  1. Charles J. Gillan — The School of Electronics, Electrical Engineering and Computer Science, Queen's University Belfast, Belfast, UK
  2. Ivor Spence — The School of Electronics, Electrical Engineering and Computer Science, Queen's University Belfast, Belfast, UK
DOI
10.1002/cpe.5984
저널
Concurrency and Computation Practice and Experience
발행년도
2020
발행기관
Wiley
피인용수
0
라이선스
cc-by-nc-nd
논문 유형
–
언어
–
원문 페이지
https://doi.org/10.1002/cpe.5984
토픽
Electron and X-Ray Spectroscopy Techniques
OpenAlex ID
W3049729779

평가 내용

관련도
관련
사업분야
산업용 섬유 · (9) 타이어코드
부 분야
–
R&D 측면
–
확신도
–
근거 용어
–
판단 근거
임베딩 유사도 기반 평가로 '산업용 섬유 > 타이어코드' 분야에 선정된 논문입니다.
R&D 활용 포인트
–
평가 입력
–

초록

Summary Using heterogeneous accelerators to obtain high performance for mathematical kernels remains an active research frontier in computational science. The accelerators have compute architectures that are different from the CPUs and in addition have memory spaces independent of the CPU systems to which they are connected. It follows that accelerators require a different approach to writing optimal code than that needed on a multi‐CPU system. Taken together these issues have represented a significant barrier to widespread adoption of accelerators for execution with large legacy code bases. OpenCL has emerged as a common programming language with which to implement code that runs across a range of parallel architectures, including multi‐core CPUs. This article is a case study on how the instruction‐level parallelism offered by field programmable gate arrays (FPGAs) and GPUs through OpenCL can be exploited in molecular physics. The algorithm which we study is the evaluation of tail integrals between Gaussian type basis functions for the R‐matrix method, a task that arises in the study of scattering of low energy electrons by molecular targets. The results of our productivity study, which is the first application of OpenCL in this problem domain, show that significant performance can be obtained from both FPGA and graphics processing unit (GPU) accelerators for this application. We discuss suitable transformations unique to each accelerator architecture for the integrals studied and present performance results comparing the FPGA and GPU with execution on Intel multi‐core systems.

본문 40,496자

본문 펼치기
Using heterogeneous accelerators to obtain high performance for mathematical kernels remains an active research frontier in computational science. The accelerators have compute architectures that are different from the CPUs and in addition have memory spaces independent of the CPU systems to which they are connected. It follows that accelerators require a different approach to writing optimal code than that needed on a multi-CPU system. Taken together these issues have represented a significant barrier to widespread adoption of accelerators for execution with large legacy code bases. OpenCL has emerged as a common programming language with which to implement code that runs across a range of parallel architectures, including multi-core CPUs. This article is a case study on how the instruction-level parallelism offered by field programmable gate arrays (FPGAs) and GPUs through OpenCL can be exploited in molecular physics. The algorithm which we study is the evaluation of tail integrals between Gaussian type basis functions for the R-matrix method, a task that arises in the study of scattering of low energy electrons by molecular targets. The results of our productivity study, which is the first application of OpenCL in this problem domain, show that significant performance can be obtained from both FPGA and graphics processing unit (GPU) accelerators for this application. We discuss suitable transformations unique to each accelerator architecture for the integrals studied and present performance results comparing the FPGA and GPU with execution on Intel multi-core systems. code and compile it unmodified to run on the combined CPU accelerator environment. Put simply, this is not yet generally possible. Adoption of new programming languages, compiler tools, and system components for accelerators represents a significant barrier to entry for many. One reason for this situation is that creating a compiler which can automatically generate parallel executable code is a staggeringly difficult task, as seen by the intractability of the problem in the face of the huge resources that have been targeted at it. 1,2 By the time an algorithm is expressed in, for example, Fortran or C, it involves programming features such as indirect addressing, pointers, recursion, indirect function calls, and possibly accesses to global resources. It then becomes essentially impossible for an automated tool to unravel the true nature of the algorithm. It follows that when a piece of legacy code is to be implemented to run on a heterogeneous accelerator platform, it is generally necessary for a human to perform the process of reverse engineering the algorithm and reformulating it for the new environment. When accelerators first entered the domain of HPC, there were different tool kits for each technology. The situation has improved in recent years. On the one hand, the Portland Group provides a Fortran compiler 3 that can target kernels onto GPUs, a product that addresses the needs of the very large base of legacy code developed in the Fortran language. An alternative approach is to port selected kernels from Fortran to OpenCL, via an implementation in C. We have sought to evaluate this process in this article in respect of one algorithm. We chose to look at the computation of tail integrals in the R-matrix method applied to electron molecule scattering. 4,5 This is an HPC application that has been developed over several decades years in the Fortran language and is today composed many tens of thousands of lines of code. The key contribution of our work is that it is the first implementation of any part of the molecular R-matrix program suite on both an FPGA accelerator or a GPU accelerator and on any platform using OpenCL. Our work quantifies the programmer effort needed to undertake the transformation this large code base in order to enable use of OpenCL. The work also reveals that new code transformations are required to gain maximum performance from an FPGA compared to those needed on a GPU. This article extends our previously published work on the implementation of two-dimensional numerical quadrature for integrals arising the modeling of electron atom scattering. 6,7 The article begins by presenting in Section 2 some background to the electron scattering problem. Section 3 defines the integrals and presents formulas for their evaluation. The table based algorithm that we developed for the use of accelerators in this problems is described in Section 5. Section 4 presents the programming environment which is used on each accelerator system. Ultimately, this article is about the application of those environments to derive performance from an initial FORTRAN source. The common theme is the porting of this source, but in different ways each time, to each of the three distinct accelerator platforms and programming environments. This means that we treat the accelerators independently in this article; there is currently no one-size-fits-all solution to our porting problem. We discuss related work on the application of accelerators for integral computations in section 7 and this article finishes with a discussion of conclusions from our work and future directions for it in Section 8. The inner and outer regions The application of the R-matrix method to electron molecule scattering has been described in detail in previous papers 8- 10 and we do not repeat the comprehensive details here; we present only the salient details relevant to the study undertaken in this article. Several review articles have also been written and the interested reader is directed to these for a comprehensive description of the method. 5,11 The R-matrix method solves the nonrelativistic Schrödinger equation for the systems consisting of the impact electron plus target molecular The inner and outer regions for each total energy E. Ψ is the unknown wave function which the method seeks to find. H is the Hamiltonian operator composed of kinetic energy and potential energy terms. We assume that the nuclei are fixed in space, an approach known as the Born-Oppenheimer approximation. The H operator therefore transforms as the totally symmetric irreducible representation of the point group to which the nuclear configuration belongs, or stated alternatively it is a rank zero tensor. It follows that Equation (1) must be solved for each irreducible representation of the spatial point group. Given that the nonrelativistic H operator is independent of spin, the quantum mechanical operator for spin commutes with H, so that the calculations must also be repeated for each possible overall spatial and spin quantum number of the system. The inner and outer regions The R-matrix method starts by using the Born-Oppenheimer approximation which means that the position of the nuclear framework is fixed in space. The configuration space of electron co-ordinates is partitioned into two regions by surrounding the nuclei with a hyper-sphere, radius a. The inner region is defined as that part of configuration space where r i < a for all electrons i. The efficiency of the R-matrix method lies in the fact that within the sphere the Ψ is expanded in basis functions, therefore turning equation (1) into a matrix diagonalization problem where the elements of the Hamiltonian matrix are multi-dimensional integrals among products of the basis functions. Most importantly, the diagonalization process is only carried out once per scattering energy per symmetry. The outer region problem is solved for each scattering energy and each symmetry but a simpler approximation is used in the outer region leading to coupled second order ordinary differential equations for the radial part of the functions representing the scattering electron. The inner and outer solutions are matched at the boundary for each E, a process that generates a matrix known as the R-matrix, from which the method derives its name. Basis functions Quantum chemistry codes use Gaussian-type functions (GTFs), primarily to benefit from the fact that all the required multi-center integrals over all space can be evaluated in closed form. 12 Furthermore, the double coset method 13 expedites the construction of symmetry adapted integrals. Basis functions Solving the Hamiltonian problem to compute bound states, which means solving equation (1) for negative values of E, requires integrals over all space. Many computer programs have been developed to perform this task optimally on different computer architectures. 14,15 This body of work has considered the cache efficiency, the number of function calls, loops, and condition branches, streaming SIMD extensions and general-purpose computing on graphics processing. 16 It has been shown that each of these aspects can impact the computation of molecular integrals by as much as an order of magnitude. 17 The UK molecular R-matrix suite is based on the IBM Alchemy computational chemistry package. 18 Parts of the Molecule-Sweden package 19 were merged into the code base 4 to enable Gaussian type basis functions to be used. This extension allowed polyatomic target molecules to be studied, that is, molecules where the nuclear framework transforms according to the Abelian point group D 2h or one of its subgroups. The approach adopted in the UK molecular R-matrix suite 4 is to represent the scattering electron by locating diffuse GTFs on the center of gravity of the molecule, to compute integrals over all space using existing bound state codes and then to subtract the contribution to the integral from the outer region. In this article, we use the code which was added to the R-matrix suite to compute the integrals (known as tail integrals) over diffuse Gaussian function in the outer region and explore the challenges of developing it to use heterogeneous accelerators as well as parallel language features present in the latest version of C++. The role of floating point precision The absolute value of the integrals, with which this article deals, span a dynamic range of 14 decimal places. It is, therefore, common place to use IEEE double precision for all variables in quantum chemistry integration programs. This is particularly significant when computing relative small tail integrals which are then subtracted from the larger integral values over all space. With the advent of GPUs, some groups have investigated mixed precision single-double precision computations for molecular bound states. 20 This approach is not viable in the case of the R-matrix computations. The role of floating point precision This requirement mitigates the performance gain that can be achieved from heterogeneous accelerators. GPUs operate at lower frequencies than CPUs but they typically have many times the number of cores than a CPU chip. However, while all GPUs have single precision units, the number of double precision units varies between micro-architectures. This means that GPUs can in principle perform many times more single precision computations per second than a multi-core CPU but a smaller multiple of double precision calculations. We report results in a later section using a typical desktop GPU, an instance of the NVidia Maxwell 2.0 architecture, on which double precision performance is 1/32 of single precision performance. The role of floating point precision FPGA accelerators present a different challenge, essentially offering programmable silicon. In principle, one can implement several floating point units with any number of bits allocated to the exponent and the mantissa. In practice, the OpenCL language currently limits this to the IEEE single and double data types. The issue then becomes whether one can fit the bitstream into the silicon available on the FPGA model. We discuss this later in the article. Furthermore, while the FPGA provides an opportunity to create a multi-core system, the preferred mechanism is to pipeline the computations. This relies on the fact that there is a very high bandwidth network on the FPGA fabric to pass data from one compute element to the next. COMPUTING THE INTEGRALS In this section, we present the formulas that are employed to compute the tail integrals which have been explained in the previous section. There are several types of integral in the computation but we focus in this article on the three one electron integrals: overlap, kinetic energy, and nuclear repulsion. We start the section by defining exactly the Gaussian type functions which form the integrand in each case. Gaussian type basis functions The definition of a primitive Gaussian function with Cartesian powers i,j,k and with exponent l centered on the nucleus n located at position (x n ,y n ,z n ) is given at the point (x,y,z) by Gaussian type basis functions where the square of the radial distance r is defined by Gaussian type basis functions In order to compute the Hamiltonian matrix, one needs to computer overlap, kinetic energy, Bloch, and nuclear repulsion integrals each of which involves products of two primitive Gaussian functions. Gaussian type basis functions In the R-matrix method, the integrals are restricted to a sphere with a finite radius around the center of gravity of the system, this being taken as the origin of co-ordinates. This poses no problem for primitive Gaussian functions located on the nuclear centers because these functions have essentially zero magnitude near the boundary of the sphere meaning that the integrals computed over all space, by a bound state code, can be taken to be equal to the integrals computed over the spherical region. However, in order to model the scattering electron, diffuse primitive Gaussian functions are located at the origin and these do have a finite magnitude close to and beyond the bounding sphere. Gaussian type basis functions It would be extremely challenging to develop a numerical integration method to compute multi-center integrals over GTFs within the R-matrix sphere, radius a. In contrast, it is straightforward to compute such integrals with one radial co-ordinate in the range [a,∞], hence giving rise the name tail integral. Given that the GTFs are continuous functions, it follows from the properties of integration that the integral over the inner region can be computed as the difference of the integral over all space and the tail integral. Given the limitations of computer arithmetic, computations need to be monitored for the impact of round-off error in this subtraction. Gaussian type basis functions The geometry of the bounding sphere implies that the integrals are easiest to compute when expressed in spherical polar rather than Cartesian co-ordinates. Using the transformation Gaussian type basis functions then defines the diffuse primitive Gaussian functions located on the center of gravity as Overlap integrals The fundamental integral to be evaluated is the three dimensional overlap integral between two primitive diffuse Gaussian, which is shown in Equation (6). Overlap integrals Switching to Cartesian co-ordinates equation (6) can be expressed as the product of three distinct one dimensional integrals, as follows: Overlap integrals where the one dimensional integrals are Overlap integrals The values for the indices i,j,k shown in these integrals will differ for every pair of primitive Gaussian basis functions. The integral in Equation (8) is zero unless i,j ∈ {0,2,4, … }, while the integrals in Equations (9) and (10) can be computed using recursion formulae. Furthermore the integral in Equation (8) Kinetic energy integrals The kinetic energy operator is decomposed into sums over integrals between two primitive diffuse Gaussian functions in the form shown in Equation (11). Kinetic energy integrals Considering the x-component of the ∇ 2 Kinetic energy integrals generates different results depending on the value of i. Kinetic energy integrals Following the same steps for the y and z co-ordinates, it follows that the integral in Equation (11) can be expressed as a summation of integrals in the same form as the overlap integral. Nuclear repulsion integrals The nuclear repulsion integrals between two primitive diffuse Gaussians have the form shown in Equation (16). Nuclear repulsion integrals where these are defined for every nuclear center in the molecule. The key to evaluating these integrals is to expand the repulsion term as follows Nuclear repulsion integrals where the S lmq in Equation (17) are the real spherical harmonics derived from the complex spherical harmonics. A key step is to re-arrange the term on the right-hand side of Equation (17) to Nuclear repulsion integrals because the product of a radial power with a real spherical harmonic can be expressed as Nuclear repulsion integrals that is as a linear combination of powers of Cartesian co-ordinates, x,y,z. Using this approach means that the nuclear repulsion integral (16) can be decomposed into a summation of overlap type integrals multiplied by coefficients. It follows that a generic kernel can be developed for the overlap type integrals and then driver functions used for the kinetic energy and nuclear repulsion integrals which make repeated calls to this kernel. COMPUTING PLATFORMS We ported existing code from the R-matrix suite to the OpenCL language and then compiled and executed this on different hardware platforms. COMPUTING PLATFORMS First, we explain the role of OpenCL and present details of the platforms on which we executed the compiled code. Programming environment: OpenCL The Open Computing Language, known more commonly as OpenCL, is an open standard maintained by the Khronos Group. It has emerged from the need to provide a common language for implementation of programs that can execute on heterogeneous platforms. This includes CPUs, GPUs, and FPGAs. OpenCL, which is based on C99 and C++11, enables programming these devices with a standard interface for parallel computing using both task and data-based parallelism. A typical approach in OpenCL is to write a kernel which is a procedure in software that can be executed independently concurrently many times, a model that matches to processing 1, 2, or 3D stencils in various applications. There are generally many more instances of the kernel than the processing elements (PEs), the actual hardware on which the kernel executes, and the system schedules blocks of kernels onto the PEs. This model, known as the NDRange approach, is best used for large groups of completely independent parallel work-items that require as few shared variables and as little synchronization as possible. It is possible to execute different kernels at the same time on the same device. This model reflects a host-centric view of accelerators, where communication of data between host and accelerator or between different kernel executing concurrently on the same device write to, and read from, a global memory accessible to all PEs. Programming environment: OpenCL While the Intel-Altera implementation of OpenCL implements ND Range feature, the preferred strategy for optimization is to use pipeline parallelism, where iterations of a loop are launched as if they were parallel work-items. Dependencies between iterations are allowed because the hardware generated by the toolkit ensures that a value computed in one iteration is available before it is read by a subsequent iteration. The Altera off-line compiler (AOC) reads an OpenCL code and implements pipelines for the computations inside for loops. Since FPGAs have a large number of registers, pipelines with hundreds of stages can be created. Nested loops and data dependencies within loops need careful consideration, otherwise loop-stalls can be created which impact negatively on performance. FPGA accelerator The computing platform on which we executed our code consists of an Intel server equipped with a Nallatech P385-A7 card. This half-height, half-length card is inserted into a PCI Express slot and operates as an 8-lane PCI Express Gen2 peripheral. The card is capable, according to manufacturer documentation, of operating at Gen3 speeds but the standard OpenCL SDK and Nallatech board support package limit its operation to FPGA accelerator Gen2. The compute element on board is an Altera Stratix V GX A7 FPGA surrounded by two 4 GB banks of DDR3 SDRAM. We prepared bitstreams GPU accelerator An NVidia GPU is composed of independent stream multiprocessors (SM) which implement a single instruction multiple data (SIMD) style of processing. Each SM has several scalar processors and one instruction unit. The same instruction in executed concurrently on each scalar processor but each processor operates on different data. A kernel code is instantiated once in each thread and the set of all threads are partitioned into blocks. Each SM can process several blocks concurrently, but all the threads in a given block are guaranteed to be executed on a single SM. To gain maximum performance from the GPU, it is customary to have the number of threads much larger than the total number of scalar processing units, and all the threads are executed using time slicing. All blocks are split into groups of thirty-two threads, an entity which is defined as a warp. The thread scheduler maintains load balancing and maximizes overall performance by switching between the active warps. GPU accelerator The micro-architecture of the NVidia GPU product line has evolved continuously since the product was introduced. In our work, we have used the Tesla M60 product has two GM204-400 type GPUs on board. The GM204-400 is an instance of the second generation of the Maxwell micro-architecture however retaining the same CUDA programming model, but with enhancements, as in the older Intel multi-core CPU In order to compare our work on the accelerator platforms, we executed the code on multi-core Intel computers based on the core i7 CPU chip operating at 2.3 GHz. This is an instance of the Haswell micro-architecture and supports SEE and AVX instructions as well as fused-multiply add instructions. We used one system with one core i7 chip installed with the Windows 7 operating system and the Intel OpenCL toolkit. For the work reported in Table 6, using the C++ std::async functionality, we used a server with 36 physical cores Intel i7 CPUs running version 14 of the UBuntu operating system version 14 with the g++ compiler version 5.4. A TABLE DRIVEN ALGORITHM TO ENABLE PARALLELISM ON ACCELERATORS The previous section explains how mathematical form of the various tail integrals arising in the study of electron-molecule scattering with Gaussian type functions can be decomposed, in general, to sums of overlap integrals of the type shown in Equation (6). In the initial sequential version of the code, a generic kernel was implemented for the overlap integrals and then this was called repeatedly within loops over pairs of functions. Figure 1 illustrates this relationship schematically. There are two distinct aspects to introducing parallelism to this computation. On the one hand, one can consider the coarse grain parallelism offered by the fact that each integral is independent of other integrals and we consider this in the next part of this section. On the other hand, one can use fine grain parallelism to optimize the computation within one integral. We present details of this at the end of this section. Identifying parallelism This loop based approach originally designed for single CPU operation and in limited places exploited the fine grain parallelism offered by SSE units on Intel chips. The aim was to compute each integral, one after another, as efficiently as possible in a loop. Given that the computation of each integral is independent, we redesigned the code completely to be able to use multiple CPUs and/or accelerators to compute integrals in parallel. The key step to enable this was to define the overall algorithm to employ a table driven approach in which we separate the processing logic from the call to the kernel function. This can be expressed in pseudo-code as follows: Identifying parallelism 1. Scan the set of all basis functions and determine maximum indices i,j,k occurring in Equation (2) 2. Using the looping structure from the original code, processing all possible combinations of basis functions that generate non-zero integrals for one or more of the three types of integrals defined in Equations (6), (11), and (16). As explained previously, each kinetic energy and nuclear repulsion integral is expressed as a sum over overlap integrals. This step depends on the point group to which the nuclear framework belongs. Identifying parallelism In our code, we are limited to the Abelian point group D 2h ad its sub-groups. In the case of nuclear repulsion integrals, this means expanding the repulsion term (17) and giving multiple overlap type integrals. For each non-zero integral identified, enter index and exponent details into one row of the integrals table, which is sufficient information with which to compute the integral. The format of the table is illustrated in Figure 2 where data from one of the basis sets reported in Section 6.3 is used. Populating the rows of the table to define the complete set of required integrals requires only integer arithmetic, principally on the Cartesian powers of the primitive Gaussian functions, as well as logic operations. 4. The final step is to process the integrals table on the host to perform sum reductions needed to compute the kinetic or nuclear repulsion integrals. Independent tasks: CPU (OpenCL and C++) and GPU The integrals table on the main CPU is best implemented using a struct of arrays (SoA) approach. in fact we use a C++ std:vector for each column because this is guaranteed to allocate contiguous memory for the elements of the vector. This facilitates transfer to the accelerator global memory, which we describe later, by simply copying the whole column to a pointer on the accelerator. This represents a relatively low cost compared to the computations therefore. Table 1 shows the maximum data speeds for the PCIe buses which connect to the peripherals. The alternative approach of using a defined struct for each row would present the potential problem that the memory pattern used by the compiler for the accelerator may not match that used on the host thereby making data copy operations alone impossible. To further optimize storage, we pack three integer indices into one 32 bit value using 10 bits per index. This exceeds any practical index value that arises in the sets of basis functions in common use today. Independent tasks: CPU (OpenCL and C++) and GPU On a multi-CPU shared memory system, the integrals can be computed by creating a number of asynchronous tasks, each with access to the integrals This is readily enabled by instantiating a vector of instances of the std::future class template. Each instance of std::future wraps the kernel function, gtolap_cpu(), which processes the integrals table in the way discussed in the previous paragraph (Table 2). We mapped this to the multi-core CPU using the std::async feature of C++11 with the policy std::launch::async. This means that the runtime continues to launch tasks in separate threads as long as there are unused CPUs available on the system. With modularized code, the use of the asynchronous features in C++ is a relatively straightforward process. Independent tasks: CPU (OpenCL and C++) and GPU A similar approach can be achieved on the CPU using OpenCL or equivalently on the GPU. The clEnqueueNDRangeKernel() method is used to launch multiple instances of the integration kernel on the platform, a one dimensional structure. Then each kernel determines its thread index and Pre-computed integrals over the phi co-ordinate The integrals over the co-ordinate can be expressed analytically and they are reused several times throughout the computation of the full set of integrals. This means that it is computationally efficient to compute a table of all required integrals at the start of the execution and to reuse it continuously. The dimension of this is determined by summing the powers i,j,k for each basis function and finding the maximum value, maxl, over the whole set of functions. The number of integrals over the co-ordinate is then 2 maxl +1) 2 . The table is computed once and shipped to the global memory of each accelerator as a one off cost. It consumes only a few MB at most and is significantly smaller than the table defining the full set of integrals. The integrals over the and co-ordinates can also be expressed analytically and coded as sum reductions. There is no numerical quadrature required. Pipelining for parallelism on the FPGA In the case of the FPGA, the preferred mechanism for parallelism is that the rows of the table are processed in a pipeline in contrast to the situation on the GPU and on the multi-core CPU. The key to achieving good performance from the FPGA implementation is to aim to have one loop iteration launched every clock cycle, technique. Loop carried dependencies can prevent this causing launched to be delayed by several clock cycles. The AOC compiler provided by Intel/Altera reports for each loop, when the -g flag is set, Pipelining for parallelism on the FPGA • operations that contribute the largest delay to the computation of the loop-carried dependency; Pipelining for parallelism on the FPGA • the launch frequency of a new loop iteration. The loop that computes the integral over the co-ordinate is identified above to add a latency of 8 clock cycles, while the loop which computes the integral over the radial co-ordinate reports a latency of 19 clock cycles. In both cases, these loops are written using an accumulator variable which holds, by the end of all iterations, the value of the relevant integral. Pipelining for parallelism on the FPGA The Programming Practices Guide suggests several strategies to remove this kind of loop carried dependency. We investigated the use of shift registers, a technique well-known to VHDL programmers but not generally suited to CPU implementations. Applying this technique means that instead of adding values to a single accumulator, within a loop, an array known as a shift register is first established and all its elements are set to zero. Then at each iteration of the loop, the following additional operations are performed with the shift register: Pipelining for parallelism on the FPGA • each newly computed value from the iteration is added to the element at the base of the array and the result placed at the top of the array; Pipelining for parallelism on the FPGA • all elements in the array are pushed down one location, step which overwrites the base element but duplicates the element at the top of the array. Pipelining for parallelism on the FPGA After the last iteration of the loop is complete, the elements in the shift register are summed, excluding the value at the top, to give the final result. This process can be implemented very efficiently on an FPGA and are widely used in streaming data applications such as network packet processing, digital signal processing, and image processing. The reason that shift registers are optimal on FPGAs stems from the fact that there is no complex address decoding required and that data movement can be enabled via dedicated connections between logic blocks in the fabric. Unlike the CPU implementation, there is no shared data bus. The integral over the co-ordinate can be expressed analytically as a sum over terms. In the CPU code, this is implemented in the following loop structure, where the label REAL_t is replaced by float or double as required when compiling and where angpart1 is the summation computed. This optimization is specific to the FPGA architecture. While the code works on CPU and GPU, it performs poorly on these architectures. RESULTS We begin this section by discussing the resource consumption for different implementation on the FPGA. As we have pointed out earlier, only the double precision implementation can produce values that are suitable for use in modeling computations. However, we report some aspects of the implementation of single precision computations to illustrate the resource consumption on the FPGA. Computations reported on for the CPU and GPU are only using double precision. At the end of section, we turn our attention to performance gained from our implementations. Data transfer to/from the accelerator We have explained earlier in the article that the algorithm is centered on a table of integrals. This is transferred to the accelerator before the launch of the compute kernels and one column, the computed values, is retrieved to the host when the execution of all kernels is completed. Table 4 reports the aggregate transfer times moving the integrals table between the accelerators for different size of problem. These figures can be compared to the row labeled Execution times in Table 5. The aggregate data transfer times are generally less than 10% of the total execution time. Performance analysis We performed several calculations for the case of the nitrogen molecule with the nuclei fixed in its equilibrium configuration. We defined different basis sets of diffuse Gaussian functions located at the center of the module. We initially used a basis set from previous work and then extended this to include higher angular momentum terms. This extension generates more basis functions and therefore more integrals so that we can examine the scalability of the computation. Table 5 shows the number of non-zero integrals computed for various sizes of the basis sets. One of the limiting factors in our approach is to determine whether the table of integrals, which has been described above and an example presented in Table 2 90M integrals to be computed. As Table 2 shows this limit is reached with over 2000 basis functions. This limit could be overcome by dividing a larger table into sub-units and computing these in a loop. Figure 2 shows the time taken to compute the integrals for different number of basis functions. Performance analysis This figure includes, for each case, construction of the table on the host, the time to move the table to and from the FPGA, and the time spent on the FPGA computing the integrals. The solid line is a quadratic curve fitted to the data points. This has the form Performance analysis where x is the number of primitive basis functions. The shape of the graph suggests that there is a fixed time cost to move the data to and from the FPGA with a value of 1.967 seconds. As larger numbers of integrals are executed, this is amortized to an extent, however, still remains significant for 2000 functions representing 25% of the elapsed time for the whole computation. Table 6 presents the elapsed times in seconds for execution of the integral workload using the C++ std:::future language feature on the CPU. Within the limits of Amdahl's law, the results down each column of the table reflect the scaling enabled by used of additional CPUs. It is interesting to compare the execution of the code as a single for-loop versus using two asynchronous tasks, an experiment that allows us to gauge the cost of using std::async. Table 7 compares these results. It is not surprising that the cost of executing two separate tasks is more expensive for smaller workloads, corresponding to smaller numbers of basis functions. However, by RELATED WORK This is the first article, in so far as we are aware to apply heterogeneous accelerator computing to the problem of integral evaluation in electron molecule scattering. GPU computing has previously been successfully applied to computation of molecular bound states where performance gains have of 180× in Hartree-Fock energy + gradient calculations have been observed. 22 The performance of the two electron integral evaluation in this work was studied using three different algorithms, well suited to the GPU architecture and distinct from the many optimal CPU approaches. 15 A combined CPU-GPU algorithm, enabling strong scaling parallelization on inhomogeneous compute clusters, was developed by Kussman and Ochensfeld 23 to evaluate two-electron contributions occurring in Hartree Fock and hybrid density functional theory. Their approach allows an efficient use of CPUs and GPUs simultaneously. They pointed out that the different architectures demand conflicting strategies in order to ensure efficient program execution. RELATED WORK In so far as we are aware, FPGAs have not been used for integration of GTFs in quantum chemistry. On the other hand, there is a large literature on using FPGAs to calculate the quantum mechanical properties of N-body systems, such as in quantum Monte Carlo techniques 24 and in molecular dynamics. 25 The suitability of a hardware approach for molecular dynamics is seen in the Anton system which is a set of customized application specific integrated circuits (ASICs) developed specifically for molecular dynamics simulations on proteins and biological macro-molecules. 26 CONCLUSIONS AND FUTURE DIRECTIONS The aim of this article is to examine the viability of applying OpenCL to enable some existing computation kernels on modern heterogeneous accelerators. We chose a FORTRAN program for the evaluation of tail integrals over diffuse Gaussian type functions and converted this into ANSI C++14, using that as a basis from which to develop an OpenCL implementation. The program was taken from a large base of code known as the UK molecular R-matrix suite, a code base that has been in continuous development for 40 years in the UK. This code base was evolved from the IBM Alchemy I program suite for molecular bound state computations, a package on which development began in the Theoretical Chemistry Group at the IBM San Jose laboratory in the late 1960s. CONCLUSIONS AND FUTURE DIRECTIONS The original code implementation used a kernel function called within a dense set of driver loops. The loop iterations were controlled by the quantum numbers of the diffuse Gaussian functions in the basis set. This analysis is completed based on logical and integer arithmetic and proceeds at very high speed on the CPU. We redesigned the algorithm to a data table driven one, centered on the idea of preparing a table of data where each row required independent execution of a kernel function. The entries in each row of the table are derived from the same driver loops in the original algorithm. The table is copied to global memory on the accelerator before launching the independent evaluation of each row as kernel instances on the accelerator. CONCLUSIONS AND FUTURE DIRECTIONS We executed this implementation on GPU and FPGA platforms, using an OpenCL SDK specific to each platform, in order to investigate the portability and performance of the implementation. These two accelerators have differing approaches to code execution and we reported on specific optimizations relevant to each architecture. The data-driven approach also works on the host CPU where the kernel instances can be considered as tasks and we have reported two different ways of achieving this. On the one hand, the OpenCL code used on the accelerators can also be used. On the other hand, the C++ language now incorporates mechanisms to easily manage this kind of task based model. The C++ language is adding increasing support for parallelism with the C++17 standard adding support for parallel implementations of the standard template library (STL). Looking forward, a concept known as an executor is proposed as as a basic building block for extension of the C++ language to include heterogeneous accelerators; however, this is not expected to appear until completion of the C++23 standard. 27 However, early implementations of the proposals for executors are beginning to appear, such as in the HPX runtime which is based on C++. 28 There are clearly a number of ways in which the research we have reported can be extended. The partitioning of operations into tabular data, or even matrix, format with execution of processing functions on each element is a pattern that can be readily identified in many computational science codes. We plan to investigate this approach in other problem domains therefore. A further research angle is to investigate the viability of using dynamic selection of precision, a feature that has been investigated by Martinez and co-workers 29 using GPUs for structure calculations.

섹션 본문 68문단 · 38,623자

(제목 없음)

1Using heterogeneous accelerators to obtain high performance for mathematical kernels remains an active research frontier in computational science. The accelerators have compute architectures that are different from the CPUs and in addition have memory spaces independent of the CPU systems to which they are connected. It follows that accelerators require a different approach to writing optimal code than that needed on a multi-CPU system. Taken together these issues have represented a significant barrier to widespread adoption of accelerators for execution with large legacy code bases. OpenCL has emerged as a common programming language with which to implement code that runs across a range of parallel architectures, including multi-core CPUs. This article is a case study on how the instruction-level parallelism offered by field programmable gate arrays (FPGAs) and GPUs through OpenCL can be exploited in molecular physics. The algorithm which we study is the evaluation of tail integrals between Gaussian type basis functions for the R-matrix method, a task that arises in the study of scattering of low energy electrons by molecular targets. The results of our productivity study, which is the first application of OpenCL in this problem domain, show that significant performance can be obtained from both FPGA and graphics processing unit (GPU) accelerators for this application. We discuss suitable transformations unique to each accelerator architecture for the integrals studied and present performance results comparing the FPGA and GPU with execution on Intel multi-core systems.

2code and compile it unmodified to run on the combined CPU accelerator environment. Put simply, this is not yet generally possible. Adoption of new programming languages, compiler tools, and system components for accelerators represents a significant barrier to entry for many.

3One reason for this situation is that creating a compiler which can automatically generate parallel executable code is a staggeringly difficult task, as seen by the intractability of the problem in the face of the huge resources that have been targeted at it. 1,2 By the time an algorithm is expressed in, for example, Fortran or C, it involves programming features such as indirect addressing, pointers, recursion, indirect function calls, and possibly accesses to global resources. It then becomes essentially impossible for an automated tool to unravel the true nature of the algorithm. It follows that when a piece of legacy code is to be implemented to run on a heterogeneous accelerator platform, it is generally necessary for a human to perform the process of reverse engineering the algorithm and reformulating it for the new environment. When accelerators first entered the domain of HPC, there were different tool kits for each technology. The situation has improved in recent years. On the one hand, the Portland Group provides a Fortran compiler 3 that can target kernels onto GPUs, a product that addresses the needs of the very large base of legacy code developed in the Fortran language. An alternative approach is to port selected kernels from Fortran to OpenCL, via an implementation in C.

4We have sought to evaluate this process in this article in respect of one algorithm. We chose to look at the computation of tail integrals in the R-matrix method applied to electron molecule scattering. 4,5 This is an HPC application that has been developed over several decades years in the Fortran language and is today composed many tens of thousands of lines of code. The key contribution of our work is that it is the first implementation of any part of the molecular R-matrix program suite on both an FPGA accelerator or a GPU accelerator and on any platform using OpenCL. Our work quantifies the programmer effort needed to undertake the transformation this large code base in order to enable use of OpenCL. The work also reveals that new code transformations are required to gain maximum performance from an FPGA compared to those needed on a GPU. This article extends our previously published work on the implementation of two-dimensional numerical quadrature for integrals arising the modeling of electron atom scattering. 6,7 The article begins by presenting in Section 2 some background to the electron scattering problem. Section 3 defines the integrals and presents formulas for their evaluation. The table based algorithm that we developed for the use of accelerators in this problems is described in Section 5.

5Section 4 presents the programming environment which is used on each accelerator system. Ultimately, this article is about the application of those environments to derive performance from an initial FORTRAN source. The common theme is the porting of this source, but in different ways each time, to each of the three distinct accelerator platforms and programming environments. This means that we treat the accelerators independently in this article; there is currently no one-size-fits-all solution to our porting problem. We discuss related work on the application of accelerators for integral computations in section 7 and this article finishes with a discussion of conclusions from our work and future directions for it in Section 8.

The inner and outer regions

6The application of the R-matrix method to electron molecule scattering has been described in detail in previous papers 8- 10 and we do not repeat the comprehensive details here; we present only the salient details relevant to the study undertaken in this article. Several review articles have also been written and the interested reader is directed to these for a comprehensive description of the method. 5,11 The R-matrix method solves the nonrelativistic Schrödinger equation for the systems consisting of the impact electron plus target molecular

7for each total energy E. Ψ is the unknown wave function which the method seeks to find. H is the Hamiltonian operator composed of kinetic energy and potential energy terms. We assume that the nuclei are fixed in space, an approach known as the Born-Oppenheimer approximation. The H operator therefore transforms as the totally symmetric irreducible representation of the point group to which the nuclear configuration belongs, or stated alternatively it is a rank zero tensor. It follows that Equation (1) must be solved for each irreducible representation of the spatial point group. Given that the nonrelativistic H operator is independent of spin, the quantum mechanical operator for spin commutes with H, so that the calculations must also be repeated for each possible overall spatial and spin quantum number of the system.

8The R-matrix method starts by using the Born-Oppenheimer approximation which means that the position of the nuclear framework is fixed in space. The configuration space of electron co-ordinates is partitioned into two regions by surrounding the nuclei with a hyper-sphere, radius a. The inner region is defined as that part of configuration space where r i < a for all electrons i. The efficiency of the R-matrix method lies in the fact that within the sphere the Ψ is expanded in basis functions, therefore turning equation (1) into a matrix diagonalization problem where the elements of the Hamiltonian matrix are multi-dimensional integrals among products of the basis functions. Most importantly, the diagonalization process is only carried out once per scattering energy per symmetry. The outer region problem is solved for each scattering energy and each symmetry but a simpler approximation is used in the outer region leading to coupled second order ordinary differential equations for the radial part of the functions representing the scattering electron. The inner and outer solutions are matched at the boundary for each E, a process that generates a matrix known as the R-matrix, from which the method derives its name.

Basis functions

9Quantum chemistry codes use Gaussian-type functions (GTFs), primarily to benefit from the fact that all the required multi-center integrals over all space can be evaluated in closed form. 12 Furthermore, the double coset method 13 expedites the construction of symmetry adapted integrals.

10Solving the Hamiltonian problem to compute bound states, which means solving equation (1) for negative values of E, requires integrals over all space. Many computer programs have been developed to perform this task optimally on different computer architectures. 14,15 This body of work has considered the cache efficiency, the number of function calls, loops, and condition branches, streaming SIMD extensions and general-purpose computing on graphics processing. 16 It has been shown that each of these aspects can impact the computation of molecular integrals by as much as an order of magnitude. 17 The UK molecular R-matrix suite is based on the IBM Alchemy computational chemistry package. 18 Parts of the Molecule-Sweden package 19 were merged into the code base 4 to enable Gaussian type basis functions to be used. This extension allowed polyatomic target molecules to be studied, that is, molecules where the nuclear framework transforms according to the Abelian point group D 2h or one of its subgroups. The approach adopted in the UK molecular R-matrix suite 4 is to represent the scattering electron by locating diffuse GTFs on the center of gravity of the molecule, to compute integrals over all space using existing bound state codes and then to subtract the contribution to the integral from the outer region. In this article, we use the code which was added to the R-matrix suite to compute the integrals (known as tail integrals) over diffuse Gaussian function in the outer region and explore the challenges of developing it to use heterogeneous accelerators as well as parallel language features present in the latest version of C++.

The role of floating point precision

11The absolute value of the integrals, with which this article deals, span a dynamic range of 14 decimal places. It is, therefore, common place to use IEEE double precision for all variables in quantum chemistry integration programs. This is particularly significant when computing relative small tail integrals which are then subtracted from the larger integral values over all space. With the advent of GPUs, some groups have investigated mixed precision single-double precision computations for molecular bound states. 20 This approach is not viable in the case of the R-matrix computations.

12This requirement mitigates the performance gain that can be achieved from heterogeneous accelerators. GPUs operate at lower frequencies than CPUs but they typically have many times the number of cores than a CPU chip. However, while all GPUs have single precision units, the number of double precision units varies between micro-architectures. This means that GPUs can in principle perform many times more single precision computations per second than a multi-core CPU but a smaller multiple of double precision calculations. We report results in a later section using a typical desktop GPU, an instance of the NVidia Maxwell 2.0 architecture, on which double precision performance is 1/32 of single precision performance.

13FPGA accelerators present a different challenge, essentially offering programmable silicon. In principle, one can implement several floating point units with any number of bits allocated to the exponent and the mantissa. In practice, the OpenCL language currently limits this to the IEEE single and double data types. The issue then becomes whether one can fit the bitstream into the silicon available on the FPGA model. We discuss this later in the article. Furthermore, while the FPGA provides an opportunity to create a multi-core system, the preferred mechanism is to pipeline the computations. This relies on the fact that there is a very high bandwidth network on the FPGA fabric to pass data from one compute element to the next.

COMPUTING THE INTEGRALS

14In this section, we present the formulas that are employed to compute the tail integrals which have been explained in the previous section. There are several types of integral in the computation but we focus in this article on the three one electron integrals: overlap, kinetic energy, and nuclear repulsion. We start the section by defining exactly the Gaussian type functions which form the integrand in each case.

Gaussian type basis functions

15The definition of a primitive Gaussian function with Cartesian powers i,j,k and with exponent l centered on the nucleus n located at position (x n ,y n ,z n ) is given at the point (x,y,z) by

16where the square of the radial distance r is defined by

17In order to compute the Hamiltonian matrix, one needs to computer overlap, kinetic energy, Bloch, and nuclear repulsion integrals each of which involves products of two primitive Gaussian functions.

18In the R-matrix method, the integrals are restricted to a sphere with a finite radius around the center of gravity of the system, this being taken as the origin of co-ordinates. This poses no problem for primitive Gaussian functions located on the nuclear centers because these functions have essentially zero magnitude near the boundary of the sphere meaning that the integrals computed over all space, by a bound state code, can be taken to be equal to the integrals computed over the spherical region. However, in order to model the scattering electron, diffuse primitive Gaussian functions are located at the origin and these do have a finite magnitude close to and beyond the bounding sphere.

19It would be extremely challenging to develop a numerical integration method to compute multi-center integrals over GTFs within the R-matrix sphere, radius a. In contrast, it is straightforward to compute such integrals with one radial co-ordinate in the range [a,∞], hence giving rise the name tail integral. Given that the GTFs are continuous functions, it follows from the properties of integration that the integral over the inner region can be computed as the difference of the integral over all space and the tail integral. Given the limitations of computer arithmetic, computations need to be monitored for the impact of round-off error in this subtraction.

20The geometry of the bounding sphere implies that the integrals are easiest to compute when expressed in spherical polar rather than Cartesian co-ordinates. Using the transformation

21then defines the diffuse primitive Gaussian functions located on the center of gravity as

Overlap integrals

22The fundamental integral to be evaluated is the three dimensional overlap integral between two primitive diffuse Gaussian, which is shown in Equation (6).

23Switching to Cartesian co-ordinates equation (6) can be expressed as the product of three distinct one dimensional integrals, as follows:

24where the one dimensional integrals are

25The values for the indices i,j,k shown in these integrals will differ for every pair of primitive Gaussian basis functions. The integral in Equation (8) is zero unless i,j ∈ {0,2,4, … }, while the integrals in Equations (9) and (10) can be computed using recursion formulae. Furthermore the integral in Equation (8)

Kinetic energy integrals

26The kinetic energy operator is decomposed into sums over integrals between two primitive diffuse Gaussian functions in the form shown in Equation (11).

27Considering the x-component of the ∇ 2

28generates different results depending on the value of i.

29Following the same steps for the y and z co-ordinates, it follows that the integral in Equation (11) can be expressed as a summation of integrals in the same form as the overlap integral.

Nuclear repulsion integrals

30The nuclear repulsion integrals between two primitive diffuse Gaussians have the form shown in Equation (16).

31where these are defined for every nuclear center in the molecule. The key to evaluating these integrals is to expand the repulsion term as follows

32where the S lmq in Equation (17) are the real spherical harmonics derived from the complex spherical harmonics. A key step is to re-arrange the term on the right-hand side of Equation (17) to

33because the product of a radial power with a real spherical harmonic can be expressed as

34that is as a linear combination of powers of Cartesian co-ordinates, x,y,z. Using this approach means that the nuclear repulsion integral (16) can be decomposed into a summation of overlap type integrals multiplied by coefficients. It follows that a generic kernel can be developed for the overlap type integrals and then driver functions used for the kinetic energy and nuclear repulsion integrals which make repeated calls to this kernel.

COMPUTING PLATFORMS

35We ported existing code from the R-matrix suite to the OpenCL language and then compiled and executed this on different hardware platforms.

36First, we explain the role of OpenCL and present details of the platforms on which we executed the compiled code.

Programming environment: OpenCL

37The Open Computing Language, known more commonly as OpenCL, is an open standard maintained by the Khronos Group. It has emerged from the need to provide a common language for implementation of programs that can execute on heterogeneous platforms. This includes CPUs, GPUs, and FPGAs. OpenCL, which is based on C99 and C++11, enables programming these devices with a standard interface for parallel computing using both task and data-based parallelism. A typical approach in OpenCL is to write a kernel which is a procedure in software that can be executed independently concurrently many times, a model that matches to processing 1, 2, or 3D stencils in various applications. There are generally many more instances of the kernel than the processing elements (PEs), the actual hardware on which the kernel executes, and the system schedules blocks of kernels onto the PEs. This model, known as the NDRange approach, is best used for large groups of completely independent parallel work-items that require as few shared variables and as little synchronization as possible. It is possible to execute different kernels at the same time on the same device. This model reflects a host-centric view of accelerators, where communication of data between host and accelerator or between different kernel executing concurrently on the same device write to, and read from, a global memory accessible to all PEs.

38While the Intel-Altera implementation of OpenCL implements ND Range feature, the preferred strategy for optimization is to use pipeline parallelism, where iterations of a loop are launched as if they were parallel work-items. Dependencies between iterations are allowed because the hardware generated by the toolkit ensures that a value computed in one iteration is available before it is read by a subsequent iteration. The Altera off-line compiler (AOC) reads an OpenCL code and implements pipelines for the computations inside for loops. Since FPGAs have a large number of registers, pipelines with hundreds of stages can be created. Nested loops and data dependencies within loops need careful consideration, otherwise loop-stalls can be created which impact negatively on performance.

FPGA accelerator

39The computing platform on which we executed our code consists of an Intel server equipped with a Nallatech P385-A7 card. This half-height, half-length card is inserted into a PCI Express slot and operates as an 8-lane PCI Express Gen2 peripheral. The card is capable, according to manufacturer documentation, of operating at Gen3 speeds but the standard OpenCL SDK and Nallatech board support package limit its operation to

40Gen2. The compute element on board is an Altera Stratix V GX A7 FPGA surrounded by two 4 GB banks of DDR3 SDRAM. We prepared bitstreams

GPU accelerator

41An NVidia GPU is composed of independent stream multiprocessors (SM) which implement a single instruction multiple data (SIMD) style of processing. Each SM has several scalar processors and one instruction unit. The same instruction in executed concurrently on each scalar processor but each processor operates on different data. A kernel code is instantiated once in each thread and the set of all threads are partitioned into blocks. Each SM can process several blocks concurrently, but all the threads in a given block are guaranteed to be executed on a single SM. To gain maximum performance from the GPU, it is customary to have the number of threads much larger than the total number of scalar processing units, and all the threads are executed using time slicing. All blocks are split into groups of thirty-two threads, an entity which is defined as a warp. The thread scheduler maintains load balancing and maximizes overall performance by switching between the active warps.

42The micro-architecture of the NVidia GPU product line has evolved continuously since the product was introduced. In our work, we have used the Tesla M60 product has two GM204-400 type GPUs on board. The GM204-400 is an instance of the second generation of the Maxwell micro-architecture however retaining the same CUDA programming model, but with enhancements, as in the older

Intel multi-core CPU

43In order to compare our work on the accelerator platforms, we executed the code on multi-core Intel computers based on the core i7 CPU chip operating at 2.3 GHz. This is an instance of the Haswell micro-architecture and supports SEE and AVX instructions as well as fused-multiply add instructions. We used one system with one core i7 chip installed with the Windows 7 operating system and the Intel OpenCL toolkit. For the work reported in Table 6, using the C++ std::async functionality, we used a server with 36 physical cores Intel i7 CPUs running version 14 of the UBuntu operating system version 14 with the g++ compiler version 5.4.

A TABLE DRIVEN ALGORITHM TO ENABLE PARALLELISM ON ACCELERATORS

44The previous section explains how mathematical form of the various tail integrals arising in the study of electron-molecule scattering with Gaussian type functions can be decomposed, in general, to sums of overlap integrals of the type shown in Equation (6). In the initial sequential version of the code, a generic kernel was implemented for the overlap integrals and then this was called repeatedly within loops over pairs of functions. Figure 1 illustrates this relationship schematically. There are two distinct aspects to introducing parallelism to this computation. On the one hand, one can consider the coarse grain parallelism offered by the fact that each integral is independent of other integrals and we consider this in the next part of this section. On the other hand, one can use fine grain parallelism to optimize the computation within one integral. We present details of this at the end of this section.

Identifying parallelism

45This loop based approach originally designed for single CPU operation and in limited places exploited the fine grain parallelism offered by SSE units on Intel chips. The aim was to compute each integral, one after another, as efficiently as possible in a loop. Given that the computation of each integral is independent, we redesigned the code completely to be able to use multiple CPUs and/or accelerators to compute integrals in parallel. The key step to enable this was to define the overall algorithm to employ a table driven approach in which we separate the processing logic from the call to the kernel function. This can be expressed in pseudo-code as follows:

461. Scan the set of all basis functions and determine maximum indices i,j,k occurring in Equation (2) 2. Using the looping structure from the original code, processing all possible combinations of basis functions that generate non-zero integrals for one or more of the three types of integrals defined in Equations (6), (11), and (16). As explained previously, each kinetic energy and nuclear repulsion integral is expressed as a sum over overlap integrals. This step depends on the point group to which the nuclear framework belongs.

47In our code, we are limited to the Abelian point group D 2h ad its sub-groups. In the case of nuclear repulsion integrals, this means expanding the repulsion term (17) and giving multiple overlap type integrals. For each non-zero integral identified, enter index and exponent details into one row of the integrals table, which is sufficient information with which to compute the integral. The format of the table is illustrated in Figure 2 where data from one of the basis sets reported in Section 6.3 is used. Populating the rows of the table to define the complete set of required integrals requires only integer arithmetic, principally on the Cartesian powers of the primitive Gaussian functions, as well as logic operations. 4. The final step is to process the integrals table on the host to perform sum reductions needed to compute the kinetic or nuclear repulsion integrals.

Independent tasks: CPU (OpenCL and C++) and GPU

48The integrals table on the main CPU is best implemented using a struct of arrays (SoA) approach. in fact we use a C++ std:vector for each column because this is guaranteed to allocate contiguous memory for the elements of the vector. This facilitates transfer to the accelerator global memory, which we describe later, by simply copying the whole column to a pointer on the accelerator. This represents a relatively low cost compared to the computations therefore. Table 1 shows the maximum data speeds for the PCIe buses which connect to the peripherals. The alternative approach of using a defined struct for each row would present the potential problem that the memory pattern used by the compiler for the accelerator may not match that used on the host thereby making data copy operations alone impossible. To further optimize storage, we pack three integer indices into one 32 bit value using 10 bits per index. This exceeds any practical index value that arises in the sets of basis functions in common use today.

49On a multi-CPU shared memory system, the integrals can be computed by creating a number of asynchronous tasks, each with access to the integrals This is readily enabled by instantiating a vector of instances of the std::future class template. Each instance of std::future wraps the kernel function, gtolap_cpu(), which processes the integrals table in the way discussed in the previous paragraph (Table 2). We mapped this to the multi-core CPU using the std::async feature of C++11 with the policy std::launch::async. This means that the runtime continues to launch tasks in separate threads as long as there are unused CPUs available on the system. With modularized code, the use of the asynchronous features in C++ is a relatively straightforward process.

50A similar approach can be achieved on the CPU using OpenCL or equivalently on the GPU. The clEnqueueNDRangeKernel() method is used to launch multiple instances of the integration kernel on the platform, a one dimensional structure. Then each kernel determines its thread index and

Pre-computed integrals over the phi co-ordinate

51The integrals over the co-ordinate can be expressed analytically and they are reused several times throughout the computation of the full set of integrals. This means that it is computationally efficient to compute a table of all required integrals at the start of the execution and to reuse it continuously. The dimension of this is determined by summing the powers i,j,k for each basis function and finding the maximum value, maxl, over the whole set of functions. The number of integrals over the co-ordinate is then 2 maxl +1) 2 . The table is computed once and shipped to the global memory of each accelerator as a one off cost. It consumes only a few MB at most and is significantly smaller than the table defining the full set of integrals. The integrals over the and co-ordinates can also be expressed analytically and coded as sum reductions. There is no numerical quadrature required.

Pipelining for parallelism on the FPGA

52In the case of the FPGA, the preferred mechanism for parallelism is that the rows of the table are processed in a pipeline in contrast to the situation on the GPU and on the multi-core CPU. The key to achieving good performance from the FPGA implementation is to aim to have one loop iteration launched every clock cycle, technique. Loop carried dependencies can prevent this causing launched to be delayed by several clock cycles. The AOC compiler provided by Intel/Altera reports for each loop, when the -g flag is set,

53• operations that contribute the largest delay to the computation of the loop-carried dependency;

54• the launch frequency of a new loop iteration. The loop that computes the integral over the co-ordinate is identified above to add a latency of 8 clock cycles, while the loop which computes the integral over the radial co-ordinate reports a latency of 19 clock cycles. In both cases, these loops are written using an accumulator variable which holds, by the end of all iterations, the value of the relevant integral.

55The Programming Practices Guide suggests several strategies to remove this kind of loop carried dependency. We investigated the use of shift registers, a technique well-known to VHDL programmers but not generally suited to CPU implementations. Applying this technique means that instead of adding values to a single accumulator, within a loop, an array known as a shift register is first established and all its elements are set to zero. Then at each iteration of the loop, the following additional operations are performed with the shift register:

56• each newly computed value from the iteration is added to the element at the base of the array and the result placed at the top of the array;

57• all elements in the array are pushed down one location, step which overwrites the base element but duplicates the element at the top of the array.

58After the last iteration of the loop is complete, the elements in the shift register are summed, excluding the value at the top, to give the final result. This process can be implemented very efficiently on an FPGA and are widely used in streaming data applications such as network packet processing, digital signal processing, and image processing. The reason that shift registers are optimal on FPGAs stems from the fact that there is no complex address decoding required and that data movement can be enabled via dedicated connections between logic blocks in the fabric. Unlike the CPU implementation, there is no shared data bus. The integral over the co-ordinate can be expressed analytically as a sum over terms. In the CPU code, this is implemented in the following loop structure, where the label REAL_t is replaced by float or double as required when compiling and where angpart1 is the summation computed. This optimization is specific to the FPGA architecture. While the code works on CPU and GPU, it performs poorly on these architectures.

RESULTS

59We begin this section by discussing the resource consumption for different implementation on the FPGA. As we have pointed out earlier, only the double precision implementation can produce values that are suitable for use in modeling computations. However, we report some aspects of the implementation of single precision computations to illustrate the resource consumption on the FPGA. Computations reported on for the CPU and GPU are only using double precision. At the end of section, we turn our attention to performance gained from our implementations.

Data transfer to/from the accelerator

60We have explained earlier in the article that the algorithm is centered on a table of integrals. This is transferred to the accelerator before the launch of the compute kernels and one column, the computed values, is retrieved to the host when the execution of all kernels is completed. Table 4 reports the aggregate transfer times moving the integrals table between the accelerators for different size of problem. These figures can be compared to the row labeled Execution times in Table 5. The aggregate data transfer times are generally less than 10% of the total execution time.

Performance analysis

61We performed several calculations for the case of the nitrogen molecule with the nuclei fixed in its equilibrium configuration. We defined different basis sets of diffuse Gaussian functions located at the center of the module. We initially used a basis set from previous work and then extended this to include higher angular momentum terms. This extension generates more basis functions and therefore more integrals so that we can examine the scalability of the computation. Table 5 shows the number of non-zero integrals computed for various sizes of the basis sets. One of the limiting factors in our approach is to determine whether the table of integrals, which has been described above and an example presented in Table 2 90M integrals to be computed. As Table 2 shows this limit is reached with over 2000 basis functions. This limit could be overcome by dividing a larger table into sub-units and computing these in a loop. Figure 2 shows the time taken to compute the integrals for different number of basis functions.

62This figure includes, for each case, construction of the table on the host, the time to move the table to and from the FPGA, and the time spent on the FPGA computing the integrals. The solid line is a quadratic curve fitted to the data points. This has the form

63where x is the number of primitive basis functions. The shape of the graph suggests that there is a fixed time cost to move the data to and from the FPGA with a value of 1.967 seconds. As larger numbers of integrals are executed, this is amortized to an extent, however, still remains significant for 2000 functions representing 25% of the elapsed time for the whole computation. Table 6 presents the elapsed times in seconds for execution of the integral workload using the C++ std:::future language feature on the CPU. Within the limits of Amdahl's law, the results down each column of the table reflect the scaling enabled by used of additional CPUs. It is interesting to compare the execution of the code as a single for-loop versus using two asynchronous tasks, an experiment that allows us to gauge the cost of using std::async. Table 7 compares these results. It is not surprising that the cost of executing two separate tasks is more expensive for smaller workloads, corresponding to smaller numbers of basis functions. However, by

RELATED WORK

64This is the first article, in so far as we are aware to apply heterogeneous accelerator computing to the problem of integral evaluation in electron molecule scattering. GPU computing has previously been successfully applied to computation of molecular bound states where performance gains have of 180× in Hartree-Fock energy + gradient calculations have been observed. 22 The performance of the two electron integral evaluation in this work was studied using three different algorithms, well suited to the GPU architecture and distinct from the many optimal CPU approaches. 15 A combined CPU-GPU algorithm, enabling strong scaling parallelization on inhomogeneous compute clusters, was developed by Kussman and Ochensfeld 23 to evaluate two-electron contributions occurring in Hartree Fock and hybrid density functional theory. Their approach allows an efficient use of CPUs and GPUs simultaneously. They pointed out that the different architectures demand conflicting strategies in order to ensure efficient program execution.

65In so far as we are aware, FPGAs have not been used for integration of GTFs in quantum chemistry. On the other hand, there is a large literature on using FPGAs to calculate the quantum mechanical properties of N-body systems, such as in quantum Monte Carlo techniques 24 and in molecular dynamics. 25 The suitability of a hardware approach for molecular dynamics is seen in the Anton system which is a set of customized application specific integrated circuits (ASICs) developed specifically for molecular dynamics simulations on proteins and biological macro-molecules. 26

CONCLUSIONS AND FUTURE DIRECTIONS

66The aim of this article is to examine the viability of applying OpenCL to enable some existing computation kernels on modern heterogeneous accelerators. We chose a FORTRAN program for the evaluation of tail integrals over diffuse Gaussian type functions and converted this into ANSI C++14, using that as a basis from which to develop an OpenCL implementation. The program was taken from a large base of code known as the UK molecular R-matrix suite, a code base that has been in continuous development for 40 years in the UK. This code base was evolved from the IBM Alchemy I program suite for molecular bound state computations, a package on which development began in the Theoretical Chemistry Group at the IBM San Jose laboratory in the late 1960s.

67The original code implementation used a kernel function called within a dense set of driver loops. The loop iterations were controlled by the quantum numbers of the diffuse Gaussian functions in the basis set. This analysis is completed based on logical and integer arithmetic and proceeds at very high speed on the CPU. We redesigned the algorithm to a data table driven one, centered on the idea of preparing a table of data where each row required independent execution of a kernel function. The entries in each row of the table are derived from the same driver loops in the original algorithm. The table is copied to global memory on the accelerator before launching the independent evaluation of each row as kernel instances on the accelerator.

68We executed this implementation on GPU and FPGA platforms, using an OpenCL SDK specific to each platform, in order to investigate the portability and performance of the implementation. These two accelerators have differing approaches to code execution and we reported on specific optimizations relevant to each architecture. The data-driven approach also works on the host CPU where the kernel instances can be considered as tasks and we have reported two different ways of achieving this. On the one hand, the OpenCL code used on the accelerators can also be used. On the other hand, the C++ language now incorporates mechanisms to easily manage this kind of task based model. The C++ language is adding increasing support for parallelism with the C++17 standard adding support for parallel implementations of the standard template library (STL). Looking forward, a concept known as an executor is proposed as as a basic building block for extension of the C++ language to include heterogeneous accelerators; however, this is not expected to appear until completion of the C++23 standard. 27 However, early implementations of the proposals for executors are beginning to appear, such as in the HPX runtime which is based on C++. 28 There are clearly a number of ways in which the research we have reported can be extended. The partitioning of operations into tabular data, or even matrix, format with execution of processing functions on each element is a pattern that can be readily identified in many computational science codes. We plan to investigate this approach in other problem domains therefore. A further research angle is to investigate the viability of using dynamic selection of precision, a feature that has been investigated by Martinez and co-workers 29 using GPUs for structure calculations.

참고문헌 23건

  1. Computational Aspects of Direct SCF and MCSCF Methods Springer eBooks · Springer Nature · 1984 10.1007/978-94-009-6451-8_7
  2. FPGA acceleration of a quantum Monte Carlo application Parallel Computing · Elsevier BV · 2008 10.1016/j.parco.2008.01.009
  3. Electron–molecule collision calculations using the R-matrix method Physics Reports · Elsevier BV · 2010 10.1016/j.physrep.2010.02.001
  4. Dynamic Precision for Electron Repulsion Integral Evaluation on Graphical Processing Units (GPUs) Journal of Chemical Theory and Computation · American Chemical Society · 2011 10.1021/ct100701w
  5. Use of double cosets in constructing integrals over symmetry orbitals The Journal of Chemical Physics · American Institute of Physics · 1975 10.1063/1.430484
  6. Encyclopedia of Computational Chemistry Journal of Molecular Modeling · Springer Science+Business Media · 1999 10.1007/s0089490050141
  7. The reduced multiplication scheme of the Rys quadrature and new recurrence relations for auxiliary function based two-electron integral evaluation The Journal of Chemical Physics · American Institute of Physics · 1991 10.1063/1.461610
  8. Quantum Chemistry on Graphical Processing Units. 3. Analytical Energy Gradients, Geometry Optimization, and First Principles Molecular Dynamics Journal of Chemical Theory and Computation · American Chemical Society · 2009 10.1021/ct9003004
  9. <b><i>R</i></b>-matrix calculations for polyatomic molecules: electron scattering by Journal of Physics B Atomic Molecular and Optical Physics · IOP Publishing · 1997 10.1088/0953-4075/30/18/010
  10. Electron scattering by nitrogen molecules Journal of Physics B Atomic and Molecular Physics · IOP Publishing · 1987 10.1088/0022-3700/20/17/032
  11. A framework for rapid system-level exploration, synthesis, and programming of multimedia MP-SoCs 2007 10.1145/1289816.1289823
  12. Comparing the implementation of two-dimensional numerical quadrature on GPU, FPGA and ClearSpeed systems to study electron scattering by atoms Concurrency and Computation Practice and Experience · Wiley · 2011 10.1002/cpe.1733
  13. Electronic wave functions - I. A general method of calculation for the stationary states of any molecular system Proceedings of the Royal Society of London A Mathematical and Physical Sciences · Royal Society · 1950 10.1098/rspa.1950.0036
  14. Programming Challenges for the Implementation of Numerical Quadrature in Atomic Physics on FPGA and GPU Accelerators 2010 10.1109/ccgrid.2010.30
  15. Quantum Chemistry on Graphical Processing Units. 1. Strategies for Two-Electron Integral Evaluation Journal of Chemical Theory and Computation · American Chemical Society · 2008 10.1021/ct700268q
  16. Electronic Structure Calculations on Graphics Processing Units Wiley eBooks · Wiley · 2016 10.1002/9781118670712
  17. Architecture of an FPGA accelerator for molecular dynamics simulation using OpenCL 2016 10.1109/icis.2016.7550743
  18. Call for another Seward: Optimization of F12 integral evaluation 2011
  19. Hybrid CPU/GPU Integral Engine for Strong-Scaling <i>Ab Initio</i> Methods Journal of Chemical Theory and Computation · American Chemical Society · 2017 10.1021/acs.jctc.6b01166
  20. HPX Smart Executors 2017 10.1145/3152041.3152084
  21. UKRmol+: A suite for modelling electronic processes in molecules interacting with electrons, positrons and photons using the R-matrix method Computer Physics Communications · Elsevier BV · 2019 10.1016/j.cpc.2019.107092
  22. Non-Adiabatic Effects in Vibrational Excitation and Dissociative Recombination Springer eBooks · Springer Nature · 1995 10.1007/978-1-4757-9797-8_9
  23. Collisions with Molecules Springer series on atomic, optical, and plasma physics · Springer Nature · 2010 10.1007/978-3-642-15931-2_11