You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
64 lines
1.3 KiB
8 years ago
|
#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;
|
||
|
};
|
||
|
|
||
8 years ago
|
class CL_Wrapper {
|
||
8 years ago
|
public:
|
||
|
|
||
8 years ago
|
CL_Wrapper();
|
||
|
~CL_Wrapper();
|
||
8 years ago
|
|
||
|
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);
|
||
8 years ago
|
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);
|
||
|
|
||
8 years ago
|
|
||
|
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;
|
||
8 years ago
|
cl_command_queue command_queue;
|
||
8 years ago
|
|
||
|
std::map<std::string, cl_kernel> kernel_map;
|
||
8 years ago
|
std::map<std::string, cl_mem> buffer_map;
|
||
8 years ago
|
};
|
||
|
|