Skip to content
OpenCL based lightweight c++ computing library
C++ CMake
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Refactored Apr 18, 2019
include/EasyCL Fixed all move constructors Apr 19, 2019
tests Refactored Apr 18, 2019
vendor Added new send / receive operators Apr 4, 2019
.gitignore More tests for operators Apr 2, 2019
.gitmodules More tests for operators Apr 2, 2019
CMakeLists.txt Update CMakeLists.txt Apr 5, 2019
COPYING More tests for operators Apr 2, 2019
README.md Update README.md Jul 9, 2019
icon.png icon added Mar 18, 2019

README.md

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

You can’t perform that action at this time.