### Boost.Compute Hello World Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/tutorial This example demonstrates how to get and print the name of the default compute device and its platform using the `boost::compute::system` and `boost::compute::device` classes. It requires the Boost.Compute library. ```cpp #include #include namespace compute = boost::compute; int main() { // get the default device compute::device device = compute::system::default_device(); // print the device's name and platform std::cout << "hello from " << device.name(); std::cout << " (platform: " << device.platform().name() << ")" << std::endl; return 0; } ``` -------------------------------- ### Create Boost.Compute dynamic_bitset Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1dynamic__bitset An example demonstrating how to create a boost::compute::dynamic_bitset on the device with space for 1000 bits, using a provided command queue. ```cpp boost::compute::dynamic_bitset<> bits(1000, queue); ``` -------------------------------- ### Boost.Compute program_cache - Get or Build Program Equivalent Logic Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Provides the equivalent logic to the get_or_build function, showing the steps of attempting to get from cache, building from source if not found, and inserting into the cache. ```cpp boost::optional p = get(key, options); if(!p){ p = program::create_with_source(source, context); p->build(options); insert(key, options, *p); } return *p; ``` -------------------------------- ### Boost.Compute Data Transformation Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/tutorial This example demonstrates applying a transformation, specifically calculating the square-root of each element, to a vector of floats on a compute device using `boost::compute::transform`. It involves copying data to the device, performing the transformation, and copying results back to the host. It requires Boost.Compute, standard C++ algorithms, and math functionals. ```cpp #include #include #include #include #include namespace compute = boost::compute; int main() { // get default device and setup context compute::device device = compute::system::default_device(); compute::context context(device); compute::command_queue queue(context, device); // generate random data on the host std::vector host_vector(10000); std::generate(host_vector.begin(), host_vector.end(), rand); // create a vector on the device compute::vector device_vector(host_vector.size(), context); // transfer data from the host to the device compute::copy( host_vector.begin(), host_vector.end(), device_vector.begin(), queue ); // calculate the square-root of each element in-place compute::transform( device_vector.begin(), device_vector.end(), device_vector.begin(), compute::sqrt(), queue ); // copy values back to the host compute::copy( device_vector.begin(), device_vector.end(), host_vector.begin(), queue ); return 0; } ``` -------------------------------- ### Boost.Compute Data Transfer Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/tutorial This example illustrates how to transfer data between the host and a compute device using `boost::compute::copy`. It shows copying data from a host array to a `boost::compute::vector` on the device, and then back to a `std::vector` on the host. It requires Boost.Compute and standard C++ containers. ```cpp #include #include #include namespace compute = boost::compute; int main() { // get default device and setup context compute::device device = compute::system::default_device(); compute::context context(device); compute::command_queue queue(context, device); // create data array on host int host_data[] = { 1, 3, 5, 7, 9 }; // create vector on device compute::vector device_vector(5, context); // copy from host to device compute::copy( host_data, host_data + 5, device_vector.begin(), queue ); // create vector on host std::vector host_vector(5); // copy data back to host compute::copy( device_vector.begin(), device_vector.end(), host_vector.begin(), queue ); return 0; } ``` -------------------------------- ### Compile C++ with Boost.Compute and OpenCL (GCC) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/getting_started This example shows how to compile a C++ program using Boost.Compute and link against the OpenCL library with GCC. It requires specifying the include path for Boost.Compute and the OpenCL library. ```bash g++ -I/path/to/compute/include main.cpp -lOpenCL ``` -------------------------------- ### Boost.Compute local_buffer Usage Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1local__buffer Example demonstrating how to use `local_buffer` to set local memory arguments for compute kernels. This snippet shows creating a local buffer for 32 floats. ```cpp // set argument to a local buffer with storage for 32 float's kernel.set_arg(0, local_buffer(32)); ``` -------------------------------- ### Create Boost.Compute Context for Default Device Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1context Demonstrates how to create a compute context for the default OpenCL device on the system. This involves first obtaining the default device and then initializing the context with it. This is a common starting point for OpenCL operations. ```cpp // get the default compute device boost::compute::device gpu = boost::compute::system::default_device(); // create a context for the device boost::compute::context context(gpu); ``` -------------------------------- ### Create Default Compute Context and Command Queue (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue This snippet shows how to obtain the default compute device, create a compute context for it, and then initialize a command queue associated with that context and device. This is a common setup for most OpenCL programs using Boost.Compute. ```cpp #include // get the default compute device boost::compute.device device = boost::compute.system.default_device(); // set up a compute context and command queue boost::compute.context context(device); boost::compute.command_queue queue(context, device); ``` -------------------------------- ### Boost Compute System Class Synopsis (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1system This C++ code snippet shows the synopsis for the 'boost::compute::system' class. It includes static functions for accessing system-level compute resources like devices, contexts, and platforms. This class simplifies the setup and management of OpenCL environments. ```cpp // In header: class system { public: // public static functions static device default_device(); static device find_device(const std::string &); static std::vector< device > devices(); static size_t device_count(); static context default_context(); static command_queue & default_queue(const command_queue & = command_queue()); static void finish(); static std::vector< platform > platforms(); static size_t platform_count(); }; ``` -------------------------------- ### Boost.Compute image1d Constructors Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1image1d Provides C++ code examples for the constructors of the boost::compute::image1d class. This includes creating a null image, initializing a new image with specified dimensions and format, copying an existing image, and move construction/assignment. ```cpp image1d(); ``` ```cpp image1d(const context & context, size_t image_width, const image_format & format, cl_mem_flags flags = read_write, void * host_ptr = 0); ``` ```cpp image1d(const image1d & other); ``` ```cpp image1d & operator=(const image1d & other); ``` ```cpp image1d(image1d && other) noexcept; ``` ```cpp image1d & operator=(image1d && other) noexcept; ``` -------------------------------- ### Wait List Constructor Examples (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1wait__list Demonstrates the creation of a wait_list object using different constructors. This includes creating an empty list, a list with a single event, a copy of another list, and a list initialized from an initializer list. ```cpp wait_list(); wait_list(const event & event); wait_list(const wait_list & other); wait_list(std::initializer_list< event > events); ``` -------------------------------- ### Boost.Compute program_cache - Get Program Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Illustrates how to retrieve a program object from the program_cache using its key. It checks if the program exists in the cache before using it. ```cpp boost::optional p = cache.get("foo"); if(p){ // program found in cache } ``` -------------------------------- ### Creating a Boost.Compute array Instance Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1array Example demonstrating how to create a fixed-size array of integers on the device using Boost.Compute. This requires a valid compute context. The array size is determined at compile time. ```cpp boost::compute::array values(context); ``` -------------------------------- ### Instantiate and Handle set_default_queue_error in C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1set__default__queue__error Demonstrates how to instantiate the set_default_queue_error exception object and retrieve error information using the what() member function. This is typically used in try-catch blocks to handle command queue setup failures in Boost.Compute applications. ```cpp try { // Code that attempts to set default command queue set_default_queue_error error; throw error; } catch (const set_default_queue_error& e) { const char* message = e.what(); // Handle error with message } ``` -------------------------------- ### copy_n Host-to-Device Memory Transfer Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/copy__n_8hpp_1ab90d7f06632091c46f71a73f496371ee Demonstrates copying four float values from host memory to a GPU device vector using boost::compute::copy_n. Shows typical usage pattern with array initialization, GPU vector creation, and the copy operation with a command queue. ```cpp // values on the host and vector on the device float values[4] = { 1.f, 2.f, 3.f, 4.f }; boost::compute::vector vec(4, context); // copy from the host to the device boost::compute::copy_n(values, 4, vec.begin(), queue); ``` -------------------------------- ### Boost.Compute program_cache - Insert Program Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Demonstrates how to insert a program object into the program_cache using a specified key. This allows for later retrieval of the compiled program. ```cpp cache.insert("foo", foo_program); ``` -------------------------------- ### Get Default Command Queue (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1system Returns the default command queue for the system. If a user-provided command queue is supplied, it attempts to set the system's default context and device accordingly. Throws an exception if the provided queue's context/device conflicts with existing defaults. The default queue is created once. ```cpp #include #include // Example usage: // boost::compute::command_queue queue = boost::compute::system::default_queue(); ``` -------------------------------- ### Boost.Compute iota Function Template C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/iota_8hpp_1ad6aa9ce0623e274eca26f8724d53ef85 Fills the range [`first`, `last`) with sequential values starting at `value`. This function requires the Boost.Compute library and a command queue. It takes buffer iterators and an initial value as input. ```cpp #include #include #include // ... template void iota(BufferIterator first, BufferIterator last, const T & value, command_queue & queue = system::default_queue()); // Example usage: // std::vector vec(10); // boost::compute::iota(vec.begin(), vec.end(), 0); ``` -------------------------------- ### Get and Set Program Build Information Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Retrieve build-specific information for the program on a given device, such as compilation options. This is crucial for understanding how a program was compiled or for debugging build issues. ```cpp template T get_build_info(cl_program_build_info info, const device & device) const; std::string build_log() const; ``` -------------------------------- ### Getting Kernel Name, Arity, Program, and Context Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1kernel Functions to retrieve essential information about an OpenCL kernel, including its function name, the number of arguments (arity), the program it belongs to, and the context it was created in. ```cpp std::string name() const; ``` ```cpp size_t arity() const; ``` ```cpp program get_program() const; ``` ```cpp context get_context() const; ``` -------------------------------- ### Boost.Compute buffer_iterator Constructor and Assignment Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1buffer__iterator Provides C++ code examples for the constructors and the assignment operator of the `boost::compute::buffer_iterator`. These functions are used to create and manage buffer iterator objects. ```cpp buffer_iterator(); ``` ```cpp buffer_iterator(const buffer & buffer, size_t index); ``` ```cpp buffer_iterator(const buffer_iterator< T > & other); ``` ```cpp buffer_iterator< T > & operator=(const buffer_iterator< T > & other); ``` -------------------------------- ### Get Command Queue Information with Template C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Retrieves information about the command queue using OpenCL query constants. Returns type-specific information based on the cl_command_queue_info parameter. ```cpp template T get_info(cl_command_queue_info info) const; ``` -------------------------------- ### Boost.Compute Lambda Library Example Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/faq Demonstrates how to use the Boost.Compute lambda library to transform C++ lambda expressions into C99 source code for OpenCL execution. This allows writing code closer to C++ that can run on GPUs. ```cpp #include #include #include #include int main() { // Define input and output vectors std::vector input = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f}; std::vector output(input.size()); // Get default compute device and context boost::compute::device device = boost::compute::system::default_device(); boost::compute::context context(device); boost::compute::command_queue queue(context, device); // Create input and output buffers on the device boost::compute::vector input_buffer(input.begin(), input.end(), queue); boost::compute::vector output_buffer(output.size(), queue); // Define the lambda expression for transformation: _1 * sqrt(_1) + 4 using namespace boost::compute::lambda; auto expr = _1 * sqrt(_1) + 4; // Perform the transform operation using the lambda expression boost::compute::transform(input_buffer.begin(), input_buffer.end(), output_buffer.begin(), expr, queue); // Copy the result back to the host vector boost::compute::copy(output_buffer.begin(), output_buffer.end(), output.begin(), queue); // Output the result (for demonstration) for (float val : output) { // std::cout << val << " "; // Example: print values } // std::cout << std::endl; return 0; } ``` -------------------------------- ### Boost.Compute program_cache - Get or Build Program Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Attempts to retrieve a program from the cache by key and options. If not found, it builds the program from source, caches it, and returns it. This simplifies the common load-or-build pattern. ```cpp program get_or_build(const std::string & key, const std::string & options, const std::string & source, const context & context); ``` -------------------------------- ### Boost.Compute Context Member Functions for Information Retrieval Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1context Illustrates C++ code for member functions of boost::compute::context used to retrieve information about the context. This includes getting the underlying OpenCL context, the associated device(s), and general context information. ```cpp cl_context & get() const; ``` ```cpp device get_device() const; ``` ```cpp std::vector< device > get_devices() const; ``` ```cpp template T get_info(cl_context_info info) const; ``` ```cpp template _unspecified_ get_info() const; ``` -------------------------------- ### Use scalar_type meta-function to get vector element type Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/structboost_1_1compute_1_1scalar__type Demonstrates the usage of the scalar_type struct template to retrieve the scalar type from a vector type. The example shows that scalar_type::type resolves to float, allowing compile-time type extraction for GPU compute vectors. ```cpp scalar_type::type == float ``` -------------------------------- ### Boost.Compute Accumulate Example C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/accumulate_8hpp_1ad20e2d713a5459580000254f9a5ca8dd Demonstrates the usage of boost::compute::accumulate with integers and floats. The integer example shows a fast accumulation using 'plus', which can be optimized to 'reduce'. The float example illustrates that 'accumulate' with 'plus' is slower due to floating-point non-associativity, recommending 'reduce' for performance. ```cpp // with vec = boost::compute::vector accumulate(vec.begin(), vec.end(), 0, plus()); // fast reduce(vec.begin(), vec.end(), &result, plus()); // fast // with vec = boost::compute::vector accumulate(vec.begin(), vec.end(), 0, plus()); // slow reduce(vec.begin(), vec.end(), &result, plus()); // fast ``` -------------------------------- ### Building Boost Compute Program from Source File (Static) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program A static method to create and immediately build a Boost Compute program from a source file. This combines program creation and compilation into a single call. Requires the source file path, context, and optional build flags. ```C++ static program build_with_source_file(const std::string &, const context &, const std::string & = std::string()); ``` -------------------------------- ### Get Memory Object Context (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1memory__object Illustrates how to get the OpenCL context associated with a Boost Compute memory object. The context is crucial for OpenCL operations. ```cpp context get_context() const; ``` -------------------------------- ### Boost.Compute Context Constructors Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1context Provides C++ code snippets for various constructors of the boost::compute::context class. These include creating null contexts, contexts for specific devices or multiple devices, and contexts from existing OpenCL contexts. ```cpp boost::compute::context(); ``` ```cpp explicit context(const device & device, const cl_context_properties * properties = 0); ``` ```cpp explicit context(const std::vector< device > & devices, const cl_context_properties * properties = 0); ``` ```cpp explicit context(cl_context context, bool retain = true); ``` ```cpp context(const context & other); ``` ```cpp context(context && other) noexcept; ``` -------------------------------- ### Boost.Compute iota Algorithm Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/reference The iota algorithm fills a range with sequentially increasing values, starting from an initial value. It takes a pair of iterators defining the range, the initial value, and an optional command queue. The values are incremented by 1 for each element in the range. ```c++ namespace boost { namespace compute { template void iota(BufferIterator, BufferIterator, const T &, command_queue & = system::default_queue()); } } ``` -------------------------------- ### Boost.Compute future Member Function: get Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1future The 'get()' member function of 'boost::compute::future' retrieves the result of the asynchronous computation. This function will block execution until the result is available. It returns the computed value of type 'T'. ```cpp T get(); ``` -------------------------------- ### Create and initialize basic_string with C-string data Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1basic__string This example demonstrates how to create a boost::compute::string object (typedef for basic_string) and initialize it with a C-string literal. The string contents are automatically copied from the host to the compute device, enabling GPU-accelerated string operations. ```cpp boost::compute::string str("hello, world!"); ``` -------------------------------- ### Host Timer Retrieval Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1device Provides functionalities to get the host timer's current value, synchronized with the device timer. This includes getting the raw nanosecond value, a pair of device and host timestamps, and formatted durations. ```C++ ulong_ get_host_timer() const; ``` ```C++ std::pair< ulong_, ulong_ > get_device_and_host_timer() const; ``` ```C++ template Duration get_host_timer() const; ``` ```C++ template std::pair< Duration, Duration > get_device_and_host_timer() const; ``` -------------------------------- ### Get Program Information Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Generic functions to retrieve various types of information about the OpenCL program. Supports type-safe retrieval using template arguments or an enum-based approach for different information types. ```cpp template T get_info(cl_program_info info) const; template _unspecified_ get_info() const; ``` -------------------------------- ### Usage Examples of is_fundamental - C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/structboost_1_1compute_1_1is__fundamental Example usage of the is_fundamental meta-function demonstrating how to check if types are fundamental. The template returns true for built-in types such as float, and returns false for composite types like std::pair. This is evaluated at compile-time using the ::value member. ```cpp is_fundamental::value == true is_fundamental>::value == false ``` -------------------------------- ### Building a Boost Compute Program Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Compiles and builds a previously created Boost Compute program for execution on OpenCL devices. This step is necessary before kernels can be extracted. The build() method can optionally take build options as a string. ```C++ // build the program foo_program.build(); ``` -------------------------------- ### Get Default Compute Context (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1system Returns the default OpenCL context for the system, which is created for the default compute device. This context is initialized once and subsequent calls return the same object. ```cpp #include #include // Example usage: // boost::compute::context ctx = boost::compute::system::default_context(); ``` -------------------------------- ### Create OpenCL Program from Binary File with Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates an OpenCL program by loading binary data from a specified file. This is efficient for deploying pre-compiled OpenCL kernels. ```cpp static program create_with_binary_file(const std::string & file, const context & context); ``` -------------------------------- ### Boost C++ bind Example: Creating a Less Than Function Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/bind_8hpp_1ab0cbccb08556fe02ac7078a1734a21e8 This C++ example demonstrates the usage of boost::compute::bind to create a unary function object. It binds the `boost::compute::less` function with `_1` (the placeholder for the first argument) and the integer `7`, effectively creating a function that checks if its argument is less than 7. ```cpp using boost::compute::less; using boost::compute::placeholders::_1; auto less_than_seven = boost::compute::bind(less(), _1, 7); ``` -------------------------------- ### Boost.Compute buffer Class Synopsis Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1buffer The synopsis for the boost::compute::buffer class outlines its constructors, destructors, and member functions. It defines how to create, copy, move, and query buffer objects on a compute device. ```cpp // In header: class buffer : public boost::compute::memory_object { public: // public member functions buffer(); explicit buffer(cl_mem, bool = true); buffer(const context &, size_t, cl_mem_flags = read_write, void * = 0); buffer(const buffer &); buffer & operator=(const buffer &); buffer(buffer &&) noexcept; buffer & operator=(buffer &&) noexcept; ~buffer(); size_t size() const; template T get_info(cl_mem_info) const; template _unspecified_ get_info() const; buffer clone(command_queue &) const; buffer create_subbuffer(cl_mem_flags, size_t, size_t); }; ``` -------------------------------- ### Struct template get - Boost.Compute functional Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/structboost_1_1compute_1_1get A template struct that provides indexed element access for aggregate types like scalarN, pair, and tuple. It takes a compile-time size_t parameter N and implements operator() to retrieve the N'th element from a given argument. This is useful for generic functional programming with heterogeneous data structures in GPU computing contexts. ```cpp template struct get { // public member functions template _unspecified_ operator()(const Arg &) const; }; ``` ```cpp template _unspecified_ operator()(const Arg & arg) const; ``` -------------------------------- ### Get Context from command_queue C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Returns the context object associated with this command queue. ```cpp context get_context() const; ``` -------------------------------- ### Get Device from command_queue C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Returns the device object that this command queue issues commands to. ```cpp device get_device() const; ``` -------------------------------- ### Boost.Compute buffer: Create with Context and Size Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1buffer Demonstrates creating a new memory buffer with a specified size, memory flags, and within a given compute context. An optional host pointer can be provided for initial data population. ```cpp buffer(const context & context, size_t size, cl_mem_flags flags = read_write, void * host_ptr = 0); ``` -------------------------------- ### Get Mean of normal_distribution Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1normal__distribution Returns the mean value of the normal distribution. This is a const member function. ```c++ result_type mean() const; ``` -------------------------------- ### Boost.Compute Pipe Constructors (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1pipe Illustrates various constructors for the boost::compute::pipe class. These include creating a null pipe, a pipe from an existing cl_mem object, a new pipe in a given context, copy construction, and move construction. OpenCL 2.0 is required. ```cpp pipe(); explicit pipe(cl_mem mem, bool retain = true); pipe(const context & context, uint_ pipe_packet_size, uint_ pipe_max_packets, cl_mem_flags flags = read_write, const cl_pipe_properties * properties = 0); pipe(const pipe & other); pipe(pipe && other) noexcept; ``` -------------------------------- ### Boost.Compute command_queue Constructors and Basic Operations (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Defines the constructors for the command_queue class, allowing initialization with an existing cl_command_queue, a context and device, or by copying/moving an existing queue. It also includes member functions to retrieve the underlying cl_command_queue, associated device and context, queue properties, and to set the queue as the default for its device. ```cpp // In header: class command_queue { public: // Constructors command_queue(); explicit command_queue(cl_command_queue, bool = true); command_queue(const context &, const device &, cl_command_queue_properties = 0); command_queue(const command_queue &); command_queue & operator=(const command_queue &); command_queue(command_queue &&) noexcept; command_queue & operator=(command_queue &&) noexcept; ~command_queue(); // Accessors cl_command_queue & get() const; device get_device() const; context get_context() const; template T get_info(cl_command_queue_info) const; template _unspecified_ get_info() const; cl_command_queue_properties get_properties() const; command_queue get_default_device_queue() const; void set_as_default_device_queue() const; }; ``` -------------------------------- ### Get Standard Deviation of normal_distribution Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1normal__distribution Returns the standard deviation of the normal distribution. This is a const member function. ```c++ result_type stddev() const; ``` -------------------------------- ### Get Command Queue Properties C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Returns the OpenCL properties flags (cl_command_queue_properties) set for this command queue. ```cpp cl_command_queue_properties get_properties() const; ``` -------------------------------- ### Boost.Compute image2d Class Synopsis Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1image2d The synopsis for the `boost::compute::image2d` class, outlining its inheritance and the signatures of its public member and static functions. This provides a quick overview of the class's interface. ```cpp // In header: class image2d : public boost::compute::image_object { public: // public member functions image2d(); image2d(const context &, size_t, size_t, const image_format &, cl_mem_flags = read_write, void * = 0, size_t = 0); image2d(const image2d &); image2d & operator=(const image2d &); image2d(image2d &&) noexcept; image2d & operator=(image2d &&) noexcept; ~image2d(); extents< 2 > size() const; extents< 2 > origin() const; template T get_info(cl_image_info) const; template _unspecified_ get_info() const; image2d clone(command_queue &) const; // public static functions static std::vector< image_format > get_supported_formats(const context &, cl_mem_flags = read_write); static bool is_supported_format(const image_format &, const context &, cl_mem_flags = read_write); }; ``` -------------------------------- ### Get Maximum Value of normal_distribution Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1normal__distribution Returns the maximum possible value that can be generated by the normal distribution. This is a const member function. ```c++ result_type max BOOST_PREVENT_MACRO_SUBSTITUTION() const; ``` -------------------------------- ### Create command_queue with Context and Device C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Constructs a command queue associated with a specific context and device with optional properties. The command queue will issue commands to the specified device within the given context. ```cpp command_queue(const context & context, const device & device, cl_command_queue_properties properties = 0); ``` -------------------------------- ### Get Minimum Value of normal_distribution Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1normal__distribution Returns the minimum possible value that can be generated by the normal distribution. This is a const member function. ```c++ result_type min BOOST_PREVENT_MACRO_SUBSTITUTION() const; ``` -------------------------------- ### Boost Compute Image Sampler Constructors Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1image__sampler Provides implementations for various constructors of the `boost::compute::image_sampler` class. These include default construction, construction with specific OpenCL parameters, explicit construction from a `cl_sampler`, and copy/move constructors. ```cpp image_sampler(); ``` ```cpp image_sampler(const context & context, bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode); ``` ```cpp explicit image_sampler(cl_sampler sampler, bool retain = true); ``` ```cpp image_sampler(const image_sampler & other); ``` ```cpp image_sampler(image_sampler && other) noexcept; ``` -------------------------------- ### Get Underlying OpenCL Handle from command_queue C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Returns a reference to the underlying cl_command_queue OpenCL handle for direct OpenCL API access. ```cpp cl_command_queue & get() const; ``` -------------------------------- ### Boost.Compute buffer: Get Size Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1buffer Returns the size of the memory buffer in bytes. This member function is part of the boost::compute::buffer class. ```cpp size_t size() const; ``` -------------------------------- ### Get Default Device Queue C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Returns the current default device command queue for the underlying device. Only available in OpenCL 2.1 or later. ```cpp command_queue get_default_device_queue() const; ``` -------------------------------- ### Include All Boost.Compute Headers Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/getting_started This C++ directive includes all available headers from the Boost.Compute library. This is the most comprehensive way to include the library's functionality. ```cpp #include ``` -------------------------------- ### Boost.Compute svm_ptr Get Context Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1svm__ptr Returns a const reference to the OpenCL `context` associated with the `svm_ptr`. This is the context in which the shared virtual memory resides. ```cpp const context & get_context() const; ``` -------------------------------- ### Creating Boost Compute Program from Binary Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates a Boost Compute program object directly from pre-compiled OpenCL binary data. This bypasses the source compilation step and is useful for deploying pre-built kernels. Requires the binary data, its size, and an OpenCL context. ```C++ static program create_with_binary(const unsigned char *, size_t, const context &); ``` ```C++ static program create_with_binary(const std::vector< unsigned char > &, const context &); ``` -------------------------------- ### Boost.Compute dynamic_bitset Class Synopsis Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1dynamic__bitset The synopsis for the boost::compute::dynamic_bitset class, detailing its template parameters, types, and public member functions. It requires the header. ```cpp #include template > class dynamic_bitset { public: typedef Block block_type; typedef Alloc allocator_type; typedef vector< Block, Alloc > container_type; typedef container_type::size_type size_type; static const size_type bits_per_block = sizeof(block_type) * CHAR_BIT; static const size_type npos = static_cast< size_type >(-1); dynamic_bitset(size_type, command_queue &); dynamic_bitset(const dynamic_bitset &); dynamic_bitset & operator=(const dynamic_bitset &); ~dynamic_bitset(); size_type size() const; size_type num_blocks() const; size_type max_size() const; bool empty() const; size_type count(command_queue &) const; void resize(size_type, command_queue &); void set(size_type, command_queue &); void set(size_type, bool, command_queue &); bool test(size_type, command_queue &); void flip(size_type, command_queue &); bool any(command_queue &) const; bool none(command_queue &) const; void reset(command_queue &); void reset(size_type, command_queue &); void clear(); allocator_type get_allocator() const; }; ``` -------------------------------- ### Boost.Compute program_cache - Get Program by Key Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Retrieves a program object from the cache using its unique key. Returns a null optional if no program matches the key. ```cpp boost::optional< program > get(const std::string & key); ``` -------------------------------- ### Boost.Compute svm_ptr Get Raw Pointer Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1svm__ptr Returns the raw `void` pointer managed by the `svm_ptr`. This allows access to the underlying memory for low-level operations. ```cpp void * get() const; ``` -------------------------------- ### Boost.Compute linear_congruential_engine Constructor Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1linear__congruential__engine Demonstrates the explicit constructor for linear_congruential_engine. It shows how to create an engine and optionally seed it with a provided value. ```cpp explicit linear_congruential_engine(command_queue & queue, result_type value = default_seed); ``` -------------------------------- ### Get Command Queue Information with Enum Template C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1command__queue Convenience overload for retrieving command queue information using template enumeration parameter for type-safe queries. ```cpp template _unspecified_ get_info() const; ``` -------------------------------- ### Boost.Compute dynamic_bitset Constructor (Size and Queue) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1dynamic__bitset Constructs a dynamic_bitset with a specified size in bits and initializes all bits to zero. It requires a command_queue to manage device memory allocation. ```cpp dynamic_bitset(size_type size, command_queue & queue); ``` -------------------------------- ### Get Memory Object Size in Bytes (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1memory__object Illustrates how to obtain the size of a Boost Compute memory_object in bytes. This is useful for memory management and allocation calculations. ```cpp size_t get_memory_size() const; ``` -------------------------------- ### Boost constant_buffer_iterator Private Dereference Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1constant__buffer__iterator Details the private dereference member function of constant_buffer_iterator. This function is used internally to get a reference to the element the iterator points to. ```cpp reference dereference() const; ``` -------------------------------- ### Boost.Compute image3d Constructors and Destructor Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1image3d Provides constructors for creating null, initialized, copied, and moved image3d objects, along with a destructor to clean up resources. It handles various initialization parameters including context, dimensions, format, memory flags, host pointer, and pitch values. ```cpp image3d(); image3d(const context &, size_t, size_t, size_t, const image_format &, cl_mem_flags = read_write, void * = 0, size_t = 0, size_t = 0); image3d(const image3d &); image3d & operator=(const image3d &); image3d(image3d &&) noexcept; image3d & operator=(image3d &&) noexcept; ~image3d(); ``` -------------------------------- ### Build OpenCL Program from Source File with Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates a new OpenCL program from a source file and builds it with specified options. The compiled binary can be cached if `BOOST_COMPUTE_USE_OFFLINE_CACHE` is defined. This function takes a file path, context, and optional build options. ```cpp static program build_with_source_file(const std::string & file, const context & context, const std::string & options = std::string()); ``` -------------------------------- ### Boost Compute Counting Iterator Constructor Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1counting__iterator The constructor for the `counting_iterator` class template, which initializes the iterator with a starting value. This is a fundamental part of setting up the counting sequence. ```cpp counting_iterator(const T & init); ``` -------------------------------- ### Constructing and Copying OpenCL Kernels Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1kernel This section covers various ways to construct and copy `kernel` objects. It includes default construction, construction from an existing `cl_kernel`, construction from a `program` and kernel name, copy construction, and assignment. ```cpp kernel(); ``` ```cpp explicit kernel(cl_kernel kernel, bool retain = true); ``` ```cpp kernel(const program & program, const std::string & name); ``` ```cpp kernel(const kernel & other); ``` ```cpp kernel & operator=(const kernel & other); ``` -------------------------------- ### Moving OpenCL Kernels Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1kernel Demonstrates move construction and move assignment for `kernel` objects. This allows for efficient transfer of ownership of OpenCL kernel resources without expensive copying. ```cpp kernel(kernel && other) noexcept; ``` ```cpp kernel & operator=(kernel && other) noexcept; ``` -------------------------------- ### Device Constructors and Destructor Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1device Covers the creation and destruction of `device` objects. This includes default construction, construction from an OpenCL device ID, copy construction, move construction, assignment operators, and the destructor. ```C++ device(); ``` ```C++ explicit device(cl_device_id id, bool retain = true); ``` ```C++ device(const device & other); ``` ```C++ device & operator=(const device & other); ``` ```C++ device(device && other) noexcept; ``` ```C++ device & operator=(device && other) noexcept; ``` ```C++ ~device(); ``` -------------------------------- ### Build OpenCL Program from Source with Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates a new OpenCL program from source code and immediately builds it with specified options. If `BOOST_COMPUTE_USE_OFFLINE_CACHE` is defined, the compiled binary is cached. This function takes source code, context, and optional build options. ```cpp static program build_with_source(const std::string & source, const context & context, const std::string & options = std::string()); ``` -------------------------------- ### Get OpenCL Platform Count (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1system Returns the total number of OpenCL platforms detected on the system. This provides a quick count of available OpenCL environments. ```cpp #include // Example usage: // size_t count = boost::compute::system::platform_count(); ``` -------------------------------- ### Boost.Compute program_cache - Get Program by Key and Options Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Retrieves a program object from the cache using both a key and build options. Returns a null optional if no program matches both criteria. ```cpp boost::optional< program > get(const std::string & key, const std::string & options); ``` -------------------------------- ### Query Platform Information Methods Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1platform Provides methods to retrieve platform metadata including name, vendor, profile, version, and supported extensions. Includes both simple string-based queries and template-based generic information retrieval for accessing OpenCL platform properties. ```cpp cl_platform_id id() const; std::string name() const; std::string vendor() const; std::string profile() const; std::string version() const; std::vector< std::string > extensions() const; bool supports_extension(const std::string & name) const; template T get_info(cl_platform_info info) const; template _unspecified_ get_info() const; ``` -------------------------------- ### Retrieving Device Identifiers and Basic Information Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1device Provides functions to retrieve the underlying OpenCL device ID and its type. The `id()` function returns the `cl_device_id`, while `get()` returns a reference to it. ```C++ cl_device_id id() const; ``` ```C++ cl_device_id & get() const; ``` ```C++ cl_device_type type() const; ``` -------------------------------- ### Querying Device Platform and Vendor Information Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1device These functions allow you to obtain information about the platform associated with the device, as well as the device's name, vendor name, profile, version, and driver version. ```C++ platform platform() const; ``` ```C++ std::string name() const; ``` ```C++ std::string vendor() const; ``` ```C++ std::string profile() const; ``` ```C++ std::string version() const; ``` ```C++ std::string driver_version() const; ``` -------------------------------- ### Creating Boost Compute Program from IL Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates a Boost Compute program object from Intermediate Language (IL) data. This is an alternative to source code or binary compilation, useful for specific OpenCL implementations or toolchains. Requires the IL data, its size, and an OpenCL context. ```C++ static program create_with_il(const void *, const size_t, const context &); ``` ```C++ static program create_with_il(const std::vector< unsigned char > &, const context &); ``` -------------------------------- ### Counting Iterator Factory Functions (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/reference Provides template functions `counting_iterator` and `make_counting_iterator` for creating iterators that generate a sequence of increasing values starting from a given value. ```cpp namespace boost { namespace compute { template class counting_iterator; template counting_iterator< T > make_counting_iterator(const T &); } } ``` -------------------------------- ### Boost Compute Program Creation from Source File Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates a Boost Compute program object from an OpenCL source code file. This is useful for organizing larger kernel definitions. It takes the file path and an OpenCL context as input. ```C++ boost::compute::program bar_program = boost::compute::program::create_with_source_file("/path/to/bar.cl", context); ``` -------------------------------- ### Get Compute Device Count (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1system Returns the total number of compute devices detected on the system. This is a simple utility to quickly determine system compute capacity. ```cpp #include // Example usage: // size_t count = boost::compute::system::device_count(); ``` -------------------------------- ### Create OpenCL Program from SPIR-V Binary with Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates an OpenCL program from SPIR-V binary data. This function requires OpenCL 2.1 or later. It takes a pointer to the binary data and its size, along with the context. ```cpp static program create_with_il(const void * il_binary, const size_t il_size, const context & context); ``` -------------------------------- ### Boost.Compute program_cache - Get Global Cache Static Function Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program__cache Retrieves the singleton global program cache associated with a given OpenCL context. This cache is used internally by Boost.Compute algorithms. ```cpp static boost::shared_ptr< program_cache > get_global_cache(const context & context); ``` -------------------------------- ### Get Memory Object Reference Count (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1memory__object Demonstrates retrieving the reference count for a Boost Compute memory object. This is important for understanding object lifetime and resource management. ```cpp uint_ reference_count() const; ``` -------------------------------- ### Boost.Compute linear_conguential_engine Copy Constructor Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1linear__congruential__engine Illustrates the copy constructor for linear_congruential_engine. This allows creating a new engine by duplicating an existing one. ```cpp linear_congruential_engine(const linear_congruential_engine< T > & other); ``` -------------------------------- ### Boost.Compute image2d Constructors and Destructor Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1image2d Demonstrates the various ways to construct and destruct `boost::compute::image2d` objects. This includes default construction, creation with specified dimensions and format, copy and move constructors, and the destructor. ```cpp image2d(); image2d(const context & context, size_t image_width, size_t image_height, const image_format & format, cl_mem_flags flags = read_write, void * host_ptr = 0, size_t image_row_pitch = 0); image2d(const image2d & other); image2d(image2d && other) noexcept; ~image2d(); ``` -------------------------------- ### Get Memory Object Flags (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1memory__object Demonstrates retrieving the creation flags associated with a Boost Compute memory object. These flags specify properties like read/write access. ```cpp cl_mem_flags get_memory_flags() const; ``` -------------------------------- ### Get Underlying OpenCL Memory Object (C++) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1memory__object Demonstrates how to retrieve the underlying OpenCL memory object from a Boost Compute memory_object. This function is essential for interacting with OpenCL directly. ```cpp cl_mem & get() const; ``` -------------------------------- ### Setting Kernel Arguments Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1kernel Methods for setting the arguments of an OpenCL kernel. This includes a low-level version taking size and value, and a templated version that simplifies setting arguments for built-in types and device memory objects. ```cpp void set_arg(size_t index, size_t size, const void * value); ``` ```cpp template void set_arg(size_t index, const T & value); ``` -------------------------------- ### Boost.Compute buffer: Get Info (Enum) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1buffer An overloaded template function to retrieve buffer information using an integer enum value. This provides a different way to query buffer properties. ```cpp template _unspecified_ get_info() const; ``` -------------------------------- ### min_element Function Template Synopsis - C++ Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/min__element_8hpp_1accfe8bec869734d5abe5500b5ceefc20 Provides the C++ synopsis for the `boost::compute::min_element` function template, including template parameters, return type, and function arguments. It specifies the header file where the function is declared. ```C++ // In header: template InputIterator min_element(InputIterator first, InputIterator last, Compare compare, command_queue & queue = system::default_queue()); ``` -------------------------------- ### Create OpenCL Program from SPIR-V Binary File with Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1program Creates an OpenCL program by loading SPIR-V binary data from a specified file. This function requires OpenCL 2.1 or later. ```cpp static program create_with_il_file(const std::string & file, const context & context); ``` -------------------------------- ### Boost.Compute buffer: Get Info (Typed) Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1buffer Retrieves specific information about the buffer object using a type-safe template. Requires the type `T` and the OpenCL memory information query parameter `cl_mem_info`. ```cpp template T get_info(cl_mem_info) const; ``` -------------------------------- ### Get Vector Size Header Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/reference Defines the `vector_size` template struct to determine the number of elements in a given vector type. This is essential for operations that depend on the dimensionality of vector data. ```cpp namespace boost { namespace compute { template struct vector_size; } } ``` -------------------------------- ### Boost.Compute Atomic Compare and Exchange Class Template Synopsis Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/doxygen/header_reference/classboost_1_1compute_1_1atomic__cmpxchg Provides the C++ synopsis for the `boost::compute::atomic_cmpxchg` class template, detailing its template parameter, base class, and member functions. This header is required for its usage. ```cpp // In header: template class atomic_cmpxchg : public boost::compute::function< T(T *, T, T)> { public: // public member functions atomic_cmpxchg(); }; ``` -------------------------------- ### Get Type Definition as String Header Boost.Compute Source: https://www.boost.org/doc/libs/latest/libs/compute/doc/html/boost_compute/reference Provides the `type_definition` function template, which returns a string representation of a given type's definition. This can be helpful for debugging or logging purposes. ```cpp namespace boost { namespace compute { template std::string type_definition(); } } ```