5. Caminho para o Exascale Computing
Intel is only company on the planet that is targeting the broad range of technologies
and devices to bring a great solution to every segment of the Technical Computing
market.
Network
& Fabrics
Software
& Services
Compute
Intel® Xeon®
Intel® Xeon Phi™
I/O &
Storage
CAS
Intel®
Cluster
ReadyIntel® Enterprise Edition
for Lustre* software
Power efficiency
Resiliency
Reliability
6. 6
Introdução
Modelos de Programação Paralela
1. Decidir a divisão dos blocos de dados entre os processadores
2. Mesma operação, dados diferentes por unidade de execução
Ex: Encontrar o maior elemento em um vetor
UP 0 UP 1 UP 2 UP 3
Decomposição de domínio
“Data Decomposition”
UP = Unidade de Processamento
7. 7
1. Dividir tarefas entre os processadores
2. Decidir quais elementos de dados serão acessados por qual processador
(leitura/escrita)
f()
s()
r()
q()h()
g()
UP 1
UP 0
UP 2
f()
g()
r()
h() q()
r()
s()
Decomposição de tarefas – “Task paralellism”
Introdução
Modelos de Programação Paralela
8. 8
Tipo especial de “Task Paralellism”. Também chamado de “Assembly line” parallelism
Padrão utilizado tanto em software quanto em hardware
Tasks conectadas em um modelo
“produtor-consumidor”
Pipeline
Stage 4Stage 3Stage 2Stage 1
A1 B1 C1
A2 B2 C2
A3 B3 C
A4
Introdução
Modelos de Programação Paralela
9. for( i = 0; i < 3; i++)
a[i] = b[i]/2.0;
9
b[0] b[1] b[2]
a[0] a[1] a[2]
///
2 2 2
Decomposição de domínio possível
Introdução
Modelos de Programação Paralela
10. for( i = 1; i < 4; i++)
a[i] = a[i-1]*b[i];
10
b[1] b[2] b[3]
a[1] a[2] a[3]
***
a[0]
Decomposição de domínio falha neste caso
Introdução
Modelos de Programação Paralela
11. a = f(x,y,z);
b = g(w,x);
t = a + b;
c = h(z);
s = t/c;
11
Decomposição de
tarefas com 3
cores
x
f
w y z
ab
g
t
c
s/
h
+
CPU 0
CPU 1 CPU 2
Introdução
Modelos de Programação Paralela
12. 12
Como aplicar tais padrões de programação paralela ?
Das linguagens de programação mais populares, nenhuma foi criada
com o objetivo de explorar paralelismo
Necessidade de adaptação destas linguagens “modernização de
código”
Objetivos
Performance
+
Produtividade
+
Portabilidade
Sequencial
Paralelo
Clusters
Introdução
Modelos de Programação Paralela
13. Principles of Delivered Performance
*Other logos, brands and names are the property of their respective owners.
All products, computer systems, dates and figures specified are preliminary based on current expectations, and are subject to change without notice.
Intel® Xeon® Processor generations from left to right in each chart: 64-bit, 5100 series, 5500 series, 5600 series, E5-2600, E5-2600 v2
Intel® Xeon Phi™ Product Family from left to right in each chart: Intel® Xeon Phi™ x100 Product Family (formerly codenamed Knights Corner), Knights Landing (next-generation Intel® Xeon Phi™
Product Family)
Work
Time =
Work
Instruction
Instruction
Cyclex
Cycle
Timex
FrequencyIPC
Não podemos mais contar somente com aumento da frequência
Algoritmo eficiente mesma carga de trabalho com menos
instruções
Compilador reduz as instruções e melhora IPC
Uso eficiente da Cache: melhora IPC
Vetorização: mesmo trabalho com menos instruções
Paralelização: mais instruções por ciclo
Path LengthPerformance
Addressing All Operands with Common CPU Approach
14. 14
for (i=0;i<=MAX;i++)
c[i]=a[i]+b[i];
+
c[i+7] c[i+6] c[i+5] c[i+4] c[i+3] c[i+2] c[i+1] c[i]
b[i+7] b[i+6] b[i+5] b[i+4] b[i+3] b[i+2] b[i+1] b[i]
a[i+7] a[i+6] a[i+5] a[i+4] a[i+3] a[i+2] a[i+1] a[i]
Vector
- Uma instrução
- Oito operações
+
C
B
A
Scalar
- Uma instrução
- Uma operação
• O que é e ?
• Capacidade de realizar uma
operação matemática em dois ou
mais elementos ao mesmo tempo.
• Por que Vetorizar ?
• Ganho substancial em performance !
Introdução
Vetorização
18. 18
Intel® AVX
Vector size: 256bit
Data types: 32 and 64 bit floats
VL: 4, 8, 16
Sample: Xi, Yi 32 bit int or float
Intel® MIC
Vector size: 512bit
Data types:
32 and 64 bit integers
32 and 64bit floats
(some support for
16 bits floats)
VL: 8,16
Sample: 32 bit float
X4
Y4
X4opY4
X3
Y3
X3opY3
X2
Y2
X2opY2
X1
Y1
X1opY1
0127
X8
Y8
X8opY8
X7
Y7
X7opY7
X6
Y6
X6opY6
X5
Y5
X5opY5
128255
X4
Y4
…
X3
Y3
…
X2
Y2
…
X1
Y1
X1opY1
0
X8
Y8
X7
Y7
X6
Y6
...
X5
Y5
…
255
…
…
…
…
…
…
…
…
…
X9
Y9
X16
Y16
X16opY16
…
…
…
...
…
…
…
…
…
511
X9opY9 X8opY8 …
Introdução
Vetorização
19. Cinco possíveis abordagens:
Bibliotecas matemáticas
– Ex.: Intel® Math Kernel Library (MKL)
Auto-vetorização
– Trabalho a cargo do Compilador
Array Notation – Cilk Plus
– Notação vetorial na linguagem de programação explicitando a vetorização
Semi auto-vetorização
– SIMD
– IVDEP
– VECTOR E NOVECTOR
C/C++ Vector classes
– Intrinsics
19
Introdução
Vetorização
20. 20
Facilidade de Uso
Ajuste Fino
Vectors
Intel® Math Kernel Library
Array Notation: Intel® Cilk™ Plus
Auto vectorization
Semi-auto vectorization:
#pragma (vector, ivdep, simd)
C/C++ Vector Classes
(F32vec16, F64vec8)
Devemos avaliar três fatores:
Necessidade de performance
Disponibilidade de recursos
para otimizar o código
Portabilidade do código
Introdução
Vetorização
21. void foo() /* Intel® Math Kernel Library */
{
float *A, *B, *C; /* Matrices */
sgemm(&transa, &transb, &N, &N, &N, &alpha, A, &N, B, &N, &beta, C, &N);
}
Intel® Xeon® processor Intel® MIC co-processor
Implicit automatic offloading requires no code
changes, simply link with the offload MKL
Library
Introdução
Intel® Math Kernel Library (Intel® MKL)
23. 1º Passo: Parâmetros para o Compilador
vec-report[n] : relatório do que foi e do que pode ser vetorizado . “n” determina o nível de
detalhes
guide : GAP – Guided Auto-parallelization . Sugestões de como vetorizar/paralelizar
O[n] : Nível de otimização O2 (default) já inclui auto-vetorização
x[code] : Otimiza as instruções de acordo com a arquitetura do processador.
-xAVX , -xCORE-AVX2, -xSSE4.2, -xSSE4.1, -xSSSE3, -xSSE3
xHost: Compilador checa o processador e aplica a melhor instrução suportada
msse2 (default): (Windows: /arch:SSE2)
23
Auto-vetorização
24. m<extension>: checagem para processadores “não Intel®”
Não aplica otimizações específicas para processadores Intel®
Compatibilidade para processadores Intel® e “não Intel®”
Instruções AVX suportadas em processadores “não Intel®”
ax<extension>
Compilador gera dois caminhos: “genérico” e “otimizado”
Ex: “icc -axCORE-AVX2 –axSSE4.2 codigo.c “ em um processador que suporta somente SSE
4.2, o compilador ignora a instrução CORE-AVX2
24
Auto-vetorização
26. Requisitos para um loop ser vetorizado
Em loops encadeados, o loop mais interno será vetorizado
Deve conter apenas blocos básicos, ex.: uma única linha de código sem condições (if
statements) ou saltos (go to)
Quantidade de iterações do loop deve ser conhecida antes de sua execução, mesmo que
em tempo de execução
Sem dependências entre os elementos a serem calculados
GAP – Guided Autoparallelization (Intel® Compiler “-guide” ) pode ajudar
26
Loop Não Vetorizável – Dependência sobre a[i-1]
for (i=1; i<MAX; i++) {
d[i] = e[i] – a[i-1];
a[i] = b[i] + c[i];
}
Auto-vetorização
28. Tipos de diretivas:
SIMD
Permissão total ao compilador vetorizar
Responsabilidade da vetorização é do programador
Mais agressivo que IVDEP ou VECTOR ALWAYS
IVDEP
Remove dependências entre ponteiros nos vetores
VECTOR e NOVECTOR
“Dicas” que mudam a heurística default do compilador
Habilita/desabilita vetorização
Alinhamento de dados, vetorização de loops sobressalentes
28
Diretivas - #pragma
29. Diretivas SIMD: forçando a vetorização
#pragma simd [clause[ [,] clause] ... ]
Guia o compilador para casos onde a auto-vetorização não é possível
Atributos padrão:
VECTORLENGTH N : tamanho do vetor (2, 4, 8 ou 16)
VECTORLENGTHFOR (data-type) : tamanho_vetor/sizeof(type)
PRIVATE (VAR1[, VAR2]...) : variável privada para cada iteração do loop
FIRSTPRIVATE (VAR1[, VAR2]...) : broadcast do valor inicial a todas as outras instâncias para cada iteração
LASTPRIVATE (VAR1[, VAR2]...) : broadcast do valor original as outras instâncias no final do loop
LINEAR (var1:step [, var2:step2]...) : incrementa número de steps para cada variável em um loop, unit-stride vector
REDUCTION (oper:var1[, var2]...) : Aplica operação de redução (+, *, -, AND, OR, EQV, NEQV) nas variáveis indicadas
ASSERT : Direciona o compilador a produzir um erro ou um warning quando a vetorização falha
29
Diretivas - #pragma
30. Diretivas SIMD: forçando a vetorização
Programador é responsável por checar a validade dos resultados
30
Diretivas - #pragma
Diretivas SIMD
Adição de vetores – C/C++
1.__declspec(align(16)) float a[MAX], b[MAX], c[MAX];
2.#pragma simd
3.for (i=0; i<MAX; i++)
4. c[i] = a[i]+b[i];
31. Diretivas VECTOR
#pragma vector aligned | unaligned : comunica ao compilador que os dados estão
alinhados
#pragma vector nontemporal | temporal ou “-opt-streaming-store always” : uso
ótimo do cache em casos de write-only; os dados não precisam ser armazenados na
cache, e sim diretamente na memória. Usar “#pragma vector aligned” antes.
#pragma novector : Instrui o compilador a não vetorizar. Útil em loops com muitas
condições (ifs)
#pragma vector always : força vetorização automática independente da heurística do
compilador
31
Diretivas - #pragma
32. Diretivas VECTOR
Streaming stores (Xeon and Xeon Phi)
Escritas na memória que não necessitam de prévias operações de
leitura.
Evita prefetch da memória para a cache
Nontemporal buffer
Otimiza bandwith
-opt-streaming-stores [always | never | auto ]
#pragma vector nontemporal[(var1[, var2, ...])]
https://software.intel.com/en-us/articles/memcpy-memset-optimization-
and-control
https://software.intel.com/sites/default/files/article/326703/streaming-
stores-2.pdf
32
Diretivas - #pragma
33. 33
Diretivas IVDEP
#pragma ivdep: Ignora dependências de variáveis
“-restrict” (necessário parâmetro ao compilador “-restrict”) : similar a
“ivdep” , informa que determinada variável não possui restrições/dependências
Diretivas - #pragma
//-restrict necessario ao compilador neste caso
void vectorize (float* restrict a, float* restrict b, float* c, float* d, int n)
{
int i;
for (i =0; i<n; i++) {
a[i] = c[i] * d[i];
b[i] = a[i] + c[i] - d[i];
}
ou
#pragma ivdep
void vectorize(float* a, float* b, float* c, float* d, int n) { … }
34. #pragma loop count : Informa ao compilador o número de
loops . Útil para melhores predições de vetorização
__assume_aligned : elimita checagem se os dados estão
alinhados, porém e´specífico para cada vetor
34
Diretivas - #pragma
void myfunc( double p[] ) {
__assume_aligned(p, 64);
for (int i=0; i<n; i++){
p[i]++;
}
int i;
int mysum(int start, int end, int a)
{
int iret=0;
#pragma loop_count min(3), max(10),
avg(5)
for (i=start;i<=end;i++)
iret += a;
return iret;
}
35. __attribute__((aligned(64)) ou __mm_malloc() / __mm__free() :
alocação estática e dinâmica de dados alinhados
-opt-assume-safe-padding : Avisa o compilador que vetores com
bytes extras, para que fiquem múltiplos do tamanho da cache, serão
inseridos . Evita “loop sobressalente”
https://software.intel.com/en-us/articles/utilizing-full-vectors
35
Diretivas - #pragma
float data[n] __attribute__((aligned(64))); (Linux)
__declspec(align(64)) float A[n]; (Windows)
float *A = (float*)_mm_malloc(n*sizeof(float), 16);
// ...
_mm_free(A);
37. Array notation
Elemental functions
37
Vetorização com Intel® Cilk™ Plus
38. Vetorização com Intel® Cilk™ Plus
Array notations
Extensões C++ Intel® Cilk Plus™ para operações com
vetores
Notação vetorial em C/C++
https://software.intel.com/en-us/articles/getting-started-with-intel-cilk-plus-array-notations
38
39. 39
A[:] += B[:]; // todo o vetor é computado
A[0:16] += B[32:16]; // A(0 até 15) + B(32 até 47)
A[0:16:2] += B[32:16:4] // A(0, 2, 4, ...30) + B(32, 36, 38, ... 92)
Compatibilidade com compiladores não-Intel
#ifdef __INTEL_COMPILER
A[:] += B[:];
#else
for (int i=0; i<16; i++)
A[i] += B[i];
#endif
Vetorização com Intel® Cilk™ Plus
Array notations
40. 40
Adição de vetores – C/C++ - Dados alinhados
1.__declspec(align(16)) float a[MAX], b[MAX], c[MAX];
2.c[i:MAX] = a[i:MAX]+b[i:MAX];
Vetorização com Intel® Cilk Plus
Array notations
41. 41
Possibilita chamar versão vetorizada da função escalar
Excelente em casos onde as funções estão implementadas
em biblioteca de terceiros
https://software.intel.com/en-us/articles/elemental-functions-
writing-data-parallel-code-in-cc-using-intel-cilk-plus
Vetorização com Intel® Cilk Plus
Elemental functions
42. 42
Lib X
float my_simple_add(float x1, float x2){
return x1 + x2;
}
Elemental Function
__attribute__(vector) float my_simple_add(float x1, float x2);
// ...em outro arquivo de código
#pragma simd
for (int i=0; i < N, ++i) {
output[i] = my_simple_add(inputa[i], inputb[i]);
}
Ou
my_simple_add(inputA[:], inputB[:]);
Vetorização com Intel® Cilk Plus
Elemental functions
44. O que é Intel® C++ Intrinsic ?
Provê acesso a ISA (Instruction Set Architecture) através de código C/C++ ao invés de
código Assembly
Ganho de performance próximo a códigos Assembly com a facilidade de C/C++
Vetorização – Extensões SIMD (Simple Instructions Multiple Data)
44
Intrinsics
47. General Purpose vs. Specialty Hardware
Investment locked into one
architecture
Reusable, Portable, Scalable
*Other logos, brands and names are the property of their respective owners.
All products, computer systems, dates and figures specified are preliminary based on current expectations, and are subject to change without notice.
Device-Specific Applications
(Accelerators)
Applications Suitable for Many Architectures
(CPU)
48. Conclusões
48
Vetorização
Permite obter mais performance
Uso de padrões abertos
Mesma técnica de programação para
CPUs e Co-processadores
Vários maneiras de vetorizar:
Facilidade ou “Ajuste fino”
50. Intel® Innovation Center &
Intel ® Parallel Computing Centers
Leverage Expertise & Application Development in HPC
Intel® Innovation Center
Competence Center
Test & Dev. Environment
HPC & Big Data Applications
Universities / Government
HPC Educational Center
Accelerator Program
Startup Incubator
Accelerator Program
Solution Center
“HPC as a Service” Prototyping
PoCs in many verticals:
Oil & Gas, Heathcare & Life Sciences,
Agriculture, Manufacture & Infra-structure, Financial
51. Intel® Innovation Center &
Intel® Parallel Computing Centers
Leverage Expertise & Application Development in HPC
• Modernizing applications to increase parallelism and
scalability
• Leverage cores, caches, threads, and vector capabilities of
microprocessors and coprocessors.
• Current centers in Brazil (more to come):
52. HPC Verticals
Leverage Expertise & Application Development in HPC
Oil & Gas
Ex. Petrobras,
British Gas,
SENAI
Reservoir
Simulation
Seismic Data
Analysis
Data
Visualization
Transport.
Ex. DENATRAN
Traffic Mgt
Traffic
Surveillance
Taxes Payment
Parking Mgt
Tolls
Health Care
Life Science
Ex. LNCC
Genome Projects
(Cure of Diseases)
Biology Systems
Image
Processing for
Medicine
Modeling &
Simulation for
Medicine
Agriculture
Ex. Embrapa
Modeling,
Simulation &
Forecast in
Agricultural
Production
Development of
seeds more
resistent to
wheather
conditions
Biofuels
Production
Manufactur
e &Infra.
Ex. Embraer,
Odebrecht
Construction &
Engineering:
• Structural Calculus / Design of
new Products
• 3D / CAD / CAM
Aeronautics:
• Aerodynamics
• Flight Simulator
• Virtual Reality
Automotive Industry:
• Car Design
• Crash Simulation
Computational
Mechanics
• Fluids & Dynamics
• Thermodynamics
• Solid Mechanics
Financial &
Telcos
Ex. Itau
Derivatives
trading
Stocks (Monte
Carlo
simulations)
Our goal is to interact with each vertical in order to support the ecosystem.
The next wave is to use HPC + Big Data solutions based on the “Software as a Service” model.
IaaS PaaS SaaS
54. From CPU to Solutions
Intel is only company on the planet that is targeting the broad range of technologies
and devices to bring a great solution to every segment of the Technical Computing
market.
Network
& Fabrics
Software
& Services
Compute
Intel® Xeon®
Intel® Xeon Phi™
I/O &
Storage
CAS
Intel®
Cluster
ReadyIntel® Enterprise Edition
for Lustre* software
Power efficiency
Resiliency
Reliability
55. Next Intel® Xeon Phi™ Product Family
Codenamed Knights Landing
All products, computer systems, dates and figures specified are preliminary based on current expectations, and are subject to change
without notice.
Available in Intel cutting-
edge 14 nanometer process
Stand alone CPU or PCIe
coprocessor – not bound by
‘offloading’ bottlenecks
Integrated Memory -
balances compute with
bandwidth
Parallel is the path forward, Intel is your roadmap!
55
56. All products, computer systems, dates and figures specified are preliminary based on current expectations, and are subject to change without notice. 1Over 3 Teraflops of peak theoretical
double-precision performance is preliminary and based on current expectations of cores, clock frequency and floating point operations per cycle. FLOPS = cores x clock frequency x floating-
point operations per second per cycle. . 2Modified version of Intel® Silvermont microarchitecture currently found in Intel® AtomTM processors. 3Modifications include AVX512 and 4
threads/core support. 4Projected peak theoretical single-thread performance relative to 1st Generation Intel® Xeon Phi™ Coprocessor 7120P (formerly codenamed Knights Corner). 5 Binary
Compatible with Intel Xeon processors using Haswell Instruction Set (except TSX) . 6Projected results based on internal Intel analysis of Knights Landing memory vs Knights Corner (GDDR5).
7Projected result based on internal Intel analysis of STREAM benchmark using a Knights Landing processor with 16GB of ultra high-bandwidth versus DDR4 memory only with all channels
populated.
Unveiling Details of Knights
Landing
(Next Generation Intel® Xeon Phi™ Products)
Conceptual—Not Actual Package Layout
2nd half ’15
1st commercial systems
3+ TFLOPS1
In One Package
Parallel Performance & Density
On-Package Memory:
up to 16GB at launch
5X Bandwidth vs DDR47
Compute: Energy-efficient IA cores2
Microarchitecture enhanced for HPC3
3X Single Thread Performance vs Knights Corner4
Intel Xeon Processor Binary Compatible5
1/3X the Space6
5X Power Efficiency6
.
.
.
.
.
.
Integrated Fabric
Intel® Silvermont Arch.
Enhanced for HPC
Processor Package
…
Platform Memory: DDR4 Bandwidth and
Capacity Comparable to Intel® Xeon®
Processors
Jointly Developed with Micron Technology
57. Intel® InfiniBand Technology
Overview
END-TO-END INFINIBAND PRODUCT LINE
DESIGNED FROM THE START FOR HPC
OPTIMIZE HPC INTERCONNECT
• High Messaging Rate
• Low End-to-End Latency - that scales
• Excellent Collectives Performance
• More Effective Bandwidth
PROVIDING BETTER HPC APPLICATION
PERFORMANCE AND SCALABILITY
(PRICE/PERFORMANCE)
Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems,
components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated
purchases, including the performance of that product when combined with other products.
See slide notes for more configuration and test details
58. Intel® OMNI Scale
The Next-Generation Fabric
Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems,
components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated
purchases, including the performance of that product when combined with other products.
See slide notes for more configuration and test details
Designed for Next Generation HPC
Host and Fabric Optimized
Supports Entry to Extreme Scale
End-to-End Solution
Intel Omni
Scale
Intel Omni
Scale
Knights
Landin
g
14nm
generation
INTEGRATION
Intel®
Processor
Fabric
Controller
32 GB/sec
System IO Interface (PCIe)
Fabric Interface
Today
Intel ® Processor
Fabric Controller
100+ GB/sec
Tomorrow
Fabric Interface
intel.com/OmniScale
59. 59
Unleashing CPU Performance in HPC
via Intel® Software
Cloud Computing
Virtualization
Open Source
Cloud Mgt
Comerical
Cloud Mgt
Applications
Dist. Compute
Cloudera Hadoop Dist.
HPC Computing
Intel® Parallel Studio XE
and Intel® Cluster Studio XE
Intel® Cluster Ready
Intel ® Data Center Manager ( Power and Thermal Mgt)
Intel® Lustre
Intel® Lustre
Intel® True
Scale Fabric Management and
Software Tools
Intel® True Scale fabric
Intel® Innovation Center Architecture
60. • Architecture, setup, and
programming resources
• Self-guided training
• Case studies
• Information on tools
and ecosystem
• Support through
community forum
INTEL® XEON PHI™ COPROCESSOR
DEVELOPER SITE
View at: http://software.intel.com/mic-
developer/
62. OPTIMIZATION NOTICE
62
Optimization Notice
Intel’s compilers may or may not optimize to the same degree for non-Intel
microprocessors for optimizations that are not unique to Intel microprocessors.
These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other
optimizations. Intel does not guarantee the availability, functionality, or
effectiveness of any optimization on microprocessors not manufactured by
Intel. Microprocessor-dependent optimizations in this product are intended for
use with Intel microprocessors. Certain optimizations not specific to Intel
microarchitecture are reserved for Intel microprocessors. Please refer to the
applicable product User and Reference Guides for more information regarding
the specific instruction sets covered by this notice.
Notice revision #20110804