mm-4104, smart sharpen using opencl in adobe photoshop cc – challenges and achievements, by joseph...

36
SMART SHARPEN USING OPENCL IN PHOTOSHOP CC – CHALLENGES AND ACHIEVEMENTS JOSEPH HSIEH ADOBE SYSTEMS INC.

Upload: amd-developer-central

Post on 13-May-2015

1.040 views

Category:

Technology


5 download

DESCRIPTION

Presentation MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh at the AMD Developer Summit, November 11-13, 2013.

TRANSCRIPT

Page 1: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

SMART SHARPEN USING OPENCL IN PHOTOSHOP CC – CHALLENGES AND ACHIEVEMENTS

JOSEPH HSIEH ADOBE SYSTEMS INC.

Page 2: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

2 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

TOPICS

Table ‒ What is OpenCL? ‒ Why Adobe Photoshop CC chooses OpenCL? ‒ Smart Sharpen in Adobe Photoshop CC ‒ Challenges ‒ What have we learned? ‒ Demo ‒ Summary ‒ Q&A

Page 3: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

What is OpenCL

Page 4: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

4 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

WHAT IS OPENCL?

OpenCL is an open standard framework (supported by AMD, Apple, Intel, Nvidia, etc.) that allows developer to write programs that execute on different hardware platforms – GPUs, CPUs, DSPs, etc.

CUDA, GLSL, C++ AMP are competing GPGPU (General-Purpose Computing on Graphics Processing Units) technologies.

Page 5: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

Why OpenCL

Page 6: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

6 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

WHY ADOBE PHOTOSHOP CC CHOOSES OPENCL

Some advanced algorithms are just not fast enough.

GPU computing is suitable for algorithms that benefits from massive parallelization.

Cross-Platform (OpenCL and OpenGL Shading language (GLSL) are the only two cross-platform GPGPU solution).

Easier to map algorithm into OpenCL code than GLSL.

Highly efficient (capable of using fast cache memory).

Learning curves – Syntax (C99 plus vector support operations).

OpenCL is available on many latest mobile devices.

Page 7: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

Smart Sharpen in Adobe Photoshop CC

Page 8: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

8 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

SHARPENING

From Scott Kelby, “I haven’t met a digital camera (or scanned) photo that I didn’t think needed a little sharpening”.

For very blurred image, you need to do deblur, not the sharpening.

Page 9: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

9 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

RENOVATED ADOBE PHOTOSHOP CC SMART SHARPEN FEATURE

Adobe renovated the legacy smart sharpen to ‒ Addresses “noise get boosted when you sharpen” issue. ‒ Better overall quality (preserve color). ‒ Reduce the halo effect.

Page 10: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

10 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN LEGACY AND CURRENT SMART SHARPEN

Page 11: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

11 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN LEGACY (ACCURATE) AND CURRENT VERSION

Page 12: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

12 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN UNSHARP MASK AND SMART SHARPEN

Page 13: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

13 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN UNSHARP MASK THRESHOLD AND SMART SHARPEN

Page 14: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

14 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

SHARPENING TIPS

Sharpen the image on a separate layer.

Blending Mode: luminosity

Adjust opaque percentage

You may want to denoise before sharpening.

Page 15: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

15 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

PERFORMANCE CONCERN

User experience – responsiveness is important. ‒ CPU Optimization.

‒ Multi-threading ‒ Vectorization using intrinsic instructions

Still not fast enough… ‒ Is the algorithm parallelizable? ‒ Is GPGPU Optimization suitable for our sharpening algorithm?

Page 16: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

16 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

CHALLENGES IN SMART SHARPEN OPENCL DEVELOPMENT

Need to rethink about the algorithm.

Limited resources. (global memory, local memory, and private memory)

Algorithm is memory bound.

Avoid memory corruption.

Debug strategy.

How to make solid OpenCL kernels?

Optimization strategy.

Driver Issues? (better re-check the OpenCL spec and your kernel first…).

Quality control (GPU on different vendor platforms).

Page 17: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

17 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

WHAT WE HAVE LEARNED

Reference code first (making sure you know the algorithm right).

Divide and conquer (easy to verify).

Always design for easy to do unit testing.

Page 18: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

18 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

WHAT WE HAVE LEARNED

Optimization strategies (general practices): ‒ Always profile first. ‒ Algorithm parallelization. ‒ Global memory read as less as possible. (???) ‒ Memory access pattern. ‒ Avoid branching. ‒ Avoid edge condition handling. ‒ Arithmetic complexity (% is bad). ‒ Avoid bank conflict as much as possible. (???) ‒ Maximize the lazy synchronization. ‒ Trade-offs. ‒ Do not make the conclusion before doing the experiments… ‒ Optimization for certain vendor devices?

Page 19: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

19 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

WHAT WE HAVE LEARNED

Quality control across various GPUs. ‒ Design of testing scenarios. ‒ Automation ‒ Collaborate with vendors.

Page 20: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

20 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

SMART SHARPEN BENCHMARK ON 5616X3744 (21 MEGA) PIXELS IMAGE

0

5

10

15

20

25

30

35

40

45

AMD Radeon 7970 i7-3770K 3.5GHz

Radius 64Radius 4Radius 1

In seconds

Page 21: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

AMD CodeXL

Page 22: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

22 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL – TOOL FOR HETEROGENEOUS COMPUTING

Features: ‒ OpenCL debug ‒ GPU profiling ‒ Analyze OpenCL kernel ‒ Collect OpenCL application trace ‒ Integrated with Microsoft Visual Studio

Page 23: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

23 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

BENEFIT OF USING AMD CODEXL

Helps you to optimize your OpenCL kernel efficiently. ‒ Analyze the usage of VGPR, SGPR, Local Memory, etc. ‒ Profiling. ‒ Host code efficiency.

Page 24: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

24 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL- OPENCL KERNEL DEBUG

Page 25: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

25 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL- MEMORY OBJECT VIEWER

Page 26: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

26 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL – TIMELINE VISUALIZATION Visualize host code execution, data transfer, and kernel execution.

Page 27: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

27 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL – PERFORMANCE COUNTER

Page 28: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

28 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL – KERNEL OCCUPANCY VIEWER

Page 29: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

OpenCL 2.0

Page 30: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

30 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

OPENCL 2.0 NEW FEATURES

Shared virtual memory ‒ Great for APUs and integrated GPUs.

Image2D, Image3D memory object read_write modifier.

Dynamic Parallelism: kernel can enqueue other kernels. ‒ Avoid to transfer execution and data between the device and host.

Pipe ‒ FIFO memory object.

Page 31: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

Smart Sharpen Demo

Page 32: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

Summary

Page 33: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

33 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

SUMMARY

Adobe Photoshop CC adopts OpenCL to accelerate great features.

Adobe dedicates to deliver the best user experience. ‒ Embrace advanced solid technologies. ‒ Works closely with vendors to insure fully tested high quality software.

Page 34: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

Q&A

Page 35: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

Thank You

Page 36: MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph Hsieh

36 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

DISCLAIMER & ATTRIBUTION

The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions and typographical errors.

The information contained herein is subject to change and may be rendered inaccurate for many reasons, including but not limited to product and roadmap changes, component and motherboard version changes, new model and/or product releases, product differences between differing manufacturers, software changes, BIOS flashes, firmware upgrades, or the like. AMD assumes no obligation to update or otherwise correct or revise this information. However, AMD reserves the right to revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes.

AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION.

AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO ANY PERSON FOR ANY DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

ATTRIBUTION

© 2013 Advanced Micro Devices, Inc. All rights reserved. AMD, the AMD Arrow logo and combinations thereof are trademarks of Advanced Micro Devices, Inc. in the United States and/or other jurisdictions. SPEC is a registered trademark of the Standard Performance Evaluation Corporation (SPEC). Other names are for informational purposes only and may be trademarks of their respective owners.