Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 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
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,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;
}
19 changes: 19 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
file(GLOB SAMPLE_DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/[0-9]*)
foreach(SAMPLE_DIR IN LISTS SAMPLE_DIRS)
# install samples
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_DIR} DESTINATION samples COMPONENT samples)

# deploy build tool for samples
file(GLOB SAMPLES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_DIR}/*)
foreach(SAMPLE IN LISTS SAMPLES)
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_DIR}/${SAMPLE})
if(UNIX)
install(FILES ${CMAKE_BINARY_DIR}/samples/buildtools/unix/Makefile DESTINATION samples/${SAMPLE_DIR}/${SAMPLE} COMPONENT samples)
elseif(WIN32)
file(GLOB NMAKE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/buildtools/nmake/*)
file(GLOB VS2015_FILES ${CMAKE_CURRENT_SOURCE_DIR}/buildtools/vs2015/*)
install(FILES ${NMAKE_FILES} ${VS2015_FILES} DESTINATION samples/${SAMPLE_DIR}/${SAMPLE} COMPONENT samples)
endif()
endif()
endforeach()
endforeach()
7 changes: 7 additions & 0 deletions apps/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Application folder for new samples

How to enable stream-based code generation for apps:
1 follow the standard getting started guide at (https://hipacc-lang.org/install.html)
2 the apps should be copied automatically to the same directory as samples
3 enable the Hipacc flag `-use-stream n` in cuda.conf
4 `-use-stream 1` for single-stream and `-use-stream 2` for multi-stream
Loading