• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    C
  • Created over 7 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Learn OpenCL step by step.

OpenCL-101

Learn OpenCL step by step as below.

  1. OpenCL Examples
  2. Installation Guide of OpenCL

1. OpenCL Examples

  1. vec-add-standard: An standard OpenCL example, accomplish addition operation of two int-type arrays (vectors).
  2. vec-add-simple: An simple addition operation of two vectors (NOT recommanded).
  3. bandwidth: Measure bandwith for various variable type.
  4. mat-transpose: An demo of matrix transpose with two OpenCL kernels.

2. Installation Guide of OpenCL

You can choose one or two ways to use OpenCL:

  1. Install OpenCL on Ubuntu 16.04 64-bit
  2. Using OpenCL by Docker
  3. Using OpenCL by WSL2

2.1 Install OpenCL on Ubuntu 16.04 64-bit

# below instructions refer linux安装opencl:ubuntu14.04+opencl1.1 - qccz123456的博客 - CSDN博客
# http://blog.csdn.net/qccz123456/article/details/52606788

$ sudo apt-get update
$ sudo apt-get install build-essential g++ cmake
$ sudo apt-get install clang libclang-3.4-dev libclang-dev libclang1
$ sudo apt-get install ocl-icd-opencl-dev ocl-icd-libopencl1
$ sudo apt-get install opencl-headers ocl-icd-dev ocl-icd-libopencl1

# below instructions refer Ubuntu 16.04.2 下为 Intel 显卡启用 OpenCL_Linux教程_Linux公社-Linux系统门户网站
# http://www.linuxidc.com/Linux/2017-03/141455.htm

$ sudo apt install ocl-icd-libopencl1
$ sudo apt install opencl-headers
$ sudo apt install clinfo
$ sudo apt install ocl-icd-opencl-dev
$ sudo apt install beignet

2.2 Using OpenCL by Docker

Using Docker is convenient, which you don't need config and install enviroments for all about OpenCL. Of course, install Docker Community Edition first and then search relative images in DockerHub.

After finish Docker installation, please follow this instruction from chihchun/opencl-intel. If anything goes normally, using command below in command line:

$ docker run -t -i --device /dev/dri:/dev/dri \
chihchun/hashcat-beignet hashcat -b

It will print similar messages as Verify installation.

2.3 Verify Installation

Using instruction below, successful installation will print same following messages:

$ clinfo

# print message below

Number of platforms                               1
  Platform Name                                   Intel Gen OCL Driver
  Platform Vendor                                 Intel
  Platform Version                                OpenCL 1.2 beignet 1.1.1
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_spir cl_khr_icd
  Platform Extensions function suffix             Intel

  Platform Name                                   Intel Gen OCL Driver
Number of devices                                 1
  Device Name                                     Intel(R) HD Graphics IvyBridge M GT2
  Device Vendor                                   Intel
  Device Vendor ID                                0x8086
  Device Version                                  OpenCL 1.2 beignet 1.1.1
  Driver Version                                  1.1.1
  Device OpenCL C Version                         OpenCL C 1.2 beignet 1.1.1
  Device Type                                     GPU
  Device Profile                                  FULL_PROFILE
  Max compute units                               16
  Max clock frequency                             1000MHz
  Device Partition                                (core)
    Max number of sub-devices                     1
    Supported partition types                     None, None, None
  Max work item dimensions                        3
  Max work item sizes                             512x512x512
  Max work group size                             512
  Preferred work group size multiple              16
  Preferred / native vector sizes                 
    char                                                16 / 8       
    short                                                8 / 8       
    int                                                  4 / 4       
    long                                                 2 / 2       
    half                                                 0 / 8        (n/a)
    float                                                4 / 4       
    double                                               0 / 2        (n/a)
  Half-precision Floating-point support           (n/a)
  Single-precision Floating-point support         (core)
    Denormals                                     No
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (n/a)
  Address bits                                    32, Little-Endian
  Global memory size                              2147483648 (2GiB)
  Error Correction support                        No
  Max memory allocation                           1073741824 (1024MiB)
  Unified memory for Host and Device              Yes
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        8192
  Global Memory cache line                        64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            65536 pixels
    Max 1D or 2D image array size                 2048 images
    Max 2D image size                             8192x8192 pixels
    Max 3D image size                             8192x8192x2048 pixels
    Max number of read image args                 128
    Max number of write image args                8
  Local memory type                               Global
  Local memory size                               65536 (64KiB)
  Max constant buffer size                        134217728 (128MiB)
  Max number of constant args                     8
  Max size of kernel argument                     1024
  Queue properties                                
    Out-of-order execution                        No
    Profiling                                     Yes
  Prefer user sync for interop                    Yes
  Profiling timer resolution                      80ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            Yes
    SPIR versions                                 <printDeviceInfo:138: get   SPIR versions size : error -30>
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                __cl_copy_region_align4;__cl_copy_region_align16;__cl_cpy_region_unalign_same_offset;__cl_copy_region_unalign_dst_offset;__cl_copy_region_unalign_src_offset;__cl_copy_buffer_rect;__cl_copy_image_1d_to_1d;__cl_copy_image_2d_to_2d;__cl_copy_image_3d_to_2d;__cl_copy_image
_2d_to_3d;__cl_copy_image_3d_to_3d;__cl_copy_image_2d_to_buffer;__cl_copy_image_3d_to_buffer;__cl_copy_buffer_to_image_2d;__cl_copy_buffer_to_image_3d;__cl_fill_region_unalign;__cl_fill_region_align2;__cl_fill_region_align4;__cl_fill_region_align8_2;__cl_fill_region_align8_4;__cl_fill_region_align8_8;__cl_fill_region_
align8_16;__cl_fill_region_align128;__cl_fill_image_1d;__cl_fill_image_1d_array;__cl_fill_image_2d;__cl_fill_image_2d_array;__cl_fill_image_3d;
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Device Extensions                               cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_spir cl_khr_icd

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  Intel Gen OCL Driver
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [Intel]
  clCreateContext(NULL, ...) [default]            Success [Intel]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  Success (1)
    Platform Name                                 Intel Gen OCL Driver
    Device Name                                   Intel(R) HD Graphics IvyBridge M GT2
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Intel Gen OCL Driver
    Device Name                                   Intel(R) HD Graphics IvyBridge M GT2

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.2.8
  ICD loader Profile                              OpenCL 1.2
        NOTE:   your OpenCL library declares to support OpenCL 1.2,
                but it seems to support up to OpenCL 2.1 too.  

How to compile OpenCL example in GCC?

Precisely, the kernel compilation in OpenCL is make in running time (library call).

In Gcc, for compilation, you only need the headers (aviables on Kronos site). But for linkage, you have to install OpenCL compatible driver.

in the Makefile :

  • for Mac OSX : -framework OpenCL
  • for Linux : -lOpenCL

ref: How to compile OpenCL example in GCC?
https://forums.khronos.org/showthread.php/5728-How-to-compile-OpenCL-example-in-GCC

3. Using OpenCL by WSL2

Other problems

git error: unable to auto-detect email address

yuanshuai@firefly:~/code/OpenCL-101$ git commit -m "update README.md"

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'yuanshuai@firefly.(none)')

After following instructions above, it still occured same error message. I reset user.email and user.name using git config --local user.email "[email protected]" and git config --local user.name "Your name" and it's okay!

ref: git中报unable to auto-detect email address 错误的解决拌办法 - liufangbaishi2014的博客 - CSDN博客 http://blog.csdn.net/liufangbaishi2014/article/details/50037507

More Repositories

1

deep-learning-model-convertor

The convertor/conversion of deep learning models for different deep learning frameworks/softwares.
3,244
star
2

embedded-ai.bi-weekly

WeChat: NeuralTalk,Weekly report and awesome list of embedded-ai.
376
star
3

Chinese-UFLDL-Tutorial

[UNMAINTAINED] 非监督特征学习与深度学习中文教程,该版本翻译自新版 UFLDL Tutorial 。建议新人们去学习斯坦福的CS231n课程,该门课程在网易云课堂上也有一个配有中文字幕的版本。
337
star
4

OpenMP-101

Learn OpenMP examples step by step
C
85
star
5

statistical-learning-methods-note

李航《统计学习方法》笔记和 Python 实现(不基于任何代数运算库)。
Python
59
star
6

darknet2caffe

Convert Darknet model to Caffe's
Python
49
star
7

android-reverse-engineering

android-reverse-engineering
26
star
8

Douban-Crawler

抓取豆瓣小组相关信息(小组、用户、帖子)。
Python
24
star
9

link-prediction

[UNMAINTAINED] 基于PySpark与MySQL的复杂网络链路预测。
Python
21
star
10

sword-x-offer

66 classic and common interview problems from 《剑指offer》 with multiple-method-CPP solutions, and common data structure summary, etc
20
star
11

awesome-deep-learning-finetune-experience

This repository not only contains experience about parameter finetune, but also other in-practice experience such as model ensemble (boosting, bagging and stacking) in Kaggle or other competitions.
16
star
12

cv-template

LaTeX resume template
7
star
13

deep-learning-model-archtecture-design-advice

6
star
14

git-101

5
star
15

kaggle-cervical-cancer-screening-classification

Solution and summary for Intel & MobileODT Cervical Cancer Screening (3-class classification)
Jupyter Notebook
5
star
16

Chatter-Bot-CN

基于ChatterBot框架,做一个中文聊天机器人。
Python
5
star
17

logging

A light-weight C++ logging for mobile.
C++
5
star
18

kaggle-lung-cancer-classification

kaggle data science bowl 2017 solution
Jupyter Notebook
4
star
19

naive-binary-gemm

C
3
star
20

caffe-tools

Python
3
star
21

spam-msg-classifier

A spam message classifier based on Naive Bayes.
Python
3
star
22

add-license-for-repo

Add license content for each file in repository recursively
Python
2
star
23

Chinese-word-segmentation

Accomplish Chinese word segmentation by Python.
Python
2
star
24

tmp

C++
2
star
25

stock-newspaper-crawler

[UNMAINTAINED]Crawl 4 kinds of finance newspaper corpus (from CCSTOCK.CN).
Python
2
star
26

tiny-deep-learning-models

fast, tiny deep learning models for mobile and embedded devices
2
star
27

pyTextRank

基于 PageRank 的关键词提取,关键句子提取(摘要)算法的 Python 实现。此外,还有一个基于此的句子相似度算法。
Jupyter Notebook
2
star
28

flask-test

Python
1
star
29

docker-101

1
star
30

monitor

Monitor service status and restart if service dead
Python
1
star
31

Django-TODO

A TODO list project by Django
Python
1
star
32

kaggle-dog-cat-classification

1
star
33

ysh329

1
star
34

software-config

Configures including vim, Xshell and etc.
Vim Script
1
star
35

conv-scale

1
star
36

deXtop

A desktop tool automaticly switching wallpapers on Ubuntu 16.04.
Python
1
star
37

build-101

CMake
1
star
38

deep-learning-operator

implementation, benchmark, optimization
C
1
star
39

Titanic-Machine-Learning-from-Disaster

In this challenge, we ask you to complete the analysis of what sorts of people were likely to survive. In particular, we ask you to apply the tools of machine learning to predict which passengers survived the tragedy.
Python
1
star
40

wordsDB

As the march of project Chinese-word-segmentation, I found that I should create and sustain a words database first. In this projec, mainly concentrating on the general words (come from modern Chinese dictionary, which as the first part) and professional words about financial, stock, fund and economics aspects.
Python
1
star