27
arrier Synchronizati 아.아.아. LHS87

Barrier synchronization

  • View
    726

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Barrier synchronization

Barrier Synchronization

아 . 꿈 . 사 . LHS87

Page 2: Barrier synchronization

초당 35 프레임 이상은 보여줘야 한다 .

한 프레임 보여주는 데 실패해도 치명적

이지 않다 .

SOFT

Single thread machinemulti thread machine

한 프레임을 n 개의 겹치지 않는 부분으로 쪼갠다

컴퓨터 게임 그래픽 출력

Page 3: Barrier synchronization

ProblemThread 별로 할당된 프레임을 준비하고 보여주는 데 필요한 시간이 서로 다르다 .

0.01s 0.03s 0.025s

Solution각 thread 작업하고 , n 개의 Thread 모두가 해당 단계를 마칠 때까지 블록하자 .

Page 4: Barrier synchronization

Barrier

Prepare Display

Frame

Page 5: Barrier synchronization

00

0

barrier

Page 6: Barrier synchronization

barrier

11

1

Page 7: Barrier synchronization

Notification time

모든 Thread 가 배리어에 도착했음을 한 Thread 가 알아챈 시점부터 해당 Thread 가

배리어를 빠져나갈 때까지의 시간 간격

Problem

Notification time 이 고르게 분포할수록 좋다

프레임의 모든 부분이

거의 비슷한 시간에 갱신될 때

그림의 품질이 향상

Page 8: Barrier synchronization

Simple Barrier

Page 9: Barrier synchronization

Simple Barrier

Page 10: Barrier synchronization

Simple Barrier

Page 11: Barrier synchronization

Simple Barrier

Page 12: Barrier synchronization

Sense-reversing Barrier

Page 13: Barrier synchronization

Tree Barrier메모리 접근을 여러 개 의 배리어로 나눔으로써 메모리 경쟁을 감소시키자

Page 14: Barrier synchronization

Art of Multiprocessor Programming 14

2-barrier

2-barrier 2-barrier

Combining Tree Barriers

Page 15: Barrier synchronization

Art of Multiprocessor Programming 15

2-barrier

2-barrier 2-barrier

Combining Tree Barriers

Page 16: Barrier synchronization

전체 thread 수

각 노드의 자식의 수

전체 thread 수 / 각 노드의 자식 수

Depth 정하기

Page 17: Barrier synchronization

각 노드의 자식의 수

Page 18: Barrier synchronization

내가 이 노드 count 마지막감소 시키는 경우면 parentawait 호출

Root

Node1

Node2

T0

T1

T2

T3

Ex) Thread 수 : 4, 각 노드 자식 수 : 2

Page 19: Barrier synchronization

Static Tree Barrier

thread 수만큼 node 를 생성한다

Ex) Thread 수 : 4, 각 노드 자식 수 : 2

Root

Node1

Node2

Node3

Node4

Node5

Node6

Count 0

Count 2

Depth 0

Depth 1

Depth 2

Page 20: Barrier synchronization

Static Tree Barrier 클래스

Depth 가 0 인 node 는

Count 가 0 이기 때문에 바로

탈출 and parent count 감소

Page 21: Barrier synchronization

Work Stealing ThreadThread 가 자신의 로컬 큐의 작업을 소진한 다음에는 , 다른 Thread 의

큐로부터 작업을 훔쳐오는 시도를 하자 .

Page 22: Barrier synchronization

작업 하기

다른 스레드 작업 가져오기

Thread활성화 상태 : 작업 있는 경우비활성화 상태 : 작업 없는 경우

종료 감지는 활성 thread 가 더 이상존재하지 않을 때 !!

Page 23: Barrier synchronization

Problem

각 thread 가 자신이 종료되었음을 알리고 , 단순히 그런 thread 수를 셈으로써

종료시점 감지 불가능

Thread A

Thread B

Thread C

A 가 B 를 확인하고 그 다음 C 를 확인 하기 전에 , B 가 C 로부터 작업을 훔쳤을 수 있다 .

Page 24: Barrier synchronization

Termination-detection Barier

setActive 로 배리어에 활성화 유무를 알린다 .

isTerminated 모든 스레드가 비활성화된 경우 true

Page 25: Barrier synchronization
Page 26: Barrier synchronization

훔치기 성공할 확률아예 없을 때 활성화로선언하는 것을 막는다 .

Page 27: Barrier synchronization

Thank you