Giter Site home page Giter Site logo

yvesyil / claw-js Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.12 MB

A hardware accelerated linear algebra library for JavaScript.

License: MIT License

CMake 0.48% C 96.39% JavaScript 3.13%
c gpu-computing javascript nodejs opencl systems-level-programming

claw-js's Introduction

Claw.js

A hardware accelerated linear algebra library for JavaScript.

Warning

Claw.js is currently in very early development. It's not going to solve any of your problems yet, but I'm working on it regularly.

Note This README is dedicated to the core C library (libclaw). See the claw-js npm package to learn about the JavaScript interface.

About

There are many libraries for Python for numerical computation, especially for linear algebra e.g. Numpy, PyTorch. Not many options are available for Node.js and to be fair, JavaScript is not the most suitable programming language for the job. But like many people from the JS community, I told myself, why not?

Claw.js uses OpenCL. I know that it's not the latest and greatest API for GPUs. The reason I wanted to first develop with that is portability. I don't want Claw.js to be dependent on a specific hardware vendor, you should be able to use it with any GPU you have!

However, support for CUDA will come in the near future.

Stack

Goals

Note Items with higher importance are usually appears higher in the list, so it's essentially a priority queue.

  • First implementations of core library (datatypes, interfaces).
  • Implement primitive matrix operations using OpenCL.
  • Create bindings for Node.js (instead of using FFI).
  • Support for CUDA.
  • SIMD optimizations.
  • Bindings for other runtimes e.g. Deno.

Installation

Note This README is dedicated to the core C library (libclaw). If you would like to use it with JavaScript, see the README at claw-js in npm.

Requirements

Build the shared object file from source (Mac & Linux)

  1. Clone this repo: git clone https://github.com/tussoftwaredesign/claw-js.git
  2. Navigate to the project root: cd claw-js
  3. Make a build directory: mkdir build
  4. Generate the build file: cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release
  5. Compile: cmake --build build -j10
  6. The compiled libclaw.so (libclaw.dylib on Mac) shared object (dynamic link library) file will be inside build

Documentation

Note This README is dedicated to the core C library (libclaw). If you would like to see the documentation for JavaScript, see the README at claw-js in npm.

Basic Example of the C API

#include <stdio.h>

#include <claw.h>

int main(int argc, char **argv)
{
    // initialize the library
    claw_init(); 
    
    // define three matrices a, b, and c.
    struct claw_mat a;
    struct claw_mat b;
    struct claw_mat c;
    
    // initialize a and b with random values between 0 and 1 and give the shape 1024x1024.
    claw_create_matrix_rand_unit(&a, 1024, 1024, CLAW_FLT32);
    claw_create_matrix_rand_unit(&b, 1024, 1024, CLAW_FLT32);
    
    // print a and b
    claw_print_matrix(stdout, &a);
    claw_print_matrix(stdout, &b);
   
    // c = a * b
    claw_matmul(&a, &b, &c);
    
    // print c 
    claw_print_matrix(stdout, &c);
    
    // cleanup
    claw_free(a);
    claw_free(b);
    claw_free(c);
}

Contributing

Please contact @yvesyil before making any changes.

License

MIT License

Acknowledgments

  • Developer: Yiğit Yılmaz @yvesyil
  • Project supervisor: John Barrett @jcbtus

claw-js's People

Contributors

yvesyil avatar

Stargazers

 avatar  avatar

Watchers

 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.