Skip to content

Commit

Permalink
Fix clippy issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
kenba committed Nov 26, 2024
1 parent be011a2 commit ef8149d
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 90 deletions.
3 changes: 2 additions & 1 deletion src/command_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ use libc::{c_void, size_t};
use std::mem;
use std::ptr;

/// An OpenCL command-buffer.
/// An OpenCL command-buffer.
///
/// This extension adds the ability to record and replay buffers of OpenCL commands.
/// See [cl_khr_command_buffer](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_command_buffer)
#[derive(Debug)]
Expand Down
14 changes: 8 additions & 6 deletions src/command_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ use libc::{c_char, c_void, size_t};
use std::mem;
use std::ptr;

/// An OpenCL command-queue.
/// An OpenCL command-queue.
///
/// Operations on OpenCL memory and kernel objects are performed using a
/// command-queue.
#[derive(Debug)]
Expand Down Expand Up @@ -85,14 +86,15 @@ impl CommandQueue {
self.max_work_item_dimensions
}

/// Create an OpenCL command-queue on a specific device.
/// Create an OpenCL command-queue on a specific device.
///
/// Queries the device the max_work_item_dimensions.
/// Deprecated in CL_VERSION_2_0 by create_command_queue_with_properties.
///
/// * `context` - a valid OpenCL context.
/// * `device_id` - a device or sub-device associated with context.
/// * `properties` - a list of properties for the command-queue, see
/// [cl_command_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#legacy-queue-properties-table).
/// [cl_command_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#legacy-queue-properties-table).
///
/// returns a Result containing the new CommandQueue
/// or the error code from the OpenCL C API function.
Expand Down Expand Up @@ -130,7 +132,7 @@ impl CommandQueue {
///
/// * `context` - a valid OpenCL context.
/// * `properties` - a list of properties for the command-queue, see
/// [cl_command_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#legacy-queue-properties-table).
/// [cl_command_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#legacy-queue-properties-table).
///
/// returns a Result containing the new CommandQueue
/// or the error code from the OpenCL C API function.
Expand Down Expand Up @@ -161,7 +163,7 @@ impl CommandQueue {
/// * `context` - a valid OpenCL context.
/// * `device_id` - a device or sub-device associated with context.
/// * `properties` - a null terminated list of properties for the command-queue, see
/// [cl_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#queue-properties-table).
/// [cl_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#queue-properties-table).
///
/// returns a Result containing the new CommandQueue
/// or the error code from the OpenCL C API function.
Expand Down Expand Up @@ -206,7 +208,7 @@ impl CommandQueue {
///
/// * `context` - a valid OpenCL context.
/// * `properties` - a null terminated list of properties for the command-queue, see
/// [cl_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#queue-properties-table).
/// [cl_queue_properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#queue-properties-table).
///
/// returns a Result containing the new CommandQueue
/// or the error code from the OpenCL C API function.
Expand Down
13 changes: 7 additions & 6 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Context {
///
/// * `devices` - a slice of cl_device_ids for an OpenCL Platform.
/// * `properties` - a null terminated list of cl_context_properties, see
/// [Context Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#context-properties-table).
/// [Context Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#context-properties-table).
/// * `pfn_notify` - an optional callback function that can be registered by the application.
/// * `user_data` - passed as the user_data argument when pfn_notify is called.
///
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Context {
///
/// * `devices` - a slice of SubDevices for an OpenCL Platform.
/// * `properties` - a null terminated list of cl_context_properties, see
/// [Context Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#context-properties-table).
/// [Context Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#context-properties-table).
/// * `pfn_notify` - an optional callback function that can be registered by the application.
/// * `user_data` - passed as the user_data argument when pfn_notify is called.
///
Expand All @@ -187,7 +187,7 @@ impl Context {
///
/// * `device_type` - the cl_device_type to create a Context for.
/// * `properties` - a null terminated list of cl_context_properties, see
/// [Context Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#context-properties-table).
/// [Context Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#context-properties-table).
/// * `pfn_notify` - an optional callback function that can be registered by the application.
/// * `user_data` - passed as the user_data argument when pfn_notify is called.
///
Expand Down Expand Up @@ -230,12 +230,13 @@ impl Context {
}

/// Get the list of image formats supported by the Context for an image type,
/// and allocation information.
/// and allocation information.
///
/// Calls clGetSupportedImageFormats to get the desired information about the context.
///
/// * `flags` - a bit-field used to specify allocation and usage information
/// about the image memory object being created, see:
/// [Memory Flags](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#memory-flags-table).
/// about the image memory object being created, see:
/// [Memory Flags](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#memory-flags-table).
/// * `image_type` - describes the image type.
///
/// returns a Result containing the desired information in an InfoType enum
Expand Down
5 changes: 3 additions & 2 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ impl SubDevice {
}
}

/// An OpenCL device id and methods to query it.
/// An OpenCL device id and methods to query it.
///
/// The query methods calls clGetDeviceInfo with the relevant param_name, see:
/// [Device Queries](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#device-queries-table).
#[derive(Copy, Clone, Debug)]
Expand Down Expand Up @@ -118,7 +119,7 @@ impl Device {
/// Create sub-devices by partitioning an OpenCL device.
///
/// * `properties` - the slice of cl_device_partition_property, see
/// [Subdevice Partition](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#subdevice-partition-table).
/// [Subdevice Partition](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#subdevice-partition-table).
///
/// returns a Result containing a vector of available SubDevices
/// or the error code from the OpenCL C API function.
Expand Down
3 changes: 2 additions & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub use cl3::event::*;
use super::Result;
use libc::c_void;

/// An OpenCL event object.
/// An OpenCL event object.
///
/// Has methods to return information from calls to clGetEventInfo and
/// clGetEventProfilingInfo with the appropriate parameters.
/// Implements the Drop trait to call release_event when the object is dropped.
Expand Down
15 changes: 8 additions & 7 deletions src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl Kernel {
/// Pass additional information other than argument values to a kernel.
///
/// * `param_name` - the information to be passed to kernel, see:
/// [Kernel Execution Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#kernel-exec-info-table).
/// [Kernel Execution Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#kernel-exec-info-table).
/// * `param_ptr` - pointer to the data for the param_name.
///
/// returns an empty Result or the error code from the OpenCL C API function.
Expand Down Expand Up @@ -322,8 +322,9 @@ pub fn create_program_kernels(program: &Program) -> Result<Vec<Kernel>> {
.collect::<Vec<Kernel>>())
}

/// A struct that implements the [builder pattern](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html)
/// to simplify setting up [Kernel] arguments and the [NDRange](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#_mapping_work_items_onto_an_ndrange)
/// A struct that implements the [builder pattern](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html).
///
/// To simplify setting up [Kernel] arguments and the [NDRange](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#_mapping_work_items_onto_an_ndrange)
/// when enqueueing a [Kernel] on a [CommandQueue].
#[derive(Debug)]
pub struct ExecuteKernel<'a> {
Expand All @@ -338,7 +339,7 @@ pub struct ExecuteKernel<'a> {
}

impl<'a> ExecuteKernel<'a> {
pub fn new(kernel: &'a Kernel) -> ExecuteKernel {
pub fn new(kernel: &'a Kernel) -> Self {
ExecuteKernel {
kernel,
num_args: kernel
Expand Down Expand Up @@ -454,7 +455,7 @@ impl<'a> ExecuteKernel<'a> {
/// Pass additional information other than argument values to a kernel.
///
/// * `param_name` - the information to be passed to kernel, see:
/// [Kernel Execution Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#kernel-exec-info-table).
/// [Kernel Execution Properties](https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#kernel-exec-info-table).
/// * `param_ptr` - pointer to the data for the param_name.
///
/// returns a reference to self.
Expand Down Expand Up @@ -637,9 +638,9 @@ impl<'a> ExecuteKernel<'a> {
/// * no global_work_sizes have been set
/// * too many global_work_sizes have been set
/// * global_work_offsets have been set and their dimensions do not match
/// global_work_sizes
/// global_work_sizes
/// * local_work_sizes have been set and their dimensions do not match
/// global_work_sizes
/// global_work_sizes
///
/// * `queue` - the [CommandQueue] to enqueue the [Kernel] on.
///
Expand Down
60 changes: 30 additions & 30 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,42 @@
//! considers OpenCL as four models:
//!
//! * **Platform Model**
//! The physical OpenCL hardware: a *host* containing one or more OpenCL [platform]s,
//! each connected to one or more OpenCL [device]s.
//! An OpenCL application running on the *host*, creates an OpenCL environment
//! called a [context] on a single [platform] to process data on one or more
//! of the OpenCL [device]s connected to the [platform].
//! The physical OpenCL hardware: a *host* containing one or more OpenCL [platform]s,
//! each connected to one or more OpenCL [device]s.
//! An OpenCL application running on the *host*, creates an OpenCL environment
//! called a [context] on a single [platform] to process data on one or more
//! of the OpenCL [device]s connected to the [platform].
//!
//! * **Programming Model**
//! An OpenCL [program] consists of OpenCL [kernel] functions that can run
//! on OpenCL [device]s within a [context].
//! OpenCL [program]s must be created (and most must be built) for a [context]
//! before their OpenCL [kernel] functions can be created from them,
//! the exception being "built-in" [kernel]s which don't need to be built
//! (or compiled and linked).
//! OpenCL [kernel]s are controlled by an OpenCL application that runs on the
//! *host*, see **Execution Model**.
//! An OpenCL [program] consists of OpenCL [kernel] functions that can run
//! on OpenCL [device]s within a [context].
//! OpenCL [program]s must be created (and most must be built) for a [context]
//! before their OpenCL [kernel] functions can be created from them,
//! the exception being "built-in" [kernel]s which don't need to be built
//! (or compiled and linked).
//! OpenCL [kernel]s are controlled by an OpenCL application that runs on the
//! *host*, see **Execution Model**.
//!
//! * **Memory Model**
//! **OpenCL 1.2** memory is divided into two fundamental memory regions:
//! **host memory** and **device memory**.
//! OpenCL [kernel]s run on **device memory**; an OpenCL application must write
//! **host memory** to **device memory** for OpenCL [kernel]s to process.
//! An OpenCL application must also read results from **device memory** to
//! **host memory** after a [kernel] has completed execution.
//! **OpenCL 2.0** shared virtual memory ([svm]) is shared between the host
//! and device(s) and synchronised by OpenCL; eliminating the explicit transfer
//! of memory between host and device(s) memory regions.
//! **OpenCL 1.2** memory is divided into two fundamental memory regions:
//! **host memory** and **device memory**.
//! OpenCL [kernel]s run on **device memory**; an OpenCL application must write
//! **host memory** to **device memory** for OpenCL [kernel]s to process.
//! An OpenCL application must also read results from **device memory** to
//! **host memory** after a [kernel] has completed execution.
//! **OpenCL 2.0** shared virtual memory ([svm]) is shared between the host
//! and device(s) and synchronised by OpenCL; eliminating the explicit transfer
//! of memory between host and device(s) memory regions.
//!
//! * **Execution Model**
//! An OpenCL application creates at least one OpenCL [command_queue] for each
//! OpenCL [device] (or *sub-device*) within it's OpenCL [context].
//! OpenCL [kernel] executions and **OpenCL 1.2** memory reads and writes are
//! "enqueued" by the OpenCL application on each [command_queue].
//! An application can wait for all "enqueued" commands to finish on a
//! [command_queue] or it can wait for specific [event]s to complete.
//! Normally [command_queue]s run commands in the order that they are given.
//! However, [event]s can be used to execute [kernel]s out-of-order.
//! An OpenCL application creates at least one OpenCL [command_queue] for each
//! OpenCL [device] (or *sub-device*) within it's OpenCL [context].
//! OpenCL [kernel] executions and **OpenCL 1.2** memory reads and writes are
//! "enqueued" by the OpenCL application on each [command_queue].
//! An application can wait for all "enqueued" commands to finish on a
//! [command_queue] or it can wait for specific [event]s to complete.
//! Normally [command_queue]s run commands in the order that they are given.
//! However, [event]s can be used to execute [kernel]s out-of-order.
//!
//! # OpenCL Objects
//!
Expand Down
Loading

0 comments on commit ef8149d

Please sign in to comment.