oneapi, module 1 - colfax international · 2019-11-18 · 1 programminginaheterogeneousworld 2...

70
ONEAPI SINGLE PROGRAMMING MODEL TO DELIVER CROSS-ARCHITECTURE PERFORMANCE MODULE 1 GETTING STARTED WITH ONEAPI

Upload: others

Post on 26-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPISINGLE PROGRAMMINGMODEL TO DELIVER CROSS-ARCHITECTURE PERFORMANCE

MODULE 1GETTING STARTEDWITH ONEAPI

Page 2: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI TRAINING SERIES2

▷ Module 1: Getting Started with oneAPI▷ Module 2: Introduction to DPC++▷ Module 3: Fundamentals of DPC++, part 1 of 2▷ Module 4: Fundamentals of DPC++, part 2 of 2▷ Modules 5+: Deeper dives into specific DPC++ features,oneAPI libraries and tools

https://oneapi.comhttps://software.intel.com/en-us/oneapi

https://tinyurl.com/book-dpcpphttp://tinyurl.com/oneapimodule?1

oneAPI module 1: Getting started with oneAPI 2 / 48

Page 3: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 3 / 48

Page 4: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

RESOURCES4

▷ Book (Chapters 1-4 Preview)▷ oneAPI Toolkit(s)▷ Training, Support, Forums,Example Code

All availableFree

https://software.intel.com/en-us/oneapi https://tinyurl.com/book-dpcpphttp://tinyurl.com/oneapimodule?1

oneAPI module 1: Getting started with oneAPI 4 / 48

Page 5: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§1. PROGRAMMING IN A HETEROGENEOUSWORLD

Page 6: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 6 / 48

Page 7: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DIVERSEWORKLOADS DEMAND DIVERSE ARCHITECTURES7

The future is adiversemix of scalar, vector, matrix, and spatialarchitectures deployed in CPU, GPU, AI, FPGA, and other accelerators.

oneAPI module 1: Getting started with oneAPI 7 / 48

Page 8: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

CHALLENGE: PROGRAMMING IN A HETEROGENEOUSWORLD8

▷ Diverse set of data-centrichardware

▷ No common programminglanguage or APIs

▷ Inconsistent tool supportacross platforms

▷ Proprietary solutions onindividual platforms

▷ Each platform requiresunique software investment

oneAPI module 1: Getting started with oneAPI 8 / 48

Page 9: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

CHALLENGE: PROGRAMMING IN A HETEROGENEOUSWORLD8

▷ Diverse set of data-centrichardware

▷ No common programminglanguage or APIs

▷ Inconsistent tool supportacross platforms

▷ Proprietary solutions onindividual platforms

▷ Each platform requiresunique software investment

oneAPI module 1: Getting started with oneAPI 8 / 48

Page 10: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

CHALLENGE: PROGRAMMING IN A HETEROGENEOUSWORLD8

▷ Diverse set of data-centrichardware

▷ No common programminglanguage or APIs

▷ Inconsistent tool supportacross platforms

▷ Proprietary solutions onindividual platforms

▷ Each platform requiresunique software investment

oneAPI module 1: Getting started with oneAPI 8 / 48

Page 11: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

CHALLENGE: PROGRAMMING IN A HETEROGENEOUSWORLD8

▷ Diverse set of data-centrichardware

▷ No common programminglanguage or APIs

▷ Inconsistent tool supportacross platforms

▷ Proprietary solutions onindividual platforms

▷ Each platform requiresunique software investment

oneAPI module 1: Getting started with oneAPI 8 / 48

Page 12: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

CHALLENGE: PROGRAMMING IN A HETEROGENEOUSWORLD8

▷ Diverse set of data-centrichardware

▷ No common programminglanguage or APIs

▷ Inconsistent tool supportacross platforms

▷ Proprietary solutions onindividual platforms

▷ Each platform requiresunique software investment

S V M S

oneAPI module 1: Getting started with oneAPI 8 / 48

Page 13: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§2. HOWONEAPI ADDRESSES OUR HETEROGENEOUSWORLD

Page 14: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 10 / 48

Page 15: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 16: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 17: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 18: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 19: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 20: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 21: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

INTEL'S ONEAPI CORE CONCEPT11

▷ Project oneAPI delivers a unifiedprogramming model to simplifydevelopment across diversearchitectures

▷ Common developer experienceacross SVMS

▷ Uncompromised native high-levellanguage performance

▷ Unified language and libraries forexpressing parallelism

▷ Support for CPU, GPU, AI,and FPGA

▷ Based on industrystandards and openspecifications

oneAPI module 1: Getting started with oneAPI 11 / 48

Page 22: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

PROTECT PROGRAMMING INVESTMENTS12

oneAPI module 1: Getting started with oneAPI 12 / 48

Page 23: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

GOOD PLAN: LET ALL LIGHTS SHINE13

▷ Allowing all ?PUs to shine should yield better results thanprogramming approaches that focus on highlighting aparticular PU over all others.

▷ Programmers want to write a single portable program thatuses ALL resources in the heterogeneous platform.

oneAPI module 1: Getting started with oneAPI 13 / 48

Page 24: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

GOOD PLAN: LET ALL LIGHTS SHINE13

▷ Allowing all ?PUs to shine should yield better results thanprogramming approaches that focus on highlighting aparticular PU over all others.

▷ Programmers want to write a single portable program thatuses ALL resources in the heterogeneous platform.

oneAPI module 1: Getting started with oneAPI 13 / 48

Page 25: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

GOOD PLAN: ?PU NEEDS CPUS14

▷ CPUs excel at serial.▷ Parallel programmers learn to hate slow serial processing, because itdestroys scaling at an alarming rate thanks to Amdahl's Law.

▷ Any investment in speeding up an application, is easily destroyed if theserial part is compromised — even if the serial part is only 0.001% of theapplication.

▷ Even using full speed for 99.999% of compute with 20K PUs, a 1/3rd speedserial processing finds that Amdahl's Law tells us that we’ll see no morethan 68% of the performance that we could obtain with full speed serialprocessing.

▷ Amdahl's Law math: ((99999/30000)+1) / ((99999/30000)+3)

oneAPI module 1: Getting started with oneAPI 14 / 48

Page 26: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

GOOD PLAN: ?PU NEEDS CPUS14

▷ CPUs excel at serial.▷ Parallel programmers learn to hate slow serial processing, because itdestroys scaling at an alarming rate thanks to Amdahl's Law.

▷ Any investment in speeding up an application, is easily destroyed if theserial part is compromised — even if the serial part is only 0.001% of theapplication.

▷ Even using full speed for 99.999% of compute with 20K PUs, a 1/3rd speedserial processing finds that Amdahl's Law tells us that we’ll see no morethan 68% of the performance that we could obtain with full speed serialprocessing.

▷ Amdahl's Law math: ((99999/30000)+1) / ((99999/30000)+3)

oneAPI module 1: Getting started with oneAPI 14 / 48

Page 27: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI FOR CROSS-ARCHITECTURE PERFORMANCE15

oneAPI module 1: Getting started with oneAPI 15 / 48

Page 28: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI FOR CROSS-ARCHITECTURE PERFORMANCE15

oneAPI module 1: Getting started with oneAPI 15 / 48

Page 29: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§3. HELLO DOUBLER - SIMPLE DPC++ CODING EXAMPLE

Page 30: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 17 / 48

Page 31: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

"HELLO DOUBLER" DPC++18

#include <CL/sycl.hpp>#include <iostream>#include <array>#include <cstdio>#define SIZE 1024

int main() {std::array<int, SIZE> myArray;for (int i = 0; i<SIZE; ++i)

myArray[i] = i;

// cl::sycl:: adds clarity for teaching// but is not how you are likely to code...printf("Value at start: myArray[42] is %d.\n",myArray[42]);{cl::sycl::queue myQ; /* use defaults today *//* (queue parameters possible - future topic) */

cl::sycl::range<1> mySize{SIZE};cl::sycl::buffer<int, 1> bufferA(myArray.data(), mySize);

myQ.submit([&](cl::sycl::handler &myHandle) {auto deviceAccessorA =

bufferA.get_access<cl::sycl::access::mode::read_write>(myHandle);myHandle.parallel_for<class uniqueID>(mySize,

[=](cl::sycl::id<1> index){deviceAccessorA[index] *= 2;

});

});}printf("Value at finish: myArray[42] is %d.\n",myArray[42]);

}

oneAPI module 1: Getting started with oneAPI 18 / 48

Page 32: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

NAMESPACE CL::SYCL::19

// cl::sycl:: adds clarity for teaching// but is not how you are likely to code...printf("Value at start: myArray[42] is %d.\n",myArray[42]);{cl::sycl::queue myQ; /* use defaults today *//* (queue parameters possible - future topic) */cl::sycl::range<1> mySize{SIZE};cl::sycl::buffer<int, 1> bufferA(myArray.data(), mySize);

myQ.submit([&](cl::sycl::handler &myHandle) {auto deviceAccessorA =bufferA.get_access<cl::sycl::access::mode::read_write>(myHandle);

myHandle.parallel_for<class uniqueID>(mySize,[=](cl::sycl::id<1> index){

deviceAccessorA[index] *= 2;}

);});

}printf("Value at finish: myArray[42] is %d.\n",myArray[42]);

▷ cl::sycl::

oneAPI module 1: Getting started with oneAPI 19 / 48

Page 33: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

NAMESPACE CL::SYCL::20

using namespace cl::sycl;

printf("Value at start: myArray[42] is %d.\n",myArray[42]);{queue myQ; /* use defaults today *//* (queue parameters possible - future topic) */range<1> mySize{SIZE};buffer<int, 1> bufferA(myArray.data(), mySize);

myQ.submit([&](handler &myHandle) {auto deviceAccessorA =bufferA.get_access<access::mode::read_write>(myHandle);

myHandle.parallel_for<class uniqueID>(mySize,[=](id<1> index){

deviceAccessorA[index] *= 2;}

);});

}printf("Value at finish: myArray[42] is %d.\n",myArray[42]);

▷ that's better!

oneAPI module 1: Getting started with oneAPI 20 / 48

Page 34: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

"HELLO DOUBLER" DPC++21

1 using namespace cl::sycl;23 printf("Value at start: myArray[42] is %d.\n",myArray[42]);4 {5 queue myQ; /* use defaults today */6 /* (queue parameters possible - future topic) */7 range<1> mySize{SIZE};8 buffer<int, 1> bufferA(myArray.data(), mySize);9

10 myQ.submit([&](handler &myHandle) {11 auto deviceAccessorA =12 bufferA.get_access<access::mode::read_write>(myHandle);13 myHandle.parallel_for<class uniqueID>(mySize,14 [=](id<1> index)15 {16 deviceAccessorA[index] *= 2;17 }18 );19 });20 }21 printf("Value at finish: myArray[42] is %d.\n",myArray[42]);

▷ Full power of C++▷ DPC++ extends C++ withSYCL and more

▷ Syntax is pure C++, no newkeywords

▷ Kernels are Key DataParallel ProgrammingConstruct

▷ Cross-platform portability▷ Optimizing compilers boostperformance

▷ Full programmer controlover performance

oneAPI module 1: Getting started with oneAPI 21 / 48

Page 35: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

"HELLO DOUBLER" DPC++21

1 using namespace cl::sycl;23 printf("Value at start: myArray[42] is %d.\n",myArray[42]);4 {5 queue myQ; /* use defaults today */6 /* (queue parameters possible - future topic) */7 range<1> mySize{SIZE};8 buffer<int, 1> bufferA(myArray.data(), mySize);9

10 myQ.submit([&](handler &myHandle) {11 auto deviceAccessorA =12 bufferA.get_access<access::mode::read_write>(myHandle);13 myHandle.parallel_for<class uniqueID>(mySize,14 [=](id<1> index)15 {16 deviceAccessorA[index] *= 2;17 }18 );19 });20 }21 printf("Value at finish: myArray[42] is %d.\n",myArray[42]);

▷ Full power of C++▷ DPC++ extends C++ withSYCL and more

▷ Syntax is pure C++, no newkeywords

▷ Kernels are Key DataParallel ProgrammingConstruct

▷ Cross-platform portability▷ Optimizing compilers boostperformance

▷ Full programmer controlover performance

oneAPI module 1: Getting started with oneAPI 21 / 48

Page 36: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

"HELLO DOUBLER" DPC++22

$ make doubler2dpcpp doubler2.cpp -o doubler2

$ ./doubler2Value at start: myArray[42] is 42.Value at finish: myArray[42] is 84.

▷ Doubler, like other DPC++ kernels, can be mapped to all architectures.▷ The suitability of each architecture is algorithm dependent.

oneAPI module 1: Getting started with oneAPI 22 / 48

Page 37: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

42 DOUBLED IS 8423

1 using namespace cl::sycl;23 printf("Value at start: myArray[42] is %d.\n",myArray[42]);4 {5 queue myQ; /* use defaults today */6 /* (queue parameters possible - future topic) */7 range<1> mySize{SIZE};8 buffer<int, 1> bufferA(myArray.data(), mySize);9

10 myQ.submit([&](handler &myHandle) {11 auto deviceAccessorA =12 bufferA.get_access<access::mode::read_write>(myHandle);13 myHandle.parallel_for<class uniqueID>(mySize,14 [=](id<1> index)15 {16 deviceAccessorA[index] *= 2;17 }18 );19 });20 }21 printf("Value at finish: myArray[42] is %d.\n",myArray[42]);

▷ myArray[42] starts as42

▷ afterwards it is 84

oneAPI module 1: Getting started with oneAPI 23 / 48

Page 38: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DPC++ PROVIDES THE MEANS!24

▷ Doubler, like other DPC++ kernels, can be mapped to allarchitectures.

▷ The suitability of each architecture is algorithm dependent.▷ Balancing performance, portability, and productivity duringapplication development is a challenge we all face.

▷ DPC++ provides all of the tools required to maintain bothgeneric portable code, and optimized target-specific code,using a single high-level programming language.

oneAPI module 1: Getting started with oneAPI 24 / 48

Page 39: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DPC++ PROVIDES THE MEANS!24

▷ Doubler, like other DPC++ kernels, can be mapped to allarchitectures.

▷ The suitability of each architecture is algorithm dependent.▷ Balancing performance, portability, and productivity duringapplication development is a challenge we all face.

▷ DPC++ provides all of the tools required to maintain bothgeneric portable code, and optimized target-specific code,using a single high-level programming language.

oneAPI module 1: Getting started with oneAPI 24 / 48

Page 40: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DPC++ PROVIDES THE MEANS!24

▷ Doubler, like other DPC++ kernels, can be mapped to allarchitectures.

▷ The suitability of each architecture is algorithm dependent.▷ Balancing performance, portability, and productivity duringapplication development is a challenge we all face.

▷ DPC++ provides all of the tools required to maintain bothgeneric portable code, and optimized target-specific code,using a single high-level programming language.

oneAPI module 1: Getting started with oneAPI 24 / 48

Page 41: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§4. WHAT IS SYCL?

Page 42: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 26 / 48

Page 43: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

SYCL27

SYCL is an industry-wide standardization effort to definecross-platform data parallelism support for C++.▷ pronounced `sickle' `sick ell' /"sik(@)l/▷ cross-platform abstraction layer for data parallelism▷ single source programming▷ extends modern C++▷ defined by a Khronos standards group▷ Intel is a participant in the standards group, as are many more▷ Most of DPC++ is already part of SYCL▷ Intel's contributes back new additions

oneAPI module 1: Getting started with oneAPI 27 / 48

Page 44: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

SYCL27

SYCL is an industry-wide standardization effort to definecross-platform data parallelism support for C++.▷ pronounced `sickle' `sick ell' /"sik(@)l/▷ cross-platform abstraction layer for data parallelism▷ single source programming▷ extends modern C++▷ defined by a Khronos standards group▷ Intel is a participant in the standards group, as are many more▷ Most of DPC++ is already part of SYCL▷ Intel's contributes back new additions

oneAPI module 1: Getting started with oneAPI 27 / 48

Page 45: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

SYCL27

SYCL is an industry-wide standardization effort to definecross-platform data parallelism support for C++.▷ pronounced `sickle' `sick ell' /"sik(@)l/▷ cross-platform abstraction layer for data parallelism▷ single source programming▷ extends modern C++▷ defined by a Khronos standards group▷ Intel is a participant in the standards group, as are many more▷ Most of DPC++ is already part of SYCL▷ Intel's contributes back new additions

oneAPI module 1: Getting started with oneAPI 27 / 48

Page 46: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

SYCL27

SYCL is an industry-wide standardization effort to definecross-platform data parallelism support for C++.▷ pronounced `sickle' `sick ell' /"sik(@)l/▷ cross-platform abstraction layer for data parallelism▷ single source programming▷ extends modern C++▷ defined by a Khronos standards group▷ Intel is a participant in the standards group, as are many more▷ Most of DPC++ is already part of SYCL▷ Intel's contributes back new additions

oneAPI module 1: Getting started with oneAPI 27 / 48

Page 47: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

SYCL27

SYCL is an industry-wide standardization effort to definecross-platform data parallelism support for C++.▷ pronounced `sickle' `sick ell' /"sik(@)l/▷ cross-platform abstraction layer for data parallelism▷ single source programming▷ extends modern C++▷ defined by a Khronos standards group▷ Intel is a participant in the standards group, as are many more▷ Most of DPC++ is already part of SYCL▷ Intel's contributes back new additions

oneAPI module 1: Getting started with oneAPI 27 / 48

Page 48: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§5. DEVCLOUD - TRY ONEAPI EASILY

Page 49: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 29 / 48

Page 50: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DEVCLOUD30

https://software.intel.com/en-us/devcloud/oneapi

oneAPI module 1: Getting started with oneAPI 30 / 48

Page 51: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§6. ONEAPI - WHY AND HOW

Page 52: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 32 / 48

Page 53: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI FOR CROSS-ARCHITECTURE PERFORMANCE33

oneAPI module 1: Getting started with oneAPI 33 / 48

Page 54: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

POWERFUL ONEAPI LIBRARIES34

For Data-Centric Functions▷ Key domain-specific functions to accelerate

compute intensive workloads▷ Custom-coded for uncompromised

performance on SVMS (Scalar, Vector,Matrix, Spatial) architectures

oneAPI module 1: Getting started with oneAPI 34 / 48

Page 55: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

POWERFUL ONEAPI TOOLS35

Productive debugging and performance analysisacross architecturesIntel® VTune™ Profiler▷ Profiler to analyze CPU and accelerator

performance of compute, threading, memory,storage, and more

Intel® Advisor▷ Design assistant to provide advice on threading,

and vectorization

Intel®-enhanced gdb▷ Application debugger for fast code debug on CPUs

and accelerators

oneAPI module 1: Getting started with oneAPI 35 / 48

Page 56: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI TOOLKITS36

One core toolkit▷ Additional toolkits targeting specific

data-centric workloads▷ Each includes oneAPI components and

complementary oneAPI ecosystemcomponents

▷ Ready-to-go containers and custominstaller for easy startup

https://software.intel.com/en-us/oneapi(one stop website for all things oneAPI - software.intel.com/oneapi)

oneAPI module 1: Getting started with oneAPI 36 / 48

Page 57: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

CROSS-ARCHITECTURE SYSTEMS TODAY, ONEAPI TODAY37

The future of computing ishere, and it is adiversemix of scalar,vector, matrix, and spatial architectures deployed in CPU, GPU, AI, FPGA,and other accelerators.

▷ oneAPI unifies and simplifies programming of CPUs andaccelerators, delivering developer productivity, and full nativelanguage performance

▷ oneAPI is based on industry standards and open specificationsto encourage ecosystem collaboration and innovation

https://software.intel.com/en-us/oneapi

oneAPI module 1: Getting started with oneAPI 37 / 48

Page 58: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

§7. WHAT IS DATA PARALLEL C++?

Page 59: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

1 Programming in a Heterogeneous World

2 How oneAPI addresses our Heterogeneous World

3 Hello Doubler - simple DPC++ coding example

4 What is SYCL?

5 DevCloud - Try oneAPI easily

6 oneAPI - Why and How

7 What is Data Parallel C++?

oneAPI module 1: Getting started with oneAPI 39 / 48

Page 60: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

WHAT IS DPC++?40

DPC++ implements cross-platform data parallelism support (extends C++).

▷ adheres to the SYCL specification▷ implements cross-platform abstraction layer for dataparallelism

▷ open source implementation (github) with all featuressupported

▷ utilizes Clang and LLVM▷ product implementation, support, and tools available fromIntel

▷ DPC++ book in progress - first four chapters available (free)

oneAPI module 1: Getting started with oneAPI 40 / 48

Page 61: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

TERMS THATWILL BE THROWN AROUND41

▷ Single Source programmers use▷ Fat Binaries implementations use▷ Directed Programming programmers use

oneAPI module 1: Getting started with oneAPI 41 / 48

Page 62: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

TERMS THATWILL BE THROWN AROUND41

▷ Single Source programmers use▷ Fat Binaries implementations use▷ Directed Programming programmers use

oneAPI module 1: Getting started with oneAPI 41 / 48

Page 63: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

TERMS THATWILL BE THROWN AROUND41

▷ Single Source programmers use▷ Fat Binaries implementations use▷ Directed Programming programmers use

oneAPI module 1: Getting started with oneAPI 41 / 48

Page 64: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

PROGRAMMING IN DPC++42

DPC++ implements cross-platform data parallelism support (extends C++).

▷ Write `kernels'▷ Control when/where/how they might be accelerated

oneAPI module 1: Getting started with oneAPI 42 / 48

Page 65: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DPC++43

The same programming language cansupport all SVMS architectures.

oneAPI module 1: Getting started with oneAPI 43 / 48

Page 66: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DPC++44

Data Parallel C++provides the features and abstractionnecessary to deliver uncompromisedperformance on SVMS architectures.

oneAPI module 1: Getting started with oneAPI 44 / 48

Page 67: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI TRAINING SERIES45

▷ Module 1: Getting Started with oneAPI▷ Module 2: Introduction to DPC++▷ Module 3: Fundamentals of DPC++, part 1 of 2▷ Module 4: Fundamentals of DPC++, part 2 of 2▷ Modules 5+: Deeper dives into specific DPC++ features,oneAPI libraries and tools

https://oneapi.comhttps://software.intel.com/en-us/oneapi

https://tinyurl.com/book-dpcpphttp://tinyurl.com/oneapimodule?1

oneAPI module 1: Getting started with oneAPI 45 / 48

Page 68: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

RESOURCES46

▷ Book (Chapters 1-4 Preview)▷ oneAPI Toolkit(s)▷ Training, Support, Forums,Example Code

All availableFree

https://software.intel.com/en-us/oneapi https://tinyurl.com/book-dpcpphttp://tinyurl.com/oneapimodule?1

oneAPI module 1: Getting started with oneAPI 46 / 48

Page 69: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

DEVCLOUD47

https://software.intel.com/en-us/devcloud/oneapi

oneAPI module 1: Getting started with oneAPI 47 / 48

Page 70: oneAPI, Module 1 - Colfax International · 2019-11-18 · 1 ProgramminginaHeterogeneousWorld 2 HowoneAPIaddressesourHeterogeneousWorld 3 HelloDoubler-simpleDPC++codingexample 4 WhatisSYCL?

ONEAPI TRAINING SERIES48

▷ Module 1: Getting Started with oneAPI▷ Module 2: Introduction to DPC++▷ Module 3: Fundamentals of DPC++, part 1 of 2▷ Module 4: Fundamentals of DPC++, part 2 of 2▷ Modules 5+: Deeper dives into specific DPC++ features,oneAPI libraries and tools

https://oneapi.comhttps://software.intel.com/en-us/oneapi

https://tinyurl.com/book-dpcpphttp://tinyurl.com/oneapimodule?1

oneAPI module 1: Getting started with oneAPI 48 / 48