Skip to content

Commit 6350ca0

Browse files
authored
Merging sepia-filter (#6)
* Updated sample.json Signed-off-by: sravanik <[email protected]> * Update sample.json
1 parent 11a8f86 commit 6350ca0

18 files changed

+24463
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if(WIN32)
2+
set(CMAKE_CXX_COMPILER "dpcpp-cl")
3+
else()
4+
set(CMAKE_CXX_COMPILER "dpcpp")
5+
endif()
6+
# Set default build type to RelWithDebInfo if not specified
7+
if (NOT CMAKE_BUILD_TYPE)
8+
message (STATUS "Default CMAKE_BUILD_TYPE not set using Release with Debug Info")
9+
set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE
10+
STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel"
11+
FORCE)
12+
endif()
13+
cmake_minimum_required (VERSION 3.0)
14+
project (SepiaFilter)
15+
add_subdirectory (src)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2019 Intel Corporation
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# sepia-filter sample
2+
Sepia filter is a program that converts a color image to a Sepia tone image which is a monochromatic image with a distinctive Brown Gray color. The program works by offloading the compute intensive conversion of each pixel to Sepia tone and is implemented using DPC++ for CPU and GPU.
3+
4+
For comprehensive instructions regarding DPC++ Programming, go to https://software.intel.com/en-us/oneapi-programming-guide and search based on relevant terms noted in the comments.
5+
6+
| Optimized for | Description
7+
|:--- |:---
8+
| OS | Linux Ubuntu 18.04, Windows 10
9+
| Hardware | Skylake with GEN9 or newer
10+
| Software | Intel&reg; oneAPI DPC++ Compiler (beta)
11+
| What you will learn | The Sepia Filter sample demonstrates the following using the oneAPI DPC++ compiler <ul><li>Writing a custom device selector class</li><li>Offloading compute intensive parts of the application using both lamba and functor kernels</li><li>Measuring kernel execution time by enabling profiling</li></ul>
12+
| Time to complete | 20 minutes
13+
14+
## Purpose
15+
Sepia filter is a DPC++ application that accepts a color image as an input and converts it to a sepia tone image by applying the sepia filter coefficients to every pixel of the image. The sample demonstrates offloading the compute intensive part of the application which is the processing of individual pixels to an accelerator with the help of lambda and functor kernels. The sample also demonstrates the usage of a custom device selector which sets precedence for a GPU device over other available devices on the system.
16+
The device selected for offloading the kernel is displayed in the output along with the time taken to execute each of the kernels. The application also outputs a sepia tone image of the input image.
17+
18+
## Key implementation details
19+
The basic DPC++ implementation explained in the code includes device selector, buffer, accessor, kernel, and command groups. In addition, this sample demonstrates implementation of a custom device selector by over writing the SYCL device selector class, offloading computation using both lambda and functor kernels and using event objects to time command group execution by enabling profiling.
20+
21+
## License
22+
This code sample is licensed under MIT license
23+
24+
## Building the Program
25+
26+
### Include Files
27+
The include folder is located at `%ONEAPI_ROOT%\dev-utilities\latest\include` on your development system.
28+
29+
### Running Samples in DevCloud
30+
If running a sample in the Intel DevCloud, remember that you must specify the compute node (CPU, GPU, FPGA) as well whether to run in batch or interactive mode. For more information see the Intel&reg; oneAPI Base Toolkit Get Started Guide (https://devcloud.intel.com/oneapi/get-started/base-toolkit/)
31+
32+
### On a Linux* System
33+
34+
Perform the following steps:
35+
36+
37+
1. Build sepia-filter program
38+
```
39+
$ cd sepia-filter
40+
$ mkdir build
41+
$ cd build
42+
$ cmake ../.
43+
$ make
44+
```
45+
46+
2. Run the program <br>
47+
```
48+
$ make run
49+
50+
```
51+
52+
### On a Windows* System Using Visual Studio* version 2017 or Newer
53+
54+
* Build the program using VS2017 or VS2019: Right click on the solution file and open using either VS2017 or VS2019 IDE. Right click on the project in Solution explorer and select Rebuild. From top menu select Debug -> Start without Debugging.
55+
* Build the program using MSBuild: Open "x64 Native Tools Command Prompt for VS2017" or "x64 Native Tools Command Prompt for VS2019". Run - MSBuild mandelbrot.sln /t:Rebuild /p:Configuration="Release"
56+
57+
58+
## Running the sample
59+
60+
### Application Parameters
61+
The Sepia-filter application expects a png image as an input parameter. The application comes with some sample images in the input folder. One of these is specified as the default input image to be converted in the cmake file and the default output image is generated in the same folder as the application.
62+
63+
### Example Output
64+
```
65+
Loaded image with a width of 3264, a height of 2448 and 3 channels
66+
Running on Intel(R) Gen9
67+
Submitting lambda kernel...
68+
Submitting functor kernel...
69+
Waiting for execution to complete...
70+
Execution completed
71+
Lambda kernel time: 10.5153 milliseconds
72+
Functor kernel time: 9.99602 milliseconds
73+
Sepia tone successfully applied to image:[input/silverfalls1.png]
74+
```
Binary file not shown.
Loading
Loading
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"guid": "B9C425DB-A3AD-4FCB-9CA0-1909E5189FB7",
3+
"name": "Sepia Filter",
4+
"categories": ["Toolkit/Intel® oneAPI Base Toolkit/oneAPI DPC++ Compiler/CPU and GPU"],
5+
"toolchain": ["dpcpp"],
6+
"description": "A program that converts an image to sepia tone",
7+
"languages": [{
8+
"cpp": {}
9+
}],
10+
"targetDevice": ["CPU", "GPU"],
11+
"os": ["linux", "windows"],
12+
"builder": ["ide", "cmake"],
13+
"ciTests": {
14+
"linux": [{
15+
"steps": [
16+
"mkdir build",
17+
"cd build",
18+
"cmake ..",
19+
"make",
20+
"make run"
21+
]
22+
}],
23+
"windows": [{
24+
"steps": [
25+
"MSBuild sepia-filter.sln /t:Rebuild /p:Configuration=\"debug\"",
26+
"cd x64\\Debug",
27+
"sepia-filter.exe ..\\..\\input\\silverfalls1.png"
28+
]
29+
}]
30+
}
31+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.136
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sepia-filter", "sepia-filter.vcxproj", "{D2DBAAFA-24E1-4EC9-AE71-1EF6A3BD67FC}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Release|x64 = Release|x64
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D2DBAAFA-24E1-4EC9-AE71-1EF6A3BD67FC}.Debug|x64.ActiveCfg = Debug|x64
15+
{D2DBAAFA-24E1-4EC9-AE71-1EF6A3BD67FC}.Debug|x64.Build.0 = Debug|x64
16+
{D2DBAAFA-24E1-4EC9-AE71-1EF6A3BD67FC}.Release|x64.ActiveCfg = Release|x64
17+
{D2DBAAFA-24E1-4EC9-AE71-1EF6A3BD67FC}.Release|x64.Build.0 = Release|x64
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {2D959279-173F-4330-95B5-03C95BAB8260}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|x64">
5+
<Configuration>Debug</Configuration>
6+
<Platform>x64</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|x64">
9+
<Configuration>Release</Configuration>
10+
<Platform>x64</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
<PropertyGroup Label="Globals">
14+
<VCProjectVersion>15.0</VCProjectVersion>
15+
<ProjectGuid>{d2dbaafa-24e1-4ec9-ae71-1ef6a3bd67fc}</ProjectGuid>
16+
<Keyword>Win32Proj</Keyword>
17+
<RootNamespace>sepia_filter</RootNamespace>
18+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
19+
</PropertyGroup>
20+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
22+
<ConfigurationType>Application</ConfigurationType>
23+
<UseDebugLibraries>true</UseDebugLibraries>
24+
<PlatformToolset>oneAPI Data Parallel C++ Compiler</PlatformToolset>
25+
<CharacterSet>Unicode</CharacterSet>
26+
</PropertyGroup>
27+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
28+
<ConfigurationType>Application</ConfigurationType>
29+
<UseDebugLibraries>false</UseDebugLibraries>
30+
<PlatformToolset>oneAPI Data Parallel C++ Compiler</PlatformToolset>
31+
<WholeProgramOptimization>true</WholeProgramOptimization>
32+
<CharacterSet>Unicode</CharacterSet>
33+
</PropertyGroup>
34+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
35+
<ConfigurationType>Application</ConfigurationType>
36+
<UseDebugLibraries>true</UseDebugLibraries>
37+
<PlatformToolset>Intel(R) oneAPI DPC++ Compiler</PlatformToolset>
38+
<CharacterSet>Unicode</CharacterSet>
39+
</PropertyGroup>
40+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
41+
<ConfigurationType>Application</ConfigurationType>
42+
<UseDebugLibraries>false</UseDebugLibraries>
43+
<PlatformToolset>Intel(R) oneAPI DPC++ Compiler</PlatformToolset>
44+
<WholeProgramOptimization>true</WholeProgramOptimization>
45+
<CharacterSet>Unicode</CharacterSet>
46+
</PropertyGroup>
47+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
48+
<ImportGroup Label="ExtensionSettings">
49+
</ImportGroup>
50+
<ImportGroup Label="Shared">
51+
</ImportGroup>
52+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
53+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
54+
</ImportGroup>
55+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
56+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+
</ImportGroup>
58+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
59+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<PropertyGroup Label="UserMacros" />
65+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
66+
<LinkIncremental>true</LinkIncremental>
67+
</PropertyGroup>
68+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
69+
<LinkIncremental>true</LinkIncremental>
70+
</PropertyGroup>
71+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
72+
<LinkIncremental>false</LinkIncremental>
73+
</PropertyGroup>
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
75+
<LinkIncremental>false</LinkIncremental>
76+
</PropertyGroup>
77+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+
<ClCompile>
79+
<PrecompiledHeader>Use</PrecompiledHeader>
80+
<WarningLevel>Level3</WarningLevel>
81+
<Optimization>Disabled</Optimization>
82+
<SDLCheck>true</SDLCheck>
83+
<ConformanceMode>true</ConformanceMode>
84+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
85+
</ClCompile>
86+
<Link>
87+
<SubSystem>Console</SubSystem>
88+
<GenerateDebugInformation>true</GenerateDebugInformation>
89+
</Link>
90+
</ItemDefinitionGroup>
91+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
92+
<ClCompile>
93+
<PrecompiledHeader>Use</PrecompiledHeader>
94+
<WarningLevel>Level3</WarningLevel>
95+
<Optimization>Disabled</Optimization>
96+
<SDLCheck>true</SDLCheck>
97+
<ConformanceMode>true</ConformanceMode>
98+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
99+
<SYCLWarningLevel>DisableAllWarnings</SYCLWarningLevel>
100+
</ClCompile>
101+
<Link>
102+
<SubSystem>Console</SubSystem>
103+
<GenerateDebugInformation>true</GenerateDebugInformation>
104+
</Link>
105+
</ItemDefinitionGroup>
106+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
107+
<ClCompile>
108+
<PrecompiledHeader>Use</PrecompiledHeader>
109+
<WarningLevel>Level3</WarningLevel>
110+
<Optimization>MaxSpeed</Optimization>
111+
<FunctionLevelLinking>true</FunctionLevelLinking>
112+
<IntrinsicFunctions>true</IntrinsicFunctions>
113+
<SDLCheck>true</SDLCheck>
114+
<ConformanceMode>true</ConformanceMode>
115+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
116+
</ClCompile>
117+
<Link>
118+
<SubSystem>Console</SubSystem>
119+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
120+
<OptimizeReferences>true</OptimizeReferences>
121+
<GenerateDebugInformation>true</GenerateDebugInformation>
122+
</Link>
123+
</ItemDefinitionGroup>
124+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
125+
<ClCompile>
126+
<PrecompiledHeader>Use</PrecompiledHeader>
127+
<WarningLevel>Level3</WarningLevel>
128+
<Optimization>MaxSpeed</Optimization>
129+
<FunctionLevelLinking>true</FunctionLevelLinking>
130+
<IntrinsicFunctions>true</IntrinsicFunctions>
131+
<SDLCheck>true</SDLCheck>
132+
<ConformanceMode>true</ConformanceMode>
133+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
134+
<SYCLWarningLevel>DisableAllWarnings</SYCLWarningLevel>
135+
</ClCompile>
136+
<Link>
137+
<SubSystem>Console</SubSystem>
138+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
139+
<OptimizeReferences>true</OptimizeReferences>
140+
<GenerateDebugInformation>true</GenerateDebugInformation>
141+
</Link>
142+
</ItemDefinitionGroup>
143+
<ItemGroup>
144+
<ClCompile Include="src\sepia_dpcpp.cpp" />
145+
</ItemGroup>
146+
<ItemGroup>
147+
<ClInclude Include="src\device_selector.hpp" />
148+
</ItemGroup>
149+
<ItemGroup>
150+
<Text Include="License.txt" />
151+
</ItemGroup>
152+
<ItemGroup>
153+
<None Include="readme.md" />
154+
</ItemGroup>
155+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
156+
<ImportGroup Label="ExtensionTargets">
157+
</ImportGroup>
158+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Source Files">
5+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
6+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
7+
</Filter>
8+
<Filter Include="Header Files">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Resource Files">
13+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
14+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup>
18+
<ClCompile Include="src\sepia_dpcpp.cpp">
19+
<Filter>Source Files</Filter>
20+
</ClCompile>
21+
</ItemGroup>
22+
<ItemGroup>
23+
<ClInclude Include="src\device_selector.hpp">
24+
<Filter>Header Files</Filter>
25+
</ClInclude>
26+
</ItemGroup>
27+
<ItemGroup>
28+
<Text Include="License.txt" />
29+
</ItemGroup>
30+
<ItemGroup>
31+
<None Include="readme.md" />
32+
</ItemGroup>
33+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
4+
<LocalDebuggerCommandArguments>input/silverfalls1.png</LocalDebuggerCommandArguments>
5+
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
6+
</PropertyGroup>
7+
</Project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
2+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
3+
add_executable (sepia sepia_dpcpp.cpp)
4+
target_link_libraries(sepia OpenCL sycl)
5+
file(COPY ../input/silverfalls1.png DESTINATION .)
6+
if(WIN32)
7+
add_custom_target (run sepia.exe silverfalls1.png)
8+
else()
9+
add_custom_target (run ./sepia silverfalls1.png)
10+
endif()
11+
12+

0 commit comments

Comments
 (0)