diff --git a/Doxyfile.in b/Doxyfile.in index 96a85ec3..b18c1888 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -821,13 +821,13 @@ STRIP_CODE_COMMENTS = YES # then for each documented function all documented # functions referencing it will be listed. -REFERENCED_BY_RELATION = YES +REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. -REFERENCES_RELATION = YES +REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from diff --git a/README.md b/README.md index 14085205..ee5d9c27 100644 --- a/README.md +++ b/README.md @@ -26,23 +26,21 @@ Features * OpenCL version independent * Integrated profiling +Documentation +============= + +* [Examples](http://fakenmc.github.io/cf4ocl/docs/latest/examples.html) +* [User guide and API](http://fakenmc.github.io/cf4ocl/docs/latest/) +* [Download, build and install](https://github.com/FakenMC/cf4ocl/wiki/Download,-build-and-install) + Feeback ======= -Clone, build and install the code, the a look at the -[examples](https://github.com/FakenMC/cf4ocl/tree/master/src/examples) -and the [v2.0.0-alpha API](http://fakenmc.github.io/cf4ocl/docs/v2.0.0-alpha). +Clone, build and install the code, take a look at the +[examples](http://fakenmc.github.io/cf4ocl/docs/latest/examples.html) +and the [user guide and API](http://fakenmc.github.io/cf4ocl/docs/latest/). The API may change until the beta release. Any feedback is appreciated. -Soon -==== - -* Simple and clear example -* Links to GitHub wiki pages with other information and examples -* Dependencies -* Downloads, installing -* More? - Not yet implemented =================== diff --git a/README.mdpp b/README.mdpp index 14085205..ee5d9c27 100644 --- a/README.mdpp +++ b/README.mdpp @@ -26,23 +26,21 @@ Features * OpenCL version independent * Integrated profiling +Documentation +============= + +* [Examples](http://fakenmc.github.io/cf4ocl/docs/latest/examples.html) +* [User guide and API](http://fakenmc.github.io/cf4ocl/docs/latest/) +* [Download, build and install](https://github.com/FakenMC/cf4ocl/wiki/Download,-build-and-install) + Feeback ======= -Clone, build and install the code, the a look at the -[examples](https://github.com/FakenMC/cf4ocl/tree/master/src/examples) -and the [v2.0.0-alpha API](http://fakenmc.github.io/cf4ocl/docs/v2.0.0-alpha). +Clone, build and install the code, take a look at the +[examples](http://fakenmc.github.io/cf4ocl/docs/latest/examples.html) +and the [user guide and API](http://fakenmc.github.io/cf4ocl/docs/latest/). The API may change until the beta release. Any feedback is appreciated. -Soon -==== - -* Simple and clear example -* Links to GitHub wiki pages with other information and examples -* Dependencies -* Downloads, installing -* More? - Not yet implemented =================== diff --git a/docs/userguide.md b/docs/userguide.md index 1cf01d42..20278fda 100644 --- a/docs/userguide.md +++ b/docs/userguide.md @@ -7,7 +7,7 @@ User guide {#ug} # Overview {#ug_overview} -The C Framework for OpenCL, cf4ocl, is a cross-platform pure C99 +The C Framework for OpenCL, _cf4ocl_, is a cross-platform pure C99 object-oriented framework for developing and benchmarking OpenCL projects in C/C++. It aims to: @@ -35,7 +35,7 @@ requirements. The _cf4ocl_ library offers an object-oriented interface to the OpenCL API using wrapper classes and methods (or structs and functions, in C -terms), grouped in modules of the same name, as shown in the following +terms), grouped into modules of the same name, as shown in the following table: | _cf4ocl_ module | _cf4ocl_ wrapper class | Wrapped OpenCL type | @@ -97,8 +97,8 @@ krnl = ccl_program_get_kernel(prg, "someKernel", NULL); ~~~~~~~~~~~~~~~ The returned kernel wrapper object will be freed when the program -is destroyed; as such, there is no need to free the former. Destroying -the program will suffice: +is destroyed; as such, there is no need to free it. Destroying the program will +suffice: ~~~~~~~~~~~~~~~{.c} ccl_program_destroy(prg); @@ -106,13 +106,14 @@ ccl_program_destroy(prg); ### Getting info about OpenCL objects {#ug_getinfo} -The `ccl__get_info_()` macros can be used to get +The `ccl__get_info_()` macros can be used to get information about OpenCL objects. Use the `array` version when the expected return value is a pointer or array, or the `scalar` version otherwise (e.g. when the expected return value is primitive or scalar type). -For example, to get the name and the number of compute cores on a device: +For example, to get the name and the number of compute cores on a +device: ~~~~~~~~~~~~~~~{.c} CCLDevice* dev; @@ -124,27 +125,22 @@ name = ccl_device_get_info_array(dev, CL_DEVICE_NAME, char*, NULL); n_cores = ccl_device_get_info_scalar(dev, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint, NULL); ~~~~~~~~~~~~~~~ -The `ccl__get_info()` macros serve more specific scenarios, and +The `ccl__get_info()` macros serve more specific scenarios, and are likely to be used less often. These macros return a ::CCLWrapperInfo* object, which contains two public fields: * `value` - A pointer to the requested value as returned by the OpenCL -clGetInfo() functions. +`clGet*Info()` functions. * `size` - The size in bytes of the value pointed to by the `value` field. To use the value, a cast should be performed on the `value` field to convert it to the required type (which is what the -`ccl__get_info_()` macros automatically do). +`ccl__get_info_()` macros automatically do). The values and objects returned by these macros are automatically released when the respective wrapper object is destroyed and should -never be directly freed by client code. In the previous example, -destroying the device wrapper will also destroy any requested info: - -~~~~~~~~~~~~~~~{.c} -ccl_device_destroy(dev); -~~~~~~~~~~~~~~~ +never be directly freed by client code. ### Error handling {#ug_errorhandle} @@ -295,20 +291,19 @@ g_log_set_handler("cf4ocl2", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RE ## Wrapper modules {#ug_wrappers} Each [OpenCL class](http://www.khronos.org/registry/cl/sdk/2.0/docs/man/xhtml/classDiagram.html) -is associated with a _cf4ocl_ module which provides functionality to -simplify its handling. At the most basic level, each module offers a -wrapper class and functions which wrap or map their OpenCL equivalents. -This, in itself, already simplifies working with OpenCL in C, because -the _cf4ocl_ wrapper classes internally manage directly related objects, -strings or variables created during the course of a program. As such, -client code just needs to follow the @ref ug_new_destroy "new/destroy" -rule for directly created objects, thus not having to worry with memory -allocation/deallocation of all the other intermediate objects. +is associated with a _cf4ocl_ module. At the most basic level, each +module offers a wrapper class and functions which wrap or map their +OpenCL equivalents. This, in itself, already simplifies working with +OpenCL in C, because the _cf4ocl_ wrapper classes internally manages +directly related objects, which may be created during the course of a +program. As such, client code just needs to follow the +@ref ug_new_destroy "new/destroy" rule for directly created objects, +thus not having to worry with memory allocation/deallocation of +intermediate objects. In most cases, however, each _cf4ocl_ module also provides methods for -other common or not-so-common OpenCL host code patterns, allowing the -programmer to avoid the verbosity in these patterns and focus on OpenCL -device code. +other common and not-so-common OpenCL host code patterns, allowing the +programmer to avoid their verbosity and focus on OpenCL device code. All _cf4ocl_ wrapper classes extend the ::CCLWrapper* abstract wrapper class. The properties and methods of this class, which are @@ -316,29 +311,19 @@ concerned with reference counts, wrapping/unwrapping of OpenCL objects and getting object information, are essentially of internal use by other _cf4ocl_ classes. This functionality is also available to client code which requires a more advanced integration with _cf4ocl_, as explained -in the @ref ug_advanced "advanced" section. +in the @ref ug_cclwrapper "advanced" section. Several OpenCL objects, namely `cl_platform_id`, `cl_context` and `cl_program`, have a direct relationship with a set of `cl_device_id` objects. In order to map this relationship, _cf4ocl_ provides the -::CCLDevContainer class, which is an intermediate class between the -::CCLWrapper parent class and the ::CCLPlatform, ::CCLContext and -::CCLProgram wrappers. The ::CCLDevContainer class implements -functionality for managing a set of ::CCLDevice* wrapper instances, and -provides three abstract methods for accessing the associated set of -::CCLDevice* wrappers, namely: - -* ::ccl_dev_container_get_all_devices(): get all ::CCLDevice* wrappers -in device container object. -* ::ccl_dev_container_get_device(): get ::CCLDevice* wrapper at given -index. -* ::ccl_dev_container_get_num_devices(): return number of devices in -device container object. - -Client code should use the respective wrapper implementations. For -example, for the ::CCLContext class, client code should use the +::CCLDevContainer* class, which is an intermediate class between the +::CCLWrapper* parent class and the ::CCLPlatform*, ::CCLContext* and +::CCLProgram* wrappers. The ::CCLDevContainer* class implements +functionality for managing a set of ::CCLDevice* wrapper instances. +This functionality is exposed to client code through concrete wrapper +methods. For example, the ::CCLContext* class provides the ::ccl_context_get_all_devices(), ::ccl_context_get_device() and -::ccl_context_get_num_devices() functions. +::ccl_context_get_num_devices() methods for this purpose. ### Platform module {#ug_platform} @@ -439,7 +424,7 @@ object-oriented (OO) approach in C. While C does not directly provide OO constructs, it is possible to implement features such as inheritance, polymorphism or encapsulation. Using this approach, _cf4ocl_ is able to offer a clean and logical class system, while being available in a form -which can be directly or indirectly invoked from other programming +(C) which can be directly or indirectly invoked from other programming languages. Each _cf4ocl_ wrapper class is defined by a source (.c) file and a @@ -449,10 +434,10 @@ class body is implemented in the source file as a C `struct`; the header file provides an opaque pointer to it, which is the public side of the class from a client code perspective. The only exceptions are the ::CCLWrapper* and ::CCLDevContainer* abstract classes, which have the -respective `struct` body publicly available in the header file. This is -required due to the way inheritance is implemented in _cf4ocl_, +respective `struct` body publicly available in their header files. This +is required due to the way inheritance is implemented in _cf4ocl_, i.e., by including a member representing the parent class `struct` in -the body of a child class `struct`. This way, instances of the child +the body of the child class `struct`. This way, instances of the child class can be cast to its parent type when required. The child class `struct` effectively extends the parent class `struct`. An example of this approach can be shown with the definitions of the abstract @@ -508,11 +493,14 @@ in C. Methods are implemented as functions which accept the object on which they operate as the first parameter. When useful, function-like macros -are also used as objects methods, such as the case of the +are also used as object methods, such as the case of the @ref ug_getinfo "info macros". Polymorphism is not used, as the so called "abstract" methods are just functions which provide common -operations to the concrete classes, and are called by the concrete -methods. +operations to concrete methods, named differently for each concrete +class. For example, the ::ccl_dev_container_get_device() abstract method +is called by the ::ccl_context_get_device(), ::ccl_platform_get_device() +and ::ccl_program_get_device() concrete methods, for which it provides +common functionality. The _cf4ocl_ class hierarchy is shown in the following inheritance diagram: @@ -569,9 +557,10 @@ the size in bytes of the wrapper to be created. The ::ccl_wrapper_new() function allocates memory for the wrapper (initializing this memory to zero), and keeps the OpenCL object (wrapping it) in the created wrapper instance. For example, the ::ccl_kernel_new() creates the -`cl_kernel` object with the clCreateKernel() OpenCL function, then -relying on the ::ccl_kernel_new_wrap() function for allocation and -initialization of the new ::CCLKernel* wrapper object memory. +`cl_kernel` object with the clCreateKernel() OpenCL function, but then +relies on the ::ccl_kernel_new_wrap() function (and thus, on +::ccl_wrapper_new()) for allocation and initialization of the new +::CCLKernel* wrapper object memory. The destruction of wrapper objects and respective memory deallocation is performed in a similar fashion. Each wrapper class has its own @@ -579,27 +568,27 @@ is performed in a similar fashion. Each wrapper class has its own object release to the "abstract" ::ccl_wrapper_unref() function. This function accepts the wrapper to be destroyed, its size in bytes, and two function pointers: the first, with prototype defined by -::ccl_wrapper_release_fields), is a wrapper specific function for +::ccl_wrapper_release_fields(), is a wrapper specific function for releasing internal wrapper objects, which the super class has no knowledge of; the second is the OpenCL object destructor function, with -prototype defined by ::ccl_wrapper_release_cl_object. Continuing on the -kernel example, the ::ccl_kernel_destroy() method delegates kernel -wrapper destruction to ::ccl_wrapper_unref() passing it the kernel -wrapper object, its size (i.e. `sizeof(CCLKernel)`, the private (static -in C) `ccl_kernel_release_fields()` function for destroying kernel -::CCLArg kernel argument objects, and the clReleaseKernel() OpenCL -kernel destructor function. +prototype defined by ::ccl_wrapper_release_cl_object(). Continuing on +the kernel example, the ::ccl_kernel_destroy() method delegates kernel +wrapper destruction to ::ccl_wrapper_unref(), passing it the kernel +wrapper object, its size (i.e. `sizeof(` ::CCLKernel `)`), the "private" +(static in C) `ccl_kernel_release_fields()` function for destroying +kernel internal objects, and the clReleaseKernel() OpenCL kernel +destructor function. As such, all _cf4ocl_ wrapper objects use a common memory allocation and deallocation strategy, implemented in the ::CCLWrapper* super class. The `ccl__new_wrap()` special constructors respect the -@ref ug_new_destroy "new/destroy" rule, because if client code creates -wrappers in this way, they must be released with the respective +@ref ug_new_destroy "new/destroy" rule. Wrappers created with their +special constructor must be released with the respective `ccl__destroy()` function. This allows client code to create OpenCL objects directly with OpenCL functions, and then wrap the objects to take advantage of _cf4ocl_ functionality and features. The OpenCL -object can be retrieve from its wrapper at all times through the +object can be retrieved from its wrapper at all times with the respective `ccl__unwrap` method. If `ccl__new_wrap()` functions are passed an OpenCL object which @@ -607,34 +596,34 @@ is already wrapped, a new wrapper will not be created. Instead, the existing wrapper is returned, with its reference count increased by 1. Thus, there is always a one-to-one relationship between wrapped OpenCL objects and their respective wrappers. In reality, the -`ccl__destroy()` functions decrease the reference count of the +`ccl__destroy()` functions decreases the reference count of the respective wrapper, only destroying it if the reference count reaches zero. Client code can increase and decrease the reference count of a wrapper object using the associated `ccl__ref()` and -`ccl__unref()` macros. The `ccl__ref()` call the +`ccl__unref()` macros. The `ccl__ref()` macros call the ::ccl_wrapper_ref() "abstract" function, casting the wrapper to its base class (::CCLWrapper*), while the `ccl__unref()` macros are just aliases for the respective `ccl__destroy()` functions. The ::CCLWrapper* class maintains a static hash table which associates -OpenCL objects (keys) to _cf4ocl_ wrappers (value). Access to this +OpenCL objects (keys) to _cf4ocl_ wrappers (values). Access to this table is thread-safe and performed by the ::ccl_wrapper_new() and ::ccl_wrapper_unref() functions. The management of OpenCL object information is also handled by the ::CCLWrapper* class. The ::ccl_wrapper_get_info() method accepts two wrapper objects, the first being the object to query; the second is -an auxiliary object required by some lower-level OpenCl info functions, -e.g. clGetKernelWorkGroupInfo(), which requires a device object besides +an auxiliary object required by some lower-level OpenCL info functions, +such clGetKernelWorkGroupInfo(), which requires a device object besides the kernel object. ::ccl_wrapper_get_info() also requires a pointer to -a OpenCL `clGet*Info()` function (typedefed as ::ccl_wrapper_info_fp) in -order to perform the desired query. ::ccl_wrapper_get_info() returns -a ::CCLWrapperInfo* object, which contains two public properties: the -queried value and its size. To be useful, the value must be cast to the -correct type. The ::ccl_wrapper_get_info_value() and -::ccl_wrapper_get_info_size() methods call ::ccl_wrapper_get_info(), -but directly return value and size of the ::CCLWrapper* object, -respectively. +a OpenCL `clGet*Info()` function (with type defined as +::ccl_wrapper_info_fp) in order to perform the desired query. +::ccl_wrapper_get_info() returns a ::CCLWrapperInfo* object, which +contains two public properties: the queried value and its size. To be +useful, the value must be cast to the correct type. The +::ccl_wrapper_get_info_value() and ::ccl_wrapper_get_info_size() methods +call ::ccl_wrapper_get_info(), but directly return the value and size of +the ::CCLWrapper* object, respectively. The requested information is kept in the information table of the respective wrapper object. When the wrapper object is destroyed, all the @@ -647,20 +636,34 @@ already been requested; if not, they proceed with the query as normal. Client code will usually use the @ref ug_getinfo "info macros" of each wrapper in order to fetch information about the underlying OpenCL -objects. These macros expand into the `ccl_wrapper_get_info*()` methods, +object. These macros expand into the `ccl_wrapper_get_info*()` methods, automatically casting objects and values to the appropriate type, -selecting the correct `clGet*Info()` function and setting the cache as -appropriate for the object being queried. For example, platform object -queries can always be cached, as the returned information will never -change. +selecting the correct `clGet*Info()` function and setting the cache flag +as appropriate for the object being queried. For example, platform +object queries can always be cached, as the returned information will +never change. ## The CCLDevContainer class {#ug_ccldevcontainer} The intermediate ::CCLDevContainer* class provides functionality for managing a set of ::CCLDevice* wrapper instances, abstracting code common to the ::CCLPlatform*, ::CCLContext* and ::CCLProgram* classes, -all of which internally keep a set of devices. This functionality -if further described in the @ref ug_wrappers "wrapper modules" section. +all of which internally keep a set of devices. The ::CCLDevContainer* +class contains three "abstract" methods for accessing the associated set +of ::CCLDevice* wrappers, namely: + +* ::ccl_dev_container_get_all_devices(): get all ::CCLDevice* wrappers +in device container object. +* ::ccl_dev_container_get_device(): get ::CCLDevice* wrapper at given +index. +* ::ccl_dev_container_get_num_devices(): return number of devices in +device container object. + +Client code should use the respective wrapper implementations. For +example, in the case of ::CCLProgram* objects, client code should use +the ::ccl_program_get_all_devices(), ::ccl_program_get_device() and +::ccl_program_get_num_devices() methods to manage the set of devices +associated with the program. ## The CCLMemObj class {#ug_cclmemobj} diff --git a/src/cf4ocl2/buffer_wrapper.h b/src/cf4ocl2/buffer_wrapper.h index e7ef21ad..4b55cf53 100644 --- a/src/cf4ocl2/buffer_wrapper.h +++ b/src/cf4ocl2/buffer_wrapper.h @@ -47,10 +47,10 @@ typedef struct ccl_image CCLImage; * clCreateSubBuffer() but assumes that the sub-buffer will represent a * specific region in the original buffer (which is the only sub-buffer * type, up to OpenCL 2.0). - * - * Buffer wrapper objects can be directly pass as kernel arguments to + * + * Buffer wrapper objects can be directly passed as kernel arguments to * functions such as ::ccl_kernel_set_args_and_enqueue_ndrange() or - * ::ccl_kernel_set_args_v(). + * ::ccl_kernel_set_args_v(). * * Information about buffer objects can be fetched using the * @ref ug_getinfo "info macros" from the @@ -70,18 +70,22 @@ typedef struct ccl_image CCLImage; * cl_float host_data[BSIZE]; * size_t buf_size = BSIZE * sizeof(cl_float); * @endcode + * * @code{.c} * buf = ccl_buffer_new( * context, CL_MEM_READ_WRITE, buf_size, NULL, NULL); * @endcode + * * @code{.c} * ccl_buffer_enqueue_write(queue, buf, CL_TRUE, 0, buf_size, * host_data, NULL, NULL); * @endcode + * * @code{.c} * ccl_buffer_enqueue_read(queue, buf, CL_TRUE, 0, buf_size, * host_data, NULL, NULL); * @endcode + * * @code{.c} * ccl_buffer_destroy(buf); * @endcode diff --git a/src/cf4ocl2/context_wrapper.h b/src/cf4ocl2/context_wrapper.h index 95cea9f1..19dfaca6 100644 --- a/src/cf4ocl2/context_wrapper.h +++ b/src/cf4ocl2/context_wrapper.h @@ -57,17 +57,13 @@ * @ref DEVICE_SELECTOR "device selection module" section. * 3. Using one of the several convenience constructors, which contain * predefined filters, such as ::ccl_context_new_gpu(), - * ::ccl_context_new_any or ::ccl_context_new_from_menu(). + * ::ccl_context_new_any() or ::ccl_context_new_from_menu(). * * Instantiation and destruction of context wrappers follows the * _cf4ocl_ @ref ug_new_destroy "new/destroy" rule; as such, context * wrapper objects must be released with the ::ccl_context_destroy() * function. * - * Additional functions allow to get the device wrappers associated - * with the the context wrapper object, as well as to obtain the - * OpenCL version supported by the underlying OpenCL platform. - * * Information about context objects can be fetched using the * context @ref ug_getinfo "info macros": * @@ -216,7 +212,7 @@ CCLContext* ccl_context_new_wrap(cl_context context); ccl_devsel_indep_type_accel, NULL, err) /** - * Creates a context wrapper for the fist found device(s). + * Creates a context wrapper for the first found device(s). * * The first found device is used. More than one device might be used if * all devices belong to the same platform. diff --git a/src/cf4ocl2/device_query.h b/src/cf4ocl2/device_query.h index b308ea41..1cc4fb9d 100644 --- a/src/cf4ocl2/device_query.h +++ b/src/cf4ocl2/device_query.h @@ -38,9 +38,9 @@ /** * @defgroup DEVICE_QUERY Device query * - * Classes and functions to facilitate the querying of OpenCL devices. - * This module primarily supports the @ref devinfo utility, but may - * also be of use to client code. + * This module facilitates the querying of OpenCL devices. It primarily + * supports the @ref devinfo utility, but may also be of use to client + * code. * * @{ */ diff --git a/src/cf4ocl2/device_selector.h b/src/cf4ocl2/device_selector.h index fbd3ba85..d447d1c1 100644 --- a/src/cf4ocl2/device_selector.h +++ b/src/cf4ocl2/device_selector.h @@ -45,7 +45,7 @@ * The ::ccl_context_new_from_filters_full() context wrapper constructor * (and the ::ccl_context_new_from_filters() macro) accepts a * ::CCLDevSelFilters object containing a set of filters. These filters - * define which devices will be used in the context. Instances of + * define which devices can be used in the context. Instances of * ::CCLDevSelFilters must be initialized to NULL: * * @dontinclude device_filter.c diff --git a/src/cf4ocl2/device_wrapper.h b/src/cf4ocl2/device_wrapper.h index ce9c9752..40740bd2 100644 --- a/src/cf4ocl2/device_wrapper.h +++ b/src/cf4ocl2/device_wrapper.h @@ -51,7 +51,7 @@ typedef struct ccl_platform CCLPlatform; * @ref CCLDevContainer "device container" objects such as * ::CCLPlatform* or ::CCLContext* instances. As such, and in accordance * with the _cf4ocl_ @ref ug_new_destroy "new/destroy" rule, the - * ::ccl_device_destroy() destructor function will also be rarely used. + * ::ccl_device_destroy() destructor function will rarely be used. * * Information about device objects can be fetched using the * device @ref ug_getinfo "info macros": diff --git a/src/cf4ocl2/errors.h b/src/cf4ocl2/errors.h index 9c5260ef..99004ffc 100644 --- a/src/cf4ocl2/errors.h +++ b/src/cf4ocl2/errors.h @@ -33,18 +33,20 @@ * * This module offers a function to convert OpenCL error codes into * human-readable strings. It is widely used by other _cf4ocl_ - * modules, but may also be useful to client code. + * modules, but may also be useful to client code which directly uses + * OpenCL functions. * * _Example:_ * * @code{.c} - * - * buf = ccl_buffer_new(ctx, flags, size, host_ptr, &err); - * if ((err) && (err->domain == CCL_OCL_ERROR)) { - * fprintf( - * stderr, "OpenCL error %d: %s", err->code, cl_err(err->code)); + * cl_int status; + * cl_event event; + * @endcode + * @code{.c} + * status = clWaitForEvents(1, &event); + * if (status != CL_SUCCESS) { + * fprintf(stderr, "OpenCL error %d: %s", status, ccl_err(status)); * } - * * @endcode * * @{ diff --git a/src/cf4ocl2/event_wrapper.h b/src/cf4ocl2/event_wrapper.h index bd9fa558..4308049f 100644 --- a/src/cf4ocl2/event_wrapper.h +++ b/src/cf4ocl2/event_wrapper.h @@ -45,22 +45,22 @@ typedef struct ccl_queue CCLQueue; * handling of OpenCL event objects. * * Typical event wrappers are not directly created by client code. They - * are returned by several functions which wrap OpenCL code which fires - * events (such as ::ccl_image_enqueue_write(), which wraps the - * clEnqueueWriteImage() OpenCL function). As such, and in accordance - * with the @ref ug_new_destroy "new/destroy" rule, regular event - * wrappers objects should not be destroyed by client code. They are + * are returned by event producing functions (such as + * ::ccl_image_enqueue_write(), which wraps the clEnqueueWriteImage() + * OpenCL function). As such, and in accordance with the + * @ref ug_new_destroy "new/destroy" rule, regular event wrappers + * objects should not be destroyed by client code. They are * automatically released when the command queue wrapper where the event - * took place is destroyed. The only exception is with user events - * (OpenCL >= 1.1), created with the ::ccl_user_event_new() constructor. - * These are special events which allow applications to enqueue commands - * that wait on user-controlled scenarios before the command is executed - * by the device. These events should be destroyed with + * took place is destroyed. User events (OpenCL >= 1.1), created with + * the ::ccl_user_event_new() constructor, are the only exception. These + * are special events which allow applications to enqueue commands that + * wait on user-controlled situations before the command is executed by + * the device. These events should be destroyed with * ::ccl_event_destroy(). * - * The @ref EVENT_WAIT_LIST "event wait list module" provides additional - * information on how to use events to synchronize the execution of - * OpenCL commands. Events are also used by the + * The @ref EVENT_WAIT_LIST "event wait list section" provides + * additional information on how to use events to synchronize the + * execution of OpenCL commands. Events are also used by the * @ref PROFILER "profiler module", although indirectly via ::CCLQueue* * wrappers, to profile and benchmark applications. * diff --git a/src/cf4ocl2/image_wrapper.h b/src/cf4ocl2/image_wrapper.h index 272ecf93..e0273c15 100644 --- a/src/cf4ocl2/image_wrapper.h +++ b/src/cf4ocl2/image_wrapper.h @@ -54,11 +54,11 @@ typedef struct ccl_buffer CCLBuffer; * @ref ug_new_destroy "new/destroy" rule; as such, images should be * freed with the ::ccl_image_destroy() destructor. * - * Image wrapper objects can be directly pass as kernel arguments to + * Image wrapper objects can be directly passed as kernel arguments to * functions such as ::ccl_program_enqueue_kernel() or * ::ccl_kernel_set_arg(). * - * Information about image objects can be fetched using the + * Information about image objects can be fetched using the image * @ref ug_getinfo "info macros": * * * ::ccl_image_get_info_scalar() @@ -66,7 +66,7 @@ typedef struct ccl_buffer CCLBuffer; * * ::ccl_image_get_info() * * If the information to be fetched is relative to the memory object - * super-class (e.g. `CL_MEM_TYPE` or `CL_MEM_FLAGS`), then the + * parent class (e.g. `CL_MEM_TYPE` or `CL_MEM_FLAGS`), then the * @ref MEMOBJ_WRAPPER "memory object module" info macros should be used * instead: * diff --git a/src/cf4ocl2/kernel_wrapper.h b/src/cf4ocl2/kernel_wrapper.h index d3a9bed5..9eb48d97 100644 --- a/src/cf4ocl2/kernel_wrapper.h +++ b/src/cf4ocl2/kernel_wrapper.h @@ -59,12 +59,11 @@ typedef struct ccl_program CCLProgram; * in accordance with the _cf4ocl_ @ref ug_new_destroy "new/destroy" * rule. * - * While the first approach might be more convenient in many situations, - * it will not work properly if the same kernel function is to be - * handled and executed by different threads. In these cases, use the - * second approach to create distinct kernel wrapper instances (wrapping - * distinct OpenCL kernel objects) for the same kernel function, one for - * each thread. + * While the first approach might be more convenient, it will not work + * properly if the same kernel function is to be handled and executed by + * different threads. In these cases, use the second approach to create + * distinct kernel wrapper instances (wrapping distinct OpenCL kernel + * objects) for the same kernel function, one for each thread. * * This module offers several functions which simplify kernel execution. * For example, the ccl_kernel_set_args_and_enqueue_ndrange() function diff --git a/src/cf4ocl2/platforms.h b/src/cf4ocl2/platforms.h index 35772138..bc55dcef 100644 --- a/src/cf4ocl2/platforms.h +++ b/src/cf4ocl2/platforms.h @@ -40,11 +40,10 @@ * The platforms module provides functionality for managing the OpenCL * platforms available in the system. * - * The ::ccl_platforms_new() function returns the set of platforms + * The ::ccl_platforms_new() function returns a list of platforms * available in the system. The ::ccl_platforms_count() can be used to - * get the number of platforms in that set, while the - * ::ccl_platforms_get() will return the @f$i^{th}@f$ platform in the - * system. + * get the number of platforms in the list, while the + * ::ccl_platforms_get() will return the @f$i^{th}@f$ platform. * * _Example:_ * @@ -57,17 +56,17 @@ * @skipline GError* err = NULL; * * @skipline Get all platforms in system - * @until platf_set = ccl_platforms_new(&err); + * @until platf_list = ccl_platforms_new(&err); * * @skipline Get number of platforms in system - * @until num_platfs = ccl_platforms_count(platf_set); + * @until num_platfs = ccl_platforms_count * * @skipline Cycle through platforms - * @until platf = ccl_platforms_get(platf_set, i); + * @until platf = ccl_platforms_get * * @skipline Cycle platforms * @until ccl_platforms_destroy - * + * * @example list_devices.c * @{ */ diff --git a/src/cf4ocl2/program_wrapper.h b/src/cf4ocl2/program_wrapper.h index 3d90fe30..2ac280cc 100644 --- a/src/cf4ocl2/program_wrapper.h +++ b/src/cf4ocl2/program_wrapper.h @@ -156,6 +156,9 @@ * _Example:_ * * @dontinclude canon.c + * @skipline #define KERNEL_NAME + * @until "}\n" + * * @skipline Wrappers. * @until c_dev * @skipline CCLEvent* evt_exec @@ -296,7 +299,7 @@ cl_bool ccl_program_build( cl_bool ccl_program_build_full(CCLProgram* prg, cl_uint num_devices, CCLDevice* const* devs, const char* options, ccl_program_callback pfn_notify, void* user_data, GError** err); - + /* Get build log for most recent build, compile or link. */ const char* ccl_program_get_build_log(CCLProgram* prg); diff --git a/src/cf4ocl2/sampler_wrapper.h b/src/cf4ocl2/sampler_wrapper.h index 5bda6a71..383ff210 100644 --- a/src/cf4ocl2/sampler_wrapper.h +++ b/src/cf4ocl2/sampler_wrapper.h @@ -58,7 +58,7 @@ * ::ccl_sampler_destroy() function, in accordance with the * _cf4ocl_ @ref ug_new_destroy "new/destroy" rule. * - * Sampler wrapper objects can be directly pass as kernel arguments to + * Sampler wrapper objects can be directly passed as kernel arguments to * functions such as ::ccl_kernel_set_args_and_enqueue_ndrange() or * ::ccl_kernel_set_args(). * diff --git a/src/samples/canon.c b/src/samples/canon.c index 09058b67..d2aece4c 100644 --- a/src/samples/canon.c +++ b/src/samples/canon.c @@ -173,7 +173,9 @@ int main(int argc, char** argv) { /* Execute program kernel, waiting for the two transfer events * to terminate (this will empty the event wait list). */ evt_exec = ccl_program_enqueue_kernel(prg, KERNEL_NAME, queue, 1, - NULL, &gws, &lws, &ewl, &err, a_dev, b_dev, c_dev, + NULL, &gws, &lws, &ewl, &err, + /* Kernel arguments. */ + a_dev, b_dev, c_dev, ccl_arg_priv(d_host, cl_uint), ccl_arg_priv(buf_n, cl_uint), NULL); HANDLE_ERROR(err); diff --git a/src/samples/device_filter.c b/src/samples/device_filter.c index feee0134..2718ccf4 100644 --- a/src/samples/device_filter.c +++ b/src/samples/device_filter.c @@ -70,7 +70,7 @@ int main(int argc, char* argv[]) { ccl_devsel_add_indep_filter( &filters, ccl_devsel_indep_type_cpu, NULL); - /* Add same platform dependent filter. This filter should always + /* Add "same platform" dependent filter. This filter should always * be added (usually in last position) for context creation, because * all devices in a context must belong to the same platform. */ ccl_devsel_add_dep_filter(&filters, ccl_devsel_dep_platform, NULL); diff --git a/src/samples/list_devices.c b/src/samples/list_devices.c index d61b0d73..78313b2e 100644 --- a/src/samples/list_devices.c +++ b/src/samples/list_devices.c @@ -41,7 +41,7 @@ int main() { /* cf4ocl objects. */ - CCLPlatforms* platf_set; + CCLPlatforms* platf_list; CCLPlatform* platf; CCLDevice* dev; @@ -54,17 +54,17 @@ int main() { GError* err = NULL; /* Get all platforms in system. */ - platf_set = ccl_platforms_new(&err); + platf_list = ccl_platforms_new(&err); HANDLE_ERROR(err); /* Get number of platforms in system. */ - num_platfs = ccl_platforms_count(platf_set); + num_platfs = ccl_platforms_count(platf_list); /* Cycle through platforms. */ for (cl_uint i = 0; i < num_platfs; ++i) { /* Get current platform. */ - platf = ccl_platforms_get(platf_set, i); + platf = ccl_platforms_get(platf_list, i); /* Get platform name. */ info = ccl_platform_get_info_string( @@ -99,7 +99,7 @@ int main() { /* Release platform set, which will release the underlying * platform wrappers, device wrappers and the requested info. */ - ccl_platforms_destroy(platf_set); + ccl_platforms_destroy(platf_list); /* Check all wrappers have been destroyed. */ g_assert(ccl_wrapper_memcheck());