Code Monkey home page Code Monkey logo

easycl's Introduction

CodeFactor Donate

Easy Computing Library

Icon made by Freepik from www.flaticon.com

Overview

EasyCL is open-source (GPL v3) header-only wrapper above OpenCL library. It's designed for easy and convenient use, allowing you to quickly write the host part of the program and flexibly use OpenCL kernels.

The library is built on the original OpenCL 1.2 C Specification. It allows you to bypass some of the inconveniences of the original OpenCL, providing work with abstractions of different levels, provides you to bypass the restriction of hard binding.

Installation

  1. Install OpenCL library on your system
  2. Clone the repo $ git clone https://github.com/architector1324/EasyCL (or just download the lastest header)
  3. Copy EasyCL.hpp to your project

Hello, World

  1. Copy EasyCL.hpp to project folder
  2. Create main.cpp:
#include <iostream>
#include "EasyCL.hpp"

int main(){
    // setup program and kernel
    auto prog = ecl::Program::load("kernel.cl");
    ecl::Kernel kern = "test";

    // get platform, setup the computer
    auto plat = ecl::System::getPlatform(0);
    auto video = ecl::Computer(0, plat, ecl::DEVICE::GPU);

    // setup data container
    ecl::array<int> a(12); // new int[12]

    // setup compute frame
    ecl::Frame frame = {prog, kern, {&a}};

    // 12 compute units combined into 3 groups
    video << a;
    video.grid(frame, {12}, {3});
    video >> a;

    //output
    for(size_t i = 0; i < 12; i++)
        std::cout << a[i] << std::endl;

    ecl::System::release();
    return 0;
}
  1. Create kernel.cl:
__kernel void test(__global int* a){
    size_t i = get_global_id(0);
    a[i] = (int)get_group_id(0) + 1;
}
  1. Type in terminal:
$ g++ -lOpenCL -o a.out main.cpp
$ ./a.out

Output:

1
1
1
2
2
2
3
3
3
4
4
4

FAQ

easycl's People

Contributors

architector1324 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

easycl's Issues

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.