From 9b45b6b571d92d89e443d847a6e4a858a68cd59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Jul 2015 14:20:44 +0200 Subject: [PATCH] Use external prebuilt OpenCL ICD DLL. --- CMakeLists.txt | 5 ----- cmake/FindOpenCL.cmake | 18 ++++++++++++++++++ eth/CMakeLists.txt | 5 +++-- ethminer/CMakeLists.txt | 1 + libethash-cl/CMakeLists.txt | 7 ++----- libethash-cl/ethash_cl_miner.cpp | 2 +- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7edaf8401..b926ae165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,11 +426,6 @@ if (GENERAL OR MINER) add_subdirectory(libethash) if (ETHASHCL) add_subdirectory(libethash-cl) - if (APPLE) - else() - add_subdirectory(khronos_icd) - set(OpenCL_TARGET OpenCL_ICD) - endif() endif () endif () diff --git a/cmake/FindOpenCL.cmake b/cmake/FindOpenCL.cmake index a786e2e86..fe03132b1 100644 --- a/cmake/FindOpenCL.cmake +++ b/cmake/FindOpenCL.cmake @@ -124,6 +124,24 @@ endif() set(OpenCL_LIBRARIES ${OpenCL_LIBRARY}) set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + + find_library( + OpenCL_LIBRARY_DEBUG + NAMES OpenCL_d + ) + + set(OpenCL_LIBRARIES optimized ${OpenCL_LIBRARY} debug ${OpenCL_LIBRARY_DEBUG}) + + # prepare dlls + string(REPLACE ".lib" ".dll" OpenCL_DLL ${OpenCL_LIBRARY}) + string(REPLACE "/lib/" "/bin/" OpenCL_DLL ${OpenCL_DLL}) + string(REPLACE ".lib" ".dll" OpenCL_DLL_DEBUG ${OpenCL_LIBRARY_DEBUG}) + string(REPLACE "/lib/" "/bin/" OpenCL_DLL_DEBUG ${OpenCL_DLL_DEBUG}) + set(OpenCL_DLLS optimized ${OpenCL_DLL} debug ${OpenCL_DLL_DEBUG}) + +endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args( OpenCL diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index 56c0ad710..c3fe2fc6c 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -30,7 +30,8 @@ if (JSONRPC) target_link_libraries(${EXECUTABLE} ${JSON_RPC_CPP_CLIENT_LIBRARIES}) target_link_libraries(${EXECUTABLE} ${CURL_LIBRARIES}) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) - eth_copy_dlls(${EXECUTABLE} CURL_DLLS) + eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) + eth_copy_dlls("${EXECUTABLE}" OpenCL_DLLS) endif() endif() @@ -42,7 +43,7 @@ if (JSCONSOLE) endif() #if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) -# eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) +# eth_copy_dlls("${EXECUTABLE}" MHD_DLLS OpenCL_DLLS) #endif() if (APPLE) diff --git a/ethminer/CMakeLists.txt b/ethminer/CMakeLists.txt index c321f0e5d..8b79afd72 100644 --- a/ethminer/CMakeLists.txt +++ b/ethminer/CMakeLists.txt @@ -33,6 +33,7 @@ target_link_libraries(${EXECUTABLE} ethash) if (DEFINED WIN32 AND NOT DEFINED CMAKE_COMPILER_IS_MINGW) eth_copy_dlls("${EXECUTABLE}" MHD_DLLS) + eth_copy_dlls("${EXECUTABLE}" OpenCL_DLLS) endif() if (APPLE) diff --git a/libethash-cl/CMakeLists.txt b/libethash-cl/CMakeLists.txt index b76eabfb5..7de2d6971 100644 --- a/libethash-cl/CMakeLists.txt +++ b/libethash-cl/CMakeLists.txt @@ -23,11 +23,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) -if (APPLE) - TARGET_LINK_LIBRARIES(${EXECUTABLE} ${OpenCL_LIBRARY} ethash) -else() - TARGET_LINK_LIBRARIES(${EXECUTABLE} OpenCL_ICD ethash) -endif() +target_include_directories(${EXECUTABLE} PUBLIC ${OpenCL_INCLUDE_DIR}) +target_link_libraries(${EXECUTABLE} ${OpenCL_LIBRARIES} ethash) install( TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( FILES ${HEADERS} DESTINATION include/${EXECUTABLE} ) diff --git a/libethash-cl/ethash_cl_miner.cpp b/libethash-cl/ethash_cl_miner.cpp index 15e0847a4..50fb273b6 100644 --- a/libethash-cl/ethash_cl_miner.cpp +++ b/libethash-cl/ethash_cl_miner.cpp @@ -180,7 +180,7 @@ bool ethash_cl_miner::configureGPU( // by default let's only consider the DAG of the first epoch uint64_t dagSize = ethash_get_datasize(_currentBlock); uint64_t requiredSize = dagSize + _extraGPUMemory; - return searchForAllDevices(_platformId, [&requiredSize](cl::Device const _device) -> bool + return searchForAllDevices(_platformId, [&requiredSize](cl::Device const& _device) -> bool { cl_ulong result; _device.getInfo(CL_DEVICE_GLOBAL_MEM_SIZE, &result);