MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Achievements, by Joseph...

Preview:

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.

Citation preview

SMART SHARPEN USING OPENCL IN PHOTOSHOP CC – CHALLENGES AND ACHIEVEMENTS

JOSEPH HSIEH ADOBE SYSTEMS INC.

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

What is OpenCL

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.

Why OpenCL

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.

Smart Sharpen in Adobe Photoshop CC

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.

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.

10 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN LEGACY AND CURRENT SMART SHARPEN

11 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN LEGACY (ACCURATE) AND CURRENT VERSION

12 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN UNSHARP MASK AND SMART SHARPEN

13 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

COMPARISON BETWEEN UNSHARP MASK THRESHOLD AND SMART SHARPEN

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.

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?

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).

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.

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?

19 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

WHAT WE HAVE LEARNED

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

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

AMD CodeXL

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

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.

24 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL- OPENCL KERNEL DEBUG

25 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL- MEMORY OBJECT VIEWER

26 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

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

27 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL – PERFORMANCE COUNTER

28 | PRESENTATION TITLE | NOVEMBER 19, 2013 | CONFIDENTIAL

AMD CODEXL – KERNEL OCCUPANCY VIEWER

OpenCL 2.0

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.

Smart Sharpen Demo

Summary

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.

Q&A

Thank You

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.

Recommended