英特尔多核课程编程大学版3.openmp课件.pptxVIP

  • 3
  • 0
  • 约2.98千字
  • 约 77页
  • 2022-05-06 发布于北京
  • 举报

英特尔多核课程编程大学版3.openmp课件.pptx

Programming with OpenMP*;Objectives;Agenda;What Is OpenMP?;Programming Model;A Few Syntax Details to Get Started;Agenda;;Activity 1: Hello Worlds;Agenda;Worksharing;omp for construct;;The Private Clause;Activity 2 – Parallel Mandelbrot ;;Schedule Clause Example;Activity 2b –Mandelbrot Scheduling ;Agenda;;omp sections;Functional Level Parallelism w sections;Advantage of Parallel Sections;Agenda;New Addition to OpenMP;What are tasks?;Simple Task Example;Task Construct – Explicit Task View;Why are tasks useful?;Activity 3 – Linked List using Tasks;;;Agenda;Data Scoping – What’s shared;Data Scoping – What’s private;A Data Environment Example;int fib ( int n ) { int x,y; if ( n 2 ) return n; #pragma omp task x = fib(n-1); #pragma omp task y = fib(n-2); #pragma omp taskwait return x+y };int fib ( int n ) { int x,y; if ( n 2 ) return n; #pragma omp task shared(x) x = fib(n-1); #pragma omp task shared(y) y = fib(n-2); #pragma omp taskwait return x+y; };List ml; //my_list Element *e; #pragma omp parallel #pragma omp single { for(e=ml-first;e;e=e-next) #pragma omp task process(e); };List ml; //my_list Element *e; #pragma omp parallel #pragma omp single { for(e=ml-first;e;e=e-next) #pragma omp task firstprivate(e) process(e); };List ml; //my_list Element *e; #pragma omp parallel #pragma omp single private(e) { for(e=ml-first;e;e=e-next) #pragma omp task process(e); };List ml; //my_list #pragma omp parallel { Element *e; for(e=ml-first;e;e=e-next) #pragma omp task process(e); };Agenda;Example: Dot Product;Race Condition;;Protect Shared Data;;;Reduction Example;Numerical Integration Example;A range of associative operands can be used with reduction Initial values are the ones that make sense mathematically;Activity 4 - Computing Pi;Denotes block of code to be executed by only one thread First thread to arrive is chosen Implicit barrier at end;Denotes block of code to be executed only by the master thread No implici

文档评论(0)

1亿VIP精品文档

相关文档