Comments (10)
Hi, can I tackle this one?
from heavydb.
Yes, good one for you.
from heavydb.
@psockali You can use ScalarExprVisitor
to build a constant-collecting visitor. There's a pitfall though: we don't know all constants upfront when sub-queries are involved. Have a look at RelAlgTranslator::translateInOper
. We can use a hybrid approach: collect and generate all the other constants upfront and leave the current handling in place (and keep LICM). Alternatively, we can reorganize the compiler to do a full pass first without emitting any IR, which we know we'll eventually have to do for other reasons as well. Going for the first approach won't hurt our ability to achieve the second and the code should be fully reusable once we have the full solution in place, so I recommend going for it as an incremental, nearly-complete solution.
from heavydb.
Hi @asuhan , I will do so.
Am I correct in assuming that only runtime constants (within the scope of a block) shall be hoisted, but literals can remain as they are?
from heavydb.
Hey @asuhan
I think I need to be much more clearer when addressing things in mapd. (e.g. literal in LLVM IR, literal in REX, literal in Analyzer::Exp, etc...).
Finally managed to look at this in more detail and it turns out that Analyzer::Constant
literals are hoisted in Executor::codegenHoistedConstants
into a memory buffer. And each unoptimized access to the literal requires a memory read from that buffer. As you have pointed out RelAlgTranslator::translateInOper
is creating Analyzer::Constant
dynamically, so scanning early on, right after translating from REX, is not very promising.
Currently I would propose to scan for Analyzer::Constant
via an ScalarExprVisitor
before the actual LLVM IR generation (somewhere in Executor::compileWorkUnit
) and also extend the Constant class to hold a few more attributes required for this extra step.
I would then generate the memory load for each literal in @query_group_by_template
and pass them as arguments to the always inlined @row_func
, which also needs to be extended to take these new parameters.
I would also make this, in effect, a configurable behaviour and would probably introduce a new compiler option flag.
I hope to start tomorrow on it, if there are no objections to the above approach.
from heavydb.
Hi @psockali, your approach sounds reasonable. Add a constant scanning visitor, generate corresponding literal loads in the first block of the query func and feed these values to the always_inlined @row_func
. Not sure if any Constant extensions are necessary but let's see if your motivation can be justified. No need to make this behavior configurable - we're just putting some literal loads where they should have been generated from the get go, instead of relying on LICM to move them there.
You mentioned @query_group_by_template
, note that it's just one of the templates that the query func can be built from, the other one is @query_template
.
from heavydb.
Hey @shtilman, as usual: theory does not reflect reality.
It turns out that during LLVM IR generation Analyzer::Constant
nodes are created on the fly and sometimes the original Constant
node is translated.
See Executor::codegenRowId
, Executor::codegenCmpDecimalConst
and Executor::codegenOuterJoinNullPlaceholder
.
This invalidates the proposed approach, because scanning the source Analyzer::Exp
tree will not be reliable nor sufficient.
I have to rethink .. please bear with me.
from heavydb.
Hey @shtilman,
@asuhan mentioned two approaches:
- Hybrid:
Currently this is the approach I am going for. - Full Pass without IR generation:
I am not confident enough at this stage to make such a central change to the compiler as I am not sure what state(s) the compiler currently maintains and how I would reset it correctly.
I think there is an alternative way, but it would require to clone the row_function (in order to correct the function type with the hoisted variable).
Either way, let me first try the hybrid approach, it probably will be complicated enough.
from heavydb.
Hi @shtilman / @asuhan
I committed an initial version of the hybrid solution. the PR is #145 .
Please let me know if this approach is OK for now as I fear that it does not capture all the cases.
from heavydb.
Comments and discussion are in #145 PR.
from heavydb.
Related Issues (20)
- [GPU Error Bug] SELECT * FROM <table> WHERE ((<column> + <column>) < <column>) OR (<column> = <column>) Brings Errors HOT 1
- golang python HOT 10
- [GPU Error Bug] SELECT * FROM <table> JOIN ( SELECT ALL <number> FROM <table>) AS <alias> Brings Errors
- [GPU Error Bug] CAST(<column>+<column>(overflow) AS BOOLEAN) Brings Errors
- Evaluate using Profile-Guided Optimization (PGO) and Post-Link Optimization (PLO) HOT 1
- Intermitted SIGSEGV errors crashing heavyDB HOT 6
- Cannot import on an individual leaf. Please import from the Aggregator. HOT 1
- pinned memory HOT 2
- Failed to compile heavyDB; CUDA architecture not detected HOT 3
- Some demos on the website are not working or outdated HOT 1
- Error Running HeavyDB with Nvidia Nsight Compute: Broken Pipe in Thrift Connection HOT 7
- Heavydb has not been updated for more than 7 months, is there any plan to continue to update the open source code? HOT 4
- [GPU Logic Bug] SELECT /*+ keep_table_function_result */ <column> FROM <table> GROUP BY <column> Brings Errors HOT 1
- [GPU Logic Bug] SELECT /*+ keep_result */ DISTINCT <column> FROM <table> GROUP BY <column> LIMIT <number> Brings Errors HOT 1
- [GPU Logic Bug] SELECT DISTINCT <column> FROM <table> Brings Errors HOT 1
- [GPU Logic Bug] SELECT <column> FROM <table> JOIN <table> Brings Errors
- [GPU Logic Bug] SELECT /*+ keep_result */ <column> FROM <table> LIMIT <number> OFFSET <number> Brings Errors HOT 1
- [GPU Logic Bug] SELECT /*+ keep_table_function_result */ <column> FROM <table> LIMIT <number> OFFSET <number> Brings Errors HOT 1
- [GPU Logic Bug] SELECT <agg_func> FROM <table> Brings Errors HOT 1
- [GPU Logic Bug] SELECT <column> FROM <table> Brings Errors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from heavydb.