Skip to content

Commit 7fb1a67

Browse files
docs: update context documentation to match new implementation
Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>
1 parent dfc98bd commit 7fb1a67

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

docs/context.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
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.
66

77
```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;
1414
```
1515

1616
#### Parameters
1717

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.
2020
- `pfn_notify`: A callback function that can be registered by the application. It will be called when there is a context error.
2121
- `user_data`: A pointer to user-supplied data that will be passed to the callback function.
2222

@@ -35,27 +35,27 @@ The function uses Zig's error handling features to manage potential OpenCL error
3535
## Creating Context from Type
3636

3737
```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;
4444
```
4545

4646
#### Parameters
4747

4848
- `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.
4949

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:
5151
- `CL_DEVICE_TYPE_CPU` -> `cpu`
5252
- `CL_DEVICE_TYPE_GPU` -> `gpu`
5353
- `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.
5454

5555
- `user_data`: Will be passed as the `user_data` argument when `pfn_notify` is called. `user_data` can be `null`.
5656

5757

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.
5959

6060
#### Error Handling
6161

@@ -76,26 +76,26 @@ The function uses Zig's error handling features to manage potential OpenCL error
7676
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.
7777

7878
```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,
8282
param_value_size: usize,
8383
param_value: ?*anyopaque,
84-
param_value_size_ret: ?*usize
85-
) errors.opencl_error!void;
84+
param_value_size_ret: ?*usize,
85+
) OpenCLError!void;
8686
```
8787

8888
#### Parameters
8989

9090
- `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:
9292
- `CL_CONTEXT_REFERENCE_COUNT` -> `reference_count`
9393
- `CL_CONTEXT_NUM_DEVICES` -> `num_devices`
9494
- `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.
9595
- `param_value`: A pointer to memory where the appropriate result being queried is returned. If `param_value` is `null`, it is ignored.
9696
- `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.
9797

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.
9999

100100
#### Error Handling
101101

@@ -109,8 +109,8 @@ The function uses Zig's error handling features to manage potential OpenCL error
109109
### Retain a context
110110

111111
```zig
112-
pub inline fn retain(context: cl_context) errors.opencl_error!void;
113-
```
112+
pub fn retain(context: Context) OpenCLError!void;
113+
```
114114

115115
#### Parameters
116116

@@ -127,7 +127,7 @@ The function uses Zig's error handling features to manage potential OpenCL error
127127
## Releasing a context
128128

129129
```zig
130-
pub inline fn release(context: cl_context) void;
130+
pub fn release(context: Context) void;
131131
```
132132

133133
#### Parameters

0 commit comments

Comments
 (0)