You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/context.md
+26-26Lines changed: 26 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,18 +5,18 @@
5
5
The `create` function creates an OpenCL context, which is used by the OpenCL runtime to manage objects such as command-queues, memory, programs, and kernels.
6
6
7
7
```zig
8
-
pub inline fn create(
9
-
properties: ?[]const cl_context_properties,
10
-
devices: []const cl_device_id,
11
-
pfn_notify: ?*const pfn_notify_callback,
12
-
user_data: ?*anyopaque
13
-
) errors.opencl_error!cl_context;
8
+
pub fn create(
9
+
properties: ?[]const Properties,
10
+
devices: []const DeviceId,
11
+
pfn_notify: ?*const Callback,
12
+
user_data: ?*anyopaque,
13
+
) OpenCLError!Context;
14
14
```
15
15
16
16
#### Parameters
17
17
18
-
-`properties`: An optional list of context properties and their values. To use this, please go to the `context.enums.context_properties` enum and read the OpenCL PDF documentation about to use it.
19
-
-`devices`: A list of `device.cl_device_id` specifying the devices to be associated with the context.
18
+
-`properties`: An optional list of context properties and their values. To use this, please go to the `Property` struct and read the OpenCL PDF documentation about to use it.
19
+
-`devices`: A list of `DeviceId` specifying the devices to be associated with the context.
20
20
-`pfn_notify`: A callback function that can be registered by the application. It will be called when there is a context error.
21
21
-`user_data`: A pointer to user-supplied data that will be passed to the callback function.
22
22
@@ -35,27 +35,27 @@ The function uses Zig's error handling features to manage potential OpenCL error
35
35
## Creating Context from Type
36
36
37
37
```zig
38
-
pub inline fn create_from_type(
39
-
properties: ?[]const cl_context_properties,
40
-
device_type: device.enums.device_type,
41
-
pfn_notify: ?*const pfn_notify_callback,
42
-
user_data: ?*anyopaque
43
-
) errors.opencl_error!cl_context;
38
+
pub fn createFromType(
39
+
properties: ?[]const Properties,
40
+
device_type: device.Type,
41
+
pfn_notify: ?*const Callback,
42
+
user_data: ?*anyopaque,
43
+
) OpenCLError!Context;
44
44
```
45
45
46
46
#### Parameters
47
47
48
48
-`properties`: A list of context property names and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list of supported properties, and their default values if not present in `properties`, is described in the Context Properties table. `properties` can be `null`, in which case all properties take on their default values.
49
49
50
-
-`device_type`: A bit-field that identifies the type of device and is described in the Device Types table. This is a member of the enum `device.enums.device_type`. For example:
50
+
-`device_type`: A bit-field that identifies the type of device and is described in the Device Types table. This is a member of the enum `device.Type`. For example:
51
51
-`CL_DEVICE_TYPE_CPU` -> `cpu`
52
52
-`CL_DEVICE_TYPE_GPU` -> `gpu`
53
53
-`pfn_notify`: A callback function that can be registered by the application. This callback function will be used by the OpenCL implementation to report errors that occur during context creation as well as errors that occur at runtime in this context. This callback function may be called asynchronously by the OpenCL implementation. It is the application's responsibility to ensure that the callback function is thread-safe. If `pfn_notify` is `null`, no callback function is registered.
54
54
55
55
-`user_data`: Will be passed as the `user_data` argument when `pfn_notify` is called. `user_data` can be `null`.
56
56
57
57
58
-
For a full list of the enum members, refer to the OpenCL PDF documentation or the `src/enums/device.zig` file where the enums are defined.
58
+
For a full list of the enum members, refer to the OpenCL PDF documentation or the `src/device.zig` file where the enums are defined.
59
59
60
60
#### Error Handling
61
61
@@ -76,26 +76,26 @@ The function uses Zig's error handling features to manage potential OpenCL error
76
76
The `get_info` function is used to query various types of information about an OpenCL context, such as the reference count, number of devices, and other attributes.
77
77
78
78
```zig
79
-
pub inline fn get_info(
80
-
context: cl_context,
81
-
param_name: enums.context_info,
79
+
pub fn getInfo(
80
+
context: Context,
81
+
param_name: Info,
82
82
param_value_size: usize,
83
83
param_value: ?*anyopaque,
84
-
param_value_size_ret: ?*usize
85
-
) errors.opencl_error!void;
84
+
param_value_size_ret: ?*usize,
85
+
) OpenCLError!void;
86
86
```
87
87
88
88
#### Parameters
89
89
90
90
-`context`: Specifies the OpenCL context being queried.
91
-
-`param_name`: Specifies the information to query. This is a member of the `context.enums.context_info` enum. For example:
91
+
-`param_name`: Specifies the information to query. This is a member of the `Info` enum. For example:
-`param_value_size`: Specifies the size in bytes of memory pointed to by `param_value`. This size must be greater than or equal to the size of the return type as described in the Context Attributes table.
95
95
-`param_value`: A pointer to memory where the appropriate result being queried is returned. If `param_value` is `null`, it is ignored.
96
96
-`param_value_size_ret`: Returns the actual size in bytes of data being queried by `param_name`. If `param_value_size_ret` is `null`, it is ignored.
97
97
98
-
For a full list of the enum members, refer to the OpenCL PDF documentation or the `src/enums/context.zig` file where the enums are defined.
98
+
For a full list of the enum members, refer to the OpenCL PDF documentation or the `src/context.zig` file where the enums are defined.
99
99
100
100
#### Error Handling
101
101
@@ -109,8 +109,8 @@ The function uses Zig's error handling features to manage potential OpenCL error
0 commit comments