PDF de programación - Rutinas y Librerías de Álgebra Lineal en Sistemas Many-Core (GPUs y MIC)

Imágen de pdf Rutinas y Librerías de Álgebra Lineal en Sistemas Many-Core (GPUs y MIC)

Rutinas y Librerías de Álgebra Lineal en Sistemas Many-Core (GPUs y MIC)gráfica de visualizaciones

Publicado el 28 de Mayo del 2018
609 visualizaciones desde el 28 de Mayo del 2018
898,6 KB
45 paginas
Creado hace 9a (04/12/2014)
Rutinas y Librerías de Álgebra Lineal en Sistemas

Many-Core (GPUs y MIC)

Luis P. García González

Unidad de Informática

Universidad Politécnica de Cartagena

UPCT

Diciembre de 2014

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

1 / 45

Introducción

Procesadores Multicore, sistemas cc-NUMA, GPUs y Coprocesadores
pueden ofrecer mejoras en el rendimiento de las librerías de Álgebra
Lineal

Son necesarias técnicas de optimización del software para poder
obtener beneficios de las posibilidades que ofrecen estos sistemas
computacionales
Modelar el tiempo de ejecución de la rutina
Análisis experimental del comportamiento de la rutina con la variación
de ciertos parámetros

En esta presentación:

El comportamiento de rutinas BLAS y LAPACK en diferentes librerías
de Álgebra Lineal y diferentes sistemas computacionales con GPUs y
MICs

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

2 / 45

Índice

NVIDIA GPUs

NVIDIA CUBLAS
NVIDIA XTCUBLAS
MAGMA GPU

Coprocesadores Intel Xeon Phi (MIC)

Intel MKL
MAGMA MIC

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

3 / 45

Experiencias con NVIDIA GPUs. Introducción I

Características

NVIDIA GPUs

Hasta 2688 cores CUDA
organizados en Streaming
Multiprocessor (MP)
Hasta 6 GBytes GDDR5
Modelo de programación CUDA
Funciones paralelas
denominadas kernels
Múltiples threads organizados en
bloques de theads y grids de
bloques

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

4 / 45

Introducción II

Preparación del sistema
Instalación de NVIDIA CUDA Toolkit

Software que proporciona un entorno de desarrollo en C/C++ y
librerías:

Compilador CUDA de NVIDIA: NVCC
cuFFT: Librería Transformada Rápida de Fourier
cuBLAS: Librería BLAS
cuSPARSE: librería para Matrices Dispersas
cuRAND: Generador de Números Aleatorios
etc.

Librerías de Álgebra Lineal para GPUs:

MAGMA: Matrix Algebra on GPU and Multicore Architectures
CULA Tools
IMSL Fortran Numerical Library

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

5 / 45

Ejemplo de llamada a rutina en CUBLAS

DGEMM

h_A = (double *)malloc(sizeof(double)*szeA);
h_B = (double *)malloc(sizeof(double)*szeB);
h_C = (double *)malloc(sizeof(double)*szeC);
...
cudaMalloc((void **) &d_A, sizeof(double)*ldda*K);
cudaMalloc((void **) &d_B, sizeof(double)*lddb*N);
cudaMalloc((void **) &d_C, sizeof(double)*lddc*N);
...
cublasSetMatrix(M, K, sizeof(double), h_A, lda, d_A, ldda);
cublasSetMatrix(K, N, sizeof(double), h_B, ldb, d_B, lddb);

cublasCreate(&handle);
cublasDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K,
d_C, lddc);

&alpha, d_A, ldda, d_B, lddb, &beta,

cublasGetMatrix(M, N, sizeof(double), d_C, lddc, h_C, ldc);

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

6 / 45

DGEMM: MAGMA, CUBLAS en GPU y MKL en CPU

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

7 / 45

100020003000400050006000700080009000100001100001002003004005006007008009001000matrixsizeGFLOPSTeslaK20c,706MHz,13MPx192Cores(2496Cores).IntelXeonE5-26202.00GHz(12cores)MAGMADGEMMCUBLASDGEMMMKLDGEMM100020003000400050006000700080009000100001100001002003004005006007008009001000matrixsizeGFLOPSTeslaK20c,706MHz,13MPx192Cores(2496Cores).IntelXeonE75301.87GHz(24cores)MAGMADGEMMCUBLASDGEMMMKLDGEMM100020003000400050006000700080009000100001100020406080100120140160180200220240260280300matrixsizeGFLOPSTeslaC2075,1147MHz,14MPx32Cores(448Cores).IntelXeonE5-26202.00GHz(12cores)MAGMADGEMMCUBLASDGEMMMKLDGEMM100020003000400050006000700020406080100120140160180matrixsizeGFLOPSGeforceGTX590,1215.0MHz,16MPx32Cores(512Cores).IntelXeonE5-26202.00GHz(12cores)MAGMADGEMMCUBLASDGEMMMKLDGEMM LU: MAGMA GPU+CPU y MKL en CPU

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

8 / 45

2000400060008000100001200014000160001800020000220000100200300400500600700matrixsizeGFLOPSTeslaK20c,706MHz,13MPx192Cores(2496Cores).IntelXeonE5-26202.00GHz(12cores)MKLMAGMA1GPU2000400060008000100001200014000160001800020000220000100200300400500600700matrixsizeGFLOPSTeslaK20c,706MHz,13MPx192Cores(2496Cores).IntelXeonE75301.87GHz(24cores)MKLMAGMA1GPU200040006000800010000120001400016000180002000022000050100150200250300350400450500550matrixsizeGFLOPSTeslaC2075,1147MHz,14MPx32Cores(448Cores).IntelXeonE5-26202.00GHz(12cores)MKLMAGMA1GPUMAGMA2GPUs200040006000800010000120001400016000180002000022000050100150200250300350400450500matrixsizeGFLOPSGeforceGTX590,1215.0MHz,16MPx32Cores(512Cores).IntelXeonE5-26202.00GHz(12cores)MKLMAGMA1GPUMAGMA2GPUsMAGMA3GPUsMAGMA4GPUs Ejemplo de llamada a rutina en MAGMA GPU

LU

cublasInit();

szeA*sizeof(double) );
M*sizeof(magma_int_t));

(ldda*M)*sizeof(double) );

magma_malloc_cpu((void **) &h_A,
magma_malloc_cpu((void **) &ipiv,
magma_malloc((void **) &d_A,
...
magma_dsetmatrix( M, M, h_A, lda, d_A, ldda );
magma_dgetrf_gpu( M, M, d_A, ldda, ipiv, &info);
magma_dgetmatrix( M, M, d_A, ldda, h_A, lda);
...

cublasShutdown();

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

9 / 45

Selección tamaño bloque en MAGMA GPU

Función de la GPU y del tamaño del problema, pero no de la CPU
LU

magma_int_t arch = magma_getdevice_arch();

if ( arch >= 300 ) {
if
(m < 3072) return 64;
else if (m < 10240) return 128;
else
return 256;

// 3.x Kepler

// 1.x and 2.x Fermi

(m < 4096) return 64;
return 128;

}
else {
if
else

}

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

10 / 45

Nueva CUBLASXT

Descripción general
La API cublasXt proporciona un interfaz multi-GPU al host: la
aplicación sólo reserva espacio para las matrices en el host. No hay
restricción en el tamaño (siempre y cuando quepan en memoria del host).
Sólo disponible para rutinas BLAS3.

Esquema cíclico por bloques

Explicación

Las matrices se dividen en
bloques cuadrados de
tamaño NBxNB.
Por cada GPU se crea un
thread de CPU encargado
de las transferencias de
memoria necesarias y de
lanzar las operaciones
cuBLAS requeridas.

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

11 / 45

Ejemplo de llamada a rutina en XT CUBLAS

XTDGEMM

h_A = (double *)malloc(sizeof(double)*szeA);
h_B = (double *)malloc(sizeof(double)*szeB);
h_C = (double *)malloc(sizeof(double)*szeC);
...
// cudaMalloc((void **) &d_A, sizeof(double)*ldda*K);
// cudaMalloc((void **) &d_B, sizeof(double)*lddb*N);
// cudaMalloc((void **) &d_C, sizeof(double)*lddc*N);
...
// cublasSetMatrix(M, K, sizeof(double), h_A, lda, d_A, ldda);
// cublasSetMatrix(K, N, sizeof(double), h_B, ldb, d_B, lddb);

cublasXtCreate(&handle);
cublasXtDgemm(handle, CUBLAS_OP_N, CUBLAS_OP_N, M, N, K,

&alpha, h_A, lda, h_B, ldb, &beta,

h_C, ldc);

// cublasGetMatrix(M, N, sizeof(double), d_C, lddc, h_C, ldc);

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

12 / 45

DGEMM: MKL en CPU, CUBLAS y XTCUBLAS

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

13 / 45

100020003000400050006000700080009000100000100200300400500600700matrixsizeGFLOPSWITHMEMORYTRANSFER2TeslaK20c,706MHz,13MPx192Cores(2496Cores).IntelXeonE5-26202.00GHz(12cores)MKLDGEMMCUBLASDGEMM1GPUCUBLASXtDGEMM2GPUCUBLASXtDGEMM Influencia del tamaño de bloque en XTCUBLAS

Prefijado a 1024
Se selecciona con la rutina
cublasXtSetBlockDim(cublasXtHandle t handle, int
blockDim)

Resultados con DGEMM
4224
NB
486.98
768
535.31
1024
1536
661.07
2048
658.25
2304
683.57
2560
649.76
615.67
2816
542.33
3328
N
1.8
NB
(UPCT)
Luis-Pedro García

5760
546.22
673.32
868.26
867.30
857.42
814.22
799.93
812.37
3.8

7296
585.18
674.42
938.00
975.04
889.12
990.51
966.67
931.37
3.6

8832
610.99
772.81
1032.65
1056.46
1126.21
1055.60
960.67
1073.27
3.8

[email protected]

10368
637.09
751.77
1077.09
1018.25
1226.5
1144.9
1176.82
980.38
3.7

11136
642.92
837.12
1023.83
1146.27
1243.94
1243.37
1270.02
1111.05
4.0
14 / 45

5 de Diciembre, 2014

DGEMM XTBLAS. INFLUENCIA NB y ALGORITMO

Las prestaciones dependen del tamaño de bloque y del algoritmo.

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

15 / 45

4500500055006000650070007500800085009000950010000105001100040050060070080090010001100120013001400matrixsizeGFLOPSWITHMEMORYTRANSFER2TeslaK20c,706MHz,13MPx192Cores(2496Cores).IntelXeonE5-26202.00GHz(12cores)2GPUXtDGEMM2GPUXtDGEMMNBOPT2GPU-OMP-DGEMM Nueva NVBLAS

Descripción general
La librería NVBLAS, en aplicaciones que realizan llamadas a BLAS para
CPU, es capaz de encaminar dinámicamente esas llamadas a una o más
GPUs (usando la API de XTCUBLAS).

Se requiere volver a enlazar
icc call_dgemm.o -o call_dgemm -lnvblas -lmkl_intel_lp64 \
-lmkl_intel_thread -lmkl_core -lpthread -lm -openmp

Ejemplo código

h_A = (double *)malloc(sizeof(double)*szeA);
h_B = (double *)malloc(sizeof(double)*szeB);
h_C = (double *)malloc(sizeof(double)*szeC);
...
dgemm_("No Transpose", "No Transpose", &M, &N, &K,

&alpha, h_A, &lda, h_B, &ldb, &beta, h_C, &ldc);

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

16 / 45

Nueva NVBLAS. Configuración

Archivo nvblas.conf
# Specify which output log file (default is stderr)
NVBLAS_LOGFILE nvblas.log

#Put here the CPU BLAS fallback Library of your choice
#NVBLAS_CPU_BLAS_LIB libopenblas.so
NVBLAS_CPU_BLAS_LIB libmkl_rt.so

# List of GPU devices Id to participate to the computation
# By default if no GPU are listed, only
# device 0 will be used
#NVBLAS_GPU_LIST 0 2 4
#NVBLAS_GPU_LIST ALL
NVBLAS_GPU_LIST ALL0

# Tile Dimension
NVBLAS_TILE_DIM 2048

Luis-Pedro García

(UPCT)

[email protected]

5 de Diciembre, 2014

17 / 45

Nueva NVBLAS. Configuración

Archivo nvblas.conf
# Autopin Memory
NVBLAS_AUTOPIN_MEM_ENABLED

#List of BLAS routines that are prevented from running on GPU
# The current list of BLAS routines supported by NVBLAS are
# GEMM, SYRK, HERK, TRSM, TRMM, SYMM, HEMM, SYR2K, HER2K

#
  • Links de descarga
http://lwp-l.com/pdf11362

Comentarios de: Rutinas y Librerías de Álgebra Lineal en Sistemas Many-Core (GPUs y MIC) (0)


No hay comentarios
 

Comentar...

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad