Giter Site home page Giter Site logo

brenocfg / rbc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heavyai/rbc

0.0 1.0 0.0 1.86 MB

Remote Backend Compiler

License: BSD 3-Clause "New" or "Revised" License

Jupyter Notebook 30.40% Python 68.15% Thrift 0.82% Batchfile 0.01% Shell 0.62%

rbc's Introduction

RBC - Remote Backend Compiler

Travis CI Appveyor CI Documentation Status

Introduction - test

A LLVM-based compilation contains three components: frontend, optimizer, backend. The frontend parses source code and produces an abstract syntax tree (AST) that is specific to the used programming language. The AST is translated to an intermediate representation (IR) that contains language independent instructions (in the case of LLVM these are SSA instructions). One can apply various optimizations (e.g. eliminating of redundant instructions, symbolic transformations, etc) to the program in IR form. Finally, the backend will transform the IR to machine code (represented in asm language, for instance) that will be specific to the computer architecture on which the program instructions will be executed. The following schema summarizes this compilation process:

       +----------+       +-----------+       +----------+
       | Frontend |------>| Optimizer |------>| Backend  |
       +----------+       +-----------+       +----------+
       /                                              \
      /    AST                                   ASM   \
     /                                                  \
source code      initial IR        transformed IR    machine code

Usually, the transformation of a computer program from its source code to machine code is carried out as a single compilation step on a host computer with a compiler. Programming language interpreters may also use JIT compilers where the source code->machine code transformation is executed in runtime (but again, on the host computer).

The aim of the Remote Backend Compiler (RBC) project is to distribute the tasks of a program JIT compilation process to separate computer systems using the client-server model. The frontend of the compiler would run on the client and the backend would run on the server. The client (compiler frontend) will send the program code to server (compiler backend) in IR form. So, the optimizer can run either in client or server.

The RBC model may be advantageous in applications where a user program (running on a client computer) carries out computations on data that is stored on a server computer while the size of the data would be so large that copying it to client computer would not be feasible: the client computer does not have enough RAM, network bandwidth is too small, server computer contains accelerator hardware, and so on.

The prototype of a RBC model is implemented in Python using Numba and llvmlite tools.

Installation

conda

conda install -c conda-forge rbc

See RBC conda-forge package for more information.

pip

pip install rbc-project

Testing

pytest -sv --pyargs rbc

Usage

Case 1: Compile and evaluate a function in a background process

from rbc import RemoteJIT
rjit = RemoteJIT()
rjit.start_server(background=True)

@rjit('double(double, double)', 'int(int, int)')
def add(x, y):
    return x + y

assert add(1, 2) == 3
assert add(1.2, 2.3) == 3.5

rjit.stop_server()

Case 2: Compile and evaluate a function in a remote server

In remote server (here using localhost for example), start the RemoteJIT process

import rbc
rjit = rbc.RemoteJIT(host='localhost', port=23678)
rjit.start_server()  # this will run the server loop

In a client computer, use the remote servers RemoteJIT process for compilation and evaluation:

from rbc import RemoteJIT
rjit = RemoteJIT(host='localhost', port=23678)
@rjit('double(double, double)', 'int(int, int)')
def add(x, y):
    return x + y
assert add(1, 2) == 3
assert add(1.2, 2.3) == 3.5

Case 3: Define User Defined Function (UDF) in Python and register it in OmnisciDB server

Assume that OmnisciDB server is running in localhost, for instance.

In a client computer, register a UDF in OmnisciDB server:

from rbc.omniscidb import RemoteOmnisci
omni = RemoteOmnisci()
@omni('i32(i32)')
def incr(x):
    return x + 1
omni.register()

In a client computer, use the UDF in a query to OmnisciDB server:

import ibis
con = ibis.omniscidb.connect(...)
q = con.sql('select i, incr(i) from mytable').execute()

More examples and usage cases

See notebooks.

rbc's People

Contributors

pearu avatar guilhermeleobas avatar brenocfg avatar angelisamaria avatar antocuni avatar jclay avatar

Watchers

James Cloos avatar

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.