rocm: leveraging open source software for accelerating ... · document. all open source software...

22
ROCm: Leveraging Open Source Software for Accelerating Applications with GPUs Derek Bouius – Product Manager

Upload: others

Post on 17-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

ROCm: Leveraging Open Source Software for Accelerating Applications with GPUsDerek Bouius – Product Manager

Page 2: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

DisclaimerThe information contained herein is for informational purposes only and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein. No license, including implied or arising by estoppel, to any intellectual property rights is granted by this document. All open source software listed in this presentation is governed by the associated open source license. Terms and limitations applicable to the purchase or use of AMD’s products are as set forth in a signed agreement between the parties or in AMD's Standard Terms and Conditions of Sale. GD-18

©2019 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo, Ryzen, Threadripper, EPYC, Infinity Fabric, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies.

PCIe is a trademark (or registered trademark) of PCI-SIG Corporation.

OpenCL is a trademark of Apple Inc. used by permission by Khronos Group, Inc.

Linux is a trademark (or registered trademark) of Linus Torvalds.ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 2

Page 3: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Design

Develop

ExecuteAnalyze

Innovate

What Scientists Care About: “Time-to-Results”

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 3

Page 4: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Merging of HPC and ML Into Same WorkflowAccelerates “Time-to-Results”

• Trained ANN can replace existing numerical solvers, enabling fast and scalable simulations – up to 100 Million times faster!

https://arxiv.org/abs/1910.07291ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 4

Page 5: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Accelerate Development Through Abstraction of Heterogenous Compute Infrastructure

Domain Specific Languages (DSLs)

Frameworks

Directives

Libraries

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 5

Page 6: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms
Page 7: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

AMD GPU Compilers:

C/C++ based

• The GCN ISA is free and open: https://developer.amd.com/resources/developer-guides-manuals/• hcc (hip-clang)

• Compiles HIP code• HIP (Heterogeneous Interface for Portability) is an

interface that looks similar to CUDA• hcc is a fork of clang• It understands HIP and emits AMDGCN in the resulting

binary• hipcc -> hcc (clang) -> amdgcn• All the x86 pieces are dealt with in the same way

• AOMP (AMD OpenMP Compiler)• Compiles C/C++ code with OpenMP “target” pragmas• Links with libomptarget to produce a binary that can

offload work to the GPU• OpenCL

• Khronos Industry Standard accelerator language

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 7

Page 8: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

AMD GPU Compilers:

the FORTRAN

story

• Important technology to the industry• AMD has plans to support OpenMP 4.5+ target

offload from FORTRAN with two open source options• F18 (based on llvm)• gfortran

• FORTRAN compiler work is an ongoing effort• See the Frontier spec sheet for what is expected

to be supported on Frontier• https://www.olcf.ornl.gov/wp-

content/uploads/2019/05/frontier_specsheet.pdf

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 8

Page 9: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

ROCm Thunk APIROCr System Runtime API

Device LLVM Compiler (GCN)

GPU Code

CPU Code

GCN Target

GCNAssembly

Optimizer

ROCm Kernel Driver

AMDGPU Kernel Driver Kernel Space

User SpaceLanguage Runtime API

Compiler Front Ends (C, C++, HIP, OpenMP, etc)

Host LLVM Compiler

Optimizer

CPU ISA Target

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 9

Page 10: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

10ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved.

Page 11: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Kernel parameters

Kernel countersKernel timestamps

GPU kernel time interval API call time intervalMemcopy time interval

$ rocprof –hsa-trace -i input.txt SimpleConvolution

11 ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 11

Page 12: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Decoder ring: Math library equivalentsBasic Linear Algebra SubroutinesCUBLAS ROCBLAS

Fast Fourier TransformsCUFFT ROCFFT

Deep Learning LibraryCUDNN MIOPEN

Optimized Parallel PrimitivesCUB ROCPRIM

C++ Template Library for Linear AlgebraEIGEN EIGEN

MORE INFO AT: GITHUB.COM/ROCM-DEVELOPER-TOOLS/HIP à HIP_PORTING_GUIDE.MDADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 12

Page 13: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

HIP: Heterogeneous-compute Interface for PortabilityC++ runtime API and kernel language that allows developers to create portable applications that can run on AMD’s accelerators as well as CUDA devices.

• Is open-source

• Provides an API for an application to leverage GPU acceleration for both AMD and CUDA devices

• Syntactically similar to CUDA. Most CUDA API calls can be converted in place: cuda -> hip

• Supports a strong subset of CUDA runtime functionality

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved.

Portable HIP C++ (Host & Device Code)

#include “cuda.h” #include “hcc.h”

nvcc hipcc

Nvidia GPU AMD GPU

13

Page 14: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

AMD GPU LibrariesA note on naming conventions:

• roc* -> AMGCN library usually written in HIP• cu* -> NVIDIA PTX libraries• hip* -> usually interface layer on top of roc*/cu* backends

hip* libraries:• Can be compiled by hipcc and can generate a call for

the device you have:• hipcc->AMDGCN• hipcc->nvcc (inlined)->NVPTX

hipBLAS

rocBLAS cuBLAS

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 14

Page 15: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

HIPify Tools

• Easy to use –point at a directory and it will attempt to hipify CUDA code

• Very simple string replacement technique: may make incorrect translations

• sed -e ‘s/cuda/hip/g’, (e.g., cudaMemcpy becomes hipMemcpy)

• Recommended for quick scans of projects

Hipify-perl:

• Requires clang compiler to parse files and perform semantic translation

• More robust translation of the code• Generates warnings and assistance for additional

analysis• High quality translation, particularly for cases where

the user is familiar with the make system

Hipify-clang:

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 15

Page 16: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Directives –OpenMP and OpenACC Abstract a Variety of Hardware Platforms

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 16

CPU GPU Accelerator

OpenMP OpenACC

Page 17: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Frameworks –HPC

HIP

ROCm CUDA

Kokkos RAJA

OpenMP

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 17

Page 18: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Frameworks – Machine Learning

MIOpen

OpenCLHIP

TensorFlow PyTorch (Caffe2)

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 18

Page 19: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

Domain Specific Languages – Portability of the Future?

OpenMP HIP

DSL 1 DSL 2 DSL n

OpenACC ISO C++

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 19

Page 20: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

hub.docker.com/r/rocm/

https://github.com/RadeonOpenCompute/k8s-device-pluginhttps://hub.docker.com/r/rocm/k8s-device-plugin/

Accelerate Today

Upstream support inSyLabs Singularity

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 20

Page 21: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms

For more detailed information…

• www.amd.com/rocm

HIP Training Webinar:• https://www.youtube.com/watch?v=3ZXbRJVvgJs

• Sessions at SC19: contact [email protected]

ADAC8 - ©2019 Advanced Micro Devices, Inc. All rights reserved. 21

Page 22: ROCm: Leveraging Open Source Software for Accelerating ... · document. All open source software listed in this presentation is governed by the associated open source license. Terms