Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d19726f
Add async kernel launch functions
Jan 23, 2020
03f4b67
Add async kernel launch flag in Hipacc
Jan 23, 2020
ccab45f
Add FAU into the license
Feb 11, 2020
da09baf
Add async memory transfer function in runtime
Feb 11, 2020
f8ee12e
Enable stream in HipaccImage and memory transfer functions
Feb 11, 2020
2d194ab
Add cuda stream init and destroy
Feb 11, 2020
db0fb4c
Update readme
Feb 12, 2020
a55bf2c
Update readme
Feb 12, 2020
47e0fac
Update README
Feb 12, 2020
ad4f544
Assign event wait and record to HipaccKernel
Feb 12, 2020
4079ca9
Extract pyramid depth (const required)
Feb 12, 2020
e8a151e
Add depth to HipaccPyramid class
Feb 12, 2020
66fb0db
Add hipaccLaunchKernel function with events
Feb 12, 2020
cbc3836
Remove conflict function decl in runtime
Feb 12, 2020
4aa5cd4
Add multi-stream event and stream generation
Feb 13, 2020
8d7261f
Add multi-stream kernel launch for pyramid application
Feb 13, 2020
f9d5489
Assign pyramid basic operations using functions
Feb 13, 2020
45f5263
Add condition for pyramid info
Feb 17, 2020
6ada644
Add device info in pyramid schedule
Feb 17, 2020
5fcad5f
Enable single stream wave estimation
Feb 17, 2020
a781675
Add print info for single stream
Feb 18, 2020
d484656
Enable stream config in the flag
Feb 18, 2020
a166db8
Fix stream init
Feb 18, 2020
be13843
Enable multi stream wave estimation
Feb 21, 2020
b43f010
Adjust depth image size for single stream analysis
Mar 3, 2020
f6d0ce6
Add information for fine-gained level execution
Mar 4, 2020
c06f4a1
Add an example
Mar 4, 2020
55f2ba0
Add instruction to use stream-based generation
Mar 4, 2020
b0f6d65
Update multistream information printout
Mar 4, 2020
b29f19e
Add clang format config
Mar 4, 2020
98174fe
Add FFT functions in runtime
julian-brandl Apr 5, 2020
1a904d9
Add FFTW support
julian-brandl Apr 5, 2020
1a487e1
Add use_fft compiler switch
julian-brandl Apr 5, 2020
52135dd
Add include fft library files
julian-brandl Apr 5, 2020
1b95b0a
Add convolve_fft function
julian-brandl Apr 5, 2020
0bd186e
Remove hard coded path for FFTW
julian-brandl Apr 16, 2020
4c68206
Remove gaussian_filter function
julian-brandl Apr 17, 2020
38b5f89
Add check for unsupported languages
julian-brandl Apr 17, 2020
3614f21
Add fft_lib function call for kernels
julian-brandl Apr 17, 2020
c32e397
Add buffer conversion to handle HipaccImage as in/output
julian-brandl Apr 17, 2020
ea8a650
Add sample for fft_lib
julian-brandl Apr 17, 2020
4aaa41e
Add adapted Makefile for fft samples
julian-brandl Apr 17, 2020
5d4f7e7
Add templates for fft helper functions
julian-brandl May 15, 2020
2b782ba
Change convolve FFT function to Kernel member function
julian-brandl May 15, 2020
16b7886
Add separate writeConvolutionCall
julian-brandl May 15, 2020
921fbf0
Replace old convolve fft function with new Kernel member functions
julian-brandl May 15, 2020
6e97c26
Add use of single precision in cuFFT and FFTW libraries
julian-brandl May 15, 2020
ff4571c
Update FFT sample
julian-brandl May 15, 2020
5e2eb98
Add FAST option for -use-fft compiler switch
julian-brandl May 18, 2020
fe2ba98
Add boundary constant parameter to fft convolution call
julian-brandl May 18, 2020
5b8b4c8
Add linear covolution functionality
julian-brandl May 18, 2020
cb69ac7
Update FFT sample
julian-brandl May 18, 2020
d2c0550
Remove obsolete convolveFFT_f kernel method
julian-brandl Jun 6, 2020
18ec113
Rename writeFFTConvolutionCall function
julian-brandl Jun 6, 2020
964aa50
Fix makefile 'dirname: missing operand' warning
julian-brandl Jun 6, 2020
5bffa40
Add functionality for explicit FFT and operations in fft-domain
julian-brandl Jun 6, 2020
b24b650
Add estimation model for convolution execution time
julian-brandl Jun 6, 2020
f2da9fc
Add new FFT user functions to dsl
julian-brandl Jun 6, 2020
37825b0
Add new test images for FFT samples
julian-brandl Jun 6, 2020
006e937
Update sample
julian-brandl Jun 6, 2020
facd414
Add new FFT halftone sample
julian-brandl Jun 6, 2020
9ae5b9d
Add error handling for FFT convolution
julian-brandl Jun 7, 2020
6b3198a
Add estimation factor for boundary conditions
julian-brandl Jun 7, 2020
bd0f0c8
Add fft_transform_device function and minor fixes
julian-brandl Jul 2, 2020
0b9fb0d
Add DCT functions
julian-brandl Jul 2, 2020
2487d85
Add sample for DFT and DCT usage
julian-brandl Jul 2, 2020
fa2b690
Fix minor bugs
julian-brandl Jul 3, 2020
70f94e9
Fix ifft scaling
julian-brandl Jul 8, 2020
06710cd
Move lib_fft dsl functions to separate fft.hpp
julian-brandl Jul 8, 2020
8f68506
Add better frequency filter functionality
julian-brandl Aug 5, 2020
97e38ef
Rename functions
julian-brandl Aug 5, 2020
286a03e
Add DCT functions on device; Rename functions
julian-brandl Aug 5, 2020
fe9aedc
Add additional function wrappers
julian-brandl Aug 5, 2020
6f3a28a
Add lib for complex math with cuda
julian-brandl Aug 5, 2020
5d600e4
Change convolution to device for cuda
julian-brandl Aug 5, 2020
38f84a6
Update fft function header
julian-brandl Aug 5, 2020
d68bdca
Update samples
julian-brandl Aug 5, 2020
65beb24
Add Image Manipulation Detection sample
julian-brandl Aug 5, 2020
401fe89
Remove unused helper file
julian-brandl Aug 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ find_program(clang NAMES clang PATHS ${LLVM_TOOLS_BINARY_DIR})
find_package(CUDA)
find_package(NVML)
find_package(OpenCL)
find_package(FFTW)

if(CUDA_FOUND AND CUDA_VERSION VERSION_LESS "7.0")
message(WARNING "At least CUDA version 7.0 required, but found CUDA version ${CUDA_VERSION}.")
Expand Down Expand Up @@ -86,6 +87,7 @@ message(STATUS "CUDA support: ${CUDA_FOUND}")
message(STATUS "OpenCL support: ${OpenCL_FOUND}")
message(STATUS "Polly support: ${USE_POLLY}")
message(STATUS "JIT estimates: ${USE_JIT_ESTIMATE}")
message(STATUS "FFTW support: ${FFTW_FOUND}")
message(STATUS "===")


Expand Down Expand Up @@ -184,3 +186,8 @@ endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/samples/CMakeLists.txt)
add_subdirectory(samples)
endif()

# add apps if available
if(EXISTS ${CMAKE_SOURCE_DIR}/apps/CMakeLists.txt)
add_subdirectory(apps)
endif()
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Copyright (c) 2020, University of Erlangen-Nuremberg
Copyright (c) 2014, Saarland University
Copyright (c) 2012, University of Erlangen-Nuremberg
Copyright (c) 2012, Siemens AG
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
This is a fork of the [Hipacc](http://hipacc-lang.org) project, with primarily experiential features:
* Asynchronous runtime APIs
* Multi-stream implementation for multiresolution filters in CUDA


# Hipacc
A domain-specific language and compiler for image processing

Expand Down
121 changes: 121 additions & 0 deletions _clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 82
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
...

212 changes: 212 additions & 0 deletions apps/6_Multiresolution_Filters/Laplacian_Pyramid_Encoding/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
//
// Copyright (c) 2020, University of Erlangen-Nuremberg
// Copyright (c) 2012, University of Erlangen-Nuremberg
// Copyright (c) 2012, Siemens AG
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

#include "hipacc.hpp"
#include <iostream>
#include <hipacc_helper.hpp>

#define SIZE_X 3
#define SIZE_Y 3
#define WIDTH 1024
#define HEIGHT 1024

using namespace hipacc;
using namespace hipacc::math;


class Gaussian : public Kernel<char> {
private:
Accessor<char> &input;
Mask<float> &mask;

public:
Gaussian(IterationSpace<char> &iter, Accessor<char> &input,
Mask<float> &mask)
: Kernel(iter), input(input), mask(mask) {
add_accessor(&input);
}

void kernel() {
output() = convolve(mask, Reduce::SUM, [&] () {
return input(mask) * mask();
});
}

void _operatePyramidReduce() {}
};

class DifferenceOfGaussian : public Kernel<char> {
private:
Accessor<char> &input1;
Accessor<char> &input2;

public:
DifferenceOfGaussian(IterationSpace<char> &iter, Accessor<char> &input1,
Accessor<char> &input2)
: Kernel(iter), input1(input1), input2(input2) {
add_accessor(&input1);
add_accessor(&input2);
}

void kernel() {
output() = input1() - input2();
}

void _operatePyramidFilter() {}
};

class Blend : public Kernel<char> {
private:
Accessor<char> &input1;
Accessor<char> &input2;

public:
Blend(IterationSpace<char> &iter, Accessor<char> &input1,
Accessor<char> &input2)
: Kernel(iter), input1(input1), input2(input2) {
add_accessor(&input1);
add_accessor(&input2);
}

void kernel() {
output() = (short)input1() + (short)input2() / 2;
}

void _operatePyramidExpand() {}
};


/*************************************************************************
* Main function *
*************************************************************************/
int main(int argc, const char **argv) {
const int width = WIDTH;
const int height = HEIGHT;
const int size_x = SIZE_X;
const int size_y = SIZE_Y;
float timing = 0;

// only filter kernel sizes 3x3, 5x5, and 7x7 implemented
if (size_x != size_y || !(size_x == 3 || size_x == 5 || size_x == 7)) {
std::cout << "Wrong filter kernel size. "
<< "Currently supported values: 3x3, 5x5, and 7x7!"
<< std::endl;
exit(EXIT_FAILURE);
}

// convolution filter mask
const float coef[SIZE_Y][SIZE_X] = {
#if SIZE_X == 3
{ 0.057118f, 0.124758f, 0.057118f },
{ 0.124758f, 0.272496f, 0.124758f },
{ 0.057118f, 0.124758f, 0.057118f }
#endif
#if SIZE_X == 5
{ 0.005008f, 0.017300f, 0.026151f, 0.017300f, 0.005008f },
{ 0.017300f, 0.059761f, 0.090339f, 0.059761f, 0.017300f },
{ 0.026151f, 0.090339f, 0.136565f, 0.090339f, 0.026151f },
{ 0.017300f, 0.059761f, 0.090339f, 0.059761f, 0.017300f },
{ 0.005008f, 0.017300f, 0.026151f, 0.017300f, 0.005008f }
#endif
#if SIZE_X == 7
{ 0.000841f, 0.003010f, 0.006471f, 0.008351f, 0.006471f, 0.003010f, 0.000841f },
{ 0.003010f, 0.010778f, 0.023169f, 0.029902f, 0.023169f, 0.010778f, 0.003010f },
{ 0.006471f, 0.023169f, 0.049806f, 0.064280f, 0.049806f, 0.023169f, 0.006471f },
{ 0.008351f, 0.029902f, 0.064280f, 0.082959f, 0.064280f, 0.029902f, 0.008351f },
{ 0.006471f, 0.023169f, 0.049806f, 0.064280f, 0.049806f, 0.023169f, 0.006471f },
{ 0.003010f, 0.010778f, 0.023169f, 0.029902f, 0.023169f, 0.010778f, 0.003010f },
{ 0.000841f, 0.003010f, 0.006471f, 0.008351f, 0.006471f, 0.003010f, 0.000841f }
#endif
};

// host memory for random generated image of width x height pixels
char *input = new char[width * height];
for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) {
input[y * width + x] = (char)((y * width + x) % 19);
}
}

std::cout << "Calculating Hipacc Gaussian Laplacian pyramid ..." << std::endl;

//************************************************************************//

// input and output image of width x height pixels
Image<char> gaus(width, height);
Image<char> lap(width, height);
Mask<float> mask(coef);

const int depth = 10;
Pyramid<char> pgaus(gaus, depth);
Pyramid<char> plap(lap, depth);

gaus = input;
traverse(pgaus, plap, [&] () {
if (!pgaus.is_top_level()) {
// construct Gaussian pyramid
BoundaryCondition<char> bound(pgaus(-1), mask, Boundary::CLAMP);
Accessor<char> acc1(bound);
IterationSpace<char> iter1(pgaus(0));
Gaussian blur(iter1, acc1, mask);
blur.execute();

// construct Laplacian pyramid
Accessor<char> acc3(pgaus(-1));
Accessor<char> acc4(pgaus(0), Interpolate::LF);
IterationSpace<char> iter3(plap(-1));
DifferenceOfGaussian DoG(iter3, acc3, acc4);
DoG.execute();
}

traverse();

// collapse pyramids
if (!pgaus.is_bottom_level()) {
// blend final output image from Laplacian pyramid
Accessor<char> acc3(plap(1), Interpolate::LF);
Accessor<char> acc4(plap(0));
IterationSpace<char> iter2(plap(0));
Blend blend(iter2, acc3, acc4);
blend.execute();
}
});

// get pointer to result data
char *output = lap.data();

//************************************************************************//

// convert to uchar for visualization
for (int p = 0; p < width*height; ++p) {
output[p] = (char)(output[p] + 127);
}

// free memory
delete[] input;

return EXIT_SUCCESS;
}
Loading