Code Monkey home page Code Monkey logo

coat's People

Contributors

tetzank avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coat's Issues

Compile extra helper functions during compilation of main function

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.

Void pointers / Operator casting

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

Improvement: Backend-independent code generation

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:

  1. **Too much templated code pollutes the engine source: ** Every part of the engine which uses coat needs to be templated. This template-heavy code ends up propagating to the rest of the engine until eventually a great part of engine code becomes header-only.
  2. **Adaptive execution with coat is a bit cumbersome: ** When doing adaptive execution, one needs two different coat::Function objects, which go through the exact same code generation steps, but emit into different backends. Ideally, the user would want to do something like 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.