ENHANCING OPENCL PERFORMANCE IN
COREL AFTERSHOT™ PRO WITH HSA
COREL AFTERSHOT™ PRO
 What is Corel AfterShot™ Pro?

 Corel AfterShot™ Pro is photo workflow software
 Non-destructive ...
AfterShot Pro
Basics
INSIDE AFTERSHOT

Architectural
Features:
‒ Task Scheduling
‒ Tile Processing

4 | Enhancing OpenCL Performance in Corel ...
AFTERSHOT TASK MANAGEMENT
 Work is broken down into Tasks. Tasks
typically:
‒ Contain execution logic (code)
‒ May store ...
PROCESSING WITH TILES
 The standard simpler approach is to use large monolithic images
 Images are broken down into tile...
PROCESSING WITH TILES CONTINUED
 The Image Processing Pipeline is made
up of several discrete steps [or filters]
 To pro...
ADVANCED TILE PROCESSING
 Some Image Filters require a radius of pixels
as input
 Partially processed neighbor Tiles mus...
OpenCL™ in
AfterShot Pro
ACCELERATING AFTERSHOT WITH OPENCL™
Goals for the AfterShot Pro OpenCL port
 Offload image processing from Tiles
 Work w...
GETTING WORK TO OPENCL
 Identify the longest running image Filter functions and replace them with OpenCL
kernels
 Do not...
CAVEATS OF ASYNCHRONOUS OPENCL PROCESSING
 High Buffer Usage
‒ Each kernel that runs needs input, output, and possibly sc...
CAVEATS OF ASYNCHRONOUS OPENCL PROCESSING – CONTINUED
 Dependencies Must Be Resolved in Advance
‒ For best performance al...
OpenCL
Challenges
LARGE RADIUS IMAGE FILTERS
 Several image processing operations require neighbor pixels. In AfterShot image Filters
are b...
LARGE RADIUS IMAGE FILTERS ARE DIFFICULT
Large Radius AfterShot Filters are particularly difficult to implement in OpenCL
...
LARGE RADIUS FILTERS - NO

Don’t do it.
 Large Radius filters are possible but at great development cost
 Performance wo...
AFTERSHOT OPENCL RESULTS
 Approximately 70% of image processing work was moved off of the CPU cores*
 Batch processing s...
OpenCL 2.0
SVM
OPENCL 2.0 SHARED VIRTUAL MEMORY

OpenCL 2.0 introduces Shared Virtual Memory (SVM)
 Basic [Coarse Grain] SVM
‒ Host and ...
AfterShot
Redux
RECONSIDERING LARGE RADIUS FILTERS
 Large Radius OpenCL filters were dropped as an AfterShot feature. The reasons were
bo...
LOCAL CONTRAST – A LARGE RADIUS AFTERSHOT FILTER
 The next version of AfterShot Pro will contain a new Local Contrast fil...
SETTING UP A KERNEL TO USE SVM MEMORY

24 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2...
LOADING SVM MEMORY FROM INSIDE THE KERNEL

25 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 1...
LOCAL CONTRAST RESULTS
 System SVM simplified Local Contrast
‒ No complicated buffer management
‒ No clever optimizations...
THANK YOU
Questions

27 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
DISCLAIMER & ATTRIBUTION
The information presented in this document is for informational purposes only and may contain tec...
Upcoming SlideShare
Loading in...5
×

HC-4020, Enhancing OpenCL performance in AfterShot Pro with HSA, by Michael Wootton

1,672

Published on

Presentation Hc-4020, Enhancing OpenCL performance in AfterShot Pro with HSA, by Michael Wootton at the AMD Developer Summit (APU13) November 11-13, 2013.

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,672
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
40
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

HC-4020, Enhancing OpenCL performance in AfterShot Pro with HSA, by Michael Wootton

  1. 1. ENHANCING OPENCL PERFORMANCE IN COREL AFTERSHOT™ PRO WITH HSA
  2. 2. COREL AFTERSHOT™ PRO  What is Corel AfterShot™ Pro?  Corel AfterShot™ Pro is photo workflow software  Non-destructive photo editing of JPEG, TIFF, and Raw formats from hundreds of cameras  Photo Management  Batch Processing of modified files 2 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  3. 3. AfterShot Pro Basics
  4. 4. INSIDE AFTERSHOT Architectural Features: ‒ Task Scheduling ‒ Tile Processing 4 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  5. 5. AFTERSHOT TASK MANAGEMENT  Work is broken down into Tasks. Tasks typically: ‒ Contain execution logic (code) ‒ May store resultant data ‒ Track whether they are complete Disk Photo Thumbnail File Reader  The Task Scheduler: ‒ Allocates a worker thread per CPU core ‒ Runs Tasks based on priority ‒ Allows Tasks to block on each other JPEG Decoder Task Dependency Data A Simple Task Dependency Graph 5 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  6. 6. PROCESSING WITH TILES  The standard simpler approach is to use large monolithic images  Images are broken down into tiles for processing  Tiling provides faster screen updates. Only compute the visible parts of the image  Tiling allows more effective memory management 6 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  7. 7. PROCESSING WITH TILES CONTINUED  The Image Processing Pipeline is made up of several discrete steps [or filters]  To process a single tile: ‒ Load the input data (e.g. raw or jpeg data) ‒ Apply each Filter step in turn  Generally, we only need the output of the last step, the top Tile in the Stack Raw Data 7 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013 Final Image
  8. 8. ADVANCED TILE PROCESSING  Some Image Filters require a radius of pixels as input  Partially processed neighbor Tiles must complete before the main Tile can continue  Intermediate Tiles must be stored in memory so they do not rerun  Example Filters: ‒ Sharpening ‒ Lens Correction ‒ Noise Reduction ‒ Cropping 8 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013 Requires multiple source tiles
  9. 9. OpenCL™ in AfterShot Pro
  10. 10. ACCELERATING AFTERSHOT WITH OPENCL™ Goals for the AfterShot Pro OpenCL port  Offload image processing from Tiles  Work within the existing System ‒ Contain changes to a few critical modules ‒ Maintain full CPU utilization ‒ Integrate OpenCL Events into the Task System 10 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  11. 11. GETTING WORK TO OPENCL  Identify the longest running image Filter functions and replace them with OpenCL kernels  Do not block CPU threads, use OpenCL event callbacks.  Processing becomes Asynchronous  Limit total work in flight to conserve memory  Marshall data automatically 11 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  12. 12. CAVEATS OF ASYNCHRONOUS OPENCL PROCESSING  High Buffer Usage ‒ Each kernel that runs needs input, output, and possibly scratch buffers. ‒ Buffers must “stick around” until the kernels complete ‒ Multiple chains of kernels a needed to keep the GPU busy Buffer Buffer Buffer Buffer Buffer Buffer Buffer Kernel 1 Kernel 2 Kernel 3 Kernel 4 Kernel 5 Processing one 512 x 512 image requires multiple 3 MB buffers resident in device memory (VRAM) 12 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  13. 13. CAVEATS OF ASYNCHRONOUS OPENCL PROCESSING – CONTINUED  Dependencies Must Be Resolved in Advance ‒ For best performance all kernels in a chain should be enqueued together ‒ The state of all dependencies must be known before the first kernel is queued ‒ Difficult to track ‒ Compromise: only use OpenCL for Filters with simple linear dependencies Kernel chaining and asynchronous execution provides excellent GPU utilization. 13 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  14. 14. OpenCL Challenges
  15. 15. LARGE RADIUS IMAGE FILTERS  Several image processing operations require neighbor pixels. In AfterShot image Filters are broken down into one of two categories: Normal Large Radius Only requires the local Tile Requires multiple Tiles 15 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  16. 16. LARGE RADIUS IMAGE FILTERS ARE DIFFICULT Large Radius AfterShot Filters are particularly difficult to implement in OpenCL  Large Radius filters will “break” kernel chaining  A extra layer of Intermediate Tiles must be resident, which will: ‒ Exhaust Device Memory, or ‒ Cause excessive bus transfers, hurting performance And the solution is… 16 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  17. 17. LARGE RADIUS FILTERS - NO Don’t do it.  Large Radius filters are possible but at great development cost  Performance would ultimately depend on tricky optimizations  Large radius filters were left to run on the CPU 17 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  18. 18. AFTERSHOT OPENCL RESULTS  Approximately 70% of image processing work was moved off of the CPU cores*  Batch processing speed improved by 3.5x*  Maintains 100% utilization on 8 CPU cores*  Only a mid-level GPU is required  Supported on Windows, Linux, and OS X AfterShot Pro with OpenCL was a success *measured on developer’s system 18 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  19. 19. OpenCL 2.0 SVM
  20. 20. OPENCL 2.0 SHARED VIRTUAL MEMORY OpenCL 2.0 introduces Shared Virtual Memory (SVM)  Basic [Coarse Grain] SVM ‒ Host and kernels can share pointers  Advanced [Fine Grain] SVM is available on some hardware ‒ Host and kernels can operate concurrently on the same memory  Fine Grain System SVM ‒ Kernels can access the entire host process’ address space. Kernels can read or write malloc buffers ‒ System SVM can greatly simplify buffer management in an OpenCL application 20 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  21. 21. AfterShot Redux
  22. 22. RECONSIDERING LARGE RADIUS FILTERS  Large Radius OpenCL filters were dropped as an AfterShot feature. The reasons were both technical and resource related  Can System SVM make Large Radius AfterShot filters feasible? Signs point to yes ‒ No Device Memory required for Intermediate buffers ‒ Input streams from SVM, no buffer transfers ‒ Behavior more in-line with Software [non-OpenCL] filters ‒ Dependencies could be resolved just as they would for a Software filter 22 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  23. 23. LOCAL CONTRAST – A LARGE RADIUS AFTERSHOT FILTER  The next version of AfterShot Pro will contain a new Local Contrast filter. ‒ GPU accelerated on systems with OpenCL and SVM. ‒ Increases image contrast in detailed areas while leaving large constant areas unchanged ‒ The effect is achieved through a large radius Unsharp Mask (10-20% of the overall image width) 23 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  24. 24. SETTING UP A KERNEL TO USE SVM MEMORY 24 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  25. 25. LOADING SVM MEMORY FROM INSIDE THE KERNEL 25 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  26. 26. LOCAL CONTRAST RESULTS  System SVM simplified Local Contrast ‒ No complicated buffer management ‒ No clever optimizations were required to hide Device memory transfers ‒ Additional memory pressure is similar to a software filter  Performance is good. The OpenCL code runs in ¼ the time of the optimized software filter* *measured on developer’s system 26 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  27. 27. THANK YOU Questions 27 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  28. 28. 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). OpenCL and the OpenCL logo are trademarks of Apple Inc. used by permission by Khronos. Other names are for informational purposes only and may be trademarks of their respective owners. 28 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×