1 / 20

Comparing Cray Tasking and OpenMP NERSC User Services

Comparing Cray Tasking and OpenMP NERSC User Services. Overview of Cray Tasking Overview of OpenMP Directives Comparison Mixing OpenMP with MPI. Cray Shared-Memory Multiprocessors. 1982: X-MP 1, 2, or 4 processors 1985: Cray-2 4 processors 1988: Y-MP 8 processors

hosea
Download Presentation

Comparing Cray Tasking and OpenMP NERSC User Services

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. Comparing Cray Tasking and OpenMPNERSC User Services Overview of Cray Tasking Overview of OpenMP Directives Comparison Mixing OpenMP with MPI

  2. Cray Shared-Memory Multiprocessors • 1982: X-MP • 1, 2, or 4 processors • 1985: Cray-2 • 4 processors • 1988: Y-MP • 8 processors • “Cray for the 90s”: C90 • 16 processors Cray Tasking vs. OpenMP - User Services Group

  3. Cray Tasking • Microtasking • Parallel loops • Macrotasking • Parallel regions • Autotasking • Emphasis on “auto” Cray Tasking vs. OpenMP - User Services Group

  4. History of OpenMP • Defined by OpenMP Architecture Review Board • Compaq/DEC, HP, IBM, Intel, SGI/Cray, Sun, etc. • Endorsed by software and application vendors • Absoft, The Portland Group, etc. • ANSYS, Fluent, Livermore Software, NAG, etc. • Fortran, C, and C++ bindings • Fortran specification released late 1997 • C and C++ specification released late 1998 • See http://www.openmp.org for complete details Cray Tasking vs. OpenMP - User Services Group

  5. Scope of OpenMP • Shared-memory explicit parallelism • Noautomatic parallelism • Some research into extending to distributed-memory environments • Directives, environment variables, runtime library routines Cray Tasking vs. OpenMP - User Services Group

  6. Cray Tasking Syntax • sentineldirective [argument …] [, directive …] • sentinel • cdir$ or !dir$ (cmic$ and !mic$ are obsolete) • Fixed format source • “normal” Fortran column rules • Free format source • sentinel begins anywhere on a line, but must be the first text • sentinel followed by anything other than space implies continuation • Multiple directives are comma-delimited • if a directive has required arguments, no other directives allowed Cray Tasking vs. OpenMP - User Services Group

  7. OpenMP Syntax • prefixdirective [clause[[,] clause]…] • Fixed format source • prefix: !$OMP, C$OMP, or *$OMP • “normal” Fortran source rules • Free format source • prefix: !$OMP • sentinel begins anywhere on a line, but must be the first text • “normal” Fortran source rules Cray Tasking vs. OpenMP - User Services Group

  8. Autotasking DOALL GUARD ENDGUARD PARALLEL ENDPARALLEL DOPARALLEL ENDDO CASE ENDCASE OpenMP PARALLEL DO CRITICAL END CRITICAL PARALLEL END PARALLEL DO END DO SECTIONS END SECTIONS Directive Correspondence Cray Tasking vs. OpenMP - User Services Group

  9. Simple Parallel Loop !MIC$ DOALL PRIVATE(I) SHARED(X,Y,Z) !$OMP PARALLEL DO DO I = 1, N Z(I)=LOG(SIN(X(I))**2+COS(Y(I))**4) END DO !$OMP END PARALLEL DO Cray Tasking vs. OpenMP - User Services Group

  10. Autotasking DOALL GUARD ENDGUARD PARALLEL ENDPARALLEL DOPARALLEL ENDDO CASE ENDCASE OpenMP PARALLEL DO CRITICAL END CRITICAL PARALLEL END PARALLEL DO END DO SECTIONS END SECTIONS Directive Correspondence Cray Tasking vs. OpenMP - User Services Group

  11. Parallel Loop With Critical Section !MIC$ DOALL PRIVATE(I) SHARED(X,Y,Z,T) !$OMP PARALLEL DO DO I = 1, N Z(I) = LOG(SIN(X(I))**2 + COS(Y(I))**4) !MIC$ GUARD !$OMP CRITICAL T = T + Z(I) !MIC$ ENDGUARD !$OMP ENDCRITICAL END DO !$OMP END PARALLEL DO Cray Tasking vs. OpenMP - User Services Group

  12. Autotasking DOALL GUARD ENDGUARD PARALLEL ENDPARALLEL DOPARALLEL ENDDO CASE ENDCASE OpenMP PARALLEL DO CRITICAL END CRITICAL PARALLEL END PARALLEL DO END DO SECTIONS END SECTIONS Directive Correspondence Cray Tasking vs. OpenMP - User Services Group

  13. Parallel Regions !MIC$ PARALLEL PRIVATE(X) SHARED(Y) !$OMP PARALLEL PRIVATE(X) !$OMP DO X = 3.0 !MIC$ GUARD !$OMP CRITICAL Y = Y + 1.0 !MIC$ ENDGUARD !$OMP ENDCRITICAL !MIC$ ENDPARALLEL !$OMP END DO !$OMP END PARALLEL Cray Tasking vs. OpenMP - User Services Group

  14. Autotasking DOALL GUARD ENDGUARD PARALLEL ENDPARALLEL DOPARALLEL ENDDO CASE ENDCASE OpenMP PARALLEL DO CRITICAL END CRITICAL PARALLEL END PARALLEL DO END DO SECTIONS END SECTIONS Directive Correspondence Cray Tasking vs. OpenMP - User Services Group

  15. Generalized Parallel Loop SUM = 0.0 !MIC$ PARALLEL PRIVATE(XSUM,I) SHARED(SUM,A,N) XSUM = 0.0 !MIC$ DOPARALLEL DO I = 1, N XSUM = XSUM + A(I) ENDDO !MIC$ GUARD SUM = SUM + XSUM !MIC$ ENDGUARD !MIC$ ENDDO !MIC$ ENDPARALLEL Cray Tasking vs. OpenMP - User Services Group

  16. Generalized Parallel Loop (cont.) SUM = 0.0 !$OMP PARALLEL PRIVATE(XSUM) XSUM = 0.0 !$OMP DO DO I = 1, N XSUM = XSUM + A(I) ENDDO !$OMP CRITICAL SUM = SUM + XSUM !$OMP END CRITICAL !$OMP END DO !$OMP END PARALLEL Cray Tasking vs. OpenMP - User Services Group

  17. Autotasking DOALL GUARD ENDGUARD PARALLEL ENDPARALLEL DOPARALLEL ENDDO CASE ENDCASE OpenMP PARALLEL DO CRITICAL END CRITICAL PARALLEL END PARALLEL DO END DO SECTIONS END SECTIONS Directive Correspondence Cray Tasking vs. OpenMP - User Services Group

  18. Parallel Blocks !MIC$ PARALLEL !$OMP PARALLEL !MIC$ CASE !$OMP SECTIONS !$OMP SECTION CALL SUBA !MIC$ CASE !$OMP SECTION CALL SUBB !MIC$ ENDCASE !$OMP END SECTIONS !MIC$ ENDPARALLEL !$OMP END SECTIONS Cray Tasking vs. OpenMP - User Services Group

  19. Mixing OpenMP and MPI INCLUDE ’mpi.h' CALL MPI_INIT(IERR) CALL MPI_COMM_RANK(MPI_COMM_WORLD,MYID,IERR) CALL MPI_COMM_SIZE(MPI_COMM_WORLD,NP,IERR) PRINT *,'PROCESS ',MYID,' OF ',NP,' IS ALIVE' !$OMP PARALLEL PRIVATE(NTHREADS, TID) TID = OMP_GET_THREAD_NUM() PRINT *,'HI;THREAD=',TID,' PROCESS=',MYID IF (TID .EQ. 0) THEN NTHREADS = OMP_GET_NUM_THREADS() PRINT *,'NTHREADS=',NTHREADS,’MYID=',MYID END IF !$OMP END PARALLEL CALL MPI_FINALIZE(IERR) END Cray Tasking vs. OpenMP - User Services Group

  20. Mixing OpenMP and MPI (cont.) % mpxlf_r smp.f -qsmp ** hi === End of Compilation 1 === 1501-510 Compilation successful for file smp.f. % setenv XLSMPOPTS "parthds=2" % ./a.out -nodes 2 Process 1 of 2 is alive Process 0 of 2 is alive HI;THREAD=0 PROCESS=0 NTHREADS=2 MYID=0 HI;THREAD=1 PROCESS=0 HI;THREAD=0 PROCESS=1 NTHREADS=2 MYID=1 HI;THREAD=1 PROCESS=1 Cray Tasking vs. OpenMP - User Services Group

More Related