提交 1dfb657a 编写于 作者: T tbbdev

Adding examples for Euro-Par 2017 and info about examples into README.md

上级 96a49bc4
......@@ -7,6 +7,10 @@ full advantage of multicore performance, that are portable, composable and have
## Release Information
Here are the latest [Changes](CHANGES) and [Release Notes](doc/Release_Notes.txt) (contains system requirements and known issues).
This release provides additional TBB examples for workshops, conferences etc.
examples/ppopp17 – examples for PPoPP 2017
examples/europar17 – examples for Euro-Par 2017
## Documentation
* Intel(R) TBB [tutorial](https://software.intel.com/en-us/tbb-tutorial)
......
Copyright (c) 2012-2014 MIT CSAIL, Google Inc., and other contributors
Developed by:
The Halide team
http://halide-lang.org
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
此差异已折叠。
此差异已折叠。
/*
Copyright (c) 2017 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <iostream>
#include <fstream>
#include <string>
#include "lodepng.h"
namespace utils {
struct image_buffer {
unsigned int width, height;
std::shared_ptr< std::vector<unsigned char> > buffer; // smart pointer to the vector of raw pixels in RGBA format, 4 bytes per pixel
};
image_buffer readPNGImage(const std::string& imageName) {
image_buffer image;
image.buffer = std::make_shared< std::vector<unsigned char> >();
unsigned int error = lodepng::decode(*image.buffer, image.width, image.height, imageName.c_str());
if (error) {
std::string exceptionMessage = "decoder error: " + std::string(lodepng_error_text(error));
throw std::runtime_error(exceptionMessage);
}
return image;
}
void readPNGImage(unsigned char* imageBuffer, unsigned int& width, unsigned int& height, const char* imageName) {
unsigned int error = lodepng_decode32_file(&imageBuffer, &width, &height, imageName);
if (error) {
std::string exceptionMessage = "decoder error: " + std::string(lodepng_error_text(error));
throw std::runtime_error(exceptionMessage);
}
}
void writePNGImage(const image_buffer& image, const std::string& outputFile) {
unsigned int error = lodepng::encode(outputFile, *image.buffer, image.width, image.height);
if (error) {
std::string exceptionMessage = "encoder error: " + std::string(lodepng_error_text(error));
throw std::runtime_error(exceptionMessage);
}
}
void writePNGImage(unsigned char* imageBuffer, unsigned int& width, unsigned int& height, const std::string& outputFile) {
unsigned int error = lodepng::encode(outputFile, imageBuffer, width, height);
if (error) {
std::string exceptionMessage = "encoder error: " + std::string(lodepng_error_text(error));
throw std::runtime_error(exceptionMessage);
}
}
image_buffer generatePNGImage() {
image_buffer image;
image.width = 1024;
image.height = 1024;
image.buffer = std::make_shared< std::vector<unsigned char> >(image.width * image.height * 4);
std::vector<unsigned char>& buffer = *image.buffer;
const int widthOffset = 4 * image.width;
for (unsigned y = 0; y < image.height; y++) {
for (unsigned x = 0; x < image.width; x++) {
const int pixelOffset = widthOffset * y + 4 * x;
buffer[pixelOffset] = 200 * !(x & y);
buffer[pixelOffset + 1] = x ^ y;
buffer[pixelOffset + 2] = x | y;
buffer[pixelOffset + 3] = 255;
}
}
return image;
}
bool isFileExist(const std::string& fileName) {
std::ifstream file(fileName);
return file.good();
}
bool isBothImagesExists(const std::string& firstFile, const std::string& secondFile) {
return isFileExist(firstFile) && isFileExist(secondFile);
}
image_buffer getOrGenerateImage(const std::string& fileName) {
return fileName.empty() ? generatePNGImage() : readPNGImage(fileName);
}
}
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#
#
# GNU Makefile that builds and runs example.
run_cmd=
PROG=stereo
ARGS=
PERF_RUN_ARGS=
# icpc by default
ifneq (,$(shell which icc 2>/dev/null))
CXX=icpc
endif
# autodetect C++11 support
include ../../common/examples-common.inc
# TBB libs
TBBLIB=-ltbb
TBBLIB_DEBUG=-ltbb_debug
# OpenCL lib
OPENCL_LIB=-lOpenCL
ifeq ($(shell uname), Linux)
ifeq ($(target), android)
LIBS+= --sysroot=$(SYSROOT)
run_cmd=../../common/android.linux.launcher.sh
else
LIBS+= -lrt
endif
else
ifeq ($(shell uname),Darwin)
override CXXFLAGS += -Wl,-rpath,$(TBBROOT)/lib
override OPENCL_LIB=-framework OpenCL
endif
endif
all: release test
release: *.cpp
$(CXX) -O2 -DNDEBUG $(CXXFLAGS) -o $(PROG) $^ ../common/lodepng.cpp -I../common $(TBBLIB) $(OPENCL_LIB) $(LIBS) $(CXX0XFLAGS)
debug: *.cpp
$(CXX) -O0 -g -DTBB_USE_DEBUG $(CXXFLAGS) -o $(PROG) $^ $(TBBLIB_DEBUG) $(OPENCL_LIB) $(LIBS) $(CXX0XFLAGS)
clean:
$(RM) $(PROG) *.o *.d
test:
$(run_cmd) ./$(PROG) $(ARGS)
perf_build: release
perf_run:
$(run_cmd) ./$(PROG) $(PERF_RUN_ARGS)

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "exercise0", "exercise0.vcxproj", "{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Debug|Win32.ActiveCfg = Debug|Win32
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Debug|Win32.Build.0 = Debug|Win32
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Debug|x64.ActiveCfg = Debug|x64
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Debug|x64.Build.0 = Debug|x64
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Release|Win32.ActiveCfg = Release|Win32
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Release|Win32.Build.0 = Release|Win32
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Release|x64.ActiveCfg = Release|x64
{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\common\lodepng.cpp" />
<ClCompile Include="..\stereo-serial.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\common\lodepng.h" />
<ClInclude Include="..\..\common\utils.h" />
</ItemGroup>
<ItemGroup>
<Image Include="..\..\common\input\input1.png" />
<Image Include="..\..\common\input\input2.png" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9C777D75-70FF-4C24-AB74-EBCDF3328AB9}</ProjectGuid>
<RootNamespace>exercise0</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)$(Platform)\$(ProjectName)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\..\include;$(INTELOCLSDKROOT)include;$(TBBROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib\x86;$(TBBROOT)\lib\ia32\vc_mt;$(TBBROOT)\lib\ia32\vc12;$(SolutionDir)\..\..\..\..\lib\ia32\vc_mt;$(SolutionDir)\..\..\..\..\lib\ia32\vc12;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>tbb.lib;tbb_preview.lib;OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\..\include;$(INTELOCLSDKROOT)include;$(TBBROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib\x64;$(TBBROOT)\lib\intel64\vc_mt;$(TBBROOT)\lib\intel64\vc12;$(SolutionDir)\..\..\..\..\lib\intel64\vc_mt;$(SolutionDir)\..\..\..\..\lib\intel64\vc12;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>tbb.lib;tbb_preview.lib;OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\..\include;$(INTELOCLSDKROOT)include;$(TBBROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib\x86;$(TBBROOT)\lib\ia32\vc_mt;$(TBBROOT)\lib\ia32\vc12;$(SolutionDir)\..\..\..\..\lib\ia32\vc_mt;$(SolutionDir)\..\..\..\..\lib\ia32\vc12;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>tbb.lib;tbb_preview.lib;OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\..\include;$(INTELOCLSDKROOT)include;$(TBBROOT)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_MBCS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(INTELOCLSDKROOT)lib\x64;$(TBBROOT)\lib\intel64\vc_mt;$(TBBROOT)\lib\intel64\vc12;$(SolutionDir)\..\..\..\..\lib\intel64\vc_mt;$(SolutionDir)\..\..\..\..\lib\intel64\vc12;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>tbb.lib;tbb_preview.lib;OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
/*
Copyright (c) 2017 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* Build instructions:
"icpc stereo-serial.cpp ../common/lodepng.cpp -o stereo -ltbb_preview -std=c++11 -I../"
Simple image processing example to start with
First task: execute example and note execution time.
*/
#include "../../common/utility/utility.h"
#include "tbb/tbb.h"
#include "../common/utils.h"
using namespace std;
typedef utils::image_buffer buffer_t;
static const int redChannelOffset = 0;
static const int greenChannelOffset = 1;
static const int blueChannelOffset = 2;
static const int channelsPerPixel = 4;
static const int channelIncreaseValue = 10;
void applyImageEffect(buffer_t& image, const int channelOffset) {
const int heighBase = channelsPerPixel * image.width;
std::vector<unsigned char>& buffer = *image.buffer;
// Increase selected color channel by a predefined value
for (unsigned int y = 0; y < image.height; y++) {
const int heightOffset = heighBase * y;
for (unsigned int x = 0; x < image.width; x++) {
int pixelOffset = heightOffset + channelsPerPixel * x + channelOffset;
buffer[pixelOffset] = static_cast<uint8_t>(min(buffer[pixelOffset] + channelIncreaseValue, 255));
}
}
}
// This function merges to image buffers into the first buffer (leftImageBuffer as a destination)
void mergeImageBuffers(buffer_t& leftImage, const buffer_t& rightImage) {
const int heighBase = channelsPerPixel * leftImage.width;
std::vector<unsigned char>& leftImageBuffer = *leftImage.buffer;
std::vector<unsigned char>& rightImageBuffer = *rightImage.buffer;
// Apply stereoscopic merge using algorithm: R: left image, G:, B: right image
for (unsigned int y = 0; y < leftImage.height; y++) {
const int heightOffset = heighBase * y;
for (unsigned int x = 0; x < leftImage.width; x++) {
const int pixelOffset = heightOffset + channelsPerPixel * x;
const int redChannelIndex = pixelOffset + redChannelOffset;
rightImageBuffer[redChannelIndex] = leftImageBuffer[redChannelIndex];
}
}
}
int main() {
std::cout << "Beginning" << std::endl;
#if _MSC_VER
std::string inputFileFirst = "../../common/input/input1.png";
std::string inputFileSecond = "../../common/input/input2.png";
#else
std::string inputFileFirst = "../common/input/input1.png";
std::string inputFileSecond = "../common/input/input2.png";
#endif
std::string outputFile = "output.png";
tbb::tick_count mainStartTime = tbb::tick_count::now();
buffer_t leftImageBuffer = utils::getOrGenerateImage(inputFileFirst);
buffer_t rightImageBuffer = utils::getOrGenerateImage(inputFileSecond);
applyImageEffect(leftImageBuffer,redChannelOffset);
applyImageEffect(rightImageBuffer,blueChannelOffset);
mergeImageBuffers(leftImageBuffer, rightImageBuffer);
utils::writePNGImage(rightImageBuffer, outputFile);
utility::report_elapsed_time((tbb::tick_count::now() - mainStartTime).seconds());
#if _MSC_VER
getchar();
#endif
return 0;
}
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
#
#
# GNU Makefile that builds and runs example.
run_cmd=
PROG=stereo
ARGS=
PERF_RUN_ARGS=
# icpc by default
ifneq (,$(shell which icc 2>/dev/null))
CXX=icpc
endif
# autodetect C++11 support
include ../../common/examples-common.inc
# TBB libs
TBBLIB=-ltbb
TBBLIB_DEBUG=-ltbb_debug
# OpenCL lib
OPENCL_LIB=-lOpenCL
ifeq ($(shell uname), Linux)
ifeq ($(target), android)
LIBS+= --sysroot=$(SYSROOT)
run_cmd=../../common/android.linux.launcher.sh
else
LIBS+= -lrt
endif
else
ifeq ($(shell uname),Darwin)
override CXXFLAGS += -Wl,-rpath,$(TBBROOT)/lib
override OPENCL_LIB=-framework OpenCL
endif
endif
all: release test
release: *.cpp
$(CXX) -O2 -DNDEBUG $(CXXFLAGS) -o $(PROG) $^ ../common/lodepng.cpp -I../common $(TBBLIB) $(OPENCL_LIB) $(LIBS) $(CXX0XFLAGS)
debug: *.cpp
$(CXX) -O0 -g -DTBB_USE_DEBUG $(CXXFLAGS) -o $(PROG) $^ $(TBBLIB_DEBUG) $(OPENCL_LIB) $(LIBS) $(CXX0XFLAGS)
clean:
$(RM) $(PROG) *.o *.d
test:
$(run_cmd) ./$(PROG) $(ARGS)
perf_build: release
perf_run:
$(run_cmd) ./$(PROG) $(PERF_RUN_ARGS)
/*
Copyright (c) 2017 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* Build instructions:
icpc exercise01.cpp ../common/lodepng.cpp -o stereo -ltbb_preview -std=c++11 -I../
Begin: Duplicate preamble from previous exercise */
#include "../../common/utility/utility.h"