Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安装不了 #299

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# v2.14.5
- Fixed compatibility with recent AMD drivers (19.7.2), thanks [@psychocrypt](https://github.com/psychocrypt).
# v0.1 FORK for arm based android devices
- removed some vendor specific opencl codelines
- build is passing under termux, but opencl in not working yet
- edited readme

# v2.14.4
- [#249](https://github.com/xmrig/xmrig-amd/pull/249) Added workaround for some drivers memory leak.
Expand Down
53 changes: 49 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@ option(WITH_CN_PICO "CryptoNight-Pico support" ON)
option(WITH_CN_GPU "CryptoNight-GPU support" ON)
option(WITH_HTTPD "HTTP REST API" ON)
option(WITH_TLS "Enable OpenSSL support" ON)
option(WITH_ASM "Enable ASM PoW implementations" ON)
option(WITH_ASM "Enable ASM PoW implementations" OFF)
option(STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
option(BUILD_STATIC "Build static binary" OFF)
option(ARM_TARGET "Force use specific ARM target 8 or 7" 0)
option(XMRIG_ARM "Build for ARM platforms" ON)

option(ARM_TARGET "Force use specific ARM target 8 or 7" 8)

option(WITH_DEBUG_LOG "Enable debug log output, network, etc" OFF)
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
option(WITH_EMBEDDED_CONFIG "Enable internal embedded JSON config" OFF)




include (CheckIncludeFile)
include (cmake/cpu.cmake)






set(HEADERS
src/amd/cryptonight.h
src/amd/GpuContext.h
Expand Down Expand Up @@ -238,6 +247,40 @@ include(cmake/flags.cmake)
add_definitions(/DCL_TARGET_OPENCL_VERSION=200)
add_definitions(/DCL_USE_DEPRECATED_OPENCL_1_2_APIS)

###############################################################################
# Find OpenCL
###############################################################################

option(OpenCL_ENABLE "Enable or disable OpenCL spport (AMD GPU support)" ON)
if(OpenCL_ENABLE)
# try to find AMD OpenCL before NVIDIA OpenCL
find_path(OpenCL_INCLUDE_DIR
NAMES
cl.h
NO_DEFAULT_PATH
PATHS
${CMAKE_SOURCE_DIR}/CL)

find_library(OpenCL_LIBRARY
NAMES
libOpenCL.so
NO_DEFAULT_PATH
PATHS
/system/vendor/lib64)
# find package will use the previews searched path variables
# find_package(OpenCL)
# if(OpenCL_FOUND)
# list(APPEND BACKEND_TYPES "amd")
# include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
# #set(LIBS ${LIBS} ${OpenCL_LIBRARY})
# link_directories(${OpenCL_LIBRARY})
# else()
# message(FATAL_ERROR "OpenCL NOT found: use `-DOpenCL_ENABLE=OFF` to build without OpenCL support for AMD gpu's")
# endif()
else()
add_definitions("-DCONF_NO_OPENCL")
endif()


include(cmake/OpenSSL.cmake)
include(cmake/cn-gpu.cmake)
Expand Down Expand Up @@ -300,7 +343,7 @@ endif()

include_directories(src)
include_directories(src/3rdparty)
include_directories(${UV_INCLUDE_DIR})


if (BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS " -static")
Expand All @@ -314,5 +357,7 @@ if (WITH_INTERLEAVE_DEBUG_LOG)
add_definitions(/DAPP_INTERLEAVE_DEBUG)
endif()



add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${CN_GPU_SOURCES} ${XMRIG_ASM_SOURCES})
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${LIBS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${OpenCL_LIBRARY} ${EXTRA_LIBS} ${LIBS})
44 changes: 18 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
# XMRig AMD
# xmrig-termux-opencl (NON WORKING BETA)

[![Github All Releases](https://img.shields.io/github/downloads/xmrig/xmrig-amd/total.svg)](https://github.com/xmrig/xmrig-amd/releases)
[![GitHub release](https://img.shields.io/github/release/xmrig/xmrig-amd/all.svg)](https://github.com/xmrig/xmrig-amd/releases)
[![GitHub Release Date](https://img.shields.io/github/release-date-pre/xmrig/xmrig-amd.svg)](https://github.com/xmrig/xmrig-amd/releases)
[![GitHub license](https://img.shields.io/github/license/xmrig/xmrig-amd.svg)](https://github.com/xmrig/xmrig-amd/blob/master/LICENSE)
[![GitHub stars](https://img.shields.io/github/stars/xmrig/xmrig-amd.svg)](https://github.com/xmrig/xmrig-amd/stargazers)
[![GitHub forks](https://img.shields.io/github/forks/xmrig/xmrig-amd.svg)](https://github.com/xmrig/xmrig-amd/network)

XMRig is high performance Monero (XMR) OpenCL miner, with the official full Windows support.
xmrig-termux-opencl is android phone arm based opencl cryptonight miner based on xmrig.

GPU mining part based on [Wolf9466](https://github.com/OhGodAPet) and [psychocrypt](https://github.com/psychocrypt) code.

* This is the AMD (OpenCL) GPU mining version, there is also a [CPU version](https://github.com/xmrig/xmrig) and [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia).
* [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases.
* There is also a [CPU version](https://github.com/xmrig/xmrig) and [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia).

:warning: Suggested values for GPU auto configuration can be not optimal or not working, you may need tweak your threads options. Please fell free open an [issue](https://github.com/xmrig/xmrig-amd/issues) if auto configuration suggest wrong values.
:warning: Suggested values for GPU auto configuration can be not optimal or not working, you may need tweak your threads options. Please feel free open an [issue](https://github.com/BenjaminWegener/xmrig-termux-opencl) if auto configuration suggests wrong values.

<img src="https://xmrig.com/assets/img/screenshots/xmrig-amd-2.8.6.png" width="795" >

#### Table of contents
* [Features](#features)
Expand All @@ -29,20 +20,27 @@ GPU mining part based on [Wolf9466](https://github.com/OhGodAPet) and [psychocry

## Features
* High performance.
* Official Windows support.
* Support for backup (failover) mining server.
* CryptoNight-Lite support for AEON.
* Automatic GPU configuration.
* Nicehash support.
* It's open source software.

## Download
* Binary releases: https://github.com/xmrig/xmrig-amd/releases
* Git tree: https://github.com/xmrig/xmrig-amd.git
* Clone with `git clone https://github.com/xmrig/xmrig-amd.git` :hammer: [Build instructions](https://github.com/xmrig/xmrig-amd/wiki/Build).

## Usage
Use [config.xmrig.com](https://config.xmrig.com/amd) to generate, edit or share configurations.
* use following instructions to use it:
* install termux from play store or aptoide
* termux-setup-storage
* pkg install cmake git libuv* openssl-dev unstable-repo -y
* pkg install libmicrohttpd-dev -y
* git clone https://github.com/xmrig/xmrig
* cd xmrig && mkdir build && cd build
* cmake ..
* make
* cp xmrig ..
* cd ..
* ./xmrig -a cryptonight/r -o stratum+tcp://cryptonightr.eu.nicehash.com:3375 -u 34yFoDVBQdrcupptL8BXSxYWsLCRj22DaE -p x --opencl-devices 0 --opencl-launch 8x8 --opencl-mem-chunk 2 --opencl-strided-index 0 --opencl-unroll 0 --nicehash --no-cache


### Command line options
```
Expand Down Expand Up @@ -94,10 +92,4 @@ Use [config.xmrig.com](https://config.xmrig.com/amd) to generate, edit or share
## Donations
Default donation 5% (5 minutes in 100 minutes) can be reduced to 1% via option `donate-level`.

* XMR: `48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD`
* BTC: `1P7ujsXeX7GxQwHNnJsRMgAdNkFZmNVqJT`

## Contacts
* [email protected]
* [reddit](https://www.reddit.com/user/XMRig/)
* [twitter](https://twitter.com/xmrig_dev)
* BTC: `34yFoDVBQdrcupptL8BXSxYWsLCRj22DaE`
36 changes: 2 additions & 34 deletions src/amd/opencl/cryptonight.cl
Original file line number Diff line number Diff line change
Expand Up @@ -1712,40 +1712,8 @@ __kernel void Groestl(__global ulong *states, __global uint *BranchBuf, __global
ulong State[8] = { 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0x0001000000000000UL };
ulong H[8], M[8];

// BUG: AMD driver 19.7.X crashs if this is written as loop
// Thx AMD for so bad software
{
((ulong8 *)M)[0] = vload8(0, states);

for (uint x = 0; x < 8; ++x) {
H[x] = M[x] ^ State[x];
}

PERM_SMALL_P(H);
PERM_SMALL_Q(M);

for (uint x = 0; x < 8; ++x) {
State[x] ^= H[x] ^ M[x];
}
}

{
((ulong8 *)M)[0] = vload8(1, states);

for (uint x = 0; x < 8; ++x) {
H[x] = M[x] ^ State[x];
}

PERM_SMALL_P(H);
PERM_SMALL_Q(M);

for (uint x = 0; x < 8; ++x) {
State[x] ^= H[x] ^ M[x];
}
}

{
((ulong8 *)M)[0] = vload8(2, states);
for (uint i = 0; i < 3; ++i) {
((ulong8 *)M)[0] = vload8(i, states);

for (uint x = 0; x < 8; ++x) {
H[x] = M[x] ^ State[x];
Expand Down
127 changes: 13 additions & 114 deletions src/common/cpu/BasicCpuInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,135 +25,34 @@
#include <string.h>
#include <thread>


#ifdef _MSC_VER
# include <intrin.h>
#else
# include <cpuid.h>
#endif

#ifndef bit_AES
# define bit_AES (1 << 25)
#endif

#ifndef bit_OSXSAVE
# define bit_OSXSAVE (1 << 27)
#endif

#ifndef bit_AVX2
# define bit_AVX2 (1 << 5)
#if __ARM_FEATURE_CRYPTO
# include <sys/auxv.h>
# include <asm/hwcap.h>
#endif


#include "common/cpu/BasicCpuInfo.h"


#define VENDOR_ID (0)
#define PROCESSOR_INFO (1)
#define CACHE_TLB_DESCRIPTOR (2)
#define EXTENDED_FEATURES (7)
#define PROCESSOR_BRAND_STRING_1 (0x80000002)
#define PROCESSOR_BRAND_STRING_2 (0x80000003)
#define PROCESSOR_BRAND_STRING_3 (0x80000004)

#define EAX_Reg (0)
#define EBX_Reg (1)
#define ECX_Reg (2)
#define EDX_Reg (3)


#ifdef _MSC_VER
static inline void cpuid(int level, int output[4]) {
__cpuid(output, level);
}
#else
static inline void cpuid(int level, int output[4]) {
int a, b, c, d;
__cpuid_count(level, 0, a, b, c, d);

output[0] = a;
output[1] = b;
output[2] = c;
output[3] = d;
}
#endif


static inline void cpu_brand_string(char* s) {
int32_t cpu_info[4] = { 0 };
cpuid(VENDOR_ID, cpu_info);

if (cpu_info[EAX_Reg] >= 4) {
for (int i = 0; i < 4; i++) {
cpuid(0x80000002 + i, cpu_info);
memcpy(s, cpu_info, sizeof(cpu_info));
s += 16;
}
}
}


static inline bool has_aes_ni()
{
int32_t cpu_info[4] = { 0 };
cpuid(PROCESSOR_INFO, cpu_info);

return (cpu_info[ECX_Reg] & bit_AES) != 0;
}


static inline bool has_avx2()
{
int32_t cpu_info[4] = { 0 };
cpuid(EXTENDED_FEATURES, cpu_info);

return (cpu_info[EBX_Reg] & bit_AVX2) != 0;
}


static inline bool has_ossave()
{
int32_t cpu_info[4] = { 0 };
cpuid(PROCESSOR_INFO, cpu_info);

return (cpu_info[ECX_Reg] & bit_OSXSAVE) != 0;
}


xmrig::BasicCpuInfo::BasicCpuInfo() :
m_assembly(ASM_NONE),
m_aes(has_aes_ni()),
m_avx2(has_avx2() && has_ossave()),
m_aes(false),
m_avx2(false),
m_brand(),
m_threads(std::thread::hardware_concurrency())
{
cpu_brand_string(m_brand);

# ifndef XMRIG_NO_ASM
if (hasAES()) {
char vendor[13] = { 0 };
int32_t data[4] = { 0 };

cpuid(0, data);

memcpy(vendor + 0, &data[1], 4);
memcpy(vendor + 4, &data[3], 4);
memcpy(vendor + 8, &data[2], 4);
# ifdef XMRIG_ARMv8
memcpy(m_brand, "ARMv8", 5);
# else
memcpy(m_brand, "ARMv7", 5);
# endif

if (memcmp(vendor, "GenuineIntel", 12) == 0) {
m_assembly = ASM_INTEL;
}
else if (memcmp(vendor, "AuthenticAMD", 12) == 0) {
m_assembly = ASM_RYZEN;
}
}
# if __ARM_FEATURE_CRYPTO
m_aes = getauxval(AT_HWCAP) & HWCAP_AES;
# endif
}


size_t xmrig::BasicCpuInfo::optimalThreadsCount(size_t memSize, int maxCpuUsage) const
{
const size_t count = threads() / 2;

return count < 1 ? 1 : count;
return threads();
}
16 changes: 5 additions & 11 deletions src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,8 @@ xmrig::Config::Config() : xmrig::CommonConfig(),
m_cache(true),
m_shouldSave(false),
m_platformIndex(0),
# if defined(__APPLE__)
m_loader("/System/Library/Frameworks/OpenCL.framework/OpenCL"),
# elif defined(_WIN32)
m_loader("OpenCL.dll"),
# else
m_loader("libOpenCL.so"),
# endif
m_vendor(xmrig::OCL_VENDOR_AMD)
m_loader("libOpenCL.so")/*,
m_vendor(xmrig::OCL_VENDOR_AMD)*/
{
}

Expand Down Expand Up @@ -93,13 +87,13 @@ bool xmrig::Config::oclInit()
{
LOG_WARN("compiling code and initializing GPUs. This will take a while...");

if (m_vendor != OCL_VENDOR_MANUAL) {
//if (m_vendor != OCL_VENDOR_MANUAL) {
m_platformIndex = OclGPU::findPlatformIdx(this);
if (m_platformIndex == -1) {
LOG_ERR("%s%s OpenCL platform NOT found.", isColors() ? "\x1B[1;31m" : "", vendorName(m_vendor));
LOG_ERR("%s%s OpenCL platform not found.", isColors() ? "\x1B[1;31m" : "", vendorName(m_vendor));
return false;
}
}
//}

if (m_platformIndex >= static_cast<int>(OclLib::getNumPlatforms())) {
LOG_ERR("%sSelected OpenCL platform index %d doesn't exist.", isColors() ? "\x1B[1;31m" : "", m_platformIndex);
Expand Down
Loading