1. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
CILK
PROGRAMAÇÃO PARALELA
Aline Zanin
Rômulo Reis de Oliveira
2. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
• Iniciado desenvolvimento em 1993;
• Criado a partir de três projetos;
• 1994 – Recebe nome de Cilk;
2
• Lançamento Cilk ++
3. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
3
Linguagem de programação de aplicações
multhithread dinâmicas em processadores
com memoria compartilhada
4. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
Exemplos de aplicações
• Computações de matrizes densas e esparsas
• Simulação de soldagem por fricção
• Evolução artificial
• Renderização de gráficos
4
• Busca heurística
5. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
• Cilk estende a liguagem C e C++;
• Cilk não é somente rápido, mas possui garantias de
performace ;
• O sistema de execução gerencia automaticamente os
aspectos de baixo nível de execução paralela;
5
• Work-stealing scheduler;
6. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
6
Work-stealing Scheduler Etapa 01
7. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
7
Work-stealing Scheduler Etapa 02
8. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
8
Work-stealing Scheduler Etapa 03
9. PALAVRAS CHAVES CILK
cilk int fib (int n) {
if (n<2) return (n);
else {
int x,y;
x = spawn fib(n-1);
y = spawn fib(n-2);
sync;
return (x+y);
}
}
Indica que o procedimento não
pode ser executado em paralelo. É
necessário que os procedimentos
anteriores tenham executados e
devolvido os seus resultados para o
frame principal.
Identifica que um processo
é Cilk e
pode receber
paralelização.
Esta palavra chave indica
que o procedimento pode
operar em paralelo com
outra execução de forma
segura.
10. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
FIBONACCI
int fib (int n) {
if (n<2) return (n);
else {
Cilk code
int x,y;
cilk int fib (int n) {
x = fib(n-1);
if (n<2) return (n);
y = fib(n-2);
else {
return (x+y);
int x,y;
}
x = spawn fib(n-1);
}
y = spawn fib(n-2);
sync;
C elision
return (x+y);
}
}
11. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
CILK PLUS
•
Cilk Plus é uma evolução de Cilk;
•
Julho de 2009, aquisição da Cilk Arts pela Intel;
•
2010, Lançamento da versão comercial de Cilk - Cilk Plus
11
• Lançamento da especificação
12. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
PALAVRAS CHAVES CILK PLUS
Cilk_for: Indica laços de repetição que podem ser
paralelizados;
Cilk_spawn: Especifica que uma função pode ser executada em
paralelo;
12
Cilk_sync: Especifica que todas as chamadas geradas em uma
função devem ser completadas antes que a execução continue;
13. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
13
int fib (int n)
{
if (n<2)
return n;
int x = cilk_spawn fib(n-1);
int y = fib(n-2);
cilk_sync;
return x+y;
}
14. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
14
cilk_for (int i = 0; i < 8; ++i)
{
do_work(i);
}
15. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
CONCLUSÃO
15
A utilização de cilk se torna simples por a mesma utilizar
apenas três palavras chaves e trabalhar com recursão,
entretanto essa simplicidade limita a aplicabilidade desta
solução para alguns problemas específicos. Por outro lado o
Cilk ++ apresenta um conjunto de palavras chaves mais
abrangente o que aumenta as possibilidades de uso da
tecnologia.
16. PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL
PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO
REFERÊNCIAS
16
[01] B. C. Kuszmaul. Synchronized MIMD Computing. PhD thesis, Department of Electrical Engineering and Computer Science,
Massachusetts Institute of Technology, May 1994. Available as MIT Laboratory for Computer Science Technical Report MIT/LCS/TR645.
[02] B. C. Kuszmaul. The StarTech massively parallel chess program. The Journal of the International Computer Chess Association,
18(1):3–20, Mar. 1995.
[03] C. E. Leiserson, Z. S. Abuhamdeh, D. C. Douglas, C. R. Feynman, M. N. Ganmukhi, J. V. Hill,W. D. Hillis, B. C. Kuszmaul, M. A.
St. Pierre, D. S. Wells, M. C. Wong, S.-W. Yang, and R. Zak. The network architecture of the Connection Machine CM-5. Journal of
Parallel and Distributed Computing, 33(2):145–158, 1996
[04]C. Joerg and B. C. Kuszmaul. Massively parallel chess. In Proceedings of the Third DIMACS Parallel Implementation Challenge,
Rutgers University, New Jersey, Oct. 17–19 1994
[05] Cilk 5.4.6 Reference Manual. Disponível em: http://supertech.csail.mit.edu/cilk/manual-5.4.6.pdf. Aceso em: 22 de agosto de 2013
[06] R. D. Blumofe and C. E. Leiserson. Scheduling multithreaded computations by work stealing. Journal of the ACM, 46(5):720–748,
Sept. 1999.
[07] R. D. Blumofe and C. E. Leiserson. Space-efficient scheduling of multithreaded computations. SIAMJournal on Computing,
27(1):202–229, Feb. 1998.
[08] Lee, Ting Angelina. Memory Abstractions for Parallel Programming. 2012. 163f. Dissertação Doutorado em Ciência da
Computação - Department of Electrical Engineering and Computer ScienceMassachusetts, Massachusetts Institute of Technology,
Massachusetts.
[09] M. Frigo, C. E. Leiserson, and K. H. Randall. The implementation of the Cilk-5 multithreaded language. In Proceedings of the ACM
SIGPLAN ’98 Conference on Programming Language Design and Implementation, pages 212–223, Montreal, Quebec, Canada, June
1998. Proceedings published ACM SIGPLAN Notices, Vol. 33, No. 5, May, 1998.
[10 ]Multithreaded Programming in Cilk Disponível em: http://supertech.csail.mit.edu/cilk/lecture-1.pdf. Consulta em 27 de agosto de
2013
[11] The Cilk Project. Disponível em: http://supertech.csail.mit.edu/cilk/ Aceso em: 22 de agosto de 2013
[12] Tutorial: Cilk Plus Keywords. Disponível em. http://www.cilkplus.org/tutorial-cilk-plus-keywords. Acesso em 23 de agosto de 2013
[13] M. Halbherr, Y. Zhou, and C. F. Joerg. MIMD-style parallel programming with continuation-passing threads. In Proceedings of the
2nd International Workshop on Massive Parallelism: Hardware, Software, and Applications, Capri, Italy, Sept. 1994.