SlideShare a Scribd company logo
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 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
AfterShot Pro
Basics
INSIDE AFTERSHOT

Architectural
Features:
‒ Task Scheduling
‒ Tile Processing

4 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
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
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
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
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
OpenCL™ in
AfterShot Pro
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
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
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
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
OpenCL
Challenges
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
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
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
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
OpenCL 2.0
SVM
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
AfterShot
Redux
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
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
SETTING UP A KERNEL TO USE SVM MEMORY

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

25 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
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
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 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

More Related Content

PDF
HC-4018, How to make the most of GPU accessible memory, by Paul Blinzer
AMD Developer Central
 
PDF
CC-4001, Aparapi and HSA: Easing the developer path to APU/GPU accelerated Ja...
AMD Developer Central
 
PDF
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
AMD Developer Central
 
PDF
Computer Vision Powered by Heterogeneous System Architecture (HSA) by Dr. Ha...
AMD Developer Central
 
PDF
PT-4053, Advanced OpenCL - Debugging and Profiling Using AMD CodeXL, by Uri S...
AMD Developer Central
 
PDF
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
AMD Developer Central
 
PDF
HC-4019, "Exploiting Coarse-grained Parallelism in B+ Tree Searches on an APU...
AMD Developer Central
 
PPTX
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
AMD Developer Central
 
HC-4018, How to make the most of GPU accessible memory, by Paul Blinzer
AMD Developer Central
 
CC-4001, Aparapi and HSA: Easing the developer path to APU/GPU accelerated Ja...
AMD Developer Central
 
PL-4047, Big Data Workload Analysis Using SWAT and Ipython Notebooks, by Moni...
AMD Developer Central
 
Computer Vision Powered by Heterogeneous System Architecture (HSA) by Dr. Ha...
AMD Developer Central
 
PT-4053, Advanced OpenCL - Debugging and Profiling Using AMD CodeXL, by Uri S...
AMD Developer Central
 
MM-4092, Optimizing FFMPEG and Handbrake Using OpenCL and Other AMD HW Capabi...
AMD Developer Central
 
HC-4019, "Exploiting Coarse-grained Parallelism in B+ Tree Searches on an APU...
AMD Developer Central
 
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
AMD Developer Central
 

What's hot (20)

PDF
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
AMD Developer Central
 
PPSX
Direct3D12 and the Future of Graphics APIs by Dave Oldcorn
AMD Developer Central
 
PDF
GS-4152, AMD’s Radeon R9-290X, One Big dGPU, by Michael Mantor
AMD Developer Central
 
PDF
HSA-4122, "HSA Queuing Mode," by Ian Bratt
AMD Developer Central
 
PDF
Keynote (Phil Rogers) - The Programmers Guide to Reaching for the Cloud - by ...
AMD Developer Central
 
PDF
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
AMD Developer Central
 
PDF
CC-4006, Deliver Hardware Accelerated Applications Using RemoteFX vGPU with W...
AMD Developer Central
 
PDF
An Introduction to OpenCL™ Programming with AMD GPUs - AMD & Acceleware Webinar
AMD Developer Central
 
PPSX
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
AMD Developer Central
 
PDF
ISCA 2014 | Heterogeneous System Architecture (HSA): Architecture and Algorit...
HSA Foundation
 
PDF
WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang...
AMD Developer Central
 
PDF
MM-4105, Realtime 4K HDR Decoding with GPU ACES, by Gary Demos
AMD Developer Central
 
PDF
Heterogeneous Systems Architecture: The Next Area of Computing Innovation
AMD
 
PDF
GS-4147, TressFX 2.0, by Bill-Bilodeau
AMD Developer Central
 
PDF
LCU13: GPGPU on ARM Experience Report
Linaro
 
PDF
PT-4142, Porting and Optimizing OpenMP applications to APU using CAPS tools, ...
AMD Developer Central
 
PPSX
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
AMD Developer Central
 
PDF
MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Ac...
AMD Developer Central
 
PDF
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
AMD Developer Central
 
PDF
CC-4000, Characterizing APU Performance in HadoopCL on Heterogeneous Distribu...
AMD Developer Central
 
PL-4044, OpenACC on AMD APUs and GPUs with the PGI Accelerator Compilers, by ...
AMD Developer Central
 
Direct3D12 and the Future of Graphics APIs by Dave Oldcorn
AMD Developer Central
 
GS-4152, AMD’s Radeon R9-290X, One Big dGPU, by Michael Mantor
AMD Developer Central
 
HSA-4122, "HSA Queuing Mode," by Ian Bratt
AMD Developer Central
 
Keynote (Phil Rogers) - The Programmers Guide to Reaching for the Cloud - by ...
AMD Developer Central
 
Keynote (Johan Andersson) - Mantle for Developers - by Johan Andersson, Techn...
AMD Developer Central
 
CC-4006, Deliver Hardware Accelerated Applications Using RemoteFX vGPU with W...
AMD Developer Central
 
An Introduction to OpenCL™ Programming with AMD GPUs - AMD & Acceleware Webinar
AMD Developer Central
 
The Small Batch (and other) solutions in Mantle API, by Guennadi Riguer, Mant...
AMD Developer Central
 
ISCA 2014 | Heterogeneous System Architecture (HSA): Architecture and Algorit...
HSA Foundation
 
WT-4071, GPU accelerated 3D graphics for Java, by Kevin Rushforth, Chien Yang...
AMD Developer Central
 
MM-4105, Realtime 4K HDR Decoding with GPU ACES, by Gary Demos
AMD Developer Central
 
Heterogeneous Systems Architecture: The Next Area of Computing Innovation
AMD
 
GS-4147, TressFX 2.0, by Bill-Bilodeau
AMD Developer Central
 
LCU13: GPGPU on ARM Experience Report
Linaro
 
PT-4142, Porting and Optimizing OpenMP applications to APU using CAPS tools, ...
AMD Developer Central
 
Rendering Battlefield 4 with Mantle by Yuriy ODonnell
AMD Developer Central
 
MM-4104, Smart Sharpen using OpenCL in Adobe Photoshop CC – Challenges and Ac...
AMD Developer Central
 
HC-4021, Efficient scheduling of OpenMP and OpenCL™ workloads on Accelerated ...
AMD Developer Central
 
CC-4000, Characterizing APU Performance in HadoopCL on Heterogeneous Distribu...
AMD Developer Central
 
Ad

More from AMD Developer Central (20)

PDF
DX12 & Vulkan: Dawn of a New Generation of Graphics APIs
AMD Developer Central
 
PPTX
Leverage the Speed of OpenCL™ with AMD Math Libraries
AMD Developer Central
 
PPTX
Introduction to Node.js
AMD Developer Central
 
PPTX
Media SDK Webinar 2014
AMD Developer Central
 
PDF
DirectGMA on AMD’S FirePro™ GPUS
AMD Developer Central
 
PPT
Webinar: Whats New in Java 8 with Develop Intelligence
AMD Developer Central
 
PPSX
Inside XBox- One, by Martin Fuller
AMD Developer Central
 
PPSX
TressFX The Fast and The Furry by Nicolas Thibieroz
AMD Developer Central
 
PPTX
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
AMD Developer Central
 
PPSX
Gcn performance ftw by stephan hodes
AMD Developer Central
 
PPSX
Inside XBOX ONE by Martin Fuller
AMD Developer Central
 
PPSX
Introduction to Direct 3D 12 by Ivan Nevraev
AMD Developer Central
 
PPSX
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
AMD Developer Central
 
PDF
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
AMD Developer Central
 
PPSX
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
AMD Developer Central
 
PDF
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
AMD Developer Central
 
PPSX
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
AMD Developer Central
 
PPSX
Mantle - Introducing a new API for Graphics - AMD at GDC14
AMD Developer Central
 
PPSX
Direct3D and the Future of Graphics APIs - AMD at GDC14
AMD Developer Central
 
PPSX
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
AMD Developer Central
 
DX12 & Vulkan: Dawn of a New Generation of Graphics APIs
AMD Developer Central
 
Leverage the Speed of OpenCL™ with AMD Math Libraries
AMD Developer Central
 
Introduction to Node.js
AMD Developer Central
 
Media SDK Webinar 2014
AMD Developer Central
 
DirectGMA on AMD’S FirePro™ GPUS
AMD Developer Central
 
Webinar: Whats New in Java 8 with Develop Intelligence
AMD Developer Central
 
Inside XBox- One, by Martin Fuller
AMD Developer Central
 
TressFX The Fast and The Furry by Nicolas Thibieroz
AMD Developer Central
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
AMD Developer Central
 
Gcn performance ftw by stephan hodes
AMD Developer Central
 
Inside XBOX ONE by Martin Fuller
AMD Developer Central
 
Introduction to Direct 3D 12 by Ivan Nevraev
AMD Developer Central
 
Holy smoke! Faster Particle Rendering using Direct Compute by Gareth Thomas
AMD Developer Central
 
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
AMD Developer Central
 
Rendering Battlefield 4 with Mantle by Johan Andersson - AMD at GDC14
AMD Developer Central
 
RapidFire - the Easy Route to low Latency Cloud Gaming Solutions - AMD at GDC14
AMD Developer Central
 
Mantle and Nitrous - Combining Efficient Engine Design with a modern API - AM...
AMD Developer Central
 
Mantle - Introducing a new API for Graphics - AMD at GDC14
AMD Developer Central
 
Direct3D and the Future of Graphics APIs - AMD at GDC14
AMD Developer Central
 
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
AMD Developer Central
 
Ad

Recently uploaded (20)

PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 

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

  • 1. ENHANCING OPENCL PERFORMANCE IN COREL AFTERSHOT™ PRO WITH HSA
  • 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
  • 4. INSIDE AFTERSHOT Architectural Features: ‒ Task Scheduling ‒ Tile Processing 4 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  • 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. 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. 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. 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
  • 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. 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. 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. 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
  • 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. 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. 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. 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
  • 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
  • 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. 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. SETTING UP A KERNEL TO USE SVM MEMORY 24 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  • 25. LOADING SVM MEMORY FROM INSIDE THE KERNEL 25 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  • 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. THANK YOU Questions 27 | Enhancing OpenCL Performance in Corel AfterShot™ Pro with HSA | NOVEMBER 19, 2013
  • 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