Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine DMA loads #146

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
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
ad654ba
Add first implementation
long-long-float May 17, 2020
b83a38a
Implement checking the equal difference
long-long-float May 23, 2020
77150c6
Format
long-long-float May 25, 2020
76952cf
Add implementation for other cases
long-long-float May 25, 2020
a5fd0d3
Fix to process at each blocks
long-long-float May 25, 2020
57f4bff
Fix a little
long-long-float Jun 13, 2020
a5a1397
Use memory pitch from the difference
long-long-float Jun 20, 2020
408477a
Fix a little
long-long-float Jun 28, 2020
0a46290
Finished implementation
long-long-float Jul 5, 2020
7a31e86
Fixed a little
long-long-float Jul 12, 2020
70d1d85
Care types other than uchar
long-long-float Jul 19, 2020
fd9fed0
Fix
long-long-float Jul 26, 2020
c39687c
Create new files of ValueExpr
long-long-float Aug 15, 2020
2d18ead
Move combineDMALoads to Combiner
long-long-float Aug 15, 2020
c7358c3
Add a test of CombineDMALoads
long-long-float Aug 18, 2020
a055fbe
Move makeValueBinaryOpFromLocal to ValueExpr.*
long-long-float Aug 23, 2020
6ca4768
Fix a test to check multiple types of vloadn
long-long-float Aug 24, 2020
4bb82e9
Support vloadn other than vload16
long-long-float Aug 24, 2020
86cf23b
Remove deep nests
long-long-float Aug 24, 2020
efebd92
Add test cases and fix
long-long-float Aug 29, 2020
59cd141
Fix test codes
long-long-float Sep 13, 2020
28de130
Fix offset of vloadn
long-long-float Sep 23, 2020
3b3bfb7
Fix a test to check the generic setup
long-long-float Sep 23, 2020
e96cd41
Remove unnecessary method
long-long-float Sep 30, 2020
99961e7
Revert SPIRVHelper.h and .cpp
long-long-float Sep 30, 2020
90c50ca
Fix to use Expression instead of ValueExpr and remove it
long-long-float Sep 30, 2020
6237397
Fix calcValueExpr to take ExpandedExprs
long-long-float Oct 11, 2020
998e468
Write the documentation of combineDMALoads
long-long-float Oct 11, 2020
6e5fafa
Implement replaceLocalToExpr
long-long-float Oct 22, 2020
414e448
Treat `or` as `add`
long-long-float Nov 1, 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
2 changes: 2 additions & 0 deletions src/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using namespace vc4c;

constexpr OpCode Expression::FAKEOP_UMUL;
constexpr OpCode Expression::FAKEOP_MUL;
constexpr OpCode Expression::FAKEOP_DIV;

SubExpression::SubExpression(const Optional<Value>& val) : Base(VariantNamespace::monostate{})
{
Expand Down
3 changes: 3 additions & 0 deletions src/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ namespace vc4c
// A fake operation to indicate an unsigned multiplication
static constexpr OpCode FAKEOP_UMUL{"umul", 132, 132, 2, false, false, FlagBehavior::NONE};

static constexpr OpCode FAKEOP_MUL{"mul", 132, 132, 2, false, false, FlagBehavior::NONE};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these signed or unsigned? Can you please name them correctly and add a comment?

static constexpr OpCode FAKEOP_DIV{"div", 132, 132, 2, false, false, FlagBehavior::NONE};

OpCode code;
SubExpression arg0;
SubExpression arg1{};
Expand Down
16 changes: 16 additions & 0 deletions src/normalization/Normalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@
#include "../optimization/ControlFlow.h"
#include "../optimization/Eliminator.h"
#include "../optimization/Reordering.h"
#include "../intermediate/operators.h"
#include "../spirv/SPIRVBuiltins.h"
#include "Inliner.h"
#include "LiteralValues.h"
#include "LongOperations.h"
#include "MemoryAccess.h"
#include "Rewrite.h"

#include "../optimization/Combiner.h"

#include "log.h"

#include <string>
#include <vector>

using namespace vc4c;
using namespace vc4c::normalization;
using namespace vc4c::periphery;
using namespace vc4c::operators;

static bool checkWorkGroupUniform(const Value& arg)
{
Expand Down Expand Up @@ -253,6 +258,16 @@ void Normalizer::normalize(Module& module) const
PROFILE_COUNTER_WITH_PREV(vc4c::profiler::COUNTER_NORMALIZATION + 2, "Eliminate Phi-nodes (after)",
method->countInstructions(), vc4c::profiler::COUNTER_NORMALIZATION + 1);
}

{
// TODO: move this optimization to appropriate location
auto kernels = module.getKernels();
for(Method* kernelFunc : kernels)
{
optimizations::combineDMALoads(module, *kernelFunc, config);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this code have to be run before the normalization steps (e.g. before the memory accesses are rewritten)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It is easy to combine vloadn, but a function inlineMethods replaces vloadn. So it should be run before inlineMethods. (I don't think it's not appropriate that an optimization process is in normalization steps.)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add this to a comment

}
}

auto kernels = module.getKernels();
// 2. inline kernel-functions
for(Method* kernelFunc : kernels)
Expand All @@ -266,6 +281,7 @@ void Normalizer::normalize(Module& module) const
PROFILE_COUNTER_WITH_PREV(vc4c::profiler::COUNTER_NORMALIZATION + 5, "Inline (after)",
kernel.countInstructions(), vc4c::profiler::COUNTER_NORMALIZATION + 4);
}

// 3. run other normalization steps on kernel functions
const auto f = [&module, this](Method* kernelFunc) -> void { normalizeMethod(module, *kernelFunc); };
ThreadPool::scheduleAll<Method*>("Normalization", kernels, f, THREAD_LOGGER.get());
Expand Down
Loading