All Projects → libocca → Occa

libocca / Occa

Licence: mit
JIT Compilation for Multiple Architectures: C++, OpenMP, CUDA, HIP, OpenCL, Metal

Programming Languages

c
50402 projects - #5 most used programming language
cpp
1120 projects
fortran
972 projects

Projects that are alternatives of or similar to Occa

Arrayfire Python
Python bindings for ArrayFire: A general purpose GPU library.
Stars: ✭ 358 (+55.65%)
Mutual labels:  gpu, gpgpu, opencl, cuda, hpc
Futhark
💥💻💥 A data-parallel functional programming language
Stars: ✭ 1,641 (+613.48%)
Mutual labels:  gpu, gpgpu, opencl, cuda, hpc
Parenchyma
An extensible HPC framework for CUDA, OpenCL and native CPU.
Stars: ✭ 71 (-69.13%)
Mutual labels:  gpu, gpgpu, opencl, cuda, hpc
Arrayfire
ArrayFire: a general purpose GPU library.
Stars: ✭ 3,693 (+1505.65%)
Mutual labels:  gpu, gpgpu, opencl, cuda, hpc
Arrayfire Rust
Rust wrapper for ArrayFire
Stars: ✭ 525 (+128.26%)
Mutual labels:  gpu, gpgpu, opencl, cuda, hpc
Ilgpu
ILGPU JIT Compiler for high-performance .Net GPU programs
Stars: ✭ 374 (+62.61%)
Mutual labels:  jit, gpu, gpgpu, opencl, cuda
monolish
monolish: MONOlithic LInear equation Solvers for Highly-parallel architecture
Stars: ✭ 166 (-27.83%)
Mutual labels:  hpc, gpu, openmp, cuda
Compute
A C++ GPU Computing Library for OpenCL
Stars: ✭ 1,192 (+418.26%)
Mutual labels:  gpu, gpgpu, opencl, hpc
allgebra
Base container for developing C++ and Fortran HPC applications
Stars: ✭ 14 (-93.91%)
Mutual labels:  hpc, gpu, openmp, cuda
Babelstream
STREAM, for lots of devices written in many programming models
Stars: ✭ 121 (-47.39%)
Mutual labels:  openmp, gpgpu, opencl, cuda
Hipsycl
Implementation of SYCL for CPUs, AMD GPUs, NVIDIA GPUs
Stars: ✭ 377 (+63.91%)
Mutual labels:  gpu, gpgpu, opencl, cuda
MatX
An efficient C++17 GPU numerical computing library with Python-like syntax
Stars: ✭ 418 (+81.74%)
Mutual labels:  hpc, gpu, cuda, gpgpu
gpubootcamp
This repository consists for gpu bootcamp material for HPC and AI
Stars: ✭ 227 (-1.3%)
Mutual labels:  hpc, gpu, openmp, cuda
Bitcracker
BitCracker is the first open source password cracking tool for memory units encrypted with BitLocker
Stars: ✭ 463 (+101.3%)
Mutual labels:  gpu, gpgpu, opencl, cuda
John
John the Ripper jumbo - advanced offline password cracker, which supports hundreds of hash and cipher types, and runs on many operating systems, CPUs, GPUs, and even some FPGAs
Stars: ✭ 5,656 (+2359.13%)
Mutual labels:  openmp, gpu, gpgpu, opencl
Arraymancer
A fast, ergonomic and portable tensor library in Nim with a deep learning focus for CPU, GPU and embedded devices via OpenMP, Cuda and OpenCL backends
Stars: ✭ 793 (+244.78%)
Mutual labels:  openmp, gpgpu, opencl, cuda
Amgcl
C++ library for solving large sparse linear systems with algebraic multigrid method
Stars: ✭ 390 (+69.57%)
Mutual labels:  openmp, gpgpu, opencl, cuda
Stdgpu
stdgpu: Efficient STL-like Data Structures on the GPU
Stars: ✭ 531 (+130.87%)
Mutual labels:  openmp, gpu, gpgpu, cuda
Neanderthal
Fast Clojure Matrix Library
Stars: ✭ 927 (+303.04%)
Mutual labels:  gpu, gpgpu, opencl, cuda
Cekirdekler
Multi-device OpenCL kernel load balancer and pipeliner API for C#. Uses shared-distributed memory model to keep GPUs updated fast while using same kernel on all devices(for simplicity).
Stars: ✭ 76 (-66.96%)
Mutual labels:  gpu, gpgpu, opencl

occa

 

Build codecov.io Slack

 

Table of Contents

 

What is OCCA?

In a nutshell, OCCA (like oca-rina) is an open-source library which aims to

  • Make it easy to program different types of devices (e.g. CPU, GPU, FPGA)
  • Provide a unified API for interacting with backend device APIs (e.g. OpenMP, CUDA, HIP, OpenCL, Metal)
  • JIT compile backend kernels and provide a kernel language (a minor extension to C) to abstract programming for each backend

The "Hello World" example of adding two vectors looks like:

@kernel void addVectors(const int entries,
                        const float *a,
                        const float *b,
                        float *ab) {
  for (int i = 0; i < entries; ++i; @tile(16, @outer, @inner)) {
    ab[i] = a[i] + b[i];
  }
}

Or we can inline it using C++ lambdas

// Capture variables
occa::scope scope({
  {"a", a},
  {"b", b},
  {"ab", ab}
});

occa::forLoop()
  .tile({entries, 16})
  .run(OCCA_FUNCTION(scope, [=](const int i) -> void {
    ab[i] = a[i] + b[i];
  }));

Or we can use a more functional way by using occa::array

// Capture variables
occa::scope scope({
  {"b", b}
});

occa::array<float> ab = (
  a.map(OCCA_FUNCTION(
    scope,
    [=](const float &value, const int index) -> float {
      return value + b[index];
    }
  ))
);

 

Documentation

We maintain our documentation on the libocca.org site

 

How to build

git clone --depth 1 https://github.com/libocca/occa.git
cd occa
make -j 4

Setup environment variables inside the occa directory

Linux
export PATH+=":${PWD}/bin"
export LD_LIBRARY_PATH+=":${PWD}/lib"

MacOS
export PATH+=":${PWD}/bin"
export DYLD_LIBRARY_PATH+=":${PWD}/lib"

 

Examples

Hello World

The occa library is based on 3 different objects, all covered in the 01_add_vectors example:

  • occa::device
  • occa::memory
  • occa::kernel
cd examples/cpp/01_add_vectors
make
./main

Inline for-loops

Find how to inline for loops using occa::forLoop in example 02_for_loops:

cd examples/cpp/02_for_loops
make
./main

 

Arrays + Functional Programming

Learn how to use occa::array in a functional way in example 03_arrays:

cd examples/cpp/03_arrays
make
./main

 

CLI

There is an executable occa provided inside bin

> occa

Usage: occa [OPTIONS] COMMAND [COMMAND...]

Helpful utilities related to OCCA workflows

Commands:
  autocomplete    Prints shell functions to autocomplete occa
                  commands and arguments
  clear           Clears cached files and cache locks
  compile         Compile kernels
  env             Print environment variables used in OCCA
  info            Prints information about available backend modes
  modes           Prints available backend modes
  translate       Translate kernels
  version         Prints OCCA version

Arguments:
  COMMAND    Command to run

Options:
  -h, --help    Print usage

 

Bash Autocomplete

if which occa > /dev/null 2>&1; then
    eval "$(occa autocomplete bash)"
fi

Similar Libraries

OCCA is definitely not the only solution that aims to simplify programming on different hardware/accelerators. Here is a list of other libraries that have taken different approaches:

  • Alpaka

    The alpaka library is a header-only C++14 abstraction library for accelerator development. Its aim is to provide performance portability across accelerators through the abstraction (not hiding!) of the underlying levels of parallelism.

  • RAJA

    RAJA is a library of C++ software abstractions, primarily developed at Lawrence Livermore National Laboratory (LLNL), that enables architecture and programming model portability for HPC applications

  • Kokkos

    Kokkos Core implements a programming model in C++ for writing performance portable applications targeting all major HPC platforms. For that purpose it provides abstractions for both parallel execution of code and data management.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].