Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™...

56
Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer October 29, 2014 * Other names and brands may be claimed as the property of others.

Transcript of Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™...

Page 1: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Intel Confidential — Do Not Forward

Optimizing LAMMPS* for Intel® Xeon Phi™ CoprocessorsW. Michael Brown

HPC Life Sciences Architect/Engineer

October 29, 2014

* Other names and brands may be claimed as the property of others.

Page 2: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Legal DisclaimersINFORMATION IN THIS DOCUMENT IS PROVIDED IN CONNECTION WITH INTEL PRODUCTS. NO LICENSE, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, TO ANY INTELLECTUAL PROPERTY RIGHTS IS GRANTED BY THIS DOCUMENT. EXCEPT AS PROVIDED IN INTEL'S TERMS AND CONDITIONS OF SALE FOR SUCH PRODUCTS, INTEL ASSUMES NO LIABILITY WHATSOEVER AND INTEL DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY, RELATING TO SALE AND/OR USE OF INTEL PRODUCTS INCLUDING LIABILITY OR WARRANTIES RELATING TO FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.

A "Mission Critical Application" is any application in which failure of the Intel Product could result, directly or indirectly, in personal injury or death. SHOULD YOU PURCHASE OR USE INTEL'S PRODUCTS FOR ANY SUCH MISSION CRITICAL APPLICATION, YOU SHALL INDEMNIFY AND HOLD INTEL AND ITS SUBSIDIARIES, SUBCONTRACTORS AND AFFILIATES, AND THE DIRECTORS, OFFICERS, AND EMPLOYEES OF EACH, HARMLESS AGAINST ALL CLAIMS COSTS, DAMAGES, AND EXPENSES AND REASONABLE ATTORNEYS' FEES ARISING OUT OF, DIRECTLY OR INDIRECTLY, ANY CLAIM OF PRODUCT LIABILITY, PERSONAL INJURY, OR DEATH ARISING IN ANY WAY OUT OF SUCH MISSION CRITICAL APPLICATION, WHETHER OR NOT INTEL OR ITS SUBCONTRACTOR WAS NEGLIGENT IN THE DESIGN, MANUFACTURE, OR WARNING OF THE INTEL PRODUCT OR ANY OF ITS PARTS.

Intel may make changes to specifications and product descriptions at any time, without notice. Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined". Intel reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising from future changes to them. The information here is subject to change without notice. Do not finalize a design with this information.

The products described in this document may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.

Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.

Copies of documents which have an order number and are referenced in this document, or other Intel literature, may be obtained by calling 1-800-548-4725, or go to: http://www.intel.com/design/literature.htm

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products.

Intel does not control or audit the design or implementation of third party benchmarks or Web sites referenced in this document. Intel encourages all of its customers to visit the referenced Web sites or others where similar performance benchmarks are reported and confirm whether the referenced benchmarks are accurate and reflect performance of systems available for purchase.

Relative performance is calculated by assigning a baseline value of 1.0 to one benchmark result, and then dividing the actual benchmark result for the baseline platform into each of the specific benchmark results of each of the other platforms, and assigning them a relative performance number that correlates with the performance improvements reported.

SPEC, SPECint, SPECfp, SPECrate. SPECpower, SPECjAppServer, SPECjbb, SPECjvm, SPECWeb, SPECompM, SPECompL, SPEC MPI, SPECjEnterprise* are trademarks of the Standard Performance Evaluation Corporation. See http://www.spec.org for more information. TPC-C, TPC-H, TPC-E are trademarks of the Transaction Processing Council. See http://www.tpc.org for more information.

Hyper-Threading Technology requires a computer system with a processor supporting HT Technology and an HT Technology-enabled chipset, BIOS and operating system. Performance will vary depending on the specific hardware and software you use. For more information including details on which processors support HT Technology, see here

Intel® Turbo Boost Technology requires a Platform with a processor with Intel Turbo Boost Technology capability. Intel Turbo Boost Technology performance varies depending on hardware, software and overall system configuration. Check with your platform manufacturer on whether your system delivers Intel Turbo Boost Technology. For more information, see http://www.intel.com/technology/turboboost

No computer system can provide absolute security. Requires an enabled Intel® processor and software optimized for use of the technology. Consult your system manufacturer and/or software vendor for more information.

Intel processor numbers are not a measure of performance. Processor numbers differentiate features within each processor family, not across different processor families: Go to: Learn About Intel® Processor Numbers

Intel product plans in this presentation do not constitute Intel plan of record product roadmaps. Please contact your Intel representative to obtain Intel’s current plan of record product roadmaps.

Copyright © 2014 Intel Corporation. All rights reserved. Intel, the Intel logo, Xeon and Intel Core are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. All dates and products specified are for planning purposes only and are subject to change without notice

*Other names and brands may be claimed as the property of others. 2

Page 3: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Risk Factors

The above statements and any others in this document that refer to plans and expectations for the third quarter, the year and the future are forward-looking statements that involve a number of risks and uncertainties. Words such as “anticipates,” “expects,” “intends,” “plans,” “believes,” “seeks,” “estimates,” “may,” “will,” “should” and their variations identify forward-looking statements. Statements that refer to or are based on projections, uncertain events or assumptions also identify forward-looking statements. Many factors could affect Intel’s actual results, and variances from Intel’s current expectations regarding such factors could cause actual results to differ materially from those expressed in these forward-looking statements. Intel presently considers the following to be the important factors that could cause actual results to differ materially from the company’s expectations. Demand could be different from Intel's expectations due to factors including changes in business and economic conditions; customer acceptance of Intel’s and competitors’ products; supply constraints and other disruptions affecting customers; changes in customer order patterns including order cancellations; and changes in the level of inventory at customers. Uncertainty in global economic and financial conditions poses a risk that consumers and businesses may defer purchases in response to negative financial events, which could negatively affect product demand and other related matters. Intel operates in intensely competitive industries that are characterized by a high percentage of costs that are fixed or difficult to reduce in the short term and product demand that is highly variable and difficult to forecast. Revenue and the gross margin percentage are affected by the timing of Intel product introductions and the demand for and market acceptance of Intel's products; actions taken by Intel's competitors, including product offerings and introductions, marketing programs and pricing pressures and Intel’s response to such actions; and Intel’s ability to respond quickly to technological developments and to incorporate new features into its products. The gross margin percentage could vary significantly from expectations based on capacity utilization; variations in inventory valuation, including variations related to the timing of qualifying products for sale; changes in revenue levels; segment product mix; the timing and execution of the manufacturing ramp and associated costs; start-up costs; excess or obsolete inventory; changes in unit costs; defects or disruptions in the supply of materials or resources; product manufacturing quality/yields; and impairments of long-lived assets, including manufacturing, assembly/test and intangible assets. Intel's results could be affected by adverse economic, social, political and physical/infrastructure conditions in countries where Intel, its customers or its suppliers operate, including military conflict and other security risks, natural disasters, infrastructure disruptions, health concerns and fluctuations in currency exchange rates. Expenses, particularly certain marketing and compensation expenses, as well as restructuring and asset impairment charges, vary depending on the level of demand for Intel's products and the level of revenue and profits. Intel’s results could be affected by the timing of closing of acquisitions and divestitures. Intel's results could be affected by adverse effects associated with product defects and errata (deviations from published specifications), and by litigation or regulatory matters involving intellectual property, stockholder, consumer, antitrust, disclosure and other issues, such as the litigation and regulatory matters described in Intel's SEC reports. An unfavorable ruling could include monetary damages or an injunction prohibiting Intel from manufacturing or selling one or more products, precluding particular business practices, impacting Intel’s ability to design its products, or requiring other remedies such as compulsory licensing of intellectual property. A detailed discussion of these and other factors that could affect Intel’s results is included in Intel’s SEC filings, including the company’s most recent reports on Form 10-Q, Form 10-K and earnings release.

Rev. 7/17/13

Page 4: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Optimization Notice

4

Optimization Notice

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel.

Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804

Page 5: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

5

Agenda

• Basics on molecular dynamics and parallelization

• Introduction to LAMMPS*

• Optimizations in LAMMPS* for CPUs and Coprocessors

• Running LAMMPS* with Intel® Xeon Phi™ Coprocessors

• Performance results from LAMMPS* Optimizations

• Progress in other molecular dynamics codes

Page 6: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Configuration Notes for Performance Measurements in this Talk

6

Page 7: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Endeavor† Cluster Node Configuration / Compilers

7

CPU: 2-socket/24 cores/48 threads

• Processor: Intel® Xeon® processor E5-2697 V2 @ 2.70GHz (12 cores) with Intel® Hyper-Threading Technology4

Coprocessor: Intel® Xeon Phi™ coprocessor 7120P

• 61 cores @ 1.238 GHz, 4-way Intel® Hyper-Threading Technology, Memory: 15872 MB

• Intel® Many-core Platform Software Stack Version 2.1.6720-19

Network: InfiniBand* Architecture Fourteen Data Rate (FDR)

Operating System: Red Hat Enterprise Linux* 2.6.32-358.el6.x86_64.crt1 #4 SMP Fri May 17 15:33:33 MDT 2013 x86_64 x86_64 x86_64 GNU/Linux

Memory: 64GB

LAMMPS* Compilation Notes

• Intel® Compiler 2013 SP1.1.106 (icc version 14.0.1)

• Intel® MPI* 5.0.0.028

• Single precision Intel® MKL FFTs

• -g -O3 -xAVX -fno-alias -ansi-alias -restrict -DLAMMPS_MEMALIGN=64 -override-limits -offload-option,mic,compiler,"-fp-model fast=2 -mGLOB_default_function_attrs=\"gather_scatter_loop_unroll=4\""

* Other names and brands may be claimed as the property of others.

† http://www.top500.org/system/176908

Page 8: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Stampede† Cluster Node Configuration / Compilers

8

CPU: 2-socket/16 cores/HT Disabled

• Processor: Intel® Xeon® processor E5-2680 (8 cores) with Intel® Hyper-Threading Technology4

disabled

Coprocessor: Intel® Xeon Phi™ coprocessor SE10P

• 61 cores @ 1.1 GHz, 4-way Intel® Hyper-Threading Technology, Memory: 8 GB

• Intel® Many-core Platform Software Stack Version 3.3

Network: InfiniBand* Architecture Fourteen Data Rate (FDR)

Operating System: CentOS* 6.5

Memory: 32GB DDR3 1600

LAMMPS* Compilation Notes

• Intel® Compiler 2013 SP1.1.106 (icc version 14.0.1)

• MVAPICH2* 2.0b

• Single precision Intel® MKL FFTs

• Compile flags: -g -O3 -xAVX -fno-alias -ansi-alias -restrict -DLAMMPS_MEMALIGN=64 -override-limits -offload-option,mic,compiler,"-fp-model fast=2 -mGLOB_default_function_attrs=\"gather_scatter_loop_unroll=4\""

* Other names and brands may be claimed as the property of others.

† http://www.top500.org/system/177931

Page 9: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Molecular Dynamics in a Nutshell

9

Page 10: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

10

Classical Molecular Dynamics

Objective: Simulate the time evolution of a system of atoms or other particles

Input:

Initial particle positions/velocities and other model-specific parameters (charge, type, rotation, bond topology, etc.)

Equation for the energy of the system

Boundary conditions (periodic, fixed, shrink-wrapped, reflecting, etc.)

Ensemble to sample from

– Microcanonical (NVE) Ensemble – Energy/Volume constant, Pressure/Temp vary

– Canonical (NVT) Ensemble – Volume/Temp constant, Pressure/Energy vary

– Isothermal/Isobaric (NPT) Ensemble – Pressure/Temp constant, Volume/Energy vary

Statistics computations and output

* Other names and brands may be claimed as the property of others.

Page 11: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

11

Basic MD Algorithm

For an iteration of the simulation,

Calculate the force on each particle as the gradient of the energy with respect to position/rotation.

Time integration to calculate the new positions/velocities of the particles with respect to the force

– May require calculation of temperature or pressure to adjust the velocities or simulation box size

Calculation of relevant statistics

Output of data and restart files

Page 12: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Energy of the System (Potential/Force Field)

12

Energy for classical molecular systems typically decomposed into:

Non-bonded (van der Waals) energy caused by induced/fluctuating dipoles that occur as atoms approach each other

Coulombic/electrostatic energy (from fitting force-field with static partial-charge on the atoms)

Bonded interactions including stretching, angle, dihedral energies

Functional form and parameters vary depending on the force-field Note: The terms are independent

allowing potential for task-based parallelism

Page 13: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Calculating the Energy/Forces (1)

13

Bonded interactions

O(N)

Typically a small fraction of the run time

Page 14: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Calculating the Energy/Forces (2)

14

van der Waals and electrostatic energies are due to interactions between all particles in the system

Typically, for biological force fields, decomposed as a sum over the energy between all pairs in the system (2-body potential)

For van der Waals with Lennard-Jones, energy falls off rapidly with distance (r^-6)

– Short-range problem

For electrostatics, energy falls off slowly (r^-1)– Long-range problem

Page 15: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Short-range problem, O(N2) -> O(N)

15

Use a cutoff distance for van der Waals interactions such that the energy is 0 between atoms separated by a larger distance (cutoff distance)

Keep a list of atoms that might fall within the cutoff for each atom (Neighbor list)

The list should include atoms at a distance further than the cutoff (skin distance) so that it does not need to be rebuilt every time step (typically every 10 timesteps)

1. Bin the atoms into cells (cell list), O(N)

2. For a given atom, check which atoms are within the cutoff+skin distance and add to list (verlet list), O(N)

Page 16: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

16

Long-range Problem (1)

O(N2) for all pairs…

Not practical to evaluate due to slow decay of E(r) (remember periodic boundaries)

Instead, Ewald summation is used: split E into two functions, Er and Ek

Er should be negligible beyond some cutoff distance

– Evaluate with short-range van der Waals

Ek should be slowly varying at all distances

– Evaluate with Poisson summation using Fourier transform with few K-vectors

E= Er + Ek

Page 17: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Long-range Problem (2)

17

Ewald Summation

Best implementations are O(N3/2)

Particle-Mesh Methods

Discretize the problem to allow for FFT use

Smooth Particle Mesh Ewald (SPME) or Particle-Particle Particle-Mesh (P3M)

1. Spread charges from atoms onto mesh

2. Poisson solve (3D FFTs on mesh)

3. Interpolate energy/force from mesh

O(MlogM) for M mesh points (M ≈ N) is typical

Page 18: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Basics on Parallelization – Distributed Memory

18

Typically a spatial decomposition where physical domain divided into subdomains, one per MPI task

Each task computes forces on atoms in its subdomain using info from nearby tasks (atoms at the borders

within the cutoff+skin [ghost atoms] are stored on both tasks)

Atoms "carry along" molecular topology as they migrate to new tasks

Communication via nearest-neighbor 6-way stencil

Advantages:

communication scales sub-linear as (N/P)2/3 (for large problems)

memory is optimal N/P

Collective Communications:

Particle-Mesh methods require effectively all-to-all communication

Thermostats/Barostats/Global Statistics can require collectives

Page 19: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Basics on Parallelization – Shared Memory

19

OpenMP/OpenCL/CUDA

Can also use a spatial decomposition with data privatization

Atom/force decompositions introduce data dependencies

Tradeoffs between data privatization/redundant computation/atomics

For example, if the number of active threads is small compared to the atom count, data privatization w/ reduction can be used (each thread uses its own array for the force)

If the number of threads is large, redundant computation can be used– For 2-body potentials (e.g. Lennard-Jones for van der Waals), “full” neighbor lists can be used

– Ignore the fact that we only have to compute the energy/force/virial term once for each pair of atoms.

– Double the size of the neighbor list so that if atom a is in b’s neighbor list, b is also in a’s.

– The result of this is double the computation for energies/forces/virials

– Removes all memory conflicts for force updates

– Approach used in GPU implementations

Page 20: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

20

Other shared memory performance options/trade-offs

• Vectorization• AoS vs SoA• Inner loop vectorization vs outer loop vectorization vs both• Neighbor-lists “chunked” by vector widths

• Verlet lists vs cell lists• Tabulation/interpolation vs explicit force-field equations

Must be careful here, subtle stat mech issues and energy conservation issues

Page 21: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

LAMMPS* in a NutshellLarge-scale Atomic/Molecular Massively Parallel Simulator

http://lammps.sandia.gov

Lead developer: Steve Plimpton, Sandia National Laboratories

21* Other names and brands may be claimed as the property of others.

Page 22: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

22

LAMMPS*

• Classical Molecular Dynamics Package

• C++, GPL License, Build as Library for use in other Codes, Stand-alone executable, or script through Python*

• 32K downloads, 8K mail list postings, > 5000 citations

• Popular due to its versatility for supporting a wide range of simulation types, potentials, etc. and for the ease with which new features can be added

• >500K lines of code

• Scalable performance with MPI*/OpenMP* and a variety of long-range solver options

• Ewald, Particle-Particle Particle-Mesh with several variants, Multilevel Summation

* Other names and brands may be claimed as the property of others.

Page 23: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

LAMMPS* Potentials/Force-Fields

23

• Biomolecules: • CHARMM*, AMBER*, OPLS, COMPASS (class 2), long-

range Coulombics via PPPM, point dipoles, ...

• Polymers: • all-atom, united-atom, coarse-grain (bead-spring FENE),

bond-breaking, …

• Materials: • EAM and MEAM for metals, Buckingham, Morse, Yukawa,

Stillinger-Weber, Tersoff, COMB, SNAP, ...

• Chemistry: • AI-REBO, REBO, ReaxFF, eFF

• Mesoscale: • granular, DPD, Gay-Berne, colloidal, peridynamics,

DSMC...

• Hybrid: • can use combinations of potentials for hybrid systems:

water on metal, polymers/semiconductor interface, colloids in solution, …

Solid Mechanics Materials

Science

Chemistry

BiophysicsGranular Flow

* Other names and brands may be claimed as the property of others.

Page 24: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

24

Modularity in LAMMPS*

LAMMPS Objects

atom styles: atom, charge, colloid, ellipsoid, point dipole

pair styles: LJ, Coulomb, Tersoff, ReaxFF, AI-REBO, COMB, MEAM, EAM,

Stillinger-Weber,

fix styles: NVE dynamics, Nose-Hoover, Berendsen, Langevin, SLLOD,

Indentation,...

compute styles: temperatures, pressures, per-atom energy, pair correlation

function, mean square displacements, spatial and time averages

Goal: All computes work with all fixes work with all pair styles work with all atom

styles

* Other names and brands may be claimed as the property of others.

Page 25: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Simulation Profile for Rhodopsin Benchmark in LAMMPS*

25

• Simulates the movement of a protein in the retina that plays an important role in the perception of light

• Simulation is in a solvated lipid bilayer using the CHARMM* force field

• Particle-Particle Particle-Mesh

• SHAKE* constraints

• Temperature is 300K

• Pressure of 1 atm

Pair62%

Bond3%

Kspce Mesh12%

Kspce FFT1%

Neigh13%

Comm3%

Other6%

Time BreakdownRhodopsin Protein, 256K Atoms, Intel® Xeon® Xeon

Endeavor - E5-2697 Processor v2 (2S), 48 MPI

Pair

Bond

Kspce Mesh

Kspce FFT

Neigh

Comm

Other

* Other names and brands may be claimed as the property of others.

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Perfo rmance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

Page 26: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Intel® Package for LAMMPS

26* Other names and brands may be claimed as the property of others.

Page 27: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

27

Objectives

Modify compute intensive routines to support vectorization

• Increasingly important for power-efficient performance on new hardware

Add support for single precision and mixed precision calculations in addition to full double precision

• Reduces random-access memory latencies, doubles the vector width, and allows for fast transcendentals on Intel® Xeon Phi™ coprocessors with use of the Quadratic Minimax Polynomial approximation

Add support for offload to Intel® Xeon Phi™ coprocessors

• Exploit power-efficient many-core processors on HPC clusters with scalable performance

Future enhancements planned

* Other names and brands may be claimed as the property of others.

Page 28: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

28

Intel® Package Optimizations (1)

Align all important memory allocations (and thread offsets into shared allocations) to 64B boundaries

• Vectorization performance is better for aligned data

• Data transfer between the host memory and coprocessor is faster for aligned data

• Eliminates false sharing between multiple threads

• Two threads will never share the same cache line for force writes

Accomplished in LAMMPS* with the pre-existing LAMMPS_MEMALIGNpreprocessor define for heap allocations and __declspec(align(64)) for important allocations on stack.

* Other names and brands may be claimed as the property of others.

Page 29: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

29

Intel® Package Optimizations (2)

Add additional new buffers for atom data (position, type, forces, energies, torques, virials, etc.) that support single, mixed, and double precision, allow for easy offload, and support efficient vectorization.

• There is a penalty for packing/casting the data every timestep, but:

• Mixed precision is faster because it uses single precision for most calculations but double precision for error-sensitive operations/variables such as accumulation

• Eliminating fragmentation and pointer chasing in memory allocations makes offload easier

• Storing atom data as {x, y, z, type} rather than {x, y, z} allows for more efficient vectorization with random-access for Intel® Xeon® processors with Intel®Advanced Vector Extensions (AVX) and keeps the data for an atom on a single cache line.

• Duplicate force/energy arrays allows for overlapping the calculations for different force-field terms with concurrent calculations on the host and coprocessor

* Other names and brands may be claimed as the property of others.

Page 30: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

30

Intel® Package Optimizations (3)

Modify the code to allow the compiler to vectorize important routines

• Use the -opt-report compiler options to get information about what the compiler does for specific loops

• Use the #pragma simd directive to help the compiler in loops with data dependencies

• Vectorization of the pairwise force inner-loops (loop over neighbors for a single atom) is guaranteed not to result in memory collisions in molecular dynamics because you will never have the same atom (memory location) more than once in a neighbor list

• Need to use a reduction clause to simd to tell the compiler to add the results for the energy/virial terms together into a single memory location at the end of the loop

* Other names and brands may be claimed as the property of others.

Page 31: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

31

Intel® Package Optimizations (4)

Modify the code to allow the compiler to vectorize important routines

• Vectorization for Intel® Xeon® processors and Intel® Xeon Phi™ coprocessors can result in different code for masking out computations within conditional branches

• For compiler vectorization in MD for Intel® AVX, it can be more efficient to zero out atoms outside the cutoff explicitly rather than using large conditional regions

• Should not be necessary with version 15 compiler

• If the number of loop iterations (trip count) is not an even multiple of the vector width, separate code will be executed to handle the last iteration of the vectorized loop (the loop remainder)

• In a few cases, this can be very inefficient

• New versions of Intel® VTune™ Amplifier will tell you about this

• In LAMMPS*, the neighbor list is padded to be a multiple of the vector width with an extra atom that is guaranteed to never be within the cutoff of any other atom

* Other names and brands may be claimed as the property of others.

Page 32: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

32

Using Intel® Xeon Phi™ Coprocessors

The coprocessors run a full-service Linux operating system allowing several options for using the coprocessor in HPC systems.

• Native mode - code is run solely on the coprocessors without involving the host processor

• Symmetric mode - MPI tasks run on both the CPUs and the coprocessor

• Offload mode - the host offloads some of the work to be performed on the coprocessor.

The best choice will depend upon a number of factors, but for legacy HPC software, “offload” provides some advantages in that optimizations can be focused on select compute-intensive routines without consideration or alteration of the distributed memory parallelization. Offload mode is used here.

Page 33: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

33

Intel® Package Optimizations (5)

Modify the code to support offload to the coprocessor with offload directives

• Offload neighbor-list build and short-range force computation

• Routines that dominate simulation profile and have a high degree of concurrency that can be parallelized.

• Avoid having to transfer neighbor list data every timestep

• Use the CPUs and the coprocessors and exploit the fact that different terms in the force-field are independent

• Support offloading a fraction of the neighbor-list build and force calculation – use the CPUs for part of the computation too.

• Asynchronous (non-blocking) data transfer and offload with the signal clause.

• Use the same C++ routine for execution on the CPU and the coprocessor with the if clause.

• Exploit independent force-field calculations by making the offload concurrent with bonded terms, long-range calculations, and some MPI* communications

* Other names and brands may be claimed as the property of others.

Page 34: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

34

Intel® Package Optimizations (6)

Use thread affinity on the coprocessor to allow for arbitrary MPI*/OpenMP* configurations.

• KMP_PLACE_THREADS + MIC_ENV_PREFIX or kmp_set_affinity_mask_proc

• Divide up the hardware threads between the MPI tasks running on each node and assign a unique set to each MPI task

Avoid doing memory allocation on coprocessor within a loop

• Allocate once and grow only if necessary using the alloc_if and free_if clauses

Avoid unnecessary repeated data transfers within a loop

• For constant atom data such as charge and type, only transfer if the atom list has changed (nocopy/length) clause

* Other names and brands may be claimed as the property of others.

Page 35: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

35

Intel® Package Optimizations (7)

Offload only the atoms that are needed

• Neighbor list build keeps track of the maximum atom used in a neighbor list for the atoms being offloaded.

• Only transfer data for atoms needed and only do force accumulation for those atoms

• Option to build neighbor-list for offload without any ghost atoms

• In this case, ghost atoms never appear in a neighborlist for an atom on the coprocessor. The host loops over all atoms, and for atoms that were offloaded, only ghost terms are evaluated.

• Coprocessor can continue computations while host is doing MPI* communication

* Other names and brands may be claimed as the property of others.

Page 36: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

36

Intel® Package Optimizations (8)

Option for dynamic load balancing

• Time computations on coprocessor and host

• Adjust the amount of work being offloaded accordingly

Page 37: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

37

Intel® Package Files

intel_preprocess.h - Preprocessor directives including defines for vector width and some macros

intel_buffers.h/cpp - Templated class (single/mixed/double precision) to hold new data structures for atom data

fix_intel.h/cpp - Class derived from LAMMPS* ‘fix’ base class. These classes have initialization and setup routines that are called when the fix is enabled in an input script, along with routines that are called every timestep. This class handles memory allocation for new atom data structures on host and coprocessor and the synchronization to copy force, energy, virial, and torque data back from the coprocessor if available.

* Other names and brands may be claimed as the property of others.

Page 38: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

38

Intel® Package Files

neigh_half_bin_intel.cpp - Neighbor list build routines modified to use new atom data structures and option to build lists without ghost atoms. Routines are called twice, first with an offload flag to start work on the coprocessor and again without to start work on the CPUs.

pair_*.h/cpp - Intel® package routines for short-range calculations modified to use new atom data structures with vectorization. Routines are called twice, once with offload flag to use both CPU and coprocessor.

Page 39: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Intel® Package Offload Simulation Profile

39

Rhodopsin benchmark scaled to 256K atoms

• Y-axis is time

• The colors in the CPU and Coprocessorcolumns at any one time represent the simultaneous operations on the CPU and the coprocessor

• 24 MPI tasks, each using 10 threads on coprocessor

• Endeavor - 2S Intel® Xeon® processor E5-2697 v2 + Intel® Xeon Phi™ coprocessor 7120A

0

1

2

3

4

5

6

7

CPU Coprocessor

Idle

Data Cast/Pack

Async Offload Latency

Data Transfer

Neigh

Pair

Data Transfer

Bond

K-Space Mesh Stencil

K-Space FFT

Idle

Imbalance

MPI

Other

Idle

* Other names and brands may be claimed as the property of others.

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Perfo rmance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

Page 40: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

40

Advantages of Intel® Package vs GPU Package (1)

• Neighbor-list offload for simulation in triclinic boxes

• Same code for routines run on the CPU and coprocessor (with or without offload)

• Optimizations for Intel® Xeon Phi™ coprocessors resulted in faster performance on Intel® Xeon® processors (up to 4.7X)

• GPU package uses different algorithms and different code/language

• Support for both ‘newton’ settings allows for more flexibility for new force-fields

• Improved flexibility for heterogeneous calculations

• Intel® Xeon Phi™ offload not limited to 16 MPI* tasks on CPU (CUDA*-MPS limitation)

• Intel® package supports OpenMP* with multiple threads on the CPU (GPU package does not use OpenMP)

• MPI* tasks sharing coprocessor are able to get exclusive core affinity

* Other names and brands may be claimed as the property of others.

Page 41: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

41

Advantages of Intel® Package vs GPU Package (2)

• More options for overlap of MPI* communications and computation

• Build process is simpler and does not require building a separate library for coprocessor routines

• One compiler/Makefile for everything

• Precision mode (single, mixed, or double) can be switched at run-time without rebuilding

• Package written in standard C++ with OpenMP*

• Offload directives used for the coprocessor

* Other names and brands may be claimed as the property of others.

Page 42: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

42

Using the Intel® Package with LAMMPS*

Included with the main LAMMPS* distribution.

Build process is the same

Use [make yes-USER-INTEL] before building to install Intel® package, similar to other packages

Use the -sf command-line option in LAMMPS* to enable the Intel® package from the command-line or edit the input script as shown on the next page

* Other names and brands may be claimed as the property of others.

Page 43: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

43

Using the Intel® Package with LAMMPS*

# Rhodopsin model

package intel 1 mode mixed balance -1

package omp 0

suffix intel

units real

neigh_modify delay 5 every 1

# ...

timestep 2.0

run 10

run 100

Select floating-point precision mode (mixed recommended):

{ single, mixed, double }

Choose fraction of work to offload to coprocessor.

0.0 Run optimized routines without using coprocessor.

0.5 Calculations for half of the atoms are on coprocessor.

-1 Fraction adjusted automatically by load balancer

For benchmarking with short runs, add a warm up-run so load balancer and other startup penalties are not included in time.

Choose number of coprocessors to use on each node.

* Other names and brands may be claimed as the property of others.

Page 44: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Performance results with the Intel® Package

44

Page 45: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

45

• Simulates the movement of a protein in the retina that plays an important role in the perception of light

• Simulation is in a solvated lipid bilayer using the CHARMM* force field• Particle-Particle Particle-Mesh • SHAKE* constraints• Temperature is 300K• Pressure of 1 atm

• Available in LAMMPS* repository

• Intel optimizations resulted in 20% performance improvements on Stampede CPUs

• With use of coprocessors, performance improvements up to 2.2X compared to the baseline code

0.50

1.00

2.00

4.00

8.00

16.00

32.00

1 2 4 8 16 32

Sim

ula

tio

n T

ime

(Lo

wer

is b

ette

r)

Nodes

LAMMPS* Rhodopsin Protein Benchmark 512K Atoms (TACC* Stampede)

2S Intel® Xeon® Processor E5-2680

2S Intel® Xeon® Processor E5-2680 + Intel® Xeon Phi™ Coprocessor SE10P

2S Intel® Xeon® Processor E5-2680 + Nvidia* Tesla K20m

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

Performance improvements with Intel® package still significant with 1000 atoms per CPU core

Source: Intel Measured August 2014

* Other names and brands may be claimed as the property of others.

Rhodopsin Protein Scaled to 512K Atoms

Page 46: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Organic Solar CellsScience Team: Jan-Michael Y Carrillo, Rajeev Kumar, Monojoy Goswami, S. Michael Kilbey II, Bobby G Sumpter (ORNL*/UT*)

46

Problem: Predictive simulation of active layer morphology and molecular alignment based on blend composition

Optimization Result:

• 15% faster simulation time on CPUs

• Up to 2.2X faster with use of a coprocessor

• Simulations include all of the statistics and I/O (about 10% of run time) from the production runs

• Significant potential for advanced multiscalesimulation models with coprocessors…

8.00

16.00

32.00

64.00

128.00

256.00

2 4 8 16 32 64

Sim

ula

tio

n T

ime

(Lo

wer

is b

ette

r)

Nodes

OPV Simulation 1.77M Atoms, GAFF Force-Field, NPT (Stampede)

2S Intel® Xeon®Processor E5-2680(Baseline)

2S Intel® Xeon®Processor E5-2680(Intel® Package)

2S Intel® Xeon® Processor E5-2680 + Intel® Xeon Phi™ SE10P

COARSE-GRAINED MD

• Morphology • Phase segregation

ATOMISTIC MD

• Orientation of Thiophene rings• Sharpness of interface

PCBM

P3HT

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other informationand performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

* Other names and brands may be claimed as the property of others.

Source: Michael Brown

Page 47: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Liquid Crystal Benchmark

47

Biaxial Ellipsoidal Liquid Crystal Mesogens with 2:1.5:1 Aspect Ratio and Mass of 1.5 (Reduced Units)

Initial equilibration in the isothermal-isobaric ensemble to reach reduced temperature of 2.4 and pressure of 8.0 followed by 50 timestepbenchmark run in microcanonical ensemble

Cutoff = 4.0, Skin = 0.8 (Reduced Units)

Based on simulations from:

Brown, W.M., Petersen, M.K., Plimpton, S.J., Grest, G.S. Liquid Crystal Nanodroplets in Solution. Journal of Chemical Physics. 2009. 130: p. 044901 (1-7).

Available in LAMMPS* repository

* Other names and brands may be claimed as the property of others.

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

1.00

2.00

4.00

8.00

16.00

32.00

64.00

1 2 4 8 16 32

Sim

ula

tio

n T

ime

(Lo

wer

is b

ette

r)

Nodes

Liquid Crystal BenchmarkWeak Scaling - 524K Particles to 16.8M

Intel® Xeon® Processor E5-2680 (Baseline)

Intel® Xeon® Processor E5-2680 (Intel® Package)

2S Intel® Xeon® Processor E5-2680 + Intel® Xeon Phi™ SE10P

Optimizations resulted in 4.7X speedup on the CPUs on StampedeOver 7X Faster when using Intel® Xeon Phi™ SE10P on Stampede

Page 48: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

48

Intel® Package Performance Summary

Performance Summary on Stampede for Workloads on 1 node or 2 nodes (OPV)

1.0

0

1.0

0

1.0

0

1.0

0

1.2

1

1.4

5

1.1

5

4.6

8

2.1

6

2.3

3

2.1

8

7.1

2

RHODOPSIN C30 OPV L IQUID CRYSTAL

CPU Only (Baseline)

CPU Only (Optimized)

CPU + Intel® Xeon Phi™ Coprocessor

Brown, W.M., Carrillo, J.-M.Y., Gavhane, N., Thakkar, F.M., Plimpton, S.J. Optimizing Legacy Molecular Dynamics Software with Directive-Based Offload, To be submitted

Page 49: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

49

Summary

Able to get significant performance improvements optimizing LAMMPS* to use Intel® Xeon Phi™ Coprocessors in a relatively short time frame

• Up to 7.1X faster simulations for materials models when compared to the previous best performance in LAMMPS* on Intel® Architecture.

Optimizations were relevant for both the CPU and the coprocessor

• Using the same routine without any coprocessor, up to 4.7X faster simulation rates on Stampede

This development model works towards code that should perform on traditional x86-based CPUs, many-core x86-based coprocessors, and future self-boot many-core processors.

* Other names and brands may be claimed as the property of others.

Page 50: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

50

Acknowledgements

Organic Solar Cell Simulations

• Jan-Michael Carrillo, Center for Nanophase Materials Sciences and Computer Science and Mathematics Division, Oak Ridge National Laboratory

• with support from the Office of Advanced Scientific Computing Research, Office of Science, U.S. Department of Energy under Contract No. DE-AC05-00OR22725 with UT-Battelle, LLC

HPC Resources

• NSF TACC* Stampede Project: ACI-1134872

The researchers acknowledge the Texas Advanced Computing Center* (TACC) at The University of Texas at Austin* for providing HPC resources that have contributed to the research results reported within this presentation. URL: http://www.tacc.utexas.edu

* Other names and brands may be claimed as the property of others.

Page 51: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Progress by Other Teams for Molecular Dynamics on Intel® Xeon Phi™ Coprocessors

51

Page 52: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Amber* 14 • Application: Amber* • Description:

• Bimolecular Simulations (Protein, DNA, RNA, virus etc.). Full double precision (DPDP)

• Availability: • As a patch of Amber 14 when user updates Amber

(http://ambermd.org/bugfixes14.html, http://ambermd.org/bugfixesat.html) Update 5 and update 8.

• Recipe available: Section 18.7 of the manual http://ambermd.org/doc12/Amber14.pdf

• Usage Model: • Baseline is on Intel® Xeon® CPU only (SNB EP performance also measured in

http://ambermd.org/gpus/benchmarks.htm#Benchmarks ) & speedup is shown with offload processing on both Xeon & Xeon Phi. Performance shown is for the released code. This is all double precision code, across the platforms.

Highlights: • The code had been optimized, delivered to the Amber community (whoever has license)

and available as update patch during code configuration.

Results: • Optimized Xeon ® CPU + Xeon Phi ™ coprocessor offload demonstrated 2X improved

performance over baseline CPU only code.

• Code Optimization Strategy:• 1) Optimized data decomposition between host and Xeon Phi™ coprocessor. 2)

Reducing data transfer between host and coprocessor 3) Reducing Launch time to coprocessor 4) Xeon Phi™ coprocessor parallel computation with reciprocal force 5) avoid lookup table to increase cache locality 6) Efficient vectorization of force loop and neighbor list 7) Optimum OpenMP* scheduling.

• Notes:• News about the release is in the website: http://ambermd.org/. Recipe is in the amber

manual for anyone to download.

52Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Perfo rmance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

Config. SummaryICC/IFORT 14.0 U1 MPI 4.1.1.036MPSS 3.2.3ECC on,Turbo on XeonTurbo off Xeon Phi 7120A

* Other names and brands may be claimed as the property of others.

1.00

1.69

1.99

0.00

0.50

1.00

1.50

2.00

2.50

Baseline IVB E5

2697 v2

Optimized IVB E5

2697 v2

Optimized IVB E5

2697v2+ 1 7120

Xeon Phi

Pe

rfo

rma

nce

, ns/

da

y

Amber : Cellulose NPT

Optimized 2S E5-2697 v2 + Intel®

Xeon Phi™ coprocessor 7120A

Optimized 2S Intel® Xeon®

processor E5-2697 v2

Baseline 2S Intel® Xeon®

processor E5-2697 v2

Page 53: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

NAMD* 2.10 pre-release• Application & workload: NAMD* 2.10 pre-release; STMV• Description:

• A parallel, object-oriented molecular dynamics code designed for high-performance simulation of large biomolecular systems

• Availability: • Intel® Xeon Phi™ coprocessor support is available as pre-release at

http://www.ks.uiuc.edu/Development/Download/download.cgi?PackageName=NAMD. Use the nightly build.

• Usage Model: • Single rank on host with best of 23 or 47 threads. Various computations are offloaded

to Intel® Xeon Phi™ coprocessor from each thread.

• Highlights: • Intel® Xeon Phi™ coprocessor support is now in the development branch of NAMD

2.10 pre-release.

• Results: • For the STMV workload, a single and dual Intel® Xeon Phi™ coprocessors continue to

provide acceleration up to 32 nodes.

• Code Optimization Strategy:• Pairlist padding, atom sorting, AoS vs SoA (AoS is used), r2_table calculation instead

of lookup, mixture of gathers and loadunpacks + transforms, force combining (force updates at the same time so indexes/masks can be reused), mixed precision, selectively load balancing the non-bonded work between the host and device, intrinsics used for both force computation and pairlist generation loops, dynamic scheduling in OpenMP* parallel for loops, computes are sorted based on “input distance.”

• Notes:• We are continuing to optimize NAMD* further. This TR will be updated as newer

results are available.

53Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Perfo rmance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. See benchmark tests and configurations in the speaker notes. For more information go to http://www.intel.com/performance

* Other names and brands may be claimed as the property of others.

Cluster benchmark (STMV)

1X2.0x

3.8x

6.7x

11.6x

20X

2.0x3.8x

6.8x

12.2x

18.9x

27.1x

2.7x5.0x

9.2x

15.4x

22.2x

29.6x

0.000

1.000

2.000

3.000

4.000

5.000

6.000

1 2 4 8 16 32

ns/

da

y

Nodes

NAMD* 2.10 (pre-release) performance

STMV (~1M atoms), 23 or 47 PPN per node

(higher is better)

Intel® Xeon® processor E5-2697 v2 (23 PPN)

Intel® Xeon® processor E5-2697 v2 (23 PPN) + 1 Intel® Xeon Phi® coprocessor C0-7120A (240T)

Intel® Xeon® processor E5-2697 v2 (23 PPN) + 2 Intel® Xeon Phi® coprocessor C0-7120A (240T)

Page 54: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

GROMACS*

Application: GROMACS* 5.0-RC1Description:

• GROMACS is a versatile package to perform molecular dynamics, i.e. simulate the Newtonian equations of motion for systems with hundreds to millions of particles. It is one of the fastest and the most popular molecular dynamics packages

Workload: 512K H2O with RF methodAvailability:

• VERSION 5.0-rc1 is available from http://www.gromacs.org/Downloads & • ftp://ftp.gromacs.org/pub/gromacs/gromacs-5.0-rc1.tar.gz

Results: • Highly optimized for Intel® Xeon® Processors

(AVX-intrinsics)• Able to run full simulation on Intel® Xeon Phi™ coprocessor natively + host processor

using a symmetric model• Optimized with intrinsics for 512-bit vectorization

on Intel Xeon Phi coprocessors

Code Optimization Strategy:• Several experiments were done to find optimal MPI*/OprenMP* decomposition

between IVB-EP host(s) and KNC

Notes:• GROMACS-5.0-RC1 contains all changes for Xeon Phi coprocessors™ and requires no

additional changes when the user downloads from the repository• Normal level modifications are required to adjust cmake configuration and generate

appropriate hostfile for MPI*• Results reported are for “as is” code downloaded from the GROMACS repository

54

Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer

systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your

contemplated purchases, including the performance of that product when combined with other products. Intel Measured Results: Different hardware architectures may require different source code. Results are based on

Intel’s best efforts to use code optimized to run best on all architectures and perform the same work. Future code optimizations may result it different results. For more information go to

http://www.intel.com/performance

* Other names and brands may be claimed as the property of others.

Page 55: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

55

Code Recipes for Intel® Xeon Phi™ Coprocessor

Short documents describing how to obtain and run software on the Intel® Xeon Phi™ Coprocessor (includes Amber*, Gromacs*, LAMMPS*, NAMD*, Quantum Espresso*, )

• https://software.intel.com/en-us/articles/code-recipes-for-intelr-xeon-phitm-coprocessor

Intel® Compiler resources for Intel® Xeon Phi™ coprocessor programming and tuning:

• https://software.intel.com/en-us/articles/programming-and-compiling-for-intel-many-integrated-core-architecture

* Other names and brands may be claimed as the property of others.

Page 56: Optimizing LAMMPS* for Intel® Xeon Phi™ · Optimizing LAMMPS* for Intel® Xeon Phi™ Coprocessors W. Michael Brown HPC Life Sciences Architect/Engineer ... Learn About Intel®

Intel Confidential — Do Not Forward