项目作者: isilence

项目描述 :
OpenCL memory abstraction library for memory transfer optimization
高级语言: C
项目地址: git://github.com/isilence/delirium_cl.git
创建时间: 2016-11-01T10:05:47Z
项目社区:https://github.com/isilence/delirium_cl

开源协议:MIT License

下载


dlmCL

dlmCl is C++ host-side library for OpenCL designed to optimize CPU-GPU data transfers by utilizing features of modern hardware memory architectures.
Its API provides methods for cross-platform runtime architecture detection and dedicated memory abstraction.
dlmCl is a support library rather than a complete computing framework, therefore it have low-level primitives that should be used in conjunction with raw OpenCL API.

Prerequisites

  • C++11 compiler
  • OpenCL 1.2 SDK
  • CMake 2.6

Installation

  1. mkdir build && cd ./build
  2. cmake ../ && make

Experimental results

perfromance counters

  • Grammian matrix (computation intensive task)
    • small task size - x1.3 boost
    • large task sizes - ~x1.0
  • Element-wise array processing (data-intensive task)
    • uniform x1.7 boost

Example

  1. // OpenCL objects and kernel params
  2. size_t loc, n;
  3. cl_device_id cl_device;
  4. cl_command_queue queue;
  5. cl_kernel kernel;
  6. ...
  7. // initialize device & memory object
  8. dlmcl::Device dev(cl_device);
  9. dlmcl::Memobj mem = dlmcl::Memobj::getOptimal(dev, n, CL_MEM_READ_WRITE);
  10. // gather output data
  11. mem->switchToHost(queue);
  12. void* mem_ptr = mem->getHostMemory();
  13. ...
  14. // run kernel
  15. mem->switchToDevice(queue);
  16. cl_mem mem_dev = src->getDeviceMemory();
  17. clSetKernelArg(kernel, 0, sizeof mem_dev, &mem_dev);
  18. clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &n, loc, 0, NULL, NULL);
  19. clFinish(queue);
  20. // gather output data
  21. mem->switchToHost(queue);
  22. void* ptr = mem->getHostMemory();