diff --git a/nheqminer/Makefile b/nheqminer/Makefile index 2e6b699..bb01935 100644 --- a/nheqminer/Makefile +++ b/nheqminer/Makefile @@ -3,7 +3,7 @@ target_name ?= nheqminer include ../Makefile.build -NHEQMINER_VERSION="0.5c" +NHEQMINER_VERSION="macos-clang" # basic CUDA check for macOS OSX_CUDA_BIN := $(shell ls -d /usr/local/cuda/bin/nvcc | tail -n 1) @@ -15,12 +15,10 @@ endif endif nheqminer_clone: - if [ ! -f "nheqminer-$(NHEQMINER_VERSION).tar.gz" ]; then curl -o nheqminer-$(NHEQMINER_VERSION).tar.gz -L https://github.com/nicehash/nheqminer/archive/$(NHEQMINER_VERSION).tar.gz; fi - if [ ! -d "nheqminer-$(NHEQMINER_VERSION)" ]; then tar xvf nheqminer-$(NHEQMINER_VERSION).tar.gz; fi + if [ ! -d "nheqminer-$(NHEQMINER_VERSION)" ]; then git clone -b $(NHEQMINER_VERSION) https://github.com/kozyilmaz/nheqminer.git nheqminer-$(NHEQMINER_VERSION); fi if [ ! -d "nheqminer" ]; then ln -sf nheqminer-$(NHEQMINER_VERSION) nheqminer; fi nheqminer_config: - $(call patchme,nheqminer-$(NHEQMINER_VERSION)) ( cd nheqminer-$(NHEQMINER_VERSION)/cpu_xenoncat/asm_mac; rm -rf equihash_avx*.elf.o equihash_avx*.o ; sh assemble.sh; ) ( mkdir -p nheqminer-cpu; cd nheqminer-cpu; \ BOOST_ROOT=${BSPROOTFS} \ @@ -72,4 +70,5 @@ nheqminer_distclean: rm -rf nheqminer-cpu rm -rf nheqminer-gpu rm -rf nheqminer-old + rm -rf nheqminer rm -rf nheqminer-$(NHEQMINER_VERSION) diff --git a/nheqminer/patches/000-nheqminer-macos-compat.patch b/nheqminer/patches/000-nheqminer-macos-compat.patch deleted file mode 100644 index adcd10d..0000000 --- a/nheqminer/patches/000-nheqminer-macos-compat.patch +++ /dev/null @@ -1,39 +0,0 @@ -diff --git a/nheqminer/crypto/common.h b/nheqminer/crypto/common.h -index 4b2b16a..70dfdba 100644 ---- a/nheqminer/crypto/common.h -+++ b/nheqminer/crypto/common.h -@@ -13,7 +13,7 @@ - #include - - //#include "sodium.h" --#ifdef WIN32 -+#if (defined(WIN32) || defined(__APPLE__)) - #include "compat/endian.h" - #else - #include -diff --git a/nheqminer/main.cpp b/nheqminer/main.cpp -index 6f7a230..7d10ff4 100644 ---- a/nheqminer/main.cpp -+++ b/nheqminer/main.cpp -@@ -37,7 +37,7 @@ namespace src = boost::log::sources; - namespace attrs = boost::log::attributes; - namespace keywords = boost::log::keywords; - --#ifdef __linux__ -+#if (defined(__linux__) || defined(__APPLE__)) - #define __cpuid(out, infoType)\ - asm("cpuid": "=a" (out[0]), "=b" (out[1]), "=c" (out[2]), "=d" (out[3]): "a" (infoType)); - #define __cpuidex(out, infoType, ecx)\ -diff --git a/nheqminer/serialize.h b/nheqminer/serialize.h -index ecb6cf1..77ccae4 100644 ---- a/nheqminer/serialize.h -+++ b/nheqminer/serialize.h -@@ -6,7 +6,7 @@ - #ifndef BITCOIN_SERIALIZE_H - #define BITCOIN_SERIALIZE_H - --#ifdef WIN32 -+#if (defined(WIN32) || defined(__APPLE__)) - #include "compat/endian.h" - #else - #include diff --git a/nheqminer/patches/001-nheqminer-macos-equihash.patch b/nheqminer/patches/001-nheqminer-macos-equihash.patch deleted file mode 100644 index 8fd7fcc..0000000 --- a/nheqminer/patches/001-nheqminer-macos-equihash.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f906675..1bcd76b 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -184,9 +184,17 @@ if (USE_CPU_TROMP) - endif() - if (USE_CPU_XENONCAT) - add_library ( xenoncat_avx1 SHARED IMPORTED GLOBAL ) -- set_target_properties ( xenoncat_avx1 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_linux/equihash_avx1.o" ) -+ if (APPLE) -+ set_target_properties ( xenoncat_avx1 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_mac/equihash_avx1.o" ) -+ else() -+ set_target_properties ( xenoncat_avx1 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_linux/equihash_avx1.o" ) -+ endif(APPLE) - add_library ( xenoncat_avx2 SHARED IMPORTED GLOBAL ) -- set_target_properties ( xenoncat_avx2 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_linux/equihash_avx2.o" ) -+ if (APPLE) -+ set_target_properties ( xenoncat_avx2 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_mac/equihash_avx2.o" ) -+ else() -+ set_target_properties ( xenoncat_avx2 PROPERTIES IMPORTED_LOCATION "../nheqminer/cpu_xenoncat/asm_linux/equihash_avx2.o" ) -+ endif(APPLE) - target_link_libraries(${PROJECT_NAME} cpu_xenoncat xenoncat_avx1 xenoncat_avx2) - endif() - if (USE_CUDA_TROMP) -diff --git a/cpu_xenoncat/asm_mac/assemble.sh b/cpu_xenoncat/asm_mac/assemble.sh -new file mode 100644 -index 0000000..35fe998 ---- /dev/null -+++ b/cpu_xenoncat/asm_mac/assemble.sh -@@ -0,0 +1,4 @@ -+fasm -m 1280000 ../asm_linux/equihash_avx1.asm equihash_avx1.elf.o -+fasm -m 1280000 ../asm_linux/equihash_avx2.asm equihash_avx2.elf.o -+objconv -fmacho64 -nu equihash_avx1.elf.o equihash_avx1.o -+objconv -fmacho64 -nu equihash_avx2.elf.o equihash_avx2.o diff --git a/nheqminer/patches/002-nheqminer-macos-cflags.patch b/nheqminer/patches/002-nheqminer-macos-cflags.patch deleted file mode 100644 index 64e39f1..0000000 --- a/nheqminer/patches/002-nheqminer-macos-cflags.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f906675..e3ab61b 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -45,6 +45,13 @@ if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse2") - # optimizations - add_definitions(-O2) -+else() -+ # apple -+ if(APPLE) -+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64 -msse2") -+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse2") -+ add_definitions(-O2) -+ endif() - endif() - - # Common diff --git a/nheqminer/patches/004-nheqminer-macos-serialize.patch b/nheqminer/patches/004-nheqminer-macos-serialize.patch deleted file mode 100644 index ef46185..0000000 --- a/nheqminer/patches/004-nheqminer-macos-serialize.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/nheqminer/serialize.h b/nheqminer/serialize.h -index ecb6cf1..1f4bfda 100644 ---- a/nheqminer/serialize.h -+++ b/nheqminer/serialize.h -@@ -652,9 +652,14 @@ void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVers - template - void Serialize_impl(Stream& os, const std::vector& v, int nType, int nVersion, const V&) - { -+#if defined(__APPLE__) -+ #warning "HACK: 'error: call to 'Serialize' is ambiguous'" -+ assert(0); -+#else - WriteCompactSize(os, v.size()); - for (typename std::vector::const_iterator vi = v.begin(); vi != v.end(); ++vi) - ::Serialize(os, (*vi), nType, nVersion); -+#endif - } - - template diff --git a/nheqminer/patches/005-nheqminer-macos-barrier.patch b/nheqminer/patches/005-nheqminer-macos-barrier.patch deleted file mode 100644 index abfdbc9..0000000 --- a/nheqminer/patches/005-nheqminer-macos-barrier.patch +++ /dev/null @@ -1,76 +0,0 @@ -diff --git a/cpu_tromp/osx_barrier.h b/cpu_tromp/osx_barrier.h -new file mode 100644 -index 0000000..da05b35 ---- /dev/null -+++ b/cpu_tromp/osx_barrier.h -@@ -0,0 +1,70 @@ -+#ifdef __APPLE__ -+ -+#ifndef PTHREAD_BARRIER_H_ -+#define PTHREAD_BARRIER_H_ -+ -+#include -+#include -+ -+typedef int pthread_barrierattr_t; -+#define PTHREAD_BARRIER_SERIAL_THREAD 1 -+ -+typedef struct -+{ -+ pthread_mutex_t mutex; -+ pthread_cond_t cond; -+ int count; -+ int tripCount; -+} pthread_barrier_t; -+ -+ -+int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) -+{ -+ if(count == 0) -+ { -+ errno = EINVAL; -+ return -1; -+ } -+ if(pthread_mutex_init(&barrier->mutex, 0) < 0) -+ { -+ return -1; -+ } -+ if(pthread_cond_init(&barrier->cond, 0) < 0) -+ { -+ pthread_mutex_destroy(&barrier->mutex); -+ return -1; -+ } -+ barrier->tripCount = count; -+ barrier->count = 0; -+ -+ return 0; -+} -+ -+int pthread_barrier_destroy(pthread_barrier_t *barrier) -+{ -+ pthread_cond_destroy(&barrier->cond); -+ pthread_mutex_destroy(&barrier->mutex); -+ return 0; -+} -+ -+int pthread_barrier_wait(pthread_barrier_t *barrier) -+{ -+ pthread_mutex_lock(&barrier->mutex); -+ ++(barrier->count); -+ if(barrier->count >= barrier->tripCount) -+ { -+ barrier->count = 0; -+ pthread_cond_broadcast(&barrier->cond); -+ pthread_mutex_unlock(&barrier->mutex); -+ return PTHREAD_BARRIER_SERIAL_THREAD; -+ } -+ else -+ { -+ pthread_cond_wait(&barrier->cond, &(barrier->mutex)); -+ pthread_mutex_unlock(&barrier->mutex); -+ return 0; -+ } -+} -+ -+#endif // PTHREAD_BARRIER_H_ -+#endif // __APPLE__ diff --git a/nheqminer/patches/006-cuda-sm30-equihash.patch b/nheqminer/patches/006-cuda-sm30-equihash.patch deleted file mode 100644 index 65a063c..0000000 --- a/nheqminer/patches/006-cuda-sm30-equihash.patch +++ /dev/null @@ -1,42 +0,0 @@ -diff --git a/cuda_djezo/equi_miner.cu b/cuda_djezo/equi_miner.cu -index 6ef9f45..cebaf52 100644 ---- a/cuda_djezo/equi_miner.cu -+++ b/cuda_djezo/equi_miner.cu -@@ -200,10 +200,25 @@ __device__ __forceinline__ uint4 operator^ (uint4 a, uint4 b) - __device__ __forceinline__ uint2 ROR2(const uint2 a, const int offset) - { - uint2 result; -+#if __CUDA_ARCH__ > 300 - { - asm("shf.r.wrap.b32 %0, %1, %2, %3;" : "=r"(result.x) : "r"(a.y), "r"(a.x), "r"(offset)); - asm("shf.r.wrap.b32 %0, %1, %2, %3;" : "=r"(result.y) : "r"(a.x), "r"(a.y), "r"(offset)); - } -+#else -+ if (!offset) -+ result = a; -+ else if (offset < 32) { -+ result.y = ((a.y >> offset) | (a.x << (32 - offset))); -+ result.x = ((a.x >> offset) | (a.y << (32 - offset))); -+ } else if (offset == 32) { -+ result.y = a.x; -+ result.x = a.y; -+ } else { -+ result.y = ((a.x >> (offset - 32)) | (a.y << (64 - offset))); -+ result.x = ((a.y >> (offset - 32)) | (a.x << (64 - offset))); -+ } -+#endif - return result; - } - -@@ -308,7 +323,11 @@ __global__ void digit_first(equi* eq, u32 nonce) - u32* hash_h32 = (u32*)hash_h; - - if (threadIdx.x < 16) -+#if __CUDA_ARCH__ > 300 - hash_h32[threadIdx.x] = __ldca(&eq->blake_h32[threadIdx.x]); -+#else -+ hash_h32[threadIdx.x] = eq->blake_h32[threadIdx.x]; -+#endif - - __syncthreads(); - diff --git a/nheqminer/patches/007-cuda-sm30-support.patch b/nheqminer/patches/007-cuda-sm30-support.patch deleted file mode 100644 index 64ef295..0000000 --- a/nheqminer/patches/007-cuda-sm30-support.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/cuda_djezo/cuda_djezo.cpp b/cuda_djezo/cuda_djezo.cpp -index 30d672e..b2b2363 100644 ---- a/cuda_djezo/cuda_djezo.cpp -+++ b/cuda_djezo/cuda_djezo.cpp -@@ -24,9 +24,9 @@ cuda_djezo::cuda_djezo(int platf_id, int dev_id) - major = atoi(m_version.substr(0, n).c_str()); - minor = atoi(m_version.substr(n + 1, m_version.length() - n - 1).c_str()); - -- if (major < 5) -+ if (major < 3) - { -- throw std::runtime_error("Only CUDA devices with SM 5.0 and higher are supported."); -+ throw std::runtime_error("Only CUDA devices with SM 3.0 and higher are supported."); - } - else if (major == 5 && minor == 0) - { diff --git a/nheqminer/patches/008-bitcoingold-support.patch b/nheqminer/patches/008-bitcoingold-support.patch deleted file mode 100644 index 799da2a..0000000 --- a/nheqminer/patches/008-bitcoingold-support.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/nheqminer/libstratum/ZcashStratum.cpp b/nheqminer/libstratum/ZcashStratum.cpp -index 7eac719..5bef4da 100644 ---- a/nheqminer/libstratum/ZcashStratum.cpp -+++ b/nheqminer/libstratum/ZcashStratum.cpp -@@ -490,7 +490,7 @@ ZcashJob* ZcashMiner::parseJob(const Array& params) - // TODO: On a LE host shouldn't this be le32toh? - ret->header.nVersion = be32toh(version); - -- if (ret->header.nVersion == 4) { -+ if (ret->header.nVersion == 4 || ret->header.nVersion == 0x20000000) { - if (params.size() < 8) { - throw std::logic_error("Invalid job params"); - }