ViennaCL - The Vienna Computing Library: viennacl/ocl/program.hpp Source File

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"
30 #include "viennacl/tools/shared_ptr.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
53 viennacl::ocl::program & operator=(const program & other)
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
76 viennacl::ocl::handle<cl_program> handle_;
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
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 >