barrier synchronization

Post on 01-Jul-2015

726 Views

Category:

Education

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Barrier Synchronization

아 . 꿈 . 사 . LHS87

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

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

이지 않다 .

SOFT

Single thread machinemulti thread machine

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

컴퓨터 게임 그래픽 출력

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

0.01s 0.03s 0.025s

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

Barrier

Prepare Display

Frame

00

0

barrier

barrier

11

1

Notification time

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

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

Problem

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

프레임의 모든 부분이

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

그림의 품질이 향상

Simple Barrier

Simple Barrier

Simple Barrier

Simple Barrier

Sense-reversing Barrier

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

Art of Multiprocessor Programming 14

2-barrier

2-barrier 2-barrier

Combining Tree Barriers

Art of Multiprocessor Programming 15

2-barrier

2-barrier 2-barrier

Combining Tree Barriers

전체 thread 수

각 노드의 자식의 수

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

Depth 정하기

각 노드의 자식의 수

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

Root

Node1

Node2

T0

T1

T2

T3

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

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

Static Tree Barrier 클래스

Depth 가 0 인 node 는

Count 가 0 이기 때문에 바로

탈출 and parent count 감소

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

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

작업 하기

다른 스레드 작업 가져오기

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

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

Problem

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

종료시점 감지 불가능

Thread A

Thread B

Thread C

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

Termination-detection Barier

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

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

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

Thank you

top related