Giter Club home page Giter Club logo

avm's People

Contributors

takagi 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

avm's Issues

Specify type of user defined function's return value in Lisp backend.

Currently built-in functions are compiled followed by a the form that specifies the type of return value. On the other hand, user defined functions do not come with them, it sometimes prevents their compiled forms not optimized.

We need to provide the forms for user defined functions as well as built-in functions.

Introduce RSQRT built-in function.

We introduce RSQRT built-in function that gives the reciprocal of the square root of the specified value to implement nbody sample code #4 .

For example, the reciprocal of the squre root of a float type value x is defined as:

(rsqrt x) = (/ 1.0 (sqrt x))

We provide RSQRT built-in function for the following types:

  • float
  • double

We need to add related definitions in the following layers:

  • Lisp built-in table
  • CUDA built-in table
  • CL-TUPLES operators
  • CL-CUDA kernel functions

Can not SET values to vector type elements in Lisp backend.

Think about the following form that set a value to a variable foo's element x:

(set (float3-x foo) 0.0)

This form is compiled into the following CL form in Lisp backend:

(setf (avm.lang.data:float3-x*
        (avm.lang.data:float3-values* foo0 foo1 foo2))
      0.0)

Here avm.lang.data:float3-x* is to be expanded into a multiple-value-call form, it is not setfable.

We need to provide setf expanders for CL-TUPLE's tuple element accessors.

Introduce DOT built-in function.

We introduce DOT built-in function for the dot product operation for vector types to implement nbody sample code #4 .

For example, the dot product of two float3 vectors a = (a1, a2, a3) and b = (b1, b2, b3) is defined as:

(dot a b) = (+ (* a1 b1) (* a2 b2) (* a3 b3))

We provide the DOT built-in function for the following vector types:

  • int2
  • int3
  • int4
  • float2
  • float3
  • float4
  • double2
  • double3
  • double4

We need to add related definitions in the following layers:

  • Lisp built-in table
  • CUDA built-in table
  • CL-TUPLES operators
  • CL-CUDA kernel functions

Support impricit progn.

There are some approaches to support implicit progn in let, flet and labels forms.

  • Before macro expansion
    • Insert progn macro
  • At convert-implicit-progn
    • Insert progn syntax
    • Expand as nested let forms
  • At each compile phase
    • Insert progn syntax
    • Handle as multiple forms

Provide EXPAND-MACRO{,-1} functions.

Provide expand-macro and expand-macro-1 API functions which expand a macro form. expand-macro function here is not the same as expand-macro function in compiling phase.

Introduce *NUMBER-OF-THREADS* special variable.

Introduce *number-of-threads* special variable that specifies how many threads are used on executing kernel functions. At the same time, *use-thread-p* special variables are to be depricated.

All samples fail, when using cuda, on OSX 10.11 with latest Cuda 8, SBCL 1.3.1 x64, cl-cuda from git

Same condition on all:

debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {1002ACC683}>:
The function COERCE is undefined.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.

(CL-CUDA.LANG.BUILT-IN::INFERRED-FUNCTION-CANDIDATES COERCE)

When running on CPU all is fine.

Accept free variables in lexical functions.

Currently free variables in lexical functions are not allowed so we have to pass variables we want to use in a lexical function as its arguments.

(defkernel mandelbrot (xs)
  (labels ((aux (x y a b m)
             (if (< m 100)
                 (let ((x1 (- (* x x) (* y y) a))
                       (y1 (- (* 2.0 x y) b)))
                   (if (> (+ (* x1 x1) (* y1 y1)) 4.0)
                       m
                       (aux x1 y1 a b (+ m 1))))
                 0)))
    (let ((a (/ (coerce (- (mod i 2048) 512)) 1024.0))
          (b (/ (coerce (- (/ i 2048) 1024)) 1024.0)))
      (set (aref xs i) (aux 0.0 0.0 a b 1)))))

It is convenient if lexical functions accept free variables so that we do not have to pass them explicitly as following:

(defkernel mandelbrot (xs)
  (let ((a (/ (coerce (- (mod i 2048) 512)) 1024.0))
        (b (/ (coerce (- (/ i 2048) 1024)) 1024.0)))
    (labels ((aux (x y m)
               (if (< m 100)
                   (let ((x1 (- (* x x) (* y y) a))
                         (y1 (- (* 2.0 x y) b)))
                     (if (> (+ (* x1 x1) (* y1 y1)) 4.0)
                         m
                         (aux x1 y1 a b (+ m 1))))
                   0)))
      (set (aref xs i) (aux 0.0 0.0 1)))))

There are several levels to support free variables. Simplest is to pass such variables as arguments implicitly by compiler, which allows us to use copy of the values. We can not modify the original values.

Remove return type in Lisp backend compilation.

Item Test Implementation
compile-function
compile-form
compile-literal
compile-reference
compile-accessor
compile-the
compile-if
compile-let
compile-flet
compile-labels
compile-set
compile-apply
lang.lisp
varenv

Lexical functions leave unused CL-CUDA kernel definitions.

Situation

Currently, lexical functions for CUDA backend are compiled into individual CL-CUDA kernel functions with their names numbered as %AUX0, %AUX1, ... in the following case:

(defkernel foo ()
  (flet ((aux () 1))
    (aux))

=>

(cl-cuda:defkernel %aux0 (cl-cuda:int ())
  (return 1))

Problem

This causes a problem that new CL-CUDA kernel functions are defined every time DEFKERNEL form is compiled, leaving out-dated useless CL-CUDA kernel definitions.

Solution

Changing lexical function names to be prefixed with outer functions' names will solve this problem.

(defkernel foo ()
  (flet ((aux () 1))
    (aux))

=>

(cl-cuda:defkernel %foo-aux (cl-cuda:int ())
  (return 1))

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.