16
CILK PROGRAMAÇÃO PARALELA PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SUL PROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO Aline Zanin Rômulo Reis de Oliveira

Cilk

Embed Size (px)

Citation preview

Page 1: Cilk

CILK

PROGRAMAÇÃO PARALELA

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Aline Zanin Rômulo Reis de Oliveira

Page 2: Cilk

2

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA 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;

• Lançamento Cilk ++

Page 3: Cilk

3

Linguagem de programação de aplicações multhithread dinâmicas em processadores

com memoria compartilhada

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Page 4: Cilk

4

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA 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

• Busca heurística

Page 5: Cilk

5

• 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;

• Work-stealing scheduler;

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Page 6: Cilk

6

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Work-stealing Scheduler Etapa 01

Page 7: Cilk

7

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Work-stealing Scheduler Etapa 02

Page 8: Cilk

8

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Work-stealing Scheduler Etapa 03

Page 9: Cilk

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); }}

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); }}

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. 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.

Page 10: Cilk

FIBONACCI

int fib (int n) {if (n<2) return (n); else { int x,y; x = fib(n-1); y = fib(n-2); return (x+y); }}

int fib (int n) {if (n<2) return (n); else { int x,y; x = fib(n-1); y = fib(n-2); return (x+y); }}

C elisionC elision

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); }}

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); }}

Cilk codeCilk code

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Page 11: Cilk

11

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

• 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

• Lançamento da especificação

CILK PLUS

Page 12: Cilk

12

Cilk_for: Indica laços de repetição que podem ser paralelizados;

Cilk_spawn: Especifica que uma função pode ser executada em paralelo;

Cilk_sync: Especifica que todas as chamadas geradas em uma função devem ser completadas antes que a execução continue;

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

PALAVRAS CHAVES CILK PLUS

Page 13: Cilk

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; }

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; }

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Page 14: Cilk

14

cilk_for (int i = 0; i < 8; ++i){ do_work(i); }

cilk_for (int i = 0; i < 8; ++i){ do_work(i); }

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

Page 15: Cilk

15

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

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.

CONCLUSÃO

Page 16: Cilk

16

PONTIFÍCIA UNIVERSIDADE CATÓLICA DO RIO GRANDE DO SULPROGRAMA DE PÓS GRADUAÇÃO EM CIENCIA DA COMPUTAÇÃO

REFERÊNCIAS[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/TR-645.[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.