ViennaCL - The Vienna Computing Library  1.7.1
Free open-source GPU-accelerated linear algebra and solver library.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
program.hpp
Go to the documentation of this file.
1 #ifndef VIENNACL_OCL_PROGRAM_HPP_
2 #define VIENNACL_OCL_PROGRAM_HPP_
3 
4 /* =========================================================================
5  Copyright (c) 2010-2016, Institute for Microelectronics,
6  Institute for Analysis and Scientific Computing,
7  TU Wien.
8  Portions of this software are copyright by UChicago Argonne, LLC.
9 
10  -----------------
11  ViennaCL - The Vienna Computing Library
12  -----------------
13 
14  Project Head: Karl Rupp rupp@iue.tuwien.ac.at
15 
16  (A list of authors and contributors can be found in the manual)
17 
18  License: MIT (X11), see file LICENSE in the base directory
19 ============================================================================= */
20 
25 #include <string>
26 #include <vector>
27 #include "viennacl/ocl/forwards.h"
28 #include "viennacl/ocl/handle.hpp"
29 #include "viennacl/ocl/kernel.hpp"
31 
32 namespace viennacl
33 {
34 namespace ocl
35 {
36 
42 class program
43 {
44  typedef std::vector<tools::shared_ptr<viennacl::ocl::kernel> > kernel_container_type;
45 
46 public:
47  program() : p_context_(NULL) {}
48  program(cl_program program_handle, viennacl::ocl::context const & program_context, std::string const & prog_name = std::string())
49  : handle_(program_handle, program_context), p_context_(&program_context), name_(prog_name) {}
50 
51  program(program const & other) : handle_(other.handle_), p_context_(other.p_context_), name_(other.name_), kernels_(other.kernels_) { }
52 
54  {
55  handle_ = other.handle_;
56  name_ = other.name_;
57  p_context_ = other.p_context_;
58  kernels_ = other.kernels_;
59  return *this;
60  }
61 
62  viennacl::ocl::context const * p_context() const { return p_context_; }
63 
64  std::string const & name() const { return name_; }
65 
67  inline viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const & kernel_name); //see context.hpp for implementation
68 
70  inline viennacl::ocl::kernel & get_kernel(std::string const & name); //see context.hpp for implementation
71 
72  const viennacl::ocl::handle<cl_program> & handle() const { return handle_; }
73 
74 private:
75 
77  viennacl::ocl::context const * p_context_;
78  std::string name_;
79  kernel_container_type kernels_;
80 };
81 
82 } //namespace ocl
83 } //namespace viennacl
84 
85 
86 #endif
This file provides the forward declarations for the OpenCL layer of ViennaCL.
viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const &kernel_name)
Adds a kernel to the program.
Definition: context.hpp:765
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:58
const viennacl::ocl::handle< cl_program > & handle() const
Definition: program.hpp:72
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:55
Implementation of a shared pointer class (cf. std::shared_ptr, boost::shared_ptr). Will be used until C++11 is widely available.
Implementation of a smart-pointer-like class for handling OpenCL handles.
program(cl_program program_handle, viennacl::ocl::context const &program_context, std::string const &prog_name=std::string())
Definition: program.hpp:48
std::string const & name() const
Definition: program.hpp:64
Wrapper class for an OpenCL program.
Definition: program.hpp:42
viennacl::ocl::program & operator=(const program &other)
Definition: program.hpp:53
Representation of an OpenCL kernel in ViennaCL.
program(program const &other)
Definition: program.hpp:51
viennacl::ocl::context const * p_context() const
Definition: program.hpp:62
viennacl::ocl::kernel & get_kernel(std::string const &name)
Returns the kernel with the provided name.
Definition: context.hpp:773