findOpenCL.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. function findOpenCL_clew()
  2. return true;
  3. end
  4. function findOpenCL_Apple()
  5. -- if os.is("macosx") then
  6. -- return true
  7. -- else
  8. return false
  9. -- end
  10. end
  11. function findOpenCL_AMD()
  12. -- local amdopenclpath = os.getenv("AMDAPPSDKROOT")
  13. -- if (amdopenclpath) then
  14. -- return true
  15. -- end
  16. return false
  17. end
  18. function findOpenCL_NVIDIA()
  19. -- local nvidiaopenclpath = os.getenv("CUDA_PATH")
  20. -- if (nvidiaopenclpath) then
  21. -- return true
  22. -- end
  23. return false
  24. end
  25. function findOpenCL_Intel()
  26. -- if os.is("Windows") then
  27. -- local intelopenclpath = os.getenv("INTELOCLSDKROOT")
  28. -- if (intelopenclpath) then
  29. -- return true
  30. -- end
  31. -- end
  32. -- if os.is("Linux") then
  33. -- local intelsdk = io.open("/usr/include/CL/opencl.h","r")
  34. -- if (intelsdk) then
  35. -- return true;
  36. -- end
  37. -- end
  38. return false
  39. end
  40. function initOpenCL_clew()
  41. configuration{}
  42. includedirs {
  43. projectRootDir .. "src/clew"
  44. }
  45. defines {"B3_USE_CLEW"}
  46. files {
  47. projectRootDir .. "src/clew/clew.c",
  48. projectRootDir .. "src/clew/clew.h"
  49. }
  50. if os.is("Linux") then
  51. links {"dl"}
  52. end
  53. end
  54. function initOpenCL_Apple()
  55. configuration{}
  56. includedirs {
  57. "/System/Library/Frameworks/OpenCL.framework"
  58. }
  59. libdirs "/System/Library/Frameworks/OpenCL.framework"
  60. links
  61. {
  62. "OpenCL.framework"
  63. }
  64. end
  65. function initOpenCL_AMD()
  66. configuration {}
  67. local amdopenclpath = os.getenv("AMDAPPSDKROOT")
  68. if (amdopenclpath) then
  69. defines { "ADL_ENABLE_CL" , "CL_PLATFORM_AMD"}
  70. includedirs {
  71. "$(AMDAPPSDKROOT)/include"
  72. }
  73. configuration "x32"
  74. libdirs {"$(AMDAPPSDKROOT)/lib/x86"}
  75. configuration "x64"
  76. libdirs {"$(AMDAPPSDKROOT)/lib/x86_64"}
  77. configuration {}
  78. links {"OpenCL"}
  79. return true
  80. end
  81. return false
  82. end
  83. function initOpenCL_NVIDIA()
  84. configuration {}
  85. local nvidiaopenclpath = os.getenv("CUDA_PATH")
  86. if (nvidiaopenclpath) then
  87. defines { "ADL_ENABLE_CL" , "CL_PLATFORM_NVIDIA"}
  88. includedirs {
  89. "$(CUDA_PATH)/include"
  90. }
  91. configuration "x32"
  92. libdirs {"$(CUDA_PATH)/lib/Win32"}
  93. configuration "x64"
  94. libdirs {"$(CUDA_PATH)/lib/x64"}
  95. configuration {}
  96. links {"OpenCL"}
  97. return true
  98. end
  99. return false
  100. end
  101. function initOpenCL_Intel()
  102. configuration {}
  103. if os.is("Windows") then
  104. local intelopenclpath = os.getenv("INTELOCLSDKROOT")
  105. if (intelopenclpath) then
  106. defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
  107. includedirs {
  108. "$(INTELOCLSDKROOT)/include"
  109. }
  110. configuration "x32"
  111. libdirs {"$(INTELOCLSDKROOT)/lib/x86"}
  112. configuration "x64"
  113. libdirs {"$(INTELOCLSDKROOT)/lib/x64"}
  114. configuration {}
  115. links {"OpenCL"}
  116. return true
  117. end
  118. end
  119. if os.is("Linux") then
  120. defines { "ADL_ENABLE_CL" , "CL_PLATFORM_INTEL"}
  121. configuration {}
  122. links {"OpenCL"}
  123. end
  124. return false
  125. end
  126. function findOpenCL (vendor )
  127. if vendor=="clew" then
  128. return findOpenCL_clew()
  129. end
  130. if vendor=="AMD" then
  131. return findOpenCL_AMD()
  132. end
  133. if vendor=="NVIDIA" then
  134. return findOpenCL_NVIDIA()
  135. end
  136. if vendor=="Intel" then
  137. return findOpenCL_Intel()
  138. end
  139. if vendor=="Apple" then
  140. return findOpenCL_Apple()
  141. end
  142. return false
  143. end
  144. function initOpenCL ( vendor )
  145. if vendor=="clew" then
  146. initOpenCL_clew()
  147. end
  148. if vendor=="AMD" then
  149. initOpenCL_AMD()
  150. end
  151. if vendor=="NVIDIA" then
  152. return initOpenCL_NVIDIA()
  153. end
  154. if vendor=="Intel" then
  155. initOpenCL_Intel()
  156. end
  157. if vendor=="Apple" then
  158. return initOpenCL_Apple()
  159. end
  160. end