• No results found

Sélection adaptative de codes polyédriques pour GPU/CPU

N/A
N/A
Protected

Academic year: 2021

Share "Sélection adaptative de codes polyédriques pour GPU/CPU"

Copied!
29
0
0

Loading.... (view fulltext now)

Full text

(1)

election adaptative de codes poly´

edriques pour

GPU/CPU

Jean-Fran¸cois DOLLINGER, Vincent LOECHNER, Philippe CLAUSS

INRIA - ´Equipe CAMUS Universit´e de Strasbourg

Saint-Hippolyte - Le 6 d´ecembre 2011

(2)

Sommaire

1 Introduction

2 Framework Pedro-CUDA

G´en´eration de code CUDA

Profilage

Pr´ediction

3 Exp´eriences

(3)

Introduction

Framework Pedro [Pradelle et al. 2011]

• Multi-versioning de nids de boucles

• Cible : CPU multi-cœurs

S´election de code `a la vol´ee

• G´en´eration de code statique

• Profilage hors-ligne

• S´election en ligne

(4)

Introduction

Table de classement

Nombre de coeurs version 1 version 2 version 3

1 40 ms 55 ms 32 ms

2 32 ms 28 ms 17 ms

3 22 ms 15 ms 9 ms

4 14 ms 7 ms 8 ms

Calcul du temps d’ex´ecution

• cnt = {2000, 600, 300, 300}

• tpred = ((2000 − 600) ∗ 40) + ((600 − 300) ∗ 32) + (0 ∗ 22) +

(5)

Introduction

Id´ee : Framework Pedro-CUDA

• Extension aux GPU et CPU + GPU

• Coˆuts de transferts

• Temps de calculs (difficilement pr´edictibles)

HMPP pr´evoit des optimisations

• Fortement coupl´ees `a l’architecture cible

Exemple de directives HMPP

#pragma hmpp ... cond=”(N > 1000)”

(6)

Introduction

... ... Version sélectionnée Version 1 Version M Profileur Prédicteur Contexte d'exécution Code binaire de l'application Compilateur

Code source Versions de code CPU + GPU Table de classement et table de débits Phase de profilage Phase de sélection Phase de compilation

(7)

Introduction

Architecture GPU Mod`ele m´emoire

• M´emoire globale

• M´emoire partag´ee

• Registres

• M´emoires constantes et textures

Mod`ele processeur

• Grille de blocs de threads

• GPU ex´ecutent des grilles

• Streaming Multiprocessors ex´ecutent des blocs (SIMD)

• Streaming Processors ex´ecutent des threads

(8)

Sommaire

1 Introduction

2 Framework Pedro-CUDA

G´en´eration de code CUDA

Profilage Pr´ediction

3 Exp´eriences

(9)

Framework Pedro-CUDA

G´en´eration de code CUDA PLuTo [Bondhugula et al. 2008, Baskaran et al. 2008]

• G´en´erateur C-vers-CUDA non fonctionnel

• Assertions invalides

• Configuration de l’ex´ecution grossi`ere

• Validit´e du code produit ?

Solution : Adapter un code CPU

• G´en´eration par des scripts Python

• Code kernel

• Code host

Version de code

• Fichier CLooG

• Dimensions parall`eles et tailles de blocs

(10)

Framework Pedro-CUDA

G´en´eration de code CUDA

Code host

• Boucles externes s´equentielles copi´ees

• Appels kernels synchrones

• Transferts de donn´ees `a l’aide de cudaMemcpy()

Code device

• Boucles parall`eles

• Transform´ees en gardes

• Mapp´ees sur la grille de threads CUDA

• Identifiant de thread affect´e `a l’indice original

(11)

Framework Pedro-CUDA

G´en´eration de code CUDA

version host kernel

for(t1...) for(t2...) //parallel for(t3...) //parallel for(t4...) for(t5...) S; cudaMemcpy(H2D) for(t1...) { cudaMemcpy(H2D) kernel<<...>>(); cudaMemcpy(D2H) } t2 = f(threadIdx.x); t3 = f(threadIdx.y); if(t2 ...) if(t3...) for(t4...) for(t5...) S; 11

(12)

Sommaire

1 Introduction

2 Framework Pedro-CUDA

G´en´eration de code CUDA

Profilage

Pr´ediction

3 Exp´eriences

(13)

Framework Pedro-CUDA

Profilage Transferts m´emoire host ↔ device

• Mesures pour certaines tailles

• Interpolation `a l’ex´ecution

0 1000 2000 3000 4000 5000 6000 2 3 4 5 6 7 8 9 Bandwidth (MB/s)

log10(message size (bytes)) Memory copies between host and device - Nvidia Quadro 4000

cudaMemcpy(cudaMemcpyHostToDevice) cudaMemcpy(cudaMemcpyDeviceToHost)

(14)

Framework Pedro-CUDA

Profilage ´

Evaluation offline du code

• Ex´ecut´e sur la machine cible

Calcul des param`etres des boucles parall`eles nok = t r u e w h i l e ( nok ) { // a j u s t e m e n t d e s p a r a m e t r e s 1 a d j u s t p a r a m s ( + 1 ) ; f o r e a c h ( p a r a l l e l d i m ) { i t = e h r h a r t ( p a r a l l e l d i m ) i f ( i t > g r i d s z ( p a r a l l e l d i m ) ) { nok = nok & f a l s e ;

} e l s e {

nok = nok & t r u e ; }

} }

(15)

Framework Pedro-CUDA

Profilage

Calcul du temps par it´eration f o r ( ; ; ) { // a j u s t e m e n t p a r a m e t r e s 2 a d j u s t p a r a m s ( ) ; // i n i t i a l i s a t i o n d e s p o i n t e u r s i n i t p o i n t e r s ( ) ; t a b s = g e t T i m e ( ) k e r n e l <<b l o c k s z , g r i d s z >>(); t a b s = g e t T i m e ( ) − t a b s ; n b i t e r = e h r h a r t ( ) ; t i t = t a b s / n b i t e r ; i f ( m e a s u r e o k ( t a b s ) ) { // m e s u r e f i a b l e ? r e t u r n t i t ; } } 15

(16)

Framework Pedro-CUDA

Profilage Temps d’ex´ecution par it´eration

-0.5 0 0.5 1 1.5 2 0 50 100 150 200 250 300 350 400

log10(time (ns)) per iteration

number of blocks Kernel launch (matmul no optimization on 2D grid)

8x2 blocks 8x4 blocks 8x8 blocks 16x4 blocks 16x16 blocks

(17)

Framework Pedro-CUDA

Profilage Table de classement

• Temps d’ex´ecution par it´eration

• Interpolation constante apr`es le seuil

• Mesures

• Nombre de blocs incr´ement´e de 1

• Arrˆet `a un seuil arbitraire

Table de bande passante

• Bande passante host ↔ device

• Mesures

• Taille des donn´ees transf´er´ees multipli´ee par deux

• Jusqu’`a saturation de la m´emoire disponible

(18)

Sommaire

1 Introduction

2 Framework Pedro-CUDA

G´en´eration de code CUDA Profilage

Pr´ediction

3 Exp´eriences

(19)

Framework Pedro-CUDA

Pr´ediction

Nids de pr´ediction

• Nids de boucles simplifi´es

• Temps d’ex´ecution et temps de transfert totaux approxim´es

f o r e a c h ( v e r s i o n ) { // e s t i m a t i o n du t e mp s de t r a n s f e r t p o u r l e n i d de b o u c l e s // h o s t−t o−d e v i c e f o r ( t 1 . . . ) { // e s t i m a t i o n du t e mp s de t r a n s f e r t p a r a p p e l k e r n e l // h o s t−t o−d e v i c e e t d e v i c e −t o−h o s t // e s t i m a t i o n du t e mp s d ’ e x e c u t i o n du k e r n e l } } 19

(20)

Framework Pedro-CUDA

Pr´ediction

Ex´ecution de la version estim´ee ˆetre la meilleure

(21)

Sommaire

1 Introduction

2 Framework Pedro-CUDA G´en´eration de code CUDA Profilage

Pr´ediction

3 Exp´eriences

4 Conclusion

(22)

Exp´

eriences

Pr´ediction des temps d’ex´ecution

0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150

matmul1matmul2matmul3matmul4 gemm1 gemm2 gemm3 gemm4 covariance1covariance2covariance3 mat-init1mat-init2

(23)

Exp´

eriences

Overhead de la pr´ediction 0 2e-06 4e-06 6e-06 8e-06 1e-05 1.2e-05 1.4e-05 1.6e-05

matmul1matmul2matmul3matmul4 gemm1gemm2gemm3gemm4 covariance1covariance2covariance3covariance4 matinit1matinit2

Time in seconds

overhead

(24)

Sommaire

1 Introduction

2 Framework Pedro-CUDA G´en´eration de code CUDA Profilage

Pr´ediction

3 Exp´eriences

(25)

Conclusion

Travail r´ealis´e

Ce qui a ´et´e fait

• M´ethode de pr´ediction pour GPU et CPU + GPU

• G´en´eration de code avec scripts python

• Codes de profilage et de pr´ediction

Ce qui marche d´ej`a

• Profilage et pr´ediction

(26)

Conclusion

Perspectives

G´en´erateur CUDA

• Gagner en flexibilit´e

• Utilisation de codes adapt´es aux GPU

Int´egration CPU vs GPU

• Choix d’une version CPU si non-performante sur GPU

Exp´eriences et consolidation de la m´ethode

(27)

election adaptative de codes poly´

edriques pour

GPU/CPU

Jean-Fran¸cois DOLLINGER, Vincent LOECHNER, Philippe CLAUSS

INRIA - ´Equipe CAMUS Universit´e de Strasbourg

Saint-Hippolyte - Le 6 d´ecembre 2011

(28)

Stream multiprocessor 1 Stream multiprocessor 2 Stream multiprocessor N Périphérique Mémoire globale Mémoire de constantes Mémoire de textures Registres Registres Registres

(29)

blockDim.x blockDim.y gridDim.y x y gridDim.x threadIdx.x threadIdx.y blockIdx.y blockIdx.x Block (0, 0) Block (1, 0) Block (0, 2) Block (1, 2) 29

References

Related documents

•  Frye Leadership Institute (US/International) •  Northern Exposure to Leadership (Canada) •  Snowbird Leadership Institute (US).. Recent/current

The tuning range of the home receiver is altered by replacing the antenna and oscillator coils and tuning condenser.. The parts are readily available from local distributors or

Most common include: Injection site reactions, skin rash, headache, nausea, diarrhea, sinus infection, abdominal pain, increased risk of minor infections.. Most serious

Figures 1 and 2 represent SEM micrographs of the evaluated areas, in the middle and apical root thirds respectively, showing dentinal tubules free of filling materials after

Robert:  Well, I don't know.  You can never be totally sure.  That's one of those things, that's 

Nevertheless, it is considerably much more flexible to generate triangular meshes over curved surfaces, and by the systematic merging of triangles, unstructured quadrilateral

o Whether the board receives sufficient information about important issues and trends in the mutual fund industry and how those areas impact the funds;.. o Whether

Some people think that suffering is just what life is all about; that you’re not supposed to really like your job, enjoy your relationship after a certain amount of time, or