From 6fe823a614279cceb2d48507bd8e93b0efd87f94 Mon Sep 17 00:00:00 2001 From: Thomas Albers Date: Sat, 4 Mar 2023 22:47:28 +0100 Subject: Initial commit --- src/types.lisp | 630 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 630 insertions(+) create mode 100644 src/types.lisp (limited to 'src/types.lisp') diff --git a/src/types.lisp b/src/types.lisp new file mode 100644 index 0000000..20a4882 --- /dev/null +++ b/src/types.lisp @@ -0,0 +1,630 @@ +(in-package #:ocl-ffi) + +(cffi:defctype cl-char :int8) +(cffi:defctype cl-uchar :uint8) +(cffi:defctype cl-short :int16) +(cffi:defctype cl-ushort :uint16) +(cffi:defctype cl-int :int32) +(cffi:defctype cl-uint :uint32) +(cffi:defctype cl-long :int64) +(cffi:defctype cl-ulong :uint64) + +(cffi:defctype cl-half :uint16) +(cffi:defctype cl-float :float) +(cffi:defctype cl-double :double) + +(cffi:defctype cl-platform-id :pointer) +(cffi:defctype cl-device-id :pointer) +(cffi:defctype cl-context :pointer) +(cffi:defctype cl-command-queue :pointer) +(cffi:defctype cl-mem :pointer) +(cffi:defctype cl-program :pointer) +(cffi:defctype cl-kernel :pointer) +(cffi:defctype cl-event :pointer) +(cffi:defctype cl-sampler :pointer) + +;;; Error Codes +(cffi:defcenum (cl-error-code cl-int) + (:complete 0) + (:running 1) + (:submitted 2) + (:queued 3) + (:success 0) + (:device-not-found -1) + (:device-not-available -2) + (:compiler-not-available -3) + (:mem-object-allocation-failure -4) + (:out-of-resources -5) + (:out-of-host-memory -6) + (:profiling-info-not-available -7) + (:mem-copy-overlap -8) + (:image-format-mismatch -9) + (:image-format-not-supported -10) + (:build-program-failure -11) + (:map-failure -12) + (:misaligned-sub-buffer-offset -13) + (:exec-status-error-for-events-in-wait-list -14) + (:compile-program-failure -15) + (:linker-not-available -16) + (:link-program-failure -17) + (:device-partition-failed -18) + (:kernel-arg-info-not-available -19) + (:invalid-value -30) + (:invalid-device-type -31) + (:invalid-platform -32) + (:invalid-device -33) + (:invalid-context -34) + (:invalid-queue-properties -35) + (:invalid-command-queue -36) + (:invalid-host-ptr -37) + (:invalid-mem-object -38) + (:invalid-image-format-descriptor -39) + (:invalid-image-size -40) + (:invalid-sampler -41) + (:invalid-binary -42) + (:invalid-build-options -43) + (:invalid-program -44) + (:invalid-program-executable -45) + (:invalid-kernel-name -46) + (:invalid-kernel-definition -47) + (:invalid-kernel -48) + (:invalid-arg-index -49) + (:invalid-arg-value -50) + (:invalid-arg-size -51) + (:invalid-kernel-args -52) + (:invalid-work-dimension -53) + (:invalid-work-group-size -54) + (:invalid-work-item-size -55) + (:invalid-global-offset -56) + (:invalid-event-wait-list -57) + (:invalid-event -58) + (:invalid-operation -59) + (:invalid-gl-object -60) + (:invalid-buffer-size -61) + (:invalid-mip-level -62) + (:invalid-global-work-size -63) + (:invalid-property -64) + (:invalid-image-descriptor -65) + (:invalid-compiler-options -66) + (:invalid-linker-options -67) + (:invalid-device-partition-count -68) + (:invalid-pipe-size -69) + (:invalid-device-queue -70) + (:invalid-spec-id -71) + (:max-size-restriction-exceeded -72)) + +(cffi:defcenum (cl-bool cl-uint) + (:false 0) + (:true 1) + (:blocking 1) + (:non-blocking 0)) + +(cffi:defctype cl-bitfield cl-ulong) +(cffi:defctype cl-properties cl-ulong) + +(cffi:defcenum (cl-platform-info cl-uint) + (:platform-profile #x0900) + (:platform-version #x0901) + (:platform-name #x0902) + (:platform-vendor #x0903) + (:platform-extensions #x0904) + (:platform-host-timer-resolution #x0905) + (:platform-numeric-version #x0906) + (:platform-extensions-with-version #x0907)) + +(cffi:defcenum (cl-device-info cl-uint) + (:device-type #x1000) + (:device-vendor-id #x1001) + (:device-max-compute-units #x1002) + (:device-max-work-item-dimensions #x1003) + (:device-max-work-group-size #x1004) + (:device-max-work-item-sizes #x1005) + (:device-preferred-vector-width-char #x1006) + (:device-preferred-vector-width-short #x1007) + (:device-preferred-vector-width-int #x1008) + (:device-preferred-vector-width-long #x1009) + (:device-preferred-vector-width-float #x100a) + (:device-preferred-vector-width-double #x100b) + (:device-max-clock-frequency #x100c) + (:device-address-bits #x100d) + (:device-max-read-image-args #x100e) + (:device-max-write-image-args #x100f) + (:device-max-mem-alloc-size #x1010) + (:device-image2d-max-width #x1011) + (:device-image2d-max-height #x1012) + (:device-image3d-max-width #x1013) + (:device-image3d-max-height #x1014) + (:device-image3d-max-depth #x1015) + (:device-image-support #x1016) + (:device-max-parameter-size #x1017) + (:device-max-samplers #x1018) + (:device-mem-base-addr-align #x1019) + (:device-min-data-type-align-size #x101a) + (:device-single-fp-config #x101b) + (:device-global-mem-cache-type #x101c) + (:device-global-mem-cacheline-size #x101d) + (:device-global-mem-cache-size #x101e) + (:device-global-mem-size #x101f) + (:device-max-constant-buffer-size #x1020) + (:device-max-constant-args #x1021) + (:device-local-mem-type #x1022) + (:device-local-mem-size #x1023) + (:device-error-correction-support #x1024) + (:device-profiling-timer-resolution #x1025) + (:device-endian-little #x1026) + (:device-available #x1027) + (:device-compiler-available #x1028) + (:device-execution-capabilities #x1029) + (:device-queue-properties #x102a) + (:device-queue-on-host-properties #x102a) + (:device-name #x102b) + (:device-vendor #x102c) + (:driver-version #x102d) + (:device-profile #x102e) + (:device-version #x102f) + (:device-extensions #x1030) + (:device-platform #x1031) + (:device-double-fp-config #x1032) + (:device-preferred-vector-width-half #x1034) + (:device-host-unified-memory #x1035) + (:device-native-vector-width-char #x1036) + (:device-native-vector-width-short #x1037) + (:device-native-vector-width-int #x1038) + (:device-native-vector-width-long #x1039) + (:device-native-vector-width-float #x103a) + (:device-native-vector-width-double #x103b) + (:device-native-vector-width-half #x103c) + (:device-opencl-c-version #x103d) + (:device-linker-available #x103e) + (:device-built-in-kernels #x103f) + (:device-image-max-buffer-size #x1040) + (:device-image-max-array-size #x1041) + (:device-parent-device #x1042) + (:device-partition-max-sub-devices #x1043) + (:device-partition-properties #x1044) + (:device-partition-affinity-domain #x1045) + (:device-partition-type #x1046) + (:device-reference-count #x1047) + (:device-preferred-interop-user-sync #x1048) + (:device-printf-buffer-size #x1049) + (:device-image-pitch-alignment #x104a) + (:device-image-base-address-alignment #x104b) + (:device-max-read-write-image-args #x104c) + (:device-max-global-variable-size #x104d) + (:device-queue-on-device-properties #x104e) + (:device-queue-on-device-preferred-size #x104f) + (:device-queue-on-device-max-size #x1050) + (:device-max-on-device-queues #x1051) + (:device-max-on-device-events #x1052) + (:device-svm-capabilities #x1053) + (:device-global-variable-preferred-total-size #x1054) + (:device-max-pipe-args #x1055) + (:device-pipe-max-active-reservations #x1056) + (:device-pipe-max-packet-size #x1057) + (:device-preferred-platform-atomic-alignment #x1058) + (:device-preferred-global-atomic-alignment #x1059) + (:device-preferred-local-atomic-alignment #x105a) + (:device-il-version #x105b) + (:device-max-num-sub-groups #x105c) + (:device-sub-group-independent-forward-progress #x105d) + (:device-numeric-version #x105e) + (:device-extensions-with-version #x1060) + (:device-ils-with-version #x1061) + (:device-built-in-kernels-with-version #x1062) + (:device-atomic-memory-capabilities #x1063) + (:device-atomic-fence-capabilities #x1064) + (:device-non-uniform-work-group-support #x1065) + (:device-opencl-c-all-versions #x1066) + (:device-preferred-work-group-size-multiple #x1067) + (:device-work-group-collective-functions-support #x1068) + (:device-generic-address-space-support #x1069) + (:device-opencl-c-features #x106f) + (:device-device-enqueue-capabilities #x1070) + (:device-pipe-support #x1071) + (:device-latest-conformance-version-passed #x1072)) + +(cffi:defcenum (cl-device-mem-cache-type cl-uint) + (:none #x0) + (:read-only-cache #x1) + (:read-write-cache #x2)) + +(cffi:defcenum (cl-device-local-mem-type cl-uint) + (:local #x1) + (:global #x2)) + + +(cffi:defcenum (cl-context-info cl-uint) + (:context-reference-count #x1080) + (:context-devices #x1081) + (:context-properties #x1082) + (:context-num-devices #x1083)) + +(cffi:defcenum (cl-command-queue-info cl-uint) + (:queue-context #x1090) + (:queue-device #x1091) + (:queue-reference-count #x1092) + (:queue-properties #x1093) + (:queue-size #x1094) + (:queue-device-default #x1095) + (:queue-properties-array #x1098)) + +(cffi:defcenum (cl-channel-order cl-uint) + (:r #x10b0) + (:a #x10b1) + (:rg #x10b2) + (:ra #x10b3) + (:rgb #x10b4) + (:rgba #x10b5) + (:bgra #x10b6) + (:argb #x10b7) + (:intensity #x10b8) + (:luminance #x10b9) + (:rx #x10ba) + (:rgx #x10bb) + (:rgbx #x10bc) + (:depth #x10bd) + (:depth-stencil #x10be) + (:srgb #x10bf) + (:srgbx #x10c0) + (:srgba #x10c1) + (:sbgra #x10c2) + (:abgr #x10c3)) + +(cffi:defcenum (cl-channel-type cl-uint) + (:snorm-int8 #x10d0) + (:snorm-int16 #x10d1) + (:unorm-int8 #x10d2) + (:unorm-int16 #x10d3) + (:unorm-short-565 #x10d4) + (:unorm-short-555 #x10d5) + (:unorm-int-101010 #x10d6) + (:signed-int8 #x10d7) + (:signed-int16 #x10d8) + (:signed-int32 #x10d9) + (:unsigned-int8 #x10da) + (:unsigned-int16 #x10db) + (:unsigned-int32 #x10dc) + (:half-float #x10dd) + (:float #x10de) + (:unorm-int24 #x10df) + (:unorm-int-101010-2 #x10e0)) + +(cffi:defcenum (cl-mem-object-type cl-uint) + (:mem-object-buffer #x10f0) + (:mem-object-image2d #x10f1) + (:mem-object-image3d #x10f2) + (:mem-object-image2d-array #x10f3) + (:mem-object-image1d #x10f4) + (:mem-object-image1d-array #x10f5) + (:mem-object-image1d-buffer #x10f6) + (:mem-object-pipe #x10f7)) + +(cffi:defcenum (cl-mem-info cl-uint) + (:mem-type #x1100) + (:mem-flags #x1101) + (:mem-size #x1102) + (:mem-host-ptr #x1103) + (:mem-map-count #x1104) + (:mem-reference-count #x1105) + (:mem-context #x1106) + (:mem-associated-memobject #x1107) + (:mem-offset #x1108) + (:mem-uses-svm-pointer #x1109) + (:mem-properties #x110a)) + +(cffi:defcenum (cl-image-info cl-uint) + (:image-format #x1110) + (:image-element-size #x1111) + (:image-row-pitch #x1112) + (:image-slice-pitch #x1113) + (:image-width #x1114) + (:image-height #x1115) + (:image-depth #x1116) + (:image-array-size #x1117) + (:image-buffer #x1118) + (:image-num-mip-levels #x1119) + (:image-num-samples #x111a)) + +(cffi:defcenum (cl-pipe-info cl-uint) + (:pipe-packet-size #x1120) + (:pipe-max-packets #x1121) + (:pipe-properties #x1122)) + +(cffi:defcenum (cl-addressing-mode cl-uint) + (:address-none #x1130) + (:address-clamp-to-edge #x1131) + (:address-clamp #x1132) + (:address-repeat #x1133) + (:address-mirrored-repeat #x1134)) + +(cffi:defcenum (cl-filter-mode cl-uint) + (:filter-nearest #x1140) + (:filter-linear #x1141)) + +(cffi:defcenum (cl-sampler-info cl-uint) + (:sampler-reference-count #x1150) + (:sampler-context #x1151) + (:sampler-normalized-coords #x1152) + (:sampler-addressing-mode #x1153) + (:sampler-filter-mode #x1154) + (:sampler-mip-filter-mode #x1155) + (:sampler-lod-min #x1156) + (:sampler-lod-max #x1157) + (:sampler-properties #x1158)) + +(cffi:defcenum (cl-program-info cl-uint) + (:program-reference-count #x1160) + (:program-context #x1161) + (:program-num-devices #x1162) + (:program-devices #x1163) + (:program-source #x1164) + (:program-binary-sizes #x1165) + (:program-binaries #x1166) + (:program-num-kernels #x1167) + (:program-kernel-names #x1168) + (:program-il #x1169) + (:program-scope-global-ctors-present #x116a) + (:program-scope-global-dtors-present #x116b)) + +(cffi:defcenum (cl-program-build-info cl-uint) + (:program-build-status #x1181) + (:program-build-options #x1182) + (:program-build-log #x1183) + (:program-binary-type #x1184) + (:program-build-global-variable-total-size #x1185)) + +(cffi:defcenum (cl-build-status cl-int) + (:build-success 0) + (:build-none -1) + (:build-error -2) + (:build-in-progress -3)) + +(cffi:defcenum (cl-kernel-info cl-uint) + (:kernel-function-name #x1190) + (:kernel-num-args #x1191) + (:kernel-reference-count #x1192) + (:kernel-context #x1193) + (:kernel-program #x1194) + (:kernel-attributes #x1195)) + +(cffi:defcenum (cl-kernel-arg-info cl-uint) + (:kernel-arg-address-qualifier #x1196) + (:kernel-arg-access-qualifier #x1197) + (:kernel-arg-type-name #x1198) + (:kernel-arg-type-qualifier #x1199) + (:kernel-arg-name #x119a)) + +(cffi:defcenum (cl-kernel-arg-address-qualifier cl-uint) + (:kernel-arg-address-global #x119b) + (:kernel-arg-address-local #x119c) + (:kernel-arg-address-constant #x119d) + (:kernel-arg-address-private #x119e)) + +(cffi:defcenum (cl-kernel-arg-access-qualifier cl-uint) + (:kernel-arg-access-read-only #x11a0) + (:kernel-arg-access-write-only #x11a1) + (:kernel-arg-access-read-write #x11a2) + (:kernel-arg-access-none #x11a3)) + +(cffi:defcenum (cl-kernel-work-group-info cl-uint) + (:kernel-work-group-size #x11b0) + (:kernel-compile-work-group-size #x11b1) + (:kernel-local-mem-size #x11b2) + (:kernel-preferred-work-group-size-multiple #x11b3) + (:kernel-private-mem-size #x11b4) + (:kernel-global-work-size #x11b5)) + +(cffi:defcenum (cl-kernel-sub-group-info cl-uint) + (:kernel-max-sub-group-size-for-ndrange #x2033) + (:kernel-sub-group-count-for-ndrange #x2034) + (:kernel-local-size-for-sub-group-count #x11b8) + (:kernel-max-num-sub-groups #x11b9) + (:kernel-compile-num-sub-groups #x11ba)) + +(cffi:defcenum (cl-kernel-exec-info cl-uint) + (:kernel-exec-info-svm-ptrs #x11b6) + (:kernel-exec-info-svm-fine-grain-system #x11b7)) + + +(cffi:defcenum (cl-event-info cl-uint) + (:event-command-queue #x11d0) + (:event-command-type #x11d1) + (:event-reference-count #x11d2) + (:event-command-execution-status #x11d3) + (:event-context #x11d4)) + +(cffi:defcenum (cl-command-type cl-uint) + (:command-ndrange-kernel #x11f0) + (:command-task #x11f1) + (:command-native-kernel #x11f2) + (:command-read-buffer #x11f3) + (:command-write-buffer #x11f4) + (:command-copy-buffer #x11f5) + (:command-read-image #x11f6) + (:command-write-image #x11f7) + (:command-copy-image #x11f8) + (:command-copy-image-to-buffer #x11f9) + (:command-copy-buffer-to-image #x11fa) + (:command-map-buffer #x11fb) + (:command-map-image #x11fc) + (:command-unmap-mem-object #x11fd) + (:command-marker #x11fe) + (:command-acquire-gl-objects #x11ff) + (:command-release-gl-objects #x1200) + (:command-read-buffer-rect #x1201) + (:command-write-buffer-rect #x1202) + (:command-copy-buffer-rect #x1203) + (:command-user #x1204) + (:command-barrier #x1205) + (:command-migrate-mem-objects #x1206) + (:command-fill-buffer #x1207) + (:command-fill-image #x1208) + (:command-svm-free #x1209) + (:command-svm-memcpy #x120a) + (:command-svm-memfill #x120b) + (:command-svm-map #x120c) + (:command-svm-unmap #x120d) + (:command-svm-migrate-mem #x120e)) + +(defconstant +complete+ #x0) +(defconstant +running+ #x1) +(defconstant +submitted+ #x2) +(defconstant +queued+ #x3) + +(cffi:defcenum (cl-buffer-create-type cl-uint) + (:buffer-create-type-region #x1220)) + +(cffi:defcenum (cl-profiling-info cl-uint) + (:profiling-command-queued #x1280) + (:profiling-command-submit #x1281) + (:profiling-command-start #x1282) + (:profiling-command-end #x1283) + (:profiling-command-complete #x1284)) + +(cffi:defcenum (cl-khronos-vendor-id cl-uint) + (:khronos-vendor-id-codeplay #x10004)) + +(cffi:defbitfield (cl-device-type cl-bitfield) + :device-type-default + :device-type-cpu + :device-type-gpu + :device-type-accelerator + :device-type-custom + (:device-type-all #xffffffff)) + +(cffi:defbitfield (cl-device-fp-config cl-bitfield) + :fp-denorm + :fp-inf-nan + :fp-round-to-nearest + :fp-round-to-zero + :fp-round-to-inf + :fp-fma + :fp-soft-float + :fp-correctly-rounded-divide-sqrt) + +(cffi:defbitfield (cl-device-exec-capabilities cl-bitfield) + :exec-kernel + :exec-native-kernel) + +(cffi:defbitfield (cl-device-svm-capabilities cl-bitfield) + :device-svm-coarse-grain-buffer + :device-svm-fine-grain-buffer + :device-svm-fine-grain-system + :device-svm-atomics) + +(cffi:defbitfield (cl-command-queue-properties cl-bitfield) + :queue-out-of-order-exec-mode-enable + :queue-profiling-enable + :queue-on-device + :queue-on-device-default) + +(cffi:defbitfield (cl-device-affinity-domain cl-bitfield) + :device-affinity-domain-numa + :device-affinity-domain-l4-cache + :device-affinity-domain-l3-cache + :device-affinity-domain-l2-cache + :device-affinity-domain-l1-cache + :device-affinity-domain-next-partitionable) + +(cffi:defbitfield (cl-mem-flags cl-bitfield) + :mem-read-write + :mem-write-only + :mem-read-only + :mem-use-host-ptr + :mem-alloc-host-ptr + :mem-copy-host-ptr + (:mem-host-write-only #x80) + :mem-host-read-only + :mem-host-no-access + :mem-svm-fine-grain-buffer + :mem-svm-atomics + :mem-kernel-read-and-write) + +(cffi:defbitfield (cl-svm-mem-flags cl-bitfield) + :mem-read-write + :mem-write-only + :mem-read-only + :mem-use-host-ptr + :mem-alloc-host-ptr + :mem-copy-host-ptr + (:mem-host-write-only #x80) + :mem-host-read-only + :mem-host-no-access + :mem-svm-fine-grain-buffer + :mem-svm-atomics + :mem-kernel-read-and-write) + + +(cffi:defbitfield (cl-mem-migration-flags cl-bitfield) + :migrate-mem-object-host + :migrate-mem-object-content-undefined) + +(cffi:defbitfield (cl-program-binary-type cl-uint) + :program-binary-type-none + :program-binary-type-compiled-object + :program-binary-type-library + :program-binary-type-executable) + +(cffi:defbitfield (cl-map-flags cl-bitfield) + :map-read + :map-write + :map-write-invalidate-region) + +(cffi:defbitfield (cl-kernel-arg-type-qualifier cl-bitfield) + (:kernel-arg-type-none+ #x0) + :kernel-arg-type-const + :kernel-arg-type-restrict + :kernel-arg-type-volatile + :kernel-arg-type-pipe) + +(cffi:defbitfield (cl-device-atomic-capabilities cl-bitfield) + :device-atomic-order-relaxed + :device-atomic-order-acq-rel + :device-atomic-order-seq-cst + :device-atomic-scope-work-item + :device-atomic-scope-work-group + :device-atomic-scope-device + :device-atomic-scope-all-devices) + +(cffi:defbitfield (cl-device-device-enqueue-capabilities cl-bitfield) + :device-queue-supported + :device-queue-replaceable-default) + +(cffi:defctype cl-mem-properties cl-properties) +(cffi:defctype cl-queue-properties cl-properties) +(cffi:defctype cl-device-partition-property :intptr) + +(cffi:defcenum (cl-context-properties :intptr :allow-undeclared-values t) + (:context-platform #x1084) + (:context-interop-user-sync #x1085)) + +(cffi:defctype cl-pipe-properties :intptr) +(cffi:defctype cl-sampler-properties cl-properties) + +(cffi:defctype cl-version cl-uint) + +(cffi:defcstruct cl-image-format + (image-channel-order cl-channel-order) + (image-channel-data-type cl-channel-type)) + +(cffi:defcstruct cl-buffer-region + (origin :size) + (size :size)) + +(cffi:defcstruct cl-name-version + (version cl-version) + ;; +name-version-max-name-size+ 64 + (name :char :count 64)) + +(cffi:defcstruct cl-image-desc + (image-type cl-mem-object-type) + (image-width :size) + (image-height :size) + (image-depth :size) + (image-array-size :size) + (image-row-pitch :size) + (image-slice-pitch :size) + (num-mip-levels cl-uint) + (num-samples cl-uint) + ;; Anon union buffer / mem_object + (buffer cl-mem)) -- cgit v1.2.3