Advertisement
Guest User

Hybris OpenCL

a guest
Apr 11th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.87 KB | None | 0 0
  1. *
  2.  * Copyright (c) 2013 Teemu Virolainen <teemu.virolainen@gmail.com>
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  * http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  */
  17.  
  18. #include <CL/cl.h>
  19. #include <dlfcn.h>
  20. #include <stddef.h>
  21. #include <stdlib.h>
  22.  
  23. #include <hybris/internal/binding.h>
  24. #include <hybris/internal/floating_point_abi.h>
  25.  
  26. static void *_libcl = NULL;
  27.  
  28. /*
  29. TODO: Merge the gles2 and OpenCL loaders to same place
  30. */
  31.  
  32.  
  33. #define OPENCL_IDLOAD(sym) \
  34.  __asm__ (".type " #sym ", %gnu_indirect_function"); \
  35. typeof(sym) * sym ## _dispatch (void) __asm__ (#sym);\
  36. typeof(sym) * sym ## _dispatch (void) \
  37. { \
  38.     return (void *) android_dlsym(_libcl, #sym); \
  39. }
  40.  
  41. static void  __attribute__((constructor)) _init_androidglesv2()  {
  42.     _libcl = (void *) android_dlopen("/system/lib/libOpenCL.so", RTLD_LAZY);
  43.  
  44. }
  45.  
  46.  
  47.  
  48. OPENCL_IDLOAD(clGetPlatformIDs);
  49. OPENCL_IDLOAD(clGetPlatformInfo);
  50. OPENCL_IDLOAD(clGetDeviceIDs);
  51. OPENCL_IDLOAD(clGetDeviceInfo);
  52. OPENCL_IDLOAD(clCreateContext);
  53. OPENCL_IDLOAD(clCreateContextFromType);
  54. OPENCL_IDLOAD(clRetainContext);
  55. OPENCL_IDLOAD(clReleaseContext);
  56. OPENCL_IDLOAD(clGetContextInfo);
  57. OPENCL_IDLOAD(clCreateCommandQueue);
  58. OPENCL_IDLOAD(clRetainCommandQueue);
  59. OPENCL_IDLOAD(clReleaseCommandQueue);
  60. OPENCL_IDLOAD(clGetCommandQueueInfo);
  61. OPENCL_IDLOAD(clCreateBuffer);
  62. OPENCL_IDLOAD(clCreateSubBuffer);
  63. OPENCL_IDLOAD(clCreateImage2D);
  64. OPENCL_IDLOAD(clCreateImage3D);
  65. OPENCL_IDLOAD(clRetainMemObject);
  66. OPENCL_IDLOAD(clReleaseMemObject);
  67. OPENCL_IDLOAD(clGetSupportedImageFormats);
  68. OPENCL_IDLOAD(clGetMemObjectInfo);
  69. OPENCL_IDLOAD(clGetImageInfo);
  70.  
  71. OPENCL_IDLOAD(clSetMemObjectDestructorCallback);
  72. OPENCL_IDLOAD(clCreateSampler);
  73. OPENCL_IDLOAD(clRetainSampler);
  74. OPENCL_IDLOAD(clReleaseSampler);
  75. OPENCL_IDLOAD(clGetSamplerInfo);
  76. OPENCL_IDLOAD(clCreateProgramWithSource);
  77. OPENCL_IDLOAD(clCreateProgramWithBinary);
  78. OPENCL_IDLOAD(clRetainProgram);
  79. OPENCL_IDLOAD(clReleaseProgram);
  80. OPENCL_IDLOAD(clBuildProgram);
  81. OPENCL_IDLOAD(clUnloadCompiler);
  82. OPENCL_IDLOAD(clGetProgramInfo);
  83. OPENCL_IDLOAD(clGetProgramBuildInfo);
  84. OPENCL_IDLOAD(clCreateKernel);
  85. OPENCL_IDLOAD(clCreateKernelsInProgram);
  86. OPENCL_IDLOAD(clRetainKernel);
  87. OPENCL_IDLOAD(clReleaseKernel);
  88. OPENCL_IDLOAD(clSetKernelArg);
  89. OPENCL_IDLOAD(clGetKernelInfo);
  90. OPENCL_IDLOAD(clGetKernelWorkGroupInfo);
  91. OPENCL_IDLOAD(clWaitForEvents);
  92. OPENCL_IDLOAD(clGetEventInfo);
  93. OPENCL_IDLOAD(clCreateUserEvent);
  94. OPENCL_IDLOAD(clRetainEvent);
  95. OPENCL_IDLOAD(clReleaseEvent);
  96. OPENCL_IDLOAD(clSetUserEventStatus);
  97. OPENCL_IDLOAD(clSetEventCallback);
  98. OPENCL_IDLOAD(clGetEventProfilingInfo);
  99. OPENCL_IDLOAD(clFlush);
  100. OPENCL_IDLOAD(clFinish);
  101. OPENCL_IDLOAD(clEnqueueReadBuffer);
  102. OPENCL_IDLOAD(clEnqueueReadBufferRect);
  103. OPENCL_IDLOAD(clEnqueueWriteBuffer);
  104. OPENCL_IDLOAD(clEnqueueWriteBufferRect);
  105. OPENCL_IDLOAD(clEnqueueCopyBuffer);
  106. OPENCL_IDLOAD(clEnqueueCopyBufferRect);
  107. OPENCL_IDLOAD(clEnqueueReadImage);
  108. OPENCL_IDLOAD(clEnqueueWriteImage);
  109. OPENCL_IDLOAD(clEnqueueCopyImage);
  110. OPENCL_IDLOAD(clEnqueueCopyImageToBuffer);
  111. OPENCL_IDLOAD(clEnqueueCopyBufferToImage);
  112. OPENCL_IDLOAD(clEnqueueMapBuffer);
  113. OPENCL_IDLOAD(clEnqueueMapImage);
  114. OPENCL_IDLOAD(clEnqueueUnmapMemObject);
  115. OPENCL_IDLOAD(clEnqueueNDRangeKernel);
  116. OPENCL_IDLOAD(clEnqueueTask);
  117. OPENCL_IDLOAD(clEnqueueNativeKernel);
  118. OPENCL_IDLOAD(clEnqueueMarker);
  119. OPENCL_IDLOAD(clEnqueueWaitForEvents);
  120. OPENCL_IDLOAD(clEnqueueBarrier);
  121. OPENCL_IDLOAD(clGetExtensionFunctionAddress);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement