ViennaCL - The Vienna Computing Library  1.5.2
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-2014, 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 PDF 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"
30 
31 namespace viennacl
32 {
33  namespace ocl
34  {
40  class program
41  {
42  typedef std::vector<viennacl::ocl::kernel> KernelContainer;
43 
44  public:
45  program() : p_context_(NULL) {}
46  program(cl_program program_handle, viennacl::ocl::context const & program_context, std::string const & prog_name = std::string())
47  : handle_(program_handle, program_context), p_context_(&program_context), name_(prog_name) {}
48 
49  program(program const & other) : handle_(other.handle_), p_context_(other.p_context_), name_(other.name_), kernels_(other.kernels_) {}
50 
52  {
53  handle_ = other.handle_;
54  name_ = other.name_;
55  p_context_ = other.p_context_;
56  kernels_ = other.kernels_;
57  return *this;
58  }
59 
60  std::string const & name() const { return name_; }
61 
63  inline viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const & kernel_name); //see context.hpp for implementation
64 
66  inline viennacl::ocl::kernel & get_kernel(std::string const & name); //see context.hpp for implementation
67 
68  const viennacl::ocl::handle<cl_program> & handle() const { return handle_; }
69 
70  private:
71 
73  viennacl::ocl::context const * p_context_;
74  std::string name_;
75  KernelContainer kernels_;
76  };
77  } //namespace ocl
78 } //namespace viennacl
79 
80 
81 #endif
This file provides the forward declarations for the OpenCL layer of ViennaCL.
program()
Definition: program.hpp:45
Represents an OpenCL kernel within ViennaCL.
Definition: kernel.hpp:59
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Definition: context.hpp:51
program(program const &other)
Definition: program.hpp:49
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
Definition: cpu_ram.hpp:29
Implementation of a smart-pointer-like class for handling OpenCL handles.
viennacl::ocl::program & operator=(const program &other)
Definition: program.hpp:51
viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const &kernel_name)
Adds a kernel to the program.
Definition: context.hpp:629
program(cl_program program_handle, viennacl::ocl::context const &program_context, std::string const &prog_name=std::string())
Definition: program.hpp:46
const viennacl::ocl::handle< cl_program > & handle() const
Definition: program.hpp:68
Wrapper class for an OpenCL program.
Definition: program.hpp:40
std::string const & name() const
Definition: program.hpp:60
viennacl::ocl::kernel & get_kernel(std::string const &name)
Returns the kernel with the provided name.
Definition: context.hpp:638
Representation of an OpenCL kernel in ViennaCL.