19
Many-SC 아아아아 아아 OpenCL 아아아아아아아아아 아아아아아아 아아 아 아아아 2014. 9. 30 신신신 Computer Graphics & Image Processing Lab Seoul National University

Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Embed Size (px)

Citation preview

Page 1: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화

2014. 9. 30

신영길

Computer Graphics & Image Processing Lab

Seoul National University

Page 2: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

목표

Many-SC 아키텍처의 성능 평가를 위한 응용프로그램 구현 및 최적화

성능 평가를 위한 항목 및 benchmarking set 설계

Benchmarking set 을 이용한 성능 실험을 통해 적합한 응용 유형 정리

Page 3: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

1 차년도 목표

PC 상에서의 OpenCL 기반 응용프로그램 구현 및 최적화 Registration Volume Rendering CT Reconstruction

비교 실험 및 평가 항목 설정

Page 4: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

진행 사항

PC 상에서의 OpenCL 기반 응용프로그램 구현 및 최적화 Registration : CPU/GPU 프로그램 구현 완료

Volume Rendering : 세가지 속도 개선 기법이 포함된 CPU/GPU 프로그램 구현 완료

CT Reconstruction : Voxel-driven backprojection 기반 CPU/GPU 프로그램 구현 완료

Page 5: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Registration

한 영상 (reference image) 과 다른 영상 (floating image) 의 위치 대응 관계를 나타내는 변환을 찾는 작업

Referenceimage

Floatingimage

Apply transformparameters

Compute similarity measureUpdate

parameters

Registered image

Con-verge?

Yes

NoPer-pixel opera-tion

Parallelization!!

Page 6: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Registration

Rigid registration 의 병렬화 각 core group 에 transformation pa-

rameter(translation, rotation) 할당

할당된 parameter 로 floating image를 이동시킨 후 , reference image 와 similarity measure 수행

가장 similarity measure 가 높은 pa-rameter 를 결과로 선택

Parameter #1 Parameter #2 Parameter #n

Page 7: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Registration

Data

CPU (sec) 3891.22 3436.51

GPU (sec) 29.83 26.68

Speedup 130.46 128.82

CPU: Intel i7-2600 (4 [email protected]) / GPU: NVIDIA GTX680 2.0GB (1536 stream [email protected])

Registration 수행시간 및 speedup

Page 8: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Volume Rendering

3D volume data 2D rendered image

Ray casting 기반 volume rendering 결과 영상의 각 픽셀마다 하나의 ray 가 진행하면서 연산을 수행 각 ray 의 계산 결과는 서로 독립적 높은 parallelism

Scalability 평가에 적합 (core 수 증가에 따른 성능 향상 평가 )

Page 9: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Volume Rendering

Parallelism 에 영향을 주는 요소 Thread diversion : threads follow different control flows Global/shared memory access Loop (instruction mix) : loop-unrolling enhances performance

Volume rendering 속도 개선 기법은 thread diversion 을 일으켜 parallel-ism 에

영향을 줌 기법 1 - transparent voxel skipping 기법 2 – early ray termination 기법 3 – empty space leaping

Current GPU architecture

Global / Constant Memory Data Cache (128KB)

Compute Device

Global Memory (2GB)

Compute Device Memory

Private Memory

Work-Item 1

Private Memory

Work-Item M…

Local Memory (48KB)

Compute Unit N

Private Memory

Work-Item 1

Private Memory

Work-Item M…

Local Memory (48KB)

Compute Unit 1

기법 2기법 1 기법 3

NVIDIA GTX680 2.0GB (1536 stream [email protected])

Page 10: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Volume Rendering

Data

Engine block (512x512x512, 16bit)Rendered image: 600x600

Metal plate (512x512x206, 16bit)

Rendered image: 600x600

Abdomen (512x512x86, 16bit)Rendered image: 600x600

CPU (sec)

GPU (sec)

Speedup CPU (sec)

GPU (sec)

Speedup CPU(sec)

GPU(sec)

Speedup

Basic VR 617.31 3.07 201.08618.2

43.05 202.70 241.22 1.19 202.71

With 기법 1 151.16 0.82 184.34150.3

10.87 172.77 67.99 0.39 174.33

With 기법 2 296.54 1.78 166.60331.8

82.07 160.33 134.53 0.8 168.16

With 기법 3 136.66 0.73 187.21141.8

50.82 172.99 45.58 0.25 182.32

With 기법 1 & 2 & 3 17.88 0.22 81.15 24.42 0.18 135.67 8.78 0.08 109.75기법 1 - transparent voxel skipping / 기법 2 – early ray termination / 기법 3 – empty space leaping

CPU: Intel i7-2600 (4 [email protected]) / GPU: NVIDIA GTX680 2.0GB (1536 stream [email protected])

Volume rendering 속도 개선 기법 사용에 따른 speedup 비교 Performance elements

1. Number of cores

2. Global memory size

Core 1Core 2

Core X

Input dataGlobal / Constant Memory Data Cache (128KB)

Compute Device

Global Memory (2GB)

Compute Device Memory

Private Memory

Work-Item 1

Private Memory

Work-Item M…

Local Memory (48KB)

Compute Unit N

Private Memory

Work-Item 1

Private Memory

Work-Item M…

Local Memory (48KB)

Compute Unit 1

Page 11: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

SDD: Source-to-Detector DistanceSOD: Source-to-Object Distance

Projection image setacquired by CT scanning

Volumetric data

CT Reconstruction

using CT scan configuration(SDD, SOD, angle, etc.)

[Cone beam]

CT Reconstruction

Projection image set volumetric data CT scan configuration( 거리 , 각도 , detector 해상도 등 ) 이용

Page 12: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Filtered backprojection

Backprojection

Fil-ter

Backprojection

Filtered backprojection 을 이용한 CT reconstruction: Apply filter to 1D projection before backprojection

CT Reconstruction

Page 13: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Object

Reconstruction

Projections

Row-wise filteredprojections

Weightedprojections

Dataacquisition

Datavisualization

Cone-beamprojection

Cone-beambackprojection

Parallelization!!

Approximation

CT Reconstruction

Cone beam CT 의 filtered backprojection : FDK (Feldkamp-Davis-Kress) algorithm

Page 14: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Volume

Voxel

Projectionimage

Sampling

Voxel-driven backprojection

Volume

Projectionimage

Sampling

Write conflict

Ray-driven backprojection

CT Reconstruction

병렬화 방법Voxel-driven backprojection vs. ray-driven backprojection parallelism 과 CT reconstruction 결과 다름

Page 15: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Output volume data size 320x320x176 480x480x264

CPU (single thread) 2944.76 8805.96

OpenCL (GPU) 18.55 52.40

Speedup 158.75 168.05

CT Reconstruction

Projection image: 512x384x680

Input

volume data

Output

CPU: Intel i7-2600 (4 [email protected]) / GPU: NVIDIA GTX680 2.0GB (1536 stream [email protected])

Voxel-driven backprojection 수행시간 및 speedup

Page 16: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

Volume

Voxel

SamplingCT Reconstruction

Voxel-driven backprojection

각 voxel 의 계산 결과는 서로 독립적이므로 높은 parallelism Scalability 평가에 적합 (core 수 증가에 따른 성능 향성 평가 )

Projection image 가 들어갈 정도의 cache memory 확보되는 경우 속도 향상 I/O throughput 평가에 적합 (cache 구조 및 크기에 따른 성능 향상 평가 )

Global / Constant Memory Data Cache

Compute Device

Global Memory

Compute Device Memory

Private Memory

Work-Item 1

Private Memory

Work-Item M…

Local Memory

Compute Unit N

Private Memory

Work-Item 1

Private Memory

Work-Item M…

Local Memory

Compute Unit 1

Volume data

Projection images

Page 17: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

CT Reconstruction

Ray-driven backprojection voxel-driven 방법에 비해 기하학적 정보를 이용하여 정확한 계산 가능 인접한 ray 들이 하나의 voxel 에 대해 동시에 업데이트 시도

◆ Write conflict

병렬화하기 어려움

구현 이슈 Write conflict 를 피하기 위해 OpenCL 의 atomic_add(float) 사용 필요 OpenCL 2.0 에서 지원 , 그러나 현재 지원하는 H/W 없음 atomic_add(int) 를 이용한 fixed-point 연산으로 대체 가능하지만 정확도 감소

Volume

Sampling

Write conflict

Page 18: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

H/W 지원이 필요한 Common Operation

현재의 응용 프로그램 기반 GPU 에 있는 operation 중 지원이 필요한 common operation

GPU 에 없는 operation 중 지원이 되면 좋은 common operation

Priority OperationApplica-

tions

1

Trilinear interpolation(Bilinear interpolation 으로 대체 가능 )

2Vector operations(e.g. vector normalization, length of vector, dot product)

3Matrix operation(e.g. 좌표 변환 )

4Mathematical functions(e.g. sin, cos, log, pow, saturate)

Priority OperationApplica-

tions

1

GradientCentral difference: 연산은 간단하나 ,

3D 데이터의 경우 6 번의 sampling

필요

향후 개발하는 응용프로그램에 따라 항목 추가

Volume Rendering

Registration

CT Reconstruction

Page 19: Many-SC 아키텍처 기반 OpenCL 프레임워크상에서의 응용프로그램 구현 및 최적화 2014. 9. 30 신영길 Computer Graphics & Image Processing Lab Seoul National

향후 일정

PC 상에서 OpenCL 기반 응용프로그램 구현 및 코드 최적화 CT Reconstruction : Ray-driven backprojection 기반 CPU/GPU 프로그램 구현

지속적 비교 실험 및 평가 항목 설정