Switched names, thinking about how to do kernel args, and buffers.

Need to do a bit more reading on how to set up interop.
Also need to figure out the buffer thing for regular primative buffers, and also image buffers
This commit is contained in:
2016-08-28 22:40:29 -07:00
parent 5dea2494a0
commit 0c70c24a52
7 changed files with 193 additions and 40 deletions

63
include/CL_Wrapper.h Normal file
View File

@@ -0,0 +1,63 @@
#include <vector>
#include <iostream>
#include "util.hpp"
#include <map>
#ifdef linux
#include <CL/cl.h>
#include <CL/opencl.h>
#elif defined _WIN32
#include <CL/cl_gl.h>
#include <CL/cl.h>
#include <CL/opencl.h>
#include <windows.h>
#elif defined TARGET_OS_MAC
# include <OpenGL/OpenGL.h>
# include <OpenCL/opencl.h>
#endif
struct device {
cl_device_id id;
cl_device_type type;
cl_uint clock_frequency;
char version[128];
cl_platform_id platform;
};
class CL_Wrapper {
public:
CL_Wrapper();
~CL_Wrapper();
int acquire_platform_and_device();
int create_shared_context();
int create_command_queue();
int compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name);
int set_kernel_arg(cl_kernel kernel, int index, int size, void* buffer, std::string kernel_name);
int store_buffer(cl_mem, std::string buffer_name);
int run_kernel(std::string kernel_name);
cl_device_id getDeviceID();
cl_platform_id getPlatformID();
cl_context getContext();
private:
int error = 0;
bool initialized = false;
bool assert(int error_code, std::string function_name);
cl_platform_id platform_id;
cl_device_id device_id;
cl_context context;
cl_command_queue command_queue;
std::map<std::string, cl_kernel> kernel_map;
std::map<std::string, cl_mem> buffer_map;
};