tetzank / coat Goto Github PK
View Code? Open in Web Editor NEWEDSL for C++ to make just-in-time code generation easier
License: MIT License
EDSL for C++ to make just-in-time code generation easier
License: MIT License
Hi,
I have the problem that for operators like Sort and Join one probably wants to compile the compare/hash functions. For asmjit backend doing something like bellow works fine:
(EDITED)
coat::Function<coat::runtimeasmjit,compare_function_t > compare_f(fn.asmrt, "compare_f");
{
auto [a, b] = compare_f.getArguments("a", "b");
// TODO haven't found a nice way of returning 0/1 for compare functions
coat::if_then_else(compare_f, a < b, [&] {
coat::ret(compare_f, one);
}, [&] {
coat::ret(compare_f, zero);
});
}
// Saves the function pointer for later usage
SortOperator::compiled_compare = compare_f.finalize();
...
static void call_sort(start, end) {
std::sort(start, end, SortOperator.compiled_compare);
}
Then later I call
coat::FunctionCall(fn, SortOperator::call_sort, "call_sort", start, end);
For LLVM it doesn't work as using the same runtime for both functions will cause the first finalize()
call to terminate it for both. Also, doing:
coat::runtimellvmjit
coat::Function<coat::runtimellvmjit,compare_function_t > compare_f(llvmrt, "compare_f");
{...}
SortOperator::compiled_compare = compare_f.finalize();
coat::FunctionCall(fn, SortOperator::call_sort, "call_sort", start, end);
doesn't work either. The generated functions f
and compare_f
keep calling each other.
Internal Functions wouldn't help either because I can't pass it to an external function.
Do you see any way out of it? It would really mess my code if I had to first generate the helper functions separately and then generate the query function.
Hi, first of all congrats on the framework. It's quite interesting
My issue is the following: I have a Buffer which allows to store tuples (for operators that need materialization). It works by calling a method void* store_tuple(size_t tuple_size)
which allocates memory of size "tuple_size" and returns a pointer to the beginning of this region.
In normal, non-generated code, I would cast this void pointer to the type I need. However, I don't know how to do it in coat. One could template the function to store tuples, like the following
template<class T>
T* store_tuple(size_t tuple_size)
However, this would still be problematic when trying to store tuples with different datatypes
Hello,
First of all I'd like to share a very positive feedback on the project. Last semester I completed this project where coat was used to compile code for ReGex matching. The results were really impressive as can be seen on the final report.
I'm currently working on a tiny query engine that uses coat for code generation. My impressions are that even though the framework is very easy to use, it has the following weak-spots:
f1 = fn.finalize(backend_1); f2 = fn.finalize(backend_2);
and only inject the back-end at the end.One solution would be to create an analogous to UMBRA IR (described here) that first generates an intermediate representation, and then based on the back-end emits machine code.
This solves both problems because the code to generate the intermediate representation is template-free and one can inject different runtimes to translate the intermediate representation to machine code.
I want to implement this feature. Would that be integrated into coat? Do you have any thoughts to share about it? Should we discuss more on the exact design?
Looking forward for your feedback
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.