├── .DS_Store ├── .gitignore ├── .travis.yml ├── 0.bindings-src ├── 1-0-package.lisp ├── 1-1-library.lisp ├── 1-2-util-for-grovel.lisp ├── 1-3-grovel-version.lisp ├── 1-4-opencl-version-feature.lisp ├── 2-0-package.lisp ├── 2-1-grovel-cl_platform.lisp ├── 2-4-grovel-cl-enum.lisp ├── 2-4-grovel-cl.lisp ├── 2-5-grovel-buffer.lisp ├── 2-6-grovel-image.lisp ├── 3-0-package.lisp ├── 3-1-translators.lisp ├── 3-2-bindings.lisp ├── README ├── dump-image.lisp ├── extfun.lisp ├── gl-binding.lisp ├── grovel-cl_gl.lisp ├── icd-binding.lisp └── retain-api.lisp ├── 1.error-src ├── error-handlers.lisp └── package.lisp ├── 2.host-src ├── 0package.lisp ├── 1util.lisp ├── 3getter-api.lisp ├── 4getter-api-definitions.lisp ├── 5setter-api.lisp ├── 6list-apis.lisp ├── 7create-apis.lisp └── 8launch-steps.lisp ├── 3.fancy-src ├── 0-package.lisp └── 1-query.lisp ├── HACKING.org ├── README.org ├── build-pocl.sh ├── circle.yml ├── eazy-opencl.asd ├── eazy-opencl.bindings.asd ├── eazy-opencl.error.asd ├── eazy-opencl.fancy.asd ├── eazy-opencl.host.asd ├── eazy-opencl.test.asd ├── t ├── helloworld.cl └── package.lisp └── testscr.ros /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guicho271828/eazy-opencl/ec3b2aae3a768bed738d825a0c7e2394a3d6622a/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.fasl 2 | *.dx32fsl 3 | *.dx64fsl 4 | *.lx32fsl 5 | *.lx64fsl 6 | *.x86f 7 | *~ 8 | .#* 9 | /cl-opencl-3b/ 10 | /lang/ 11 | /CL/ 12 | /2.host-src/get.lisp 13 | /2.host-src/opencl.lisp 14 | /pocl/ 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | sudo: true 3 | 4 | addons: 5 | apt: 6 | sources: 7 | - llvm-toolchain-precise-3.6 8 | - ubuntu-toolchain-r-test 9 | packages: 10 | - g++-4.8 11 | - clang-3.6 12 | - libclang-3.6-dev 13 | - llvm-3.6-dev 14 | - libedit-dev 15 | - libc6-i386 16 | - clisp 17 | - openjdk-7-jre 18 | 19 | env: 20 | global: 21 | - PATH=~/.roswell/bin:$PATH 22 | - ROSWELL_INSTALL_DIR=$HOME/.roswell 23 | - LLVM_CONFIG=/usr/lib/llvm-3.6/bin/llvm-config 24 | matrix: 25 | - LISP=sbcl-bin 26 | - LISP=ccl-bin 27 | - LISP=abcl 28 | - LISP=clisp 29 | - LISP=ecl 30 | - LISP=cmucl 31 | - LISP=alisp 32 | 33 | matrix: 34 | allow_failures: 35 | - env: LISP=ccl 36 | - env: LISP=clisp 37 | - env: LISP=abcl 38 | - env: LISP=ecl 39 | - env: LISP=cmucl 40 | - env: LISP=alisp 41 | 42 | install: 43 | - sudo bash -c 'echo "deb http://mirrors.kernel.org/ubuntu vivid main universe" >> /etc/apt/sources.list' 44 | - sudo apt-get update 45 | - sudo apt-get install -y libltdl3-dev libhwloc-dev ocl-icd-opencl-dev 46 | - ./build-pocl.sh 47 | - sudo make -C pocl install 48 | - curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh 49 | # this is a temporary change until https://github.com/cffi/cffi/commit/7861673b90f1e99932872722ccc46a8145736c75 is registered to quicklisp 50 | - git clone https://github.com/cffi/cffi.git ~/lisp/cffi 51 | - ros install cffi 52 | - ros install cffi-grovel 53 | - ros install eazy-opencl 54 | 55 | cache: 56 | directories: 57 | - $HOME/.roswell 58 | - $HOME/.config/common-lisp 59 | - $HOME/pocl 60 | 61 | script: 62 | - ./testscr.ros 63 | -------------------------------------------------------------------------------- /0.bindings-src/1-0-package.lisp: -------------------------------------------------------------------------------- 1 | (defpackage :eazy-opencl.grovel-utils 2 | (:use :cl :cffi) 3 | (:nicknames :%ocl/u) 4 | (:export 5 | #:lispify 6 | #:lispify-k 7 | #:lispify-k-pair 8 | #:lispify-wo-prefix)) 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /0.bindings-src/1-1-library.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :eazy-opencl.grovel-utils) 3 | 4 | (define-foreign-library :opencl 5 | (:darwin (:framework "OpenCL")) ;; ? 6 | (:windows "OpenCL.dll" :convention :stdcall) 7 | (:unix (:or "libOpenCL.so" "libOpenCL.so.1" "libOpenCL.so.1.0" ))) 8 | 9 | (use-foreign-library :opencl) 10 | -------------------------------------------------------------------------------- /0.bindings-src/1-2-util-for-grovel.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :eazy-opencl.grovel-utils) 3 | 4 | ;; drawn from swig-lispify 5 | 6 | (defun lispify (name &optional flag (package *package*)) 7 | (labels ((helper (lst last rest &aux (c (car lst))) 8 | (cond 9 | ((null lst) 10 | rest) 11 | ((upper-case-p c) 12 | (helper (cdr lst) 'upper 13 | (case last 14 | ((lower) (list* c #\- rest)) 15 | (t (cons c rest))))) 16 | ((lower-case-p c) 17 | (helper (cdr lst) 'lower (cons (char-upcase c) rest))) 18 | ((digit-char-p c) 19 | (helper (cdr lst) 'digit 20 | (cons c rest))) 21 | ((char-equal c #\_) 22 | (helper (cdr lst) '_ (cons #\- rest))) 23 | (t 24 | (error "Invalid character: ~A" c))))) 25 | (let* ((fix (case flag 26 | ((constant enumvalue) "+") 27 | (variable "*") 28 | (t ""))) 29 | (sym (intern 30 | (concatenate 31 | 'string 32 | fix 33 | (nreverse (helper (concatenate 'list name) nil nil)) 34 | fix) 35 | package))) 36 | ;;(export sym package) 37 | sym))) 38 | 39 | (defun lispify-k (name &optional flag) 40 | (lispify name flag (find-package :keyword))) 41 | 42 | (defun lispify-k-pair (name &optional flag) 43 | (assert (zerop (search "CL_" name :test #'char-equal))) 44 | `(,(lispify (subseq name 3) flag (find-package :keyword)) ,name)) 45 | 46 | (defun lispify-wo-prefix (name &optional flag) 47 | (assert (zerop (search "CL_" name :test #'char-equal))) 48 | (lispify (subseq name 3) flag)) 49 | 50 | -------------------------------------------------------------------------------- /0.bindings-src/1-3-grovel-version.lisp: -------------------------------------------------------------------------------- 1 | ;; groveller file 2 | (in-package :eazy-opencl.grovel-utils) 3 | 4 | #+darwin 5 | (include "OpenCL/cl.h") 6 | 7 | #-darwin 8 | (include "CL/cl.h") 9 | 10 | (constant (opencl-1.0 "CL_VERSION_1_0") :optional t) 11 | (constant (opencl-1.1 "CL_VERSION_1_1") :optional t) 12 | (constant (opencl-1.2 "CL_VERSION_1_2") :optional t) 13 | (constant (opencl-2.0 "CL_VERSION_2_0") :optional t) 14 | (constant (opencl-2.1 "CL_VERSION_2_1") :optional t) 15 | -------------------------------------------------------------------------------- /0.bindings-src/1-4-opencl-version-feature.lisp: -------------------------------------------------------------------------------- 1 | (in-package :eazy-opencl.grovel-utils) 2 | 3 | (when (boundp 'opencl-1.0) (push :opencl-1.0 *features*)) 4 | (when (boundp 'opencl-1.1) (push :opencl-1.1 *features*)) 5 | (when (boundp 'opencl-1.2) (push :opencl-1.2 *features*)) 6 | (when (boundp 'opencl-2.0) (push :opencl-2.0 *features*)) 7 | (when (boundp 'opencl-2.1) (push :opencl-2.1 *features*)) 8 | -------------------------------------------------------------------------------- /0.bindings-src/2-0-package.lisp: -------------------------------------------------------------------------------- 1 | (in-package :%ocl/u) 2 | 3 | (defpackage :eazy-opencl.grovel 4 | (:use :cffi :%ocl/u) 5 | (:nicknames :%ocl/g) 6 | ;; C.1 shared application scalar data types 7 | #.(list 8 | :export 9 | (lispify-wo-prefix "CL_CHAR") 10 | (lispify-wo-prefix "CL_UCHAR") 11 | (lispify-wo-prefix "CL_SHORT") 12 | (lispify-wo-prefix "CL_USHORT") 13 | (lispify-wo-prefix "CL_INT") 14 | (lispify-wo-prefix "CL_UINT") 15 | (lispify-wo-prefix "CL_LONG") 16 | (lispify-wo-prefix "CL_ULONG") 17 | (lispify-wo-prefix "CL_HALF") 18 | (lispify-wo-prefix "CL_FLOAT") 19 | (lispify-wo-prefix "CL_DOUBLE")) 20 | ;; C.2 supported application vector data types 21 | #.(list 22 | :export 23 | (lispify-wo-prefix "CL_CHAR2") 24 | (lispify-wo-prefix "CL_UCHAR2") 25 | (lispify-wo-prefix "CL_SHORT2") 26 | (lispify-wo-prefix "CL_USHORT2") 27 | (lispify-wo-prefix "CL_INT2") 28 | (lispify-wo-prefix "CL_UINT2") 29 | (lispify-wo-prefix "CL_LONG2") 30 | (lispify-wo-prefix "CL_ULONG2") 31 | (lispify-wo-prefix "CL_HALF2") 32 | (lispify-wo-prefix "CL_FLOAT2") 33 | (lispify-wo-prefix "CL_DOUBLE2") 34 | 35 | (lispify-wo-prefix "CL_CHAR3") 36 | (lispify-wo-prefix "CL_UCHAR3") 37 | (lispify-wo-prefix "CL_SHORT3") 38 | (lispify-wo-prefix "CL_USHORT3") 39 | (lispify-wo-prefix "CL_INT3") 40 | (lispify-wo-prefix "CL_UINT3") 41 | (lispify-wo-prefix "CL_LONG3") 42 | (lispify-wo-prefix "CL_ULONG3") 43 | (lispify-wo-prefix "CL_HALF3") 44 | (lispify-wo-prefix "CL_FLOAT3") 45 | (lispify-wo-prefix "CL_DOUBLE3") 46 | 47 | (lispify-wo-prefix "CL_CHAR4") 48 | (lispify-wo-prefix "CL_UCHAR4") 49 | (lispify-wo-prefix "CL_SHORT4") 50 | (lispify-wo-prefix "CL_USHORT4") 51 | (lispify-wo-prefix "CL_INT4") 52 | (lispify-wo-prefix "CL_UINT4") 53 | (lispify-wo-prefix "CL_LONG4") 54 | (lispify-wo-prefix "CL_ULONG4") 55 | (lispify-wo-prefix "CL_HALF4") 56 | (lispify-wo-prefix "CL_FLOAT4") 57 | (lispify-wo-prefix "CL_DOUBLE4") 58 | 59 | (lispify-wo-prefix "CL_CHAR8") 60 | (lispify-wo-prefix "CL_UCHAR8") 61 | (lispify-wo-prefix "CL_SHORT8") 62 | (lispify-wo-prefix "CL_USHORT8") 63 | (lispify-wo-prefix "CL_INT8") 64 | (lispify-wo-prefix "CL_UINT8") 65 | (lispify-wo-prefix "CL_LONG8") 66 | (lispify-wo-prefix "CL_ULONG8") 67 | (lispify-wo-prefix "CL_HALF8") 68 | (lispify-wo-prefix "CL_FLOAT8") 69 | (lispify-wo-prefix "CL_DOUBLE8") 70 | 71 | (lispify-wo-prefix "CL_CHAR16") 72 | (lispify-wo-prefix "CL_UCHAR16") 73 | (lispify-wo-prefix "CL_SHORT16") 74 | (lispify-wo-prefix "CL_USHORT16") 75 | (lispify-wo-prefix "CL_INT16") 76 | (lispify-wo-prefix "CL_UINT16") 77 | (lispify-wo-prefix "CL_LONG16") 78 | (lispify-wo-prefix "CL_ULONG16") 79 | (lispify-wo-prefix "CL_HALF16") 80 | (lispify-wo-prefix "CL_FLOAT16") 81 | (lispify-wo-prefix "CL_DOUBLE16") 82 | 83 | (lispify-wo-prefix "CL_CHAR_BIT" :constant) 84 | (lispify-wo-prefix "CL_SCHAR_MAX" :constant) 85 | (lispify-wo-prefix "CL_SCHAR_MIN" :constant) 86 | (lispify-wo-prefix "CL_CHAR_MAX" :constant) 87 | (lispify-wo-prefix "CL_CHAR_MIN" :constant) 88 | (lispify-wo-prefix "CL_UCHAR_MAX" :constant) 89 | (lispify-wo-prefix "CL_SHRT_MAX" :constant) 90 | (lispify-wo-prefix "CL_SHRT_MIN" :constant) 91 | (lispify-wo-prefix "CL_USHRT_MAX" :constant) 92 | (lispify-wo-prefix "CL_INT_MAX" :constant) 93 | (lispify-wo-prefix "CL_INT_MIN" :constant) 94 | (lispify-wo-prefix "CL_UINT_MAX" :constant) 95 | (lispify-wo-prefix "CL_LONG_MAX" :constant) 96 | (lispify-wo-prefix "CL_LONG_MIN" :constant) 97 | (lispify-wo-prefix "CL_ULONG_MAX" :constant) 98 | (lispify-wo-prefix "CL_FLT_DIG" :constant) 99 | (lispify-wo-prefix "CL_FLT_MANT_DIG" :constant) 100 | (lispify-wo-prefix "CL_FLT_MAX_10_EXP" :constant) 101 | (lispify-wo-prefix "CL_FLT_MAX_EXP" :constant) 102 | (lispify-wo-prefix "CL_FLT_MIN_10_EXP" :constant) 103 | (lispify-wo-prefix "CL_FLT_MIN_EXP" :constant) 104 | (lispify-wo-prefix "CL_FLT_RADIX" :constant) 105 | (lispify-wo-prefix "CL_FLT_MAX" :constant) 106 | (lispify-wo-prefix "CL_FLT_MIN" :constant) 107 | (lispify-wo-prefix "CL_FLT_EPSILON" :constant) 108 | (lispify-wo-prefix "CL_DBL_DIG" :constant) 109 | (lispify-wo-prefix "CL_DBL_MANT_DIG" :constant) 110 | (lispify-wo-prefix "CL_DBL_MAX_10_EXP" :constant) 111 | (lispify-wo-prefix "CL_DBL_MAX_EXP" :constant) 112 | (lispify-wo-prefix "CL_DBL_MIN_10_EXP" :constant) 113 | (lispify-wo-prefix "CL_DBL_MIN_EXP" :constant) 114 | (lispify-wo-prefix "CL_DBL_RADIX" :constant) 115 | (lispify-wo-prefix "CL_DBL_MAX" :constant) 116 | (lispify-wo-prefix "CL_DBL_MIN" :constant) 117 | (lispify-wo-prefix "CL_DBL_EPSILON" :constant) 118 | (lispify-wo-prefix "CL_NAN" :constant) 119 | (lispify-wo-prefix "CL_HUGE_VALF" :constant) 120 | (lispify-wo-prefix "CL_HUGE_VAL" :constant) 121 | (lispify-wo-prefix "CL_MAXFLOAT" :constant) 122 | (lispify-wo-prefix "CL_INFINITY" :constant)) 123 | ;; grovel-cl 124 | #.(list 125 | :export 126 | (lispify "intptr_t") 127 | (lispify "uintptr_t") 128 | (lispify "size_t") 129 | (lispify "ptrdiff_t") 130 | 131 | (lispify "platform_id") 132 | (lispify "__device_id") 133 | (lispify "__context") 134 | (lispify "__command_queue") 135 | (lispify "__mem") 136 | (lispify "__program") 137 | (lispify "__kernel") 138 | (lispify "__event") 139 | (lispify "__sampler") 140 | (lispify "__bool") 141 | (lispify "bitfield") 142 | (lispify "device_type") 143 | (lispify "platform_info") 144 | (lispify "device_info") 145 | (lispify "device_fp_config") 146 | (lispify "device_mem_cache_type") 147 | (lispify "device_local_mem_type") 148 | (lispify "device_exec_capabilities") 149 | #+opencl-2.0 150 | (lispify "device_svm_capabilities") 151 | (lispify "command_queue_properties") 152 | (lispify "device_partition_property") 153 | (lispify "device_affinity_domain") 154 | (lispify "context_properties") 155 | (lispify "context_info") 156 | #+opencl-2.0 157 | (lispify "queue_properties") 158 | (lispify "command_queue_info") 159 | (lispify "channel_order") 160 | (lispify "channel_type") 161 | (lispify "mem_flags") 162 | #+opencl-2.0 163 | (lispify "svm_mem_flags") 164 | (lispify "mem_object_type") 165 | (lispify "mem_info") 166 | (lispify "mem_migration_flags") 167 | (lispify "image_info") 168 | (lispify "buffer_create_type") 169 | (lispify "addressing_mode") 170 | (lispify "filter_mode") 171 | (lispify "sampler_info") 172 | (lispify "map_flags") 173 | #+opencl-2.0 174 | (lispify "pipe_properties") 175 | #+opencl-2.0 176 | (lispify "pipe_info") 177 | (lispify "program_info") 178 | (lispify "program_build_info") 179 | (lispify "program_binary_type") 180 | (lispify "build_status") 181 | (lispify "kernel_info") 182 | (lispify "kernel_arg_info") 183 | (lispify "kernel_arg_address_qualifier") 184 | (lispify "kernel_arg_access_qualifier") 185 | (lispify "kernel_arg_type_qualifier") 186 | (lispify "kernel_work_group_info") 187 | #+opencl-2.1 188 | (lispify "kernel_sub_group_info") 189 | (lispify "event_info") 190 | (lispify "command_type") 191 | (lispify "profiling_info") 192 | #+opencl-2.0 193 | (lispify "sampler_properties") 194 | #+opencl-2.0 195 | (lispify "kernel_exec_info")) 196 | #.(list 197 | :export 198 | :--error-code 199 | (lispify-wo-prefix "CL_SUCCESS") 200 | (lispify-wo-prefix "CL_DEVICE_NOT_FOUND") 201 | (lispify-wo-prefix "CL_DEVICE_NOT_AVAILABLE") 202 | (lispify-wo-prefix "CL_COMPILER_NOT_AVAILABLE") 203 | (lispify-wo-prefix "CL_MEM_OBJECT_ALLOCATION_FAILURE") 204 | (lispify-wo-prefix "CL_OUT_OF_RESOURCES") 205 | (lispify-wo-prefix "CL_OUT_OF_HOST_MEMORY") 206 | (lispify-wo-prefix "CL_PROFILING_INFO_NOT_AVAILABLE") 207 | (lispify-wo-prefix "CL_MEM_COPY_OVERLAP") 208 | (lispify-wo-prefix "CL_IMAGE_FORMAT_MISMATCH") 209 | (lispify-wo-prefix "CL_IMAGE_FORMAT_NOT_SUPPORTED") 210 | (lispify-wo-prefix "CL_BUILD_PROGRAM_FAILURE") 211 | (lispify-wo-prefix "CL_MAP_FAILURE") 212 | (lispify-wo-prefix "CL_MISALIGNED_SUB_BUFFER_OFFSET") 213 | (lispify-wo-prefix "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST") 214 | (lispify-wo-prefix "CL_COMPILE_PROGRAM_FAILURE") 215 | (lispify-wo-prefix "CL_LINKER_NOT_AVAILABLE") 216 | (lispify-wo-prefix "CL_LINK_PROGRAM_FAILURE") 217 | (lispify-wo-prefix "CL_DEVICE_PARTITION_FAILED") 218 | (lispify-wo-prefix "CL_KERNEL_ARG_INFO_NOT_AVAILABLE") 219 | (lispify-wo-prefix "CL_INVALID_VALUE") 220 | (lispify-wo-prefix "CL_INVALID_DEVICE_TYPE") 221 | (lispify-wo-prefix "CL_INVALID_PLATFORM") 222 | (lispify-wo-prefix "CL_INVALID_DEVICE") 223 | (lispify-wo-prefix "CL_INVALID_CONTEXT") 224 | (lispify-wo-prefix "CL_INVALID_QUEUE_PROPERTIES") 225 | (lispify-wo-prefix "CL_INVALID_COMMAND_QUEUE") 226 | (lispify-wo-prefix "CL_INVALID_HOST_PTR") 227 | (lispify-wo-prefix "CL_INVALID_MEM_OBJECT") 228 | (lispify-wo-prefix "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR") 229 | (lispify-wo-prefix "CL_INVALID_IMAGE_SIZE") 230 | (lispify-wo-prefix "CL_INVALID_SAMPLER") 231 | (lispify-wo-prefix "CL_INVALID_BINARY") 232 | (lispify-wo-prefix "CL_INVALID_BUILD_OPTIONS") 233 | (lispify-wo-prefix "CL_INVALID_PROGRAM") 234 | (lispify-wo-prefix "CL_INVALID_PROGRAM_EXECUTABLE") 235 | (lispify-wo-prefix "CL_INVALID_KERNEL_NAME") 236 | (lispify-wo-prefix "CL_INVALID_KERNEL_DEFINITION") 237 | (lispify-wo-prefix "CL_INVALID_KERNEL") 238 | (lispify-wo-prefix "CL_INVALID_ARG_INDEX") 239 | (lispify-wo-prefix "CL_INVALID_ARG_VALUE") 240 | (lispify-wo-prefix "CL_INVALID_ARG_SIZE") 241 | (lispify-wo-prefix "CL_INVALID_KERNEL_ARGS") 242 | (lispify-wo-prefix "CL_INVALID_WORK_DIMENSION") 243 | (lispify-wo-prefix "CL_INVALID_WORK_GROUP_SIZE") 244 | (lispify-wo-prefix "CL_INVALID_WORK_ITEM_SIZE") 245 | (lispify-wo-prefix "CL_INVALID_GLOBAL_OFFSET") 246 | (lispify-wo-prefix "CL_INVALID_EVENT_WAIT_LIST") 247 | (lispify-wo-prefix "CL_INVALID_EVENT") 248 | (lispify-wo-prefix "CL_INVALID_OPERATION") 249 | (lispify-wo-prefix "CL_INVALID_GL_OBJECT") 250 | (lispify-wo-prefix "CL_INVALID_BUFFER_SIZE") 251 | (lispify-wo-prefix "CL_INVALID_MIP_LEVEL") 252 | (lispify-wo-prefix "CL_INVALID_GLOBAL_WORK_SIZE") 253 | (lispify-wo-prefix "CL_INVALID_PROPERTY") 254 | (lispify-wo-prefix "CL_INVALID_IMAGE_DESCRIPTOR") 255 | (lispify-wo-prefix "CL_INVALID_COMPILER_OPTIONS") 256 | (lispify-wo-prefix "CL_INVALID_LINKER_OPTIONS") 257 | (lispify-wo-prefix "CL_INVALID_DEVICE_PARTITION_COUNT") 258 | (lispify-wo-prefix "CL_INVALID_PIPE_SIZE") 259 | (lispify-wo-prefix "CL_INVALID_DEVICE_QUEUE") 260 | 261 | (lispify-wo-prefix "CL_FALSE") 262 | (lispify-wo-prefix "CL_TRUE") 263 | (lispify-wo-prefix "CL_BLOCKING") 264 | (lispify-wo-prefix "CL_NON_BLOCKING") 265 | 266 | (lispify "platform_info") 267 | (lispify-wo-prefix "CL_PLATFORM_PROFILE") 268 | (lispify-wo-prefix "CL_PLATFORM_VERSION") 269 | (lispify-wo-prefix "CL_PLATFORM_NAME") 270 | (lispify-wo-prefix "CL_PLATFORM_VENDOR") 271 | (lispify-wo-prefix "CL_PLATFORM_EXTENSIONS") 272 | 273 | (lispify "device_type") 274 | (lispify-wo-prefix "CL_DEVICE_TYPE_DEFAULT") 275 | (lispify-wo-prefix "CL_DEVICE_TYPE_CPU") 276 | (lispify-wo-prefix "CL_DEVICE_TYPE_GPU") 277 | (lispify-wo-prefix "CL_DEVICE_TYPE_ACCELERATOR") 278 | (lispify-wo-prefix "CL_DEVICE_TYPE_CUSTOM") 279 | (lispify-wo-prefix "CL_DEVICE_TYPE_ALL") 280 | 281 | (lispify "device_info") 282 | (lispify-wo-prefix "CL_DEVICE_TYPE") 283 | (lispify-wo-prefix "CL_DEVICE_VENDOR_ID") 284 | (lispify-wo-prefix "CL_DEVICE_MAX_COMPUTE_UNITS") 285 | (lispify-wo-prefix "CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS") 286 | (lispify-wo-prefix "CL_DEVICE_MAX_WORK_GROUP_SIZE") 287 | (lispify-wo-prefix "CL_DEVICE_MAX_WORK_ITEM_SIZES") 288 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR") 289 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT") 290 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT") 291 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG") 292 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT") 293 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE") 294 | (lispify-wo-prefix "CL_DEVICE_MAX_CLOCK_FREQUENCY") 295 | (lispify-wo-prefix "CL_DEVICE_ADDRESS_BITS") 296 | (lispify-wo-prefix "CL_DEVICE_MAX_READ_IMAGE_ARGS") 297 | (lispify-wo-prefix "CL_DEVICE_MAX_WRITE_IMAGE_ARGS") 298 | (lispify-wo-prefix "CL_DEVICE_MAX_MEM_ALLOC_SIZE") 299 | (lispify-wo-prefix "CL_DEVICE_IMAGE2D_MAX_WIDTH") 300 | (lispify-wo-prefix "CL_DEVICE_IMAGE2D_MAX_HEIGHT") 301 | (lispify-wo-prefix "CL_DEVICE_IMAGE3D_MAX_WIDTH") 302 | (lispify-wo-prefix "CL_DEVICE_IMAGE3D_MAX_HEIGHT") 303 | (lispify-wo-prefix "CL_DEVICE_IMAGE3D_MAX_DEPTH") 304 | (lispify-wo-prefix "CL_DEVICE_IMAGE_SUPPORT") 305 | (lispify-wo-prefix "CL_DEVICE_MAX_PARAMETER_SIZE") 306 | (lispify-wo-prefix "CL_DEVICE_MAX_SAMPLERS") 307 | (lispify-wo-prefix "CL_DEVICE_MEM_BASE_ADDR_ALIGN") 308 | ;; #-opencl-1.2 309 | (lispify-wo-prefix "CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE") 310 | (lispify-wo-prefix "CL_DEVICE_SINGLE_FP_CONFIG") 311 | (lispify-wo-prefix "CL_DEVICE_GLOBAL_MEM_CACHE_TYPE") 312 | (lispify-wo-prefix "CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE") 313 | (lispify-wo-prefix "CL_DEVICE_GLOBAL_MEM_CACHE_SIZE") 314 | (lispify-wo-prefix "CL_DEVICE_GLOBAL_MEM_SIZE") 315 | (lispify-wo-prefix "CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE") 316 | (lispify-wo-prefix "CL_DEVICE_MAX_CONSTANT_ARGS") 317 | (lispify-wo-prefix "CL_DEVICE_LOCAL_MEM_TYPE") 318 | (lispify-wo-prefix "CL_DEVICE_LOCAL_MEM_SIZE") 319 | (lispify-wo-prefix "CL_DEVICE_ERROR_CORRECTION_SUPPORT") 320 | (lispify-wo-prefix "CL_DEVICE_PROFILING_TIMER_RESOLUTION") 321 | (lispify-wo-prefix "CL_DEVICE_ENDIAN_LITTLE") 322 | (lispify-wo-prefix "CL_DEVICE_AVAILABLE") 323 | (lispify-wo-prefix "CL_DEVICE_COMPILER_AVAILABLE") 324 | (lispify-wo-prefix "CL_DEVICE_EXECUTION_CAPABILITIES") 325 | ;; #-opencl-2.0 326 | (lispify-wo-prefix "CL_DEVICE_QUEUE_PROPERTIES") 327 | ;; in opencl-2.0, CL_DEVICE_QUEUE_PROPERTIES is replaced by CL_DEVICE_QUEUE_ON_HOST_PROPERTIES 328 | #+opencl-2.0 329 | (lispify-wo-prefix "CL_DEVICE_QUEUE_ON_HOST_PROPERTIES") 330 | (lispify-wo-prefix "CL_DEVICE_NAME") 331 | (lispify-wo-prefix "CL_DEVICE_VENDOR") 332 | (lispify-wo-prefix "CL_DRIVER_VERSION") 333 | (lispify-wo-prefix "CL_DEVICE_PROFILE") 334 | (lispify-wo-prefix "CL_DEVICE_VERSION") 335 | (lispify-wo-prefix "CL_DEVICE_EXTENSIONS") 336 | (lispify-wo-prefix "CL_DEVICE_PLATFORM") 337 | (lispify-wo-prefix "CL_DEVICE_DOUBLE_FP_CONFIG") 338 | ;; 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG 339 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF") 340 | ;; #+(and opencl-1.1 (not opencl-2.0)) 341 | #+opencl-1.1 342 | (lispify-wo-prefix "CL_DEVICE_HOST_UNIFIED_MEMORY") 343 | #+opencl-1.1 344 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR") 345 | #+opencl-1.1 346 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT") 347 | #+opencl-1.1 348 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_INT") 349 | #+opencl-1.1 350 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG") 351 | #+opencl-1.1 352 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT") 353 | #+opencl-1.1 354 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE") 355 | #+opencl-1.1 356 | (lispify-wo-prefix "CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF") 357 | #+opencl-1.1 358 | (lispify-wo-prefix "CL_DEVICE_OPENCL_C_VERSION") 359 | (lispify-wo-prefix "CL_DEVICE_LINKER_AVAILABLE") 360 | (lispify-wo-prefix "CL_DEVICE_BUILT_IN_KERNELS") 361 | (lispify-wo-prefix "CL_DEVICE_IMAGE_MAX_BUFFER_SIZE") 362 | (lispify-wo-prefix "CL_DEVICE_IMAGE_MAX_ARRAY_SIZE") 363 | (lispify-wo-prefix "CL_DEVICE_PARENT_DEVICE") 364 | (lispify-wo-prefix "CL_DEVICE_PARTITION_MAX_SUB_DEVICES") 365 | (lispify-wo-prefix "CL_DEVICE_PARTITION_PROPERTIES") 366 | (lispify-wo-prefix "CL_DEVICE_PARTITION_AFFINITY_DOMAIN") 367 | (lispify-wo-prefix "CL_DEVICE_PARTITION_TYPE") 368 | (lispify-wo-prefix "CL_DEVICE_REFERENCE_COUNT") 369 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_INTEROP_USER_SYNC") 370 | (lispify-wo-prefix "CL_DEVICE_PRINTF_BUFFER_SIZE") 371 | (lispify-wo-prefix "CL_DEVICE_IMAGE_PITCH_ALIGNMENT") 372 | (lispify-wo-prefix "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT") 373 | (lispify-wo-prefix "CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS") 374 | (lispify-wo-prefix "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE") 375 | (lispify-wo-prefix "CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES") 376 | (lispify-wo-prefix "CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE") 377 | (lispify-wo-prefix "CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE") 378 | (lispify-wo-prefix "CL_DEVICE_MAX_ON_DEVICE_QUEUES") 379 | (lispify-wo-prefix "CL_DEVICE_MAX_ON_DEVICE_EVENTS") 380 | (lispify-wo-prefix "CL_DEVICE_SVM_CAPABILITIES") 381 | (lispify-wo-prefix "CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE") 382 | (lispify-wo-prefix "CL_DEVICE_MAX_PIPE_ARGS") 383 | (lispify-wo-prefix "CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS") 384 | (lispify-wo-prefix "CL_DEVICE_PIPE_MAX_PACKET_SIZE") 385 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT") 386 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT") 387 | (lispify-wo-prefix "CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT") 388 | 389 | (lispify "device_fp_config") 390 | (lispify-wo-prefix "CL_FP_DENORM") 391 | (lispify-wo-prefix "CL_FP_INF_NAN") 392 | (lispify-wo-prefix "CL_FP_ROUND_TO_NEAREST") 393 | (lispify-wo-prefix "CL_FP_ROUND_TO_ZERO") 394 | (lispify-wo-prefix "CL_FP_ROUND_TO_INF") 395 | (lispify-wo-prefix "CL_FP_FMA") 396 | (lispify-wo-prefix "CL_FP_SOFT_FLOAT") 397 | (lispify-wo-prefix "CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT") 398 | 399 | (lispify "device_mem_cache_type") 400 | (lispify-wo-prefix "CL_NONE") 401 | (lispify-wo-prefix "CL_READ_ONLY_CACHE") 402 | (lispify-wo-prefix "CL_READ_WRITE_CACHE") 403 | 404 | (lispify "device_local_mem_type") 405 | (lispify-wo-prefix "CL_LOCAL") 406 | (lispify-wo-prefix "CL_GLOBAL") 407 | 408 | (lispify "device_exec_capabilities") 409 | (lispify-wo-prefix "CL_EXEC_KERNEL") 410 | (lispify-wo-prefix "CL_EXEC_NATIVE_KERNEL") 411 | 412 | (lispify "command_queue_properties") 413 | (lispify-wo-prefix "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE") 414 | (lispify-wo-prefix "CL_QUEUE_PROFILING_ENABLE") 415 | (lispify-wo-prefix "CL_QUEUE_ON_DEVICE") 416 | (lispify-wo-prefix "CL_QUEUE_ON_DEVICE_DEFAULT") 417 | 418 | (lispify "context_info") 419 | (lispify-wo-prefix "CL_CONTEXT_REFERENCE_COUNT") 420 | (lispify-wo-prefix "CL_CONTEXT_DEVICES") 421 | (lispify-wo-prefix "CL_CONTEXT_PROPERTIES") 422 | #+opencl-1.1 423 | (lispify-wo-prefix "CL_CONTEXT_NUM_DEVICES") 424 | 425 | (lispify "context_properties") 426 | (lispify-wo-prefix "CL_CONTEXT_PLATFORM") 427 | (lispify-wo-prefix "CL_CONTEXT_INTEROP_USER_SYNC") 428 | 429 | (lispify "device_partition_property") 430 | (lispify-wo-prefix "CL_DEVICE_PARTITION_EQUALLY") 431 | (lispify-wo-prefix "CL_DEVICE_PARTITION_BY_COUNTS") 432 | (lispify-wo-prefix "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END") 433 | (lispify-wo-prefix "CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN") 434 | 435 | (lispify "device_affinity_domain") 436 | (lispify-wo-prefix "CL_DEVICE_AFFINITY_DOMAIN_NUMA") 437 | (lispify-wo-prefix "CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE") 438 | (lispify-wo-prefix "CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE") 439 | (lispify-wo-prefix "CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE") 440 | (lispify-wo-prefix "CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE") 441 | (lispify-wo-prefix "CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE") 442 | 443 | (lispify "device_svm_capabilities") 444 | (lispify-wo-prefix "CL_DEVICE_SVM_COARSE_GRAIN_BUFFER") 445 | (lispify-wo-prefix "CL_DEVICE_SVM_FINE_GRAIN_BUFFER") 446 | (lispify-wo-prefix "CL_DEVICE_SVM_FINE_GRAIN_SYSTEM") 447 | (lispify-wo-prefix "CL_DEVICE_SVM_ATOMICS") 448 | 449 | (lispify "command_queue_info") 450 | (lispify-wo-prefix "CL_QUEUE_CONTEXT") 451 | (lispify-wo-prefix "CL_QUEUE_DEVICE") 452 | (lispify-wo-prefix "CL_QUEUE_REFERENCE_COUNT") 453 | (lispify-wo-prefix "CL_QUEUE_PROPERTIES") 454 | (lispify-wo-prefix "CL_QUEUE_SIZE") 455 | 456 | (lispify "mem_flags") 457 | (lispify-wo-prefix "CL_MEM_READ_WRITE") 458 | (lispify-wo-prefix "CL_MEM_WRITE_ONLY") 459 | (lispify-wo-prefix "CL_MEM_READ_ONLY") 460 | (lispify-wo-prefix "CL_MEM_USE_HOST_PTR") 461 | (lispify-wo-prefix "CL_MEM_ALLOC_HOST_PTR") 462 | (lispify-wo-prefix "CL_MEM_COPY_HOST_PTR") 463 | ;; reserved (1 << 6) 464 | (lispify-wo-prefix "CL_MEM_HOST_WRITE_ONLY") 465 | (lispify-wo-prefix "CL_MEM_HOST_READ_ONLY") 466 | (lispify-wo-prefix "CL_MEM_HOST_NO_ACCESS") 467 | (lispify-wo-prefix "CL_MEM_SVM_FINE_GRAIN_BUFFER") 468 | (lispify-wo-prefix "CL_MEM_SVM_ATOMICS") 469 | (lispify-wo-prefix "CL_MEM_KERNEL_READ_AND_WRITE") 470 | 471 | ;; FIXME : duplicated --- cl_mem_flags 472 | (lispify "svm_mem_flags") 473 | (lispify-wo-prefix "CL_MEM_READ_WRITE") 474 | (lispify-wo-prefix "CL_MEM_WRITE_ONLY") 475 | (lispify-wo-prefix "CL_MEM_READ_ONLY") 476 | (lispify-wo-prefix "CL_MEM_USE_HOST_PTR") 477 | (lispify-wo-prefix "CL_MEM_ALLOC_HOST_PTR") 478 | (lispify-wo-prefix "CL_MEM_COPY_HOST_PTR") 479 | ;; reserved (1 << 6) 480 | (lispify-wo-prefix "CL_MEM_HOST_WRITE_ONLY") 481 | (lispify-wo-prefix "CL_MEM_HOST_READ_ONLY") 482 | (lispify-wo-prefix "CL_MEM_HOST_NO_ACCESS") 483 | (lispify-wo-prefix "CL_MEM_SVM_FINE_GRAIN_BUFFER") 484 | (lispify-wo-prefix "CL_MEM_SVM_ATOMICS") 485 | (lispify-wo-prefix "CL_MEM_KERNEL_READ_AND_WRITE") 486 | 487 | (lispify "mem_migration_flags") 488 | (lispify-wo-prefix "CL_MIGRATE_MEM_OBJECT_HOST") 489 | (lispify-wo-prefix "CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED") 490 | 491 | (lispify "channel_order") 492 | (lispify-wo-prefix "CL_R") 493 | (lispify-wo-prefix "CL_A") 494 | (lispify-wo-prefix "CL_RG") 495 | (lispify-wo-prefix "CL_RA") 496 | (lispify-wo-prefix "CL_RGB") 497 | (lispify-wo-prefix "CL_RGBA") 498 | (lispify-wo-prefix "CL_BGRA") 499 | (lispify-wo-prefix "CL_ARGB") 500 | (lispify-wo-prefix "CL_INTENSITY") 501 | (lispify-wo-prefix "CL_LUMINANCE") 502 | #+opencl-1.1 503 | (lispify-wo-prefix "CL_Rx") 504 | #+opencl-1.1 505 | (lispify-wo-prefix "CL_RGx") 506 | #+opencl-1.1 507 | (lispify-wo-prefix "CL_RGBx") 508 | (lispify-wo-prefix "CL_DEPTH") 509 | (lispify-wo-prefix "CL_DEPTH_STENCIL") 510 | (lispify-wo-prefix "CL_sRGB") 511 | (lispify-wo-prefix "CL_sRGBx") 512 | (lispify-wo-prefix "CL_sRGBA") 513 | (lispify-wo-prefix "CL_sBGRA") 514 | (lispify-wo-prefix "CL_ABGR") 515 | 516 | (lispify "channel_type") 517 | (lispify-wo-prefix "CL_SNORM_INT8") 518 | (lispify-wo-prefix "CL_SNORM_INT16") 519 | (lispify-wo-prefix "CL_UNORM_INT8") 520 | (lispify-wo-prefix "CL_UNORM_INT16") 521 | (lispify-wo-prefix "CL_UNORM_SHORT_565") 522 | (lispify-wo-prefix "CL_UNORM_SHORT_555") 523 | (lispify-wo-prefix "CL_UNORM_INT_101010") 524 | (lispify-wo-prefix "CL_SIGNED_INT8") 525 | (lispify-wo-prefix "CL_SIGNED_INT16") 526 | (lispify-wo-prefix "CL_SIGNED_INT32") 527 | (lispify-wo-prefix "CL_UNSIGNED_INT8") 528 | (lispify-wo-prefix "CL_UNSIGNED_INT16") 529 | (lispify-wo-prefix "CL_UNSIGNED_INT32") 530 | (lispify-wo-prefix "CL_HALF_FLOAT") 531 | ;; (lispify-wo-prefix "CL_FLOAT") 532 | (lispify-wo-prefix "CL_UNORM_INT24") 533 | 534 | (lispify "mem_object_type") 535 | (lispify-wo-prefix "CL_MEM_OBJECT_BUFFER") 536 | (lispify-wo-prefix "CL_MEM_OBJECT_IMAGE2D") 537 | (lispify-wo-prefix "CL_MEM_OBJECT_IMAGE3D") 538 | (lispify-wo-prefix "CL_MEM_OBJECT_IMAGE2D_ARRAY") 539 | (lispify-wo-prefix "CL_MEM_OBJECT_IMAGE1D") 540 | (lispify-wo-prefix "CL_MEM_OBJECT_IMAGE1D_ARRAY") 541 | (lispify-wo-prefix "CL_MEM_OBJECT_IMAGE1D_BUFFER") 542 | (lispify-wo-prefix "CL_MEM_OBJECT_PIPE") 543 | 544 | (lispify "mem_info") 545 | (lispify-wo-prefix "CL_MEM_TYPE") 546 | (lispify-wo-prefix "CL_MEM_FLAGS") 547 | (lispify-wo-prefix "CL_MEM_SIZE") 548 | (lispify-wo-prefix "CL_MEM_HOST_PTR") 549 | (lispify-wo-prefix "CL_MEM_MAP_COUNT") 550 | (lispify-wo-prefix "CL_MEM_REFERENCE_COUNT") 551 | (lispify-wo-prefix "CL_MEM_CONTEXT") 552 | (lispify-wo-prefix "CL_MEM_ASSOCIATED_MEMOBJECT") 553 | (lispify-wo-prefix "CL_MEM_OFFSET") 554 | (lispify-wo-prefix "CL_MEM_USES_SVM_POINTER") 555 | 556 | (lispify "image_info") 557 | (lispify-wo-prefix "CL_IMAGE_FORMAT") 558 | (lispify-wo-prefix "CL_IMAGE_ELEMENT_SIZE") 559 | (lispify-wo-prefix "CL_IMAGE_ROW_PITCH") 560 | (lispify-wo-prefix "CL_IMAGE_SLICE_PITCH") 561 | (lispify-wo-prefix "CL_IMAGE_WIDTH") 562 | (lispify-wo-prefix "CL_IMAGE_HEIGHT") 563 | (lispify-wo-prefix "CL_IMAGE_DEPTH") 564 | (lispify-wo-prefix "CL_IMAGE_ARRAY_SIZE") 565 | ;; #-opencl-2.0 566 | (lispify-wo-prefix "CL_IMAGE_BUFFER") 567 | (lispify-wo-prefix "CL_IMAGE_NUM_MIP_LEVELS") 568 | (lispify-wo-prefix "CL_IMAGE_NUM_SAMPLES") 569 | 570 | (lispify "pipe_info") 571 | (lispify-wo-prefix "CL_PIPE_PACKET_SIZE") 572 | (lispify-wo-prefix "CL_PIPE_MAX_PACKETS") 573 | 574 | (lispify "addressing_mode") 575 | (lispify-wo-prefix "CL_ADDRESS_NONE") 576 | (lispify-wo-prefix "CL_ADDRESS_CLAMP_TO_EDGE") 577 | (lispify-wo-prefix "CL_ADDRESS_CLAMP") 578 | (lispify-wo-prefix "CL_ADDRESS_REPEAT") 579 | (lispify-wo-prefix "CL_ADDRESS_MIRRORED_REPEAT") 580 | 581 | (lispify "filter_mode") 582 | (lispify-wo-prefix "CL_FILTER_NEAREST") 583 | (lispify-wo-prefix "CL_FILTER_LINEAR") 584 | 585 | (lispify "sampler_info") 586 | (lispify-wo-prefix "CL_SAMPLER_REFERENCE_COUNT") 587 | (lispify-wo-prefix "CL_SAMPLER_CONTEXT") 588 | (lispify-wo-prefix "CL_SAMPLER_NORMALIZED_COORDS") 589 | (lispify-wo-prefix "CL_SAMPLER_ADDRESSING_MODE") 590 | (lispify-wo-prefix "CL_SAMPLER_FILTER_MODE") 591 | (lispify-wo-prefix "CL_SAMPLER_MIP_FILTER_MODE") 592 | (lispify-wo-prefix "CL_SAMPLER_LOD_MIN") 593 | (lispify-wo-prefix "CL_SAMPLER_LOD_MAX") 594 | 595 | (lispify "map_flags") 596 | (lispify-wo-prefix "CL_MAP_READ") 597 | (lispify-wo-prefix "CL_MAP_WRITE") 598 | ;; #+opencl-1.2 599 | (lispify-wo-prefix "CL_MAP_WRITE_INVALIDATE_REGION") 600 | 601 | (lispify "program_info") 602 | (lispify-wo-prefix "CL_PROGRAM_REFERENCE_COUNT") 603 | (lispify-wo-prefix "CL_PROGRAM_CONTEXT") 604 | (lispify-wo-prefix "CL_PROGRAM_NUM_DEVICES") 605 | (lispify-wo-prefix "CL_PROGRAM_DEVICES") 606 | (lispify-wo-prefix "CL_PROGRAM_SOURCE") 607 | (lispify-wo-prefix "CL_PROGRAM_BINARY_SIZES") 608 | (lispify-wo-prefix "CL_PROGRAM_BINARIES") 609 | (lispify-wo-prefix "CL_PROGRAM_NUM_KERNELS") 610 | (lispify-wo-prefix "CL_PROGRAM_KERNEL_NAMES") 611 | 612 | (lispify "program_build_info") 613 | (lispify-wo-prefix "CL_PROGRAM_BUILD_STATUS") 614 | (lispify-wo-prefix "CL_PROGRAM_BUILD_OPTIONS") 615 | (lispify-wo-prefix "CL_PROGRAM_BUILD_LOG") 616 | (lispify-wo-prefix "CL_PROGRAM_BINARY_TYPE") 617 | (lispify-wo-prefix "CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE") 618 | 619 | (lispify "program_binary_type") 620 | (lispify-wo-prefix "CL_PROGRAM_BINARY_TYPE_NONE") 621 | (lispify-wo-prefix "CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT") 622 | (lispify-wo-prefix "CL_PROGRAM_BINARY_TYPE_LIBRARY") 623 | (lispify-wo-prefix "CL_PROGRAM_BINARY_TYPE_EXECUTABLE") 624 | 625 | (lispify "build_status") 626 | (lispify-wo-prefix "CL_BUILD_SUCCESS") 627 | (lispify-wo-prefix "CL_BUILD_NONE") 628 | (lispify-wo-prefix "CL_BUILD_ERROR") 629 | (lispify-wo-prefix "CL_BUILD_IN_PROGRESS") 630 | 631 | (lispify "kernel_info") 632 | (lispify-wo-prefix "CL_KERNEL_FUNCTION_NAME") 633 | (lispify-wo-prefix "CL_KERNEL_NUM_ARGS") 634 | (lispify-wo-prefix "CL_KERNEL_REFERENCE_COUNT") 635 | (lispify-wo-prefix "CL_KERNEL_CONTEXT") 636 | (lispify-wo-prefix "CL_KERNEL_PROGRAM") 637 | (lispify-wo-prefix "CL_KERNEL_ATTRIBUTES") 638 | 639 | (lispify "kernel_arg_info") 640 | (lispify-wo-prefix "CL_KERNEL_ARG_ADDRESS_QUALIFIER") 641 | (lispify-wo-prefix "CL_KERNEL_ARG_ACCESS_QUALIFIER") 642 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_NAME") 643 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_QUALIFIER") 644 | (lispify-wo-prefix "CL_KERNEL_ARG_NAME") 645 | 646 | (lispify "kernel_arg_address_qualifier") 647 | (lispify-wo-prefix "CL_KERNEL_ARG_ADDRESS_GLOBAL") 648 | (lispify-wo-prefix "CL_KERNEL_ARG_ADDRESS_LOCAL") 649 | (lispify-wo-prefix "CL_KERNEL_ARG_ADDRESS_CONSTANT") 650 | (lispify-wo-prefix "CL_KERNEL_ARG_ADDRESS_PRIVATE") 651 | 652 | (lispify "kernel_arg_access_qualifier") 653 | (lispify-wo-prefix "CL_KERNEL_ARG_ACCESS_READ_ONLY") 654 | (lispify-wo-prefix "CL_KERNEL_ARG_ACCESS_WRITE_ONLY") 655 | (lispify-wo-prefix "CL_KERNEL_ARG_ACCESS_READ_WRITE") 656 | (lispify-wo-prefix "CL_KERNEL_ARG_ACCESS_NONE") 657 | 658 | (lispify "kernel_arg_type_qualifer") 659 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_NONE") 660 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_CONST") 661 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_RESTRICT") 662 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_VOLATILE") 663 | (lispify-wo-prefix "CL_KERNEL_ARG_TYPE_PIPE") 664 | 665 | (lispify "kernel_work_group_info") 666 | (lispify-wo-prefix "CL_KERNEL_WORK_GROUP_SIZE") 667 | (lispify-wo-prefix "CL_KERNEL_COMPILE_WORK_GROUP_SIZE") 668 | (lispify-wo-prefix "CL_KERNEL_LOCAL_MEM_SIZE") 669 | (lispify-wo-prefix "CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE") 670 | (lispify-wo-prefix "CL_KERNEL_PRIVATE_MEM_SIZE") 671 | (lispify-wo-prefix "CL_KERNEL_GLOBAL_WORK_SIZE") 672 | #+opencl-2.1 673 | (lispify-wo-prefix "CL_KERNEL_MAX_NUM_SUB_GROUPS") 674 | #+opencl-2.1 675 | (lispify-wo-prefix "CL_KERNEL_COMPILE_NUM_SUB_GROUPS") 676 | 677 | #+opencl-2.1 678 | (lispify "kernel_sub_group_info") 679 | (lispify-wo-prefix "CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE") 680 | (lispify-wo-prefix "CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE") 681 | (lispify-wo-prefix "CL_GET_LOCAL_SIZE_FOR_SUB_GROUP_COUNT") 682 | 683 | (lispify "kernel_exec_info") 684 | (lispify-wo-prefix "CL_KERNEL_EXEC_INFO_SVM_PTRS") 685 | (lispify-wo-prefix "CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM") 686 | 687 | (lispify "event_info") 688 | (lispify-wo-prefix "CL_EVENT_COMMAND_QUEUE") 689 | (lispify-wo-prefix "CL_EVENT_COMMAND_TYPE") 690 | (lispify-wo-prefix "CL_EVENT_REFERENCE_COUNT") 691 | (lispify-wo-prefix "CL_EVENT_COMMAND_EXECUTION_STATUS") 692 | (lispify-wo-prefix "CL_EVENT_CONTEXT") 693 | 694 | (lispify "command_type") 695 | (lispify-wo-prefix "CL_COMMAND_NDRANGE_KERNEL") 696 | (lispify-wo-prefix "CL_COMMAND_TASK") 697 | (lispify-wo-prefix "CL_COMMAND_NATIVE_KERNEL") 698 | (lispify-wo-prefix "CL_COMMAND_READ_BUFFER") 699 | (lispify-wo-prefix "CL_COMMAND_WRITE_BUFFER") 700 | (lispify-wo-prefix "CL_COMMAND_COPY_BUFFER") 701 | (lispify-wo-prefix "CL_COMMAND_READ_IMAGE") 702 | (lispify-wo-prefix "CL_COMMAND_WRITE_IMAGE") 703 | (lispify-wo-prefix "CL_COMMAND_COPY_IMAGE") 704 | (lispify-wo-prefix "CL_COMMAND_COPY_IMAGE_TO_BUFFER") 705 | (lispify-wo-prefix "CL_COMMAND_COPY_BUFFER_TO_IMAGE") 706 | (lispify-wo-prefix "CL_COMMAND_MAP_BUFFER") 707 | (lispify-wo-prefix "CL_COMMAND_MAP_IMAGE") 708 | (lispify-wo-prefix "CL_COMMAND_UNMAP_MEM_OBJECT") 709 | (lispify-wo-prefix "CL_COMMAND_MARKER") 710 | (lispify-wo-prefix "CL_COMMAND_ACQUIRE_GL_OBJECTS") 711 | (lispify-wo-prefix "CL_COMMAND_RELEASE_GL_OBJECTS") 712 | (lispify-wo-prefix "CL_COMMAND_READ_BUFFER_RECT") 713 | (lispify-wo-prefix "CL_COMMAND_WRITE_BUFFER_RECT") 714 | (lispify-wo-prefix "CL_COMMAND_COPY_BUFFER_RECT") 715 | (lispify-wo-prefix "CL_COMMAND_USER") 716 | (lispify-wo-prefix "CL_COMMAND_BARRIER") 717 | (lispify-wo-prefix "CL_COMMAND_MIGRATE_MEM_OBJECTS") 718 | (lispify-wo-prefix "CL_COMMAND_FILL_BUFFER") 719 | (lispify-wo-prefix "CL_COMMAND_FILL_IMAGE") 720 | (lispify-wo-prefix "CL_COMMAND_SVM_FREE") 721 | (lispify-wo-prefix "CL_COMMAND_SVM_MEMCPY") 722 | (lispify-wo-prefix "CL_COMMAND_SVM_MEMFILL") 723 | (lispify-wo-prefix "CL_COMMAND_SVM_MAP") 724 | (lispify-wo-prefix "CL_COMMAND_SVM_UNMAP") 725 | 726 | (lispify "command_execution_status") 727 | (lispify-wo-prefix "CL_COMPLETE") 728 | (lispify-wo-prefix "CL_RUNNING") 729 | (lispify-wo-prefix "CL_SUBMITTED") 730 | (lispify-wo-prefix "CL_QUEUED") 731 | 732 | (lispify "buffer_create_type") 733 | (lispify-wo-prefix "CL_BUFFER_CREATE_TYPE_REGION") 734 | 735 | (lispify "profiling_info") 736 | (lispify-wo-prefix "CL_PROFILING_COMMAND_QUEUED") 737 | (lispify-wo-prefix "CL_PROFILING_COMMAND_SUBMIT") 738 | (lispify-wo-prefix "CL_PROFILING_COMMAND_START") 739 | (lispify-wo-prefix "CL_PROFILING_COMMAND_END") 740 | (lispify-wo-prefix "CL_PROFILING_COMMAND_COMPLETE")) 741 | (:export 742 | #:image-format 743 | #:image-desc)) 744 | 745 | -------------------------------------------------------------------------------- /0.bindings-src/2-1-grovel-cl_platform.lisp: -------------------------------------------------------------------------------- 1 | ;; groveller file 2 | 3 | (in-package #:eazy-opencl.grovel) 4 | #+darwin 5 | (include "OpenCL/cl_platform.h") 6 | 7 | #-darwin 8 | (include "CL/cl_platform.h") 9 | 10 | ;;; C.1 Shared Application Scalar Data Types 11 | 12 | (ctype #.(lispify-wo-prefix "cl_char") "cl_char") 13 | (ctype #.(lispify-wo-prefix "cl_uchar") "cl_uchar") 14 | (ctype #.(lispify-wo-prefix "cl_short") "cl_short") 15 | (ctype #.(lispify-wo-prefix "cl_ushort") "cl_ushort") 16 | (ctype #.(lispify-wo-prefix "cl_int") "cl_int") 17 | (ctype #.(lispify-wo-prefix "cl_uint") "cl_uint") 18 | (ctype #.(lispify-wo-prefix "cl_long") "cl_long") 19 | (ctype #.(lispify-wo-prefix "cl_ulong") "cl_ulong") 20 | (ctype #.(lispify-wo-prefix "cl_half") "cl_half") 21 | (ctype #.(lispify-wo-prefix "cl_float") "cl_float") 22 | (ctype #.(lispify-wo-prefix "cl_double") "cl_double") 23 | 24 | ;;; C.2 Supported Application Vector Data Types 25 | 26 | ;; (ctype #.(lispify-wo-prefix "cl_char2") "cl_char2") 27 | ;; (ctype #.(lispify-wo-prefix "cl_uchar2") "cl_uchar2") 28 | ;; (ctype #.(lispify-wo-prefix "cl_short2") "cl_short2") 29 | ;; (ctype #.(lispify-wo-prefix "cl_ushort2") "cl_ushort2") 30 | ;; (ctype #.(lispify-wo-prefix "cl_int2") "cl_int2") 31 | ;; (ctype #.(lispify-wo-prefix "cl_uint2") "cl_uint2") 32 | ;; (ctype #.(lispify-wo-prefix "cl_long2") "cl_long2") 33 | ;; (ctype #.(lispify-wo-prefix "cl_ulong2") "cl_ulong2") 34 | ;; (ctype #.(lispify-wo-prefix "cl_half2") "cl_half2") 35 | ;; (ctype #.(lispify-wo-prefix "cl_float2") "cl_float2") 36 | ;; (ctype #.(lispify-wo-prefix "cl_double2") "cl_double2") 37 | ;; 38 | ;; (ctype #.(lispify-wo-prefix "cl_char3") "cl_char3") 39 | ;; (ctype #.(lispify-wo-prefix "cl_uchar3") "cl_uchar3") 40 | ;; (ctype #.(lispify-wo-prefix "cl_short3") "cl_short3") 41 | ;; (ctype #.(lispify-wo-prefix "cl_ushort3") "cl_ushort3") 42 | ;; (ctype #.(lispify-wo-prefix "cl_int3") "cl_int3") 43 | ;; (ctype #.(lispify-wo-prefix "cl_uint3") "cl_uint3") 44 | ;; (ctype #.(lispify-wo-prefix "cl_long3") "cl_long3") 45 | ;; (ctype #.(lispify-wo-prefix "cl_ulong3") "cl_ulong3") 46 | ;; (ctype #.(lispify-wo-prefix "cl_half3") "cl_half3") 47 | ;; (ctype #.(lispify-wo-prefix "cl_float3") "cl_float3") 48 | ;; (ctype #.(lispify-wo-prefix "cl_double3") "cl_double3") 49 | ;; 50 | ;; (ctype #.(lispify-wo-prefix "cl_char4") "cl_char4") 51 | ;; (ctype #.(lispify-wo-prefix "cl_uchar4") "cl_uchar4") 52 | ;; (ctype #.(lispify-wo-prefix "cl_short4") "cl_short4") 53 | ;; (ctype #.(lispify-wo-prefix "cl_ushort4") "cl_ushort4") 54 | ;; (ctype #.(lispify-wo-prefix "cl_int4") "cl_int4") 55 | ;; (ctype #.(lispify-wo-prefix "cl_uint4") "cl_uint4") 56 | ;; (ctype #.(lispify-wo-prefix "cl_long4") "cl_long4") 57 | ;; (ctype #.(lispify-wo-prefix "cl_ulong4") "cl_ulong4") 58 | ;; (ctype #.(lispify-wo-prefix "cl_half4") "cl_half4") 59 | ;; (ctype #.(lispify-wo-prefix "cl_float4") "cl_float4") 60 | ;; (ctype #.(lispify-wo-prefix "cl_double4") "cl_double4") 61 | ;; 62 | ;; (ctype #.(lispify-wo-prefix "cl_char8") "cl_char8") 63 | ;; (ctype #.(lispify-wo-prefix "cl_uchar8") "cl_uchar8") 64 | ;; (ctype #.(lispify-wo-prefix "cl_short8") "cl_short8") 65 | ;; (ctype #.(lispify-wo-prefix "cl_ushort8") "cl_ushort8") 66 | ;; (ctype #.(lispify-wo-prefix "cl_int8") "cl_int8") 67 | ;; (ctype #.(lispify-wo-prefix "cl_uint8") "cl_uint8") 68 | ;; (ctype #.(lispify-wo-prefix "cl_long8") "cl_long8") 69 | ;; (ctype #.(lispify-wo-prefix "cl_ulong8") "cl_ulong8") 70 | ;; (ctype #.(lispify-wo-prefix "cl_half8") "cl_half8") 71 | ;; (ctype #.(lispify-wo-prefix "cl_float8") "cl_float8") 72 | ;; (ctype #.(lispify-wo-prefix "cl_double8") "cl_double8") 73 | ;; 74 | ;; (ctype #.(lispify-wo-prefix "cl_char16") "cl_char16") 75 | ;; (ctype #.(lispify-wo-prefix "cl_uchar16") "cl_uchar16") 76 | ;; (ctype #.(lispify-wo-prefix "cl_short16") "cl_short16") 77 | ;; (ctype #.(lispify-wo-prefix "cl_ushort16") "cl_ushort16") 78 | ;; (ctype #.(lispify-wo-prefix "cl_int16") "cl_int16") 79 | ;; (ctype #.(lispify-wo-prefix "cl_uint16") "cl_uint16") 80 | ;; (ctype #.(lispify-wo-prefix "cl_long16") "cl_long16") 81 | ;; (ctype #.(lispify-wo-prefix "cl_ulong16") "cl_ulong16") 82 | ;; (ctype #.(lispify-wo-prefix "cl_half16") "cl_half16") 83 | ;; (ctype #.(lispify-wo-prefix "cl_float16") "cl_float16") 84 | ;; (ctype #.(lispify-wo-prefix "cl_double16") "cl_double16") 85 | 86 | ;;; C.9 Application constant definitions 87 | 88 | 89 | (constant (#.(lispify-wo-prefix "CL_CHAR_BIT" :constant) "CL_CHAR_BIT")) 90 | (constant (#.(lispify-wo-prefix "CL_SCHAR_MAX" :constant) "CL_SCHAR_MAX")) 91 | (constant (#.(lispify-wo-prefix "CL_SCHAR_MIN" :constant) "CL_SCHAR_MIN")) 92 | (constant (#.(lispify-wo-prefix "CL_CHAR_MAX" :constant) "CL_CHAR_MAX")) 93 | (constant (#.(lispify-wo-prefix "CL_CHAR_MIN" :constant) "CL_CHAR_MIN")) 94 | (constant (#.(lispify-wo-prefix "CL_UCHAR_MAX" :constant) "CL_UCHAR_MAX")) 95 | (constant (#.(lispify-wo-prefix "CL_SHRT_MAX" :constant) "CL_SHRT_MAX")) 96 | (constant (#.(lispify-wo-prefix "CL_SHRT_MIN" :constant) "CL_SHRT_MIN")) 97 | (constant (#.(lispify-wo-prefix "CL_USHRT_MAX" :constant) "CL_USHRT_MAX")) 98 | (constant (#.(lispify-wo-prefix "CL_INT_MAX" :constant) "CL_INT_MAX")) 99 | (constant (#.(lispify-wo-prefix "CL_INT_MIN" :constant) "CL_INT_MIN")) 100 | (constant (#.(lispify-wo-prefix "CL_UINT_MAX" :constant) "CL_UINT_MAX")) 101 | (constant (#.(lispify-wo-prefix "CL_LONG_MAX" :constant) "CL_LONG_MAX")) 102 | (constant (#.(lispify-wo-prefix "CL_LONG_MIN" :constant) "CL_LONG_MIN")) 103 | (constant (#.(lispify-wo-prefix "CL_ULONG_MAX" :constant) "CL_ULONG_MAX")) 104 | (constant (#.(lispify-wo-prefix "CL_FLT_DIG" :constant) "CL_FLT_DIG")) 105 | (constant (#.(lispify-wo-prefix "CL_FLT_MANT_DIG" :constant) "CL_FLT_MANT_DIG")) 106 | (constant (#.(lispify-wo-prefix "CL_FLT_MAX_10_EXP" :constant) "CL_FLT_MAX_10_EXP")) 107 | (constant (#.(lispify-wo-prefix "CL_FLT_MAX_EXP" :constant) "CL_FLT_MAX_EXP")) 108 | (constant (#.(lispify-wo-prefix "CL_FLT_MIN_10_EXP" :constant) "CL_FLT_MIN_10_EXP")) 109 | (constant (#.(lispify-wo-prefix "CL_FLT_MIN_EXP" :constant) "CL_FLT_MIN_EXP")) 110 | (constant (#.(lispify-wo-prefix "CL_FLT_RADIX" :constant) "CL_FLT_RADIX")) 111 | (constant (#.(lispify-wo-prefix "CL_FLT_MAX" :constant) "CL_FLT_MAX")) 112 | (constant (#.(lispify-wo-prefix "CL_FLT_MIN" :constant) "CL_FLT_MIN")) 113 | (constant (#.(lispify-wo-prefix "CL_FLT_EPSILON" :constant) "CL_FLT_EPSILON")) 114 | (constant (#.(lispify-wo-prefix "CL_DBL_DIG" :constant) "CL_DBL_DIG")) 115 | (constant (#.(lispify-wo-prefix "CL_DBL_MANT_DIG" :constant) "CL_DBL_MANT_DIG")) 116 | (constant (#.(lispify-wo-prefix "CL_DBL_MAX_10_EXP" :constant) "CL_DBL_MAX_10_EXP")) 117 | (constant (#.(lispify-wo-prefix "CL_DBL_MAX_EXP" :constant) "CL_DBL_MAX_EXP")) 118 | (constant (#.(lispify-wo-prefix "CL_DBL_MIN_10_EXP" :constant) "CL_DBL_MIN_10_EXP")) 119 | (constant (#.(lispify-wo-prefix "CL_DBL_MIN_EXP" :constant) "CL_DBL_MIN_EXP")) 120 | (constant (#.(lispify-wo-prefix "CL_DBL_RADIX" :constant) "CL_DBL_RADIX")) 121 | (constant (#.(lispify-wo-prefix "CL_DBL_MAX" :constant) "CL_DBL_MAX")) 122 | (constant (#.(lispify-wo-prefix "CL_DBL_MIN" :constant) "CL_DBL_MIN")) 123 | (constant (#.(lispify-wo-prefix "CL_DBL_EPSILON" :constant) "CL_DBL_EPSILON")) 124 | (constant (#.(lispify-wo-prefix "CL_NAN" :constant) "CL_NAN")) 125 | (constant (#.(lispify-wo-prefix "CL_HUGE_VALF" :constant) "CL_HUGE_VALF")) 126 | (constant (#.(lispify-wo-prefix "CL_HUGE_VAL" :constant) "CL_HUGE_VAL")) 127 | (constant (#.(lispify-wo-prefix "CL_MAXFLOAT" :constant) "CL_MAXFLOAT")) 128 | (constant (#.(lispify-wo-prefix "CL_INFINITY" :constant) "CL_INFINITY")) 129 | 130 | -------------------------------------------------------------------------------- /0.bindings-src/2-4-grovel-cl-enum.lisp: -------------------------------------------------------------------------------- 1 | ;;; groveller file 2 | 3 | (in-package #:eazy-opencl.grovel) 4 | #+darwin 5 | (include "OpenCL/cl.h") 6 | #-darwin 7 | (include "CL/cl.h") 8 | 9 | #+darwin 10 | (include "OpenCL/cl_ext.h") 11 | #-darwin 12 | (include "CL/cl_ext.h") 13 | 14 | (constant (#.(lispify "FALSE") "CL_FALSE")) 15 | (constant (#.(lispify "TRUE") "CL_TRUE")) 16 | (constant (#.(lispify "BLOCKING") "CL_BLOCKING")) 17 | (constant (#.(lispify "NON_BLOCKING") "CL_NON_BLOCKING")) 18 | 19 | 20 | ;;; enums 21 | 22 | (constantenum (--error-code :base-type int) ; from CL_INT 23 | (#.(lispify-k-pair "CL_SUCCESS")) 24 | (#.(lispify-k-pair "CL_DEVICE_NOT_FOUND")) 25 | (#.(lispify-k-pair "CL_DEVICE_NOT_AVAILABLE")) 26 | (#.(lispify-k-pair "CL_COMPILER_NOT_AVAILABLE")) 27 | (#.(lispify-k-pair "CL_MEM_OBJECT_ALLOCATION_FAILURE")) 28 | (#.(lispify-k-pair "CL_OUT_OF_RESOURCES")) 29 | (#.(lispify-k-pair "CL_OUT_OF_HOST_MEMORY")) 30 | (#.(lispify-k-pair "CL_PROFILING_INFO_NOT_AVAILABLE")) 31 | (#.(lispify-k-pair "CL_MEM_COPY_OVERLAP")) 32 | (#.(lispify-k-pair "CL_IMAGE_FORMAT_MISMATCH")) 33 | (#.(lispify-k-pair "CL_IMAGE_FORMAT_NOT_SUPPORTED")) 34 | (#.(lispify-k-pair "CL_BUILD_PROGRAM_FAILURE")) 35 | (#.(lispify-k-pair "CL_MAP_FAILURE")) 36 | (#.(lispify-k-pair "CL_MISALIGNED_SUB_BUFFER_OFFSET")) 37 | (#.(lispify-k-pair "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST")) 38 | (#.(lispify-k-pair "CL_COMPILE_PROGRAM_FAILURE")) 39 | (#.(lispify-k-pair "CL_LINKER_NOT_AVAILABLE")) 40 | (#.(lispify-k-pair "CL_LINK_PROGRAM_FAILURE")) 41 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_FAILED")) 42 | (#.(lispify-k-pair "CL_KERNEL_ARG_INFO_NOT_AVAILABLE")) 43 | (#.(lispify-k-pair "CL_INVALID_VALUE")) 44 | (#.(lispify-k-pair "CL_INVALID_DEVICE_TYPE")) 45 | (#.(lispify-k-pair "CL_INVALID_PLATFORM")) 46 | (#.(lispify-k-pair "CL_INVALID_DEVICE")) 47 | (#.(lispify-k-pair "CL_INVALID_CONTEXT")) 48 | (#.(lispify-k-pair "CL_INVALID_QUEUE_PROPERTIES")) 49 | (#.(lispify-k-pair "CL_INVALID_COMMAND_QUEUE")) 50 | (#.(lispify-k-pair "CL_INVALID_HOST_PTR")) 51 | (#.(lispify-k-pair "CL_INVALID_MEM_OBJECT")) 52 | (#.(lispify-k-pair "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR")) 53 | (#.(lispify-k-pair "CL_INVALID_IMAGE_SIZE")) 54 | (#.(lispify-k-pair "CL_INVALID_SAMPLER")) 55 | (#.(lispify-k-pair "CL_INVALID_BINARY")) 56 | (#.(lispify-k-pair "CL_INVALID_BUILD_OPTIONS")) 57 | (#.(lispify-k-pair "CL_INVALID_PROGRAM")) 58 | (#.(lispify-k-pair "CL_INVALID_PROGRAM_EXECUTABLE")) 59 | (#.(lispify-k-pair "CL_INVALID_KERNEL_NAME")) 60 | (#.(lispify-k-pair "CL_INVALID_KERNEL_DEFINITION")) 61 | (#.(lispify-k-pair "CL_INVALID_KERNEL")) 62 | (#.(lispify-k-pair "CL_INVALID_ARG_INDEX")) 63 | (#.(lispify-k-pair "CL_INVALID_ARG_VALUE")) 64 | (#.(lispify-k-pair "CL_INVALID_ARG_SIZE")) 65 | (#.(lispify-k-pair "CL_INVALID_KERNEL_ARGS")) 66 | (#.(lispify-k-pair "CL_INVALID_WORK_DIMENSION")) 67 | (#.(lispify-k-pair "CL_INVALID_WORK_GROUP_SIZE")) 68 | (#.(lispify-k-pair "CL_INVALID_WORK_ITEM_SIZE")) 69 | (#.(lispify-k-pair "CL_INVALID_GLOBAL_OFFSET")) 70 | (#.(lispify-k-pair "CL_INVALID_EVENT_WAIT_LIST")) 71 | (#.(lispify-k-pair "CL_INVALID_EVENT")) 72 | (#.(lispify-k-pair "CL_INVALID_OPERATION")) 73 | (#.(lispify-k-pair "CL_INVALID_GL_OBJECT")) 74 | (#.(lispify-k-pair "CL_INVALID_BUFFER_SIZE")) 75 | (#.(lispify-k-pair "CL_INVALID_MIP_LEVEL")) 76 | (#.(lispify-k-pair "CL_INVALID_GLOBAL_WORK_SIZE")) 77 | (#.(lispify-k-pair "CL_INVALID_PROPERTY")) 78 | (#.(lispify-k-pair "CL_INVALID_IMAGE_DESCRIPTOR")) 79 | (#.(lispify-k-pair "CL_INVALID_COMPILER_OPTIONS")) 80 | (#.(lispify-k-pair "CL_INVALID_LINKER_OPTIONS")) 81 | (#.(lispify-k-pair "CL_INVALID_DEVICE_PARTITION_COUNT")) 82 | #+opencl-2.0 83 | (#.(lispify-k-pair "CL_INVALID_PIPE_SIZE")) 84 | #+opencl-2.0 85 | (#.(lispify-k-pair "CL_INVALID_DEVICE_QUEUE")) 86 | ;; extension 87 | (#.(lispify-k-pair "CL_PLATFORM_NOT_FOUND_KHR"))) 88 | 89 | (constantenum (#.(lispify "platform_info") :base-type #.(lispify "__platform_info")) 90 | (#.(lispify-k-pair "CL_PLATFORM_PROFILE")) 91 | (#.(lispify-k-pair "CL_PLATFORM_VERSION")) 92 | (#.(lispify-k-pair "CL_PLATFORM_NAME")) 93 | (#.(lispify-k-pair "CL_PLATFORM_VENDOR")) 94 | (#.(lispify-k-pair "CL_PLATFORM_EXTENSIONS")) 95 | ;; extension 96 | (#.(lispify-k-pair "CL_PLATFORM_ICD_SUFFIX_KHR"))) 97 | 98 | (bitfield (#.(lispify "device_type") :base-type #.(lispify "__device_type")) 99 | (#.(lispify-k-pair "CL_DEVICE_TYPE_DEFAULT")) 100 | (#.(lispify-k-pair "CL_DEVICE_TYPE_CPU")) 101 | (#.(lispify-k-pair "CL_DEVICE_TYPE_GPU")) 102 | (#.(lispify-k-pair "CL_DEVICE_TYPE_ACCELERATOR")) 103 | (#.(lispify-k-pair "CL_DEVICE_TYPE_CUSTOM")) 104 | (#.(lispify-k-pair "CL_DEVICE_TYPE_ALL"))) 105 | 106 | (constantenum (#.(lispify "device_info") :base-type #.(lispify "__device_info")) 107 | (#.(lispify-k-pair "CL_DEVICE_TYPE")) 108 | (#.(lispify-k-pair "CL_DEVICE_VENDOR_ID")) 109 | (#.(lispify-k-pair "CL_DEVICE_MAX_COMPUTE_UNITS")) 110 | (#.(lispify-k-pair "CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS")) 111 | (#.(lispify-k-pair "CL_DEVICE_MAX_WORK_GROUP_SIZE")) 112 | (#.(lispify-k-pair "CL_DEVICE_MAX_WORK_ITEM_SIZES")) 113 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR")) 114 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT")) 115 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT")) 116 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG")) 117 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT")) 118 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE")) 119 | (#.(lispify-k-pair "CL_DEVICE_MAX_CLOCK_FREQUENCY")) 120 | (#.(lispify-k-pair "CL_DEVICE_ADDRESS_BITS")) 121 | (#.(lispify-k-pair "CL_DEVICE_MAX_READ_IMAGE_ARGS")) 122 | (#.(lispify-k-pair "CL_DEVICE_MAX_WRITE_IMAGE_ARGS")) 123 | (#.(lispify-k-pair "CL_DEVICE_MAX_MEM_ALLOC_SIZE")) 124 | (#.(lispify-k-pair "CL_DEVICE_IMAGE2D_MAX_WIDTH")) 125 | (#.(lispify-k-pair "CL_DEVICE_IMAGE2D_MAX_HEIGHT")) 126 | (#.(lispify-k-pair "CL_DEVICE_IMAGE3D_MAX_WIDTH")) 127 | (#.(lispify-k-pair "CL_DEVICE_IMAGE3D_MAX_HEIGHT")) 128 | (#.(lispify-k-pair "CL_DEVICE_IMAGE3D_MAX_DEPTH")) 129 | (#.(lispify-k-pair "CL_DEVICE_IMAGE_SUPPORT")) 130 | (#.(lispify-k-pair "CL_DEVICE_MAX_PARAMETER_SIZE")) 131 | (#.(lispify-k-pair "CL_DEVICE_MAX_SAMPLERS")) 132 | (#.(lispify-k-pair "CL_DEVICE_MEM_BASE_ADDR_ALIGN")) 133 | ;; #-opencl-1.2 134 | (#.(lispify-k-pair "CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE")) 135 | (#.(lispify-k-pair "CL_DEVICE_SINGLE_FP_CONFIG")) 136 | (#.(lispify-k-pair "CL_DEVICE_GLOBAL_MEM_CACHE_TYPE")) 137 | (#.(lispify-k-pair "CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE")) 138 | (#.(lispify-k-pair "CL_DEVICE_GLOBAL_MEM_CACHE_SIZE")) 139 | (#.(lispify-k-pair "CL_DEVICE_GLOBAL_MEM_SIZE")) 140 | (#.(lispify-k-pair "CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE")) 141 | (#.(lispify-k-pair "CL_DEVICE_MAX_CONSTANT_ARGS")) 142 | (#.(lispify-k-pair "CL_DEVICE_LOCAL_MEM_TYPE")) 143 | (#.(lispify-k-pair "CL_DEVICE_LOCAL_MEM_SIZE")) 144 | (#.(lispify-k-pair "CL_DEVICE_ERROR_CORRECTION_SUPPORT")) 145 | (#.(lispify-k-pair "CL_DEVICE_PROFILING_TIMER_RESOLUTION")) 146 | (#.(lispify-k-pair "CL_DEVICE_ENDIAN_LITTLE")) 147 | (#.(lispify-k-pair "CL_DEVICE_AVAILABLE")) 148 | (#.(lispify-k-pair "CL_DEVICE_COMPILER_AVAILABLE")) 149 | (#.(lispify-k-pair "CL_DEVICE_EXECUTION_CAPABILITIES")) 150 | ;; #-opencl-2.0 151 | (#.(lispify-k-pair "CL_DEVICE_QUEUE_PROPERTIES")) 152 | ;; in opencl-2.0, CL_DEVICE_QUEUE_PROPERTIES is replaced by CL_DEVICE_QUEUE_ON_HOST_PROPERTIES 153 | #+opencl-2.0 154 | (#.(lispify-k-pair "CL_DEVICE_QUEUE_ON_HOST_PROPERTIES")) 155 | (#.(lispify-k-pair "CL_DEVICE_NAME")) 156 | (#.(lispify-k-pair "CL_DEVICE_VENDOR")) 157 | (#.(lispify-k-pair "CL_DRIVER_VERSION")) 158 | (#.(lispify-k-pair "CL_DEVICE_PROFILE")) 159 | (#.(lispify-k-pair "CL_DEVICE_VERSION")) 160 | (#.(lispify-k-pair "CL_DEVICE_EXTENSIONS")) 161 | (#.(lispify-k-pair "CL_DEVICE_PLATFORM")) 162 | (#.(lispify-k-pair "CL_DEVICE_DOUBLE_FP_CONFIG")) 163 | ;; 0x1033 reserved for CL_DEVICE_HALF_FP_CONFIG 164 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF")) 165 | ;; #+(and opencl-1.1 (not opencl-2.0)) 166 | #+opencl-1.1 167 | (#.(lispify-k-pair "CL_DEVICE_HOST_UNIFIED_MEMORY")) 168 | #+opencl-1.1 169 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR")) 170 | #+opencl-1.1 171 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT")) 172 | #+opencl-1.1 173 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_INT")) 174 | #+opencl-1.1 175 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG")) 176 | #+opencl-1.1 177 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT")) 178 | #+opencl-1.1 179 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE")) 180 | #+opencl-1.1 181 | (#.(lispify-k-pair "CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF")) 182 | #+opencl-1.1 183 | (#.(lispify-k-pair "CL_DEVICE_OPENCL_C_VERSION")) 184 | (#.(lispify-k-pair "CL_DEVICE_LINKER_AVAILABLE")) 185 | (#.(lispify-k-pair "CL_DEVICE_BUILT_IN_KERNELS")) 186 | (#.(lispify-k-pair "CL_DEVICE_IMAGE_MAX_BUFFER_SIZE")) 187 | (#.(lispify-k-pair "CL_DEVICE_IMAGE_MAX_ARRAY_SIZE")) 188 | (#.(lispify-k-pair "CL_DEVICE_PARENT_DEVICE")) 189 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_MAX_SUB_DEVICES")) 190 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_PROPERTIES")) 191 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_AFFINITY_DOMAIN")) 192 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_TYPE")) 193 | (#.(lispify-k-pair "CL_DEVICE_REFERENCE_COUNT")) 194 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_INTEROP_USER_SYNC")) 195 | (#.(lispify-k-pair "CL_DEVICE_PRINTF_BUFFER_SIZE")) 196 | (#.(lispify-k-pair "CL_DEVICE_IMAGE_PITCH_ALIGNMENT")) 197 | (#.(lispify-k-pair "CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT")) 198 | #+opencl-2.0 199 | (#.(lispify-k-pair "CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS")) 200 | #+opencl-2.0 201 | (#.(lispify-k-pair "CL_DEVICE_MAX_GLOBAL_VARIABLE_SIZE")) 202 | #+opencl-2.0 203 | (#.(lispify-k-pair "CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES")) 204 | #+opencl-2.0 205 | (#.(lispify-k-pair "CL_DEVICE_QUEUE_ON_DEVICE_PREFERRED_SIZE")) 206 | #+opencl-2.0 207 | (#.(lispify-k-pair "CL_DEVICE_QUEUE_ON_DEVICE_MAX_SIZE")) 208 | #+opencl-2.0 209 | (#.(lispify-k-pair "CL_DEVICE_MAX_ON_DEVICE_QUEUES")) 210 | #+opencl-2.0 211 | (#.(lispify-k-pair "CL_DEVICE_MAX_ON_DEVICE_EVENTS")) 212 | #+opencl-2.0 213 | (#.(lispify-k-pair "CL_DEVICE_SVM_CAPABILITIES")) 214 | #+opencl-2.0 215 | (#.(lispify-k-pair "CL_DEVICE_GLOBAL_VARIABLE_PREFERRED_TOTAL_SIZE")) 216 | #+opencl-2.0 217 | (#.(lispify-k-pair "CL_DEVICE_MAX_PIPE_ARGS")) 218 | #+opencl-2.0 219 | (#.(lispify-k-pair "CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS")) 220 | #+opencl-2.0 221 | (#.(lispify-k-pair "CL_DEVICE_PIPE_MAX_PACKET_SIZE")) 222 | #+opencl-2.0 223 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_PLATFORM_ATOMIC_ALIGNMENT")) 224 | #+opencl-2.0 225 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT")) 226 | #+opencl-2.0 227 | (#.(lispify-k-pair "CL_DEVICE_PREFERRED_LOCAL_ATOMIC_ALIGNMENT"))) 228 | 229 | (bitfield (#.(lispify "device_fp_config") :base-type #.(lispify "__device_fp_config")) 230 | (#.(lispify-k-pair "CL_FP_DENORM")) 231 | (#.(lispify-k-pair "CL_FP_INF_NAN")) 232 | (#.(lispify-k-pair "CL_FP_ROUND_TO_NEAREST")) 233 | (#.(lispify-k-pair "CL_FP_ROUND_TO_ZERO")) 234 | (#.(lispify-k-pair "CL_FP_ROUND_TO_INF")) 235 | (#.(lispify-k-pair "CL_FP_FMA")) 236 | (#.(lispify-k-pair "CL_FP_SOFT_FLOAT")) 237 | (#.(lispify-k-pair "CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT"))) 238 | 239 | (constantenum (#.(lispify "device_mem_cache_type") :base-type #.(lispify "__device_mem_cache_type")) 240 | (#.(lispify-k-pair "CL_NONE")) 241 | (#.(lispify-k-pair "CL_READ_ONLY_CACHE")) 242 | (#.(lispify-k-pair "CL_READ_WRITE_CACHE"))) 243 | 244 | (constantenum (#.(lispify "device_local_mem_type") :base-type #.(lispify "__device_local_mem_type")) 245 | (#.(lispify-k-pair "CL_LOCAL")) 246 | (#.(lispify-k-pair "CL_GLOBAL"))) 247 | 248 | (bitfield (#.(lispify "device_exec_capabilities") :base-type #.(lispify "__device_exec_capabilities")) 249 | (#.(lispify-k-pair "CL_EXEC_KERNEL")) 250 | (#.(lispify-k-pair "CL_EXEC_NATIVE_KERNEL"))) 251 | 252 | (bitfield (#.(lispify "command_queue_properties") :base-type #.(lispify "__command_queue_properties")) 253 | (#.(lispify-k-pair "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE")) 254 | (#.(lispify-k-pair "CL_QUEUE_PROFILING_ENABLE")) 255 | #+opencl-2.0 256 | (#.(lispify-k-pair "CL_QUEUE_ON_DEVICE")) 257 | #+opencl-2.0 258 | (#.(lispify-k-pair "CL_QUEUE_ON_DEVICE_DEFAULT"))) 259 | 260 | #+opencl-2.0 261 | (constantenum (#.(lispify "queue_properties") :base-type #.(lispify "__queue_properties")) 262 | (#.(lispify-k-pair "CL_QUEUE_PROPERTIES")) 263 | (#.(lispify-k-pair "CL_QUEUE_SIZE"))) 264 | 265 | (constantenum (#.(lispify "context_info") :base-type #.(lispify "__context_info")) 266 | (#.(lispify-k-pair "CL_CONTEXT_REFERENCE_COUNT")) 267 | (#.(lispify-k-pair "CL_CONTEXT_DEVICES")) 268 | (#.(lispify-k-pair "CL_CONTEXT_PROPERTIES")) 269 | #+opencl-1.1 270 | (#.(lispify-k-pair "CL_CONTEXT_NUM_DEVICES"))) 271 | 272 | (constantenum (#.(lispify "context_properties") :base-type #.(lispify "__context_properties")) 273 | (#.(lispify-k-pair "CL_CONTEXT_PLATFORM")) 274 | (#.(lispify-k-pair "CL_CONTEXT_INTEROP_USER_SYNC"))) 275 | 276 | (constantenum (#.(lispify "device_partition_property") :base-type #.(lispify "__device_partition_property")) 277 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_EQUALLY")) 278 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_BY_COUNTS")) 279 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_BY_COUNTS_LIST_END")) 280 | (#.(lispify-k-pair "CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN"))) 281 | 282 | (bitfield (#.(lispify "device_affinity_domain") :base-type #.(lispify "__device_affinity_domain")) 283 | (#.(lispify-k-pair "CL_DEVICE_AFFINITY_DOMAIN_NUMA")) 284 | (#.(lispify-k-pair "CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE")) 285 | (#.(lispify-k-pair "CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE")) 286 | (#.(lispify-k-pair "CL_DEVICE_AFFINITY_DOMAIN_L2_CACHE")) 287 | (#.(lispify-k-pair "CL_DEVICE_AFFINITY_DOMAIN_L1_CACHE")) 288 | (#.(lispify-k-pair "CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE"))) 289 | 290 | #+opencl-2.0 291 | (bitfield (#.(lispify "device_svm_capabilities") :base-type #.(lispify "__device_svm_capabilities")) 292 | (#.(lispify-k-pair "CL_DEVICE_SVM_COARSE_GRAIN_BUFFER")) 293 | (#.(lispify-k-pair "CL_DEVICE_SVM_FINE_GRAIN_BUFFER")) 294 | (#.(lispify-k-pair "CL_DEVICE_SVM_FINE_GRAIN_SYSTEM")) 295 | (#.(lispify-k-pair "CL_DEVICE_SVM_ATOMICS"))) 296 | 297 | (constantenum (#.(lispify "command_queue_info") :base-type #.(lispify "__command_queue_info")) 298 | (#.(lispify-k-pair "CL_QUEUE_CONTEXT")) 299 | (#.(lispify-k-pair "CL_QUEUE_DEVICE")) 300 | (#.(lispify-k-pair "CL_QUEUE_REFERENCE_COUNT")) 301 | (#.(lispify-k-pair "CL_QUEUE_PROPERTIES")) 302 | #+opencl-2.0 303 | (#.(lispify-k-pair "CL_QUEUE_SIZE"))) 304 | 305 | (bitfield (#.(lispify "mem_flags") :base-type #.(lispify "__mem_flags")) 306 | (#.(lispify-k-pair "CL_MEM_READ_WRITE")) 307 | (#.(lispify-k-pair "CL_MEM_WRITE_ONLY")) 308 | (#.(lispify-k-pair "CL_MEM_READ_ONLY")) 309 | (#.(lispify-k-pair "CL_MEM_USE_HOST_PTR")) 310 | (#.(lispify-k-pair "CL_MEM_ALLOC_HOST_PTR")) 311 | (#.(lispify-k-pair "CL_MEM_COPY_HOST_PTR")) 312 | ;; reserved (1 << 6) 313 | (#.(lispify-k-pair "CL_MEM_HOST_WRITE_ONLY")) 314 | (#.(lispify-k-pair "CL_MEM_HOST_READ_ONLY")) 315 | (#.(lispify-k-pair "CL_MEM_HOST_NO_ACCESS")) 316 | (#.(lispify-k-pair "CL_MEM_SVM_FINE_GRAIN_BUFFER")) 317 | (#.(lispify-k-pair "CL_MEM_SVM_ATOMICS")) 318 | (#.(lispify-k-pair "CL_MEM_KERNEL_READ_AND_WRITE"))) 319 | 320 | ;; FIXME : duplicated --- cl_mem_flags 321 | #+opencl-2.0 322 | (bitfield (#.(lispify "svm_mem_flags") :base-type #.(lispify "__svm_mem_flags")) 323 | (#.(lispify-k-pair "CL_MEM_READ_WRITE")) 324 | (#.(lispify-k-pair "CL_MEM_WRITE_ONLY")) 325 | (#.(lispify-k-pair "CL_MEM_READ_ONLY")) 326 | (#.(lispify-k-pair "CL_MEM_USE_HOST_PTR")) 327 | (#.(lispify-k-pair "CL_MEM_ALLOC_HOST_PTR")) 328 | (#.(lispify-k-pair "CL_MEM_COPY_HOST_PTR")) 329 | ;; reserved (1 << 6) 330 | (#.(lispify-k-pair "CL_MEM_HOST_WRITE_ONLY")) 331 | (#.(lispify-k-pair "CL_MEM_HOST_READ_ONLY")) 332 | (#.(lispify-k-pair "CL_MEM_HOST_NO_ACCESS")) 333 | (#.(lispify-k-pair "CL_MEM_SVM_FINE_GRAIN_BUFFER")) 334 | (#.(lispify-k-pair "CL_MEM_SVM_ATOMICS")) 335 | (#.(lispify-k-pair "CL_MEM_KERNEL_READ_AND_WRITE"))) 336 | 337 | (bitfield (#.(lispify "mem_migration_flags") :base-type #.(lispify "__mem_migration_flags")) 338 | (#.(lispify-k-pair "CL_MIGRATE_MEM_OBJECT_HOST")) 339 | (#.(lispify-k-pair "CL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINED"))) 340 | 341 | (constantenum (#.(lispify "channel_order") :base-type #.(lispify "__channel_order")) 342 | (#.(lispify-k-pair "CL_R")) 343 | (#.(lispify-k-pair "CL_A")) 344 | (#.(lispify-k-pair "CL_RG")) 345 | (#.(lispify-k-pair "CL_RA")) 346 | (#.(lispify-k-pair "CL_RGB")) 347 | (#.(lispify-k-pair "CL_RGBA")) 348 | (#.(lispify-k-pair "CL_BGRA")) 349 | (#.(lispify-k-pair "CL_ARGB")) 350 | (#.(lispify-k-pair "CL_INTENSITY")) 351 | (#.(lispify-k-pair "CL_LUMINANCE")) 352 | #+opencl-1.1 353 | (#.(lispify-k-pair "CL_Rx")) 354 | #+opencl-1.1 355 | (#.(lispify-k-pair "CL_RGx")) 356 | #+opencl-1.1 357 | (#.(lispify-k-pair "CL_RGBx")) 358 | (#.(lispify-k-pair "CL_DEPTH")) 359 | (#.(lispify-k-pair "CL_DEPTH_STENCIL")) 360 | (#.(lispify-k-pair "CL_sRGB")) 361 | (#.(lispify-k-pair "CL_sRGBx")) 362 | (#.(lispify-k-pair "CL_sRGBA")) 363 | (#.(lispify-k-pair "CL_sBGRA")) 364 | (#.(lispify-k-pair "CL_ABGR"))) 365 | 366 | (constantenum (#.(lispify "channel_type") :base-type #.(lispify "__channel_type")) 367 | (#.(lispify-k-pair "CL_SNORM_INT8")) 368 | (#.(lispify-k-pair "CL_SNORM_INT16")) 369 | (#.(lispify-k-pair "CL_UNORM_INT8")) 370 | (#.(lispify-k-pair "CL_UNORM_INT16")) 371 | (#.(lispify-k-pair "CL_UNORM_SHORT_565")) 372 | (#.(lispify-k-pair "CL_UNORM_SHORT_555")) 373 | (#.(lispify-k-pair "CL_UNORM_INT_101010")) 374 | (#.(lispify-k-pair "CL_SIGNED_INT8")) 375 | (#.(lispify-k-pair "CL_SIGNED_INT16")) 376 | (#.(lispify-k-pair "CL_SIGNED_INT32")) 377 | (#.(lispify-k-pair "CL_UNSIGNED_INT8")) 378 | (#.(lispify-k-pair "CL_UNSIGNED_INT16")) 379 | (#.(lispify-k-pair "CL_UNSIGNED_INT32")) 380 | (#.(lispify-k-pair "CL_HALF_FLOAT")) 381 | (#.(lispify-k-pair "CL_FLOAT")) 382 | (#.(lispify-k-pair "CL_UNORM_INT24"))) 383 | 384 | (constantenum (#.(lispify "mem_object_type") :base-type #.(lispify "__mem_object_type")) 385 | (#.(lispify-k-pair "CL_MEM_OBJECT_BUFFER")) 386 | (#.(lispify-k-pair "CL_MEM_OBJECT_IMAGE2D")) 387 | (#.(lispify-k-pair "CL_MEM_OBJECT_IMAGE3D")) 388 | (#.(lispify-k-pair "CL_MEM_OBJECT_IMAGE2D_ARRAY")) 389 | (#.(lispify-k-pair "CL_MEM_OBJECT_IMAGE1D")) 390 | (#.(lispify-k-pair "CL_MEM_OBJECT_IMAGE1D_ARRAY")) 391 | (#.(lispify-k-pair "CL_MEM_OBJECT_IMAGE1D_BUFFER")) 392 | #+opencl-2.0 393 | (#.(lispify-k-pair "CL_MEM_OBJECT_PIPE"))) 394 | 395 | (constantenum (#.(lispify "mem_info") :base-type #.(lispify "__mem_info")) 396 | (#.(lispify-k-pair "CL_MEM_TYPE")) 397 | (#.(lispify-k-pair "CL_MEM_FLAGS")) 398 | (#.(lispify-k-pair "CL_MEM_SIZE")) 399 | (#.(lispify-k-pair "CL_MEM_HOST_PTR")) 400 | (#.(lispify-k-pair "CL_MEM_MAP_COUNT")) 401 | (#.(lispify-k-pair "CL_MEM_REFERENCE_COUNT")) 402 | (#.(lispify-k-pair "CL_MEM_CONTEXT")) 403 | (#.(lispify-k-pair "CL_MEM_ASSOCIATED_MEMOBJECT")) 404 | (#.(lispify-k-pair "CL_MEM_OFFSET")) 405 | #+opencl-2.0 406 | (#.(lispify-k-pair "CL_MEM_USES_SVM_POINTER"))) 407 | 408 | (constantenum (#.(lispify "image_info") :base-type #.(lispify "__image_info")) 409 | (#.(lispify-k-pair "CL_IMAGE_FORMAT")) 410 | (#.(lispify-k-pair "CL_IMAGE_ELEMENT_SIZE")) 411 | (#.(lispify-k-pair "CL_IMAGE_ROW_PITCH")) 412 | (#.(lispify-k-pair "CL_IMAGE_SLICE_PITCH")) 413 | (#.(lispify-k-pair "CL_IMAGE_WIDTH")) 414 | (#.(lispify-k-pair "CL_IMAGE_HEIGHT")) 415 | (#.(lispify-k-pair "CL_IMAGE_DEPTH")) 416 | (#.(lispify-k-pair "CL_IMAGE_ARRAY_SIZE")) 417 | ;; #-opencl-2.0 418 | (#.(lispify-k-pair "CL_IMAGE_BUFFER")) 419 | (#.(lispify-k-pair "CL_IMAGE_NUM_MIP_LEVELS")) 420 | (#.(lispify-k-pair "CL_IMAGE_NUM_SAMPLES"))) 421 | 422 | #+opencl-2.0 423 | (constantenum (#.(lispify "pipe_info") :base-type #.(lispify "__pipe_info")) 424 | (#.(lispify-k-pair "CL_PIPE_PACKET_SIZE")) 425 | (#.(lispify-k-pair "CL_PIPE_MAX_PACKETS"))) 426 | 427 | #+opencl-2.0 428 | (constantenum (#.(lispify "pipe_properties") :base-type #.(lispify "__pipe_properties"))) 429 | 430 | 431 | (constantenum (#.(lispify "addressing_mode") :base-type #.(lispify "__addressing_mode")) 432 | (#.(lispify-k-pair "CL_ADDRESS_NONE")) 433 | (#.(lispify-k-pair "CL_ADDRESS_CLAMP_TO_EDGE")) 434 | (#.(lispify-k-pair "CL_ADDRESS_CLAMP")) 435 | (#.(lispify-k-pair "CL_ADDRESS_REPEAT")) 436 | (#.(lispify-k-pair "CL_ADDRESS_MIRRORED_REPEAT"))) 437 | 438 | (constantenum (#.(lispify "filter_mode") :base-type #.(lispify "__filter_mode")) 439 | (#.(lispify-k-pair "CL_FILTER_NEAREST")) 440 | (#.(lispify-k-pair "CL_FILTER_LINEAR"))) 441 | 442 | (constantenum (#.(lispify "sampler_info") :base-type #.(lispify "__sampler_info")) 443 | (#.(lispify-k-pair "CL_SAMPLER_REFERENCE_COUNT")) 444 | (#.(lispify-k-pair "CL_SAMPLER_CONTEXT")) 445 | (#.(lispify-k-pair "CL_SAMPLER_NORMALIZED_COORDS")) 446 | (#.(lispify-k-pair "CL_SAMPLER_ADDRESSING_MODE")) 447 | (#.(lispify-k-pair "CL_SAMPLER_FILTER_MODE")) 448 | ;; extensions, not included 449 | ;; (#.(lispify-k-pair "CL_SAMPLER_MIP_FILTER_MODE")) 450 | ;; (#.(lispify-k-pair "CL_SAMPLER_LOD_MIN")) 451 | ;; (#.(lispify-k-pair "CL_SAMPLER_LOD_MAX")) 452 | ) 453 | 454 | #+opencl-2.0 455 | (constantenum (#.(lispify "sampler_properties") :base-type #.(lispify "__sampler_properties")) 456 | (#.(lispify-k-pair "CL_SAMPLER_NORMALIZED_COORDS")) 457 | (#.(lispify-k-pair "CL_SAMPLER_ADDRESSING_MODE")) 458 | (#.(lispify-k-pair "CL_SAMPLER_FILTER_MODE"))) 459 | 460 | (bitfield (#.(lispify "map_flags") :base-type #.(lispify "__map_flags")) 461 | (#.(lispify-k-pair "CL_MAP_READ")) 462 | (#.(lispify-k-pair "CL_MAP_WRITE")) 463 | ;; #+opencl-1.2 464 | (#.(lispify-k-pair "CL_MAP_WRITE_INVALIDATE_REGION"))) 465 | 466 | (constantenum (#.(lispify "program_info") :base-type #.(lispify "__program_info")) 467 | (#.(lispify-k-pair "CL_PROGRAM_REFERENCE_COUNT")) 468 | (#.(lispify-k-pair "CL_PROGRAM_CONTEXT")) 469 | (#.(lispify-k-pair "CL_PROGRAM_NUM_DEVICES")) 470 | (#.(lispify-k-pair "CL_PROGRAM_DEVICES")) 471 | (#.(lispify-k-pair "CL_PROGRAM_SOURCE")) 472 | (#.(lispify-k-pair "CL_PROGRAM_BINARY_SIZES")) 473 | (#.(lispify-k-pair "CL_PROGRAM_BINARIES")) 474 | (#.(lispify-k-pair "CL_PROGRAM_NUM_KERNELS")) 475 | (#.(lispify-k-pair "CL_PROGRAM_KERNEL_NAMES"))) 476 | 477 | (constantenum (#.(lispify "program_build_info") :base-type #.(lispify "__program_build_info")) 478 | (#.(lispify-k-pair "CL_PROGRAM_BUILD_STATUS")) 479 | (#.(lispify-k-pair "CL_PROGRAM_BUILD_OPTIONS")) 480 | (#.(lispify-k-pair "CL_PROGRAM_BUILD_LOG")) 481 | (#.(lispify-k-pair "CL_PROGRAM_BINARY_TYPE")) 482 | #+opencl-2.0 483 | (#.(lispify-k-pair "CL_PROGRAM_BUILD_GLOBAL_VARIABLE_TOTAL_SIZE"))) 484 | 485 | (constantenum (#.(lispify "program_binary_type") :base-type #.(lispify "__program_binary_type")) 486 | (#.(lispify-k-pair "CL_PROGRAM_BINARY_TYPE_NONE")) 487 | (#.(lispify-k-pair "CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT")) 488 | (#.(lispify-k-pair "CL_PROGRAM_BINARY_TYPE_LIBRARY")) 489 | (#.(lispify-k-pair "CL_PROGRAM_BINARY_TYPE_EXECUTABLE"))) 490 | 491 | (constantenum (#.(lispify "build_status") :base-type #.(lispify "__build_status")) 492 | (#.(lispify-k-pair "CL_BUILD_SUCCESS")) 493 | (#.(lispify-k-pair "CL_BUILD_NONE")) 494 | (#.(lispify-k-pair "CL_BUILD_ERROR")) 495 | (#.(lispify-k-pair "CL_BUILD_IN_PROGRESS"))) 496 | 497 | (constantenum (#.(lispify "kernel_info") :base-type #.(lispify "__kernel_info")) 498 | (#.(lispify-k-pair "CL_KERNEL_FUNCTION_NAME")) 499 | (#.(lispify-k-pair "CL_KERNEL_NUM_ARGS")) 500 | (#.(lispify-k-pair "CL_KERNEL_REFERENCE_COUNT")) 501 | (#.(lispify-k-pair "CL_KERNEL_CONTEXT")) 502 | (#.(lispify-k-pair "CL_KERNEL_PROGRAM")) 503 | (#.(lispify-k-pair "CL_KERNEL_ATTRIBUTES"))) 504 | 505 | (constantenum (#.(lispify "kernel_arg_info") :base-type #.(lispify "__kernel_arg_info")) 506 | (#.(lispify-k-pair "CL_KERNEL_ARG_ADDRESS_QUALIFIER")) 507 | (#.(lispify-k-pair "CL_KERNEL_ARG_ACCESS_QUALIFIER")) 508 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_NAME")) 509 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_QUALIFIER")) 510 | (#.(lispify-k-pair "CL_KERNEL_ARG_NAME"))) 511 | 512 | (constantenum (#.(lispify "kernel_arg_address_qualifier") :base-type #.(lispify "__kernel_arg_address_qualifier")) 513 | (#.(lispify-k-pair "CL_KERNEL_ARG_ADDRESS_GLOBAL")) 514 | (#.(lispify-k-pair "CL_KERNEL_ARG_ADDRESS_LOCAL")) 515 | (#.(lispify-k-pair "CL_KERNEL_ARG_ADDRESS_CONSTANT")) 516 | (#.(lispify-k-pair "CL_KERNEL_ARG_ADDRESS_PRIVATE"))) 517 | 518 | (constantenum (#.(lispify "kernel_arg_access_qualifier") :base-type #.(lispify "__kernel_arg_access_qualifier")) 519 | (#.(lispify-k-pair "CL_KERNEL_ARG_ACCESS_READ_ONLY")) 520 | (#.(lispify-k-pair "CL_KERNEL_ARG_ACCESS_WRITE_ONLY")) 521 | (#.(lispify-k-pair "CL_KERNEL_ARG_ACCESS_READ_WRITE")) 522 | (#.(lispify-k-pair "CL_KERNEL_ARG_ACCESS_NONE"))) 523 | 524 | (constantenum (#.(lispify "kernel_arg_type_qualifier") :base-type #.(lispify "__kernel_arg_type_qualifier")) 525 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_NONE")) 526 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_CONST")) 527 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_RESTRICT")) 528 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_VOLATILE")) 529 | #+opencl-2.0 530 | (#.(lispify-k-pair "CL_KERNEL_ARG_TYPE_PIPE"))) 531 | 532 | (constantenum (#.(lispify "kernel_work_group_info") :base-type #.(lispify "__kernel_work_group_info")) 533 | (#.(lispify-k-pair "CL_KERNEL_WORK_GROUP_SIZE")) 534 | (#.(lispify-k-pair "CL_KERNEL_COMPILE_WORK_GROUP_SIZE")) 535 | (#.(lispify-k-pair "CL_KERNEL_LOCAL_MEM_SIZE")) 536 | (#.(lispify-k-pair "CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE")) 537 | (#.(lispify-k-pair "CL_KERNEL_PRIVATE_MEM_SIZE")) 538 | (#.(lispify-k-pair "CL_KERNEL_GLOBAL_WORK_SIZE")) 539 | #+opencl-2.1 540 | (#.(lispify-k-pair "CL_KERNEL_MAX_NUM_SUB_GROUPS")) 541 | #+opencl-2.1 542 | (#.(lispify-k-pair "CL_KERNEL_COMPILE_NUM_SUB_GROUPS"))) 543 | 544 | #+opencl-2.1 545 | (constantenum (#.(lispify "kernel_sub_group_info") :base-type #.(lispify "__kernel_sub_group_info")) 546 | (#.(lispify-k-pair "CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE")) 547 | (#.(lispify-k-pair "CL_KERNEL_SUB_GROUP_COUNT_FOR_NDRANGE")) 548 | (#.(lispify-k-pair "CL_GET_LOCAL_SIZE_FOR_SUB_GROUP_COUNT"))) 549 | 550 | #+opencl-2.0 551 | (constantenum (#.(lispify "kernel_exec_info") :base-type #.(lispify "__kernel_exec_info")) 552 | (#.(lispify-k-pair "CL_KERNEL_EXEC_INFO_SVM_PTRS")) 553 | (#.(lispify-k-pair "CL_KERNEL_EXEC_INFO_SVM_FINE_GRAIN_SYSTEM"))) 554 | 555 | (constantenum (#.(lispify "event_info") :base-type #.(lispify "__event_info")) 556 | (#.(lispify-k-pair "CL_EVENT_COMMAND_QUEUE")) 557 | (#.(lispify-k-pair "CL_EVENT_COMMAND_TYPE")) 558 | (#.(lispify-k-pair "CL_EVENT_REFERENCE_COUNT")) 559 | (#.(lispify-k-pair "CL_EVENT_COMMAND_EXECUTION_STATUS")) 560 | (#.(lispify-k-pair "CL_EVENT_CONTEXT"))) 561 | 562 | (constantenum (#.(lispify "command_type") :base-type #.(lispify "__command_type")) 563 | (#.(lispify-k-pair "CL_COMMAND_NDRANGE_KERNEL")) 564 | (#.(lispify-k-pair "CL_COMMAND_TASK")) 565 | (#.(lispify-k-pair "CL_COMMAND_NATIVE_KERNEL")) 566 | (#.(lispify-k-pair "CL_COMMAND_READ_BUFFER")) 567 | (#.(lispify-k-pair "CL_COMMAND_WRITE_BUFFER")) 568 | (#.(lispify-k-pair "CL_COMMAND_COPY_BUFFER")) 569 | (#.(lispify-k-pair "CL_COMMAND_READ_IMAGE")) 570 | (#.(lispify-k-pair "CL_COMMAND_WRITE_IMAGE")) 571 | (#.(lispify-k-pair "CL_COMMAND_COPY_IMAGE")) 572 | (#.(lispify-k-pair "CL_COMMAND_COPY_IMAGE_TO_BUFFER")) 573 | (#.(lispify-k-pair "CL_COMMAND_COPY_BUFFER_TO_IMAGE")) 574 | (#.(lispify-k-pair "CL_COMMAND_MAP_BUFFER")) 575 | (#.(lispify-k-pair "CL_COMMAND_MAP_IMAGE")) 576 | (#.(lispify-k-pair "CL_COMMAND_UNMAP_MEM_OBJECT")) 577 | (#.(lispify-k-pair "CL_COMMAND_MARKER")) 578 | (#.(lispify-k-pair "CL_COMMAND_ACQUIRE_GL_OBJECTS")) 579 | (#.(lispify-k-pair "CL_COMMAND_RELEASE_GL_OBJECTS")) 580 | (#.(lispify-k-pair "CL_COMMAND_READ_BUFFER_RECT")) 581 | (#.(lispify-k-pair "CL_COMMAND_WRITE_BUFFER_RECT")) 582 | (#.(lispify-k-pair "CL_COMMAND_COPY_BUFFER_RECT")) 583 | (#.(lispify-k-pair "CL_COMMAND_USER")) 584 | (#.(lispify-k-pair "CL_COMMAND_BARRIER")) 585 | (#.(lispify-k-pair "CL_COMMAND_MIGRATE_MEM_OBJECTS")) 586 | (#.(lispify-k-pair "CL_COMMAND_FILL_BUFFER")) 587 | (#.(lispify-k-pair "CL_COMMAND_FILL_IMAGE")) 588 | (#.(lispify-k-pair "CL_COMMAND_SVM_FREE")) 589 | (#.(lispify-k-pair "CL_COMMAND_SVM_MEMCPY")) 590 | (#.(lispify-k-pair "CL_COMMAND_SVM_MEMFILL")) 591 | (#.(lispify-k-pair "CL_COMMAND_SVM_MAP")) 592 | (#.(lispify-k-pair "CL_COMMAND_SVM_UNMAP"))) 593 | 594 | (constantenum (command-execution-status :base-type int) 595 | (#.(lispify-k-pair "CL_COMPLETE")) 596 | (#.(lispify-k-pair "CL_RUNNING")) 597 | (#.(lispify-k-pair "CL_SUBMITTED")) 598 | (#.(lispify-k-pair "CL_QUEUED"))) 599 | 600 | (constantenum (#.(lispify "buffer_create_type") :base-type #.(lispify "__buffer_create_type")) 601 | (#.(lispify-k-pair "CL_BUFFER_CREATE_TYPE_REGION"))) 602 | 603 | (constantenum (#.(lispify "profiling_info") :base-type #.(lispify "__profiling_info")) 604 | (#.(lispify-k-pair "CL_PROFILING_COMMAND_QUEUED")) 605 | (#.(lispify-k-pair "CL_PROFILING_COMMAND_SUBMIT")) 606 | (#.(lispify-k-pair "CL_PROFILING_COMMAND_START")) 607 | (#.(lispify-k-pair "CL_PROFILING_COMMAND_END")) 608 | (#.(lispify-k-pair "CL_PROFILING_COMMAND_COMPLETE"))) 609 | 610 | -------------------------------------------------------------------------------- /0.bindings-src/2-4-grovel-cl.lisp: -------------------------------------------------------------------------------- 1 | ;;; groveller file 2 | 3 | (in-package #:eazy-opencl.grovel) 4 | 5 | #+darwin 6 | (include "OpenCL/cl.h") 7 | #-darwin 8 | (include "CL/cl.h") 9 | 10 | #+darwin 11 | (include "OpenCL/cl_ext.h") 12 | #-darwin 13 | (include "CL/cl_ext.h") 14 | 15 | ;;; types 16 | 17 | (ctype #.(lispify "intptr_t") "intptr_t") 18 | (ctype #.(lispify "uintptr_t") "uintptr_t") 19 | (ctype #.(lispify "size_t") "size_t") 20 | (ctype #.(lispify "ptrdiff_t") "ptrdiff_t") 21 | 22 | (ctype #.(lispify "platform_id") "cl_platform_id") 23 | (ctype #.(lispify "__device_id") "cl_device_id") 24 | (ctype #.(lispify "__context") "cl_context") 25 | (ctype #.(lispify "__command_queue") "cl_command_queue") 26 | (ctype #.(lispify "__mem") "cl_mem") 27 | (ctype #.(lispify "__program") "cl_program") 28 | (ctype #.(lispify "__kernel") "cl_kernel") 29 | (ctype #.(lispify "__event") "cl_event") 30 | (ctype #.(lispify "__sampler") "cl_sampler") 31 | 32 | ;; /* WARNING! Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */ 33 | (ctype #.(lispify "__bool") "cl_bool") 34 | 35 | (ctype #.(lispify "bitfield") "cl_bitfield") 36 | 37 | ;;; enum/bitfield types. These are used as the base-type of 38 | ;;; enum/bitfield. See 2-4-grovel-cl-enum.lisp for examples 39 | 40 | (ctype #.(lispify "__device_type") "cl_device_type") 41 | (ctype #.(lispify "__platform_info") "cl_platform_info") 42 | (ctype #.(lispify "__device_info") "cl_device_info") 43 | (ctype #.(lispify "__device_fp_config") "cl_device_fp_config") 44 | (ctype #.(lispify "__device_mem_cache_type") "cl_device_mem_cache_type") 45 | (ctype #.(lispify "__device_local_mem_type") "cl_device_local_mem_type") 46 | (ctype #.(lispify "__device_exec_capabilities") "cl_device_exec_capabilities") 47 | #+opencl-2.0 48 | (ctype #.(lispify "__device_svm_capabilities") "cl_device_svm_capabilities") 49 | (ctype #.(lispify "__command_queue_properties") "cl_command_queue_properties") 50 | (ctype #.(lispify "__device_partition_property") "cl_device_partition_property") 51 | (ctype #.(lispify "__device_affinity_domain") "cl_device_affinity_domain") 52 | (ctype #.(lispify "__context_properties") "cl_context_properties") 53 | (ctype #.(lispify "__context_info") "cl_context_info") 54 | #+opencl-2.0 55 | (ctype #.(lispify "__queue_properties") "cl_queue_properties") 56 | (ctype #.(lispify "__command_queue_info") "cl_command_queue_info") 57 | (ctype #.(lispify "__channel_order") "cl_channel_order") 58 | (ctype #.(lispify "__channel_type") "cl_channel_type") 59 | (ctype #.(lispify "__mem_flags") "cl_mem_flags") 60 | #+opencl-2.0 61 | (ctype #.(lispify "__svm_mem_flags") "cl_svm_mem_flags") 62 | (ctype #.(lispify "__mem_object_type") "cl_mem_object_type") 63 | (ctype #.(lispify "__mem_info") "cl_mem_info") 64 | (ctype #.(lispify "__mem_migration_flags") "cl_mem_migration_flags") 65 | (ctype #.(lispify "__image_info") "cl_image_info") 66 | (ctype #.(lispify "__buffer_create_type") "cl_buffer_create_type") 67 | (ctype #.(lispify "__addressing_mode") "cl_addressing_mode") 68 | (ctype #.(lispify "__filter_mode") "cl_filter_mode") 69 | (ctype #.(lispify "__sampler_info") "cl_sampler_info") 70 | (ctype #.(lispify "__map_flags") "cl_map_flags") 71 | #+opencl-2.0 72 | (ctype #.(lispify "__pipe_properties") "cl_pipe_properties") 73 | #+opencl-2.0 74 | (ctype #.(lispify "__pipe_info") "cl_pipe_info") 75 | (ctype #.(lispify "__program_info") "cl_program_info") 76 | (ctype #.(lispify "__program_build_info") "cl_program_build_info") 77 | (ctype #.(lispify "__program_binary_type") "cl_program_binary_type") 78 | (ctype #.(lispify "__build_status") "cl_build_status") 79 | (ctype #.(lispify "__kernel_info") "cl_kernel_info") 80 | (ctype #.(lispify "__kernel_arg_info") "cl_kernel_arg_info") 81 | (ctype #.(lispify "__kernel_arg_address_qualifier") "cl_kernel_arg_address_qualifier") 82 | (ctype #.(lispify "__kernel_arg_access_qualifier") "cl_kernel_arg_access_qualifier") 83 | (ctype #.(lispify "__kernel_arg_type_qualifier") "cl_kernel_arg_type_qualifier") 84 | (ctype #.(lispify "__kernel_work_group_info") "cl_kernel_work_group_info") 85 | #+opencl-2.1 86 | (ctype #.(lispify "__kernel_sub_group_info") "cl_kernel_sub_group_info") 87 | (ctype #.(lispify "__event_info") "cl_event_info") 88 | (ctype #.(lispify "__command_type") "cl_command_type") 89 | (ctype #.(lispify "__profiling_info") "cl_profiling_info") 90 | #+opencl-2.0 91 | (ctype #.(lispify "__sampler_properties") "cl_sampler_properties") 92 | #+opencl-2.0 93 | (ctype #.(lispify "__kernel_exec_info") "cl_kernel_exec_info") 94 | 95 | -------------------------------------------------------------------------------- /0.bindings-src/2-5-grovel-buffer.lisp: -------------------------------------------------------------------------------- 1 | ;; groveller file 2 | 3 | (in-package #:eazy-opencl.grovel) 4 | 5 | #+darwin 6 | (include "OpenCL/cl.h") 7 | #-darwin 8 | (include "CL/cl.h") 9 | 10 | (cstruct #.(lispify "buffer_region") "cl_buffer_region" 11 | (:origin "origin" :type size-t) 12 | (:origin "size" :type size-t)) 13 | 14 | -------------------------------------------------------------------------------- /0.bindings-src/2-6-grovel-image.lisp: -------------------------------------------------------------------------------- 1 | ;; groveller file, TBP 2 | 3 | ;; 5.3 Image objects 4 | (in-package #:eazy-opencl.grovel) 5 | 6 | #+darwin 7 | (include "OpenCL/cl.h") 8 | #-darwin 9 | (include "CL/cl.h") 10 | 11 | (cstruct image-format "cl_image_format" 12 | (:channel-order "image_channel_order" :type #.(lispify "channel_order")) 13 | (:channel-data-type "image_channel_data_type" :type #.(lispify "channel_type"))) 14 | 15 | (cstruct image-desc "cl_image_desc" 16 | (#.(lispify-k "image_type") "image_type" :type #.(lispify "mem_object_type")) 17 | (#.(lispify-k "image_width") "image_width" :type size-t) 18 | (#.(lispify-k "image_height") "image_height" :type size-t) 19 | (#.(lispify-k "image_depth") "image_depth" :type size-t) 20 | (#.(lispify-k "image_array_size") "image_array_size" :type size-t) 21 | (#.(lispify-k "image_row_pitch") "image_row_pitch" :type size-t) 22 | (#.(lispify-k "image_slice_pitch") "image_slice_pitch" :type size-t) 23 | (#.(lispify-k "num_mip_levels") "num_mip_levels" :type uint) 24 | (#.(lispify-k "num_samples") "num_samples" :type uint) 25 | (#-opencl-2.0 :buffer 26 | #-opencl-2.0 "buffer" 27 | #+opencl-2.0 #.(lispify-k "mem_object") 28 | #+opencl-2.0 "mem_object" 29 | :type --mem)) 30 | 31 | -------------------------------------------------------------------------------- /0.bindings-src/3-0-package.lisp: -------------------------------------------------------------------------------- 1 | (defpackage :eazy-opencl.bindings 2 | (:use :cl :cffi :%ocl/g :trivial-garbage :alexandria) 3 | (:shadow :float :char) 4 | (:nicknames :%ocl) 5 | #.(let ((acc '(:export))) 6 | (do-external-symbols (s :%ocl/g (nreverse acc)) 7 | (push s acc))) 8 | (:export 9 | #:buffer 10 | #:sub-buffer 11 | #:image 12 | #:pipe 13 | :command-queue 14 | :context 15 | :device-id 16 | :event 17 | :kernel 18 | :mem 19 | :program 20 | :sampler 21 | :bool 22 | #:opencl-error 23 | #:opencl-error-code 24 | #:*defined-opencl-functions*) 25 | (:export 26 | :boxed-command-queue 27 | :boxed-context 28 | :boxed-device-id 29 | :boxed-event 30 | :boxed-kernel 31 | :boxed-mem 32 | :boxed-program 33 | :boxed-sampler 34 | :boxed-buffer 35 | :boxed-image 36 | :boxed-pipe 37 | :boxed-sub-buffer 38 | :finalize-box) 39 | (:export 40 | ;; function bindings 41 | :get-platform-ids 42 | :get-platform-info 43 | ;; 44 | :get-device-ids 45 | :get-device-info 46 | :release-device 47 | ;; 48 | :create-context 49 | :create-context-from-type 50 | :release-context 51 | :get-context-info 52 | ;; 53 | :create-command-queue 54 | :create-command-queue-with-properties 55 | :release-command-queue 56 | :get-command-queue-info 57 | :set-command-queue-property 58 | :enqueue-marker 59 | :enqueue-barrier 60 | :enqueue-wait-for-events 61 | :enqueue-marker-with-wait-list 62 | :enqueue-barrier-with-wait-list 63 | ;; 64 | :create-buffer 65 | :create-sub-buffer 66 | :enqueue-read-buffer 67 | :enqueue-write-buffer 68 | :enqueue-copy-buffer 69 | :enqueue-map-buffer 70 | :enqueue-read-buffer-rect 71 | :enqueue-write-buffer-rect 72 | :enqueue-copy-buffer-rect 73 | :enqueue-fill-buffer 74 | ;; 75 | :get-image-info 76 | :create-image 77 | :create-image-2d 78 | :create-image-3d 79 | :get-supported-image-formats 80 | :enqueue-write-image 81 | :enqueue-copy-image-to-buffer 82 | :enqueue-map-image 83 | :enqueue-read-image 84 | :enqueue-copy-buffer-to-image 85 | :enqueue-copy-image 86 | :enqueue-fill-image 87 | ;; 88 | :create-pipe 89 | :get-pipe-info 90 | ;; 91 | :release-mem-object 92 | :get-mem-object-info 93 | :enqueue-unmap-mem-object 94 | :set-mem-object-destructor-callback 95 | :enqueue-migrate-mem-objects 96 | ;; 97 | :create-sampler 98 | :create-sampler-with-properties 99 | :release-sampler 100 | :get-sampler-info 101 | ;; 102 | :create-program-with-source 103 | :create-program-with-binary 104 | :create-program-with-builtin-kernels 105 | :create-program-with-IL 106 | :release-program 107 | :get-program-info 108 | :build-program 109 | :compile-program 110 | :link-program 111 | :get-program-build-info 112 | ;; 113 | :create-kernel 114 | :create-kernels-in-program 115 | :release-kernel 116 | :set-kernel-arg 117 | :set-kernel-arg-svm-pointer 118 | :get-kernel-info 119 | :set-kernel-exec-info 120 | :get-kernel-work-group-info 121 | :get-kernel-arg-info 122 | :get-kernel-sub-group-info 123 | :enqueue-task 124 | :enqueue-nd-range-kernel 125 | :enqueue-native-kernel 126 | ;; 127 | :release-event 128 | :wait-for-events 129 | :get-event-info 130 | :get-event-profiling-info 131 | :create-user-event 132 | :set-user-event-status 133 | :set-event-callback 134 | ;; 135 | :flush 136 | :finish 137 | :unload-compiler 138 | :unload-platform-compiler 139 | :get-host-timer 140 | :get-device-and-host-timer)) 141 | 142 | -------------------------------------------------------------------------------- /0.bindings-src/3-1-translators.lisp: -------------------------------------------------------------------------------- 1 | ;;; translator 2 | (in-package :eazy-opencl.bindings) 3 | 4 | ;;; bool 5 | 6 | (define-foreign-type bool-type () 7 | () 8 | (:actual-type --bool) 9 | (:simple-parser bool)) 10 | 11 | (defmethod translate-to-foreign (lispobj (type bool-type)) 12 | (if lispobj true false)) 13 | 14 | (defmethod translate-from-foreign (c-obj (type bool-type)) 15 | (= c-obj true)) 16 | 17 | ;;; error-code 18 | 19 | (define-foreign-type error-code-type () 20 | () 21 | (:actual-type --error-code) 22 | (:simple-parser error-code)) 23 | 24 | (define-condition opencl-error (error) 25 | ((code :accessor opencl-error-code 26 | :initarg :code 27 | :initform (error 'simple-program-error 28 | :format-control "Missing required argument: :CODE"))) 29 | (:report (lambda (c s) 30 | (with-slots (code) c 31 | (format s "OpenCL error ~s" code))))) 32 | 33 | (defmethod print-object ((c opencl-error) s) 34 | (print-unreadable-object (c s :type t) 35 | (with-slots (code) c 36 | (format s ":code ~s" code)))) 37 | 38 | (defmethod translate-from-foreign (c-obj (type error-code-type)) 39 | (let ((code (foreign-enum-keyword '--error-code c-obj))) 40 | (if (eq code :success) 41 | :success 42 | (error 'opencl-error :code code)))) 43 | 44 | ;;; OpenCL objects e.g. program, context 45 | 46 | (defstruct box 47 | (value 0 :read-only t)) 48 | 49 | (defgeneric finalize-box (boxed-object) 50 | (:documentation "Finalize a boxed OpenCL object") 51 | (:method (any) 52 | "Default method, does nothing." 53 | any)) 54 | 55 | (defmacro define-cl-object-type (type &key 56 | (actual-type (symbolicate '-- type)) 57 | (releaser (symbolicate 'release- type)) 58 | (inherit 'box)) 59 | (let* ((translator (symbolicate type '-type)) 60 | (box (symbolicate 'boxed- type)) 61 | (unbox (symbolicate box '-value))) 62 | `(progn 63 | (define-foreign-type ,translator () 64 | () 65 | (:actual-type ,actual-type) 66 | (:simple-parser ,type)) 67 | (defstruct (,box (:include ,inherit) (:constructor ,box (value)))) 68 | (defmethod translate-to-foreign ((lisp-obj ,box) (type ,translator)) 69 | (,unbox lisp-obj)) 70 | (defmethod finalize-box ((lisp-obj ,box)) 71 | (finalize lisp-obj 72 | (let ((c-obj (,unbox lisp-obj))) 73 | (lambda () 74 | ;; FIXME: this notinline is here because 75 | ;; ,realeaser is later declared inline, and sbcl 76 | ;; complains it. For a better solution 77 | ;; delay the definition of translate-from-foreign. 78 | (declare (notinline ,releaser)) 79 | (format *trace-output* "~&Releasing ~a ~a" ',type c-obj) 80 | (handler-case 81 | (,releaser c-obj) 82 | (opencl-error (c) 83 | (print c *error-output*))))))) 84 | (defmethod translate-from-foreign (c-obj (type ,translator)) 85 | (,box c-obj))))) 86 | 87 | (define-cl-object-type command-queue) 88 | (define-cl-object-type context) 89 | (define-cl-object-type device-id :releaser release-device) 90 | (define-cl-object-type event) 91 | (define-cl-object-type kernel) 92 | (define-cl-object-type mem :releaser release-mem-object) 93 | (define-cl-object-type program) 94 | (define-cl-object-type sampler) 95 | 96 | ;; TODO: rewrite mem to specialized versions 97 | (define-cl-object-type buffer 98 | :actual-type mem 99 | :releaser release-mem-object 100 | :inherit boxed-mem) 101 | (define-cl-object-type image 102 | :actual-type mem 103 | :releaser release-mem-object 104 | :inherit boxed-mem) 105 | (define-cl-object-type pipe 106 | :actual-type mem 107 | :releaser release-mem-object 108 | :inherit boxed-mem) 109 | (define-cl-object-type sub-buffer 110 | :actual-type buffer 111 | :releaser release-mem-object 112 | :inherit boxed-buffer) 113 | -------------------------------------------------------------------------------- /0.bindings-src/3-2-bindings.lisp: -------------------------------------------------------------------------------- 1 | ;;; Ordered in create-release-retain-get/set-info order 2 | 3 | (in-package :eazy-opencl.bindings) 4 | 5 | (defparameter *defined-opencl-functions* nil) 6 | 7 | (defmacro defclfun (&whole whole lisp-and-c-name return-type &body args) 8 | (let ((lname (second lisp-and-c-name))) 9 | `(progn 10 | (push ',(cdr whole) *defined-opencl-functions*) 11 | (declaim (inline ,lname)) 12 | (defcfun ,lisp-and-c-name ,return-type ,@args) 13 | (declaim (notinline ,lname))))) 14 | 15 | ;;; platform 16 | (defclfun ("clGetPlatformIDs" get-platform-ids) error-code 17 | (num-entries uint) 18 | (platforms (:pointer platform-id)) 19 | (num-platforms (:pointer uint))) 20 | 21 | (defclfun ("clGetPlatformInfo" get-platform-info) error-code 22 | (platform platform-id) 23 | (param-name platform-info) 24 | (param-value-size size-t) 25 | (param-value (:pointer :void)) 26 | (param-value-size-ret (:pointer size-t))) 27 | 28 | ;;; device 29 | (defclfun ("clGetDeviceIDs" get-device-ids) error-code 30 | (platform platform-id) 31 | (device-type device-type) 32 | (num-entries uint) 33 | (devices (:pointer device-id)) 34 | (num-devices (:pointer uint))) 35 | 36 | (defclfun ("clGetDeviceInfo" get-device-info) error-code 37 | (device device-id) 38 | (param-name device-info) 39 | (param-value-size size-t) 40 | (param-value (:pointer :void)) 41 | (param-value-size-ret (:pointer size-t))) 42 | 43 | (defclfun ("clReleaseDevice" release-device) error-code 44 | (device --device-id)) 45 | 46 | ;;; context 47 | (defclfun ("clCreateContext" create-context) context 48 | (properties (:pointer context-properties)) 49 | (num-devices uint) 50 | (devices (:pointer device-id)) 51 | (pfn-notify :pointer) ;; fixme: full type? 52 | (user-data (:pointer :void)) 53 | (errcode-ret (:pointer error-code))) 54 | 55 | (defclfun ("clCreateContextFromType" create-context-from-type) context 56 | (properties (:pointer context-properties)) 57 | (device-type device-type) 58 | (pfn-notify :pointer) ;; type? 59 | (user-data (:pointer :void)) 60 | (errcode-ret (:pointer error-code))) 61 | 62 | (defclfun ("clReleaseContext" release-context) error-code 63 | (context --context)) 64 | 65 | (defclfun ("clGetContextInfo" get-context-info) error-code 66 | (context context) 67 | (param-name context-info) 68 | (param-value-size size-t) 69 | (param-value (:pointer :void)) 70 | (param-value-size-ret (:pointer size-t)));;; program 71 | 72 | 73 | ;;; queue 74 | 75 | ;; #-opencl-2.0 76 | (defclfun ("clCreateCommandQueue" create-command-queue) command-queue 77 | (context context) 78 | (device device-id) 79 | (properties command-queue-properties) 80 | (errcode-ret (:pointer error-code))) 81 | 82 | #+opencl-2.0 83 | (defclfun ("clCreateCommandQueueWithProperties" create-command-queue-with-properties) command-queue 84 | (context context) 85 | (device device-id) 86 | (properties (:pointer queue-properties)) 87 | (errcode-ret (:pointer error-code))) 88 | 89 | (defclfun ("clReleaseCommandQueue" release-command-queue) error-code 90 | (command-queue --command-queue)) 91 | 92 | (defclfun ("clGetCommandQueueInfo" get-command-queue-info) error-code 93 | (command-queue command-queue) 94 | (param-name command-queue-info) 95 | (param-value-size size-t) 96 | (param-value (:pointer :void)) 97 | (param-value-size-ret (:pointer size-t))) 98 | 99 | ;; #-opencl-1.1 100 | (defclfun ("clSetCommandQueueProperty" set-command-queue-property) 101 | error-code 102 | (command-queue command-queue) 103 | (properties command-queue-properties) 104 | (enable bool) 105 | (old-properties (:pointer command-queue-properties))) 106 | 107 | ;; #-opencl-1.2 108 | (defclfun ("clEnqueueMarker" enqueue-marker) error-code 109 | (command-queue command-queue) 110 | (event (:pointer event))) 111 | 112 | ;; #-opencl-1.2 113 | (defclfun ("clEnqueueBarrier" enqueue-barrier) error-code 114 | (command-queue command-queue)) 115 | 116 | 117 | ;; #-opencl-1.2 118 | (defclfun ("clEnqueueWaitForEvents" enqueue-wait-for-events) error-code 119 | (command-queue command-queue) 120 | (num-events uint) 121 | (event-list (:pointer event))) 122 | 123 | #+opencl-1.2 124 | (defclfun ("clEnqueueMarkerWithWaitList" enqueue-marker-with-wait-list) error-code 125 | (command-queue command-queue) 126 | (num-events-in-wait-list uint) 127 | (event-wait-list :pointer) 128 | (event (:pointer event))) 129 | 130 | #+opencl-1.2 131 | (defclfun ("clEnqueueBarrierWithWaitList" enqueue-barrier-with-wait-list) error-code 132 | (command-queue command-queue) 133 | (num-events-in-wait-list uint) 134 | (event-wait-list :pointer) 135 | (event (:pointer event))) 136 | 137 | ;;; buffer 138 | 139 | 140 | (defclfun ("clCreateBuffer" create-buffer) buffer 141 | (context context) 142 | (flags mem-flags) 143 | (size size-t) 144 | (host-ptr (:pointer :void)) 145 | (errcode-ret (:pointer error-code))) 146 | 147 | #+opencl-1.1 148 | (defclfun ("clCreateSubBuffer" create-sub-buffer) sub-buffer 149 | (buffer buffer) 150 | (flags mem-flags) 151 | (buffer-create-type buffer-create-type) 152 | (buffer-create-info (:pointer :void)) 153 | (errcode-ret (:pointer error-code))) 154 | 155 | (defclfun ("clEnqueueReadBuffer" enqueue-read-buffer) error-code 156 | (command-queue command-queue) 157 | (buffer buffer) 158 | (blocking-read-p bool) 159 | (offset size-t) 160 | (size size-t) 161 | (ptr (:pointer :void)) 162 | (num-events-in-wait-list uint) 163 | (event-wait-list (:pointer event)) 164 | (event (:pointer event))) 165 | 166 | (defclfun ("clEnqueueWriteBuffer" enqueue-write-buffer) error-code 167 | (command-queue command-queue) 168 | (buffer buffer) 169 | (blocking-write-p bool) 170 | (offset size-t) 171 | (size size-t) 172 | (ptr (:pointer :void)) 173 | (num-events-in-wait-list uint) 174 | (event-wait-list (:pointer event)) 175 | (event (:pointer event))) 176 | 177 | (defclfun ("clEnqueueCopyBuffer" enqueue-copy-buffer) error-code 178 | (command-queue command-queue) 179 | (src-buffer buffer) 180 | (dst-buffer buffer) 181 | (src-offset size-t) 182 | (dst-offset size-t) 183 | (size size-t) 184 | (num-events-in-wait-list uint) 185 | (event-wait-list (:pointer event)) 186 | (event (:pointer event))) 187 | 188 | (defclfun ("clEnqueueMapBuffer" enqueue-map-buffer) (:pointer :void) 189 | (command-queue command-queue) 190 | (buffer buffer) 191 | (blocking-map-p bool) 192 | (map-flags map-flags) 193 | (offset size-t) 194 | (size size-t) 195 | (num-events-in-wait-list uint) 196 | (event-wait-list (:pointer event)) 197 | (event (:pointer event)) 198 | (errcode-ret (:pointer error-code))) 199 | 200 | #+opencl-1.1 201 | (defclfun ("clEnqueueReadBufferRect" enqueue-read-buffer-rect) int 202 | (command-queue command-queue) 203 | (buffer buffer) 204 | (blocking-read-p bool) 205 | (buffer-origin (:pointer size-t)) ;;[3] 206 | (host-origin (:pointer size-t)) ;;[3] 207 | (region (:pointer size-t)) ;;[3] 208 | (buffer-row-pitch size-t) 209 | (buffer-slice-pitch size-t) 210 | (host-row-pitch size-t) 211 | (host-slice-pitch size-t) 212 | (pointer (:pointer :void)) 213 | (num-events-in-wait-list uint) 214 | (event-wait-list (:pointer event)) 215 | (event (:pointer event))) 216 | 217 | #+opencl-1.1 218 | (defclfun ("clEnqueueWriteBufferRect" enqueue-write-buffer-rect) int 219 | (command-queue command-queue) 220 | (buffer buffer) 221 | (blocking-write-p bool) 222 | (buffer-origin (:pointer size-t)) ;;[3] 223 | (host-origin (:pointer size-t)) ;;[3] 224 | (region (:pointer size-t)) ;;[3] 225 | (buffer-row-pitch size-t) 226 | (buffer-slice-pitch size-t) 227 | (host-row-pitch size-t) 228 | (host-slice-pitch size-t) 229 | (pointer :pointer) 230 | (num-events-in-wait-list uint) 231 | (event-wait-list (:pointer event)) 232 | (event (:pointer event))) 233 | 234 | #+opencl-1.1 235 | (defclfun ("clEnqueueCopyBufferRect" enqueue-copy-buffer-rect) int 236 | (command-queue command-queue) 237 | (src-buffer buffer) 238 | (dst-buffer buffer) 239 | (src-origin (:pointer size-t)) ;;[3] 240 | (dst-origin (:pointer size-t)) ;;[3] 241 | (region (:pointer size-t)) ;;[3] 242 | (src-row-pitch size-t) 243 | (src-slice-pitch size-t) 244 | (dst-row-pitch size-t) 245 | (dst-slice-pitch size-t) 246 | (num-events-in-wait-list uint) 247 | (event-wait-list (:pointer event)) 248 | (event (:pointer event))) 249 | #+opencl-1.2 250 | (defclfun ("clEnqueueFillBuffer" enqueue-fill-buffer) error-code 251 | (command-queue command-queue) 252 | (buffer buffer) 253 | (pattern (:pointer :void)) 254 | (pattern-size size-t) 255 | (offset size-t) 256 | (size size-t) 257 | (num-events-in-wait-list uint) 258 | (event-wait-list :pointer) 259 | (event (:pointer event))) 260 | ;;; image 261 | 262 | (defclfun ("clGetImageInfo" get-image-info) error-code 263 | (image image) 264 | (param-name image-info) 265 | (param-value-size size-t) 266 | (param-value (:pointer :void)) 267 | (param-value-size-ret (:pointer size-t))) 268 | 269 | #+opencl-1.2 270 | (defclfun ("clCreateImage" create-image) image 271 | (context context) 272 | (flags mem-flags) 273 | (image-format (:pointer (:struct image-format))) 274 | (image-desc (:pointer (:struct image-desc))) 275 | (host-ptr (:pointer :void)) 276 | (errcode-ret (:pointer error-code))) 277 | 278 | ;; #-opencl-1.2 279 | (defclfun ("clCreateImage2D" create-image-2d) image 280 | (context context) 281 | (flags mem-flags) 282 | (image-format (:pointer (:struct image-format))) 283 | (image-width size-t) 284 | (image-height size-t) 285 | (image-row-pitch size-t) 286 | (host-ptr (:pointer :void)) 287 | (errcode-ret (:pointer error-code))) 288 | 289 | ;; #-opencl-1.2 290 | (defclfun ("clCreateImage3D" create-image-3d) image 291 | (context context) 292 | (flags mem-flags) 293 | (image-format :pointer) 294 | (image-width size-t) 295 | (image-height size-t) 296 | (image-depth size-t) 297 | (image-row-pitch size-t) 298 | (image-slice-pitch size-t) 299 | (host-ptr (:pointer :void)) 300 | (error-code-ret (:pointer error-code))) 301 | 302 | (defclfun ("clGetSupportedImageFormats" get-supported-image-formats) 303 | error-code 304 | (context context) 305 | (flags mem-flags) 306 | (image-type mem-object-type) 307 | (num-entries uint) 308 | (image-formats (:pointer (:struct image-format))) 309 | (num-image-format (:pointer uint))) 310 | 311 | (defclfun ("clEnqueueWriteImage" enqueue-write-image) error-code 312 | (command-queue command-queue) 313 | (image image) 314 | (blocking-write bool) 315 | (origin (:pointer size-t)) ;; todo: special type for these size_t[3] args? 316 | (region (:pointer size-t)) 317 | (input-row-pitch size-t) 318 | (input-slice-pitch size-t) 319 | (ptr (:pointer :void)) 320 | (num-events-in-wait-list uint) 321 | (event-wait-list (:pointer event)) 322 | (event (:pointer event))) 323 | 324 | (defclfun ("clEnqueueCopyImageToBuffer" enqueue-copy-image-to-buffer) 325 | error-code 326 | (command-queue command-queue) 327 | (src-image image) 328 | (dst-buffer buffer) 329 | (src-origin (:pointer size-t)) 330 | (region (:pointer size-t)) 331 | (dst-offset size-t) 332 | (num-events-in-wait-list uint) 333 | (event-wait-list (:pointer event)) 334 | (event (:pointer event))) 335 | 336 | (defclfun ("clEnqueueMapImage" enqueue-map-image) (:pointer :void) 337 | (command-queue command-queue) 338 | (image image) 339 | (blocking-map bool) 340 | (map-flags map-flags) 341 | (origin (:pointer size-t)) ;; [3] 342 | (region (:pointer size-t)) ;; [3] 343 | (image-row-pitch (:pointer size-t)) 344 | (image-slice-pitch (:pointer size-t)) 345 | (num-events-in-wait-list uint) 346 | (event-wait-list (:pointer event)) 347 | (event (:pointer event)) 348 | (errcode-ret (:pointer error-code))) 349 | 350 | (defclfun ("clEnqueueReadImage" enqueue-read-image) error-code 351 | (command-queue command-queue) 352 | (image image) 353 | (blocking-read bool) 354 | (origin (:pointer size-t)) ;;[3] 355 | (region (:pointer size-t)) ;;[3] 356 | (row-pitch size-t) 357 | (slice-pitch size-t) 358 | (ptr (:pointer :void)) 359 | (num-events-in-wait-list uint) 360 | (event-wait-list (:pointer event)) 361 | (event (:pointer event))) 362 | 363 | 364 | (defclfun ("clEnqueueCopyBufferToImage" enqueue-copy-buffer-to-image) 365 | error-code 366 | (command-queue command-queue) 367 | (src-buffer buffer) 368 | (dst-image image) 369 | (src-offset size-t) 370 | (dst-origin (:pointer size-t)) ;;[3] 371 | (region (:pointer size-t)) ;;[3] 372 | (num-events-in-wait-list uint) 373 | (event-wait-list (:pointer event)) 374 | (event (:pointer event))) 375 | 376 | (defclfun ("clEnqueueCopyImage" enqueue-copy-image) error-code 377 | (command-queue command-queue) 378 | (src-image image) 379 | (dst-image image) 380 | (src-origin (:pointer size-t)) ;;[3] 381 | (dst-origin (:pointer size-t)) ;;[3] 382 | (region (:pointer size-t)) ;;[3] 383 | (num-events-in-wait-list uint) 384 | (event-wait-list (:pointer event)) 385 | (event (:pointer event))) 386 | #+opencl-1.2 387 | (defclfun ("clEnqueueFillImage" enqueue-fill-image) error-code 388 | (command-queue command-queue) 389 | (image image) 390 | (fill-color (:pointer :void)) 391 | (origin (:pointer size-t)) 392 | (region (:pointer size-t)) 393 | (num-events-in-wait-list uint) 394 | (event-wait-list :pointer) 395 | (event (:pointer event))) 396 | 397 | ;;; pipe 398 | 399 | #+opencl-2.0 400 | (defclfun ("clCreatePipe" create-pipe) pipe 401 | (context context) 402 | (flags mem-flags) 403 | (pipe-packet-size (:pointer uint)) 404 | (pipe-max-packets (:pointer uint)) 405 | (properties (:pointer pipe-properties)) 406 | (errcode-ret (:pointer error-code))) 407 | 408 | #+opencl-2.0 409 | (defclfun ("clGetPipeInfo" get-pipe-info) error-code 410 | (pipe pipe) 411 | (param-name pipe-info) 412 | (param-value-size size-t) 413 | (param-value (:pointer :void)) 414 | (param-value-size-ret (:pointer size-t))) 415 | 416 | ;;; mem 417 | 418 | (defclfun ("clReleaseMemObject" release-mem-object) error-code 419 | (memobj --mem)) 420 | (defclfun ("clGetMemObjectInfo" get-mem-object-info) error-code 421 | (memobj mem) 422 | (param-name mem-info) 423 | (param-value-size size-t) 424 | (param-value (:pointer :void)) 425 | (param-value-size-ret (:pointer size-t))) 426 | 427 | #+opencl-1.1 428 | (defclfun ("clSetMemObjectDestructorCallback" set-mem-object-destructor-callback) int 429 | (memobj mem) 430 | (callback :pointer) 431 | (user-data (:pointer :void))) 432 | 433 | (defclfun ("clEnqueueUnmapMemObject" enqueue-unmap-mem-object) error-code 434 | (command-queue command-queue) 435 | (memobj mem) 436 | (mapped-ptr (:pointer :void)) 437 | (num-events-in-wait-list uint) 438 | (event-wait-list (:pointer event)) 439 | (event (:pointer event))) 440 | #+opencl-1.2 441 | (defclfun ("clEnqueueMigrateMemObjects" enqueue-migrate-mem-objects) error-code 442 | (command-queue command-queue) 443 | (num-mem-objects uint) 444 | (mem-objects (:pointer mem)) 445 | (flags mem-migration-flags) 446 | (num-events-in-wait-list uint) 447 | (event-wait-list :pointer) 448 | (event (:pointer event))) 449 | 450 | 451 | ;;; Shared Virtual Memory : TODO 452 | 453 | ;;; sampler 454 | 455 | ;; #-opencl-2.0 456 | (defclfun ("clCreateSampler" create-sampler) sampler 457 | (context context) 458 | (normalized-coords bool) 459 | (addressing-mode addressing-mode) 460 | (filter-mode filter-mode) 461 | (errcode-ret (:pointer error-code))) 462 | 463 | #+opencl-2.0 464 | (defclfun ("clCreateSamplerWithProperties" create-sampler-with-properties) sampler 465 | (context context) 466 | (sampler-properties sampler-properties) 467 | (errcode-ret (:pointer error-code))) 468 | 469 | (defclfun ("clReleaseSampler" release-sampler) error-code 470 | (sampler --sampler)) 471 | 472 | 473 | (defclfun ("clGetSamplerInfo" get-sampler-info) error-code 474 | (sampler sampler) 475 | (param-name sampler-info) 476 | (param-value-size size-t) 477 | (param-value (:pointer :void)) 478 | (param-value-size-ret (:pointer size-t))) 479 | 480 | ;;; program 481 | (defclfun ("clCreateProgramWithSource" create-program-with-source) program 482 | (context context) 483 | (count uint) 484 | (strings (:pointer :string)) 485 | (lengths (:pointer size-t)) 486 | (errcode-ret (:pointer error-code))) 487 | 488 | (defclfun ("clCreateProgramWithBinary" create-program-with-binary) program 489 | (context context) 490 | (num-devices uint) 491 | (device-list (:pointer device-id)) 492 | (lengths (:pointer size-t)) 493 | (binaries (:pointer (:pointer :unsigned-char))) 494 | (binary-status (:pointer int)) 495 | (errcode-ret (:pointer error-code))) 496 | 497 | (defclfun ("clCreateProgramWithBuiltInKernels" create-program-with-builtin-kernels) program 498 | (context context) 499 | (num-devices uint) 500 | (device-list (:pointer device-id)) 501 | (kernel-names :string) 502 | (errcode-ret (:pointer error-code))) 503 | 504 | #+opencl-2.1 505 | (defclfun ("clCreateProgramWithIL" create-program-with-IL) program 506 | (context context) 507 | (il (:pointer :void)) 508 | (lengths (:pointer size-t)) 509 | (errcode-ret (:pointer error-code))) 510 | 511 | 512 | 513 | (defclfun ("clReleaseProgram" release-program) error-code 514 | (program --program)) 515 | 516 | (defclfun ("clGetProgramInfo" get-program-info) error-code 517 | (program program) 518 | (param-name program-info) 519 | (param-value-size size-t) 520 | (param-value (:pointer :void)) 521 | (param-value-size-ret (:pointer size-t))) 522 | 523 | (defclfun ("clBuildProgram" build-program) error-code 524 | (program program) 525 | (num-devices uint) 526 | (device-list (:pointer device-id)) 527 | (options :string) 528 | (pfn-notify :pointer) ;; FIXME: function pointer type 529 | (user-data (:pointer :void))) 530 | #+opencl-1.2 531 | (defclfun ("clCompileProgram" compile-program) error-code 532 | (program program) 533 | (num-devices uint) 534 | (device-list (:pointer device-id)) 535 | (options :string) 536 | (num-input-headers uint) 537 | (input-headers (:pointer program)) 538 | (header-include-names (:pointer :string)) 539 | (pfn-notify :pointer) ;; FIXME: function pointer type 540 | (user-data (:pointer :void))) 541 | #+opencl-1.2 542 | (defclfun ("clLinkProgram" link-program) program 543 | (context context) 544 | (num-devices uint) 545 | (device-list (:pointer device-id)) 546 | (options :string) 547 | (num-input-programs uint) 548 | (input-programs (:pointer program)) 549 | (pfn-notify :pointer) ;; FIXME: function pointer type 550 | (user-data (:pointer :void)) 551 | (errcode-ret (:pointer error-code))) 552 | 553 | (defclfun ("clGetProgramBuildInfo" get-program-build-info) error-code 554 | (program program) 555 | (device device-id) 556 | (param-name program-build-info) 557 | (param-value-size size-t) 558 | (param-value (:pointer :void)) 559 | (param-value-size-ret (:pointer size-t))) 560 | ;;; kernel 561 | (defclfun ("clCreateKernel" create-kernel) kernel 562 | (program program) 563 | (kernel-name :string) 564 | (errcode-ret (:pointer error-code))) 565 | 566 | (defclfun ("clCreateKernelsInProgram" create-kernels-in-program) error-code 567 | (program program) 568 | (num-kernels uint) 569 | (kernels (:pointer kernel)) 570 | (num-kernels-ret (:pointer uint))) 571 | 572 | (defclfun ("clReleaseKernel" release-kernel) error-code 573 | (kernel --kernel)) 574 | 575 | 576 | (defclfun ("clSetKernelArg" set-kernel-arg) error-code 577 | (kernel kernel) 578 | (arg-index uint) 579 | (arg-size size-t) 580 | (arg-value (:pointer :void))) 581 | 582 | #+opencl-2.0 583 | (defclfun ("clSetKernelArgSVMPointer" set-kernel-arg-svm-pointer) error-code 584 | (kernel kernel) 585 | (arg-index uint) 586 | (arg-value (:pointer :void))) 587 | 588 | (defclfun ("clGetKernelInfo" get-kernel-info) error-code 589 | (kernel-name kernel) 590 | (param-name kernel-info) 591 | (param-value-size size-t) 592 | (param-value (:pointer :void)) 593 | (param-value-size-ret :pointer)) 594 | 595 | #+opencl-2.0 596 | (defclfun ("clSetKernelExecInfo" set-kernel-exec-info) error-code 597 | (kernel-name kernel) 598 | (param-name kernel-exec-info) 599 | (param-value-size size-t) 600 | (param-value (:pointer :void))) 601 | 602 | #+opencl-1.1 603 | (defclfun ("clGetKernelWorkGroupInfo" get-kernel-work-group-info) error-code 604 | (kernel kernel) 605 | (device device-id) 606 | (param-name kernel-work-group-info) 607 | (param-value-size size-t) 608 | (param-value (:pointer :void)) 609 | (param-value-size-ret (:pointer size-t))) 610 | 611 | #+opencl-1.2 612 | (defclfun ("clGetKernelArgInfo" get-kernel-arg-info) error-code 613 | (kernel-name kernel) 614 | (arg-index uint) 615 | (param-name kernel-arg-info) 616 | (param-value-size size-t) 617 | (param-value (:pointer :void)) 618 | (param-value-size-ret (:pointer size-t))) 619 | 620 | #+opencl-2.1 621 | (defclfun ("clGetKernelSubGroupInfo" get-kernel-sub-group-info) error-code 622 | (kernel kernel) 623 | (device device-id) 624 | (param-name kernel-sub-group-info) 625 | (input-value-size size-t) 626 | (input-value (:pointer :void)) 627 | (param-value-size size-t) 628 | (param-value (:pointer :void)) 629 | (param-value-size-ret (:pointer size-t))) 630 | 631 | 632 | ;; #-opencl-2.0 633 | (defclfun ("clEnqueueTask" enqueue-task) error-code 634 | (command-queue command-queue) 635 | (kernel kernel) 636 | (num-events-in-wait-list uint) 637 | (event-wait-list (:pointer event)) 638 | (event (:pointer event))) 639 | 640 | 641 | (defclfun ("clEnqueueNDRangeKernel" enqueue-nd-range-kernel) error-code 642 | (command-queue command-queue) 643 | (kernel kernel) 644 | (work-dim uint) 645 | (global-work-offset (:pointer size-t)) 646 | (global-work-size (:pointer size-t)) 647 | (local-work-size (:pointer size-t)) 648 | (num-events-in-wait-list uint) 649 | (event-wait-list (:pointer event)) 650 | (event (:pointer event))) 651 | 652 | (defclfun ("clEnqueueNativeKernel" enqueue-native-kernel) error-code 653 | (command-queue command-queue) 654 | (user-func :pointer) 655 | (args (:pointer :void)) 656 | (cb-args size-t) 657 | (num-mem-objects uint) 658 | (mem-list (:pointer mem)) 659 | (args-mem-loc (:pointer (:pointer :void))) 660 | (num-events-in-wait-list uint) 661 | (event-wait-list :pointer) ;FIXME : spec suggests (:pointer event) ... 662 | (event (:pointer event))) 663 | 664 | ;;; event 665 | (defclfun ("clReleaseEvent" release-event) error-code 666 | (event --event)) 667 | 668 | (defclfun ("clWaitForEvents" wait-for-events) error-code 669 | (num-events uint) 670 | (event-list (:pointer event))) 671 | 672 | (defclfun ("clGetEventInfo" get-event-info) error-code 673 | (event event) 674 | (param-name event-info) 675 | (param-value-size size-t) 676 | (param-value (:pointer :void)) 677 | (param-value-size-ret (:pointer size-t))) 678 | 679 | (defclfun ("clGetEventProfilingInfo" get-event-profiling-info) error-code 680 | (event event) 681 | (param-name profiling-info) 682 | (param-value-size size-t) 683 | (param-value (:pointer :void)) 684 | (param-value-size-ret (:pointer size-t))) 685 | 686 | #+opencl-1.1 687 | (defclfun ("clCreateUserEvent" create-user-event) event 688 | (context context) 689 | (errcode-ret (:pointer error-code))) 690 | 691 | #+opencl-1.1 692 | (defclfun ("clSetUserEventStatus" set-user-event-status) int 693 | (event event) 694 | (execution-status int)) 695 | 696 | #+opencl-1.1 697 | (defclfun ("clSetEventCallback" set-event-callback) int 698 | (event event) 699 | (command-exec-callback-type int) ;; CL_COMPLETE = 0x0 700 | (callback :pointer) 701 | (user-data (:pointer :void))) 702 | 703 | 704 | ;;; others 705 | 706 | (defclfun ("clFlush" flush) error-code 707 | (command-queue command-queue)) 708 | 709 | (defclfun ("clFinish" finish) error-code 710 | (command-queue command-queue)) 711 | 712 | ;; #-opencl-1.2 713 | (defclfun ("clUnloadCompiler" unload-compiler) error-code) 714 | 715 | #+opencl-1.2 716 | (defclfun ("clUnloadPlatformCompiler" unload-platform-compiler) error-code 717 | (platform platform-id)) 718 | 719 | 720 | #+opencl-2.1 721 | (defclfun ("clGetHostTimer" get-host-timer) error-code 722 | (device device-id) 723 | (host-timestamp (:pointer ulong))) 724 | 725 | #+opencl-2.1 726 | (defclfun ("clGetDeviceAndHostTimer" get-device-and-host-timer) error-code 727 | (device device-id) 728 | (device-timestamp (:pointer ulong)) 729 | (host-timestamp (:pointer ulong))) 730 | 731 | 732 | ;;; extensions 733 | 734 | ;;;; GL 735 | 736 | ;; clCreateEventFromEGLSyncKHR 737 | ;; clCreateEventFromGLsyncKHR 738 | ;; clCreateFromEGLImageKHR 739 | ;; clCreateFromGLBuffer 740 | ;; clCreateFromGLRenderbuffer 741 | ;; clCreateFromGLTexture 742 | ;; clEnqueueAcquireEGLObjectsKHR 743 | ;; clEnqueueAcquireGLObjects 744 | ;; clEnqueueReleaseEGLObjectsKHR 745 | ;; clEnqueueReleaseGLObjects 746 | ;; clGetGLObjectInfo 747 | ;; clGetGLTextureInfo 748 | 749 | ;;;; DX11, D3D 750 | 751 | ;; clCreateFromDX9MediaSurfaceKHR 752 | ;; clCreateFromD3D10BufferKHR 753 | ;; clCreateFromD3D10Texture2DKHR 754 | ;; clCreateFromD3D10Texture3DKHR 755 | ;; clCreateFromD3D11BufferKHR 756 | ;; clCreateFromD3D11Texture2DKHR 757 | ;; clCreateFromD3D11Texture3DKHR 758 | 759 | ;; clEnqueueAcquireDX9MediaSurfacesKHR 760 | ;; clEnqueueAcquireD3D10ObjectsKHR 761 | ;; clEnqueueAcquireD3D11ObjectsKHR 762 | 763 | ;; clEnqueueReleaseDX9MediaSurfacesKHR 764 | ;; clEnqueueReleaseD3D10ObjectsKHR 765 | ;; clEnqueueReleaseD3D11ObjectsKHR 766 | 767 | ;; clGetDeviceIDsFromD3D10KHR 768 | ;; clGetDeviceIDsFromD3D11KHR 769 | ;; clGetDeviceIDsFromDX9MediaAdapterKHR 770 | 771 | ;;;; others 772 | 773 | ;; clGetExtensionFunctionAddressForPlatform 774 | ;; clGetKernelInfo 775 | ;; clGetKernelSubGroupInfoKHR 776 | ;; clIcdGetPlatformIDsKHR 777 | ;; clTerminateContextKHR 778 | -------------------------------------------------------------------------------- /0.bindings-src/README: -------------------------------------------------------------------------------- 1 | unnumbered files are junk files containing 2 | the unimplemented part of cl-opencl-3b. -------------------------------------------------------------------------------- /0.bindings-src/dump-image.lisp: -------------------------------------------------------------------------------- 1 | ;; Note: the code here is taken from cl-opencl-3b. I do not understand what 2 | ;; they are doing, but it seems like something related to dumping the lisp image. 3 | ;; I do not understand the later macros either. What are they for? --- guicho 2015/10/9 4 | 5 | ;; ;; deprecated in opencl1.2? 6 | ;; (defcfun ("clGetExtensionFunctionAddress" get-extension-function-address) 7 | ;; (:pointer :void) 8 | ;; (function-name :string)) 9 | ;; 10 | ;; (eval-when (:load-toplevel :execute) 11 | ;; #+clisp (pushnew 'reset-cl-pointers custom:*fini-hooks*) 12 | ;; #+sbcl (pushnew 'reset-cl-pointers sb-ext:*save-hooks*) 13 | ;; #+cmu (pushnew 'reset-cl-pointers ext:*before-save-initializations*) 14 | ;; #-(or clisp sbcl cmu) 15 | ;; (warn "Don't know how to setup a hook before saving cores on this Lisp.")) 16 | ;; 17 | ;; (defparameter *cl-extension-resetter-list* nil) 18 | ;; ;;; FIXME? There's a possible race condition here, but this function 19 | ;; ;;; is intended to be called while saving an image, so if someone is 20 | ;; ;;; still calling CL functions we lose anyway... 21 | ;; (defun reset-cl-pointers () 22 | ;; (format t "~&;; resetting OpenCL extension pointers...~%") 23 | ;; (mapc #'funcall *cl-extension-resetter-list*) 24 | ;; (setf *cl-extension-resetter-list* nil)) 25 | -------------------------------------------------------------------------------- /0.bindings-src/extfun.lisp: -------------------------------------------------------------------------------- 1 | 2 | ;; it is here, untouched, but it doesnt seem like being used... --- guicho 2015/10/9 3 | ;; (defmacro defclextfun ((cname lname) return-type &body args) 4 | ;; (alexandria:with-unique-names (pointer) 5 | ;; `(let ((,pointer (null-pointer))) 6 | ;; (defun ,lname ,(mapcar #'car args) 7 | ;; #++(format t "call ext ~s: ~s~%" ',lname (list ,@(mapcar 'first args))) 8 | ;; (when (null-pointer-p ,pointer) 9 | ;; (setf ,pointer (get-extension-function-address ,cname)) 10 | ;; (assert (not (null-pointer-p ,pointer)) () 11 | ;; "Couldn't load symbol ~A~%" ,cname) 12 | ;; (format t "Loaded function pointer for ~A: ~A~%" ,cname ,pointer) 13 | ;; (push (lambda () (setf ,pointer (null-pointer))) 14 | ;; *cl-extension-resetter-list*)) 15 | ;; (foreign-funcall-pointer 16 | ;; ,pointer 17 | ;; (:library opencl) 18 | ;; ,@(loop for arg in args 19 | ;; collect (second arg) 20 | ;; collect (first arg)) 21 | ;; ,return-type))))) 22 | -------------------------------------------------------------------------------- /0.bindings-src/gl-binding.lisp: -------------------------------------------------------------------------------- 1 | ;; cl_khr_gl_sharing 2 | 3 | (defclextfun ("clGetGLContextInfoKHR" get-gl-context-info-khr) cl-error-codes 4 | (properties (:pointer context-properties)) 5 | (param-name gl-context-info) 6 | (param-value-size size-t) 7 | (param-value (:pointer :void)) 8 | (param-value-size-ret (:pointer size-t))) 9 | 10 | ;; cl_gl.h 11 | 12 | (defclfun ("clCreateFromGLBuffer" create-from-gl-buffer) mem 13 | (context context) 14 | (flags mem-flags) 15 | (bufobj gl-uint) 16 | (errcode-ret (:pointer cl-error-codes))) 17 | 18 | ;; #-opencl-1.2 19 | (defclfun ("clCreateFromGLTexture2D" create-from-gl-texture-2d) mem 20 | (context context) 21 | (flags mem-flags) 22 | (target gl-texture-target) 23 | (miplevel gl-int) 24 | (texture gl-uint) 25 | (errcode-ret (:pointer cl-error-codes))) 26 | 27 | ;; #-opencl-1.2 28 | (defclfun ("clCreateFromGLTexture3D" create-from-gl-texture-3d) mem 29 | (context context) 30 | (flags mem-flags) 31 | (target gl-texture-target) 32 | (miplevel gl-int) 33 | (texture gl-uint) 34 | (errcode-ret (:pointer cl-error-codes))) 35 | 36 | ;; 1.0 37 | (defclfun ("clCreateFromGLRenderbuffer" create-from-gl-renderbuffer) mem 38 | (context context) 39 | (flags mem-flags) 40 | (renderbuffer gl-uint) 41 | (errcode-ret (:pointer cl-error-codes))) 42 | 43 | ;; 1.0 44 | (defclfun ("clGetGLObjectInfo" get-gl-object-info) cl-error-codes 45 | (memobj mem) 46 | (gl-object-type (:pointer gl-object-type)) 47 | (gl-object-name (:pointer gl-uint))) 48 | 49 | ;; 1.0 50 | (defclfun ("clGetGLTextureInfo" get-gl-texture-info) cl-error-codes 51 | (memobj mem) 52 | (param-name gl-texture-info) 53 | (param-value-size size-t) 54 | (param-value (:pointer :void)) 55 | (param-value-size-ret (:pointer size-t))) 56 | 57 | ;; 1.0 58 | (defclfun ("clEnqueueAcquireGLObjects" enqueue-acquire-gl-objects) cl-error-codes 59 | (command-queue command-queue) 60 | (num-objects uint) 61 | (mem-objects (:pointer mem)) 62 | (num-events-in-wait-list uint) 63 | (event-wait-list (:pointer event)) 64 | (event (:pointer event))) 65 | 66 | ;; 1.0 67 | (defclfun ("clEnqueueReleaseGLObjects" enqueue-release-gl-objects) cl-error-codes 68 | (command-queue command-queue) 69 | (num-objects uint) 70 | (mem-objects (:pointer mem)) 71 | (num-events-in-wait-list uint) 72 | (event-wait-list (:pointer event)) 73 | (event (:pointer event))) 74 | -------------------------------------------------------------------------------- /0.bindings-src/grovel-cl_gl.lisp: -------------------------------------------------------------------------------- 1 | ;; cl_khr_gl_sharing 2 | 3 | (defcenum (gl-context-info uint) 4 | (:current-device-for-gl-context-khr #x2006) 5 | (:devices-for-gl-context-khr #x2007)) 6 | 7 | 8 | 9 | ;; cl_gl.h 10 | 11 | ;; fixme: import these from cl-opengl? 12 | ;; (would probably want to split out the GL stuff to a separate .asd if it 13 | ;; depended on cl-opengl though, so just leaving here for now) 14 | (defctype gl-enum :unsigned-int) 15 | (defctype gl-uint :unsigned-int) 16 | (defctype gl-int :int) 17 | 18 | ;; not sure if it would be better to just use gl:enum here or keep it specific 19 | (defcenum (gl-texture-target uint) 20 | (:texture-2d #x0de1) 21 | (:texture-cube-map-positive-x #x8515) 22 | (:texture-cube-map-positive-y #x8517) 23 | (:texture-cube-map-positive-z #x8519) 24 | (:texture-cube-map-negative-x #x8516) 25 | (:texture-cube-map-negative-y #x8518) 26 | (:texture-cube-map-negative-z #x851a) 27 | (:texture-rectangle #x84f5) 28 | (:texture-rectangle-arb #x84f5) 29 | (:texture-3d #x806F)) 30 | 31 | (defcenum (gl-object-type uint) 32 | (:buffer #x2000) 33 | (:texture-2d #x2001) 34 | (:texture-3d #x2002) 35 | (:renderbuffer #x2003)) 36 | 37 | (defcenum (gl-texture-info uint) 38 | (:texture-target #x2004) 39 | (:mipmap-level #x2005)) 40 | 41 | ;; clCreateContext, clCreateContextFromType, and clGetGLContextInfoKHR 42 | ;; CL_INVALID_GL_SHAREGROUP_REFERENCE_KHR 43 | ;; -1000 44 | ;; 45 | ;; clGetGLContextInfoKHR 46 | ;; CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR 47 | ;; 0x2006 48 | ;; CL_DEVICES_FOR_GL_CONTEXT_KHR 49 | ;; 0x2007 50 | 51 | ;; clCreateContext and clCreateContextFromTypeCL_GL_CONTEXT_KHR 52 | ;; CL_EGL_DISPLAY_KHR 53 | ;; CL_GLX_DISPLAY_KHR 54 | ;; CL_WGL_HDC_KHR 55 | ;; CL_CGL_SHAREGROUP_KHR 56 | 57 | ;; clCreateEventFromGLsyncKHR 58 | -------------------------------------------------------------------------------- /0.bindings-src/icd-binding.lisp: -------------------------------------------------------------------------------- 1 | 2 | ;; cl_khr_icd 3 | ;; not sure if this is actually exposed to clients or not? 4 | (defclextfun ("clIcdGetPlatformIDsKHR" icd-get-platform-ids-khr) int 5 | (num-entries uint) 6 | (platforms (:pointer platform-id)) 7 | (num-platforms (:pointer uint))) 8 | 9 | -------------------------------------------------------------------------------- /0.bindings-src/retain-api.lisp: -------------------------------------------------------------------------------- 1 | ;; (defclfun ("clRetainContext" retain-context) error-code 2 | ;; (context context)) 3 | ;; (defclfun ("clRetainCommandQueue" retain-command-queue) error-code 4 | ;; (command-queue command-queue)) 5 | ;; (defclfun ("clRetainMemObject" retain-mem-object) error-code 6 | ;; (memobj mem)) 7 | ;; (defclfun ("clRetainSampler" retain-sampler) error-code 8 | ;; (sampler sampler)) 9 | ;; (defclfun ("clRetainProgram" retain-program) error-code 10 | ;; (program program)) 11 | ;; (defclfun ("clRetainKernel" retain-kernel) error-code 12 | ;; (kernel kernel)) 13 | ;; (defclfun ("clRetainEvent" retain-event) error-code 14 | ;; (event event)) 15 | -------------------------------------------------------------------------------- /1.error-src/error-handlers.lisp: -------------------------------------------------------------------------------- 1 | (in-package :eazy-opencl.error) 2 | 3 | ;; blah blah blah. 4 | 5 | (eval-when (:compile-toplevel :load-toplevel :execute) 6 | (defun wrap-api (function-info) 7 | "Return a defun form which wraps the original function, inlining the given cffi function." 8 | (match function-info 9 | ((list* _ _ args) 10 | (if (equal '(:pointer error-code) (second (lastcar args))) 11 | (wrap-api-taking-error-ptr function-info) 12 | (trivia.skip:skip))) 13 | (_ 14 | (wrap-api-normal function-info)))) 15 | 16 | (defun wrap-api-normal (function-info &optional (wrapper #'identity)) 17 | (match function-info 18 | ((list* (list _ (and lname (symbol name))) _ args) 19 | (let ((new-args (mapcar (compose #'car #'ensure-list) args)) 20 | (new-name (intern name))) 21 | `(progn 22 | (declaim (inline ,new-name)) 23 | (defun ,new-name ,new-args 24 | (declare (inline ,lname)) 25 | ,(funcall wrapper `(,lname ,@new-args))) 26 | (declaim (notinline ,new-name))))))) 27 | 28 | (defun wrap-api-taking-error-ptr (function-info) 29 | "Takes a info of a function which takes a pointer to EAZY-OPENCL.BINDING:ERROR-CODE 30 | in its last argument, then return the wrapped code. 31 | It signals an error when the error-code stored in the pointer is not a :SUCCESS." 32 | (with-gensyms (result e) 33 | (wrap-api-normal 34 | (butlast function-info) 35 | (lambda (form) 36 | `(with-foreign-object (,e 'error-code) 37 | (let* ((,result (,@form ,e))) 38 | (mem-ref ,e 'error-code) 39 | (finalize-box ,result)))))))) 40 | 41 | (defmacro wrap-apis () 42 | `(progn ,@(mapcar #'wrap-api *defined-opencl-functions*))) 43 | 44 | (wrap-apis) 45 | 46 | -------------------------------------------------------------------------------- /1.error-src/package.lisp: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | (in-package :cl-user) 7 | (defpackage eazy-opencl.error 8 | (:use :cl :alexandria :trivia :cffi) 9 | (:nicknames :%ocl/e) 10 | (:import-from :eazy-opencl.bindings 11 | #:error-code 12 | #:finalize-box 13 | #:*defined-opencl-functions*) 14 | #.`(:export 15 | ,@(mapcar (lambda (info) 16 | (make-symbol (symbol-name (cadar info)))) 17 | eazy-opencl.bindings:*defined-opencl-functions*))) 18 | -------------------------------------------------------------------------------- /2.host-src/0package.lisp: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | (in-package :cl-user) 7 | (defpackage eazy-opencl.host 8 | (:use :cl :cffi :iterate :alexandria :trivia :trivial-garbage) 9 | ;; using %ocl is dangerous! Causes incorrect overloading 10 | (:nicknames :%ocl/h) 11 | (:import-from :%ocl 12 | :boxed-command-queue 13 | :boxed-context 14 | :boxed-device-id 15 | :boxed-event 16 | :boxed-kernel 17 | :boxed-mem 18 | :boxed-program 19 | :boxed-sampler 20 | :boxed-buffer 21 | :boxed-image 22 | :boxed-pipe 23 | :boxed-sub-buffer 24 | :finalize-box) 25 | ;;(:shadow :char :float :finish) 26 | (:shadowing-import-from :%ocl/e 27 | ;; reexport 28 | #:create-kernel) 29 | (:export 30 | ;; getter api 31 | #:get-platform-info 32 | #:get-device-info 33 | #:get-context-info 34 | #:get-command-queue-info 35 | #:get-mem-object-info 36 | #:get-image-info 37 | #:get-sampler-info 38 | #:get-program-info 39 | #:get-program-build-info 40 | #:get-kernel-info 41 | #:get-kernel-work-group-info 42 | #:get-event-info 43 | #:get-event-profiling-info 44 | ;; list api 45 | #:get-platform-ids 46 | #:get-device-ids 47 | #:get-supported-image-formats 48 | ;; setter api 49 | #:set-kernel-arg 50 | #+opencl-2.0 51 | #:set-kernel-exec-info 52 | ;; create api 53 | #:create-context 54 | #:create-context-from-type 55 | #:create-command-queue 56 | #:create-command-queue-with-properties 57 | #:create-buffer 58 | #:create-image 59 | #+opencl-2.0 60 | #:create-pipe 61 | #:create-sampler 62 | #:create-sampler-with-properties 63 | #:create-program-with-source 64 | #:create-program-with-binary 65 | #:create-program-with-builtin-kernels 66 | #:build-program 67 | #:compile-program 68 | #:link-program 69 | #:create-kernels-in-program 70 | ;; reexport 71 | #:create-kernel)) 72 | -------------------------------------------------------------------------------- /2.host-src/1util.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :eazy-opencl.host) 3 | 4 | (defmacro without-fp-traps (&body body) 5 | ;; FIXME: document why this is needed 6 | #+(and sbcl (or x86 x86-64)) 7 | `(sb-int:with-float-traps-masked (:invalid :divide-by-zero) 8 | ,@body) 9 | #-(and sbcl (or x86 x86-64)) 10 | `(progn ,@body)) 11 | 12 | ;;; with-foreign-array 13 | #| 14 | 15 | Several functions use this, e.g. clCreateContext, clCreateCommandQueueWithProperties. 16 | They take "properties" argument, which is a pointer to a 0-terminated array 17 | containing property and property-value alternatingly. 18 | 19 | |# 20 | 21 | (defmacro with-foreign-array ((pointer-var type sequence &optional size) &body body) 22 | "Convert a sequence to a foreign array, then bound it to pointer-var. 23 | 24 | SEQUENCE, TYPE are evaluated. 25 | " 26 | (let ((size (or size (gensym "SIZE")))) 27 | `(locally 28 | (declare (inline call-with-foreign-array)) 29 | (call-with-foreign-array 30 | ,type ,sequence 31 | (lambda (,pointer-var ,size) 32 | (declare (ignorable ,size)) 33 | ,@body))))) 34 | 35 | (declaim (inline call-with-foreign-array)) 36 | (defun call-with-foreign-array (type sequence callback) 37 | (let ((len (length sequence))) 38 | (with-foreign-object (pointer type len) 39 | (loop for i below len 40 | do 41 | (setf (mem-aref pointer type i) 42 | ;; sbcl optimize it away when the type of sequence is known. 43 | ;; note: this function is inlined. 44 | (elt sequence i))) 45 | (funcall callback pointer len)))) 46 | (declaim (notinline call-with-foreign-array)) 47 | 48 | 49 | ;;; with-opencl-plist 50 | #| 51 | 52 | Several functions use this, e.g. clCreateContext, clCreateCommandQueueWithProperties. 53 | They take "properties" argument, which is a pointer to a 0-terminated array 54 | containing property and property-value alternatingly. 55 | 56 | |# 57 | 58 | 59 | (defmacro with-opencl-plist ((var type plist) &body body) 60 | "Several functions use this, e.g. clCreateContext, clCreateCommandQueueWithProperties. 61 | Run BODY where VAR is bound to an OpenCL property list (foreign) 62 | converted from PLIST (evaluated). 63 | 64 | TYPE (evaluated). 65 | " 66 | `(locally 67 | (declare (inline call-with-opencl-plist)) 68 | (call-with-opencl-plist 69 | ,plist 70 | ,type 71 | (lambda (,var) ,@body)))) 72 | 73 | (declaim (inline call-with-opencl-plist)) 74 | (defun call-with-opencl-plist (properties type callback) 75 | "Setup the given memory region in foreign-array with a lisp plist, by 76 | destructively modify the region" 77 | (check-type properties list) 78 | (let* ((len (length properties)) 79 | ;;(base-len (/ len 2)) 80 | (foreign-len (1+ len))) 81 | (assert (evenp len)) 82 | (with-foreign-object (foreign-array type foreign-len) 83 | ;; setup array 84 | (loop for i below len by 2 85 | for (p v) on properties by #'cddr 86 | do 87 | (setf (mem-aref foreign-array type i) p) 88 | (setf (mem-aref foreign-array type (1+ i)) 89 | (if (pointerp v) 90 | (pointer-address v) 91 | v))) 92 | (setf (mem-aref foreign-array type len) 0) 93 | (funcall callback foreign-array)))) 94 | (declaim (notinline call-with-opencl-plist)) 95 | 96 | 97 | 98 | ;;; enum-keywords-as-symbols 99 | 100 | (defun enum-keywords-as-symbols (foreign-type) 101 | (mapcar (compose #'intern #'string) 102 | (foreign-enum-keyword-list foreign-type))) 103 | -------------------------------------------------------------------------------- /2.host-src/3getter-api.lisp: -------------------------------------------------------------------------------- 1 | #| 2 | 3 | Opencl interface is completely imperative, so we need a good interface. 4 | Largely forked from cl-opencl-3b. 5 | 6 | This file contain only the definition of the macro define-info-getter. 7 | Actual use of this macro is in functional-definitions.lisp. 8 | 9 | |# 10 | 11 | (in-package :eazy-opencl.host) 12 | 13 | ;;; info-getter 14 | 15 | (defmacro define-info-getter (name (&rest args) (type) &body body) 16 | "Define a functional wrapper for get-XXX-info apis. 17 | NAME: The name of the resulting wrapper. MUST be the same name as the underlying api in EAZY-OPENCL.ERROR. 18 | ARGS: The parameters of the resulting wrapper. 19 | TYPE: enum type accepted by FUN as a parameter. 20 | BODY: Query specification of the getter, the most complicated part of the OpenCL API. 21 | Each element of the body may take either of the 4 forms: 22 | 23 | (:QUERY RESULT_TYPE) 24 | 25 | The simplest case, where RESULT-TYPE 26 | should be a CFFI type of the value returned by the API. 27 | 28 | (:QUERY :STRING) 29 | 30 | Another simple case. The result is converted to the lisp string. 31 | 32 | (:QUERY RESULT_TYPE :FIXEDSIZE [number]) 33 | 34 | The size of the result is [number]*sizeof(result_type). 35 | 36 | (:QUERY RESULT_TYPE :QUERYSIZE [:QUERY2]) 37 | 38 | The size of the result is [number]*sizeof(result_type), where [number] is 39 | obtained by another call to FUN with :QUERY2. For 40 | example, :MAX-WORK-ITEM-SIZES in GET-DEVICE-INFO requires another call to 41 | GET-DEVICE-INFO with :MAX-WORK-ITEM-DIMENSIONS, which returns the size. 42 | 43 | (:QUERY NIL :ARRAY t) 44 | 45 | The result is an array of unknown size, and the size can be queried with the api itself by 46 | passing NULL argument. 47 | 48 | (:QUERY NIL :FORM FORM) 49 | 50 | Last resort. In place of the default behavior, FORM is used in the expansion. 51 | 52 | " 53 | (let ((param (lastcar args)) 54 | (fun (find-symbol (symbol-name name) (find-package "%OCL/E")))) 55 | ;; check if each parameter is valid 56 | (iter (for form in body) 57 | (ematch form 58 | ((list* pname _) 59 | (assert (foreign-enum-value type pname))))) 60 | ;; check if there is no missing parameter 61 | (unless (set-equal (mapcar #'first body) 62 | (foreign-enum-keyword-list type)) 63 | (simple-style-warning 64 | "~" 65 | (list (set-difference (foreign-enum-keyword-list type) 66 | (mapcar #'first body)) 67 | (asdf:system-relative-pathname 68 | :eazy-opencl 69 | "2.host-src/functional-definitions.lisp")))) 70 | `(defun ,name (,@args) 71 | (ecase ,param 72 | ,@(mapcar (curry #'info-getter-case-form name args fun) body))))) 73 | 74 | (defun info-getter-case-form (name args fun form) 75 | (ematch form 76 | ((list* pname _ (plist :fixedsize (number))) 77 | `(,pname ,(%fixed-size-case args fun form))) 78 | ((list* pname _ (plist :querysize (keyword))) 79 | `(,pname ,(%dynamic-size-case name args fun form))) 80 | ((list* pname _ (plist :array t)) 81 | `(,pname ,(%array-case args fun form))) 82 | ((list pname _ :form code) 83 | `(,pname ,code)) 84 | ((list pname :string) 85 | `(,pname ,(%string-case args fun pname))) 86 | ((list pname _) 87 | `(,pname ,(%simple-case args fun form))))) 88 | 89 | (defun %base-type (form) 90 | (destructuring-bind (pname type &key plist &allow-other-keys) form 91 | (declare (ignorable pname)) 92 | (if plist 93 | ;; fixme: any exported way to do this? 94 | (cffi::canonicalize-foreign-type type) 95 | type))) 96 | 97 | (defun %fixed-size-case (args fun form) 98 | (let ((base-type (%base-type form))) 99 | (destructuring-bind (pname type &key fixedsize plist) form 100 | `(let ((count ,fixedsize)) 101 | (with-foreign-object (value ',base-type count) 102 | (,fun ,@(butlast args) ,pname 103 | (* ,(foreign-type-size type) count) 104 | value 105 | (cffi:null-pointer)) 106 | (loop for i below count 107 | for v = (mem-aref value ',type i) 108 | ,@(when plist 109 | `(for prop = t then (not prop) 110 | when (and prop (not (zerop v))) 111 | collect (foreign-enum-keyword ',type v) 112 | else)) 113 | collect v)))))) 114 | 115 | (defun %dynamic-size-case (name args fun form) 116 | (let ((base-type (%base-type form))) 117 | (destructuring-bind (pname type &key querysize plist) form 118 | `(let ((count 119 | ;; further call to NAME for obtaining the size 120 | (,name ,@(butlast args) ,querysize))) 121 | (with-foreign-object (value ',base-type count) 122 | (,fun ,@(butlast args) ,pname 123 | (* ,(foreign-type-size type) count) 124 | value 125 | (cffi:null-pointer)) 126 | (loop for i below count 127 | for v = (mem-aref value ',type i) 128 | ,@(when plist 129 | `(for prop = t then (not prop) 130 | when (and prop (not (zerop v))) 131 | collect (foreign-enum-keyword ',type v) 132 | else)) 133 | collect v)))))) 134 | 135 | (defun %array-case (args fun form) 136 | (let ((base-type (%base-type form))) 137 | (destructuring-bind (pname type &key plist &allow-other-keys) form 138 | `(with-foreign-object (size '%ocl:size-t) 139 | (,fun ,@(butlast args) ,pname 140 | 0 (cffi:null-pointer) 141 | size) 142 | (let ((count (floor (mem-aref size '%ocl:size-t) 143 | ,(foreign-type-size type)))) 144 | (with-foreign-object (value ',base-type count) 145 | (,fun ,@(butlast args) ,pname 146 | (* ,(foreign-type-size type) 147 | count) 148 | value 149 | (cffi:null-pointer)) 150 | (loop for i below count 151 | for v = (mem-aref value ',base-type i) 152 | ,@ (when plist 153 | `(for prop = t then (not prop) 154 | when (and prop (not (zerop v))) 155 | collect (foreign-enum-keyword ',type v) 156 | else)) 157 | collect v))))))) 158 | 159 | (defun %string-case (args fun pname) 160 | `(with-foreign-object (size '%ocl:size-t) 161 | (,fun ,@(butlast args) ,pname 0 (cffi:null-pointer) size) 162 | (let ((count (mem-aref size '%ocl:size-t))) 163 | ;; char is not imported due to conflict with cl:char 164 | (with-foreign-object (str '%ocl/g:char count) 165 | (,fun ,@(butlast args) ,pname count str (cffi:null-pointer)) 166 | ;; for CCL 167 | (handler-case 168 | (foreign-string-to-lisp str :encoding :ascii) 169 | (error (c) 170 | (warn "~a occured during foreign-string-to-lisp. Returning \"\", so the results is unreliable" 171 | (type-of c)) 172 | "")))))) 173 | 174 | (defun %simple-case (args fun form) 175 | (ematch form 176 | ((list pname type) 177 | `(with-foreign-object (value ',type) 178 | (,fun ,@(butlast args) ,pname 179 | ,(foreign-type-size type) value 180 | (cffi:null-pointer)) 181 | (mem-aref value ',type))))) 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /2.host-src/4getter-api-definitions.lisp: -------------------------------------------------------------------------------- 1 | (in-package :eazy-opencl.host) 2 | 3 | 4 | ;;; info-getter definitions (alphabetical) 5 | 6 | ;; "returns specified info about a platform-id 7 | ;; param = :profile, :version, :name, :vendor, :extensions" 8 | (define-info-getter get-command-queue-info (command-queue param) (%ocl:command-queue-info) 9 | (:queue-context %ocl:context) 10 | (:queue-device %ocl:device-id) 11 | (:queue-reference-count %ocl:uint) 12 | (:queue-properties %ocl:command-queue-properties) 13 | #+opencl-2.0 14 | (:queue-size %ocl:uint)) 15 | 16 | (define-info-getter get-context-info (context param) (%ocl:context-info) 17 | (:context-reference-count %ocl:uint) 18 | (:context-devices %ocl:device-id :array t) 19 | (:context-properties %ocl:context-properties :array t :plist t) 20 | (:context-num-devices %ocl:uint)) 21 | ;; fixme : support plist stuff: alternating enum/value pairs terminated by a single 0 22 | 23 | (define-info-getter get-device-info (device-id param) (%ocl:device-info) 24 | (:device-address-bits %ocl:uint) 25 | (:device-available %ocl:bool) 26 | (:device-built-in-kernels :string) 27 | (:device-compiler-available %ocl:bool) 28 | (:device-double-fp-config %ocl:device-fp-config) 29 | (:device-endian-little %ocl:bool) 30 | (:device-error-correction-support %ocl:bool) 31 | (:device-execution-capabilities %ocl:device-exec-capabilities) 32 | (:device-extensions :string) 33 | (:device-global-mem-cache-size %ocl:ulong) 34 | (:device-global-mem-cache-type %ocl:device-mem-cache-type) 35 | (:device-global-mem-cacheline-size %ocl:uint) 36 | (:device-global-mem-size %ocl:ulong) 37 | #+opencl-2.0 38 | (:device-global-variable-preferred-total-size %ocl:size-t) 39 | (:device-host-unified-memory %ocl:bool) 40 | (:device-image-base-address-alignment %ocl:uint) 41 | (:device-image-max-array-size %ocl:size-t) 42 | (:device-image-max-buffer-size %ocl:size-t) 43 | (:device-image-pitch-alignment %ocl:uint) 44 | (:device-image-support %ocl:bool) 45 | (:device-image2d-max-height %ocl:size-t) 46 | (:device-image2d-max-width %ocl:size-t) 47 | (:device-image3d-max-depth %ocl:size-t) 48 | (:device-image3d-max-height %ocl:size-t) 49 | (:device-image3d-max-width %ocl:size-t) 50 | (:device-linker-available %ocl:bool) 51 | (:device-local-mem-size %ocl:ulong) 52 | (:device-local-mem-type %ocl:device-local-mem-type) 53 | (:device-max-clock-frequency %ocl:uint) 54 | (:device-max-compute-units %ocl:uint) 55 | (:device-max-constant-args %ocl:uint) 56 | (:device-max-constant-buffer-size %ocl:ulong) 57 | #+opencl-2.0 58 | (:device-max-global-variable-size %ocl:size-t) 59 | (:device-max-mem-alloc-size %ocl:ulong) 60 | #+opencl-2.0 61 | (:device-max-on-device-events %ocl:uint) 62 | #+opencl-2.0 63 | (:device-max-on-device-queues %ocl:uint) 64 | (:device-max-parameter-size %ocl:size-t) 65 | #+opencl-2.0 66 | (:device-max-pipe-args %ocl:uint) 67 | (:device-max-read-image-args %ocl:uint) 68 | #+opencl-2.0 69 | (:device-max-read-write-image-args %ocl:uint) 70 | (:device-max-samplers %ocl:uint) 71 | (:device-max-work-group-size %ocl:size-t) 72 | (:device-max-work-item-dimensions %ocl:uint) 73 | (:device-max-work-item-sizes %ocl:size-t :querysize :device-max-work-item-dimensions) 74 | (:device-max-write-image-args %ocl:uint) 75 | (:device-mem-base-addr-align %ocl:uint) 76 | (:device-min-data-type-align-size %ocl:uint) 77 | (:device-name :string) 78 | (:device-native-vector-width-char %ocl:uint) 79 | (:device-native-vector-width-double %ocl:uint) 80 | (:device-native-vector-width-float %ocl:uint) 81 | (:device-native-vector-width-half %ocl:uint) 82 | (:device-native-vector-width-int %ocl:uint) 83 | (:device-native-vector-width-long %ocl:uint) 84 | (:device-native-vector-width-short %ocl:uint) 85 | (:device-opencl-c-version :string) 86 | (:device-parent-device %ocl:device-id) 87 | (:device-partition-affinity-domain %ocl:device-affinity-domain) 88 | (:device-partition-max-sub-devices %ocl:uint) 89 | (:device-partition-properties %ocl:device-partition-property :array t) 90 | (:device-partition-type %ocl:device-partition-property :array t) 91 | #+opencl-2.0 92 | (:device-pipe-max-active-reservations %ocl:uint) 93 | #+opencl-2.0 94 | (:device-pipe-max-packet-size %ocl:uint) 95 | (:device-platform %ocl:platform-id) 96 | #+opencl-2.0 97 | (:device-preferred-global-atomic-alignment %ocl:uint) 98 | (:device-preferred-interop-user-sync %ocl:uint) 99 | #+opencl-2.0 100 | (:device-preferred-local-atomic-alignment %ocl:uint) 101 | #+opencl-2.0 102 | (:device-preferred-platform-atomic-alignment %ocl:uint) 103 | (:device-preferred-vector-width-char %ocl:uint) 104 | (:device-preferred-vector-width-double %ocl:uint) 105 | (:device-preferred-vector-width-float %ocl:uint) 106 | (:device-preferred-vector-width-half %ocl:uint) 107 | (:device-preferred-vector-width-int %ocl:uint) 108 | (:device-preferred-vector-width-long %ocl:uint) 109 | (:device-preferred-vector-width-short %ocl:uint) 110 | (:device-printf-buffer-size %ocl:size-t) 111 | (:device-profile :string) 112 | (:device-profiling-timer-resolution %ocl:size-t) 113 | #+opencl-2.0 114 | (:device-queue-on-device-max-size %ocl:uint) 115 | #+opencl-2.0 116 | (:device-queue-on-device-preferred-size %ocl:uint) 117 | #+opencl-2.0 118 | (:device-queue-on-device-properties %ocl:command-queue-properties) 119 | #+opencl-2.0 120 | (:device-queue-on-host-properties %ocl:command-queue-properties) 121 | (:device-queue-properties %ocl:command-queue-properties) 122 | (:device-reference-count %ocl:uint) 123 | (:device-single-fp-config %ocl:device-fp-config) 124 | #+opencl-2.0 125 | (:device-svm-capabilities %ocl:device-svm-capabilities) 126 | (:device-type %ocl:device-type) 127 | (:device-vendor :string) 128 | (:device-vendor-id %ocl:uint) 129 | (:device-version :string) 130 | (:driver-version :string)) 131 | 132 | (define-info-getter get-event-info (event param) (%ocl:event-info) 133 | (:event-command-queue %ocl:command-queue) 134 | #+opencl-1.1 135 | (:event-context %ocl:context) 136 | (:event-command-type %ocl:command-type) 137 | (:event-command-execution-status %ocl:int) 138 | (:event-reference-count %ocl:uint)) 139 | 140 | (define-info-getter get-event-profiling-info (event param) (%ocl:profiling-info) 141 | (:profiling-command-queued %ocl:ulong) 142 | (:profiling-command-submit %ocl:ulong) 143 | (:profiling-command-start %ocl:ulong) 144 | (:profiling-command-end %ocl:ulong) 145 | #+opencl-2.0 146 | (:profiling-command-complete %ocl:ulong)) 147 | 148 | (define-info-getter get-image-info (image param) (%ocl:image-info) 149 | (:image-format (:pointer (:struct %ocl:image-format))) 150 | (:image-element-size %ocl:size-t) 151 | (:image-row-pitch %ocl:size-t) 152 | (:image-slice-pitch %ocl:size-t) 153 | (:image-width %ocl:size-t) 154 | (:image-height %ocl:size-t) 155 | (:image-depth %ocl:size-t) 156 | (:image-num-samples %ocl:uint) 157 | (:image-num-mip-levels %ocl:uint) 158 | ;; #-opencl-2.0 159 | #+opencl-1.2 160 | (:image-buffer %ocl:buffer) ; deprecated in 2.0 161 | (:image-array-size %ocl:size-t)) 162 | 163 | (define-info-getter get-kernel-info (kernel param) (%ocl:kernel-info) 164 | (:kernel-attributes :string) 165 | (:kernel-function-name :string) 166 | (:kernel-num-args %ocl:uint) 167 | (:kernel-reference-count %ocl:uint) 168 | (:kernel-context %ocl:context) 169 | (:kernel-program %ocl:program)) 170 | 171 | (define-info-getter get-kernel-work-group-info (kernel device param) (%ocl:kernel-work-group-info) 172 | (:kernel-global-work-size %ocl:size-t :fixedsize 3) 173 | (:kernel-work-group-size %ocl:size-t) 174 | (:kernel-compile-work-group-size %ocl:size-t :fixedsize 3) 175 | (:kernel-local-mem-size %ocl:ulong) 176 | (:kernel-preferred-work-group-size-multiple %ocl:ulong) 177 | (:kernel-private-mem-size %ocl:ulong)) 178 | 179 | 180 | (define-info-getter get-mem-object-info (memobj param) (%ocl:mem-info) 181 | (:mem-type %ocl:mem-object-type) 182 | (:mem-flags %ocl:mem-flags) 183 | (:mem-size %ocl:size-t) 184 | (:mem-host-ptr (:pointer :void)) 185 | (:mem-map-count %ocl:uint) 186 | (:mem-reference-count %ocl:uint) 187 | (:mem-context %ocl:context) 188 | #+opencl-1.1 189 | (:mem-associated-memobject %ocl:mem) 190 | (:mem-offset %ocl:size-t) 191 | #+opencl-2.0 192 | (:mem-uses-svm-pointer %ocl:bool)) 193 | 194 | #+opencl-2.0 195 | (define-info-getter get-pipe-info (pipe param) (%ocl:pipe-info) 196 | (:pipe-packet-size %ocl:uint) 197 | (:pipe-max-packets %ocl:uint)) 198 | 199 | (define-info-getter get-platform-info (platform-id param) (%ocl:platform-info) 200 | (:platform-profile :string) 201 | (:platform-version :string) 202 | (:platform-name :string) 203 | (:platform-vendor :string) 204 | (:platform-extensions :string) 205 | (:platform-icd-suffix-khr :string)) 206 | 207 | (define-info-getter get-program-build-info (program device param) (%ocl:program-build-info) 208 | (:program-build-status %ocl:build-status) 209 | (:program-build-options :string) 210 | (:program-build-log :string) 211 | (:program-binary-type %ocl:program-binary-type) 212 | #+opencl-2.0 213 | (:program-build-global-variable-total-size %ocl:size-t)) 214 | 215 | (define-info-getter get-program-info (program param) (%ocl:program-info) 216 | (:program-reference-count %ocl:uint) 217 | (:program-context %ocl:context) 218 | (:program-num-devices %ocl:uint) 219 | (:program-devices %ocl:device-id :array t) 220 | (:program-source :string) 221 | (:program-binary-sizes %ocl:size-t :array t) 222 | #+opencl-1.2 223 | (:program-kernel-names :string) 224 | #+opencl-1.2 225 | (:program-num-kernels %ocl:size-t) 226 | (:program-binaries 227 | nil 228 | :form 229 | ;; fixme: test this... 230 | (let* ((sizes (get-program-info program :program-binary-sizes)) 231 | (total-size (reduce #'+ sizes))) 232 | (with-foreign-pointer (buffer total-size) 233 | (with-foreign-object (pointers '(:pointer :void) (length sizes)) 234 | (loop for j = 0 then (+ size j) 235 | for size in sizes 236 | for i from 0 237 | do (setf (mem-aref pointers :pointer i) (inc-pointer buffer j))) 238 | (%ocl/e:get-program-info program :program-binaries 239 | (* (foreign-type-size :pointer) (length sizes)) 240 | pointers 241 | (cffi:null-pointer)) 242 | (loop for i from 0 243 | for size in sizes 244 | collect 245 | (loop with array = (make-array size :element-type '(unsigned-byte 8)) 246 | for j below size 247 | do (setf (aref array j) 248 | (mem-aref (mem-aref pointers :pointer i) :uchar j)) 249 | finally (return array)))))))) 250 | 251 | (define-info-getter get-sampler-info (sampler param) (%ocl:sampler-info) 252 | (:sampler-reference-count %ocl:uint) 253 | (:sampler-context %ocl:context) 254 | (:sampler-normalized-coords %ocl:bool) 255 | (:sampler-addressing-mode %ocl:addressing-mode) 256 | (:sampler-filter-mode %ocl:filter-mode) 257 | ;; extensions, not included 258 | ;; (:sampler-lod-max %ocl:) 259 | ;; (:sampler-lod-min %ocl:) 260 | ;; (:sampler-mip-filter-mode %ocl:) 261 | ) 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /2.host-src/5setter-api.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :eazy-opencl.host) 3 | 4 | (defun set-kernel-arg (kernel index value type) 5 | (with-foreign-object (p type) 6 | (setf (mem-ref p type) value) 7 | (%ocl/e:set-kernel-arg kernel index (foreign-type-size type) p))) 8 | 9 | ;; (define-info-getter set-kernel-exec-info (kernel param) (%ocl:kernel-exec-info) 10 | ;; (:kernel-exec-info-svm-ptrs (:pointer :void) :array t) 11 | ;; (:kernel-exec-info-svm-fine-grain-system %ocl:bool)) 12 | 13 | #+opencl-2.0 14 | (defun set-kernel-exec-info (kernel param-name value) 15 | (ecase param-name 16 | (:kernel-exec-info-svm-ptrs 17 | (with-foreign-array (a '(:pointer :void) value size) 18 | (%ocl/e:set-kernel-exec-info kernel param-name size a))) 19 | (:kernel-exec-info-svm-fine-grain-system 20 | (%ocl/e:set-kernel-exec-info kernel param-name (foreign-type-size '%ocl:bool) value)))) 21 | -------------------------------------------------------------------------------- /2.host-src/6list-apis.lisp: -------------------------------------------------------------------------------- 1 | 2 | (in-package :eazy-opencl.host) 3 | 4 | (defmacro get-counted-list (fun (&rest args) type) 5 | "Handles some apis returning an array." 6 | (with-gensyms (fcount count buffer i) 7 | `(with-foreign-object (,fcount '%ocl:uint) 8 | ;; the total length is unknown, so calls it once 9 | (,fun ,@args 0 (cffi:null-pointer) ,fcount) 10 | (let ((,count (mem-aref ,fcount '%ocl:uint))) 11 | (when (> ,count 0) 12 | (with-foreign-object (,buffer ,type (1+ ,count)) 13 | ;; then call the same function again to obtain the real array 14 | (,fun ,@args (1+ ,count) ,buffer ,fcount) 15 | (loop for ,i below ,count 16 | collect (mem-aref ,buffer ,type ,i)))))))) 17 | 18 | #+prototype 19 | (defun get-platform-ids () 20 | "returns a list of available OpenCL Platform IDs" 21 | ;; FIXME: figure out if returning same pointer twice is correct, 22 | ;; possibly remove-duplicates on it if so? 23 | (without-fp-traps 24 | (get-counted-list %ocl/e:get-platform-ids () '%ocl:platform-id))) 25 | 26 | (defmacro define-list-api (name args function type) 27 | `(defun ,name ,args 28 | (without-fp-traps 29 | (get-counted-list ,function ,args ',type)))) 30 | 31 | (define-list-api get-platform-ids () %ocl/e:get-platform-ids %ocl:platform-id) 32 | (define-list-api get-device-ids (platform-id device-types) %ocl/e:get-device-ids %ocl:device-id) 33 | (define-list-api get-supported-image-formats (context flags image-type) %ocl/e:get-supported-image-formats (:pointer (:struct %ocl:image-format))) 34 | 35 | -------------------------------------------------------------------------------- /2.host-src/7create-apis.lisp: -------------------------------------------------------------------------------- 1 | ;;; Thin API wrapper over %ocl/e apis, mainly on clCreateXXX 2 | 3 | (in-package #:eazy-opencl.host) 4 | 5 | ;;; OpenCL Platform Layer 6 | ;;;; contexts 7 | 8 | ;; todo: error callback, better handling of properties stuff 9 | ;; properties arg is ugly since it mixes pointers with enums 10 | ;; only one option though, so handling it explicitly for now 11 | (defun create-context #.`(devices &rest properties 12 | &key ,@(enum-keywords-as-symbols '%ocl:context-properties)) 13 | ;; #.(documentation 'create-context 'function) 14 | (declare #.`(ignore ,@(enum-keywords-as-symbols '%ocl:context-properties))) 15 | (with-opencl-plist (props '%ocl:context-properties properties) 16 | (with-foreign-array (devs '%ocl:device-id devices) 17 | (%ocl/e:create-context props (length devices) devs 18 | (null-pointer) 19 | (null-pointer))))) 20 | 21 | (defun create-context-from-type #.`(type &rest properties 22 | &key ,@(enum-keywords-as-symbols '%ocl:context-properties)) 23 | ;; #.(documentation 'create-context-from-type 'function) 24 | (declare #.`(ignore ,@(enum-keywords-as-symbols '%ocl:context-properties))) 25 | (with-opencl-plist (props '%ocl:context-properties properties) 26 | (%ocl/e:create-context-from-type props type 27 | (null-pointer) 28 | (null-pointer)))) 29 | 30 | ;;; OpenCL Runtime 31 | ;;;; Command Queues 32 | 33 | (defun create-command-queue (context device &optional properties) 34 | ;; #.(documentation 'create-context-from-type 'function) 35 | "This interface is deprecated in OpenCL2.0 ! 36 | Properties should be a list of :out-of-order-exec-mode-enable and :profiling-enable." 37 | ;; something like above should be autogenerated when defining create-context-from-type 38 | #+opencl-2.0 39 | (simple-style-warning "This interface is deprecated in opencl 2.0! Use create-command-queue-with-properties.") 40 | (%ocl/e:create-command-queue context device properties)) 41 | 42 | #+opencl-2.0 43 | (defun create-command-queue-with-properties #.`(context device &rest properties 44 | &key ,@(enum-keywords-as-symbols '%ocl:queue-properties)) 45 | ;; #.(documentation 'create-command-queue-with-properties 'function) 46 | (declare #.`(ignore ,@(enum-keywords-as-symbols '%ocl:queue-properties))) 47 | (with-opencl-plist (props '%ocl:queue-properties properties) 48 | (%ocl/e:create-command-queue-with-properties context device props))) 49 | 50 | ;;;; Buffer 51 | 52 | (defun create-buffer (context flags size &optional (host-ptr (null-pointer))) 53 | ;; #.(documentation 'create-buffer 'function) 54 | (%ocl/e:create-buffer context flags size host-ptr)) 55 | 56 | ;;;; Image (TODO: test it) 57 | 58 | ;; further abstraction should be done in level3 59 | (defun create-image (context flags image-format image-desc &optional (host-ptr (null-pointer))) 60 | (%ocl/e:create-image context flags image-format image-desc host-ptr)) 61 | 62 | ;;;; Pipes 63 | 64 | #+opencl-2.0 65 | (defun create-pipe #.`(context flags packet-size max-packets &rest properties 66 | &key ,@(enum-keywords-as-symbols '%ocl:pipe-properties)) 67 | #+opencl-2.0 68 | (declare (ignorable properties)) 69 | ;; in opencl2.0, properties should be NULL 70 | #+opencl-2.0 71 | (%ocl/e:create-pipe context flags packet-size max-packets (null-pointer)) 72 | #+opencl-2.1 73 | (with-opencl-plist (props '%ocl:pipe-properties properties) 74 | (%ocl/e:create-pipe context flags packet-size max-packets props))) 75 | 76 | ;;;; SVM (TODO) 77 | 78 | 79 | ;;;; Sampler (TODO: test it) 80 | (defun create-sampler (context normalized-coords addressing-mode filter-mode) 81 | ;; #.(documentation 'create-context-from-type 'function) 82 | "This interface is deprecated in OpenCL2.0 ! 83 | Properties should be a list of :out-of-order-exec-mode-enable and :profiling-enable." 84 | ;; something like above should be autogenerated when defining create-context-from-type 85 | #+opencl-2.0 86 | (simple-style-warning "This interface is deprecated in opencl 2.0! Use create-sampler-with-properties.") 87 | (%ocl/e:create-sampler context normalized-coords addressing-mode filter-mode)) 88 | 89 | #+opencl-2.0 90 | (defun create-sampler-with-properties #.`(context &rest properties 91 | &key ,@(enum-keywords-as-symbols '%ocl:sampler-properties)) 92 | ;; #.(documentation 'create-sampler 'function) 93 | (declare #.`(ignore ,@(enum-keywords-as-symbols '%ocl:sampler-properties))) 94 | (with-opencl-plist (props '%ocl:sampler-properties properties) 95 | (%ocl/e:create-sampler-with-properties context props))) 96 | 97 | ;;;; Program 98 | 99 | ;; I don't see any benefit in passing multiple strings to 100 | ;; create-program-with-source. 101 | 102 | #+nil 103 | (defun slurp (stream) 104 | "http://www.ymeme.com/slurping-a-file-common-lisp-83.html" 105 | (let ((seq (make-array (file-length stream) 106 | :element-type 'character 107 | :fill-pointer t))) 108 | (setf (fill-pointer seq) (read-sequence seq stream)) 109 | seq)) 110 | 111 | (declaim (ftype (function (boxed-context (or string stream pathname)) 112 | boxed-program) 113 | create-program-with-source)) 114 | (defun create-program-with-source (context source) 115 | "Wrapper around create-program-with-source." 116 | (flet ((load-into-string (length) 117 | (let ((seq (make-array length :element-type 'character :fill-pointer t))) 118 | (setf (fill-pointer seq) (read-sequence seq source)) 119 | (values seq (/= (fill-pointer seq) length))))) 120 | (ematch source 121 | ((type pathname) 122 | (with-open-file (s source) 123 | (create-program-with-source context s))) 124 | ((type string) 125 | (with-foreign-string (cstring source) 126 | (with-foreign-object (p :pointer 1) 127 | (setf (mem-ref p :pointer) cstring) 128 | (%ocl/e:create-program-with-source context 1 p (null-pointer))))) 129 | ((type file-stream) 130 | (assert (input-stream-p source)) 131 | (create-program-with-source context (load-into-string (file-length source)))) 132 | ((type stream) 133 | (assert (input-stream-p source)) 134 | (let ((len 0)) 135 | (declare (fixnum len)) 136 | (let ((cstrings (iter (for (values str eof-p) = (load-into-string 4096)) 137 | (collect (foreign-string-alloc str) result-type simple-vector) 138 | (incf len) 139 | (until eof-p)))) 140 | (unwind-protect 141 | (with-foreign-object (p :pointer len) 142 | (loop for i below len 143 | do (setf (mem-aref p :pointer i) (elt cstrings i))) 144 | (%ocl/e:create-program-with-source context len p (null-pointer))) 145 | (map nil #'foreign-string-free cstrings)))))))) 146 | 147 | ;; todo: create-program-with-binary 148 | ;; todo: create-program-with-builtin-kernels 149 | ;; todo: create-program-with-IL 150 | 151 | ;; todo: add notify callback support 152 | ;; - requiring callers to pass a cffi callback is a bit ugly 153 | ;; - using an interbal cffi callback and trying to map back to caller's 154 | ;; lisp callback is probably nicer API, but harder to implement 155 | ;; - also need to deal with thread safety stuff... not sure if it might 156 | ;; be called from arbitrary threads or not 157 | ;; todo: add keywords for know options? 158 | (defun build-program (program &key (devices :all) (options "")) 159 | (check-type options string) 160 | (if (eq :all devices) 161 | (%ocl/e:build-program program 162 | 0 (null-pointer) 163 | options 164 | (null-pointer) (null-pointer)) 165 | (with-foreign-array (devices-foreign '%ocl:device-id devices size) 166 | (%ocl/e:build-program program 167 | size devices-foreign 168 | options 169 | (null-pointer) (null-pointer)))) 170 | program) 171 | 172 | #+opencl-1.2 173 | (defun compile-program (program &key devices (options "") header-alist) 174 | "devices: if nil, compilation is performed on all devices. 175 | 176 | header-programs-alist: alist of (header-name . program) , 177 | For example, '((\"foo.h\" . #.(SB-SYS:INT-SAP #X7FFFE7B5FFE8)))." 178 | (check-type options string) 179 | (with-foreign-array (%header-programs '%ocl:program (mapcar #'cdr header-alist)) 180 | (with-foreign-array (%header-names :string (mapcar #'car header-alist)) 181 | (flet ((compile/devices (num devices) 182 | (%ocl/e:compile-program program 183 | num devices 184 | options 185 | (length header-alist) %header-programs %header-names 186 | (null-pointer) (null-pointer)))) 187 | (if devices 188 | (with-foreign-array (%devices '%ocl:device-id devices) 189 | (compile/devices (length devices) %devices)) 190 | (compile/devices 0 (null-pointer)))))) 191 | program) 192 | 193 | #+opencl-1.2 194 | (defun link-program (context &key devices (options "") programs) 195 | "devices: if not specified, it will be the list of devices associated with context." 196 | (check-type options string) 197 | (with-foreign-array (%programs '%ocl:program programs) 198 | (flet ((compile/devices (num devices) 199 | (%ocl/e:link-program context num devices options 200 | (length programs) %programs 201 | (null-pointer) (null-pointer)))) 202 | (if devices 203 | (with-foreign-array (%devices '%ocl:device-id devices) 204 | (compile/devices (length devices) %devices)) 205 | (compile/devices 0 (null-pointer))))) 206 | programs) 207 | 208 | ;; TODO: below comment is in the original opencl.lisp by 3b. 209 | ;; 210 | ;; ;; nv drivers return :invalid-binary for undefined functions, 211 | ;; ;; so treat that like build failure for now... 212 | ;; ((:build-program-failure :invalid-binary) 213 | ;; (let ((status (loop for i in (get-program-info program :devices) 214 | ;; collect (list (get-program-build-info program i :status) 215 | ;; (get-program-build-info program i :log))))) 216 | ;; (error "Build-program returned :build-program-failure:~:{~&~s : ~s~}" status)))))) 217 | 218 | ;;;; Kernel 219 | 220 | 221 | (defun create-kernels-in-program (program) 222 | ;; fixme: verify calling this twice is the correct way to figure out 223 | ;; how many kernels are in program... 224 | (get-counted-list %ocl/e:create-kernels-in-program (program) '%ocl:kernel)) 225 | 226 | 227 | 228 | ;;;; Event 229 | -------------------------------------------------------------------------------- /2.host-src/8launch-steps.lisp: -------------------------------------------------------------------------------- 1 | 2 | #| 3 | 4 | 5 | This file, similar to the original opencl.lisp, follows the structure of 6 | opencl 2.0 specification available from the kronos website. 7 | 8 | 9 | The test scripts in t/ follows the similar structure, and holds several 10 | unit tests. 11 | 12 | |# 13 | 14 | 15 | (in-package :eazy-opencl.host) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /3.fancy-src/0-package.lisp: -------------------------------------------------------------------------------- 1 | 2 | 3 | (defpackage :eazy-opencl.fancy 4 | (:use :cl :alexandria :iterate :trivia :eazy-opencl.host) 5 | (:import-from :eazy-opencl.bindings 6 | :boxed-command-queue 7 | :boxed-context 8 | :boxed-device-id 9 | :boxed-event 10 | :boxed-kernel 11 | :boxed-mem 12 | :boxed-program 13 | :boxed-sampler 14 | :boxed-buffer 15 | :boxed-image 16 | :boxed-pipe 17 | :boxed-sub-buffer) 18 | (:export 19 | #:call-with-easy-opencl-setup 20 | #:with-easy-opencl-setup)) 21 | 22 | -------------------------------------------------------------------------------- /3.fancy-src/1-query.lisp: -------------------------------------------------------------------------------- 1 | 2 | 3 | (in-package :eazy-opencl.fancy) 4 | 5 | (defmacro with-easy-opencl-setup ((platform-query 6 | device-query 7 | context-query 8 | queue-query) 9 | &body body) 10 | " 11 | *-query : var | (var &optional test) 12 | 13 | VAR : 14 | 15 | A symbol naming a variable. Symbol _ (regardless of package) is ignored, 16 | and can appear multiple times. 17 | 18 | TEST : 19 | 20 | A unary boolean test function. When it returns nil, it excludes some 21 | platform/device etc. It signals an error when the number of instances 22 | matched is 0 or more than 2. 23 | 24 | BODY : a form to be executed under the binding. 25 | " 26 | (destructuring-bind (platform &optional 27 | (platform-test '(constantly t))) (ensure-list platform-query) 28 | (destructuring-bind (device &optional 29 | (device-test '(constantly t))) (ensure-list device-query) 30 | (destructuring-bind (context &optional 31 | (context-test '(constantly t))) (ensure-list context-query) 32 | (destructuring-bind (queue &optional 33 | (queue-test '(constantly t))) (ensure-list queue-query) 34 | (let* (ignore-list 35 | (variables (iter (for var in (list platform device context queue)) 36 | (collect 37 | (ematch var 38 | ((symbol (name "_")) 39 | (with-gensyms (ignored) 40 | (push ignored ignore-list) 41 | ignored)) 42 | ((symbol) var)))))) 43 | `(call-with-easy-opencl-setup 44 | ,platform-test 45 | ,device-test 46 | ,context-test 47 | ,queue-test 48 | (lambda ,variables 49 | ,@(when ignore-list 50 | `((declare (ignore ,@ignore-list)))) 51 | ,@body)))))))) 52 | 53 | #+prototype 54 | (with-easy-opencl-setup (platform 55 | (device (lambda (device) 56 | (eq (get-device-info device :device-type) 57 | :device-type-gpu))) 58 | ctx 59 | queue) 60 | (is (atom device)) 61 | (is (atom device)) 62 | (is (atom ctx)) 63 | (is (atom queue))) 64 | 65 | (defun call-with-easy-opencl-setup (platform-test 66 | device-test 67 | context-test 68 | queue-test 69 | callback) 70 | (let (%pid %device %ctx %queue flag) 71 | (iter (for pid in (remove-if-not platform-test (get-platform-ids))) 72 | (for devices = (remove-if-not device-test (get-device-ids pid (list :device-type-all)))) 73 | (unless (< 0 (length devices) 2) 74 | (next-iteration)) 75 | (for did = (first devices)) 76 | (for ctx = (create-context devices :context-platform pid)) 77 | (unless (funcall context-test ctx) 78 | (next-iteration)) 79 | (for queue = 80 | #-opencl-2.0 81 | (create-command-queue ctx did) 82 | #+opencl-2.0 83 | (create-command-queue-with-properties ctx did)) 84 | (unless (funcall queue-test queue) 85 | (next-iteration)) 86 | (when flag (error "multiple instances found!")) 87 | (setf %pid pid %device (first devices) %ctx ctx %queue queue flag t)) 88 | (if (and %pid %device %ctx %queue) 89 | (funcall callback %pid %device %ctx %queue) 90 | (error "no instances found!")))) 91 | 92 | 93 | 94 | 95 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 96 | 97 | #| unused ideas 98 | 99 | (deftype query-type () 100 | `(member :one :many)) 101 | 102 | QUERY-TYPE : a form which evaluates to a keyword :one, :many or :one-or-many . 103 | 104 | When :one, it signals an error when the number of instances matched is 0 or more than 2. 105 | 106 | When :many, it signals an error when the number of instances matched is 0 or 1. 107 | 108 | When :one-or-many, it signals an error when the number of instances matched is 0. 109 | 110 | 111 | (flet ((declare-form (variable query-type type) 112 | (match query-type 113 | (:one `((declare (type ,type ,variable)))) 114 | (:many `((declare (type list ,variable))))))) 115 | 116 | ,@(declare-form platform platform-query-type 'fixnum) 117 | ,@(declare-form device device-query-type 'boxed-device-id) 118 | ,@(declare-form context context-query-type 'boxed-context) 119 | ,@(declare-form queue queue-query-type 'boxed-command-queue) 120 | 121 | 122 | (declare (type query-type 123 | platform-query-type 124 | device-query-type 125 | context-query-type 126 | queue-query-type)) 127 | 128 | 129 | 130 | |# 131 | -------------------------------------------------------------------------------- /HACKING.org: -------------------------------------------------------------------------------- 1 | 2 | 3 | Design Architechture: 4 | 5 | * Error handling (layer 0) 6 | 7 | This layer wraps the bare CFFI api with error handling. 8 | 9 | OpenCL APIs can be divided into three categories of functions: 10 | 11 | 1. It does not return any error 12 | 2. The return value (cl_int) tells the error situation 13 | 3. Takes a pointer to cl_int in the last argument, then sets the error value to that address 14 | 15 | The level0 binding layer handles the second case only. 16 | 17 | * Garbage collection (layer 0) 18 | 19 | We use the garbage collector of the host lisp 20 | in order to manage opencl objects with refcount interface, e.g. context, kernel and memobj. 21 | 22 | These objects are boxed in lisp structure-objects, named as boxed-context, boxed-kernel and so on. 23 | When these objects are GC'ed, then the finalization procedure implemented with trivial-garbage:finalize 24 | will invoke appropriate RELEASE interface of the refcount system in OpenCL. 25 | (e.g. release-kernel, release-context). 26 | 27 | Boxing/unboxing operations are transparent to the user; it runs during 28 | foreign type translation. 29 | 30 | * Error handling (layer 1) 31 | 32 | In error-handlers.lisp, `wrap-api-taking-error-ptr` handles the third case. 33 | Resulting interface has an argument list shorter than the original function by one (errcode-ret). 34 | 35 | * Convert the imperative C apis -> functional apis. (layer 2) 36 | 37 | This layer handles more about pointers, including properties and arrays. 38 | 39 | Error handling is already achieved by the previous layer. 40 | What we do now is to convert to/from foreign type, 41 | or to handle the apis which returns the result by setting it to the given pointer. 42 | 43 | Original api names are maintained. Some are re-exported from level-1, some 44 | are newly interned and exported. 45 | 46 | * Performance overhead of boxing 47 | 48 | Computation done by opencl should be sufficiently larger than the overhead. 49 | 50 | If this overhead is a problem, then it also means that your application 51 | contains a large number of very costly GPU-MEMORY communications, required 52 | each time the GPGPU computation is initialized. In such cases, you should 53 | instead consider changing the algorithm or even stop using GPGPU. 54 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * eazy-opencl - Opencl Binding for Common Lisp 2 | 3 | Development status: 4 | 5 | + basic CFFI binding, grovelling 6 | + proper error handling 7 | + integration to lisp GC 8 | + Minimally Viable API 9 | + extensive testing ([[https://travis-ci.org/guicho271828/eazy-opencl][https://travis-ci.org/guicho271828/eazy-opencl.svg]], [[https://circleci.com/gh/guicho271828/eazy-opencl][https://circleci.com/gh/guicho271828/eazy-opencl.svg]]) 10 | 11 | TODOs: 12 | + lisp-to-C preprocessor -> *work in progress* at https://github.com/gos-k/oclcl 13 | + Loading external OpenCL library easily (like in quicklisp) 14 | + Really good way to handle complicated memory operation 15 | (e.g., generating operations automatically) 16 | 17 | Perhaps, I should stop here, and leave these features to external libraries? 18 | 19 | ** Installation 20 | 21 | You have to install OpenCL ICD Loader and some OpenCL platform icd. 22 | On Debian/Ubuntu, 23 | 24 | ICD loader: =sudo apt-get install ocl-icd-opencl-dev= 25 | 26 | A Platform ICD provides an OpenCL implementation. Some are available from apt-get: 27 | 28 | + AMD (proprietary) : =sudo apt-get install amd-opencl-icd= 29 | + Nvidia (proprietary) : =sudo apt-get install nvidia-opencl-icd= 30 | + Intel (proprietary) : =sudo apt-get install beignet-opencl-icd= 31 | + Mesa (free) : =sudo apt-get install mesa-opencl-icd= 32 | + POCL (portable opencl) : =sudo apt-get install pocl-opencl-icd= --- 33 | Tested on latest source (>=0.12) from Git. Older versions have several 34 | unimplemented features/arguments and does not pass all the test, but 35 | mostly working as long as you don't use them. 36 | 37 | However, note that these packages (both ICD loader and OpenCL 38 | implementation) are not up-to-date. My recommendation is to download the 39 | latest driver&icd from vendors' websites. 40 | 41 | *As of 2015/11/04, it also requires the latest cffi installed from the git repositry*. 42 | 43 | =cd $quicklisp_local_project ; git clone https://github.com/cffi/cffi.git= 44 | 45 | Once they are up, just load this library in the quicklisp local-project directory. 46 | Run the tests by: 47 | 48 | =(asdf:test-system :eazy-opencl)= 49 | 50 | ** Devices 51 | 52 | OpenCL supports wide variety of hardware including CPU. The official, comprehensive device 53 | list is available [[https://www.khronos.org/conformance/adopters/conformant-products][here]]. 54 | 55 | + CPU with SSE2.X instruction (AMD APPSDK), SSE4.2 instruction (Intel driver) 56 | + Intel Xeon Phi (Intel driver) 57 | + ARM mobile CPUs (qualcomm snapdragon etc.) 58 | + CPU with embedded GPU (latest Intel, or AMD A-series) 59 | + FPGA, ASIC, DSP 60 | + GPGPU (Radeon, GeForce) 61 | 62 | Note that AMD APPSDK can be installed on any CPUs supporting SSE2 (even on Intel). 63 | 64 | # While NVIDIA used to be largely inactive in supporting OpenCL and like to 65 | # maintain the vendor-lock-in with CUDA, as of 2015-05-07, there are [[https://www.khronos.org/conformance/adopters/conformant-products][large 66 | # number of NVIDIA's products]] passing the opencl 1.2 conformance test. 67 | 68 | ** Supported OpenCL Versions 69 | 70 | This library supports opencl-1.0, 1.1, 1.2 and 2.0. They are automatically 71 | switched by grovelling the OpenCL header in the path. 72 | 73 | This library is developped on machine with AMD APPSDK v3.0 (OpenCL 2.0), Radeon HD 5770 and PhenomII X6. 74 | Tests on CI runs with POCL 0.12 (OpenCL 1.2). 75 | 76 | OpenCL has a /specification/ independent from /implementations/, much like 77 | in ANSI Common Lisp. It maintains the backward-compatibility (any programs 78 | written with earlier versions of OpenCL should work.) 79 | 80 | Bug/Trouble Reports should go to [[https://github.com/guicho271828/eazy-opencl/issues][github issues]] page. 81 | 82 | In this library, I do not support ANY OpenGL / Direct3D- related apis since 83 | I mostly target scientific use. 84 | I welcome any pullrequests as long as it comes with a minimal test. 85 | 86 | ** Author 87 | 88 | Masataro Asai (guicho2.71828@gmail.com) 89 | 90 | C source generator will be forked from [[https://github.com/takagi/cl-cuda][Takagi@CL-CUDA]] if ever implemented. 91 | 92 | CFFI-binding is forked from cl-opencl-3b, but largely extended to support OpenCL 2.0. 93 | 94 | ** Motivation 95 | 96 | Both [[https://github.com/malkia/cl-opencl][cl-opencl]] and [[https://github.com/3b/cl-opencl-3b][cl-opencl-3b]] look abandoned, so I'm trying to supersede 97 | it. In fact, no one seems using it, nor it is on Quicklisp. 98 | 99 | Implementing Deep NN in lisp is one ambitious goal. However it is not 100 | really necessary, since external DL-NN OpenCL libraries are available. 101 | See https://github.com/hughperkins/DeepCL. 102 | 103 | * License 104 | 105 | I'll plan to license it under the LLGPL, but since this is a fork from 106 | cl-opencl-3b which lacks the license, I'm asking 3b to specify one. 107 | 108 | -------------------------------------------------------------------------------- /build-pocl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [ -d pocl ] && exit 0 4 | 5 | git clone --depth=1 https://github.com/pocl/pocl.git 6 | 7 | cd pocl 8 | 9 | export CXX="g++-4.8" 10 | ./autogen.sh 11 | ./configure 12 | make 13 | 14 | 15 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | environment: 3 | PATH: ~/.roswell/bin:$PATH 4 | LLVM_CONFIG: /usr/lib/llvm-3.6/bin/llvm-config 5 | 6 | dependencies: 7 | pre: 8 | - sudo bash -c 'echo "deb http://mirrors.kernel.org/ubuntu vivid main universe" >> /etc/apt/sources.list' 9 | - sudo apt-get update 10 | - apt-cache search pocl 11 | - apt-cache search icd 12 | - apt-cache search opencl 13 | - sudo apt-get install -y libltdl3-dev libhwloc-dev ocl-icd-opencl-dev g++-4.8 clang-3.6 libclang-3.6-dev llvm-3.6-dev libedit-dev 14 | - ./build-pocl.sh 15 | - sudo make -C pocl install 16 | - curl -L https://raw.githubusercontent.com/snmsts/roswell/master/scripts/install-for-ci.sh | sh 17 | - ros install ccl-bin 18 | - git clone https://github.com/cffi/cffi.git ~/lisp/cffi 19 | post: 20 | - ros install cffi 21 | - ros install cffi-grovel 22 | - ros install eazy-opencl 23 | cache_directories: 24 | - ~/.roswell/ 25 | - pocl 26 | 27 | test: 28 | override: 29 | - ros -L sbcl-bin testscr.ros 30 | - ros -L ccl-bin testscr.ros 31 | -------------------------------------------------------------------------------- /eazy-opencl.asd: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | #| 7 | Opencl Binding for Common Lisp 8 | 9 | Author: Masataro Asai (guicho2.71828@gmail.com) 10 | |# 11 | 12 | 13 | 14 | (in-package :cl-user) 15 | (defpackage eazy-opencl-asd 16 | (:use :cl :asdf)) 17 | (in-package :eazy-opencl-asd) 18 | 19 | 20 | (defsystem eazy-opencl 21 | :version "0.1" 22 | :author "Masataro Asai" 23 | :mailto "guicho2.71828@gmail.com" 24 | :license "LLGPL" 25 | :depends-on (:eazy-opencl.bindings 26 | :eazy-opencl.error 27 | :eazy-opencl.host 28 | :eazy-opencl.fancy) 29 | :description "Opencl Binding for Common Lisp" 30 | :in-order-to ((test-op (test-op :eazy-opencl.test)))) 31 | -------------------------------------------------------------------------------- /eazy-opencl.bindings.asd: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | #| 7 | Opencl Binding for Common Lisp 8 | 9 | Author: Masataro Asai (guicho2.71828@gmail.com) 10 | |# 11 | 12 | 13 | 14 | (in-package :cl-user) 15 | (defpackage eazy-opencl-asd 16 | (:use :cl :asdf)) 17 | (in-package :eazy-opencl-asd) 18 | 19 | (defsystem eazy-opencl.bindings 20 | :version "0.1" 21 | :author "Masataro Asai" 22 | :mailto "guicho2.71828@gmail.com" 23 | :license "LLGPL" 24 | :defsystem-depends-on (:cffi-grovel) 25 | :depends-on (:alexandria :cffi :trivial-garbage) 26 | :components ((:module "0.bindings-src" 27 | :components 28 | ((:file "1-0-package") 29 | (:file "1-1-library") 30 | (:file "1-2-util-for-grovel") 31 | (:cffi-grovel-file "1-3-grovel-version") 32 | (:file "1-4-opencl-version-feature") 33 | (:file "2-0-package") 34 | (:cffi-grovel-file "2-1-grovel-cl_platform") 35 | (:cffi-grovel-file "2-4-grovel-cl") 36 | (:cffi-grovel-file "2-4-grovel-cl-enum") 37 | (:cffi-grovel-file "2-5-grovel-buffer") 38 | (:cffi-grovel-file "2-6-grovel-image") 39 | (:file "3-0-package") 40 | (:file "3-1-translators") 41 | (:file "3-2-bindings")) 42 | :serial t)) 43 | :description "Opencl Binding for Common Lisp: Low-level API bindings") 44 | -------------------------------------------------------------------------------- /eazy-opencl.error.asd: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | #| 7 | Opencl Binding for Common Lisp 8 | 9 | Author: Masataro Asai (guicho2.71828@gmail.com) 10 | |# 11 | 12 | 13 | 14 | (in-package :cl-user) 15 | (defpackage eazy-opencl-asd 16 | (:use :cl :asdf)) 17 | (in-package :eazy-opencl-asd) 18 | 19 | 20 | (defsystem eazy-opencl.error 21 | :version "0.1" 22 | :author "Masataro Asai" 23 | :mailto "guicho2.71828@gmail.com" 24 | :license "LLGPL" 25 | :depends-on (:alexandria 26 | :trivia 27 | :eazy-opencl.bindings) 28 | :components ((:module "1.error-src" 29 | :components 30 | ((:file "package") 31 | (:file "error-handlers")))) 32 | :description "Opencl Binding for Common Lisp: Wrapper of the low level API") 33 | -------------------------------------------------------------------------------- /eazy-opencl.fancy.asd: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | #| 7 | Opencl Binding for Common Lisp 8 | 9 | Author: Masataro Asai (guicho2.71828@gmail.com) 10 | |# 11 | 12 | 13 | 14 | (in-package :cl-user) 15 | (defpackage eazy-opencl-asd 16 | (:use :cl :asdf)) 17 | (in-package :eazy-opencl-asd) 18 | 19 | 20 | (defsystem eazy-opencl.fancy 21 | :version "0.1" 22 | :author "Masataro Asai" 23 | :mailto "guicho2.71828@gmail.com" 24 | :license "LLGPL" 25 | :depends-on (:eazy-opencl.host) 26 | :components ((:module "3.fancy-src" 27 | :components 28 | ((:file "0-package") 29 | (:file "1-query")))) 30 | :description "Opencl Binding for Common Lisp: C translator") 31 | -------------------------------------------------------------------------------- /eazy-opencl.host.asd: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | #| 7 | Opencl Binding for Common Lisp 8 | 9 | Author: Masataro Asai (guicho2.71828@gmail.com) 10 | |# 11 | 12 | 13 | 14 | (in-package :cl-user) 15 | (defpackage eazy-opencl-asd 16 | (:use :cl :asdf)) 17 | (in-package :eazy-opencl-asd) 18 | 19 | 20 | (defsystem eazy-opencl.host 21 | :version "0.1" 22 | :author "Masataro Asai" 23 | :mailto "guicho2.71828@gmail.com" 24 | :license "LLGPL" 25 | :depends-on (:iterate 26 | :alexandria 27 | :trivia 28 | :eazy-opencl.error) 29 | :components ((:module "2.host-src" 30 | :components 31 | ((:file "0package") 32 | (:file "1util") 33 | (:file "3getter-api") 34 | (:file "4getter-api-definitions") 35 | (:file "5setter-api") 36 | (:file "6list-apis") 37 | (:file "7create-apis") 38 | (:file "8launch-steps")) 39 | :serial t)) 40 | :description "Opencl Binding for Common Lisp: User API") 41 | -------------------------------------------------------------------------------- /eazy-opencl.test.asd: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | 7 | (in-package :cl-user) 8 | (defpackage eazy-opencl.test-asd 9 | (:use :cl :asdf)) 10 | (in-package :eazy-opencl.test-asd) 11 | 12 | 13 | (defsystem eazy-opencl.test 14 | :author "Masataro Asai" 15 | :mailto "guicho2.71828@gmail.com" 16 | :description "Test system of eazy-opencl" 17 | :license "LLGPL" 18 | :depends-on (:eazy-opencl 19 | :fiveam) 20 | :components ((:module "t" 21 | :components 22 | ((:file "package")))) 23 | :perform (test-op :after (op c) (eval (read-from-string "(every #'fiveam::TEST-PASSED-P (5am:run! :eazy-opencl))")) 24 | )) 25 | -------------------------------------------------------------------------------- /t/helloworld.cl: -------------------------------------------------------------------------------- 1 | #pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable 2 | 3 | __constant char hw[] = "Hello, World"; 4 | 5 | __kernel void hello(__global char * out) { 6 | size_t tid = get_global_id(0); 7 | out[tid] = hw[tid]; 8 | } 9 | -------------------------------------------------------------------------------- /t/package.lisp: -------------------------------------------------------------------------------- 1 | #| 2 | This file is a part of eazy-opencl project. 3 | Copyright (c) 2015 Masataro Asai (guicho2.71828@gmail.com) 4 | |# 5 | 6 | (in-package :cl-user) 7 | (defpackage :eazy-opencl.test 8 | (:use :cl 9 | :cffi 10 | :eazy-opencl.host 11 | :eazy-opencl.fancy 12 | :fiveam 13 | :iterate :alexandria :trivia)) 14 | (in-package :eazy-opencl.test) 15 | 16 | 17 | 18 | (def-suite :eazy-opencl) 19 | (in-suite :eazy-opencl) 20 | 21 | ;; run test with (run! test-name) 22 | 23 | (defmacro pie (form) 24 | (with-gensyms (result) 25 | `(handler-case 26 | (let ((,result ,form)) 27 | (format t "~%~" 28 | (list ,result ',form (list ,@(cdr form)))) 29 | ,result) 30 | (%ocl:opencl-error (c) 31 | (format t "~%~" 32 | (list (%ocl:opencl-error-code c) ',form (list ,@(cdr form)))) 33 | nil)))) 34 | 35 | (defmacro is-string (form &rest reason-args) 36 | `(is (typep ,form 'string) ,@reason-args)) 37 | 38 | (defun all-enums (foreign-typename) 39 | "just an alias" 40 | (sort (copy-list (foreign-enum-keyword-list foreign-typename)) #'string<)) 41 | 42 | (defun all-bitfields (foreign-typename) 43 | "just an alias" 44 | (sort (copy-list (foreign-bitfield-symbol-list foreign-typename)) #'string<)) 45 | 46 | (defun test-all-infos (things params name fn) 47 | (let ((things (ensure-list things))) 48 | (iter (for param in params) 49 | (format t "~%~" (list param name things)) 50 | (finishes 51 | (handler-case 52 | (format t "~%~" 53 | (list (apply fn (append things (list param))) param name things)) 54 | (%ocl:opencl-error (c) 55 | (format t "~%~" 56 | (list (%ocl:opencl-error-code c) param name things))) 57 | (babel:character-decoding-error (c) 58 | (fail "~%~" 59 | (list c (babel:character-decoding-error-octets c) param name things))) 60 | (error (c) 61 | (fail "~" 62 | (list (type-of c) c fn (append things (list param))))))) 63 | (handler-case 64 | (trivial-garbage:gc) 65 | (error (c) 66 | (fail "~" 67 | (list c fn (append things (list param))))))))) 68 | 69 | ;; :MEM-OFFSET and :MEM-ASSOCIATED-MEMOBJECT cause crash on OSX 70 | (defparameter *mem-info* 71 | #+darwin 72 | (set-difference (all-enums '%ocl:mem-info) '(:MEM-OFFSET :MEM-ASSOCIATED-MEMOBJECT)) 73 | #-darwin 74 | (all-enums '%ocl:mem-info)) 75 | 76 | ;; :PROGRAM-BINARY-SIZES and :PROGRAM-BINARIES cause crash on OSX 77 | (defparameter *program-info* 78 | #+darwin 79 | (set-difference (all-enums '%ocl:program-info) '(:PROGRAM-BINARY-SIZES :PROGRAM-BINARIES)) 80 | #-darwin 81 | (all-enums '%ocl:program-info)) 82 | 83 | (test setup 84 | (is-true (get-platform-ids)) 85 | (iter (for pid in (get-platform-ids)) 86 | (test-all-infos pid (all-enums '%ocl:platform-info) :platform #'get-platform-info) 87 | (finishes 88 | (iter (for type in (all-bitfields '%ocl:device-type)) 89 | (format t "~&list of device ids with platform-id ~s and type ~s:" pid (list type)) 90 | (for dids = (pie (get-device-ids pid (list type)))) 91 | (iter (for did in dids) 92 | (test-all-infos did (all-enums '%ocl:device-info) :device #'get-device-info) 93 | (format t "~& getting a context from device ~s and platform ~s" did pid) 94 | (for ctx = (create-context (list did) :context-platform pid)) ; :context-platform pid 95 | (test-all-infos ctx (all-enums '%ocl:context-info) :context #'get-context-info) 96 | (for cq = (pie (create-command-queue ctx did))) 97 | (when cq 98 | (test-all-infos cq (all-enums '%ocl:command-queue-info) :command-queue #'get-command-queue-info)) 99 | #+opencl-2.0 100 | (for cq2 = (pie (create-command-queue-with-properties ctx did))) 101 | #+opencl-2.0 102 | (when cq2 103 | (test-all-infos cq2 (all-enums '%ocl:command-queue-info) :command-queue #'get-command-queue-info))) 104 | (for ctx-type = (pie (create-context-from-type type :context-platform pid))) 105 | (when ctx-type 106 | (test-all-infos ctx-type (all-enums '%ocl:context-info) :context #'get-context-info)))))) 107 | 108 | (defvar *helloworld* " 109 | 110 | #pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable 111 | 112 | __constant char hw[] = \"Hello, World\"; 113 | 114 | __kernel void hello(__global char * out) { 115 | size_t tid = get_global_id(0); 116 | out[tid] = hw[tid]; 117 | } 118 | 119 | ") 120 | 121 | (test helloworld 122 | ;; http://developer.amd.com/tools-and-sdks/opencl-zone/opencl-resources/introductory-tutorial-to-opencl/ 123 | (iter (for pid in (get-platform-ids)) 124 | (iter (for type in (all-bitfields '%ocl:device-type)) 125 | ;; in this example, we do not care the device id 126 | (for ctx = 127 | (or (pie (create-context-from-type type :context-platform pid)) 128 | (progn 129 | (skip "No context found for the device type ~s in platform ~s" type pid) 130 | (next-iteration)))) 131 | (for devices = 132 | (or (pie (get-context-info ctx :context-devices)) 133 | (progn 134 | (skip "No device found for the context ~s" ctx) 135 | (next-iteration)))) 136 | (for did = (first devices)) 137 | (for cq = 138 | (or (pie #-opencl-2.0 139 | (create-command-queue ctx did) 140 | #+opencl-2.0 141 | (create-command-queue-with-properties ctx did)) 142 | (progn 143 | (skip "Command queue for ctx ~s and device ~s (~s) was not created" ctx did type) 144 | (next-iteration)))) 145 | (for result = 146 | (with-foreign-pointer-as-string ((out-host size) 13) ;; Hello, World : char[13] 147 | (let* ((out-device 148 | (or (pie (create-buffer ctx '(:mem-write-only :mem-use-host-ptr) size out-host)) 149 | (next-iteration))) 150 | (program 151 | (or (pie (create-program-with-source ctx *helloworld*)) 152 | (next-iteration)))) 153 | (or (pie (build-program program :devices (list did))) 154 | (next-iteration)) 155 | (let ((kernel (or (pie (create-kernel program "hello")) 156 | (next-iteration)))) 157 | (test-all-infos out-device *mem-info* :buffer #'get-mem-object-info) 158 | (test-all-infos program *program-info* :program #'get-program-info) 159 | (test-all-infos (list program did) (all-enums '%ocl:program-build-info) :build #'get-program-build-info) 160 | (test-all-infos kernel (all-enums '%ocl:kernel-info) :kernel #'get-kernel-info) 161 | (finishes 162 | (set-kernel-arg kernel 0 out-device '%ocl:mem)) 163 | ;; run the kernel 164 | (%ocl/h::with-foreign-array (global-work-size '%ocl:size-t (list size)) 165 | (pie (%ocl:enqueue-nd-range-kernel cq kernel 1 (cffi:null-pointer) global-work-size (cffi:null-pointer) 0 (cffi:null-pointer) (cffi:null-pointer)))) 166 | (pie 167 | (%ocl:enqueue-read-buffer cq out-device %ocl:true 0 size out-host 0 (cffi:null-pointer) (cffi:null-pointer))))))) 168 | (is (string= "Hello, World" (print result)))))) 169 | 170 | (test helloworld-from-file 171 | (iter (for pid in (get-platform-ids)) 172 | (iter (for type in (all-bitfields '%ocl:device-type)) 173 | ;; in this example, we do not care the device id 174 | (for ctx = 175 | (or (pie (create-context-from-type type :context-platform pid)) 176 | (progn 177 | (skip "No context found for the device type ~s in platform ~s" type pid) 178 | (next-iteration)))) 179 | (for devices = 180 | (or (pie (get-context-info ctx :context-devices)) 181 | (progn 182 | (skip "No device found for the context ~s" ctx) 183 | (next-iteration)))) 184 | (for did = (first devices)) 185 | (for cq = 186 | (or (pie #-opencl-2.0 187 | (create-command-queue ctx did) 188 | #+opencl-2.0 189 | (create-command-queue-with-properties ctx did)) 190 | (progn 191 | (skip "Command queue for ctx ~s and device ~s (~s) was not created" ctx did type) 192 | (next-iteration)))) 193 | (for result = 194 | (with-foreign-pointer-as-string ((out-host size) 13) ;; Hello, World : char[13] 195 | (let* ((out-device 196 | (or (pie (create-buffer ctx '(:mem-write-only :mem-use-host-ptr) size out-host)) 197 | (next-iteration))) 198 | (program 199 | (or (pie (create-program-with-source ctx (asdf:system-relative-pathname :eazy-opencl "t/helloworld.cl"))) 200 | (next-iteration)))) 201 | (or (pie (build-program program :devices (list did))) 202 | (next-iteration)) 203 | (let ((kernel (or (pie (create-kernel program "hello")) 204 | (next-iteration)))) 205 | (finishes 206 | (set-kernel-arg kernel 0 out-device '%ocl:mem)) 207 | ;; run the kernel 208 | (%ocl/h::with-foreign-array (global-work-size '%ocl:size-t (list size)) 209 | (pie (%ocl:enqueue-nd-range-kernel cq kernel 1 (cffi:null-pointer) global-work-size (cffi:null-pointer) 0 (cffi:null-pointer) (cffi:null-pointer)))) 210 | (pie 211 | (%ocl:enqueue-read-buffer cq out-device %ocl:true 0 size out-host 0 (cffi:null-pointer) (cffi:null-pointer))))))) 212 | (is (string= "Hello, World" (print result)))))) 213 | 214 | (test with-easy-opencl-setup 215 | (finishes 216 | (with-easy-opencl-setup (platform 217 | (device (lambda (device) 218 | (member :device-type-cpu 219 | (get-device-info device :device-type)))) 220 | ctx 221 | queue) 222 | (is (atom platform)) 223 | (is (atom device)) 224 | (is (atom ctx)) 225 | (is (atom queue)))) 226 | (finishes 227 | (with-easy-opencl-setup (_ 228 | (_ (lambda (device) 229 | (member :device-type-cpu 230 | (get-device-info device :device-type)))) 231 | _ queue) 232 | (is (atom queue)))) 233 | (signals simple-error 234 | (with-easy-opencl-setup ((_ (constantly nil)) _ _ _))) 235 | (signals simple-error 236 | (with-easy-opencl-setup (_ (_ (constantly nil)) _ _))) 237 | (signals simple-error 238 | (with-easy-opencl-setup (_ _ (_ (constantly nil)) _))) 239 | (signals simple-error 240 | (with-easy-opencl-setup (_ _ _ (_ (constantly nil)))))) 241 | 242 | 243 | (test helloworld-with-easy-opencl-setup 244 | (with-easy-opencl-setup (platform 245 | (device (lambda (device) 246 | (member :device-type-cpu 247 | (get-device-info device :device-type)))) 248 | ctx 249 | queue) 250 | (is (string= 251 | "Hello, World" 252 | (with-foreign-pointer-as-string ((out-host size) 13) ;; Hello, World : char[13] 253 | (let* ((out-device (create-buffer ctx '(:mem-write-only :mem-use-host-ptr) size out-host)) 254 | (program (create-program-with-source ctx (asdf:system-relative-pathname :eazy-opencl "t/helloworld.cl")))) 255 | (build-program program :devices (list device)) 256 | (let ((kernel (create-kernel program "hello"))) 257 | (set-kernel-arg kernel 0 out-device '%ocl:mem) 258 | (%ocl/h::with-foreign-array (global-work-size '%ocl:size-t (list size)) 259 | (%ocl:enqueue-nd-range-kernel queue kernel 1 (cffi:null-pointer) global-work-size (cffi:null-pointer) 0 (cffi:null-pointer) (cffi:null-pointer))) 260 | (%ocl:enqueue-read-buffer queue out-device %ocl:true 0 size out-host 0 (cffi:null-pointer) (cffi:null-pointer))))))))) 261 | 262 | 263 | #+nil 264 | (test fancy-memory-interface 265 | (with-easy-opencl-setup (platform 266 | (device (lambda (device) 267 | (eq (get-device-info device :device-type) 268 | :device-type-gpu))) 269 | ctx 270 | queue) 271 | (is (string= 272 | "Hello, World" 273 | (print 274 | (with-naive-shared-array (out-host out-device 13) 275 | (load-program ctx source) 276 | (kernel-call (load-program ctx source) "hello" out-device 277 | ;; work dim 278 | ;; global work offset 279 | ;; global work size 280 | ;; local work size 281 | ) 282 | (read-buffer out-device out-host))))))) 283 | -------------------------------------------------------------------------------- /testscr.ros: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #|-*- mode:lisp -*-|# 3 | #| 4 | exec ros -Q -- $0 "$@" 5 | |# 6 | 7 | (ql:quickload '(:fiveam :trivial-features :cffi :cffi-grovel)) 8 | 9 | (in-package :ASDF/BUNDLE) 10 | 11 | #+ccl 12 | (defun bundle-pathname-type (bundle-type) 13 | (etypecase bundle-type 14 | ((eql :no-output-file) nil) ;; should we error out instead? 15 | ((or null string) bundle-type) 16 | ((eql :fasl) #-(or ecl mkcl) (compile-file-type) #+(or ecl mkcl) "fasb") 17 | #+ecl 18 | ((member :dll :lib :shared-library :static-library :program :object :program) 19 | (compile-file-type :type bundle-type)) 20 | ((member :image) #-allegro "image" #+allegro "dxl") 21 | ((member :dll :shared-library) (cond ((os-macosx-p) "dylib") ((os-unix-p) "so") ((os-windows-p) "dll"))) 22 | ((member :lib :static-library) (cond ((os-unix-p) "a") 23 | ((os-windows-p) (if (featurep '(:or :mingw32 :mingw64)) "a" "lib")))) 24 | ((eql :program) (cond ((os-unix-p) nil) ((os-windows-p) "exe"))))) 25 | 26 | #+ccl 27 | (trace UIOP/FILESYSTEM:INTER-DIRECTORY-SEPARATOR 28 | UIOP/STREAM:NULL-DEVICE-PATHNAME 29 | UIOP/STREAM:DEFAULT-TEMPORARY-DIRECTORY 30 | UIOP/RUN-PROGRAM::ESCAPE-SHELL-TOKEN 31 | UIOP/RUN-PROGRAM::%NORMALIZE-SYSTEM-COMMAND 32 | UIOP/RUN-PROGRAM::%REDIRECTED-SYSTEM-COMMAND 33 | UIOP/CONFIGURATION:SYSTEM-CONFIGURATION-DIRECTORIES 34 | UIOP/CONFIGURATION:USER-CONFIGURATION-DIRECTORIES 35 | ASDF/SOURCE-REGISTRY:DEFAULT-SYSTEM-SOURCE-REGISTRY 36 | ASDF/SOURCE-REGISTRY:DEFAULT-USER-SOURCE-REGISTRY 37 | ASDF/BUNDLE:BUNDLE-PATHNAME-TYPE) 38 | 39 | (in-package :cl-user) 40 | 41 | (ql:quickload :eazy-opencl.test) 42 | 43 | (defun main (&rest argv) 44 | (declare (ignorable argv)) 45 | (uiop:quit (if (every (complement #'fiveam::test-failure-p) 46 | (handler-case 47 | (let ((result-list (fiveam:run :eazy-opencl))) 48 | (fiveam:explain! result-list) 49 | result-list) 50 | (serious-condition (c) 51 | (describe c) 52 | (uiop:quit 2)))) 53 | 0 1))) 54 | --------------------------------------------------------------------------------