Skip to content

Commit

Permalink
fix OpenCL compatibility
Browse files Browse the repository at this point in the history
- enforce that only host side OpenCl 1.2 functions are used if the miner is compiled with `XMR-STAK_COMPILE=generic`
- update documentation
- add CMake option `XMR-STAK_COMPILE` to windows
  • Loading branch information
psychocrypt committed Nov 18, 2017
1 parent f50fa7d commit 7e8475a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")
set(XMR-STAK_CURRENCY "all" CACHE STRING "select miner currency")
set_property(CACHE XMR-STAK_CURRENCY PROPERTY STRINGS "all;monero;aeon")

if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(XMR-STAK_COMPILE "native" CACHE STRING "select CPU compute architecture")
set_property(CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic")
if("${XMR-STAK_COMPILE}" STREQUAL "native")

set(XMR-STAK_COMPILE "native" CACHE STRING "select CPU compute architecture")
set_property(CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic")
if("${XMR-STAK_COMPILE}" STREQUAL "native")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "-march=native -mtune=native ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-march=native -mtune=native ${CMAKE_C_FLAGS}")
elseif(NOT "${XMR-STAK_COMPILE}" STREQUAL "generic")
message(FATAL_ERROR "XMR-STAK_COMPILE is set to an unknown value '${XMR-STAK_COMPILE}'")
endif()
elseif("${XMR-STAK_COMPILE}" STREQUAL "generic")
add_definitions("-DCONF_ENFORCE_OpenCL_1_2=1")
else()
message(FATAL_ERROR "XMR-STAK_COMPILE is set to an unknown value '${XMR-STAK_COMPILE}'")
endif()

if("${XMR-STAK_CURRENCY}" STREQUAL "all")
Expand Down
4 changes: 1 addition & 3 deletions doc/compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ After the configuration you need to compile the miner, follow the guide for your
- you can find the binary and the `config.txt` file after `make install` in `$HOME/xmr-stak-cpu/bin`
- `CMAKE_LINK_STATIC` link libgcc and libstdc++ libraries static (default OFF)
- disable with `cmake .. -DCMAKE_LINK_STATIC=ON`
- if you use static compile to run the miner on another system set `-DXMR-STAK_COMPILE=generic` (only available for LINUX, BSD and MacOSX)
- if you use static compile to run the miner on another system set `-DXMR-STAK_COMPILE=generic`
- `CMAKE_BUILD_TYPE` set the build type
- valid options: `Release` or `Debug`
- you should always keep `Release` for your productive miners
Expand All @@ -46,8 +46,6 @@ After the configuration you need to compile the miner, follow the guide for your
- `OpenSSL_ENABLE` allow to disable/enable the dependency *OpenSSL*
- it is not possible to connect to a *https* secured pool if option is disabled: `cmake .. -DOpenSSL_ENABLE=OFF`
- `XMR-STAK_CURRENCY` - compile for Monero(XMR) or Aeon(AEON) usage only e.g. `cmake .. -DXMR-STAK_CURRENCY=monero`

### only available for LINUX, BSD and MacOSX
- `XMR-STAK_COMPILE` select the CPU compute architecture (default: native)
- native means the miner binary can be used only on the system where it is compiled but will archive the highest hash rate
- use `cmake .. -DXMR-STAK_COMPILE=generic` to run the miner on all CPU's with sse2
Expand Down
4 changes: 2 additions & 2 deletions xmrstak/backend/amd/amd_gpu/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const char* err_to_str(cl_int ret)
return "CL_INVALID_LINKER_OPTIONS";
case CL_INVALID_DEVICE_PARTITION_COUNT:
return "CL_INVALID_DEVICE_PARTITION_COUNT";
#ifdef CL_VERSION_2_0
#if defined(CL_VERSION_2_0) && !defined(CONF_ENFORCE_OpenCL_1_2)
case CL_INVALID_PIPE_SIZE:
return "CL_INVALID_PIPE_SIZE";
case CL_INVALID_DEVICE_QUEUE:
Expand Down Expand Up @@ -227,7 +227,7 @@ size_t InitOpenCLGpu(cl_context opencl_ctx, GpuContext* ctx, const char* source_
}

printer::inst()->print_msg(L1,"Device %lu work size %lu / %lu.", ctx->deviceIdx, ctx->workSize, MaximumWorkSize);
#ifdef CL_VERSION_2_0
#if defined(CL_VERSION_2_0) && !defined(CONF_ENFORCE_OpenCL_1_2)
const cl_queue_properties CommandQueueProperties[] = { 0, 0, 0 };
ctx->CommandQueues = clCreateCommandQueueWithProperties(opencl_ctx, ctx->DeviceID, CommandQueueProperties, &ret);
#else
Expand Down

0 comments on commit 7e8475a

Please sign in to comment.