This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deprecated.go
105 lines (99 loc) · 4.15 KB
/
deprecated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package cl30
// #cgo CFLAGS: -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_2_APIS
// #cgo CXXFLAGS: -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_2_APIS
// #cgo CPPFLAGS: -DCL_USE_DEPRECATED_OPENCL_1_2_APIS -DCL_USE_DEPRECATED_OPENCL_2_2_APIS
// #include "api.h"
// extern cl_int cl30SetProgramReleaseCallback(cl_program program, uintptr_t *userData);
import "C"
import "unsafe"
// CreateCommandQueue creates a command-queue on a specific device.
//
// Deprecated: 1.2; Use CreateCommandQueueWithProperties() instead.
// See also: https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/clCreateCommandQueue.html
func CreateCommandQueue(context Context, deviceID DeviceID, properties CommandQueuePropertiesFlags) (CommandQueue, error) {
var status C.cl_int
commandQueue := C.clCreateCommandQueue(
context.handle(),
deviceID.handle(),
C.cl_command_queue_properties(properties),
&status)
if status != C.CL_SUCCESS {
return 0, StatusError(status)
}
return CommandQueue(*((*uintptr)(unsafe.Pointer(&commandQueue)))), nil
}
// CreateSampler creates a sampler object.
//
// Deprecated: 1.2; Use CreateSamplerWithProperties() instead.
// See also: https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/clCreateSampler.html
func CreateSampler(context Context, normalizedCoords bool, addressingMode SamplerAddressingMode, filterMode SamplerFilterMode) (Sampler, error) {
var status C.cl_int
sampler := C.clCreateSampler(
context.handle(),
C.cl_bool(BoolFrom(normalizedCoords)),
C.cl_addressing_mode(addressingMode),
C.cl_filter_mode(filterMode),
&status)
if status != C.CL_SUCCESS {
return 0, StatusError(status)
}
return Sampler(*((*uintptr)(unsafe.Pointer(&sampler)))), nil
}
// EnqueueTask enqueues a command to execute a kernel, using a single work-item, on a device.
//
// EnqueueTask() is equivalent to calling EnqueueNDRangeKernel() with one WorkDimension that has
// GlobalOffset = 0, GlobalSize = 1, and LocalSize = 1.
//
// Deprecated: 1.2; Use EnqueueNDRangeKernel() instead.
// See also: https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/clEnqueueTask.html
func EnqueueTask(commandQueue CommandQueue, kernel Kernel, waitList []Event, event *Event) error {
var rawWaitList unsafe.Pointer
if len(waitList) > 0 {
rawWaitList = unsafe.Pointer(&waitList[0])
}
status := C.clEnqueueTask(
commandQueue.handle(),
kernel.handle(),
C.cl_uint(len(waitList)),
(*C.cl_event)(rawWaitList),
(*C.cl_event)(unsafe.Pointer(event)))
if status != C.CL_SUCCESS {
return StatusError(status)
}
return nil
}
// SetProgramReleaseCallback registers a destructor callback function with a program object.
//
// Each call to SetProgramReleaseCallback() registers the specified callback function on a callback stack associated
// with program. The registered callback functions are called in the reverse order in which they were registered.
// The registered callback functions are called after destructors (if any) for program scope global variables (if any)
// are called and before the program object is deleted.
// This provides a mechanism for an application to be notified when destructors for program scope global variables
// are complete.
//
// SetProgramReleaseCallback() may unconditionally return an error if no devices in the context associated with
// program support destructors for program scope global variables.
// Support for constructors and destructors for program scope global variables is required only for OpenCL 2.2 devices.
//
// Since: 2.2
// Deprecated: 2.2
// See also: https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/clSetProgramReleaseCallback.html
func SetProgramReleaseCallback(program Program, callback func()) error {
callbackUserData, err := userDataFor(callback)
if err != nil {
return err
}
status := C.cl30SetProgramReleaseCallback(program.handle(), callbackUserData.ptr)
if status != C.CL_SUCCESS {
callbackUserData.Delete()
return StatusError(status)
}
return nil
}
//export cl30GoProgramReleaseCallback
func cl30GoProgramReleaseCallback(_ Program, userData *C.uintptr_t) {
callbackUserData := userDataFrom(userData)
callback := callbackUserData.Value().(func())
callbackUserData.Delete()
callback()
}