gKitGL
CLKernel.h
00001 
00002 #ifndef _CL_KERNEL_H
00003 #define _CL_KERNEL_H
00004 
00005 #include <string>
00006 #include <CL/CLPlatform.h>
00007 
00008 #include "CLInit.h"
00009 #include "CLResource.h"
00010 
00011 
00012 namespace gk {
00013 
00014 class CLBuffer;
00015 class CLImage;
00016 class TextFile;
00017     
00018 class CLKernel : public CLResource
00019 {
00020     cl_program m_program;
00021     cl_kernel m_kernel;
00022     cl_uint m_parameter_count;
00023     
00024     CLKernel( CLKernel& );
00025     CLKernel& operator= ( const CLKernel& );
00026     
00027     std::string m_name;
00028     std::string m_options;
00029     TextFile *m_source;
00030     int make( const TextFile *source, const std::string& name, const std::string& options );
00031     
00032 public:
00033     CLKernel( )
00034         :
00035         m_program(0),
00036         m_kernel(0),
00037         m_parameter_count(0),
00038         m_name(),
00039         m_options(),
00040         m_source(NULL)
00041     {}
00042     
00043     CLKernel( TextFile *source, const std::string& name, const std::string& options= "" )
00044         :
00045         m_program(0),
00046         m_kernel(0),
00047         m_parameter_count(0),
00048         m_name(name),
00049         m_options(options),
00050         m_source(source)
00051     {}
00052     
00053     ~CLKernel( ) {}
00054 
00055     int define( const std::string& what, const std::string& value );
00056     int options( const std::string& options );
00057     
00058     int createCLResource( );
00059     int releaseCLResource( );
00060     
00061     const std::string& name( ) const
00062     {
00063         return m_name;
00064     }
00065         
00066     const cl_kernel *object( ) const
00067     {
00068         return &m_kernel;
00069     }
00070     
00071     cl_kernel *object( )
00072     {
00073         return &m_kernel;
00074     }
00075     
00076     cl_kernel kernel( ) const
00077     {
00078         return m_kernel;
00079     }
00080     
00081     int parameterCount( )
00082     {
00083         return m_parameter_count;
00084     }
00085     
00086     int setParameter( const unsigned int index, const size_t size, const void *value );
00087     int setParameter( const unsigned int index, const CLBuffer *buffer );
00088     int setParameter( const unsigned int index, const CLImage *image );
00089     
00090     size_t workgroupSize( );
00091     size_t scheduleSize( );
00092     size_t CompileWorkgroupSize( ); // declaredSize ?
00093     size_t CompileWorkgroupSizes( size_t sizes[3] );
00094     
00095     size_t localMemorySize( );
00096     size_t privateMemorySize( );
00097 };
00098 
00099 CLKernel *createKernel( const std::string& filename, const std::string& name, const std::string& options= "" );
00100 
00101 int dispatch( CLKernel *kernel, const size_t global_size, const size_t group_size, cl_event *wait= NULL );
00102 int dispatch2D( CLKernel *kernel, const size_t global_width, const size_t global_height, const size_t group_width, const size_t group_height, cl_event *wait= NULL );
00103 int dispatch3D( CLKernel *kernel, cl_event *wait= NULL );
00104 
00105 }       // namespace gk
00106 
00107 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerator Friends