1 / 7

Parallel Systems Lecture 10

Parallel Systems Lecture 10. Dr. Guy Tel- Zur. Administration. Home assignments status Final presentation status Open Excel file ps2013a.xlsx Allinea DDT Debugger? Lab #2 will take place on 17/1/13 (lecture #12) @ lab217. Today’s Agenda.

chiku
Download Presentation

Parallel Systems Lecture 10

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Parallel SystemsLecture 10 Dr. Guy Tel-Zur

  2. Administration • Home assignments status • Final presentation status • Open Excel file ps2013a.xlsx • Allinea DDT Debugger? • Lab #2 will take place on 17/1/13 (lecture #12) @ lab217

  3. Today’s Agenda • OpenMP examples (SC99 pi integration using Visual Studio). • Openmp_examples.pptx • Combining OpenMP and MPI • hpi.c, hybridpi.c, lecture11-12.pdf • Sorting Algorithms • Wilkinson & Allen chapter 10 • Numerical Algorithms • Wilkinson & Allen chapter 11

  4. Hybrid MPI + OpenMP Demo Machine File: Node1 Node2 Node3 node4 Each node has many cores MPI mpicc -o mpi_outmpi_test.c -fopenmp OpenMP Demo: cd ~/mpi program name: hybridpi.c

  5. Hybrid MPI+OpenMP continued

  6. Hybrid Pi (MPI+OpenMP) #include <stdio.h> #include <mpi.h> #include <omp.h> #define NBIN 100000 #define MAX_THREADS 8 int main(int argc,char **argv) { int nbin,myid,nproc,nthreads,tid; double step,sum[MAX_THREADS]={0.0},pi=0.0,pig; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&myid); MPI_Comm_size(MPI_COMM_WORLD,&nproc); nbin = NBIN/nproc; step = 1.0/(nbin*nproc);

  7. #pragma omp parallel private(tid) { int i; double x; nthreads = omp_get_num_threads(); tid = omp_get_thread_num(); for (i=nbin*myid+tid; i<nbin*(myid+1); i+=nthreads) { x = (i+0.5)*step; sum[tid] += 4.0/(1.0+x*x); } printf("rank tid sum = %d %d %e\n",myid,tid,sum[tid]); } for(tid=0; tid<nthreads; tid++) pi += sum[tid]*step; MPI_Allreduce(&pi,&pig,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); if (myid==0) printf("PI = %f\n",pig); MPI_Finalize(); return 0; }

More Related