ViennaCL - The Vienna Computing Library
1.5.2
|
00001 #ifndef VIENNACL_OCL_PROGRAM_HPP_ 00002 #define VIENNACL_OCL_PROGRAM_HPP_ 00003 00004 /* ========================================================================= 00005 Copyright (c) 2010-2014, Institute for Microelectronics, 00006 Institute for Analysis and Scientific Computing, 00007 TU Wien. 00008 Portions of this software are copyright by UChicago Argonne, LLC. 00009 00010 ----------------- 00011 ViennaCL - The Vienna Computing Library 00012 ----------------- 00013 00014 Project Head: Karl Rupp rupp@iue.tuwien.ac.at 00015 00016 (A list of authors and contributors can be found in the PDF manual) 00017 00018 License: MIT (X11), see file LICENSE in the base directory 00019 ============================================================================= */ 00020 00025 #include <string> 00026 #include <vector> 00027 #include "viennacl/ocl/forwards.h" 00028 #include "viennacl/ocl/handle.hpp" 00029 #include "viennacl/ocl/kernel.hpp" 00030 00031 namespace viennacl 00032 { 00033 namespace ocl 00034 { 00040 class program 00041 { 00042 typedef std::vector<viennacl::ocl::kernel> KernelContainer; 00043 00044 public: 00045 program() : p_context_(NULL) {} 00046 program(cl_program program_handle, viennacl::ocl::context const & program_context, std::string const & prog_name = std::string()) 00047 : handle_(program_handle, program_context), p_context_(&program_context), name_(prog_name) {} 00048 00049 program(program const & other) : handle_(other.handle_), p_context_(other.p_context_), name_(other.name_), kernels_(other.kernels_) {} 00050 00051 viennacl::ocl::program & operator=(const program & other) 00052 { 00053 handle_ = other.handle_; 00054 name_ = other.name_; 00055 p_context_ = other.p_context_; 00056 kernels_ = other.kernels_; 00057 return *this; 00058 } 00059 00060 std::string const & name() const { return name_; } 00061 00063 inline viennacl::ocl::kernel & add_kernel(cl_kernel kernel_handle, std::string const & kernel_name); //see context.hpp for implementation 00064 00066 inline viennacl::ocl::kernel & get_kernel(std::string const & name); //see context.hpp for implementation 00067 00068 const viennacl::ocl::handle<cl_program> & handle() const { return handle_; } 00069 00070 private: 00071 00072 viennacl::ocl::handle<cl_program> handle_; 00073 viennacl::ocl::context const * p_context_; 00074 std::string name_; 00075 KernelContainer kernels_; 00076 }; 00077 } //namespace ocl 00078 } //namespace viennacl 00079 00080 00081 #endif