Skip to content

Commit

Permalink
Merge pull request #20 from ctuning/issue-22
Browse files Browse the repository at this point in the history
Add OpenCL v1.1. stab #19
  • Loading branch information
gfursin authored Jan 17, 2017
2 parents c61036a + 8910baa commit 2088c3d
Show file tree
Hide file tree
Showing 21 changed files with 3,084 additions and 0 deletions.
1 change: 1 addition & 0 deletions package/.cm/alias-a-lib-opencl-1.1-stubs-android
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
51417bde2463db8f
1 change: 1 addition & 0 deletions package/.cm/alias-u-51417bde2463db8f
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib-opencl-1.1-stubs-android
1 change: 1 addition & 0 deletions package/lib-opencl-1.1-stubs-android/.cm/desc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
21 changes: 21 additions & 0 deletions package/lib-opencl-1.1-stubs-android/.cm/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"backup_data_uid": "51417bde2463db8f",
"backup_module_uid": "1dc07ee0f4742028",
"backup_module_uoa": "package",
"control": {
"author": "Grigori Fursin",
"author_email": "[email protected]",
"author_webpage": "http://fursin.net",
"copyright": "See CK COPYRIGHT.txt for copyright details",
"engine": "CK",
"iso_datetime": "2017-01-13T13:46:16.355876",
"license": "See CK LICENSE.txt for licensing details",
"version": [
"1",
"8",
"6",
"1"
]
},
"data_name": "lib-opencl-1.1-stubs-android"
}
35 changes: 35 additions & 0 deletions package/lib-opencl-1.1-stubs-android/.cm/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"customize": {
"extra_dir": "",
"skip_copy_to_remote": "yes",
"skip_ext": "yes",
"version": "1.1"
},
"deps": {
"compiler": {
"local": "yes",
"name": "C compiler",
"sort": 10,
"tags": "compiler,lang-c"
}
},
"end_full_path": {
"android": "lib$#sep#$libOpenCL.so"
},
"only_for_host_os_tags": [
"windows",
"linux"
],
"only_for_target_os_tags": [
"android"
],
"process_script": "process",
"soft_uoa": "6eb9a57038688ad3",
"suggested_path": "lib-opencl-stubs",
"tags": [
"lib",
"opencl",
"lang-c",
"lang-cpp"
]
}
4 changes: 4 additions & 0 deletions package/lib-opencl-1.1-stubs-android/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Grigori Fursin downloaded and converted cl.h from Khronos website and created stubs lib
needed for compiling OpenCL-based programs for Android mobile devices:

* https://www.khronos.org/registry/cl/
14 changes: 14 additions & 0 deletions package/lib-opencl-1.1-stubs-android/_download.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cd include
cd CL

wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/opencl.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_platform.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_ext.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_egl.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_dx9_media_sharing.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_d3d10.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_d3d11.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_gl.h
wget https://raw.githubusercontent.com/KhronosGroup/OpenCL-Headers/opencl12/cl_gl_ext.h
wget https://www.khronos.org/registry/cl/api/2.1/cl.hpp
1 change: 1 addition & 0 deletions package/lib-opencl-1.1-stubs-android/_process.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python _process.py include/CL/cl.h
55 changes: 55 additions & 0 deletions package/lib-opencl-1.1-stubs-android/_process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import sys
import os

lib=sys.argv[1]

f=open(lib, 'r')
s=f.read()
f.close()

o ='/**********************************************************\n'
o+=' Automatically generated for Collective Knowledge Framework\n'
o+=' http://github.com/ctuning/ck\n'
o+='\n'
o+=' (C)opyright 2016 by Grigori Fursin (cTuning foundation)\n'
o+='\n'
o+=' Released under the same license as OpenCL\n'
o+=' (see include/CL/cl.h)\n'
o+='**********************************************************/\n'
o+='\n'
o+='#include <CL/cl.h>\n'
o+='\n'

ll=s.split('\n')

w=False
for l in ll:
if w:
if l.endswith(';'):
w=False
lx=l[:-1]+'\n'
lx+='{}\n'
lx+='\n'
else:
lx=l+'\n'

# Process var names
i1=lx.find('/*')
if i1>0:
i2=lx.find('*/',i1)
if i2>0:
vr=lx[i1+2:i2-1].strip()
if vr.endswith('[3]'):
vr=vr[:-3]
lx=lx[:i1-1]+' '+vr+' '+lx[i2+2:]

o+=lx

elif l.startswith('extern CL_API_ENTRY ') and l.find('_DEPRECATED')<0:
w=True
o+=l[7:]+'\n'

# Write CK json
f=open('lib/stubs.c','wt')
f.write(o)
f.close()
47 changes: 47 additions & 0 deletions package/lib-opencl-1.1-stubs-android/ck-make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@echo off

rem
rem Make script for CK libraries
rem (depends on configured/installed compilers via CK)
rem
rem See CK LICENSE.txt for licensing details.
rem See CK Copyright.txt for copyright details.
rem
rem Developer(s): Grigori Fursin, 2015
rem

set CK_SOURCE_FILES=stubs.c
set CK_OBJ_FILES=stubs%CK_OBJ_EXT%
set LIB_NAME=libOpenCL

set CK_COMPILER_FLAGS_MISC=%CK_FLAG_PREFIX_INCLUDE%../include %CK_COMPILER_FLAGS_MISC%

echo.
echo Building dynamic library ...
echo.

set CK_TARGET_FILE=%LIB_NAME%%CK_DLL_EXT%
set CK_TARGET_FILE_D=%CK_TARGET_FILE%

set CK_CC_FLAGS=%CK_COMPILER_FLAGS_OBLIGATORY% %CK_COMPILER_FLAGS_MISC% %CK_COMPILER_FLAGS_CC_OPTS% %CK_COMPILER_FLAGS_ARCH% %CK_COMPILER_FLAGS_PAR%

echo Executing %CK_CC% %CK_OPT_SPEED% %CK_FLAGS_DLL% %CK_CC_FLAGS% %CK_SOURCE_FILES% %CK_FLAGS_OUTPUT%%CK_TARGET_FILE% %CK_FLAGS_DLL_EXTRA% %CK_LD_FLAGS_MISC% %CK_LD_FLAGS_EXTRA%
%CK_CC% %CK_OPT_SPEED% %CK_FLAGS_DLL% %CK_CC_FLAGS% %CK_SOURCE_FILES% %CK_FLAGS_OUTPUT%%CK_TARGET_FILE% %CK_FLAGS_DLL_EXTRA% %CK_LD_FLAGS_MISC% %CK_LD_FLAGS_EXTRA%
if %errorlevel% neq 0 (
echo.
echo Building failed!
goto err
)

echo.
echo Installing ...
echo.

mkdir %INSTALL_DIR%\lib
copy /B %CK_TARGET_FILE_D% %INSTALL_DIR%\lib

exit /b 0

:err
set /p x=Press any key to continue!
exit /b 1
18 changes: 18 additions & 0 deletions package/lib-opencl-1.1-stubs-android/ck-make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#! /bin/bash

#
# Make script for CK libraries
# (depends on configured/installed compilers via CK)
#
# See CK LICENSE.txt for licensing details.
# See CK Copyright.txt for copyright details.
#
# Developer(s): Grigori Fursin, 2015
#


echo ""
echo "cmake is not required for vis version just copy libOpenCL.so..."
echo ""


Loading

0 comments on commit 2088c3d

Please sign in to comment.