1 / 6

Parallel Smoothing Algorithm Implementation Using OpenMP

This document provides an implementation of a parallel smoothing algorithm using OpenMP, designed for efficient computation on shared memory systems. The algorithm computes the average of neighboring values in a grid, iterating through specified indices while employing barrier synchronization to ensure thread safety. It leverages features such as dynamic scheduling and thread synchronization. This is particularly beneficial for computational tasks involving large matrices and can be adapted for various applications in scientific computing.

Télécharger la présentation

Parallel Smoothing Algorithm Implementation Using OpenMP

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. DO J=2,N-1 DO I=2,N-1 А(I,J) = A(I-1,J) + A(I,J-1) + A(I+1,J) + A(I,J+1) / 4 ENDDO ENDDO

  2. Нить 0 Нить 1 Нить N

  3. Нить 0 Нить 1 Нить 2

  4. !$OMP PARALLEL DEFAULT(SHARED) PRIVATE(I,J,IAM,NUMT,ILIMIT) !$ IAM = OMP_GET_THREAD_NUM () !$ NUMT = OMP_GET_NUM_THREADS () !$ ISYNC (IAM) = 0 !$ ILIMIT=MIN(NUMT-1, N-1-2) !$OMP BARRIER DO J=2,N-1 !$ IF (IAM .GT. 0 .AND. IAM .LE. ILIMIT) THEN !$ DO WHILE (ISYNC(IAM-1) .EQ. 0) !$OMP FLUSH(ISYNC) !$ ENDDO !$ ISYNC(IAM-1)=0 !$OMP FLUSH(ISYNC) !$ ENDIF !$OMP DO DO I=2,N-1 А(I,J) = (A(I-1,J) + A(I,J-1) + A(I+1,J) + A(I,J+1)) / 4 ENDDO !$OMP ENDDO NOWAIT !$ IF (IAM .LT. ILIMIT) THEN !$ DO WHILE (ISYNC(IAM) .EQ. 1) !$OMP FLUSH(ISYNC) !$ ENDDO !$ ISYNC(IAM)=1 !$OMP FLUSH(ISYNC) !$ ENDIF ENDDO !$OMP END PARALLEL

  5. !$OMP PARALLEL PRIVATE(J,I,IAM,NEWJ) !$ IAM = OMP_GET_THREAD_NUM() DO NEWJ = 2, N-1 + OMP_GET_NUM_THREADS () - 1 J = NEWJ-IAM !$OMP DO SCHEDULE (STATIC) DO I = 2, N-1 !$ IF (J .LT. 2 .OR. J .GT. N-1) THEN !$ CYCLE !$ ENDIF A( I, J ) = (A( I-1, J ) + A( I+1, J ) + A( I, J-1 ) +A( I, J+1 ))/4 ENDDO ENDDO !$OMP END PARALLEL

  6. Материалы по курсу: ftp://ftp.keldysh.ru/K_student/OpenMp

More Related