-
-
Save PontiacGTX/c0ddb06320718b4343858a9c95512e39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef APPLICATIONCL_H | |
#define APPLICATIONCL_H | |
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
#include <iterator> | |
#include <fstream> | |
#include <sstream> | |
#include <CL/cl.h> | |
class Program | |
{ | |
friend int readfilec(const char* filePath, unsigned char*& content, unsigned long* filesize); | |
friend void CheckErrorCode(cl_int status, cl_program& program, cl_device_id& devices, const std::string& message); | |
friend void GetMessageError(cl_int status, cl_program program, cl_device_id device); | |
public: | |
cl_int status; | |
cl_platform_id platform;// = nullptr; | |
cl_device_id* devices;// = nullptr; | |
cl_context context; | |
cl_command_queue commandQueue; | |
cl_program program; | |
size_t sourceSize[1]={0}; | |
const char* sourceCode;// = nullptr; | |
std::string strSource; | |
const char* filePath; | |
unsigned char* fileBytes; | |
//="kernelApplication.cl"; | |
inline void SetFilePath(const char* path) { filePath = path; } | |
inline const char* GetFilePath() { return filePath; } | |
void GetPlatform(cl_platform_id& platform); | |
void GetDeviceIDs(cl_device_id*& devices, const cl_platform_id& platform); | |
void GetContext(cl_context& context, const cl_platform_id& platform, cl_device_id*& devices); | |
void GetCommandQueue(cl_command_queue& commandQueue, const cl_context& context, cl_device_id*& devices); | |
template<size_t size> | |
void CreateProgramWithSource(const char*& filePath, std::string& SourceStr, size_t(&sourceSize)[size], cl_context& context, cl_program& program); | |
void BuildProgram(cl_program& program, const cl_uint& deviceCount, cl_device_id*& devices); | |
int ParseFile(std::string& content, const std::string& filename); | |
Program() : platform(nullptr), commandQueue(NULL), program(NULL), context(NULL), devices(nullptr), sourceCode(nullptr), filePath("kernelApplication.cl"),status(0) | |
{ | |
} | |
private: | |
}; | |
#endif // !APPLICATIONCL_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment