Build Systems: Combining CUDA and Modern CMake GTC, San Jose, CA - - PowerPoint PPT Presentation

build systems combining cuda and
SMART_READER_LITE
LIVE PREVIEW

Build Systems: Combining CUDA and Modern CMake GTC, San Jose, CA - - PowerPoint PPT Presentation

Build Systems: Combining CUDA and Modern CMake GTC, San Jose, CA May, 2017 Robert Maynard Kitware, Inc. Founded in 1998 by five former GE Research employees 136 current employees; 47 with PhDs Privately held, profitable from


slide-1
SLIDE 1

Robert Maynard

GTC, San Jose, CA May, 2017

Build Systems: Combining CUDA and Modern CMake

slide-2
SLIDE 2

Kitware, Inc.

  • Founded in 1998 by five former GE Research employees
  • 136 current employees; 47 with PhDs
  • Privately held, profitable from creation
  • Offices

– Clifton Park, NY – Carrboro, NC – Santa Fe, NM – Lyon, France

slide-3
SLIDE 3

Business Model: Open Source

  • Open-source Software

– Normally BSD-licensed

  • Collaborative Research and Development
  • Technology Integration
  • Services, Support, Training, and Consulting
slide-4
SLIDE 4

Why CMake? Everyone is using it

KDE 2006 – First Tipping Point!

10 20 30 40 50 60 70 80 90 100 2004-01 2004-05 2004-09 2005-01 2005-05 2005-09 2006-01 2006-05 2006-09 2007-01 2007-05 2007-09 2008-01 2008-05 2008-09 2009-01 2009-05 2009-09 2010-01 2010-05 2010-09 2011-01 2011-05 2011-09 2012-01 2012-05 2012-09 2013-01 2013-05 2013-09 2014-01 2014-05 2014-09 2015-01 2015-05 2015-09 2016-01 2016-05 2016-09 2017-01

cmake: (Worldwide) autoconf: (Worldwide)

slide-5
SLIDE 5
  • Introduction of CMake Server
  • QTCreator
  • VisualStudio 2017
  • C++ Package Managers
  • Conan.io – provides helper scripts
  • Microsoft.vckpg
  • Native CUDA language support
  • CMake 3.5, 3.6, 3.7, and 3.8 in the last 14 months

Why CMake? Everyone is using it

2016-17 – Second Tipping Point!

slide-6
SLIDE 6

Classic CMake

Directory Directory Executable Library B Directory Library A

In reality most projects have a very directory centric model Downard propagation – Include Directories – Compile Definitions – Find Packages Consumers have to know: – Does the dependency generate build tree files – Does the dependency use any new external package

slide-7
SLIDE 7

Modern CMake

  • Modern CMake uses new(er) APIs
  • Modern CMake is target focused

– Include Directories – Compile Options – Compile Definitions

  • Modern CMake introduces the concept of usage requirements

– PUBLIC – PRIVATE – INTERFACE

  • Modern CMake is more declarative
slide-8
SLIDE 8

Let’s write CMake code!

8

slide-9
SLIDE 9

Let’s write CMake code!

9

slide-10
SLIDE 10

Shared Library Mixed Languages

10

PRIVATE: only the given target will use it INTERFACE: only consuming targets use it BUILD_INTERFACE: used by consumers from this project or use the build directory INSTALL_INTERFACE: used by consumers after this target has been installed

slide-11
SLIDE 11

Shared Library Mixed Languages

11

PUBLIC: given target and consuming targets will use it

slide-12
SLIDE 12

Interface Library

12

slide-13
SLIDE 13

Lets Run CMake

13

slide-14
SLIDE 14

Separable Compilation

  • Separable compilation allows CUDA

code to call device functions implemented in other translation units

  • CMake 3.8 is capable of separable

compilation and device linking

– device linking of static libraries occurs when they are consumed by a shared library or executable

14

slide-15
SLIDE 15

Separable Compilation

15

slide-16
SLIDE 16

Separable Compilation

16

slide-17
SLIDE 17

Separable Compilation

17

slide-18
SLIDE 18

CMake is able to produce two types of config files 1. You have config files that are part of the build tree of a project. These contain build paths that can only be used on the current machine 2. You have installed config files that are meant to be machine

  • relocatable. Large projects generally ship these as part of the SDK

Export Configuration

18

Export Configuration File

slide-19
SLIDE 19

Export Configuration

19

slide-20
SLIDE 20

Install Export Configuration

20

slide-21
SLIDE 21

The Proof

21

slide-22
SLIDE 22

The Proof

22

slide-23
SLIDE 23

CMake 3.9: MSVC

  • CMake 3.9 adds CUDA support to MSVC
  • Will require the CUDA MSBuild extensions

23

slide-24
SLIDE 24

CMake 3.9: OBJECT targets

  • CMake 3.9 is expanding OBJECT support
  • Will be

– Installable – Exportable – Importable – Usable in Generator Expressions

24

slide-25
SLIDE 25

CMake 3.9: PTX

  • CMake 3.9 will add support for PTX files
  • Will be

– Installable – Exportable – Importable – Usable in Generator Expressions

25

slide-26
SLIDE 26

CMake 3.9: PTX

26

slide-27
SLIDE 27

Now that you are inspired

27

  • Explore more CUDA+CMake snippets

– https://gitlab.kitware.com/robertmaynard/cmake_cuda_tests

slide-28
SLIDE 28

Now that you are inspired

28

  • Read “how to write a CMake buildsystem”

– https://cmake.org/cmake/help/v3.8/manual/cmake-buildsystem.7.htmlExplore the CMake documentation

  • Explore the CMake documentation

– https://www.cmake.org/cmake/help/v3.8/

slide-29
SLIDE 29

Thank You!

Robert Maynard

robert.maynard@kitware.com

@robertjmaynard

Please complete the Presenter Evaluation sent to you by email or through the GTC Mobile App. Your feedback is important!

Checkout out: Kitware @ www.kitware.com CMake @ www.cmake.org Thanks to NVIDIA for all the technical support when developing this work