Skip to content

Commit

Permalink
Merge pull request ethereum-mining#2032 from ianzur/sys-openCL-config…
Browse files Browse the repository at this point in the history
…-option

ENH: config option to use system OpenCL (for ROCm users)
  • Loading branch information
jean-m-cyr authored Sep 11, 2020
2 parents a355fea + 1536abb commit c118e83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ option(ETHDBUS "Build with D-Bus support" OFF)
option(APICORE "Build with API Server support" ON)
option(BINKERN "Install AMD binary kernels" ON)
option(DEVBUILD "Log developer metrics" OFF)
option(USE_SYS_OPENCL "Build with system OpenCL" OFF)

# propagates CMake configuration options to the compiler
function(configureProject)
Expand All @@ -55,6 +56,9 @@ function(configureProject)
if (DEVBUILD)
add_definitions(-DDEV_BUILD)
endif()
if (USE_SYS_OPENCL)
add_definitions(-DUSE_SYS_OPENCL)
endif()
endfunction()

hunter_add_package(Boost COMPONENTS system filesystem thread)
Expand All @@ -68,6 +72,10 @@ find_package(ethash CONFIG REQUIRED)

configureProject()

if(APPLE)
set(USE_SYS_OPENCL ON)
endif()

message("----------------------------------------------------------------------------")
message("-- CMake ${CMAKE_VERSION}")
message("-- Build ${CMAKE_BUILD_TYPE} / ${CMAKE_SYSTEM_NAME}")
Expand All @@ -79,6 +87,7 @@ message("-- ETHDBUS Build D-Bus components ${ETHD
message("-- APICORE Build API Server components ${APICORE}")
message("-- BINKERN Install AMD binary kernels ${BINKERN}")
message("-- DEVBUILD Build with dev logging ${DEVBUILD}")
message("-- USE_SYS_OPENCL Build with system OpenCL ${USE_SYS_OPENCL}")
message("----------------------------------------------------------------------------")
message("")

Expand All @@ -87,7 +96,6 @@ if(UNIX AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
endif()


cable_add_buildinfo_library(PROJECT_NAME ${PROJECT_NAME})

add_subdirectory(libdevcore)
Expand Down
3 changes: 3 additions & 0 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ you have to install the OpenGL libraries. E.g. on Ubuntu run:
sudo apt-get install mesa-common-dev
```

If you want to use locally installed [ROCm-OpenCL](https://rocmdocs.amd.com/en/latest/) package, use build flag `-DUSE_SYS_OPENCL=ON` with cmake config.

### macOS

1. GCC version >= TBF
Expand Down Expand Up @@ -143,6 +145,7 @@ cmake .. -DETHASHCUDA=ON -DETHASHCL=OFF
* `-DAPICORE=ON` - enable API Server, `ON` by default.
* `-DBINKERN=ON` - install AMD binary kernels, `ON` by default.
* `-DETHDBUS=ON` - enable D-Bus support, `OFF` by default.
* `-DUSE_SYS_OPENCL=ON` - Use system OpenCL, `OFF` by default, unless on macOS. Specify to use local **ROCm-OpenCL** package.
## Disable Hunter
Expand Down
4 changes: 2 additions & 2 deletions libethash-cl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ set(SOURCES
${CMAKE_CURRENT_BINARY_DIR}/ethash.h
)

if(APPLE)
# On macOS use system OpenCL library.
if(USE_SYS_OPENCL)
# On macOS or using ROCm-OpenCL, use system OpenCL library.
find_package(OpenCL REQUIRED)
else()
hunter_add_package(OpenCL)
Expand Down

0 comments on commit c118e83

Please sign in to comment.