# GpuX **Repository Path**: kinchow/gpu-x ## Basic Information - **Project Name**: GpuX - **Description**: 基于OpenCL的Gpu执行器 - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2023-02-28 - **Last Updated**: 2023-10-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GpuX #### 介绍 基于OpenCL的GPU执行器。 GpuX简化了OpenCL在GPU上的使用,仅使用简单的接口和配置即可在GPU上运行程序。 #### 安装教程 ```shell cmake -B build -DENABLE_EXAMPLE=ON # 如果需要构建例子-DENABLE_EXAMPLE=ON,否则-DENABLE_EXAMPLE=OFF cmake --build build ``` #### 使用说明 ##### GpuX ```c++ GpuX &GetInstance(); /* * 功能:获取GpuX单例的引用 * 返回值:GpuX单例的引用 */ int Create(const std::string &config); /* * 功能:配置GpuX * 参数:const std::string &config 配置json文件的路径 * 返回值:GpuX错误码 */ void Destroy(); /* * 功能:释放GpuX */ int GetClError(); /* * 功能:获取OpenCL运行时错误 * 返回值:OpenCL运行时错误 */ int Finish(); /* * 功能:阻塞直到所有在GPU的函数运行结束 * 返回值:GpuX错误码 */ Buffer *CreateBuffer(void *ptr, size_t size); /* * 功能:创建Buffer对象 * 参数:void *ptr 主机端内存的指针 * size_t size 主机端内存的大小,单位字节 * 返回值:Buffer对象 */ void DestroyBuffer(Buffer *buffer); /* * 功能:销毁Buffer对象 * 参数:Buffer *buffer Buffer对象 */ template int Run(const std::string &function, bool async, T arg, Ts... args); /* * 功能:运行函数 * 参数:const std::string &function 函数名 * bool async 是否异步执行 * T arg, Ts... args 可变参数 * 返回值:GpuX错误码 */ ``` ##### Buffer 内存对象 ```c++ cl_mem GetClMem(); /* * 功能:获取内存对应的cl_mem对象 * 返回值:内存对应的cl_mem对象 */ void *GetPointer(); /* * 功能:获取内存指针 * 返回值:内存指针 */ size_t GetSize(); /* * 功能:获取内存大小 * 返回值:内存大小 */ int Flush(); /* * 功能:刷新内存 * 返回值:GpuX错误码 */ ```