All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
program.hpp
Go to the documentation of this file.
#ifndef VIENNACL_OCL_PROGRAM_HPP_
#define VIENNACL_OCL_PROGRAM_HPP_
/* =========================================================================
Copyright (c) 2010-2016, Institute for Microelectronics,
Institute for Analysis and Scientific Computing,
TU Wien.
Portions of this software are copyright by UChicago Argonne, LLC.
-----------------
ViennaCL - The Vienna Computing Library
-----------------
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
(A list of authors and contributors can be found in the manual)
License: MIT (X11), see file LICENSE in the base directory
============================================================================= */
#include <string>
#include <vector>
#include "viennacl/ocl/forwards.h"
#include "viennacl/ocl/handle.hpp"
#include "viennacl/ocl/kernel.hpp"
#include "viennacl/tools/shared_ptr.hpp"
namespace viennacl
{
namespace ocl
{
class program
{
typedef std::vector<tools::shared_ptr<viennacl::ocl::kernel> > kernel_container_type;
public:
program() : p_context_(NULL) {}
program(cl_program program_handle, viennacl::ocl::context const & program_context, std::string const & prog_name = std::string())
: handle_(program_handle, program_context), p_context_(&program_context), name_(prog_name) {}
program(program const & other) : handle_(other.handle_), p_context_(other.p_context_), name_(other.name_), kernels_(other.kernels_) { }
viennacl::ocl::program & operator=(const program & other)
{
handle_ = other.handle_;
name_ = other.name_;
p_context_ = other.p_context_;
kernels_ = other.kernels_;
return *this;
}
viennacl::ocl::context const * p_context() const { return p_context_; }
std::string const & name() const { return name_; }
inline viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const & kernel_name); //see context.hpp for implementation
inline viennacl::ocl::kernel & get_kernel(std::string const & name); //see context.hpp for implementation
const viennacl::ocl::handle<cl_program> & handle() const { return handle_; }
private:
viennacl::ocl::handle<cl_program> handle_;
viennacl::ocl::context const * p_context_;
std::string name_;
kernel_container_type kernels_;
};
} //namespace ocl
} //namespace viennacl
#endif
forwards.h
This file provides the forward declarations for the OpenCL layer of ViennaCL.
viennacl::ocl::program::add_kernel
viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const &kernel_name)
Adds a kernel to the program.
Definition: context.hpp:765
viennacl::ocl::program::program
program()
Definition: program.hpp:47
viennacl::ocl::kernel
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:58
viennacl::ocl::program::handle
const viennacl::ocl::handle< cl_program > & handle() const
Definition: program.hpp:72
viennacl::ocl::context
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:55
shared_ptr.hpp
Implementation of a shared pointer class (cf. std::shared_ptr, boost::shared_ptr). Will be used until C++11 is widely available.
handle.hpp
Implementation of a smart-pointer-like class for handling OpenCL handles.
viennacl::ocl::program::program
program(cl_program program_handle, viennacl::ocl::context const &program_context, std::string const &prog_name=std::string())
Definition: program.hpp:48
viennacl::ocl::program::name
std::string const & name() const
Definition: program.hpp:64
viennacl::ocl::program
Wrapper class for an OpenCL program.
Definition: program.hpp:42
viennacl::ocl::program::operator=
viennacl::ocl::program & operator=(const program &other)
Definition: program.hpp:53
kernel.hpp
Representation of an OpenCL kernel in ViennaCL.
viennacl::ocl::program::program
program(program const &other)
Definition: program.hpp:51
viennacl::ocl::program::p_context
viennacl::ocl::context const * p_context() const
Definition: program.hpp:62
viennacl::ocl::program::get_kernel
viennacl::ocl::kernel & get_kernel(std::string const &name)
Returns the kernel with the provided name.
Definition: context.hpp:773
viennacl::ocl::handle< cl_program >