├── .appveyor.yml
├── .clang-format
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── compile_bug_report.md
│ ├── execution_bug_report.md
│ ├── feature_request.md
│ └── tuning_help.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .travis.yml
├── CI
└── checkPRBranch
├── CMakeLists.txt
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── README.md
├── THIRD-PARTY-LICENSES
├── doc
├── FAQ.md
├── README.md
├── _img
│ ├── 2ragerx-btn.png
│ ├── 2xmr-stak-btn.png
│ ├── YT.png
│ ├── cpu.png
│ ├── faq-green.png
│ ├── faq.png
│ ├── features-xmr-stak.png
│ ├── features.png
│ ├── fee.png
│ ├── fine-tuning-green.png
│ ├── fine-tuning.png
│ ├── gpu.png
│ ├── header.png
│ ├── how-to-compile-green.png
│ ├── how-to-compile.png
│ ├── html_reports.png
│ ├── interleave.png
│ ├── menu-donations-green.png
│ ├── menu-donations.png
│ ├── menu-features-green.png
│ ├── menu-features.png
│ ├── menu-get-miner-green.png
│ ├── menu-get-miner.png
│ ├── menu-support-green.png
│ ├── menu-support.png
│ ├── menu-supported-coins-green.png
│ ├── menu-supported-coins.png
│ ├── ragerx-btn.png
│ ├── ragerx.png
│ ├── rx.png
│ ├── split.png
│ ├── stak-yt-cover.jpg
│ ├── troubleshooting-green.png
│ ├── troubleshooting.png
│ ├── usage-green.png
│ ├── usage.png
│ ├── xmr-stak-btn-active.png
│ ├── xmr-stak-btn.png
│ ├── xmr-stak-cpu-connection.png
│ ├── xmr-stak-cpu-hashrate.png
│ ├── xmr-stak-cpu-results.png
│ ├── xmr-stak-rx-btn-inactive.png
│ ├── xmr-stak-rx-btn.png
│ └── xmrig.png
├── compile
│ ├── compile.md
│ ├── compile_FreeBSD.md
│ ├── compile_Linux.md
│ ├── compile_Windows.md
│ └── compile_macOS.md
├── pgp_keys.md
├── troubleshooting.md
├── tuning.md
└── usage.md
├── scripts
└── build_xmr-stak_docker
│ └── build_xmr-stak_docker.sh
└── xmrstak
├── backend
├── amd
│ ├── OclCryptonightR_gen.cpp
│ ├── OclCryptonightR_gen.hpp
│ ├── amd_gpu
│ │ ├── gpu.cpp
│ │ ├── gpu.hpp
│ │ └── opencl
│ │ │ ├── blake256.cl
│ │ │ ├── cryptonight.cl
│ │ │ ├── cryptonight_gpu.cl
│ │ │ ├── cryptonight_r.rtcl
│ │ │ ├── cryptonight_r_def.rtcl
│ │ │ ├── fast_div_heavy.cl
│ │ │ ├── fast_int_math_v2.cl
│ │ │ ├── groestl256.cl
│ │ │ ├── jh.cl
│ │ │ ├── wolf-aes.cl
│ │ │ └── wolf-skein.cl
│ ├── autoAdjust.hpp
│ ├── config.tpl
│ ├── jconf.cpp
│ ├── jconf.hpp
│ ├── minethd.cpp
│ └── minethd.hpp
├── backendConnector.cpp
├── backendConnector.hpp
├── cpu
│ ├── autoAdjust.hpp
│ ├── autoAdjustHwloc.hpp
│ ├── config.tpl
│ ├── cpuType.cpp
│ ├── cpuType.hpp
│ ├── crypto
│ │ ├── CryptonightR_gen.cpp
│ │ ├── asm
│ │ │ ├── cnR
│ │ │ │ ├── CryptonightR_template.S
│ │ │ │ ├── CryptonightR_template.asm
│ │ │ │ ├── CryptonightR_template.h
│ │ │ │ ├── CryptonightR_template.inc
│ │ │ │ ├── CryptonightR_template_win.inc
│ │ │ │ ├── CryptonightWOW_template.inc
│ │ │ │ └── CryptonightWOW_template_win.inc
│ │ │ ├── cryptonight_v8_double_main_loop_sandybridge_linux.inc
│ │ │ ├── cryptonight_v8_double_main_loop_sandybridge_win64.inc
│ │ │ ├── cryptonight_v8_main_loop.S
│ │ │ ├── cryptonight_v8_main_loop.asm
│ │ │ ├── cryptonight_v8_main_loop_ivybridge_linux.inc
│ │ │ ├── cryptonight_v8_main_loop_ivybridge_win64.inc
│ │ │ ├── cryptonight_v8_main_loop_ryzen_linux.inc
│ │ │ └── cryptonight_v8_main_loop_ryzen_win64.inc
│ │ ├── c_blake256.c
│ │ ├── c_blake256.h
│ │ ├── c_groestl.c
│ │ ├── c_groestl.h
│ │ ├── c_jh.c
│ │ ├── c_jh.h
│ │ ├── c_keccak.c
│ │ ├── c_keccak.h
│ │ ├── c_skein.c
│ │ ├── c_skein.h
│ │ ├── cn_gpu.hpp
│ │ ├── cn_gpu_avx.cpp
│ │ ├── cn_gpu_ssse3.cpp
│ │ ├── cryptonight.h
│ │ ├── cryptonight_aesni.h
│ │ ├── cryptonight_common.cpp
│ │ ├── groestl_tables.h
│ │ ├── hash.h
│ │ ├── int-util.h
│ │ ├── skein_port.h
│ │ ├── soft_aes.hpp
│ │ └── variant4_random_math.h
│ ├── hwlocMemory.cpp
│ ├── hwlocMemory.hpp
│ ├── jconf.cpp
│ ├── jconf.hpp
│ ├── minethd.cpp
│ └── minethd.hpp
├── cryptonight.hpp
├── globalStates.cpp
├── globalStates.hpp
├── iBackend.hpp
├── miner_work.hpp
├── nvidia
│ ├── CudaCryptonightR_gen.cpp
│ ├── CudaCryptonightR_gen.hpp
│ ├── autoAdjust.hpp
│ ├── config.tpl
│ ├── jconf.cpp
│ ├── jconf.hpp
│ ├── minethd.cpp
│ ├── minethd.hpp
│ └── nvcc_code
│ │ ├── cryptonight.hpp
│ │ ├── cuda_aes.hpp
│ │ ├── cuda_blake.hpp
│ │ ├── cuda_core.cu
│ │ ├── cuda_cryptonight_gpu.hpp
│ │ ├── cuda_cryptonight_r.curt
│ │ ├── cuda_device.hpp
│ │ ├── cuda_extra.cu
│ │ ├── cuda_extra.hpp
│ │ ├── cuda_fast_div_heavy.hpp
│ │ ├── cuda_fast_int_math_v2.hpp
│ │ ├── cuda_groestl.hpp
│ │ ├── cuda_jh.hpp
│ │ ├── cuda_keccak.hpp
│ │ └── cuda_skein.hpp
├── plugin.hpp
└── pool_data.hpp
├── cli
├── cli-miner.cpp
└── xmr-stak.manifest
├── config.tpl
├── cpputil
├── LICENSE.txt
└── read_write_lock.h
├── donate-level.hpp
├── http
├── httpd.cpp
├── httpd.hpp
├── webdesign.cpp
└── webdesign.hpp
├── jconf.cpp
├── jconf.hpp
├── misc
├── coinDescription.hpp
├── configEditor.hpp
├── console.cpp
├── console.hpp
├── environment.cpp
├── environment.hpp
├── executor.cpp
├── executor.hpp
├── home_dir.hpp
├── jext.hpp
├── telemetry.cpp
├── telemetry.hpp
├── thdq.hpp
├── uac.cpp
├── uac.hpp
├── utility.cpp
└── utility.hpp
├── net
├── jpsock.cpp
├── jpsock.hpp
├── msgstruct.hpp
├── socket.cpp
├── socket.hpp
└── socks.hpp
├── params.hpp
├── picosha2
└── picosha2.hpp
├── pools.tpl
├── rapidjson
├── allocators.h
├── document.h
├── encodedstream.h
├── encodings.h
├── error
│ ├── en.h
│ └── error.h
├── filereadstream.h
├── filewritestream.h
├── fwd.h
├── internal
│ ├── biginteger.h
│ ├── diyfp.h
│ ├── dtoa.h
│ ├── ieee754.h
│ ├── itoa.h
│ ├── meta.h
│ ├── pow10.h
│ ├── regex.h
│ ├── stack.h
│ ├── strfunc.h
│ ├── strtod.h
│ └── swap.h
├── istreamwrapper.h
├── memorybuffer.h
├── memorystream.h
├── msinttypes
│ ├── inttypes.h
│ └── stdint.h
├── ostreamwrapper.h
├── pointer.h
├── prettywriter.h
├── rapidjson.h
├── reader.h
├── schema.h
├── stream.h
├── stringbuffer.h
└── writer.h
├── version.cpp
└── version.hpp
/.appveyor.yml:
--------------------------------------------------------------------------------
1 | # image
2 | image: Visual Studio 2015
3 |
4 | # build platform
5 | platform: x64
6 |
7 | # clone directory
8 | clone_folder: c:\xmr-stak
9 |
10 | install:
11 | - mkdir c:\xmr-stak-dep
12 | - curl -sL https://github.com/fireice-uk/xmr-stak-dep/releases/download/v1/xmr-stak-dep.zip -o xmr-stak-dep.zip
13 | - 7z x xmr-stak-dep.zip -o"c:\xmr-stak-dep" -y > nul
14 | - appveyor DownloadFile https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda_8.0.44_windows-exe -FileName cuda_8.0.44_windows.exe
15 | - cuda_8.0.44_windows.exe -s compiler_8.0 cudart_8.0 nvrtc_8.0 nvrtc_dev_8.0
16 | - set PATH=%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;%PATH%
17 | - nvcc -V
18 |
19 | build_script:
20 | - call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat"
21 | - cd c:\xmr-stak
22 | - mkdir build
23 | - cd build
24 | - set CMAKE_PREFIX_PATH=C:\xmr-stak-dep\hwloc;C:\xmr-stak-dep\libmicrohttpd;C:\xmr-stak-dep\openssl;
25 | - cmake -G "Visual Studio 14 2015 Win64" -T v140,host=x64 .. -DCUDA_ARCH=30
26 | - cmake --build . --config Release --target install
27 |
28 | test_script:
29 | - cd c:\xmr-stak\build\bin\Release
30 | - dir
31 | - copy C:\xmr-stak-dep\openssl\bin\* .
32 | - set XMRSTAK_NOWAIT=1
33 | - xmr-stak.exe --help --noUAC
34 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | IndentWidth: 4
2 | TabWidth: 4
3 | ColumnLimit: 0
4 | BreakBeforeBraces: Allman
5 | AllowShortIfStatementsOnASingleLine: false
6 | IndentCaseLabels: false
7 | SpaceBeforeParens: Never
8 | UseTab: Always
9 | AlignAfterOpenBracket: DontAlign
10 | PointerBindsToType: true
11 | BreakConstructorInitializers: AfterColon
12 | ConstructorInitializerAllOnOneLineOrOnePerLine: true
13 | ConstructorInitializerIndentWidth: 4
14 | ContinuationIndentWidth: 4
15 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | xmrstak/version.cpp export-subst
2 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/compile_bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Compile bug report
3 | about: You have an issue to compile xmr-stak.
4 |
5 | ---
6 |
7 | `...` are the placeholder for your answers. Please answer each question!
8 |
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **Which operating system do you use? **
14 |
15 | ```
16 | ...
17 | ```
18 |
19 | **To Reproduce**
20 | ```
21 | # Please post all commands and the output.
22 | ...
23 | ```
24 |
25 | **Additional information.**
26 |
27 | ```
28 | # run `cmake -LA .` in the build folder and add the output here
29 | ...
30 | ```
31 |
32 | **Feel free to add more information.**
33 | ```
34 | ...
35 | ```
36 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/execution_bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Execution bug report
3 | about: You have an issue to execute xmr-stak.
4 |
5 | ---
6 |
7 | **Most execution issues are caused by driver problems. Please use the [xmr-stak sub-reddit](https://www.reddit.com/r/XmrStak/) to ask for help instead of opening an issue here.**
8 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for xmr-stak.
4 |
5 | ---
6 |
7 | **Please explain the feature as good as possible.**
8 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/tuning_help.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Need help for optimization.
3 | about: You need help to optimize your setup.
4 |
5 | ---
6 |
7 | **Please use the [xmr-stak sub-reddit](https://www.reddit.com/r/XmrStak/) to discuss optimizations.**
8 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Please make sure your PR is against **dev** branch. Merging PRs directly into master branch would interfere with our workflow.
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | obj/
3 | build/
4 | xmr-stak-cpu.layout
5 | xmr-stak-cpu.depend
6 | config-debug.txt
7 |
8 | # netbeans project files
9 | /nbproject/
10 |
11 | # tmp files
12 | *~
13 |
14 | # merge original backup files
15 | *.orig
16 |
17 | # KDevelop files
18 | .kdev4/
19 | xmr-stak.kdev4
20 |
21 | # Idea/Clion project files
22 | cmake-build-release/
23 | cmake-build-debug/
24 | \.idea/
25 |
26 | # MacOS files
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | dist: trusty
2 |
3 | osx_image: xcode8.3
4 |
5 | sudo: false
6 |
7 | language: cpp
8 |
9 | cache:
10 | apt: true
11 | directories:
12 | - $HOME/.cache/cuda
13 |
14 | addons:
15 | apt:
16 | packages: &default_packages
17 | - cmake
18 | - libmicrohttpd-dev
19 | - libssl-dev
20 | - libhwloc-dev
21 |
22 | env:
23 | global:
24 | - CUDA_ROOT: $HOME/.cache/cuda
25 |
26 | matrix:
27 | include:
28 | - os: linux
29 | compiler: gcc
30 | addons:
31 | apt:
32 | sources:
33 | - ubuntu-toolchain-r-test
34 | packages:
35 | - *default_packages
36 | - gcc-5
37 | - g++-5
38 | env:
39 | - CMAKE_CXX_COMPILER=g++-5
40 | - CMAKE_C_COMPILER=gcc-5
41 | - XMRSTAK_CMAKE_FLAGS="-DCUDA_ARCH=30 -DOpenCL_ENABLE=OFF"
42 |
43 | - os: linux
44 | compiler: gcc
45 | addons:
46 | apt:
47 | sources:
48 | - ubuntu-toolchain-r-test
49 | packages:
50 | - *default_packages
51 | - gcc-6
52 | - g++-6
53 | env:
54 | - CMAKE_CXX_COMPILER=g++-6
55 | - CMAKE_C_COMPILER=gcc-6
56 | - XMRSTAK_CMAKE_FLAGS="-DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF"
57 |
58 | # test with disabled HWLOC, MICROHTTPD, OpenSSL and no accelerators
59 | - os: linux
60 | compiler: gcc
61 | addons:
62 | apt:
63 | sources:
64 | - ubuntu-toolchain-r-test
65 | packages:
66 | - *default_packages
67 | - gcc-6
68 | - g++-6
69 | env:
70 | - CMAKE_CXX_COMPILER=g++-6
71 | - CMAKE_C_COMPILER=gcc-6
72 | - XMRSTAK_CMAKE_FLAGS="-DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF -DHWLOC_ENABLE=OFF -DOpenSSL_ENABLE=OFF -DMICROHTTPD_ENABLE=OFF"
73 |
74 | - os: linux
75 | compiler: gcc
76 | addons:
77 | apt:
78 | sources:
79 | - ubuntu-toolchain-r-test
80 | packages:
81 | - *default_packages
82 | - gcc-7
83 | - g++-7
84 | env:
85 | - CMAKE_CXX_COMPILER=g++-7
86 | - CMAKE_C_COMPILER=gcc-7
87 | - XMRSTAK_CMAKE_FLAGS="-DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF"
88 |
89 | - os: osx
90 | compiler: gcc
91 | env:
92 | - XMRSTAK_CMAKE_FLAGS="-DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF"
93 |
94 | before_install:
95 | - . CI/checkPRBranch
96 | - if [ $TRAVIS_OS_NAME = osx ] ; then
97 | brew update;
98 | fi
99 | - export PATH=$CUDA_ROOT/bin:$PATH
100 |
101 | install:
102 |
103 | # CUDA
104 | - if [ $TRAVIS_OS_NAME != osx ]; then
105 | NVCC_FOUND=$(which nvcc >/dev/null && { echo 0; } || { echo 1; });
106 | if [ $NVCC_FOUND -ne 0 ]; then
107 | mkdir -p $CUDA_ROOT &&
108 | cd $CUDA_ROOT &&
109 | travis_retry wget https://developer.nvidia.com/compute/cuda/8.0/prod/local_installers/cuda_8.0.44_linux-run &&
110 | ls -la &&
111 | chmod u+x *-run &&
112 | ./cuda_8.0.44_linux-run --silent --toolkit --toolkitpath=$CUDA_ROOT &&
113 | rm -rf ./cuda_8.0.44_linux-run $CUDA_ROOT/{samples,jre,doc,share} &&
114 | cd -;
115 | fi
116 | fi;
117 |
118 | script:
119 | - if [ $TRAVIS_OS_NAME = osx ]; then
120 | brew install hwloc;
121 | cmake -DMICROHTTPD_ENABLE=OFF -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ${XMRSTAK_CMAKE_FLAGS} .;
122 | else
123 | cmake -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} ${XMRSTAK_CMAKE_FLAGS} .;
124 | fi;
125 | - make VERBOSE=1 install
126 | - ./bin/xmr-stak --help
127 |
--------------------------------------------------------------------------------
/CI/checkPRBranch:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 |
4 | # Disallow pull requests to `fireice-uk/xmr-stak` branch `master`
5 | #
6 | # - merging from `dev` or `release-...` located within our reposetory is allowed
7 | # - merging to `master` within a fork is allowed
8 | # - pull request to `dev` are allowed from everywhere
9 | #
10 | # See: https://docs.travis-ci.com/user/environment-variables/
11 | # https://developer.github.com/v3/pulls/#get-a-single-pull-request
12 | #
13 | #
14 | # return 0 = OK, else false
15 | #
16 |
17 | if [ "$TRAVIS" != "true" ] ; then
18 | echo "Not in travis, so I have nothing to do :)"
19 | else
20 | xmrstak_slug="fireice-uk/xmr-stak"
21 |
22 | # check only pull requests to `master`
23 | if [ "$TRAVIS_EVENT_TYPE" == "pull_request" ] && [ "$TRAVIS_BRANCH" == "master" ] ; then
24 | # allow pull requests to forks
25 | if [ "$TRAVIS_REPO_SLUG" == "$xmrstak_slug" ] ; then
26 | echo "$TRAVIS_PULL_REQUEST_BRANCH" | grep -q "^dev$"
27 | comingFromDev=$?
28 | echo "$TRAVIS_PULL_REQUEST_BRANCH" | grep -q "^release-"
29 | comingFromRelease=$?
30 | # check origin
31 | if [[ "$TRAVIS_PULL_REQUEST_SLUG" != "$xmrstak_slug" || ( $comingFromDev -ne 0 && $comingFromRelease -ne 0 ) ]] ; then
32 | # the PR came from a fork owned by the first part of the slug
33 | pr_author=$(echo "$TRAVIS_PULL_REQUEST_SLUG" | awk -F "/" '{print $1}')
34 | pr_branch=$TRAVIS_PULL_REQUEST_BRANCH
35 | echo ""
36 | echo "Pull request opened to wrong branch!"
37 | echo ""
38 | echo "Pul requests need to go to our 'dev' branch but your pull-request from '"$TRAVIS_PULL_REQUEST_SLUG"' was"
39 | echo "sent to 'master' which is only updated by our maintainers for new stable releases."
40 | echo ""
41 | echo "Please re-open your pull-request against our 'dev' branch:"
42 | echo " https://github.com/fireice-uk/xmr-stak/compare/dev...$pr_author:$pr_branch?expand=1"
43 | echo ""
44 | echo "For further information, please see:"
45 | echo " https://github.com/fireice-uk/xmr-stak/blob/dev/CONTRIBUTING.md"
46 | exit 1
47 | fi
48 | fi
49 | fi
50 | fi
51 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing to XMR-Stak
2 |
3 | :+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
4 |
5 | Please make sure your PR is against **dev** branch. Merging PRs directly into master branch would interfere with our workflow.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # Latest version of ubuntu
2 | FROM nvidia/cuda:9.0-base
3 |
4 | # Default git repository
5 | ENV GIT_REPOSITORY https://github.com/fireice-uk/xmr-stak.git
6 | ENV XMRSTAK_CMAKE_FLAGS -DXMR-STAK_COMPILE=generic -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF
7 |
8 | # Innstall packages
9 | RUN apt-get update \
10 | && set -x \
11 | && apt-get install -qq --no-install-recommends -y build-essential ca-certificates cmake cuda-core-9-0 git cuda-cudart-dev-9-0 libhwloc-dev libmicrohttpd-dev libssl-dev \
12 | && git clone $GIT_REPOSITORY \
13 | && cd /xmr-stak \
14 | && cmake ${XMRSTAK_CMAKE_FLAGS} . \
15 | && make \
16 | && cd - \
17 | && mv /xmr-stak/bin/* /usr/local/bin/ \
18 | && rm -rf /xmr-stak \
19 | && apt-get purge -y -qq build-essential cmake cuda-core-9-0 git cuda-cudart-dev-9-0 libhwloc-dev libmicrohttpd-dev libssl-dev \
20 | && apt-get clean -qq
21 |
22 | VOLUME /mnt
23 |
24 | WORKDIR /mnt
25 |
26 | ENTRYPOINT ["/usr/local/bin/xmr-stak"]
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/THIRD-PARTY-LICENSES:
--------------------------------------------------------------------------------
1 | This application bundles the following third-party software in accordance with the following licenses:
2 |
3 | -------------------------------------------------------------------------
4 |
5 | Package: Original NVidia mining code
6 | Authors: tsiv and KlausT
7 | License: GNU GPLv3
8 | Notes: Improvements are (c) of Xmr-Stak team and are covered by GNU GPLv3
9 |
10 | -------------------------------------------------------------------------
11 |
12 | Package: Original AMD mining code
13 | Authors: wolf9466
14 | License: MIT License
15 | Notes: Improvements are (c) of Xmr-Stak team and are covered by GNU GPLv3
16 |
17 | -------------------------------------------------------------------------
18 |
19 | Package: RapidJSON
20 | Authors: THL A29 Limited, a Tencent company, and Milo Yip
21 | License: MIT License and BSD License
22 |
23 | -------------------------------------------------------------------------
24 |
25 | Package: PicoSHA2
26 | Authors: okdshin
27 | License: MIT License
28 |
29 | -------------------------------------------------------------------------
30 |
31 | Package: cpputil
32 | Authors: Will Zhang
33 | Source: https://github.com/willzhang4a58/cpputil
34 | License: MIT License
35 |
36 | -------------------------------------------------------------------------
37 |
--------------------------------------------------------------------------------
/doc/FAQ.md:
--------------------------------------------------------------------------------
1 | # FAQ
2 | To improve our support we created [Xmr-Stak forum](https://www.reddit.com/r/XmrStak). Check it out if you have a problem, or you are looking for most up to date config for your card and [guides](https://www.reddit.com/r/XmrStak/wiki/index).
3 |
4 |
5 | ## Content Overview
6 | * [Virus Protection Alert](#virus-protection-alert)
7 | * [Change Currency to Mine](#change-currency-to-mine)
8 | * [How can I mine Monero](#how-can-i-mine-monero)
9 | * [Which currency must be chosen if my fork coin is not listed](#which-currency-must-be-chosen-if-my-fork-coin-is-not-listed)
10 |
11 | ### Virus Protection Alert
12 | Some virus protection software flags the miner binary as *malware*. This is a false positive — the software does not contain any malware (and since it is open source, you can verify that yourself!)
13 | If your antivirus software flags **xmr-stak**, it will likely move it to its quarantine area. You may have to whitelist **xmr-stak** in your antivirus.
14 |
15 | ### Change Currency to Mine
16 | If the miner is compiled for Monero and Aeon than you can change
17 | - the value `currency` in the config *or*
18 | - start the miner with the [command line option](usage.md) `--currency monero` or `--currency aeon7`
19 | - run `xmr-stak --help` to see all supported currencies and algorithms
20 |
21 | ### How can I mine Monero
22 | Set the value `currency` in `pools.txt` to `monero`.
23 |
24 | ### Which currency must be chosen if my fork coin is not listed
25 | If your coin you want to mine is not listed please check the documentation of the coin and try to find out if `cryptonight` or `cryptonight-lite` is the used algorithm.
26 | Select one of these generic coin algorithms.
27 |
28 |
--------------------------------------------------------------------------------
/doc/_img/2ragerx-btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/2ragerx-btn.png
--------------------------------------------------------------------------------
/doc/_img/2xmr-stak-btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/2xmr-stak-btn.png
--------------------------------------------------------------------------------
/doc/_img/YT.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/YT.png
--------------------------------------------------------------------------------
/doc/_img/cpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/cpu.png
--------------------------------------------------------------------------------
/doc/_img/faq-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/faq-green.png
--------------------------------------------------------------------------------
/doc/_img/faq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/faq.png
--------------------------------------------------------------------------------
/doc/_img/features-xmr-stak.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/features-xmr-stak.png
--------------------------------------------------------------------------------
/doc/_img/features.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/features.png
--------------------------------------------------------------------------------
/doc/_img/fee.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/fee.png
--------------------------------------------------------------------------------
/doc/_img/fine-tuning-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/fine-tuning-green.png
--------------------------------------------------------------------------------
/doc/_img/fine-tuning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/fine-tuning.png
--------------------------------------------------------------------------------
/doc/_img/gpu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/gpu.png
--------------------------------------------------------------------------------
/doc/_img/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/header.png
--------------------------------------------------------------------------------
/doc/_img/how-to-compile-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/how-to-compile-green.png
--------------------------------------------------------------------------------
/doc/_img/how-to-compile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/how-to-compile.png
--------------------------------------------------------------------------------
/doc/_img/html_reports.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/html_reports.png
--------------------------------------------------------------------------------
/doc/_img/interleave.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/interleave.png
--------------------------------------------------------------------------------
/doc/_img/menu-donations-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-donations-green.png
--------------------------------------------------------------------------------
/doc/_img/menu-donations.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-donations.png
--------------------------------------------------------------------------------
/doc/_img/menu-features-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-features-green.png
--------------------------------------------------------------------------------
/doc/_img/menu-features.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-features.png
--------------------------------------------------------------------------------
/doc/_img/menu-get-miner-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-get-miner-green.png
--------------------------------------------------------------------------------
/doc/_img/menu-get-miner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-get-miner.png
--------------------------------------------------------------------------------
/doc/_img/menu-support-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-support-green.png
--------------------------------------------------------------------------------
/doc/_img/menu-support.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-support.png
--------------------------------------------------------------------------------
/doc/_img/menu-supported-coins-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-supported-coins-green.png
--------------------------------------------------------------------------------
/doc/_img/menu-supported-coins.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/menu-supported-coins.png
--------------------------------------------------------------------------------
/doc/_img/ragerx-btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/ragerx-btn.png
--------------------------------------------------------------------------------
/doc/_img/ragerx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/ragerx.png
--------------------------------------------------------------------------------
/doc/_img/rx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/rx.png
--------------------------------------------------------------------------------
/doc/_img/split.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/split.png
--------------------------------------------------------------------------------
/doc/_img/stak-yt-cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/stak-yt-cover.jpg
--------------------------------------------------------------------------------
/doc/_img/troubleshooting-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/troubleshooting-green.png
--------------------------------------------------------------------------------
/doc/_img/troubleshooting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/troubleshooting.png
--------------------------------------------------------------------------------
/doc/_img/usage-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/usage-green.png
--------------------------------------------------------------------------------
/doc/_img/usage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/usage.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-btn-active.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-btn-active.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-btn.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-cpu-connection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-cpu-connection.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-cpu-hashrate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-cpu-hashrate.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-cpu-results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-cpu-results.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-rx-btn-inactive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-rx-btn-inactive.png
--------------------------------------------------------------------------------
/doc/_img/xmr-stak-rx-btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmr-stak-rx-btn.png
--------------------------------------------------------------------------------
/doc/_img/xmrig.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fireice-uk/xmr-stak/67cf951b15ccac79763706e392b49ebc95957c51/doc/_img/xmrig.png
--------------------------------------------------------------------------------
/doc/compile/compile_FreeBSD.md:
--------------------------------------------------------------------------------
1 | # Compile **xmr-stak** for FreeBSD
2 |
3 | ## Install Dependencies
4 |
5 | *Note: This guide is tested for FreeBSD 11.0-RELEASE*
6 |
7 | From the root shell, run the following commands:
8 |
9 | pkg install git libmicrohttpd hwloc cmake
10 |
11 | Type 'y' and hit enter to proceed with installing the packages.
12 |
13 | git clone https://github.com/fireice-uk/xmr-stak.git
14 | mkdir xmr-stak/build
15 | cd xmr-stak/build
16 | cmake ..
17 | make install
18 |
19 | Now you have the binary located at "bin/xmr-stak" and the needed shared libraries.
20 |
--------------------------------------------------------------------------------
/doc/compile/compile_macOS.md:
--------------------------------------------------------------------------------
1 | # Compile **xmr-stak** for macOS
2 |
3 | ## Dependencies
4 |
5 | Assuming you already have [Homebrew](https://brew.sh) installed, the installation of dependencies is pretty straightforward and will generate the `xmr-stak` binary in the `bin/` directory.
6 |
7 | ### For NVIDIA GPUs
8 |
9 | ```shell
10 | brew tap caskroom/drivers
11 | brew cask install nvidia-cuda
12 | brew install hwloc libmicrohttpd gcc openssl cmake
13 | cmake . -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DOpenCL_ENABLE=OFF
14 | make install
15 | ```
16 |
17 | [All available CMake options](compile.md#nvidia-build-options)
18 |
19 | ### For AMD GPUs
20 |
21 | OpenCL is bundled with Xcode, so no other depedency then the basic ones needed. Just enable OpenCL via the `-DOpenCL_ENABLE=ON` CMake option.
22 |
23 | ```shell
24 | brew install hwloc libmicrohttpd gcc openssl cmake
25 | cmake . -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=ON
26 | make install
27 | ```
28 |
29 | ### For CPU-only mining
30 |
31 | ```shell
32 | brew install hwloc libmicrohttpd gcc openssl cmake
33 | cmake . -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF
34 | make install
35 | ```
36 |
37 | [All available CMake options](compile.md#cpu-build-options)
38 |
--------------------------------------------------------------------------------
/doc/pgp_keys.md:
--------------------------------------------------------------------------------
1 | # Developer PGP Key's
2 |
3 | ## Key @fireice-uk
4 | ```
5 | -----BEGIN PGP PUBLIC KEY BLOCK-----
6 | Version: GnuPG v2
7 |
8 | mQENBFhYUmUBCAC6493W5y1MMs38ApRbI11jWUqNdFm686XLkZWGDfYImzL6pEYk
9 | RdWkyt9ziCyA6NUeWFQYniv/z10RxYKq8ulVVJaKb9qPGMU0ESfdxlFNJkU/pf28
10 | sEVBagGvGw8uFxjQONnBJ7y7iNRWMN7qSRS636wN5ryTHNsmqI4ClXPHkXkDCDUX
11 | QvhXZpG9RRM6jsE3jBGz/LJi3FyZLo/vB60OZBODJ2IA0wSR41RRiOq01OqDueva
12 | 9jPoAokNglJfn/CniQ+lqUEXj1vjAZ1D5Mn9fISzA/UPen5Z7Sipaa9aAtsDBOfP
13 | K9iPKOsWa2uTafoyXgiwEVXCCeMMUjCGaoFBABEBAAG0ImZpcmVpY2VfdWsgPGZp
14 | cmVpY2UueG1yQGdtYWlsLmNvbT6JATcEEwEIACEFAlhYUmUCGwMFCwkIBwIGFQgJ
15 | CgsCBBYCAwECHgECF4AACgkQ+yT3mn7UHDTEcQf8CMhqaZ0IOBxeBnsq5HZr2X6z
16 | E5bODp5cPs6ha1tjH3CWpk1AFeykNtXH7kPW9hcDt/e4UQtcHs+lu6YU59X7xLJQ
17 | udOkpWdmooJMXRWS/zeeon4ivT9d69jNnwubh8EJOyw8xm/se6n48BcewfHekW/6
18 | mVrbhLbF1dnuUGXzRN1WxsUZx3uJd2UvrkJhAtHtX92/qIVhT0+3PXV0bmpHURlK
19 | YKhhm8dPLV9jPX8QVRHQXCOHSMqy/KoWEe6CnT0Isbkq3JtS3K4VBVeTX9gkySRc
20 | IFxrNJdXsI9BxKv4O8yajP8DohpoGLMDKZKSO0yq0BRMgMh0cw6Lk22uyulGALkB
21 | DQRYWFJlAQgAqikfViOmIccCZKVMZfNHjnigKtQqNrbJpYZCOImql4FqbZu9F7TD
22 | 9HIXA43SPcwziWlyazSy8Pa9nCpc6PuPPO1wxAaNIc5nt+w/x2EGGTIFGjRoubmP
23 | 3i5jZzOFYsvR2W3PgVa3/ujeYYJYo1oeVeuGmmJRejs0rp1mbvBSKw1Cq6C4cI0x
24 | GTY1yXFGLIgdfYNMmiLsTy1Qwq8YStbFKeUYAMMG3128SAIaT3Eet911f5Jx4tC8
25 | 6kWUr6PX1rQ0LQJqyIsLq9U53XybUksRfJC9IEfgvgBxRBHSD8WfqEhHjhW1VsZG
26 | dcYgr7A1PIneWsCEY+5VUnqTlt2HPaKweQARAQABiQEfBBgBCAAJBQJYWFJlAhsM
27 | AAoJEPsk95p+1Bw0Pr8H/0vZ6U2zaih03jOHOvsrYxRfDXSmgudOp1VS45aHIREd
28 | 2nrJ+drleeFVyb14UQqO/6iX9GuDX2yBEHdCg2aljeP98AaMU//RiEtebE6CUWsL
29 | HPVXHIkxwBCBe0YkJINHUQqLz/5f6qLsNUp1uTH2++zhdBWvg+gErTYbx8aFMFYH
30 | 0GoOtqE5rtlAh5MTvDZm+UcDwKJCxhrLaN3R3dDoyrDNRTgHQQuX5/opJBiUnVNK
31 | d+vugnxzpMIJQP11yCZkz/KxV8zQ2QPMuZdAoh3znd/vGCJcp0rWphn4pqxA4vDp
32 | c4hC0Yg9Dha1OoE5CJCqVL+ic4vAyB1urAwBlsd/wH8=
33 | =B5I+
34 | -----END PGP PUBLIC KEY BLOCK-----
35 | ```
36 |
37 | ## Key @psychocrypt
38 | ```
39 | -----BEGIN PGP PUBLIC KEY BLOCK-----
40 | Version: GnuPG v2
41 |
42 | mQENBFoq84cBCACm4moXhW5kLRByCh7q1lZz/RP88fINfX2jsxS3QyagjsAD7yxy
43 | CZPlwF+NsZTX/jVbMTUTHDO1KEejWO4peYYeJT50BcTS7MOF+O3EVI3j/G45v5L5
44 | yI0MOgsQFVM4k5A9n0W+oULZK7ejiBSolzSG7PbwMpUjUSMEl4boUd5zFPNq/kpo
45 | OMmJR/Q17LOqvnQsbkQDUprl+qvbD5q2xEFPNKt3KmUUEOF8a1dIDkUZmXEklLFp
46 | cUjLTviscgP1+Mfyasz6cAjfaN+7IwYS+vGnFcwXx93sIq4J3wkpgpyMNdtoK1hY
47 | ALJxzk8TF7NRFU68uIqDGrROEDa5asW9L75DABEBAAG0JnBzeWNob2NyeXB0IDxw
48 | c3ljaG9jcnlwdGhwY0BnbWFpbC5jb20+iQE3BBMBCAAhBQJaKvOHAhsDBQsJCAcC
49 | BhUICQoLAgQWAgMBAh4BAheAAAoJEAUWOMCIZelDeLoH/j+nZE3E636tKvHoP2Uv
50 | 7PG1dP9F+fTHhru53iVIxR+UXubobgAYH8lOo7yBuO+JGWDf4KjyNRrRf/To1xD5
51 | udpU6BrJ8iS3MTPk0jQ1delk+7jaFLXaJbQPdOVRR7dddi32j3Vw6wPaCWhK8xt/
52 | xDIEJJ6TlSwNBiYIriLa2uB5q0DhwdWBsZqna5xhp2jihxhtEUXs4IkkIETIVs8e
53 | FIzqxNALUNWRit2Bm1Etm4KId9GV5N6eyjekYUk3zGLivsyTHbl6XhNFmQk8UzIP
54 | N5OjcJb1UFr7Q43kRvUGDZEh08l+k5P2qQ1y3g1WypcPsfSh/+XMeCe27DaLeOwZ
55 | SD25AQ0EWirzhwEIANUkGzShhAscwJt5L/huftn/TQYaBIcYtKLYyIyQsG7c3/bO
56 | aNB4t5ZkYBPrVRyqRcnaJffIvi4oq+wSnCUn++jXZbH1OrSCZhcPBsdvgHz0KV9D
57 | 71KpJ2p9cdjqO6MWM7DrKy30QNSf5eiDzhqTB4NMKLidgGIDCz7ahFZDH2vONaOn
58 | 1A8WFXMy06lFWsYTe4TjpPOG5ZFHhSNsTthYp7sUgLwvThKhXRl0nM5C9mwShw8I
59 | 9r5/gbzEvyJJx0anJLHyka2AYFtrCcK9WGx4I6PsTfj318T1bVzWfjnq9FXZ1p3c
60 | UeTYX8f92EqAs0dcvC0hrNWyhNr2D4G+YF6KAysAEQEAAYkBHwQYAQgACQUCWirz
61 | hwIbDAAKCRAFFjjAiGXpQ5CPCACCuhM8SbtnG83oQJbxWA63DdXZPTyuFGbiMRS4
62 | 9EJkx7hVu94NJEaJMFGETn+qKLjaV+QtsBK/ZtZBRbKoqBhFzbRt8NOfC26JHEx0
63 | tdrBb4Ct8SAPhEhZDZFJt3kac038E3mBeXDoDAqdoltqG8C24uk99QHJwAhjWNb9
64 | uOMTGcm/j7ieyGF87bMKCdnTDXWABTAUbeBTD+MCfyEJgeMa6G3LWSsoj2cOwj0K
65 | Nla4ixBctXWPewAyobNaN+EGJj99TMuz/3EMtxSzh//u2czenic3IUzoG1jSWwi1
66 | +5AETDxKdVzpZYolUBYZGmnsStLvyh/+n6Xt19LM1+NBos1y
67 | =JTYP
68 | -----END PGP PUBLIC KEY BLOCK-----
69 | ```
70 |
--------------------------------------------------------------------------------
/doc/usage.md:
--------------------------------------------------------------------------------
1 | # HowTo Use Xmr-Stak
2 |
3 | ## Content Overview
4 | * [Configurations](#configurations)
5 | * [Usage on Windows](#usage-on-windows)
6 | * [Usage on Linux & macOS](#usage-on-linux--macos)
7 | * [Command Line Options](#command-line-options)
8 | * [Use different backends](#use-different-backends)
9 | * [HTML and JSON API report configuraton](#html-and-json-api-report-configuraton)
10 |
11 | ## Configurations
12 |
13 | Before you started the miner the first time there are no config files available.
14 | Config files will be created at the first start.
15 | The number of files depends on the available backends.
16 | `config.txt` contains the common miner settings.
17 | `pools.txt` contains the selected mining pools and currency to mine.
18 | `amd.txt`, `cpu.txt` and `nvidia.txt` contains miner backend specific settings and can be used for further tuning ([Tuning Guide](tuning.md)).
19 |
20 | Note: If the pool is ignoring the option `rig_id` in `pools.txt` to name your worker please check the pool documentation how a worker name can be set.
21 |
22 | ## Usage on Windows
23 | 1) Double click the `xmr-stak.exe` file
24 | 2) Fill in the pool url settings, currency, username and password
25 |
26 | `set XMRSTAK_NOWAIT=1` disable the dialog `Press any key to exit.` for non UAC execution.
27 |
28 |
29 | ## Usage on Linux & macOS
30 | 1) Open a terminal within the folder with the binary
31 | 2) Start the miner with `./xmr-stak`
32 |
33 | ## Command Line Options
34 |
35 | The miner allow to overwrite some of the settings via command line options.
36 | Run `xmr-stak --help` to show all available command line options.
37 |
38 | ## Use Different Backends
39 |
40 | On linux and OSX please add `./` before the binary name `xmr-stak`.
41 |
42 | ### CPU Only:
43 | ```
44 | xmr-stak --noAMD --noNVIDIA
45 | ```
46 |
47 | ### NVIDIA/AMD Only:
48 |
49 | The miner will automatically detect if CUDA (for NVIDIA GPUs) or OpenCL (for AMD GPUs) is available.
50 |
51 | ```
52 | xmr-stak --noCPU
53 | ```
54 |
55 | ### NVIDIA via OpenCL
56 |
57 | It is possible to use the OpenCl backend which is originally created for AMD GPUs with NVIDIA GPus.
58 | Some NVIDIA GPUs can reach better performance with this backend.
59 |
60 | ```
61 | xmr-stak --openCLVendor NVIDIA --noNVIDIA
62 | ```
63 |
64 | ## Docker image usage
65 |
66 | You can run the Docker image the following way:
67 |
68 | ```
69 | docker run --rm -it -u $(id -u):$(id -g) --name fireice-uk/xmr-stak -v "$PWD":/mnt xmr-stak
70 | docker stop xmr-stak
71 | docker run --rm -it -u $(id -u):$(id -g) --name fireice-uk/xmr-stak -v "$PWD":/mnt xmr-stak --config config.txt
72 | ```
73 |
74 | Debug the docker image by getting inside:
75 |
76 | ```
77 | docker run --entrypoint=/bin/bash --rm -it -u $(id -u):$(id -g) --name fireice-uk/xmr-stak -v "$PWD":/mnt xmr-stak
78 | ```
79 |
80 | ## HTML and JSON API report configuration
81 |
82 | To configure the reports shown on the [README](../README.md) side you need to edit the httpd_port variable. Then enable wifi on your phone and navigate to [miner ip address]:[httpd_port] in your phone browser. If you want to use the data in scripts, you can get the JSON version of the data at url [miner ip address]:[httpd_port]/api.json
83 |
--------------------------------------------------------------------------------
/scripts/build_xmr-stak_docker/build_xmr-stak_docker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -uex
2 |
3 | if [[ $EUID -ne 0 ]]; then
4 | echo "This script must be run as root"
5 | exit 1
6 | fi
7 |
8 | if [ -d xmr-stak ]; then
9 | git -C xmr-stak clean -fd
10 | else
11 | git clone https://github.com/fireice-uk/xmr-stak.git
12 | fi
13 |
14 | wget -c https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
15 | chmod a+x cuda_*_linux-run
16 |
17 |
18 | ########################
19 | # Fedora 27
20 | ########################
21 | # CUDA is not going to work on Fedora 27 beacuse it only supports these distributions: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
22 | docker run --rm -it -v $PWD:/mnt fedora:27 /bin/bash -c "
23 | set -x ;
24 | dnf install -y -q cmake gcc-c++ hwloc-devel libmicrohttpd-devel libstdc++-static make openssl-devel;
25 | cd /mnt/xmr-stak ;
26 | cmake -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF . ;
27 | make ;
28 | "
29 |
30 | test -d fedora_27 || mkdir fedora_27
31 | mv xmr-stak/bin/* fedora_27
32 | git -C xmr-stak clean -fd
33 |
34 |
35 | ########################
36 | # Ubuntu (17.04)
37 | ########################
38 | docker run --rm -it -v $PWD:/mnt ubuntu:17.04 /bin/bash -c "
39 | set -x ;
40 | apt update -qq ;
41 | apt install -y -qq libmicrohttpd-dev libssl-dev cmake build-essential libhwloc-dev ;
42 | cd /mnt/xmr-stak ;
43 | /mnt/cuda_*_linux-run --silent --toolkit ;
44 | cmake -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF . ;
45 | make ;
46 | "
47 |
48 | test -d ubuntu_17.10 || mkdir ubuntu_17.10
49 | mv xmr-stak/bin/* ubuntu_17.10
50 | git -C xmr-stak clean -fd
51 |
52 |
53 | ########################
54 | # Ubuntu 16.04
55 | ########################
56 | docker run --rm -it -v $PWD:/mnt ubuntu:16.04 /bin/bash -c "
57 | set -x ;
58 | apt update -qq ;
59 | apt install -y -qq cmake g++ libmicrohttpd-dev libssl-dev libhwloc-dev ;
60 | cd /mnt/xmr-stak ;
61 | /mnt/cuda_*_linux-run --silent --toolkit ;
62 | cmake -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF . ;
63 | make ;
64 | "
65 |
66 | test -d ubuntu_16.04 || mkdir ubuntu_16.04
67 | mv xmr-stak/bin/* ubuntu_16.04
68 | git -C xmr-stak clean -fd
69 |
70 |
71 | ########################
72 | # Ubuntu 14.04
73 | ########################
74 | docker run --rm -it -v $PWD:/mnt ubuntu:14.04 /bin/bash -c "
75 | set -x ;
76 | apt update -qq ;
77 | apt install -y -qq curl libmicrohttpd-dev libssl-dev libhwloc-dev software-properties-common ;
78 | add-apt-repository -y ppa:ubuntu-toolchain-r/test ;
79 | apt update -qq ;
80 | apt install -y -qq gcc-6 g++-6 make ;
81 | update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 1 --slave /usr/bin/g++ g++ /usr/bin/g++-6 ;
82 | curl -L https://cmake.org/files/LatestRelease/cmake-3.10.0.tar.gz | tar -xzf - -C /tmp/ ;
83 | ( cd /tmp/cmake-*/ && ./configure && make && sudo make install && cd - ) > /dev/null
84 | update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force ;
85 | cd /mnt/xmr-stak ;
86 | /mnt/cuda_*_linux-run --silent --toolkit ;
87 | cmake -DCUDA_ENABLE=ON -DOpenCL_ENABLE=OFF . ;
88 | make ;
89 | "
90 |
91 | test -d ubuntu_14.04 || mkdir ubuntu_14.04
92 | mv xmr-stak/bin/* ubuntu_14.04
93 | git -C xmr-stak clean -fd
94 |
95 |
96 | ########################
97 | # CentOS 7
98 | ########################
99 | # CUDA is not going to work on CentOS/RHEL beacuse it's only support gcc-4 in these distributions: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
100 | docker run --rm -it -v $PWD:/mnt centos:7 /bin/bash -c "
101 | set -x ;
102 | yum install -y -q centos-release-scl epel-release ;
103 | yum install -y -q cmake3 devtoolset-7-gcc* hwloc-devel libmicrohttpd-devel make openssl-devel perl ;
104 | scl enable devtoolset-7 - << EOF
105 | cd /mnt/xmr-stak ;
106 | cmake3 -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF . ;
107 | make ;
108 | EOF
109 | "
110 |
111 | test -d centos_7 || mkdir centos_7
112 | mv xmr-stak/bin/* centos_7
113 | git -C xmr-stak clean -fd
114 |
115 |
116 | ########################
117 | # CentOS 6.x
118 | ########################
119 | # CUDA is not going to work on CentOS/RHEL beacuse it's only support gcc-4 in these distributions: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
120 | docker run --rm -it -v $PWD:/mnt centos:6 /bin/bash -c "
121 | set -x ;
122 | yum install -y -q centos-release-scl epel-release ;
123 | yum install -y -q cmake3 devtoolset-7-gcc* hwloc-devel libmicrohttpd-devel openssl-devel make ;
124 | scl enable devtoolset-7 - << EOF
125 | cd /mnt/xmr-stak ;
126 | cmake3 -DCUDA_ENABLE=OFF -DOpenCL_ENABLE=OFF . ;
127 | make ;
128 | EOF
129 | "
130 |
131 | test -d centos_6 || mkdir centos_6
132 | mv xmr-stak/bin/* centos_6
133 | git -C xmr-stak clean -fd
134 |
135 | rm -rf xmr-stak
136 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/OclCryptonightR_gen.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/backend/cryptonight.hpp"
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | #if defined(__APPLE__)
10 | #include
11 | #else
12 | #include
13 | #endif
14 |
15 | #include "xmrstak/backend/amd/amd_gpu/gpu.hpp"
16 |
17 | namespace xmrstak
18 | {
19 | namespace amd
20 | {
21 |
22 | cl_program CryptonightR_get_program(GpuContext* ctx, const xmrstak_algo algo,
23 | uint64_t height_offset, uint64_t height_chunk_size, uint32_t precompile_count, bool background = false);
24 |
25 | } // namespace amd
26 | } // namespace xmrstak
27 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/amd_gpu/opencl/blake256.cl:
--------------------------------------------------------------------------------
1 | R"===(
2 | /*
3 | * blake256 kernel implementation.
4 | *
5 | * ==========================(LICENSE BEGIN)============================
6 | * Copyright (c) 2014 djm34
7 | * Copyright (c) 2014 tpruvot
8 | * Permission is hereby granted, free of charge, to any person obtaining
9 | * a copy of this software and associated documentation files (the
10 | * "Software"), to deal in the Software without restriction, including
11 | * without limitation the rights to use, copy, modify, merge, publish,
12 | * distribute, sublicense, and/or sell copies of the Software, and to
13 | * permit persons to whom the Software is furnished to do so, subject to
14 | * the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be
17 | * included in all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 | *
27 | * ===========================(LICENSE END)=============================
28 | *
29 | * @author djm34
30 | */
31 | __constant static const int sigma[16][16] = {
32 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
33 | { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
34 | { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
35 | { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
36 | { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
37 | { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 },
38 | { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 },
39 | { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 },
40 | { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 },
41 | { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 },
42 | { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
43 | { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
44 | { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 },
45 | { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 },
46 | { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 },
47 | { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }
48 | };
49 |
50 |
51 | __constant static const sph_u32 c_IV256[8] = {
52 | 0x6A09E667, 0xBB67AE85,
53 | 0x3C6EF372, 0xA54FF53A,
54 | 0x510E527F, 0x9B05688C,
55 | 0x1F83D9AB, 0x5BE0CD19
56 | };
57 |
58 | /* Second part (64-80) msg never change, store it */
59 | __constant static const sph_u32 c_Padding[16] = {
60 | 0, 0, 0, 0,
61 | 0x80000000, 0, 0, 0,
62 | 0, 0, 0, 0,
63 | 0, 1, 0, 640,
64 | };
65 | __constant static const sph_u32 c_u256[16] = {
66 | 0x243F6A88, 0x85A308D3,
67 | 0x13198A2E, 0x03707344,
68 | 0xA4093822, 0x299F31D0,
69 | 0x082EFA98, 0xEC4E6C89,
70 | 0x452821E6, 0x38D01377,
71 | 0xBE5466CF, 0x34E90C6C,
72 | 0xC0AC29B7, 0xC97C50DD,
73 | 0x3F84D5B5, 0xB5470917
74 | };
75 |
76 | #define GS(a,b,c,d,x) { \
77 | const sph_u32 idx1 = sigma[r][x]; \
78 | const sph_u32 idx2 = sigma[r][x+1]; \
79 | v[a] += (m[idx1] ^ c_u256[idx2]) + v[b]; \
80 | v[d] ^= v[a]; \
81 | v[d] = rotate(v[d], 16U); \
82 | v[c] += v[d]; \
83 | v[b] ^= v[c]; \
84 | v[b] = rotate(v[b], 20U); \
85 | \
86 | v[a] += (m[idx2] ^ c_u256[idx1]) + v[b]; \
87 | v[d] ^= v[a]; \
88 | v[d] = rotate(v[d], 24U); \
89 | v[c] += v[d]; \
90 | v[b] ^= v[c]; \
91 | v[b] = rotate(v[b], 25U); \
92 | }
93 | )==="
94 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/amd_gpu/opencl/cryptonight_r_def.rtcl:
--------------------------------------------------------------------------------
1 | R"===(
2 | /*
3 | * This program is free software: you can redistribute it and/or modify
4 | * it under the terms of the GNU General Public License as published by
5 | * the Free Software Foundation, either version 3 of the License, or
6 | * any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | * GNU General Public License for more details.
12 | *
13 | * You should have received a copy of the GNU General Public License
14 | * along with this program. If not, see .
15 | *
16 | */
17 |
18 | #define cryptonight_r_wow 15
19 | #define cryptonight_r 16
20 |
21 | #define MEM_CHUNK (1 << MEM_CHUNK_EXPONENT)
22 |
23 | #if(STRIDED_INDEX==0)
24 | # define IDX(x) (x)
25 | #elif(STRIDED_INDEX==1)
26 | # define IDX(x) (mul24(((uint)(x)), Threads))
27 | #elif(STRIDED_INDEX==2)
28 | # define IDX(x) (((x) % MEM_CHUNK) + ((x) / MEM_CHUNK) * WORKSIZE * MEM_CHUNK)
29 | #elif(STRIDED_INDEX==3)
30 | # define IDX(x) ((x) * WORKSIZE)
31 | #endif
32 |
33 | )==="
34 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/amd_gpu/opencl/fast_div_heavy.cl:
--------------------------------------------------------------------------------
1 | R"===(
2 |
3 | #if(ALGO == cryptonight_heavy || ALGO == cryptonight_haven || ALGO == cryptonight_bittube2 || ALGO == cryptonight_superfast)
4 | inline long fast_div_heavy(long _a, int _b)
5 | {
6 | long a = abs(_a);
7 | int b = abs(_b);
8 | float rcp = native_recip(convert_float_rte(b));
9 | float rcp2 = as_float(as_uint(rcp) + (32U << 23));
10 | ulong q1 = convert_ulong(convert_float_rte(as_int2(a).s1) * rcp2);
11 | a -= q1 * as_uint(b);
12 | float q2f = convert_float_rte(as_int2(a >> 12).s0) * rcp;
13 | q2f = as_float(as_uint(q2f) + (12U << 23));
14 | long q2 = convert_long_rte(q2f);
15 | int a2 = as_int2(a).s0 - as_int2(q2).s0 * b;
16 | int q3 = convert_int_rte(convert_float_rte(a2) * rcp);
17 | q3 += (a2 - q3 * b) >> 31;
18 | const long q = q1 + q2 + q3;
19 | return ((as_int2(_a).s1 ^ _b) < 0) ? -q : q;
20 | }
21 | #endif
22 | )==="
23 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/config.tpl:
--------------------------------------------------------------------------------
1 | R"===(// generated by XMRSTAK_VERSION
2 |
3 | /*
4 | * GPU configuration. You should play around with intensity and worksize as the fastest settings will vary.
5 | * index - GPU index number usually starts from 0
6 | * intensity - Number of parallel GPU threads (nothing to do with CPU threads)
7 | * worksize - Number of local GPU threads (nothing to do with CPU threads)
8 | * affine_to_cpu - This will affine the thread to a CPU. This can make a GPU miner play along nicer with a CPU miner.
9 | * strided_index - switch memory pattern used for the scratchpad memory
10 | * 3 = chunked memory, chunk size based on the 'worksize'
11 | * required: intensity must be a multiple of worksize
12 | * 2 = chunked memory, chunk size is controlled by 'mem_chunk'
13 | * required: intensity must be a multiple of worksize
14 | * 1 or true = use 16 byte contiguous memory per thread, the next memory block has offset of intensity blocks
15 | * (for cryptonight_v8 and monero it is equal to strided_index = 0)
16 | * 0 or false = use a contiguous block of memory per thread
17 | * mem_chunk - range 0 to 18: set the number of elements (16byte) per chunk
18 | * this value is only used if 'strided_index' == 2
19 | * element count is computed with the equation: 2 to the power of 'mem_chunk' e.g. 4 means a chunk of 16 elements(256 byte)
20 | * unroll - allow to control how often the POW main loop is unrolled; valid range [1;128) - for most OpenCL implementations it must be a power of two.
21 | * comp_mode - Compatibility enable/disable the automatic guard around compute kernel which allows
22 | * to use an intensity which is not the multiple of the worksize.
23 | * If you set false and the intensity is not multiple of the worksize the miner can crash:
24 | * in this case set the intensity to a multiple of the worksize or activate comp_mode.
25 | * interleave - Controls the starting point in time between two threads on the same GPU device relative to the last started thread.
26 | * This option has only an effect if two compute threads using the same GPU device: valid range [0;100]
27 | * 0 = disable thread interleaving
28 | * 40 = each working thread waits until 40% of the hash calculation of the previously started thread is finished
29 | * "gpu_threads_conf" :
30 | * [
31 | * { "index" : 0, "intensity" : 1000, "worksize" : 8, "affine_to_cpu" : false,
32 | * "strided_index" : true, "mem_chunk" : 2, "unroll" : 8, "comp_mode" : true,
33 | * "interleave" : 40
34 | * },
35 | * ],
36 | * If you do not wish to mine with your AMD GPU(s) then use:
37 | * "gpu_threads_conf" :
38 | * null,
39 | */
40 |
41 | "gpu_threads_conf" : [
42 | GPUCONFIG
43 | ],
44 |
45 | /*
46 | * number of rounds per intensity performed to find the best intensity settings
47 | *
48 | * WARNING: experimental option
49 | *
50 | * 0 = disable auto tuning
51 | * 10 or higher = recommended value if you don't already know the best intensity
52 | */
53 | "auto_tune" : 0,
54 |
55 | /*
56 | * Platform index. This will be 0 unless you have different OpenCL platform - eg. AMD and Intel.
57 | */
58 | "platform_index" : PLATFORMINDEX,
59 | )==="
60 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/jconf.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/params.hpp"
4 |
5 | #include
6 | #include
7 |
8 | namespace xmrstak
9 | {
10 | namespace amd
11 | {
12 |
13 | class jconf
14 | {
15 | public:
16 | static jconf* inst()
17 | {
18 | if(oInst == nullptr)
19 | oInst = new jconf;
20 | return oInst;
21 | };
22 |
23 | bool parse_config(const char* sFilename = params::inst().configFileAMD.c_str());
24 |
25 | struct thd_cfg
26 | {
27 | size_t index;
28 | size_t intensity;
29 | size_t w_size;
30 | long long cpu_aff;
31 | int stridedIndex;
32 | int interleave = 40;
33 | int memChunk;
34 | int unroll;
35 | bool compMode;
36 | };
37 |
38 | size_t GetThreadCount();
39 | bool GetThreadConfig(size_t id, thd_cfg& cfg);
40 |
41 | size_t GetAutoTune();
42 | size_t GetPlatformIdx();
43 |
44 | private:
45 | jconf();
46 | static jconf* oInst;
47 |
48 | struct opaque_private;
49 | opaque_private* prv;
50 | };
51 |
52 | } // namespace amd
53 | } // namespace xmrstak
54 |
--------------------------------------------------------------------------------
/xmrstak/backend/amd/minethd.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "amd_gpu/gpu.hpp"
4 | #include "jconf.hpp"
5 | #include "xmrstak/backend/cpu/crypto/cryptonight.h"
6 | #include "xmrstak/backend/iBackend.hpp"
7 | #include "xmrstak/backend/miner_work.hpp"
8 | #include "xmrstak/misc/environment.hpp"
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | namespace xmrstak
15 | {
16 | namespace amd
17 | {
18 |
19 | class minethd : public iBackend
20 | {
21 | public:
22 | static std::vector* thread_starter(uint32_t threadOffset, miner_work& pWork);
23 | static bool init_gpus();
24 |
25 | private:
26 | typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx**, const xmrstak_algo&);
27 |
28 | minethd(miner_work& pWork, size_t iNo, GpuContext* ctx, const jconf::thd_cfg cfg);
29 |
30 | void work_main();
31 |
32 | uint64_t iJobNo;
33 |
34 | miner_work oWork;
35 |
36 | std::promise order_fix;
37 | std::mutex thd_aff_set;
38 |
39 | std::thread oWorkThd;
40 | int64_t affinity;
41 | uint32_t autoTune;
42 |
43 | bool bQuit;
44 | bool bNoPrefetch;
45 |
46 | //Mutable ptr to vector below, different for each thread
47 | GpuContext* pGpuCtx;
48 |
49 | // WARNING - this vector (but not its contents) must be immutable
50 | // once the threads are started
51 | static std::vector vGpuData;
52 | };
53 |
54 | } // namespace amd
55 | } // namespace xmrstak
56 |
--------------------------------------------------------------------------------
/xmrstak/backend/backendConnector.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "iBackend.hpp"
4 | #include "miner_work.hpp"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | namespace xmrstak
12 | {
13 |
14 | struct BackendConnector
15 | {
16 | static std::vector* thread_starter(miner_work& pWork);
17 | static bool self_test();
18 | };
19 |
20 | } // namespace xmrstak
21 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/config.tpl:
--------------------------------------------------------------------------------
1 | R"===(// generated by XMRSTAK_VERSION
2 |
3 | /*
4 | * Thread configuration for each thread. Make sure it matches the number above.
5 | * low_power_mode - This can either be a boolean (true or false), or a number between 1 to 5. When set to true,
6 | * this mode will double the cache usage, and double the single thread performance. It will
7 | * consume much less power (as less cores are working), but will max out at around 80-85% of
8 | * the maximum performance. When set to a number N greater than 1, this mode will increase the
9 | * cache usage and single thread performance by N times.
10 | *
11 | * no_prefetch - Some systems can gain up to extra 5% here, but sometimes it will have no difference or make
12 | * things slower.
13 | *
14 | * asm - Allow to switch to a assembler version of cryptonight_v8; allowed value [auto, off, intel_avx, amd_avx]
15 | * - auto: xmr-stak will automatically detect the asm type (default)
16 | * - off: disable the usage of optimized assembler
17 | * - intel_avx: supports Intel cpus with avx instructions e.g. Xeon v2, Core i7/i5/i3 3xxx, Pentium G2xxx, Celeron G1xxx
18 | * - amd_avx: supports AMD cpus with avx instructions e.g. AMD Ryzen 1xxx and 2xxx series
19 | *
20 | * affine_to_cpu - This can be either false (no affinity), or the CPU core number. Note that on hyperthreading
21 | * systems it is better to assign threads to physical cores. On Windows this usually means selecting
22 | * even or odd numbered cpu numbers. For Linux it will be usually the lower CPU numbers, so for a 4
23 | * physical core CPU you should select cpu numbers 0-3.
24 | *
25 | * On the first run the miner will look at your system and suggest a basic configuration that will work,
26 | * you can try to tweak it from there to get the best performance.
27 | *
28 | * A filled out configuration should look like this:
29 | * "cpu_threads_conf" :
30 | * [
31 | * { "low_power_mode" : false, "no_prefetch" : true, "asm" : "auto", "affine_to_cpu" : 0 },
32 | * { "low_power_mode" : false, "no_prefetch" : true, "asm" : "auto", "affine_to_cpu" : 1 },
33 | * ],
34 | * If you do not wish to mine with your CPU(s) then use:
35 | * "cpu_threads_conf" :
36 | * null,
37 | */
38 |
39 | "cpu_threads_conf" :
40 | [
41 | CPUCONFIG
42 | ],
43 | )==="
44 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/cpuType.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "xmrstak/backend/cpu/cpuType.hpp"
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #ifdef _WIN32
9 | #define strcasecmp _stricmp
10 | #include
11 | #else
12 | #include
13 | #endif
14 |
15 | namespace xmrstak
16 | {
17 | namespace cpu
18 | {
19 | void cpuid(uint32_t eax, int32_t ecx, int32_t val[4])
20 | {
21 | std::memset(val, 0, sizeof(int32_t) * 4);
22 |
23 | #ifdef _WIN32
24 | __cpuidex(val, eax, ecx);
25 | #else
26 | __cpuid_count(eax, ecx, val[0], val[1], val[2], val[3]);
27 | #endif
28 | }
29 |
30 | int32_t get_masked(int32_t val, int32_t h, int32_t l)
31 | {
32 | val &= (0x7FFFFFFF >> (31 - (h - l))) << l;
33 | return val >> l;
34 | }
35 |
36 | bool has_feature(int32_t val, int32_t bit)
37 | {
38 | int32_t mask = 1 << bit;
39 | return (val & mask) != 0u;
40 | }
41 |
42 | Model getModel()
43 | {
44 | int32_t cpu_info[4];
45 | char cpustr[13] = {0};
46 |
47 | cpuid(0, 0, cpu_info);
48 | std::memcpy(cpustr, &cpu_info[1], 4);
49 | std::memcpy(cpustr + 4, &cpu_info[3], 4);
50 | std::memcpy(cpustr + 8, &cpu_info[2], 4);
51 |
52 | Model result;
53 |
54 | cpuid(1, 0, cpu_info);
55 |
56 | result.family = get_masked(cpu_info[0], 12, 8);
57 | result.model = get_masked(cpu_info[0], 8, 4) | get_masked(cpu_info[0], 20, 16) << 4;
58 | result.type_name = cpustr;
59 |
60 | // feature bits https://en.wikipedia.org/wiki/CPUID
61 | // sse2
62 | result.sse2 = has_feature(cpu_info[3], 26);
63 | // aes-ni
64 | result.aes = has_feature(cpu_info[2], 25);
65 | // avx - 27 is the check if the OS overwrote cpu features
66 | result.avx = has_feature(cpu_info[2], 28) && has_feature(cpu_info[2], 27);
67 |
68 | if(strcmp(cpustr, "AuthenticAMD") == 0)
69 | {
70 | if(result.family == 0xF)
71 | result.family += get_masked(cpu_info[0], 28, 20);
72 | }
73 |
74 | return result;
75 | }
76 |
77 | } // namespace cpu
78 | } // namespace xmrstak
79 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/cpuType.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | namespace xmrstak
7 | {
8 | namespace cpu
9 | {
10 | struct Model
11 | {
12 | uint32_t family = 0u;
13 | uint32_t model = 0u;
14 | bool aes = false;
15 | bool sse2 = false;
16 | bool avx = false;
17 | std::string type_name = "unknown";
18 | };
19 |
20 | Model getModel();
21 |
22 | /** Mask bits between h and l and return the value
23 | *
24 | * This enables us to put in values exactly like in the manual
25 | * For example EBX[30:22] is get_masked(cpu_info[1], 31, 22)
26 | */
27 | int32_t get_masked(int32_t val, int32_t h, int32_t l);
28 |
29 | } // namespace cpu
30 | } // namespace xmrstak
31 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/CryptonightR_gen.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | typedef void (*void_func)();
4 |
5 | #include "cryptonight.h"
6 | #include "cryptonight_aesni.h"
7 | #include "xmrstak/backend/cpu/crypto/asm/cnR/CryptonightR_template.h"
8 | #include "xmrstak/misc/console.hpp"
9 |
10 | static inline void add_code(uint8_t*& p, void (*p1)(), void (*p2)())
11 | {
12 | const ptrdiff_t size = reinterpret_cast(p2) - reinterpret_cast(p1);
13 | if(size > 0)
14 | {
15 | memcpy(p, reinterpret_cast(p1), size);
16 | p += size;
17 | }
18 | }
19 |
20 | static inline void add_random_math(uint8_t*& p, const V4_Instruction* code, int code_size, const void_func* instructions, const void_func* instructions_mov, bool is_64_bit, int selected_asm)
21 | {
22 | uint32_t prev_rot_src = (uint32_t)(-1);
23 |
24 | for(int i = 0;; ++i)
25 | {
26 | const V4_Instruction inst = code[i];
27 | if(inst.opcode == RET)
28 | {
29 | break;
30 | }
31 |
32 | uint8_t opcode = (inst.opcode == MUL) ? inst.opcode : (inst.opcode + 2);
33 | uint8_t dst_index = inst.dst_index;
34 | uint8_t src_index = inst.src_index;
35 |
36 | const uint32_t a = inst.dst_index;
37 | const uint32_t b = inst.src_index;
38 | const uint8_t c = opcode | (dst_index << V4_OPCODE_BITS) | (((src_index == 8) ? dst_index : src_index) << (V4_OPCODE_BITS + V4_DST_INDEX_BITS));
39 |
40 | switch(inst.opcode)
41 | {
42 | case ROR:
43 | case ROL:
44 | if(b != prev_rot_src)
45 | {
46 | prev_rot_src = b;
47 | add_code(p, instructions_mov[c], instructions_mov[c + 1]);
48 | }
49 | break;
50 | }
51 |
52 | if(a == prev_rot_src)
53 | {
54 | prev_rot_src = (uint32_t)(-1);
55 | }
56 |
57 | void_func begin = instructions[c];
58 |
59 | // AMD == 2
60 | if((selected_asm == 2) && (inst.opcode == MUL && !is_64_bit))
61 | {
62 | // AMD Bulldozer has latency 4 for 32-bit IMUL and 6 for 64-bit IMUL
63 | // Always use 32-bit IMUL for AMD Bulldozer in 32-bit mode - skip prefix 0x48 and change 0x49 to 0x41
64 | uint8_t* prefix = reinterpret_cast(begin);
65 |
66 | if(*prefix == 0x49)
67 | {
68 | *(p++) = 0x41;
69 | }
70 |
71 | begin = reinterpret_cast(prefix + 1);
72 | }
73 |
74 | add_code(p, begin, instructions[c + 1]);
75 |
76 | if(inst.opcode == ADD)
77 | {
78 | *(uint32_t*)(p - sizeof(uint32_t) - (is_64_bit ? 3 : 0)) = inst.C;
79 | if(is_64_bit)
80 | {
81 | prev_rot_src = (uint32_t)(-1);
82 | }
83 | }
84 | }
85 | }
86 |
87 | void v4_compile_code(size_t N, cryptonight_ctx* ctx, int code_size)
88 | {
89 | printer::inst()->print_msg(LDEBUG, "CryptonightR update ASM code");
90 | const int allocation_size = 65536;
91 |
92 | if(ctx->fun_data == nullptr)
93 | ctx->fun_data = static_cast(allocateExecutableMemory(allocation_size));
94 | else
95 | unprotectExecutableMemory(ctx->fun_data, allocation_size);
96 |
97 | uint8_t* p0 = ctx->fun_data;
98 | uint8_t* p = p0;
99 | if(ctx->fun_data != nullptr)
100 | {
101 |
102 | if(N == 2)
103 | {
104 | add_code(p, CryptonightR_template_double_part1, CryptonightR_template_double_part2);
105 | add_random_math(p, ctx->cn_r_ctx.code, code_size, instructions, instructions_mov, false, ctx->asm_version);
106 | add_code(p, CryptonightR_template_double_part2, CryptonightR_template_double_part3);
107 | add_random_math(p, ctx->cn_r_ctx.code, code_size, instructions, instructions_mov, false, ctx->asm_version);
108 | add_code(p, CryptonightR_template_double_part3, CryptonightR_template_double_part4);
109 | *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightR_template_double_mainloop) - ((const uint8_t*)CryptonightR_template_double_part1)) - (p - p0));
110 | add_code(p, CryptonightR_template_double_part4, CryptonightR_template_double_end);
111 | }
112 | else
113 | {
114 | add_code(p, CryptonightR_template_part1, CryptonightR_template_part2);
115 | add_random_math(p, ctx->cn_r_ctx.code, code_size, instructions, instructions_mov, false, ctx->asm_version);
116 | add_code(p, CryptonightR_template_part2, CryptonightR_template_part3);
117 | *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightR_template_mainloop) - ((const uint8_t*)CryptonightR_template_part1)) - (p - p0));
118 | add_code(p, CryptonightR_template_part3, CryptonightR_template_end);
119 | }
120 |
121 | ctx->loop_fn = reinterpret_cast(ctx->fun_data);
122 | protectExecutableMemory(ctx->fun_data, allocation_size);
123 | flushInstructionCache(ctx->fun_data, p - p0);
124 | }
125 | else
126 | {
127 | printer::inst()->print_msg(L0, "Error: CPU CryptonightR update ASM code ctx->fun_data is a nullptr");
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.S:
--------------------------------------------------------------------------------
1 | #ifdef __APPLE__
2 | # define ALIGN(x) .align 6
3 | #else
4 | # define ALIGN(x) .align x
5 | #endif
6 | .intel_syntax noprefix
7 | #ifdef __APPLE__
8 | # define FN_PREFIX(fn) _ ## fn
9 | .text
10 | #else
11 | # define FN_PREFIX(fn) fn
12 | .section .text
13 | #endif
14 | .global FN_PREFIX(cryptonight_v8_mainloop_ivybridge_asm)
15 | .global FN_PREFIX(cryptonight_v8_mainloop_ryzen_asm)
16 | .global FN_PREFIX(cryptonight_v8_double_mainloop_sandybridge_asm)
17 |
18 | ALIGN(64)
19 | FN_PREFIX(cryptonight_v8_mainloop_ivybridge_asm):
20 | sub rsp, 48
21 | mov rcx, rdi
22 | #include "cryptonight_v8_main_loop_ivybridge_linux.inc"
23 | add rsp, 48
24 | ret 0
25 | mov eax, 3735929054
26 |
27 | ALIGN(64)
28 | FN_PREFIX(cryptonight_v8_mainloop_ryzen_asm):
29 | sub rsp, 48
30 | mov rcx, rdi
31 | #include "cryptonight_v8_main_loop_ryzen_linux.inc"
32 | add rsp, 48
33 | ret 0
34 | mov eax, 3735929054
35 |
36 | ALIGN(64)
37 | FN_PREFIX(cryptonight_v8_double_mainloop_sandybridge_asm):
38 | sub rsp, 48
39 | mov rcx, rdi
40 | mov rdx, rsi
41 | #include "cryptonight_v8_double_main_loop_sandybridge_linux.inc"
42 | add rsp, 48
43 | ret 0
44 | mov eax, 3735929054
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop.asm:
--------------------------------------------------------------------------------
1 | _TEXT_CNV8_MAINLOOP SEGMENT PAGE READ EXECUTE
2 | PUBLIC cryptonight_v8_mainloop_ivybridge_asm
3 | PUBLIC cryptonight_v8_mainloop_ryzen_asm
4 | PUBLIC cryptonight_v8_double_mainloop_sandybridge_asm
5 |
6 | ALIGN(64)
7 | cryptonight_v8_mainloop_ivybridge_asm PROC
8 | INCLUDE cryptonight_v8_main_loop_ivybridge_win64.inc
9 | ret 0
10 | mov eax, 3735929054
11 | cryptonight_v8_mainloop_ivybridge_asm ENDP
12 |
13 | ALIGN(64)
14 | cryptonight_v8_mainloop_ryzen_asm PROC
15 | INCLUDE cryptonight_v8_main_loop_ryzen_win64.inc
16 | ret 0
17 | mov eax, 3735929054
18 | cryptonight_v8_mainloop_ryzen_asm ENDP
19 |
20 | ALIGN(64)
21 | cryptonight_v8_double_mainloop_sandybridge_asm PROC
22 | INCLUDE cryptonight_v8_double_main_loop_sandybridge_win64.inc
23 | ret 0
24 | mov eax, 3735929054
25 | cryptonight_v8_double_mainloop_sandybridge_asm ENDP
26 |
27 | _TEXT_CNV8_MAINLOOP ENDS
28 | END
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop_ivybridge_linux.inc:
--------------------------------------------------------------------------------
1 | mov QWORD PTR [rsp+24], rbx
2 | push rbp
3 | push rsi
4 | push rdi
5 | push r12
6 | push r13
7 | push r14
8 | push r15
9 | sub rsp, 80
10 |
11 | stmxcsr DWORD PTR [rsp]
12 | mov DWORD PTR [rsp+4], 24448
13 | ldmxcsr DWORD PTR [rsp+4]
14 |
15 | mov rax, QWORD PTR [rcx+48]
16 | mov r9, rcx
17 | xor rax, QWORD PTR [rcx+16]
18 | mov esi, 524288
19 | mov r8, QWORD PTR [rcx+32]
20 | mov r13d, -2147483647
21 | xor r8, QWORD PTR [rcx]
22 | mov r11, QWORD PTR [rcx+40]
23 | mov r10, r8
24 | mov rdx, QWORD PTR [rcx+56]
25 | movq xmm4, rax
26 | xor rdx, QWORD PTR [rcx+24]
27 | xor r11, QWORD PTR [rcx+8]
28 | mov rbx, QWORD PTR [rcx+224]
29 | mov rax, QWORD PTR [r9+80]
30 | xor rax, QWORD PTR [r9+64]
31 | movq xmm0, rdx
32 | mov rcx, QWORD PTR [rcx+88]
33 | xor rcx, QWORD PTR [r9+72]
34 | movq xmm3, QWORD PTR [r9+104]
35 | movaps XMMWORD PTR [rsp+64], xmm6
36 | movaps XMMWORD PTR [rsp+48], xmm7
37 | movaps XMMWORD PTR [rsp+32], xmm8
38 | and r10d, 2097136
39 | movq xmm5, rax
40 |
41 | xor eax, eax
42 | mov QWORD PTR [rsp+16], rax
43 |
44 | mov ax, 1023
45 | shl rax, 52
46 | movq xmm8, rax
47 | mov r15, QWORD PTR [r9+96]
48 | punpcklqdq xmm4, xmm0
49 | movq xmm0, rcx
50 | punpcklqdq xmm5, xmm0
51 | movdqu xmm6, XMMWORD PTR [r10+rbx]
52 |
53 | ALIGN(64)
54 | main_loop_ivybridge:
55 | lea rdx, QWORD PTR [r10+rbx]
56 | mov ecx, r10d
57 | mov eax, r10d
58 | mov rdi, r15
59 | xor ecx, 16
60 | xor eax, 32
61 | xor r10d, 48
62 | movq xmm0, r11
63 | movq xmm7, r8
64 | punpcklqdq xmm7, xmm0
65 | aesenc xmm6, xmm7
66 | movq rbp, xmm6
67 | mov r9, rbp
68 | and r9d, 2097136
69 | movdqu xmm2, XMMWORD PTR [rcx+rbx]
70 | movdqu xmm1, XMMWORD PTR [rax+rbx]
71 | movdqu xmm0, XMMWORD PTR [r10+rbx]
72 | paddq xmm1, xmm7
73 | paddq xmm0, xmm5
74 | paddq xmm2, xmm4
75 | movdqu XMMWORD PTR [rcx+rbx], xmm0
76 | movdqu XMMWORD PTR [rax+rbx], xmm2
77 | movdqu XMMWORD PTR [r10+rbx], xmm1
78 | mov r10, r9
79 | xor r10d, 32
80 | movq rcx, xmm3
81 | mov rax, rcx
82 | shl rax, 32
83 | xor rdi, rax
84 | movdqa xmm0, xmm6
85 | pxor xmm0, xmm4
86 | movdqu XMMWORD PTR [rdx], xmm0
87 | xor rdi, QWORD PTR [r9+rbx]
88 | lea r14, QWORD PTR [r9+rbx]
89 | mov r12, QWORD PTR [r14+8]
90 | xor edx, edx
91 | lea r9d, DWORD PTR [ecx+ecx]
92 | add r9d, ebp
93 | movdqa xmm0, xmm6
94 | psrldq xmm0, 8
95 | or r9d, r13d
96 | movq rax, xmm0
97 | div r9
98 | xorps xmm3, xmm3
99 | mov eax, eax
100 | shl rdx, 32
101 | add rdx, rax
102 | lea r9, QWORD PTR [rdx+rbp]
103 | mov r15, rdx
104 | mov rax, r9
105 | shr rax, 12
106 | movq xmm0, rax
107 | paddq xmm0, xmm8
108 | sqrtsd xmm3, xmm0
109 | psubq xmm3, XMMWORD PTR [rsp+16]
110 | movq rdx, xmm3
111 | test edx, 524287
112 | je sqrt_fixup_ivybridge
113 | psrlq xmm3, 19
114 | psubq xmm3, XMMWORD PTR [rsp+16]
115 | sqrt_fixup_ivybridge_ret:
116 |
117 | mov ecx, r10d
118 | mov rax, rdi
119 | mul rbp
120 | movq xmm2, rdx
121 | xor rdx, [rcx+rbx]
122 | add r8, rdx
123 | mov QWORD PTR [r14], r8
124 | xor r8, rdi
125 | mov edi, r8d
126 | and edi, 2097136
127 | movq xmm0, rax
128 | xor rax, [rcx+rbx+8]
129 | add r11, rax
130 | mov QWORD PTR [r14+8], r11
131 | punpcklqdq xmm2, xmm0
132 |
133 | mov r9d, r10d
134 | xor r9d, 48
135 | xor r10d, 16
136 | pxor xmm2, XMMWORD PTR [r9+rbx]
137 | movdqu xmm0, XMMWORD PTR [r10+rbx]
138 | paddq xmm0, xmm5
139 | movdqu xmm1, XMMWORD PTR [rcx+rbx]
140 | paddq xmm2, xmm4
141 | paddq xmm1, xmm7
142 | movdqa xmm5, xmm4
143 | movdqu XMMWORD PTR [r9+rbx], xmm0
144 | movdqa xmm4, xmm6
145 | movdqu XMMWORD PTR [rcx+rbx], xmm2
146 | movdqu XMMWORD PTR [r10+rbx], xmm1
147 | movdqu xmm6, [rdi+rbx]
148 | mov r10d, edi
149 | xor r11, r12
150 | dec rsi
151 | jne main_loop_ivybridge
152 |
153 | ldmxcsr DWORD PTR [rsp]
154 | mov rbx, QWORD PTR [rsp+160]
155 | movaps xmm6, XMMWORD PTR [rsp+64]
156 | movaps xmm7, XMMWORD PTR [rsp+48]
157 | movaps xmm8, XMMWORD PTR [rsp+32]
158 | add rsp, 80
159 | pop r15
160 | pop r14
161 | pop r13
162 | pop r12
163 | pop rdi
164 | pop rsi
165 | pop rbp
166 | jmp cnv2_main_loop_ivybridge_endp
167 |
168 | sqrt_fixup_ivybridge:
169 | dec rdx
170 | mov r13d, -1022
171 | shl r13, 32
172 | mov rax, rdx
173 | shr rdx, 19
174 | shr rax, 20
175 | mov rcx, rdx
176 | sub rcx, rax
177 | add rax, r13
178 | not r13
179 | sub rcx, r13
180 | mov r13d, -2147483647
181 | imul rcx, rax
182 | sub rcx, r9
183 | adc rdx, 0
184 | movq xmm3, rdx
185 | jmp sqrt_fixup_ivybridge_ret
186 |
187 | cnv2_main_loop_ivybridge_endp:
188 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop_ivybridge_win64.inc:
--------------------------------------------------------------------------------
1 | mov QWORD PTR [rsp+24], rbx
2 | push rbp
3 | push rsi
4 | push rdi
5 | push r12
6 | push r13
7 | push r14
8 | push r15
9 | sub rsp, 80
10 |
11 | stmxcsr DWORD PTR [rsp]
12 | mov DWORD PTR [rsp+4], 24448
13 | ldmxcsr DWORD PTR [rsp+4]
14 |
15 | mov rax, QWORD PTR [rcx+48]
16 | mov r9, rcx
17 | xor rax, QWORD PTR [rcx+16]
18 | mov esi, 524288
19 | mov r8, QWORD PTR [rcx+32]
20 | mov r13d, -2147483647
21 | xor r8, QWORD PTR [rcx]
22 | mov r11, QWORD PTR [rcx+40]
23 | mov r10, r8
24 | mov rdx, QWORD PTR [rcx+56]
25 | movd xmm4, rax
26 | xor rdx, QWORD PTR [rcx+24]
27 | xor r11, QWORD PTR [rcx+8]
28 | mov rbx, QWORD PTR [rcx+224]
29 | mov rax, QWORD PTR [r9+80]
30 | xor rax, QWORD PTR [r9+64]
31 | movd xmm0, rdx
32 | mov rcx, QWORD PTR [rcx+88]
33 | xor rcx, QWORD PTR [r9+72]
34 | movq xmm3, QWORD PTR [r9+104]
35 | movaps XMMWORD PTR [rsp+64], xmm6
36 | movaps XMMWORD PTR [rsp+48], xmm7
37 | movaps XMMWORD PTR [rsp+32], xmm8
38 | and r10d, 2097136
39 | movd xmm5, rax
40 |
41 | xor eax, eax
42 | mov QWORD PTR [rsp+16], rax
43 |
44 | mov ax, 1023
45 | shl rax, 52
46 | movd xmm8, rax
47 | mov r15, QWORD PTR [r9+96]
48 | punpcklqdq xmm4, xmm0
49 | movd xmm0, rcx
50 | punpcklqdq xmm5, xmm0
51 | movdqu xmm6, XMMWORD PTR [r10+rbx]
52 |
53 | ALIGN(64)
54 | main_loop_ivybridge:
55 | lea rdx, QWORD PTR [r10+rbx]
56 | mov ecx, r10d
57 | mov eax, r10d
58 | mov rdi, r15
59 | xor ecx, 16
60 | xor eax, 32
61 | xor r10d, 48
62 | movd xmm0, r11
63 | movd xmm7, r8
64 | punpcklqdq xmm7, xmm0
65 | aesenc xmm6, xmm7
66 | movd rbp, xmm6
67 | mov r9, rbp
68 | and r9d, 2097136
69 | movdqu xmm2, XMMWORD PTR [rcx+rbx]
70 | movdqu xmm1, XMMWORD PTR [rax+rbx]
71 | movdqu xmm0, XMMWORD PTR [r10+rbx]
72 | paddq xmm1, xmm7
73 | paddq xmm0, xmm5
74 | paddq xmm2, xmm4
75 | movdqu XMMWORD PTR [rcx+rbx], xmm0
76 | movdqu XMMWORD PTR [rax+rbx], xmm2
77 | movdqu XMMWORD PTR [r10+rbx], xmm1
78 | mov r10, r9
79 | xor r10d, 32
80 | movd rcx, xmm3
81 | mov rax, rcx
82 | shl rax, 32
83 | xor rdi, rax
84 | movdqa xmm0, xmm6
85 | pxor xmm0, xmm4
86 | movdqu XMMWORD PTR [rdx], xmm0
87 | xor rdi, QWORD PTR [r9+rbx]
88 | lea r14, QWORD PTR [r9+rbx]
89 | mov r12, QWORD PTR [r14+8]
90 | xor edx, edx
91 | lea r9d, DWORD PTR [ecx+ecx]
92 | add r9d, ebp
93 | movdqa xmm0, xmm6
94 | psrldq xmm0, 8
95 | or r9d, r13d
96 | movd rax, xmm0
97 | div r9
98 | xorps xmm3, xmm3
99 | mov eax, eax
100 | shl rdx, 32
101 | add rdx, rax
102 | lea r9, QWORD PTR [rdx+rbp]
103 | mov r15, rdx
104 | mov rax, r9
105 | shr rax, 12
106 | movd xmm0, rax
107 | paddq xmm0, xmm8
108 | sqrtsd xmm3, xmm0
109 | psubq xmm3, XMMWORD PTR [rsp+16]
110 | movd rdx, xmm3
111 | test edx, 524287
112 | je sqrt_fixup_ivybridge
113 | psrlq xmm3, 19
114 | psubq xmm3, XMMWORD PTR [rsp+16]
115 | sqrt_fixup_ivybridge_ret:
116 |
117 | mov ecx, r10d
118 | mov rax, rdi
119 | mul rbp
120 | movd xmm2, rdx
121 | xor rdx, [rcx+rbx]
122 | add r8, rdx
123 | mov QWORD PTR [r14], r8
124 | xor r8, rdi
125 | mov edi, r8d
126 | and edi, 2097136
127 | movd xmm0, rax
128 | xor rax, [rcx+rbx+8]
129 | add r11, rax
130 | mov QWORD PTR [r14+8], r11
131 | punpcklqdq xmm2, xmm0
132 |
133 | mov r9d, r10d
134 | xor r9d, 48
135 | xor r10d, 16
136 | pxor xmm2, XMMWORD PTR [r9+rbx]
137 | movdqu xmm0, XMMWORD PTR [r10+rbx]
138 | paddq xmm0, xmm5
139 | movdqu xmm1, XMMWORD PTR [rcx+rbx]
140 | paddq xmm2, xmm4
141 | paddq xmm1, xmm7
142 | movdqa xmm5, xmm4
143 | movdqu XMMWORD PTR [r9+rbx], xmm0
144 | movdqa xmm4, xmm6
145 | movdqu XMMWORD PTR [rcx+rbx], xmm2
146 | movdqu XMMWORD PTR [r10+rbx], xmm1
147 | movdqu xmm6, [rdi+rbx]
148 | mov r10d, edi
149 | xor r11, r12
150 | dec rsi
151 | jne main_loop_ivybridge
152 |
153 | ldmxcsr DWORD PTR [rsp]
154 | mov rbx, QWORD PTR [rsp+160]
155 | movaps xmm6, XMMWORD PTR [rsp+64]
156 | movaps xmm7, XMMWORD PTR [rsp+48]
157 | movaps xmm8, XMMWORD PTR [rsp+32]
158 | add rsp, 80
159 | pop r15
160 | pop r14
161 | pop r13
162 | pop r12
163 | pop rdi
164 | pop rsi
165 | pop rbp
166 | jmp cnv2_main_loop_ivybridge_endp
167 |
168 | sqrt_fixup_ivybridge:
169 | dec rdx
170 | mov r13d, -1022
171 | shl r13, 32
172 | mov rax, rdx
173 | shr rdx, 19
174 | shr rax, 20
175 | mov rcx, rdx
176 | sub rcx, rax
177 | add rax, r13
178 | not r13
179 | sub rcx, r13
180 | mov r13d, -2147483647
181 | imul rcx, rax
182 | sub rcx, r9
183 | adc rdx, 0
184 | movd xmm3, rdx
185 | jmp sqrt_fixup_ivybridge_ret
186 |
187 | cnv2_main_loop_ivybridge_endp:
188 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop_ryzen_linux.inc:
--------------------------------------------------------------------------------
1 | mov QWORD PTR [rsp+16], rbx
2 | mov QWORD PTR [rsp+24], rbp
3 | mov QWORD PTR [rsp+32], rsi
4 | push rdi
5 | push r12
6 | push r13
7 | push r14
8 | push r15
9 | sub rsp, 64
10 |
11 | stmxcsr DWORD PTR [rsp]
12 | mov DWORD PTR [rsp+4], 24448
13 | ldmxcsr DWORD PTR [rsp+4]
14 |
15 | mov rax, QWORD PTR [rcx+48]
16 | mov r9, rcx
17 | xor rax, QWORD PTR [rcx+16]
18 | mov ebp, 524288
19 | mov r8, QWORD PTR [rcx+32]
20 | xor r8, QWORD PTR [rcx]
21 | mov r11, QWORD PTR [rcx+40]
22 | mov r10, r8
23 | mov rdx, QWORD PTR [rcx+56]
24 | movq xmm3, rax
25 | xor rdx, QWORD PTR [rcx+24]
26 | xor r11, QWORD PTR [rcx+8]
27 | mov rbx, QWORD PTR [rcx+224]
28 | mov rax, QWORD PTR [r9+80]
29 | xor rax, QWORD PTR [r9+64]
30 | movq xmm0, rdx
31 | mov rcx, QWORD PTR [rcx+88]
32 | xor rcx, QWORD PTR [r9+72]
33 | mov rdi, QWORD PTR [r9+104]
34 | and r10d, 2097136
35 | movaps XMMWORD PTR [rsp+48], xmm6
36 | movq xmm4, rax
37 | movaps XMMWORD PTR [rsp+32], xmm7
38 | movaps XMMWORD PTR [rsp+16], xmm8
39 | xorps xmm8, xmm8
40 | mov ax, 1023
41 | shl rax, 52
42 | movq xmm7, rax
43 | mov r15, QWORD PTR [r9+96]
44 | punpcklqdq xmm3, xmm0
45 | movq xmm0, rcx
46 | punpcklqdq xmm4, xmm0
47 |
48 | ALIGN(64)
49 | main_loop_ryzen:
50 | movdqa xmm5, XMMWORD PTR [r10+rbx]
51 | movq xmm0, r11
52 | movq xmm6, r8
53 | punpcklqdq xmm6, xmm0
54 | lea rdx, QWORD PTR [r10+rbx]
55 | lea r9, QWORD PTR [rdi+rdi]
56 | shl rdi, 32
57 |
58 | mov ecx, r10d
59 | mov eax, r10d
60 | xor ecx, 16
61 | xor eax, 32
62 | xor r10d, 48
63 | aesenc xmm5, xmm6
64 | movdqa xmm2, XMMWORD PTR [rcx+rbx]
65 | movdqa xmm1, XMMWORD PTR [rax+rbx]
66 | movdqa xmm0, XMMWORD PTR [r10+rbx]
67 | paddq xmm2, xmm3
68 | paddq xmm1, xmm6
69 | paddq xmm0, xmm4
70 | movdqa XMMWORD PTR [rcx+rbx], xmm0
71 | movdqa XMMWORD PTR [rax+rbx], xmm2
72 | movdqa XMMWORD PTR [r10+rbx], xmm1
73 |
74 | movaps xmm1, xmm8
75 | mov rsi, r15
76 | xor rsi, rdi
77 | movq r14, xmm5
78 | movdqa xmm0, xmm5
79 | pxor xmm0, xmm3
80 | mov r10, r14
81 | and r10d, 2097136
82 | movdqa XMMWORD PTR [rdx], xmm0
83 | xor rsi, QWORD PTR [r10+rbx]
84 | lea r12, QWORD PTR [r10+rbx]
85 | mov r13, QWORD PTR [r10+rbx+8]
86 |
87 | add r9d, r14d
88 | or r9d, -2147483647
89 | xor edx, edx
90 | movdqa xmm0, xmm5
91 | psrldq xmm0, 8
92 | movq rax, xmm0
93 |
94 | div r9
95 | movq xmm0, rax
96 | movq xmm1, rdx
97 | punpckldq xmm0, xmm1
98 | movq r15, xmm0
99 | paddq xmm0, xmm5
100 | movdqa xmm2, xmm0
101 | psrlq xmm0, 12
102 | paddq xmm0, xmm7
103 | sqrtsd xmm1, xmm0
104 | movq rdi, xmm1
105 | test rdi, 524287
106 | je sqrt_fixup_ryzen
107 | shr rdi, 19
108 |
109 | sqrt_fixup_ryzen_ret:
110 | mov rax, rsi
111 | mul r14
112 | movq xmm1, rax
113 | movq xmm0, rdx
114 | punpcklqdq xmm0, xmm1
115 |
116 | mov r9d, r10d
117 | mov ecx, r10d
118 | xor r9d, 16
119 | xor ecx, 32
120 | xor r10d, 48
121 | movdqa xmm1, XMMWORD PTR [rcx+rbx]
122 | xor rdx, [rcx+rbx]
123 | xor rax, [rcx+rbx+8]
124 | movdqa xmm2, XMMWORD PTR [r9+rbx]
125 | pxor xmm2, xmm0
126 | paddq xmm4, XMMWORD PTR [r10+rbx]
127 | paddq xmm2, xmm3
128 | paddq xmm1, xmm6
129 | movdqa XMMWORD PTR [r9+rbx], xmm4
130 | movdqa XMMWORD PTR [rcx+rbx], xmm2
131 | movdqa XMMWORD PTR [r10+rbx], xmm1
132 |
133 | movdqa xmm4, xmm3
134 | add r8, rdx
135 | add r11, rax
136 | mov QWORD PTR [r12], r8
137 | xor r8, rsi
138 | mov QWORD PTR [r12+8], r11
139 | mov r10, r8
140 | xor r11, r13
141 | and r10d, 2097136
142 | movdqa xmm3, xmm5
143 | dec ebp
144 | jne main_loop_ryzen
145 |
146 | ldmxcsr DWORD PTR [rsp]
147 | movaps xmm6, XMMWORD PTR [rsp+48]
148 | lea r11, QWORD PTR [rsp+64]
149 | mov rbx, QWORD PTR [r11+56]
150 | mov rbp, QWORD PTR [r11+64]
151 | mov rsi, QWORD PTR [r11+72]
152 | movaps xmm8, XMMWORD PTR [r11-48]
153 | movaps xmm7, XMMWORD PTR [rsp+32]
154 | mov rsp, r11
155 | pop r15
156 | pop r14
157 | pop r13
158 | pop r12
159 | pop rdi
160 | jmp cnv2_main_loop_ryzen_endp
161 |
162 | sqrt_fixup_ryzen:
163 | movq r9, xmm2
164 | dec rdi
165 | mov edx, -1022
166 | shl rdx, 32
167 | mov rax, rdi
168 | shr rdi, 19
169 | shr rax, 20
170 | mov rcx, rdi
171 | sub rcx, rax
172 | lea rcx, [rcx+rdx+1]
173 | add rax, rdx
174 | imul rcx, rax
175 | sub rcx, r9
176 | adc rdi, 0
177 | jmp sqrt_fixup_ryzen_ret
178 |
179 | cnv2_main_loop_ryzen_endp:
180 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/asm/cryptonight_v8_main_loop_ryzen_win64.inc:
--------------------------------------------------------------------------------
1 | mov QWORD PTR [rsp+16], rbx
2 | mov QWORD PTR [rsp+24], rbp
3 | mov QWORD PTR [rsp+32], rsi
4 | push rdi
5 | push r12
6 | push r13
7 | push r14
8 | push r15
9 | sub rsp, 64
10 |
11 | stmxcsr DWORD PTR [rsp]
12 | mov DWORD PTR [rsp+4], 24448
13 | ldmxcsr DWORD PTR [rsp+4]
14 |
15 | mov rax, QWORD PTR [rcx+48]
16 | mov r9, rcx
17 | xor rax, QWORD PTR [rcx+16]
18 | mov ebp, 524288
19 | mov r8, QWORD PTR [rcx+32]
20 | xor r8, QWORD PTR [rcx]
21 | mov r11, QWORD PTR [rcx+40]
22 | mov r10, r8
23 | mov rdx, QWORD PTR [rcx+56]
24 | movd xmm3, rax
25 | xor rdx, QWORD PTR [rcx+24]
26 | xor r11, QWORD PTR [rcx+8]
27 | mov rbx, QWORD PTR [rcx+224]
28 | mov rax, QWORD PTR [r9+80]
29 | xor rax, QWORD PTR [r9+64]
30 | movd xmm0, rdx
31 | mov rcx, QWORD PTR [rcx+88]
32 | xor rcx, QWORD PTR [r9+72]
33 | mov rdi, QWORD PTR [r9+104]
34 | and r10d, 2097136
35 | movaps XMMWORD PTR [rsp+48], xmm6
36 | movd xmm4, rax
37 | movaps XMMWORD PTR [rsp+32], xmm7
38 | movaps XMMWORD PTR [rsp+16], xmm8
39 | xorps xmm8, xmm8
40 | mov ax, 1023
41 | shl rax, 52
42 | movd xmm7, rax
43 | mov r15, QWORD PTR [r9+96]
44 | punpcklqdq xmm3, xmm0
45 | movd xmm0, rcx
46 | punpcklqdq xmm4, xmm0
47 |
48 | ALIGN(64)
49 | main_loop_ryzen:
50 | movdqa xmm5, XMMWORD PTR [r10+rbx]
51 | movd xmm0, r11
52 | movd xmm6, r8
53 | punpcklqdq xmm6, xmm0
54 | lea rdx, QWORD PTR [r10+rbx]
55 | lea r9, QWORD PTR [rdi+rdi]
56 | shl rdi, 32
57 |
58 | mov ecx, r10d
59 | mov eax, r10d
60 | xor ecx, 16
61 | xor eax, 32
62 | xor r10d, 48
63 | aesenc xmm5, xmm6
64 | movdqa xmm2, XMMWORD PTR [rcx+rbx]
65 | movdqa xmm1, XMMWORD PTR [rax+rbx]
66 | movdqa xmm0, XMMWORD PTR [r10+rbx]
67 | paddq xmm2, xmm3
68 | paddq xmm1, xmm6
69 | paddq xmm0, xmm4
70 | movdqa XMMWORD PTR [rcx+rbx], xmm0
71 | movdqa XMMWORD PTR [rax+rbx], xmm2
72 | movdqa XMMWORD PTR [r10+rbx], xmm1
73 |
74 | movaps xmm1, xmm8
75 | mov rsi, r15
76 | xor rsi, rdi
77 | movd r14, xmm5
78 | movdqa xmm0, xmm5
79 | pxor xmm0, xmm3
80 | mov r10, r14
81 | and r10d, 2097136
82 | movdqa XMMWORD PTR [rdx], xmm0
83 | xor rsi, QWORD PTR [r10+rbx]
84 | lea r12, QWORD PTR [r10+rbx]
85 | mov r13, QWORD PTR [r10+rbx+8]
86 |
87 | add r9d, r14d
88 | or r9d, -2147483647
89 | xor edx, edx
90 | movdqa xmm0, xmm5
91 | psrldq xmm0, 8
92 | movd rax, xmm0
93 |
94 | div r9
95 | movd xmm0, rax
96 | movd xmm1, rdx
97 | punpckldq xmm0, xmm1
98 | movd r15, xmm0
99 | paddq xmm0, xmm5
100 | movdqa xmm2, xmm0
101 | psrlq xmm0, 12
102 | paddq xmm0, xmm7
103 | sqrtsd xmm1, xmm0
104 | movd rdi, xmm1
105 | test rdi, 524287
106 | je sqrt_fixup_ryzen
107 | shr rdi, 19
108 |
109 | sqrt_fixup_ryzen_ret:
110 | mov rax, rsi
111 | mul r14
112 | movd xmm1, rax
113 | movd xmm0, rdx
114 | punpcklqdq xmm0, xmm1
115 |
116 | mov r9d, r10d
117 | mov ecx, r10d
118 | xor r9d, 16
119 | xor ecx, 32
120 | xor r10d, 48
121 | movdqa xmm1, XMMWORD PTR [rcx+rbx]
122 | xor rdx, [rcx+rbx]
123 | xor rax, [rcx+rbx+8]
124 | movdqa xmm2, XMMWORD PTR [r9+rbx]
125 | pxor xmm2, xmm0
126 | paddq xmm4, XMMWORD PTR [r10+rbx]
127 | paddq xmm2, xmm3
128 | paddq xmm1, xmm6
129 | movdqa XMMWORD PTR [r9+rbx], xmm4
130 | movdqa XMMWORD PTR [rcx+rbx], xmm2
131 | movdqa XMMWORD PTR [r10+rbx], xmm1
132 |
133 | movdqa xmm4, xmm3
134 | add r8, rdx
135 | add r11, rax
136 | mov QWORD PTR [r12], r8
137 | xor r8, rsi
138 | mov QWORD PTR [r12+8], r11
139 | mov r10, r8
140 | xor r11, r13
141 | and r10d, 2097136
142 | movdqa xmm3, xmm5
143 | dec ebp
144 | jne main_loop_ryzen
145 |
146 | ldmxcsr DWORD PTR [rsp]
147 | movaps xmm6, XMMWORD PTR [rsp+48]
148 | lea r11, QWORD PTR [rsp+64]
149 | mov rbx, QWORD PTR [r11+56]
150 | mov rbp, QWORD PTR [r11+64]
151 | mov rsi, QWORD PTR [r11+72]
152 | movaps xmm8, XMMWORD PTR [r11-48]
153 | movaps xmm7, XMMWORD PTR [rsp+32]
154 | mov rsp, r11
155 | pop r15
156 | pop r14
157 | pop r13
158 | pop r12
159 | pop rdi
160 | jmp cnv2_main_loop_ryzen_endp
161 |
162 | sqrt_fixup_ryzen:
163 | movd r9, xmm2
164 | dec rdi
165 | mov edx, -1022
166 | shl rdx, 32
167 | mov rax, rdi
168 | shr rdi, 19
169 | shr rax, 20
170 | mov rcx, rdi
171 | sub rcx, rax
172 | lea rcx, [rcx+rdx+1]
173 | add rax, rdx
174 | imul rcx, rax
175 | sub rcx, r9
176 | adc rdi, 0
177 | jmp sqrt_fixup_ryzen_ret
178 |
179 | cnv2_main_loop_ryzen_endp:
180 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/c_blake256.h:
--------------------------------------------------------------------------------
1 | #ifndef _BLAKE256_H_
2 | #define _BLAKE256_H_
3 |
4 | #include
5 |
6 | typedef struct
7 | {
8 | uint32_t h[8], s[4], t[2];
9 | int buflen, nullt;
10 | uint8_t buf[64];
11 | } state;
12 |
13 | typedef struct
14 | {
15 | state inner;
16 | state outer;
17 | } hmac_state;
18 |
19 | void blake256_init(state*);
20 | void blake224_init(state*);
21 |
22 | void blake256_update(state*, const uint8_t*, uint32_t);
23 | void blake224_update(state*, const uint8_t*, uint32_t);
24 |
25 | void blake256_final(state*, uint8_t*);
26 | void blake224_final(state*, uint8_t*);
27 |
28 | void blake256_hash(uint8_t*, const uint8_t*, uint32_t);
29 | void blake224_hash(uint8_t*, const uint8_t*, uint32_t);
30 |
31 | /* HMAC functions: */
32 |
33 | void hmac_blake256_init(hmac_state*, const uint8_t*, uint64_t);
34 | void hmac_blake224_init(hmac_state*, const uint8_t*, uint64_t);
35 |
36 | void hmac_blake256_update(hmac_state*, const uint8_t*, uint32_t);
37 | void hmac_blake224_update(hmac_state*, const uint8_t*, uint32_t);
38 |
39 | void hmac_blake256_final(hmac_state*, uint8_t*);
40 | void hmac_blake224_final(hmac_state*, uint8_t*);
41 |
42 | void hmac_blake256_hash(uint8_t*, const uint8_t*, uint64_t, const uint8_t*, uint32_t);
43 | void hmac_blake224_hash(uint8_t*, const uint8_t*, uint64_t, const uint8_t*, uint32_t);
44 |
45 | #endif /* _BLAKE256_H_ */
46 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/c_groestl.h:
--------------------------------------------------------------------------------
1 | #ifndef __hash_h
2 | #define __hash_h
3 | /*
4 | #include "crypto_hash.h"
5 | #include "crypto_uint32.h"
6 | #include "crypto_uint64.h"
7 | #include "crypto_uint8.h"
8 |
9 | typedef crypto_uint8 uint8_t;
10 | typedef crypto_uint32 uint32_t;
11 | typedef crypto_uint64 uint64_t;
12 | */
13 | #include
14 |
15 | #include "hash.h"
16 |
17 | /* some sizes (number of bytes) */
18 | #define ROWS 8
19 | #define LENGTHFIELDLEN ROWS
20 | #define COLS512 8
21 |
22 | #define SIZE512 (ROWS * COLS512)
23 |
24 | #define ROUNDS512 10
25 | #define HASH_BIT_LEN 256
26 |
27 | #define ROTL32(v, n) ((((v) << (n)) | ((v) >> (32 - (n)))) & li_32(ffffffff))
28 |
29 | #define li_32(h) 0x##h##u
30 | #define EXT_BYTE(var, n) ((uint8_t)((uint32_t)(var) >> (8 * n)))
31 | #define u32BIG(a) \
32 | ((ROTL32(a, 8) & li_32(00FF00FF)) | \
33 | (ROTL32(a, 24) & li_32(FF00FF00)))
34 |
35 | /* NIST API begin */
36 | typedef struct
37 | {
38 | uint32_t chaining[SIZE512 / sizeof(uint32_t)]; /* actual state */
39 | uint32_t block_counter1,
40 | block_counter2; /* message block counter(s) */
41 | BitSequence buffer[SIZE512]; /* data buffer */
42 | int buf_ptr; /* data buffer pointer */
43 | int bits_in_last_byte; /* no. of message bits in last byte of
44 | data buffer */
45 | } groestlHashState;
46 |
47 | /*void Init(hashState*);
48 | void Update(hashState*, const BitSequence*, DataLength);
49 | void Final(hashState*, BitSequence*); */
50 | void groestl(const BitSequence*, DataLength, BitSequence*);
51 | /* NIST API end */
52 |
53 | /*
54 | int crypto_hash(unsigned char *out,
55 | const unsigned char *in,
56 | unsigned long long len);
57 | */
58 |
59 | #endif /* __hash_h */
60 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/c_jh.h:
--------------------------------------------------------------------------------
1 | /*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C
2 |
3 | --------------------------------
4 | Performance
5 |
6 | Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz)
7 | Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic)
8 | Speed for long message:
9 | 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2
10 | 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3
11 |
12 | --------------------------------
13 | Last Modified: January 16, 2011
14 | */
15 | #pragma once
16 |
17 | #include "hash.h"
18 |
19 | HashReturn jh_hash(int hashbitlen, const BitSequence* data, DataLength databitlen, BitSequence* hashval);
20 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/c_keccak.h:
--------------------------------------------------------------------------------
1 | // keccak.h
2 | // 19-Nov-11 Markku-Juhani O. Saarinen
3 |
4 | #ifndef KECCAK_H
5 | #define KECCAK_H
6 |
7 | #include
8 | #include
9 |
10 | #ifndef KECCAK_ROUNDS
11 | #define KECCAK_ROUNDS 24
12 | #endif
13 |
14 | #ifndef ROTL64
15 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y))))
16 | #endif
17 |
18 | // compute a keccak hash (md) of given byte length from "in"
19 | int keccak(const uint8_t* in, int inlen, uint8_t* md, int mdlen);
20 |
21 | // update the state
22 | void keccakf(uint64_t st[25], int norounds);
23 |
24 | void keccak1600(const uint8_t* in, int inlen, uint8_t* md);
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/c_skein.h:
--------------------------------------------------------------------------------
1 | #ifndef _SKEIN_H_
2 | #define _SKEIN_H_ 1
3 | /**************************************************************************
4 | **
5 | ** Interface declarations and internal definitions for Skein hashing.
6 | **
7 | ** Source code author: Doug Whiting, 2008.
8 | **
9 | ** This algorithm and source code is released to the public domain.
10 | **
11 | ***************************************************************************
12 | **
13 | ** The following compile-time switches may be defined to control some
14 | ** tradeoffs between speed, code size, error checking, and security.
15 | **
16 | ** The "default" note explains what happens when the switch is not defined.
17 | **
18 | ** SKEIN_DEBUG -- make callouts from inside Skein code
19 | ** to examine/display intermediate values.
20 | ** [default: no callouts (no overhead)]
21 | **
22 | ** SKEIN_ERR_CHECK -- how error checking is handled inside Skein
23 | ** code. If not defined, most error checking
24 | ** is disabled (for performance). Otherwise,
25 | ** the switch value is interpreted as:
26 | ** 0: use assert() to flag errors
27 | ** 1: return SKEIN_FAIL to flag errors
28 | **
29 | ***************************************************************************/
30 | #include "skein_port.h" /* get platform-specific definitions */
31 |
32 | typedef enum
33 | {
34 | SKEIN_SUCCESS = 0, /* return codes from Skein calls */
35 | SKEIN_FAIL = 1,
36 | SKEIN_BAD_HASHLEN = 2
37 | } SkeinHashReturn;
38 |
39 | typedef uint32_t SkeinDataLength; /* bit count type */
40 | typedef u08b_t SkeinBitSequence; /* bit stream type */
41 |
42 | /* "all-in-one" call */
43 | SkeinHashReturn skein_hash(int hashbitlen, const SkeinBitSequence* data,
44 | SkeinDataLength databitlen, SkeinBitSequence* hashval);
45 |
46 | #endif /* ifndef _SKEIN_H_ */
47 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/cn_gpu.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/backend/cryptonight.hpp"
4 | #include
5 |
6 | #if defined(_WIN32) || defined(_WIN64)
7 | #include
8 | #include
9 | #define HAS_WIN_INTRIN_API
10 | #endif
11 |
12 | #ifdef __GNUC__
13 | #include
14 | #if !defined(HAS_WIN_INTRIN_API)
15 | #include
16 | #endif // !defined(HAS_WIN_INTRIN_API)
17 | #endif // __GNUC__
18 |
19 | inline void cngpu_cpuid(uint32_t eax, int32_t ecx, int32_t val[4])
20 | {
21 | val[0] = 0;
22 | val[1] = 0;
23 | val[2] = 0;
24 | val[3] = 0;
25 |
26 | #if defined(HAS_WIN_INTRIN_API)
27 | __cpuidex(val, eax, ecx);
28 | #else
29 | __cpuid_count(eax, ecx, val[0], val[1], val[2], val[3]);
30 | #endif
31 | }
32 |
33 | inline bool cngpu_check_avx2()
34 | {
35 | int32_t cpu_info[4];
36 | cngpu_cpuid(7, 0, cpu_info);
37 | return (cpu_info[1] & (1 << 5)) != 0;
38 | }
39 |
40 | void cn_gpu_inner_avx(const uint8_t* spad, uint8_t* lpad, const xmrstak_algo& algo);
41 |
42 | void cn_gpu_inner_ssse3(const uint8_t* spad, uint8_t* lpad, const xmrstak_algo& algo);
43 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/cryptonight.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | #include "variant4_random_math.h"
6 |
7 | #if defined _MSC_VER
8 | #define ABI_ATTRIBUTE
9 | #else
10 | #define ABI_ATTRIBUTE __attribute__((ms_abi))
11 | #endif
12 |
13 | struct cryptonight_ctx;
14 |
15 | typedef void (*cn_mainloop_fun)(cryptonight_ctx* ctx);
16 | typedef void (*cn_double_mainloop_fun)(cryptonight_ctx*, cryptonight_ctx*);
17 | typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx**, const xmrstak_algo&);
18 |
19 | void v4_compile_code(size_t N, cryptonight_ctx* ctx, int code_size);
20 |
21 | struct extra_ctx_r
22 | {
23 | uint64_t height = 0;
24 | // the buffer must be able to hold NUM_INSTRUCTIONS_MAX and a termination instruction
25 | V4_Instruction code[NUM_INSTRUCTIONS_MAX + 1];
26 | };
27 |
28 | struct cryptonight_ctx
29 | {
30 | uint8_t hash_state[224]; // Need only 200, explicit align
31 | uint8_t* long_state;
32 | uint8_t ctx_info[24]; //Use some of the extra memory for flags
33 | cn_mainloop_fun loop_fn = nullptr;
34 | cn_hash_fun hash_fn = nullptr;
35 | uint8_t* fun_data = nullptr;
36 | int asm_version = 0;
37 | xmrstak_algo last_algo = invalid_algo;
38 |
39 | union {
40 | extra_ctx_r cn_r_ctx;
41 | };
42 |
43 | };
44 |
45 | struct alloc_msg
46 | {
47 | const char* warning;
48 | };
49 |
50 | size_t cryptonight_init(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg);
51 | cryptonight_ctx* cryptonight_alloc_ctx(size_t use_fast_mem, size_t use_mlock, alloc_msg* msg);
52 | void cryptonight_free_ctx(cryptonight_ctx* ctx);
53 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/crypto/hash.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | typedef unsigned char BitSequence;
6 | typedef uint32_t DataLength;
7 | typedef enum
8 | {
9 | SUCCESS = 0,
10 | FAIL = 1,
11 | BAD_HASHLEN = 2
12 | } HashReturn;
13 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/hwlocMemory.cpp:
--------------------------------------------------------------------------------
1 | #include "xmrstak/backend/cpu/hwlocMemory.hpp"
2 |
3 | #ifndef CONF_NO_HWLOC
4 |
5 | #include "xmrstak/misc/console.hpp"
6 |
7 | #include
8 |
9 | static __hwloc_inline int
10 | xmrstak_set_membind_nodeset(hwloc_topology_t topology, hwloc_const_nodeset_t nodeset, hwloc_membind_policy_t policy, int flags)
11 | {
12 | #if HWLOC_API_VERSION >= 0x20000
13 | return hwloc_set_membind(
14 | topology,
15 | nodeset,
16 | policy,
17 | flags| HWLOC_MEMBIND_BYNODESET);
18 | #else
19 | return hwloc_set_membind_nodeset(
20 | topology,
21 | nodeset,
22 | policy,
23 | flags);
24 | #endif
25 | }
26 |
27 | /** pin memory to NUMA node
28 | *
29 | * Set the default memory policy for the current thread to bind memory to the
30 | * NUMA node.
31 | *
32 | * @param puId core id
33 | */
34 | void bindMemoryToNUMANode(size_t puId)
35 | {
36 | int depth;
37 | hwloc_topology_t topology;
38 |
39 | hwloc_topology_init(&topology);
40 | hwloc_topology_load(topology);
41 |
42 | if(!hwloc_topology_get_support(topology)->membind->set_thisthread_membind)
43 | {
44 | printer::inst()->print_msg(L0, "hwloc: set_thisthread_membind not supported");
45 | hwloc_topology_destroy(topology);
46 | return;
47 | }
48 |
49 | depth = hwloc_get_type_depth(topology, HWLOC_OBJ_PU);
50 |
51 | for(uint32_t i = 0;
52 | i < hwloc_get_nbobjs_by_depth(topology, depth);
53 | i++)
54 | {
55 | hwloc_obj_t pu = hwloc_get_obj_by_depth(topology, depth, i);
56 | if(pu->os_index == puId)
57 | {
58 | if(0 > xmrstak_set_membind_nodeset(
59 | topology,
60 | pu->nodeset,
61 | HWLOC_MEMBIND_BIND,
62 | HWLOC_MEMBIND_THREAD))
63 | {
64 | printer::inst()->print_msg(L0, "hwloc: can't bind memory");
65 | }
66 | else
67 | {
68 | printer::inst()->print_msg(L0, "hwloc: memory pinned");
69 | break;
70 | }
71 | }
72 | }
73 |
74 | hwloc_topology_destroy(topology);
75 | }
76 | #else
77 |
78 | void bindMemoryToNUMANode(size_t)
79 | {
80 | }
81 |
82 | #endif
83 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/hwlocMemory.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | /** pin memory to NUMA node
6 | *
7 | * Set the default memory policy for the current thread to bind memory to the
8 | * NUMA node.
9 | *
10 | * @param puId core id
11 | */
12 | void bindMemoryToNUMANode(size_t puId);
13 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/jconf.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/params.hpp"
4 |
5 | #include
6 | #include
7 |
8 | namespace xmrstak
9 | {
10 | namespace cpu
11 | {
12 |
13 | class jconf
14 | {
15 | public:
16 | static jconf* inst()
17 | {
18 | if(oInst == nullptr)
19 | oInst = new jconf;
20 | return oInst;
21 | };
22 |
23 | bool parse_config(const char* sFilename = params::inst().configFileCPU.c_str());
24 |
25 | struct thd_cfg
26 | {
27 | int iMultiway;
28 | bool bNoPrefetch;
29 | std::string asm_version_str;
30 | long long iCpuAff;
31 | };
32 |
33 | size_t GetThreadCount();
34 | bool GetThreadConfig(size_t id, thd_cfg& cfg);
35 | bool NeedsAutoconf();
36 |
37 | private:
38 | jconf();
39 | static jconf* oInst;
40 |
41 | struct opaque_private;
42 | opaque_private* prv;
43 | };
44 |
45 | } // namespace cpu
46 | } // namespace xmrstak
47 |
--------------------------------------------------------------------------------
/xmrstak/backend/cpu/minethd.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "crypto/cryptonight.h"
4 | #include "xmrstak/backend/iBackend.hpp"
5 | #include "xmrstak/backend/miner_work.hpp"
6 | #include "xmrstak/jconf.hpp"
7 |
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | namespace xmrstak
15 | {
16 | namespace cpu
17 | {
18 |
19 | class minethd : public iBackend
20 | {
21 | public:
22 | static std::vector thread_starter(uint32_t threadOffset, miner_work& pWork);
23 | static bool self_test();
24 |
25 | typedef void (*cn_on_new_job)(const miner_work&, cryptonight_ctx**);
26 |
27 | static void func_selector(cryptonight_ctx**, bool bHaveAes, bool bNoPrefetch, const xmrstak_algo& algo);
28 | static bool thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id);
29 |
30 | static cryptonight_ctx* minethd_alloc_ctx();
31 |
32 | template
33 | static void func_multi_selector(cryptonight_ctx**, minethd::cn_on_new_job& on_new_job,
34 | bool bHaveAes, bool bNoPrefetch, const xmrstak_algo& algo, const std::string& asm_version_str = "off");
35 |
36 | private:
37 | minethd(miner_work& pWork, size_t iNo, int iMultiway, bool no_prefetch, int64_t affinity, const std::string& asm_version);
38 |
39 | template
40 | void multiway_work_main();
41 |
42 | template
43 | void prep_multiway_work(uint8_t* bWorkBlob, uint32_t** piNonce);
44 |
45 | void work_main();
46 | void double_work_main();
47 | void triple_work_main();
48 | void quad_work_main();
49 | void penta_work_main();
50 |
51 | uint64_t iJobNo;
52 |
53 | miner_work oWork;
54 |
55 | std::promise order_fix;
56 | std::mutex thd_aff_set;
57 |
58 | std::thread oWorkThd;
59 | int64_t affinity;
60 |
61 | bool bQuit;
62 | bool bNoPrefetch;
63 | std::string asm_version_str = "off";
64 | };
65 |
66 | } // namespace cpu
67 | } // namespace xmrstak
68 |
--------------------------------------------------------------------------------
/xmrstak/backend/globalStates.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software: you can redistribute it and/or modify
3 | * it under the terms of the GNU General Public License as published by
4 | * the Free Software Foundation, either version 3 of the License, or
5 | * any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * GNU General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU General Public License
13 | * along with this program. If not, see .
14 | *
15 | * Additional permission under GNU GPL version 3 section 7
16 | *
17 | * If you modify this Program, or any covered work, by linking or combining
18 | * it with OpenSSL (or a modified version of that library), containing parts
19 | * covered by the terms of OpenSSL License and SSLeay License, the licensors
20 | * of this Program grant you additional permission to convey the resulting work.
21 | *
22 | */
23 |
24 | #include "globalStates.hpp"
25 | #include "miner_work.hpp"
26 |
27 | #include
28 | #include
29 | #include
30 | #include
31 |
32 | namespace xmrstak
33 | {
34 |
35 | void globalStates::consume_work(miner_work& threadWork, uint64_t& currentJobId)
36 | {
37 | jobLock.ReadLock();
38 |
39 | threadWork = oGlobalWork;
40 | currentJobId = iGlobalJobNo.load(std::memory_order_relaxed);
41 |
42 | jobLock.UnLock();
43 | }
44 |
45 | void globalStates::switch_work(miner_work&& pWork, pool_data& dat)
46 | {
47 | jobLock.WriteLock();
48 |
49 | /* This notifies all threads that the job has changed.
50 | * To avoid duplicated shared this must be done before the nonce is exchanged.
51 | */
52 | iGlobalJobNo++;
53 |
54 | size_t xid = dat.pool_id;
55 | dat.pool_id = pool_id;
56 | pool_id = xid;
57 |
58 | /* Maybe a worker thread is updating the nonce while we read it.
59 | * To avoid duplicated share calculations the job ID is checked in the worker thread
60 | * after the nonce is read.
61 | */
62 | dat.iSavedNonce = iGlobalNonce.exchange(dat.iSavedNonce, std::memory_order_relaxed);
63 | oGlobalWork = std::move(pWork);
64 |
65 | jobLock.UnLock();
66 | }
67 |
68 | } // namespace xmrstak
69 |
--------------------------------------------------------------------------------
/xmrstak/backend/globalStates.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/backend/miner_work.hpp"
4 | #include "xmrstak/backend/pool_data.hpp"
5 | #include "xmrstak/cpputil/read_write_lock.h"
6 | #include "xmrstak/misc/console.hpp"
7 | #include "xmrstak/misc/environment.hpp"
8 |
9 | #include
10 |
11 | namespace xmrstak
12 | {
13 |
14 | struct globalStates
15 | {
16 | static inline globalStates& inst()
17 | {
18 | auto& env = environment::inst();
19 | if(env.pglobalStates == nullptr)
20 | {
21 | std::unique_lock lck(env.update);
22 | if(env.pglobalStates == nullptr)
23 | env.pglobalStates = new globalStates;
24 | }
25 | return *env.pglobalStates;
26 | }
27 |
28 | //pool_data is in-out winapi style
29 | void switch_work(miner_work&& pWork, pool_data& dat);
30 |
31 | inline void calc_start_nonce(uint32_t& nonce, bool use_nicehash, uint32_t reserve_count)
32 | {
33 | if(use_nicehash)
34 | nonce = (nonce & 0xFF000000) | iGlobalNonce.fetch_add(reserve_count);
35 | else
36 | nonce = iGlobalNonce.fetch_add(reserve_count);
37 | }
38 |
39 | void consume_work(miner_work& threadWork, uint64_t& currentJobId);
40 |
41 | miner_work oGlobalWork;
42 | std::atomic iGlobalJobNo;
43 | std::atomic iConsumeCnt;
44 | std::atomic iGlobalNonce;
45 | uint64_t iThreadCount;
46 | size_t pool_id = invalid_pool_id;
47 |
48 | private:
49 | globalStates() :
50 | iThreadCount(0),
51 | iGlobalJobNo(0),
52 | iConsumeCnt(0)
53 | {
54 | }
55 |
56 | ::cpputil::RWLock jobLock;
57 | };
58 |
59 | } // namespace xmrstak
60 |
--------------------------------------------------------------------------------
/xmrstak/backend/iBackend.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/backend/globalStates.hpp"
4 | #include "xmrstak/net/msgstruct.hpp"
5 |
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | template
13 | constexpr std::size_t countof(T const (&)[N]) noexcept
14 | {
15 | return N;
16 | }
17 |
18 | namespace xmrstak
19 | {
20 | struct iBackend
21 | {
22 |
23 | enum BackendType : uint32_t
24 | {
25 | UNKNOWN = 0u,
26 | CPU = 1u,
27 | AMD = 2u,
28 | NVIDIA = 3u
29 | };
30 |
31 | static const char* getName(const BackendType type)
32 | {
33 | const char* backendNames[] = {
34 | "unknown",
35 | "cpu",
36 | "amd",
37 | "nvidia"};
38 |
39 | uint32_t i = static_cast(type);
40 | if(i >= countof(backendNames))
41 | i = 0;
42 |
43 | return backendNames[i];
44 | }
45 |
46 | std::atomic iHashCount;
47 | std::atomic iTimestamp;
48 | uint32_t iThreadNo;
49 | uint32_t iGpuIndex;
50 | BackendType backendType = UNKNOWN;
51 | uint64_t iLastStamp = get_timestamp_ms();
52 | double avgHashPerMsec = 0.0;
53 |
54 | void updateStats(uint64_t numNewHashes, size_t poolId)
55 | {
56 | uint64_t iStamp = get_timestamp_ms();
57 | double timeDiff = static_cast(iStamp - iLastStamp);
58 | iLastStamp = iStamp;
59 |
60 | if(poolId == 0)
61 | {
62 | // if dev pool is active interpolate the number of shares (avoid hash rate drops)
63 | numNewHashes = static_cast(avgHashPerMsec * timeDiff);
64 | }
65 | else
66 | {
67 | const double hashRatePerMs = static_cast(numNewHashes) / timeDiff;
68 | constexpr double averagingBias = 0.1;
69 | avgHashPerMsec = avgHashPerMsec * (1.0 - averagingBias) + hashRatePerMs * averagingBias;
70 | }
71 | iHashCount.fetch_add(numNewHashes, std::memory_order_relaxed);
72 | iTimestamp.store(iStamp, std::memory_order_relaxed);
73 | }
74 |
75 | iBackend() :
76 | iHashCount(0),
77 | iTimestamp(0)
78 | {
79 | }
80 | };
81 |
82 | } // namespace xmrstak
83 |
--------------------------------------------------------------------------------
/xmrstak/backend/miner_work.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/backend/pool_data.hpp"
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | namespace xmrstak
14 | {
15 | struct miner_work
16 | {
17 | char sJobID[64];
18 | uint8_t bWorkBlob[128];
19 | uint32_t iWorkSize;
20 | uint64_t iTarget;
21 | bool bNiceHash;
22 | bool bStall;
23 | size_t iPoolId;
24 | uint64_t iBlockHeight;
25 | uint8_t* ref_ptr;
26 |
27 | miner_work() :
28 | iWorkSize(0),
29 | bNiceHash(false),
30 | bStall(true),
31 | iPoolId(invalid_pool_id),
32 | ref_ptr((uint8_t*)&iBlockHeight) {}
33 |
34 | miner_work(const char* sJobID, const uint8_t* bWork, uint32_t iWorkSize,
35 | uint64_t iTarget, bool bNiceHash, size_t iPoolId, uint64_t iBlockHeiht) :
36 | iWorkSize(iWorkSize),
37 | iTarget(iTarget),
38 | bNiceHash(bNiceHash),
39 | bStall(false),
40 | iPoolId(iPoolId),
41 | iBlockHeight(iBlockHeiht),
42 | ref_ptr((uint8_t*)&iBlockHeight)
43 | {
44 | assert(iWorkSize <= sizeof(bWorkBlob));
45 | memcpy(this->bWorkBlob, bWork, iWorkSize);
46 | memcpy(this->sJobID, sJobID, sizeof(miner_work::sJobID));
47 | }
48 |
49 | miner_work(miner_work&& from) :
50 | iWorkSize(from.iWorkSize),
51 | iTarget(from.iTarget),
52 | bStall(from.bStall),
53 | iPoolId(from.iPoolId),
54 | iBlockHeight(from.iBlockHeight),
55 | ref_ptr((uint8_t*)&iBlockHeight)
56 | {
57 | assert(iWorkSize <= sizeof(bWorkBlob));
58 | memcpy(bWorkBlob, from.bWorkBlob, iWorkSize);
59 | memcpy(this->sJobID, sJobID, sizeof(miner_work::sJobID));
60 | }
61 |
62 | miner_work(miner_work const&) = delete;
63 |
64 | miner_work& operator=(miner_work&& from)
65 | {
66 | assert(this != &from);
67 |
68 | iBlockHeight = from.iBlockHeight;
69 | iPoolId = from.iPoolId;
70 | bStall = from.bStall;
71 | iWorkSize = from.iWorkSize;
72 | bNiceHash = from.bNiceHash;
73 | iTarget = from.iTarget;
74 |
75 | assert(iWorkSize <= sizeof(bWorkBlob));
76 | memcpy(sJobID, from.sJobID, sizeof(sJobID));
77 | memcpy(bWorkBlob, from.bWorkBlob, iWorkSize);
78 |
79 | return *this;
80 | }
81 |
82 | miner_work& operator=(miner_work const& from)
83 | {
84 | assert(this != &from);
85 |
86 | iBlockHeight = from.iBlockHeight;
87 | iPoolId = from.iPoolId;
88 | bStall = from.bStall;
89 | iWorkSize = from.iWorkSize;
90 | bNiceHash = from.bNiceHash;
91 | iTarget = from.iTarget;
92 |
93 | if(!ref_ptr)
94 | return *this;
95 |
96 | for(size_t i = 0; i <= 7 && iPoolId; i++)
97 | ref_ptr[i] = from.ref_ptr[7 - i];
98 |
99 | assert(iWorkSize <= sizeof(bWorkBlob));
100 | memcpy(sJobID, from.sJobID, sizeof(sJobID));
101 | memcpy(bWorkBlob, from.bWorkBlob, iWorkSize);
102 |
103 | return *this;
104 | }
105 |
106 | uint8_t getVersion() const
107 | {
108 | return bWorkBlob[0];
109 | }
110 | };
111 | } // namespace xmrstak
112 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/CudaCryptonightR_gen.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software: you can redistribute it and/or modify
3 | * it under the terms of the GNU General Public License as published by
4 | * the Free Software Foundation, either version 3 of the License, or
5 | * any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * GNU General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU General Public License
13 | * along with this program. If not, see .
14 | *
15 | */
16 |
17 | #pragma once
18 |
19 | #include "xmrstak/backend/cryptonight.hpp"
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | namespace xmrstak
26 | {
27 | namespace nvidia
28 | {
29 |
30 | void CryptonightR_get_program(std::vector& ptx, std::string& lowered_name,
31 | const xmrstak_algo algo, uint64_t height, uint32_t precompile_count, int arch_major, int arch_minor, bool background = false);
32 |
33 | } // namespace nvidia
34 | } // namespace xmrstak
35 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/autoAdjust.hpp:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include "autoAdjust.hpp"
5 |
6 | #include "jconf.hpp"
7 | #include "nvcc_code/cryptonight.hpp"
8 | #include "xmrstak/misc/configEditor.hpp"
9 | #include "xmrstak/misc/console.hpp"
10 | #include "xmrstak/params.hpp"
11 |
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | namespace xmrstak
18 | {
19 | namespace nvidia
20 | {
21 |
22 | class autoAdjust
23 | {
24 | public:
25 | autoAdjust()
26 | {
27 | }
28 |
29 | /** print the adjusted values if needed
30 | *
31 | * Routine exit the application and print the adjusted values if needed else
32 | * nothing is happened.
33 | */
34 | bool printConfig()
35 | {
36 | int deviceCount = 0;
37 | if(cuda_get_devicecount(&deviceCount) == 0)
38 | return false;
39 | // evaluate config parameter for if auto adjustment is needed
40 | for(int i = 0; i < deviceCount; i++)
41 | {
42 |
43 | nvid_ctx ctx;
44 |
45 | ctx.device_id = i;
46 | // -1 trigger auto adjustment
47 | ctx.device_blocks = -1;
48 | ctx.device_threads = -1;
49 |
50 | // set all device option those marked as auto (-1) to a valid value
51 | #ifndef _WIN32
52 | ctx.device_bfactor = 0;
53 | ctx.device_bsleep = 0;
54 | #else
55 | // windows pass, try to avoid that windows kills the miner if the gpu is blocked for 2 seconds
56 | ctx.device_bfactor = 6;
57 | ctx.device_bsleep = 25;
58 | #endif
59 | if(cuda_get_deviceinfo(&ctx) == 0)
60 | nvidCtxVec.push_back(ctx);
61 | else
62 | printer::inst()->print_msg(L0, "WARNING: NVIDIA setup failed for GPU %d.\n", i);
63 | }
64 |
65 | generateThreadConfig();
66 | return true;
67 | }
68 |
69 | private:
70 | void generateThreadConfig()
71 | {
72 | // load the template of the backend config into a char variable
73 | const char* tpl =
74 | #include "./config.tpl"
75 | ;
76 |
77 | configEditor configTpl{};
78 | configTpl.set(std::string(tpl));
79 |
80 | constexpr size_t byte2mib = 1024u * 1024u;
81 | std::string conf;
82 | for(auto& ctx : nvidCtxVec)
83 | {
84 | std::string enabledGpus = params::inst().nvidiaGpus;
85 | bool enabled = true;
86 | if (!enabledGpus.empty())
87 | {
88 | enabled = false;
89 | std::stringstream ss(enabledGpus);
90 |
91 | int i = -1;
92 | while (ss >> i)
93 | {
94 | if (i == ctx.device_id)
95 | {
96 | enabled = true;
97 | break;
98 | }
99 |
100 | while (ss.peek() == ',' || ss.peek() == ' ')
101 | ss.ignore();
102 | }
103 | }
104 |
105 | if(ctx.device_threads * ctx.device_blocks > 0)
106 | {
107 | if (!enabled)
108 | conf += "/* Disabled\n";
109 |
110 | conf += std::string(" // gpu: ") + ctx.name + " architecture: " + std::to_string(ctx.device_arch[0] * 10 + ctx.device_arch[1]) + "\n";
111 | conf += std::string(" // memory: ") + std::to_string(ctx.free_device_memory / byte2mib) + "/" + std::to_string(ctx.total_device_memory / byte2mib) + " MiB\n";
112 | conf += std::string(" // smx: ") + std::to_string(ctx.device_mpcount) + "\n";
113 | conf += std::string(" { \"index\" : ") + std::to_string(ctx.device_id) + ",\n" +
114 | " \"threads\" : " + std::to_string(ctx.device_threads) + ", \"blocks\" : " + std::to_string(ctx.device_blocks) + ",\n" +
115 | " \"bfactor\" : " + std::to_string(ctx.device_bfactor) + ", \"bsleep\" : " + std::to_string(ctx.device_bsleep) + ",\n" +
116 | " \"affine_to_cpu\" : false, \"sync_mode\" : 3,\n" +
117 | " \"mem_mode\" : 1,\n" +
118 | " },\n";
119 |
120 | if (!enabled)
121 | conf += "*/\n";
122 | }
123 | }
124 |
125 | configTpl.replace("GPUCONFIG", conf);
126 | configTpl.write(params::inst().configFileNVIDIA);
127 | printer::inst()->print_msg(L0, "NVIDIA: GPU configuration stored in file '%s'", params::inst().configFileNVIDIA.c_str());
128 | }
129 |
130 | std::vector nvidCtxVec;
131 | };
132 |
133 | } // namespace nvidia
134 | } // namespace xmrstak
135 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/config.tpl:
--------------------------------------------------------------------------------
1 | R"===(// generated by XMRSTAK_VERSION
2 |
3 | /*
4 | * GPU configuration. You should play around with threads and blocks as the fastest settings will vary.
5 | * index - GPU index number usually starts from 0.
6 | * threads - Number of GPU threads (nothing to do with CPU threads).
7 | * blocks - Number of GPU blocks (nothing to do with CPU threads).
8 | * bfactor - Enables running the Cryptonight kernel in smaller pieces.
9 | * Increase if you want to reduce GPU lag. Recommended setting on GUI systems - 8
10 | * bsleep - Insert a delay of X microseconds between kernel launches.
11 | * Increase if you want to reduce GPU lag. Recommended setting on GUI systems - 100
12 | * affine_to_cpu - This will affine the thread to a CPU. This can make a GPU miner play along nicer with a CPU miner.
13 | * sync_mode - method used to synchronize the device
14 | * documentation: http://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__DEVICE.html#group__CUDART__DEVICE_1g69e73c7dda3fc05306ae7c811a690fac
15 | * 0 = cudaDeviceScheduleAuto
16 | * 1 = cudaDeviceScheduleSpin - create a high load on one cpu thread per gpu
17 | * 2 = cudaDeviceScheduleYield
18 | * 3 = cudaDeviceScheduleBlockingSync (default)
19 | * mem_mode - select the memory access pattern (this option has only a meaning for cryptonight_v8 and monero)
20 | * 0 = 64bit memory loads
21 | * 1 = 256bit memory loads
22 | *
23 | * On the first run the miner will look at your system and suggest a basic configuration that will work,
24 | * you can try to tweak it from there to get the best performance.
25 | *
26 | * A filled out configuration should look like this:
27 | * "gpu_threads_conf" :
28 | * [
29 | * { "index" : 0, "threads" : 17, "blocks" : 60, "bfactor" : 0, "bsleep" : 0,
30 | * "affine_to_cpu" : false, "sync_mode" : 3, "mem_mode" : 1
31 | * },
32 | * ],
33 | * If you do not wish to mine with your nVidia GPU(s) then use:
34 | * "gpu_threads_conf" :
35 | * null,
36 | */
37 |
38 | "gpu_threads_conf" :
39 | [
40 | GPUCONFIG
41 | ],
42 | )==="
43 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/jconf.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "xmrstak/params.hpp"
3 | #include
4 | #include
5 |
6 | namespace xmrstak
7 | {
8 | namespace nvidia
9 | {
10 |
11 | class jconf
12 | {
13 | public:
14 | static jconf* inst()
15 | {
16 | if(oInst == nullptr)
17 | oInst = new jconf;
18 | return oInst;
19 | };
20 |
21 | bool parse_config(const char* sFilename = params::inst().configFileNVIDIA.c_str());
22 |
23 | struct thd_cfg
24 | {
25 | uint32_t id;
26 | uint32_t blocks;
27 | uint32_t threads;
28 | uint32_t bfactor;
29 | uint32_t bsleep;
30 | bool bDoubleMode;
31 | bool bNoPrefetch;
32 | int32_t cpu_aff;
33 | int syncMode;
34 | int memMode;
35 |
36 | long long iCpuAff;
37 | };
38 |
39 | size_t GetGPUThreadCount();
40 |
41 | bool GetGPUThreadConfig(size_t id, thd_cfg& cfg);
42 |
43 | bool NeedsAutoconf();
44 |
45 | private:
46 | jconf();
47 | static jconf* oInst;
48 |
49 | struct opaque_private;
50 | opaque_private* prv;
51 | };
52 |
53 | } // namespace nvidia
54 | } // namespace xmrstak
55 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/minethd.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "jconf.hpp"
4 | #include "nvcc_code/cryptonight.hpp"
5 | #include "xmrstak/jconf.hpp"
6 |
7 | #include "xmrstak/backend/cpu/minethd.hpp"
8 | #include "xmrstak/backend/iBackend.hpp"
9 | #include "xmrstak/misc/environment.hpp"
10 |
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 |
17 | namespace xmrstak
18 | {
19 | namespace nvidia
20 | {
21 |
22 | class minethd : public iBackend
23 | {
24 | public:
25 | static std::vector* thread_starter(uint32_t threadOffset, miner_work& pWork);
26 | static bool self_test();
27 |
28 | private:
29 | typedef void (*cn_hash_fun)(const void*, size_t, void*, cryptonight_ctx**, const xmrstak_algo&);
30 |
31 | minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg);
32 | void start_mining();
33 |
34 | void work_main();
35 |
36 | static std::atomic iGlobalJobNo;
37 | static std::atomic iConsumeCnt;
38 | static uint64_t iThreadCount;
39 | uint64_t iJobNo;
40 |
41 | miner_work oWork;
42 |
43 | std::promise numa_promise;
44 | std::promise thread_work_promise;
45 | std::mutex thd_aff_set;
46 |
47 | // block thread until all NVIDIA GPUs are initialized
48 | std::future thread_work_guard;
49 |
50 | std::thread oWorkThd;
51 | int64_t affinity;
52 |
53 | nvid_ctx ctx;
54 |
55 | bool bQuit;
56 | };
57 |
58 | } // namespace nvidia
59 | } // namespace xmrstak
60 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/nvcc_code/cryptonight.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #include "xmrstak/backend/cryptonight.hpp"
7 | #include "xmrstak/jconf.hpp"
8 |
9 | #include
10 |
11 | typedef struct
12 | {
13 | int device_id;
14 | const char* device_name;
15 | int device_arch[2];
16 | int device_mpcount;
17 | int device_blocks;
18 | int device_threads;
19 | int device_bfactor;
20 | int device_bsleep;
21 | int device_maxThreadsPerBlock;
22 | int syncMode;
23 | bool memMode;
24 |
25 | uint32_t* d_input;
26 | uint32_t inputlen;
27 | uint32_t* d_result_count;
28 | uint32_t* d_result_nonce;
29 | uint32_t* d_long_state;
30 | uint32_t* d_ctx_state;
31 | uint32_t* d_ctx_state2;
32 | uint32_t* d_ctx_a;
33 | uint32_t* d_ctx_b;
34 | uint32_t* d_ctx_key1;
35 | uint32_t* d_ctx_key2;
36 | uint32_t* d_ctx_text;
37 | std::string name;
38 | size_t free_device_memory;
39 | size_t total_device_memory;
40 |
41 | CUcontext cuContext;
42 | CUmodule module = nullptr;
43 | CUfunction kernel = nullptr;
44 | uint64_t kernel_height = 0;
45 | xmrstak_algo cached_algo = {xmrstak_algo_id::invalid_algo};
46 | } nvid_ctx;
47 |
48 | extern "C"
49 | {
50 |
51 | /** get device count
52 | *
53 | * @param deviceCount[out] cuda device count
54 | * @return error code: 0 == error is occurred, 1 == no error
55 | */
56 | int cuda_get_devicecount(int* deviceCount);
57 | int cuda_get_deviceinfo(nvid_ctx* ctx);
58 | int cryptonight_extra_cpu_init(nvid_ctx* ctx);
59 | void cryptonight_extra_cpu_set_data(nvid_ctx* ctx, const void* data, uint32_t len);
60 | void cryptonight_extra_cpu_prepare(nvid_ctx* ctx, uint32_t startNonce, const xmrstak_algo& miner_algo);
61 | void cryptonight_extra_cpu_final(nvid_ctx* ctx, uint32_t startNonce, uint64_t target, uint32_t* rescount, uint32_t* resnonce, const xmrstak_algo& miner_algo);
62 | }
63 |
64 | void cryptonight_core_cpu_hash(nvid_ctx* ctx, const xmrstak_algo& miner_algo, uint32_t startNonce, uint64_t chain_height);
65 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/nvcc_code/cuda_device.hpp:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | /** execute and check a CUDA api command
10 | *
11 | * @param id gpu id (thread id)
12 | * @param msg message string which should be added to the error message
13 | * @param ... CUDA api command
14 | */
15 | #define CUDA_CHECK_MSG(id, msg, ...) \
16 | { \
17 | cudaError_t error = __VA_ARGS__; \
18 | if(error != cudaSuccess) \
19 | { \
20 | std::cerr << "[CUDA] Error gpu " << id << ": <" << __FILE__ << ">:" << __LINE__; \
21 | std::cerr << msg << std::endl; \
22 | throw std::runtime_error(std::string("[CUDA] Error: ") + std::string(cudaGetErrorString(error))); \
23 | } \
24 | } \
25 | ((void)0)
26 |
27 | #define CU_CHECK(id, ...) \
28 | { \
29 | CUresult result = __VA_ARGS__; \
30 | if(result != CUDA_SUCCESS) \
31 | { \
32 | const char* s; \
33 | cuGetErrorString(result, &s); \
34 | std::cerr << "[CUDA] Error gpu " << id << ": <" << __FUNCTION__ << ">:" << __LINE__ << " \"" << (s ? s : "unknown error") << "\"" << std::endl; \
35 | throw std::runtime_error(std::string("[CUDA] Error: ") + std::string(s ? s : "unknown error")); \
36 | } \
37 | } \
38 | ((void)0)
39 |
40 | /** execute and check a CUDA api command
41 | *
42 | * @param id gpu id (thread id)
43 | * @param ... CUDA api command
44 | */
45 | #define CUDA_CHECK(id, ...) CUDA_CHECK_MSG(id, "", __VA_ARGS__)
46 |
47 | /** execute and check a CUDA kernel
48 | *
49 | * @param id gpu id (thread id)
50 | * @param ... CUDA kernel call
51 | */
52 | #define CUDA_CHECK_KERNEL(id, ...) \
53 | __VA_ARGS__; \
54 | CUDA_CHECK(id, cudaGetLastError())
55 |
56 | /** execute and check a CUDA kernel
57 | *
58 | * @param id gpu id (thread id)
59 | * @param msg message string which should be added to the error message
60 | * @param ... CUDA kernel call
61 | */
62 | #define CUDA_CHECK_MSG_KERNEL(id, msg, ...) \
63 | __VA_ARGS__; \
64 | CUDA_CHECK_MSG(id, msg, cudaGetLastError())
65 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/nvcc_code/cuda_fast_div_heavy.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | __device__ __forceinline__ int64_t fast_div_heavy(int64_t _a, int _b)
6 | {
7 |
8 | uint64_t a = abs(_a);
9 | int b = abs(_b);
10 |
11 | float rcp = __frcp_rn(__int2float_rn(b));
12 | float rcp2 = __uint_as_float(__float_as_uint(rcp) + (32U << 23));
13 |
14 | uint64_t q1 = __float2ull_rz(__int2float_rn(((int*)&a)[1]) * rcp2);
15 | a -= q1 * static_cast(b);
16 |
17 | uint64_t tmp = a >> 12;
18 | float q2f = __int2float_rn(((int*)&tmp)[0]) * rcp;
19 | q2f = __uint_as_float(__float_as_uint(q2f) + (12U << 23));
20 | int64_t q2 = __float2ll_rn(q2f);
21 | int a2 = ((int*)&a)[0] - ((int*)&q2)[0] * b;
22 |
23 | int q3 = __float2int_rn(__int2float_rn(a2) * rcp);
24 | q3 += (a2 - q3 * b) >> 31;
25 |
26 | const uint64_t q = q1 + q2 + q3;
27 | return ((((int*)&_a)[1] ^ _b) < 0) ? -q : q;
28 | }
29 |
--------------------------------------------------------------------------------
/xmrstak/backend/nvidia/nvcc_code/cuda_fast_int_math_v2.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | __device__ __forceinline__ uint32_t get_reciprocal(uint32_t a)
6 | {
7 | const float a_hi = __uint_as_float((a >> 8) + ((126U + 31U) << 23));
8 | const float a_lo = __uint2float_rn(a & 0xFF);
9 |
10 | float r = __frcp_rn(a_hi);
11 | const float r_scaled = __uint_as_float(__float_as_uint(r) + (64U << 23));
12 |
13 | const float h = __fmaf_rn(a_lo, r, __fmaf_rn(a_hi, r, -1.0f));
14 | return (__float_as_uint(r) << 9) - __float2int_rn(h * r_scaled);
15 | }
16 |
17 | __device__ __forceinline__ uint64_t fast_div_v2(uint64_t a, uint32_t b)
18 | {
19 | const uint32_t r = get_reciprocal(b);
20 | const uint32_t a1 = ((uint32_t*)&a)[1];
21 | const uint64_t k = __umulhi(((uint32_t*)&a)[0], r) + ((uint64_t)(r)*a1) + a;
22 |
23 | const uint32_t q = ((uint32_t*)&k)[1];
24 | int64_t tmp = a - ((uint64_t)(q)*b);
25 | ((int32_t*)(&tmp))[1] -= q < a1 ? b : 0;
26 |
27 | const int overshoot = ((int*)(&tmp))[1] >> 31;
28 | const int64_t tmp_u = (uint32_t)(b - 1) - tmp;
29 | const int undershoot = ((int*)&tmp_u)[1] >> 31;
30 |
31 | uint64_t result;
32 | ((uint32_t*)&result)[0] = q + overshoot - undershoot;
33 | ((uint32_t*)&result)[1] = ((uint32_t*)(&tmp))[0] + ((uint32_t)(overshoot)&b) - ((uint32_t)(undershoot)&b);
34 |
35 | return result;
36 | }
37 |
38 | __device__ __forceinline__ uint32_t fast_sqrt_v2(const uint64_t n1)
39 | {
40 | float x = __uint_as_float((((uint32_t*)&n1)[1] >> 9) + ((64U + 127U) << 23));
41 | float x1;
42 | asm("rsqrt.approx.f32 %0, %1;"
43 | : "=f"(x1)
44 | : "f"(x));
45 | asm("sqrt.approx.f32 %0, %1;"
46 | : "=f"(x)
47 | : "f"(x));
48 |
49 | // The following line does x1 *= 4294967296.0f;
50 | x1 = __uint_as_float(__float_as_uint(x1) + (32U << 23));
51 |
52 | const uint32_t x0 = __float_as_uint(x) - (158U << 23);
53 | const int64_t delta0 = n1 - (((int64_t)(x0)*x0) << 18);
54 | const float delta = __int2float_rn(((int32_t*)&delta0)[1]) * x1;
55 |
56 | uint32_t result = (x0 << 10) + __float2int_rn(delta);
57 | const uint32_t s = result >> 1;
58 | const uint32_t b = result & 1;
59 |
60 | const uint64_t x2 = (uint64_t)(s) * (s + b) + ((uint64_t)(result) << 32) - n1;
61 | const int32_t overshoot = ((int64_t)(x2 + b) > 0) ? -1 : 0;
62 | const int32_t undershoot = ((int64_t)(x2 + 0x100000000UL + s) < 0) ? 1 : 0;
63 | result += (overshoot + undershoot);
64 | return result;
65 | }
66 |
--------------------------------------------------------------------------------
/xmrstak/backend/plugin.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/misc/environment.hpp"
4 | #include "xmrstak/params.hpp"
5 |
6 | #include "iBackend.hpp"
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #ifndef USE_PRECOMPILED_HEADERS
14 | #ifdef WIN32
15 | #include
16 | #include
17 | #else
18 | #include
19 | #include
20 | #endif
21 | #include
22 | #endif
23 |
24 | namespace xmrstak
25 | {
26 |
27 | struct plugin
28 | {
29 |
30 | plugin() = default;
31 |
32 | void load(const std::string backendName, const std::string libName)
33 | {
34 | m_backendName = backendName;
35 | #ifdef WIN32
36 | libBackend = LoadLibrary(TEXT((libName + ".dll").c_str()));
37 | if(!libBackend)
38 | {
39 | std::cerr << "WARNING: " << m_backendName << " cannot load backend library: " << (libName + ".dll") << std::endl;
40 | return;
41 | }
42 | #else
43 | // `.so` linux file extention for dynamic libraries
44 | std::string fileExtension = ".so";
45 | #if defined(__APPLE__)
46 | // `.dylib` Mac OS X file extention for dynamic libraries
47 | fileExtension = ".dylib";
48 | #endif
49 | // search library in working directory
50 | libBackend = dlopen(("./lib" + libName + fileExtension).c_str(), RTLD_NOW | RTLD_LAZY | RTLD_GLOBAL);
51 | // fallback to binary directory
52 | if(!libBackend)
53 | libBackend = dlopen((params::inst().executablePrefix + "lib" + libName + fileExtension).c_str(), RTLD_NOW | RTLD_LAZY | RTLD_GLOBAL);
54 | // try use LD_LIBRARY_PATH
55 | if(!libBackend)
56 | libBackend = dlopen(("lib" + libName + fileExtension).c_str(), RTLD_NOW | RTLD_LAZY | RTLD_GLOBAL);
57 | if(!libBackend)
58 | {
59 | std::cerr << "WARNING: " << m_backendName << " cannot load backend library: " << dlerror() << std::endl;
60 | return;
61 | }
62 | #endif
63 |
64 | #ifdef WIN32
65 | fn_startBackend = (startBackend_t)GetProcAddress(libBackend, "xmrstak_start_backend");
66 | if(!fn_startBackend)
67 | {
68 | std::cerr << "WARNING: backend plugin " << libName << " contains no entry 'xmrstak_start_backend': " << GetLastError() << std::endl;
69 | }
70 | #else
71 | // reset last error
72 | dlerror();
73 | fn_startBackend = (startBackend_t)dlsym(libBackend, "xmrstak_start_backend");
74 | const char* dlsym_error = dlerror();
75 | if(dlsym_error)
76 | {
77 | std::cerr << "WARNING: backend plugin " << libName << " contains no entry 'xmrstak_start_backend': " << dlsym_error << std::endl;
78 | }
79 | #endif
80 | }
81 |
82 | std::vector* startBackend(uint32_t threadOffset, miner_work& pWork, environment& env)
83 | {
84 | if(fn_startBackend == nullptr)
85 | {
86 | std::vector* pvThreads = new std::vector();
87 | return pvThreads;
88 | }
89 |
90 | return fn_startBackend(threadOffset, pWork, env);
91 | }
92 |
93 | void unload()
94 | {
95 | if(libBackend)
96 | {
97 | #ifdef WIN32
98 | FreeLibrary(libBackend);
99 | #else
100 | dlclose(libBackend);
101 | #endif
102 | }
103 | fn_startBackend = nullptr;
104 | }
105 |
106 | std::string m_backendName;
107 |
108 | typedef std::vector* (*startBackend_t)(uint32_t threadOffset, miner_work& pWork, environment& env);
109 |
110 | startBackend_t fn_startBackend = nullptr;
111 |
112 | #ifdef WIN32
113 | HINSTANCE libBackend;
114 | #else
115 | void* libBackend = nullptr;
116 | #endif
117 | };
118 |
119 | } // namespace xmrstak
120 |
--------------------------------------------------------------------------------
/xmrstak/backend/pool_data.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | constexpr static size_t invalid_pool_id = (-1);
7 |
8 | namespace xmrstak
9 | {
10 |
11 | struct pool_data
12 | {
13 | uint32_t iSavedNonce;
14 | size_t pool_id;
15 |
16 | pool_data() :
17 | iSavedNonce(0),
18 | pool_id(invalid_pool_id)
19 | {
20 | }
21 | };
22 |
23 | } // namespace xmrstak
24 |
--------------------------------------------------------------------------------
/xmrstak/cli/xmr-stak.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 | XMR-Stak Monero Miner
10 |
11 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/xmrstak/cpputil/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Will Zhang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/xmrstak/cpputil/read_write_lock.h:
--------------------------------------------------------------------------------
1 | /* MIT License
2 | *
3 | * Copyright (c) 2018 Will Zhang
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in all
13 | * copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | * SOFTWARE.
22 | */
23 |
24 | #pragma once
25 |
26 | #include
27 | #include
28 |
29 | namespace cpputil
30 | {
31 |
32 | class RWLock
33 | {
34 | public:
35 | RWLock() : status_(0), waiting_readers_(0), waiting_writers_(0) {}
36 | RWLock(const RWLock&) = delete;
37 | RWLock(RWLock&&) = delete;
38 | RWLock& operator = (const RWLock&) = delete;
39 | RWLock& operator = (RWLock&&) = delete;
40 |
41 | void ReadLock()
42 | {
43 | std::unique_lock lck(mtx_);
44 | waiting_readers_ += 1;
45 | read_cv_.wait(lck, [&]() { return waiting_writers_ == 0 && status_ >= 0; });
46 | waiting_readers_ -= 1;
47 | status_ += 1;
48 | }
49 |
50 | void WriteLock()
51 | {
52 | std::unique_lock lck(mtx_);
53 | waiting_writers_ += 1;
54 | write_cv_.wait(lck, [&]() { return status_ == 0; });
55 | waiting_writers_ -= 1;
56 | status_ = -1;
57 | }
58 |
59 | void UnLock()
60 | {
61 | std::unique_lock lck(mtx_);
62 | if (status_ == -1) {
63 | status_ = 0;
64 | }
65 | else
66 | {
67 | status_ -= 1;
68 | }
69 | if (waiting_writers_ > 0)
70 | {
71 | if (status_ == 0)
72 | {
73 | write_cv_.notify_one();
74 | }
75 | }
76 | else
77 | {
78 | read_cv_.notify_all();
79 | }
80 | }
81 |
82 | private:
83 | /** status of the lock
84 | * -1 : one writer
85 | * 0 : no reader and no writer
86 | * n > 0 : n reader
87 | */
88 | int32_t status_;
89 | int32_t waiting_readers_;
90 | int32_t waiting_writers_;
91 | std::mutex mtx_;
92 | std::condition_variable read_cv_;
93 | std::condition_variable write_cv_;
94 | };
95 |
96 | } // namespace cpputil
97 |
--------------------------------------------------------------------------------
/xmrstak/donate-level.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | /*
4 | * DEV DONATION SETTING
5 | * This setting is a percentage of your hashing power that the miner donates to the developers of this app.
6 | * It can be 0.0 if you don't want to help the developers. The default setting of 2.0 means that
7 | * the miner will mine into your usual pool for 98 minutes, then switch to the developer's pool for 2.0 minutes.
8 | * Switching pools is instant and it only happens after a successful connection, so you don't lose any hash time.
9 | *
10 | * If you plan on changing this setting to 0.0, please consider making a one time donation to our wallets:
11 | * fireice-uk:
12 | * 4581HhZkQHgZrZjKeCfCJxZff9E3xCgHGF25zABZz7oR71TnbbgiS7sK9jveE6Dx6uMs2LwszDuvQJgRZQotdpHt1fTdDhk
13 | * psychocrypt:
14 | * 43NoJVEXo21hGZ6tDG6Z3g4qimiGdJPE6GRxAmiWwm26gwr62Lqo7zRiCJFSBmbkwTGNuuES9ES5TgaVHceuYc4Y75txCTU
15 | *
16 | * Thank you for your support.
17 | */
18 |
19 | constexpr double fDevDonationLevel = 2.0 / 100.0;
20 |
--------------------------------------------------------------------------------
/xmrstak/http/httpd.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | struct MHD_Daemon;
6 | struct MHD_Connection;
7 |
8 | class httpd
9 | {
10 | public:
11 | static httpd* inst()
12 | {
13 | if(oInst == nullptr)
14 | oInst = new httpd;
15 | return oInst;
16 | };
17 |
18 | bool start_daemon();
19 |
20 | private:
21 | httpd();
22 | static httpd* oInst;
23 |
24 | static int req_handler(void* cls,
25 | MHD_Connection* connection,
26 | const char* url,
27 | const char* method,
28 | const char* version,
29 | const char* upload_data,
30 | size_t* upload_data_size,
31 | void** ptr);
32 |
33 | MHD_Daemon* d;
34 | };
35 |
--------------------------------------------------------------------------------
/xmrstak/http/webdesign.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | extern const char sHtmlCssEtag[];
4 | extern const char sHtmlCssFile[];
5 | extern size_t sHtmlCssSize;
6 |
7 | extern const char sHtmlAccessDenied[];
8 | extern size_t sHtmlAccessDeniedSize;
9 |
10 | extern const char sHttpAuthRealm[];
11 | extern const char sHttpAuthOpaque[];
12 |
13 | extern const char sHtmlCommonHeader[];
14 |
15 | extern const char sHtmlMotdBoxStart[];
16 | extern const char sHtmlMotdEntry[];
17 | extern const char sHtmlMotdBoxEnd[];
18 |
19 | extern const char sHtmlHashrateBodyHigh[];
20 | extern const char sHtmlHashrateTableRow[];
21 | extern const char sHtmlHashrateBodyLow[];
22 |
23 | extern const char sHtmlConnectionBodyHigh[];
24 | extern const char sHtmlConnectionTableRow[];
25 | extern const char sHtmlConnectionBodyLow[];
26 |
27 | extern const char sHtmlResultBodyHigh[];
28 | extern const char sHtmlResultTableRow[];
29 | extern const char sHtmlResultBodyLow[];
30 |
31 | extern const char sJsonApiThdHashrate[];
32 | extern const char sJsonApiResultError[];
33 | extern const char sJsonApiConnectionError[];
34 | extern const char sJsonApiFormat[];
35 |
--------------------------------------------------------------------------------
/xmrstak/jconf.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "params.hpp"
4 | #include "xmrstak/misc/coinDescription.hpp"
5 | #include "xmrstak/misc/environment.hpp"
6 |
7 | #include
8 | #include
9 |
10 | class jconf
11 | {
12 | public:
13 | static jconf* inst()
14 | {
15 | auto& env = xmrstak::environment::inst();
16 | if(env.pJconfConfig == nullptr)
17 | {
18 | std::unique_lock lck(env.update);
19 | if(env.pJconfConfig == nullptr)
20 | env.pJconfConfig = new jconf;
21 | }
22 | return env.pJconfConfig;
23 | };
24 |
25 | bool parse_config(const char* sFilename, const char* sFilenamePools);
26 |
27 | struct pool_cfg
28 | {
29 | const char* sPoolAddr;
30 | const char* sWalletAddr;
31 | const char* sRigId;
32 | const char* sPasswd;
33 | bool nicehash;
34 | bool tls;
35 | const char* tls_fingerprint;
36 | size_t raw_weight;
37 | double weight;
38 | };
39 |
40 | size_t wt_max;
41 | size_t wt_min;
42 |
43 | uint64_t GetPoolCount();
44 | bool GetPoolConfig(size_t id, pool_cfg& cfg);
45 |
46 | enum slow_mem_cfg
47 | {
48 | always_use,
49 | no_mlck,
50 | print_warning,
51 | never_use,
52 | unknown_value
53 | };
54 |
55 | bool TlsSecureAlgos();
56 |
57 | inline xmrstak::coin_selection GetCurrentCoinSelection() const { return currentCoin; }
58 |
59 | std::string GetMiningCoin();
60 |
61 | static void GetAlgoList(std::string& list);
62 | static bool IsOnAlgoList(std::string& needle);
63 | static const char* GetDefaultPool(const char* needle);
64 |
65 | uint64_t GetVerboseLevel();
66 | bool PrintMotd();
67 | uint64_t GetAutohashTime();
68 |
69 | const char* GetOutputFile();
70 |
71 | uint64_t GetCallTimeout();
72 | uint64_t GetNetRetry();
73 | uint64_t GetGiveUpLimit();
74 |
75 | uint16_t GetHttpdPort();
76 | const char* GetHttpUsername();
77 | const char* GetHttpPassword();
78 |
79 | bool DaemonMode();
80 |
81 | bool PreferIpv4();
82 |
83 | inline bool HaveHardwareAes() { return bHaveAes; }
84 |
85 | static void cpuid(uint32_t eax, int32_t ecx, int32_t val[4]);
86 |
87 | slow_mem_cfg GetSlowMemSetting();
88 |
89 | private:
90 | jconf();
91 |
92 | bool parse_file(const char* sFilename, bool main_conf);
93 |
94 | bool check_cpu_features();
95 | struct opaque_private;
96 | opaque_private* prv;
97 |
98 | bool bHaveAes;
99 | xmrstak::coin_selection currentCoin;
100 | };
101 |
--------------------------------------------------------------------------------
/xmrstak/misc/coinDescription.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/backend/cryptonight.hpp"
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | namespace xmrstak
11 | {
12 | struct coinDescription
13 | {
14 | xmrstak_algo algo = {xmrstak_algo_id::invalid_algo};
15 | uint8_t fork_version = 0u;
16 | xmrstak_algo algo_root = {xmrstak_algo_id::invalid_algo};
17 |
18 | coinDescription() = default;
19 |
20 | coinDescription(
21 | const xmrstak_algo in_algo,
22 | const uint8_t in_fork_version = 0,
23 | xmrstak_algo in_algo_root = xmrstak_algo_id::invalid_algo) :
24 | algo(in_algo),
25 | algo_root(in_algo_root),
26 | fork_version(in_fork_version)
27 | {
28 | }
29 |
30 | inline xmrstak_algo GetMiningAlgo() const { return algo; }
31 | inline xmrstak_algo GetMiningAlgoRoot() const { return algo_root; }
32 | inline uint8_t GetMiningForkVersion() const { return fork_version; }
33 | };
34 |
35 | struct coin_selection
36 | {
37 | const char* coin_name = nullptr;
38 | /* [0] -> user pool
39 | * [1] -> dev pool
40 | */
41 | coinDescription pool_coin[2];
42 | const char* default_pool = nullptr;
43 |
44 | coin_selection() = default;
45 |
46 | coin_selection(
47 | const char* in_coin_name,
48 | const coinDescription user_coinDescription,
49 | const coinDescription dev_coinDescription,
50 | const char* in_default_pool) :
51 | coin_name(in_coin_name),
52 | default_pool(in_default_pool)
53 | {
54 | pool_coin[0] = user_coinDescription;
55 | pool_coin[1] = dev_coinDescription;
56 | }
57 |
58 | /** get coin description for the pool
59 | *
60 | * @param poolId 0 select dev pool, else the user pool is selected
61 | */
62 | inline coinDescription GetDescription(size_t poolId) const
63 | {
64 | coinDescription tmp = (poolId == 0 ? pool_coin[1] : pool_coin[0]);
65 | return tmp;
66 | }
67 |
68 | /** return all POW algorithm for the current selected currency
69 | *
70 | * @return required POW algorithms without duplicated entries
71 | */
72 | inline std::vector GetAllAlgorithms()
73 | {
74 | std::vector allAlgos = {
75 | GetDescription(0).GetMiningAlgo(),
76 | GetDescription(0).GetMiningAlgoRoot(),
77 | GetDescription(1).GetMiningAlgo(),
78 | GetDescription(1).GetMiningAlgoRoot()};
79 |
80 | std::sort(allAlgos.begin(), allAlgos.end());
81 | std::remove(allAlgos.begin(), allAlgos.end(), invalid_algo);
82 | auto last = std::unique(allAlgos.begin(), allAlgos.end());
83 | // remove duplicated algorithms
84 | allAlgos.erase(last, allAlgos.end());
85 |
86 | return allAlgos;
87 | }
88 | };
89 | } // namespace xmrstak
90 |
--------------------------------------------------------------------------------
/xmrstak/misc/configEditor.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "../version.hpp"
10 |
11 | namespace xmrstak
12 | {
13 |
14 | struct configEditor
15 | {
16 | std::string m_fileContent;
17 |
18 | configEditor()
19 | {
20 | }
21 |
22 | static bool file_exist(const std::string filename)
23 | {
24 | std::ifstream fstream(filename);
25 | return fstream.good();
26 | }
27 |
28 | void set(const std::string&& content)
29 | {
30 | m_fileContent = content;
31 | }
32 |
33 | bool load(const std::string filename)
34 | {
35 | std::ifstream fstream(filename);
36 | m_fileContent = std::string(
37 | (std::istreambuf_iterator(fstream)),
38 | std::istreambuf_iterator());
39 | return fstream.good();
40 | }
41 |
42 | void write(const std::string filename)
43 | {
44 | // endmarks: for filtering full lines inside the template string
45 | // Platform marks are done globally here
46 | // "---WINDOWS" endmark keeps lines when compiled for Windows
47 | // "---LINUX" endmark keeps lines when compiled for Linux (and anything not-windows)
48 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__WINDOWS__)
49 | // windows:
50 | // completely drop lines with endmark-linux
51 | replace(".*---LINUX\n", "");
52 | // strip off windows endmarks, keep the lines
53 | replace("---WINDOWS\n", "\n");
54 | #else
55 | // not-windows:
56 | // completely drop lines with endmark-windows
57 | replace(".*---WINDOWS\n", "");
58 | // strip off linux endmarks, keep the lines
59 | replace("---LINUX\n", "\n");
60 | #endif
61 | replace("XMRSTAK_VERSION", get_version_str());
62 | std::ofstream out(filename);
63 | out << m_fileContent;
64 | out.close();
65 | }
66 |
67 | void replace(const std::string search, const std::string substring)
68 | {
69 | m_fileContent = std::regex_replace(m_fileContent, std::regex(search), substring);
70 | }
71 | };
72 |
73 | } // namespace xmrstak
74 |
--------------------------------------------------------------------------------
/xmrstak/misc/console.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/misc/environment.hpp"
4 |
5 | #include
6 |
7 | enum out_colours
8 | {
9 | K_RED,
10 | K_GREEN,
11 | K_BLUE,
12 | K_YELLOW,
13 | K_CYAN,
14 | K_MAGENTA,
15 | K_WHITE,
16 | K_NONE
17 | };
18 |
19 | // Warning - on Linux get_key will detect control keys, but not on Windows.
20 | // We will only use it for alphanum keys anyway.
21 | int get_key();
22 |
23 | void set_colour(out_colours cl);
24 | void reset_colour();
25 |
26 | // on MSVC sizeof(long int) = 4, gcc sizeof(long int) = 8, this is the workaround
27 | // now we can use %llu on both compilers
28 | inline long long unsigned int int_port(size_t i)
29 | {
30 | return i;
31 | }
32 |
33 | enum verbosity : size_t
34 | {
35 | L0 = 0,
36 | L1 = 1,
37 | L2 = 2,
38 | L3 = 3,
39 | L4 = 4,
40 | LDEBUG = 10,
41 | LINF = 100
42 | };
43 |
44 | class printer
45 | {
46 | public:
47 | static inline printer* inst()
48 | {
49 | auto& env = xmrstak::environment::inst();
50 | if(env.pPrinter == nullptr)
51 | {
52 | std::unique_lock lck(env.update);
53 | if(env.pPrinter == nullptr)
54 | env.pPrinter = new printer;
55 | }
56 | return env.pPrinter;
57 | };
58 |
59 | inline void set_verbose_level(size_t level) { verbose_level = (verbosity)level; }
60 | void print_msg(verbosity verbose, const char* fmt, ...);
61 | void print_str(const char* str);
62 | bool open_logfile(const char* file);
63 |
64 | private:
65 | printer();
66 |
67 | std::mutex print_mutex;
68 | verbosity verbose_level;
69 | FILE* logfile;
70 | };
71 |
72 | void win_exit(int code = 1);
73 |
--------------------------------------------------------------------------------
/xmrstak/misc/environment.cpp:
--------------------------------------------------------------------------------
1 | #include "environment.hpp"
2 |
3 | #include "xmrstak/misc/console.hpp"
4 | #include "xmrstak/backend/cpu/crypto/cryptonight.h"
5 | #include "xmrstak/params.hpp"
6 | #include "xmrstak/misc/executor.hpp"
7 | #include "xmrstak/jconf.hpp"
8 |
9 | namespace xmrstak
10 | {
11 | void environment::init_singeltons()
12 | {
13 | printer::inst();
14 | globalStates::inst();
15 | jconf::inst();
16 | executor::inst();
17 | params::inst();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/xmrstak/misc/environment.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class printer;
6 | class jconf;
7 | class executor;
8 |
9 | namespace xmrstak
10 | {
11 |
12 | struct globalStates;
13 | struct params;
14 |
15 | struct environment
16 | {
17 | static inline environment& inst(environment* init = nullptr)
18 | {
19 | static environment* env = nullptr;
20 |
21 | if(env == nullptr)
22 | {
23 | if(init == nullptr)
24 | {
25 | env = new environment;
26 | env->init_singeltons();
27 | }
28 | else
29 | env = init;
30 | }
31 |
32 | return *env;
33 | }
34 |
35 | environment()
36 | {
37 | }
38 |
39 | printer* pPrinter = nullptr;
40 | globalStates* pglobalStates = nullptr;
41 | jconf* pJconfConfig = nullptr;
42 | executor* pExecutor = nullptr;
43 | params* pParams = nullptr;
44 |
45 | std::mutex update;
46 |
47 | private:
48 | void init_singeltons();
49 | };
50 |
51 | } // namespace xmrstak
52 |
--------------------------------------------------------------------------------
/xmrstak/misc/home_dir.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | #ifdef _WIN32
6 | #include
7 | // this comment avoid that clang format reorders the includes
8 | #include
9 |
10 | namespace
11 | {
12 | inline std::string get_home()
13 | {
14 | char path[MAX_PATH + 1];
15 | // get folder "appdata\local"
16 | if(SHGetSpecialFolderPathA(HWND_DESKTOP, path, CSIDL_LOCAL_APPDATA, FALSE))
17 | {
18 | return path;
19 | }
20 | else
21 | return ".";
22 | }
23 | } // namespace
24 |
25 | #else
26 | #include
27 | #include
28 | #include
29 |
30 | namespace
31 | {
32 | inline std::string get_home()
33 | {
34 | const char* home = ".";
35 |
36 | if((home = getenv("HOME")) == nullptr)
37 | home = getpwuid(getuid())->pw_dir;
38 |
39 | return home;
40 | }
41 | } // namespace
42 |
43 | #endif // _WIN32
44 |
--------------------------------------------------------------------------------
/xmrstak/misc/jext.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/rapidjson/document.h"
4 | #include "xmrstak/rapidjson/error/en.h"
5 |
6 | using namespace rapidjson;
7 |
8 | /* This macro brings rapidjson more in line with other libs */
9 | inline const Value* GetObjectMember(const Value& obj, const char* key)
10 | {
11 | Value::ConstMemberIterator itr = obj.FindMember(key);
12 | if(itr != obj.MemberEnd())
13 | return &itr->value;
14 | else
15 | return nullptr;
16 | }
17 |
18 | #ifdef _MSC_VER
19 |
20 | #include
21 | #define bswap_32(x) _byteswap_ulong(x)
22 | #define bswap_64(x) _byteswap_uint64(x)
23 |
24 | #elif defined(__APPLE__)
25 |
26 | // Mac OS X / Darwin features
27 | #include
28 | #define bswap_32(x) OSSwapInt32(x)
29 | #define bswap_64(x) OSSwapInt64(x)
30 |
31 | #elif defined(__sun) || defined(sun)
32 |
33 | #include
34 | #define bswap_32(x) BSWAP_32(x)
35 | #define bswap_64(x) BSWAP_64(x)
36 |
37 | #elif defined(__FreeBSD__)
38 |
39 | #include
40 | #define bswap_32(x) bswap32(x)
41 | #define bswap_64(x) bswap64(x)
42 |
43 | #elif defined(__OpenBSD__)
44 |
45 | #include
46 | #define bswap_32(x) swap32(x)
47 | #define bswap_64(x) swap64(x)
48 |
49 | #elif defined(__NetBSD__)
50 |
51 | #include
52 | #include
53 | #if defined(__BSWAP_RENAME) && !defined(__bswap_32)
54 | #define bswap_32(x) bswap32(x)
55 | #define bswap_64(x) bswap64(x)
56 | #endif
57 |
58 | #else
59 |
60 | #include
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/xmrstak/misc/telemetry.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software: you can redistribute it and/or modify
3 | * it under the terms of the GNU General Public License as published by
4 | * the Free Software Foundation, either version 3 of the License, or
5 | * any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 | * GNU General Public License for more details.
11 | *
12 | * You should have received a copy of the GNU General Public License
13 | * along with this program. If not, see .
14 | *
15 | * Additional permission under GNU GPL version 3 section 7
16 | *
17 | * If you modify this Program, or any covered work, by linking or combining
18 | * it with OpenSSL (or a modified version of that library), containing parts
19 | * covered by the terms of OpenSSL License and SSLeay License, the licensors
20 | * of this Program grant you additional permission to convey the resulting work.
21 | *
22 | */
23 |
24 | #include "telemetry.hpp"
25 | #include "xmrstak/net/msgstruct.hpp"
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | namespace xmrstak
32 | {
33 |
34 | telemetry::telemetry(size_t iThd)
35 | {
36 | ppHashCounts = new uint64_t*[iThd];
37 | ppTimestamps = new uint64_t*[iThd];
38 | iBucketTop = new uint32_t[iThd];
39 |
40 | for(size_t i = 0; i < iThd; i++)
41 | {
42 | ppHashCounts[i] = new uint64_t[iBucketSize];
43 | ppTimestamps[i] = new uint64_t[iBucketSize];
44 | iBucketTop[i] = 0;
45 | memset(ppHashCounts[i], 0, sizeof(uint64_t) * iBucketSize);
46 | memset(ppTimestamps[i], 0, sizeof(uint64_t) * iBucketSize);
47 | }
48 | }
49 |
50 | double telemetry::calc_telemetry_data(size_t iLastMillisec, size_t iThread)
51 | {
52 |
53 | uint64_t iEarliestHashCnt = 0;
54 | uint64_t iEarliestStamp = 0;
55 | uint64_t iLatestStamp = 0;
56 | uint64_t iLatestHashCnt = 0;
57 | bool bHaveFullSet = false;
58 |
59 | uint64_t iTimeNow = get_timestamp_ms();
60 |
61 | //Start at 1, buckettop points to next empty
62 | for(size_t i = 1; i < iBucketSize; i++)
63 | {
64 | size_t idx = (iBucketTop[iThread] - i) & iBucketMask; //overflow expected here
65 |
66 | if(ppTimestamps[iThread][idx] == 0)
67 | break; //That means we don't have the data yet
68 |
69 | if(iLatestStamp == 0)
70 | {
71 | iLatestStamp = ppTimestamps[iThread][idx];
72 | iLatestHashCnt = ppHashCounts[iThread][idx];
73 | }
74 |
75 | if(iTimeNow - ppTimestamps[iThread][idx] > iLastMillisec)
76 | {
77 | bHaveFullSet = true;
78 | break; //We are out of the requested time period
79 | }
80 |
81 | iEarliestStamp = ppTimestamps[iThread][idx];
82 | iEarliestHashCnt = ppHashCounts[iThread][idx];
83 | }
84 |
85 | if(!bHaveFullSet || iEarliestStamp == 0 || iLatestStamp == 0)
86 | return nan("");
87 |
88 | //Don't think that can happen, but just in case
89 | if(iLatestStamp - iEarliestStamp == 0)
90 | return nan("");
91 |
92 | double fHashes, fTime;
93 | fHashes = static_cast(iLatestHashCnt - iEarliestHashCnt);
94 | fTime = static_cast(iLatestStamp - iEarliestStamp);
95 | fTime /= 1000.0;
96 |
97 | return fHashes / fTime;
98 | }
99 |
100 | void telemetry::push_perf_value(size_t iThd, uint64_t iHashCount, uint64_t iTimestamp)
101 | {
102 | size_t iTop = iBucketTop[iThd];
103 | ppHashCounts[iThd][iTop] = iHashCount;
104 | ppTimestamps[iThd][iTop] = iTimestamp;
105 |
106 | iBucketTop[iThd] = (iTop + 1) & iBucketMask;
107 | }
108 |
109 | } // namespace xmrstak
110 |
--------------------------------------------------------------------------------
/xmrstak/misc/telemetry.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | namespace xmrstak
7 | {
8 |
9 | class telemetry
10 | {
11 | public:
12 | telemetry(size_t iThd);
13 | void push_perf_value(size_t iThd, uint64_t iHashCount, uint64_t iTimestamp);
14 | double calc_telemetry_data(size_t iLastMillisec, size_t iThread);
15 |
16 | private:
17 | constexpr static size_t iBucketSize = 2 << 11; //Power of 2 to simplify calculations
18 | constexpr static size_t iBucketMask = iBucketSize - 1;
19 | uint32_t* iBucketTop;
20 | uint64_t** ppHashCounts;
21 | uint64_t** ppTimestamps;
22 | };
23 |
24 | } // namespace xmrstak
25 |
--------------------------------------------------------------------------------
/xmrstak/misc/thdq.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | template
9 | class thdq
10 | {
11 | public:
12 | T pop()
13 | {
14 | std::unique_lock mlock(mutex_);
15 | while(queue_.empty())
16 | {
17 | cond_.wait(mlock);
18 | }
19 | auto item = std::move(queue_.front());
20 | queue_.pop();
21 | return item;
22 | }
23 |
24 | void pop(T& item)
25 | {
26 | std::unique_lock mlock(mutex_);
27 | while(queue_.empty())
28 | {
29 | cond_.wait(mlock);
30 | }
31 | item = queue_.front();
32 | queue_.pop();
33 | }
34 |
35 | void push(const T& item)
36 | {
37 | std::unique_lock mlock(mutex_);
38 | queue_.push(item);
39 | mlock.unlock();
40 | cond_.notify_one();
41 | }
42 |
43 | void push(T&& item)
44 | {
45 | std::unique_lock mlock(mutex_);
46 | queue_.push(std::move(item));
47 | mlock.unlock();
48 | cond_.notify_one();
49 | }
50 |
51 | private:
52 | std::queue queue_;
53 | std::mutex mutex_;
54 | std::condition_variable cond_;
55 | };
56 |
--------------------------------------------------------------------------------
/xmrstak/misc/uac.cpp:
--------------------------------------------------------------------------------
1 | #ifdef _WIN32
2 | #include "xmrstak/misc/console.hpp"
3 | #include "xmrstak/params.hpp"
4 | #include "xmrstak/jconf.hpp"
5 |
6 | #include
7 | #include
8 |
9 | BOOL IsElevated()
10 | {
11 | BOOL fRet = FALSE;
12 | HANDLE hToken = NULL;
13 | if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
14 | {
15 | TOKEN_ELEVATION Elevation;
16 | DWORD cbSize = sizeof(TOKEN_ELEVATION);
17 | if(GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof(Elevation), &cbSize))
18 | fRet = Elevation.TokenIsElevated;
19 | }
20 | if(hToken)
21 | CloseHandle(hToken);
22 | return fRet;
23 | }
24 |
25 | BOOL SelfElevate(const std::string& my_path, const std::string& params)
26 | {
27 | if(IsElevated())
28 | return FALSE;
29 |
30 | SHELLEXECUTEINFO shExecInfo = {0};
31 | shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
32 | shExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
33 | shExecInfo.hwnd = NULL;
34 | shExecInfo.lpVerb = "runas";
35 | shExecInfo.lpFile = my_path.c_str();
36 | shExecInfo.lpParameters = params.c_str();
37 | shExecInfo.lpDirectory = NULL;
38 | shExecInfo.nShow = SW_SHOW;
39 | shExecInfo.hInstApp = NULL;
40 |
41 | if(!ShellExecuteEx(&shExecInfo))
42 | return FALSE;
43 |
44 | // Loiter in the background to make scripting easier
45 | printer::inst()->print_msg(L0, "This window has been opened because xmr-stak needed to run as administrator. It can be safely closed now.");
46 | WaitForSingleObject(shExecInfo.hProcess, INFINITE);
47 | std::exit(0);
48 |
49 | return TRUE;
50 | }
51 |
52 | VOID RequestElevation()
53 | {
54 | if(IsElevated())
55 | return;
56 |
57 | if(!xmrstak::params::inst().allowUAC)
58 | {
59 | printer::inst()->print_msg(L0, "The miner needs to run as administrator, but you passed --noUAC option. Please remove it or set use_slow_memory to always.");
60 | if (::jconf::inst()->GetSlowMemSetting() == ::jconf::print_warning)
61 | return;
62 |
63 | win_exit();
64 | return;
65 | }
66 |
67 | SelfElevate(xmrstak::params::inst().minerArg0, xmrstak::params::inst().minerArgs);
68 | }
69 |
70 | BOOL IsWindows10OrNewer()
71 | {
72 | OSVERSIONINFOEX osvi = {0};
73 | osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
74 | osvi.dwMajorVersion = 10;
75 | osvi.dwMinorVersion = 0;
76 | DWORDLONG dwlConditionMask = 0;
77 | VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
78 | VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
79 | return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask);
80 | }
81 | #endif
82 |
--------------------------------------------------------------------------------
/xmrstak/misc/uac.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef _WIN32
4 | #include
5 |
6 | BOOL IsElevated();
7 | BOOL SelfElevate(const std::string& my_path, const std::string& params);
8 | VOID RequestElevation();
9 | BOOL IsWindows10OrNewer();
10 | #endif
11 |
--------------------------------------------------------------------------------
/xmrstak/misc/utility.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace xmrstak
5 | {
6 | bool strcmp_i(const std::string& str1, const std::string& str2)
7 | {
8 | if(str1.size() != str2.size())
9 | return false;
10 | else
11 | return (str1.empty() | str2.empty()) ? false : std::equal(str1.begin(), str1.end(), str2.begin(), [](char c1, char c2) {
12 | return ::tolower(c1) == ::tolower(c2);
13 | });
14 | }
15 | } // namespace xmrstak
16 |
--------------------------------------------------------------------------------
/xmrstak/misc/utility.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | namespace xmrstak
6 | {
7 | /** case insensitive string compare
8 | *
9 | * @return true if both strings are equal, else false
10 | */
11 | bool strcmp_i(const std::string& str1, const std::string& str2);
12 | } // namespace xmrstak
13 |
--------------------------------------------------------------------------------
/xmrstak/net/jpsock.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "msgstruct.hpp"
4 | #include "xmrstak/backend/iBackend.hpp"
5 | #include "xmrstak/jconf.hpp"
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | /* Our pool can have two kinds of errors:
14 | - Parsing or connection error
15 | Those are fatal errors (we drop the connection if we encounter them).
16 | After they are constructed from const char* strings from various places.
17 | (can be from read-only mem), we pass them in an executor message
18 | once the recv thread expires.
19 | - Call error
20 | This error happens when the "server says no". Usually because the job was
21 | outdated, or we somehow got the hash wrong. It isn't fatal.
22 | We parse it in-situ in the network buffer, after that we copy it to a
23 | std::string. Executor will move the buffer via an r-value ref.
24 | */
25 | class base_socket;
26 |
27 | class jpsock
28 | {
29 | public:
30 | jpsock(size_t id, const char* sAddr, const char* sLogin, const char* sRigId, const char* sPassword, double pool_weight, bool dev_pool, bool tls, const char* tls_fp, bool nicehash);
31 | ~jpsock();
32 |
33 | bool connect(std::string& sConnectError);
34 | void disconnect(bool quiet = false);
35 |
36 | bool cmd_login();
37 | bool cmd_submit(const char* sJobId, uint32_t iNonce, const uint8_t* bResult, const char* backend_name, uint64_t backend_hashcount, uint64_t total_hashcount, const xmrstak_algo& algo);
38 |
39 | static bool hex2bin(const char* in, unsigned int len, unsigned char* out);
40 | static void bin2hex(const unsigned char* in, unsigned int len, char* out);
41 |
42 | inline double get_pool_weight(bool gross_weight)
43 | {
44 | double ret = pool_weight;
45 | if(gross_weight && bRunning)
46 | ret += 10.0;
47 | if(gross_weight && bLoggedIn)
48 | ret += 10.0;
49 | return ret;
50 | }
51 |
52 | inline size_t can_connect() { return get_timestamp() != connect_time; }
53 | inline bool is_running() { return bRunning; }
54 | inline bool is_logged_in() { return bLoggedIn; }
55 | inline bool is_dev_pool() { return pool; }
56 | inline size_t get_pool_id() { return pool_id; }
57 | inline bool get_disconnects(size_t& att, size_t& time)
58 | {
59 | att = connect_attempts;
60 | time = disconnect_time != 0 ? get_timestamp() - disconnect_time + 1 : 0;
61 | return pool && usr_login[0];
62 | }
63 | inline const char* get_pool_addr() { return net_addr.c_str(); }
64 | inline const char* get_tls_fp() { return tls_fp.c_str(); }
65 | inline const char* get_rigid() { return usr_rigid.c_str(); }
66 | inline bool is_nicehash() { return nicehash; }
67 |
68 | bool get_pool_motd(std::string& strin);
69 |
70 | std::string&& get_call_error();
71 | bool have_call_error() { return call_error; }
72 | bool have_sock_error() { return bHaveSocketError; }
73 | inline uint64_t get_current_diff() { return iJobDiff; }
74 |
75 | void save_nonce(uint32_t nonce);
76 | bool get_current_job(pool_job& job);
77 |
78 | bool set_socket_error(const char* a);
79 | bool set_socket_error(const char* a, const char* b);
80 | bool set_socket_error(const char* a, size_t len);
81 | bool set_socket_error_strerr(const char* a);
82 | bool set_socket_error_strerr(const char* a, int res);
83 |
84 | private:
85 | std::string net_addr;
86 | std::string usr_login;
87 | std::string usr_rigid;
88 | std::string usr_pass;
89 | std::string tls_fp;
90 |
91 | size_t pool_id;
92 | double pool_weight;
93 | bool pool;
94 | bool nicehash;
95 |
96 | bool ext_algo = false;
97 | bool ext_backend = false;
98 | bool ext_hashcount = false;
99 | bool ext_motd = false;
100 |
101 | std::string pool_motd;
102 | std::mutex motd_mutex;
103 |
104 | size_t connect_time = 0;
105 | std::atomic connect_attempts;
106 | std::atomic disconnect_time;
107 |
108 | std::atomic bRunning;
109 | std::atomic bLoggedIn;
110 | std::atomic quiet_close;
111 | std::atomic call_error;
112 |
113 | uint8_t* bJsonRecvMem;
114 | uint8_t* bJsonParseMem;
115 | uint8_t* bJsonCallMem;
116 |
117 | static constexpr size_t iJsonMemSize = 4096;
118 | static constexpr size_t iSockBufferSize = 4096;
119 |
120 | struct call_rsp;
121 | struct opaque_private;
122 | struct opq_json_val;
123 |
124 | void jpsock_thread();
125 | bool jpsock_thd_main();
126 | bool process_line(char* line, size_t len);
127 | bool process_pool_job(const opq_json_val* params, const uint64_t messageId);
128 | bool cmd_ret_wait(const char* sPacket, opq_json_val& poResult, uint64_t& messageId);
129 |
130 | char sMinerId[64];
131 | std::atomic iJobDiff;
132 |
133 | std::string sSocketError;
134 | std::atomic bHaveSocketError;
135 |
136 | std::mutex call_mutex;
137 | std::condition_variable call_cond;
138 | std::thread* oRecvThd;
139 |
140 | std::mutex job_mutex;
141 | pool_job oCurrentJob;
142 |
143 | opaque_private* prv;
144 | base_socket* sck;
145 |
146 | uint64_t iMessageCnt = 0;
147 | uint64_t iLastMessageId = 0;
148 | };
149 |
--------------------------------------------------------------------------------
/xmrstak/net/socket.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "socks.hpp"
4 | #include
5 |
6 | class jpsock;
7 |
8 | class base_socket
9 | {
10 | public:
11 | virtual bool set_hostname(const char* sAddr) = 0;
12 | virtual bool connect() = 0;
13 | virtual int recv(char* buf, unsigned int len) = 0;
14 | virtual bool send(const char* buf) = 0;
15 | virtual void close(bool free) = 0;
16 |
17 | protected:
18 | std::atomic sock_closed;
19 | };
20 |
21 | class plain_socket : public base_socket
22 | {
23 | public:
24 | plain_socket(jpsock* err_callback);
25 |
26 | bool set_hostname(const char* sAddr);
27 | bool connect();
28 | int recv(char* buf, unsigned int len);
29 | bool send(const char* buf);
30 | void close(bool free);
31 |
32 | private:
33 | jpsock* pCallback;
34 | addrinfo* pSockAddr;
35 | addrinfo* pAddrRoot;
36 | SOCKET hSocket;
37 | };
38 |
39 | typedef struct ssl_ctx_st SSL_CTX;
40 | typedef struct bio_st BIO;
41 | typedef struct ssl_st SSL;
42 |
43 | class tls_socket : public base_socket
44 | {
45 | public:
46 | tls_socket(jpsock* err_callback);
47 |
48 | bool set_hostname(const char* sAddr);
49 | bool connect();
50 | int recv(char* buf, unsigned int len);
51 | bool send(const char* buf);
52 | void close(bool free);
53 |
54 | private:
55 | void init_ctx();
56 | void print_error();
57 |
58 | jpsock* pCallback;
59 |
60 | SSL_CTX* ctx = nullptr;
61 | BIO* bio = nullptr;
62 | SSL* ssl = nullptr;
63 | };
64 |
--------------------------------------------------------------------------------
/xmrstak/net/socks.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef _WIN32
4 | #ifndef _WIN32_WINNT
5 | #define _WIN32_WINNT 0x0601 /* Windows 7 */
6 | #endif
7 |
8 | #include
9 | #include
10 | // this comment disable clang include reordering for windows.h
11 | #include
12 |
13 | inline void sock_init()
14 | {
15 | static bool bWSAInit = false;
16 |
17 | if(!bWSAInit)
18 | {
19 | WSADATA wsaData;
20 | WSAStartup(MAKEWORD(2, 2), &wsaData);
21 | bWSAInit = true;
22 | }
23 | }
24 |
25 | inline void sock_close(SOCKET s)
26 | {
27 | shutdown(s, SD_BOTH);
28 | closesocket(s);
29 | }
30 |
31 | inline const char* sock_strerror(char* buf, size_t len)
32 | {
33 | buf[0] = '\0';
34 |
35 | FormatMessageA(
36 | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
37 | NULL, WSAGetLastError(),
38 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
39 | (LPSTR)buf, len, NULL);
40 |
41 | return buf;
42 | }
43 |
44 | inline const char* sock_gai_strerror(int err, char* buf, size_t len)
45 | {
46 | buf[0] = '\0';
47 |
48 | FormatMessageA(
49 | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
50 | NULL, (DWORD)err,
51 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
52 | (LPSTR)buf, len, NULL);
53 |
54 | return buf;
55 | }
56 |
57 | #else
58 |
59 | /* Assume that any non-Windows platform uses POSIX-style sockets instead. */
60 | #include
61 | #include
62 | #include /* Needed for getaddrinfo() and freeaddrinfo() */
63 | #include /* Needed for IPPROTO_TCP */
64 | #include
65 | #include
66 | #include
67 | #include /* Needed for close() */
68 |
69 | inline void sock_init() {}
70 | typedef int SOCKET;
71 |
72 | #define INVALID_SOCKET (-1)
73 | #define SOCKET_ERROR (-1)
74 |
75 | inline void sock_close(SOCKET s)
76 | {
77 | shutdown(s, SHUT_RDWR);
78 | close(s);
79 | }
80 |
81 | inline const char* sock_strerror(char* buf, size_t len)
82 | {
83 | buf[0] = '\0';
84 |
85 | #if defined(__APPLE__) || defined(__FreeBSD__) || !defined(_GNU_SOURCE) || !defined(__GLIBC__)
86 |
87 | strerror_r(errno, buf, len);
88 | return buf;
89 | #else
90 | return strerror_r(errno, buf, len);
91 | #endif
92 | }
93 |
94 | inline const char* sock_gai_strerror(int err, char* buf, size_t len)
95 | {
96 | buf[0] = '\0';
97 | return gai_strerror(err);
98 | }
99 | #endif
100 |
--------------------------------------------------------------------------------
/xmrstak/params.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "xmrstak/misc/environment.hpp"
4 | #include "xmrstak/misc/home_dir.hpp"
5 |
6 | #include
7 |
8 | namespace xmrstak
9 | {
10 |
11 | struct params
12 | {
13 |
14 | static inline params& inst()
15 | {
16 | auto& env = environment::inst();
17 | if(env.pParams == nullptr)
18 | {
19 | std::unique_lock lck(env.update);
20 | if(env.pParams == nullptr)
21 | env.pParams = new params;
22 | }
23 | return *env.pParams;
24 | }
25 |
26 | std::string executablePrefix;
27 | std::string binaryName;
28 | bool useAMD;
29 | bool AMDCache;
30 | bool useNVIDIA;
31 | bool useCPU;
32 | std::string amdGpus;
33 | std::string nvidiaGpus;
34 | // user selected OpenCL vendor
35 | std::string openCLVendor;
36 |
37 | bool poolUseTls = false;
38 | std::string poolURL;
39 | bool userSetPwd = false;
40 | std::string poolPasswd;
41 | bool userSetRigid = false;
42 | std::string poolRigid;
43 | std::string poolUsername;
44 | bool nicehashMode = false;
45 |
46 | static constexpr int32_t httpd_port_unset = -1;
47 | static constexpr int32_t httpd_port_disabled = 0;
48 | int32_t httpd_port = httpd_port_unset;
49 |
50 | std::string currency;
51 |
52 | std::string configFile;
53 | std::string configFilePools;
54 | std::string configFileAMD;
55 | std::string rootAMDCacheDir;
56 | std::string configFileNVIDIA;
57 | std::string configFileCPU;
58 |
59 | std::string outputFile;
60 | int h_print_time = -1;
61 |
62 | bool allowUAC = true;
63 | std::string minerArg0;
64 | std::string minerArgs;
65 |
66 | // block_version >= 0 enable benchmark
67 | int benchmark_block_version = -1;
68 | int benchmark_wait_sec = 30;
69 | int benchmark_work_sec = 60;
70 |
71 | params() :
72 | binaryName("xmr-stak"),
73 | executablePrefix(""),
74 | useAMD(true),
75 | AMDCache(true),
76 | useNVIDIA(true),
77 | useCPU(true),
78 | openCLVendor("AMD"),
79 | configFile("config.txt"),
80 | configFilePools("pools.txt"),
81 | configFileAMD("amd.txt"),
82 | rootAMDCacheDir(get_home() + "/.openclcache/"),
83 | configFileCPU("cpu.txt"),
84 | configFileNVIDIA("nvidia.txt")
85 | {
86 | }
87 | };
88 |
89 | } // namespace xmrstak
90 |
--------------------------------------------------------------------------------
/xmrstak/pools.tpl:
--------------------------------------------------------------------------------
1 | R"===(// generated by XMRSTAK_VERSION
2 |
3 | /*
4 | * pool_address - Pool address should be entered as "pool_address:port" (e.g "pool.ryo-currency.com:4444"). Only stratum pools are supported.
5 | * wallet_address - Your wallet, or pool login.
6 | * rig_id - Rig identifier for pool-side statistics (needs pool support).
7 | * pool_password - Can be empty in most cases or "x".
8 | * use_nicehash - Limit the nonce to 3 bytes as required by nicehash.
9 | * use_tls - This option will make us connect using Transport Layer Security.
10 | * tls_fingerprint - Server's SHA256 fingerprint. If this string is non-empty then we will check the server's cert against it.
11 | * pool_weight - Pool weight is a number telling the miner how important the pool is. Miner will mine mostly at the pool
12 | * with the highest weight, unless the pool fails. Weight must be an integer larger than 0.
13 | */
14 |
15 | "pool_list" :
16 | [
17 | POOLCONF],
18 |
19 | /*
20 | * Currency to mine. Supported values:
21 | *
22 | * bbscoin (automatic switch with block version 3 to cryptonight_v7)
23 | * bittube (uses cryptonight_bittube2 algorithm)
24 | * graft
25 | * haven (automatic switch with block version 3 to cryptonight_haven)
26 | * lethean
27 | * masari
28 | * qrl - Quantum Resistant Ledger
29 | * ryo
30 | * turtlecoin
31 | * plenteum
32 | * torque
33 | * xcash
34 | *
35 | * Native algorithms which do not depend on any block versions:
36 | *
37 | * # 256KiB scratchpad memory
38 | * cryptonight_turtle
39 | * # 1MiB scratchpad memory
40 | * cryptonight_lite
41 | * cryptonight_lite_v7
42 | * cryptonight_lite_v7_xor (algorithm used by ipbc)
43 | * # 2MiB scratchpad memory
44 | * cryptonight
45 | * cryptonight_gpu (for Ryo's 14th of Feb fork)
46 | * cryptonight_superfast
47 | * cryptonight_v7
48 | * cryptonight_v8
49 | * cryptonight_v8_double (used by xcash)
50 | * cryptonight_v8_half (used by masari and torque)
51 | * cryptonight_v8_reversewaltz (used by graft)
52 | * cryptonight_v8_zelerius
53 | * # 4MiB scratchpad memory
54 | * cryptonight_bittube2
55 | * cryptonight_haven
56 | * cryptonight_heavy
57 | */
58 |
59 | "currency" : "CURRENCY",
60 | )==="
61 |
--------------------------------------------------------------------------------
/xmrstak/rapidjson/error/en.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_ERROR_EN_H_
16 | #define RAPIDJSON_ERROR_EN_H_
17 |
18 | #include "error.h"
19 |
20 | #ifdef __clang__
21 | RAPIDJSON_DIAG_PUSH
22 | RAPIDJSON_DIAG_OFF(switch-enum)
23 | RAPIDJSON_DIAG_OFF(covered-switch-default)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 |
28 | //! Maps error code of parsing into error message.
29 | /*!
30 | \ingroup RAPIDJSON_ERRORS
31 | \param parseErrorCode Error code obtained in parsing.
32 | \return the error message.
33 | \note User can make a copy of this function for localization.
34 | Using switch-case is safer for future modification of error codes.
35 | */
36 | inline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) {
37 | switch (parseErrorCode) {
38 | case kParseErrorNone: return RAPIDJSON_ERROR_STRING("No error.");
39 |
40 | case kParseErrorDocumentEmpty: return RAPIDJSON_ERROR_STRING("The document is empty.");
41 | case kParseErrorDocumentRootNotSingular: return RAPIDJSON_ERROR_STRING("The document root must not be followed by other values.");
42 |
43 | case kParseErrorValueInvalid: return RAPIDJSON_ERROR_STRING("Invalid value.");
44 |
45 | case kParseErrorObjectMissName: return RAPIDJSON_ERROR_STRING("Missing a name for object member.");
46 | case kParseErrorObjectMissColon: return RAPIDJSON_ERROR_STRING("Missing a colon after a name of object member.");
47 | case kParseErrorObjectMissCommaOrCurlyBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or '}' after an object member.");
48 |
49 | case kParseErrorArrayMissCommaOrSquareBracket: return RAPIDJSON_ERROR_STRING("Missing a comma or ']' after an array element.");
50 |
51 | case kParseErrorStringUnicodeEscapeInvalidHex: return RAPIDJSON_ERROR_STRING("Incorrect hex digit after \\u escape in string.");
52 | case kParseErrorStringUnicodeSurrogateInvalid: return RAPIDJSON_ERROR_STRING("The surrogate pair in string is invalid.");
53 | case kParseErrorStringEscapeInvalid: return RAPIDJSON_ERROR_STRING("Invalid escape character in string.");
54 | case kParseErrorStringMissQuotationMark: return RAPIDJSON_ERROR_STRING("Missing a closing quotation mark in string.");
55 | case kParseErrorStringInvalidEncoding: return RAPIDJSON_ERROR_STRING("Invalid encoding in string.");
56 |
57 | case kParseErrorNumberTooBig: return RAPIDJSON_ERROR_STRING("Number too big to be stored in double.");
58 | case kParseErrorNumberMissFraction: return RAPIDJSON_ERROR_STRING("Miss fraction part in number.");
59 | case kParseErrorNumberMissExponent: return RAPIDJSON_ERROR_STRING("Miss exponent in number.");
60 |
61 | case kParseErrorTermination: return RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error.");
62 | case kParseErrorUnspecificSyntaxError: return RAPIDJSON_ERROR_STRING("Unspecific syntax error.");
63 |
64 | default: return RAPIDJSON_ERROR_STRING("Unknown error.");
65 | }
66 | }
67 |
68 | RAPIDJSON_NAMESPACE_END
69 |
70 | #ifdef __clang__
71 | RAPIDJSON_DIAG_POP
72 | #endif
73 |
74 | #endif // RAPIDJSON_ERROR_EN_H_
75 |
--------------------------------------------------------------------------------
/xmrstak/rapidjson/filereadstream.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_FILEREADSTREAM_H_
16 | #define RAPIDJSON_FILEREADSTREAM_H_
17 |
18 | #include "stream.h"
19 | #include
20 |
21 | #ifdef __clang__
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(padded)
24 | RAPIDJSON_DIAG_OFF(unreachable-code)
25 | RAPIDJSON_DIAG_OFF(missing-noreturn)
26 | #endif
27 |
28 | RAPIDJSON_NAMESPACE_BEGIN
29 |
30 | //! File byte stream for input using fread().
31 | /*!
32 | \note implements Stream concept
33 | */
34 | class FileReadStream {
35 | public:
36 | typedef char Ch; //!< Character type (byte).
37 |
38 | //! Constructor.
39 | /*!
40 | \param fp File pointer opened for read.
41 | \param buffer user-supplied buffer.
42 | \param bufferSize size of buffer in bytes. Must >=4 bytes.
43 | */
44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) {
45 | RAPIDJSON_ASSERT(fp_ != 0);
46 | RAPIDJSON_ASSERT(bufferSize >= 4);
47 | Read();
48 | }
49 |
50 | Ch Peek() const { return *current_; }
51 | Ch Take() { Ch c = *current_; Read(); return c; }
52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); }
53 |
54 | // Not implemented
55 | void Put(Ch) { RAPIDJSON_ASSERT(false); }
56 | void Flush() { RAPIDJSON_ASSERT(false); }
57 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
58 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
59 |
60 | // For encoding detection only.
61 | const Ch* Peek4() const {
62 | return (current_ + 4 <= bufferLast_) ? current_ : 0;
63 | }
64 |
65 | private:
66 | void Read() {
67 | if (current_ < bufferLast_)
68 | ++current_;
69 | else if (!eof_) {
70 | count_ += readCount_;
71 | readCount_ = fread(buffer_, 1, bufferSize_, fp_);
72 | bufferLast_ = buffer_ + readCount_ - 1;
73 | current_ = buffer_;
74 |
75 | if (readCount_ < bufferSize_) {
76 | buffer_[readCount_] = '\0';
77 | ++bufferLast_;
78 | eof_ = true;
79 | }
80 | }
81 | }
82 |
83 | std::FILE* fp_;
84 | Ch *buffer_;
85 | size_t bufferSize_;
86 | Ch *bufferLast_;
87 | Ch *current_;
88 | size_t readCount_;
89 | size_t count_; //!< Number of characters read
90 | bool eof_;
91 | };
92 |
93 | RAPIDJSON_NAMESPACE_END
94 |
95 | #ifdef __clang__
96 | RAPIDJSON_DIAG_POP
97 | #endif
98 |
99 | #endif // RAPIDJSON_FILESTREAM_H_
100 |
--------------------------------------------------------------------------------
/xmrstak/rapidjson/filewritestream.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_FILEWRITESTREAM_H_
16 | #define RAPIDJSON_FILEWRITESTREAM_H_
17 |
18 | #include "stream.h"
19 | #include
20 |
21 | #ifdef __clang__
22 | RAPIDJSON_DIAG_PUSH
23 | RAPIDJSON_DIAG_OFF(unreachable-code)
24 | #endif
25 |
26 | RAPIDJSON_NAMESPACE_BEGIN
27 |
28 | //! Wrapper of C file stream for input using fread().
29 | /*!
30 | \note implements Stream concept
31 | */
32 | class FileWriteStream {
33 | public:
34 | typedef char Ch; //!< Character type. Only support char.
35 |
36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
37 | RAPIDJSON_ASSERT(fp_ != 0);
38 | }
39 |
40 | void Put(char c) {
41 | if (current_ >= bufferEnd_)
42 | Flush();
43 |
44 | *current_++ = c;
45 | }
46 |
47 | void PutN(char c, size_t n) {
48 | size_t avail = static_cast(bufferEnd_ - current_);
49 | while (n > avail) {
50 | std::memset(current_, c, avail);
51 | current_ += avail;
52 | Flush();
53 | n -= avail;
54 | avail = static_cast(bufferEnd_ - current_);
55 | }
56 |
57 | if (n > 0) {
58 | std::memset(current_, c, n);
59 | current_ += n;
60 | }
61 | }
62 |
63 | void Flush() {
64 | if (current_ != buffer_) {
65 | size_t result = fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_);
66 | if (result < static_cast(current_ - buffer_)) {
67 | // failure deliberately ignored at this time
68 | // added to avoid warn_unused_result build errors
69 | }
70 | current_ = buffer_;
71 | }
72 | }
73 |
74 | // Not implemented
75 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
76 | char Take() { RAPIDJSON_ASSERT(false); return 0; }
77 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
78 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
79 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
80 |
81 | private:
82 | // Prohibit copy constructor & assignment operator.
83 | FileWriteStream(const FileWriteStream&);
84 | FileWriteStream& operator=(const FileWriteStream&);
85 |
86 | std::FILE* fp_;
87 | char *buffer_;
88 | char *bufferEnd_;
89 | char *current_;
90 | };
91 |
92 | //! Implement specialized version of PutN() with memset() for better performance.
93 | template<>
94 | inline void PutN(FileWriteStream& stream, char c, size_t n) {
95 | stream.PutN(c, n);
96 | }
97 |
98 | RAPIDJSON_NAMESPACE_END
99 |
100 | #ifdef __clang__
101 | RAPIDJSON_DIAG_POP
102 | #endif
103 |
104 | #endif // RAPIDJSON_FILESTREAM_H_
105 |
--------------------------------------------------------------------------------
/xmrstak/rapidjson/fwd.h:
--------------------------------------------------------------------------------
1 | // Tencent is pleased to support the open source community by making RapidJSON available.
2 | //
3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
4 | //
5 | // Licensed under the MIT License (the "License"); you may not use this file except
6 | // in compliance with the License. You may obtain a copy of the License at
7 | //
8 | // http://opensource.org/licenses/MIT
9 | //
10 | // Unless required by applicable law or agreed to in writing, software distributed
11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the
13 | // specific language governing permissions and limitations under the License.
14 |
15 | #ifndef RAPIDJSON_FWD_H_
16 | #define RAPIDJSON_FWD_H_
17 |
18 | #include "rapidjson.h"
19 |
20 | RAPIDJSON_NAMESPACE_BEGIN
21 |
22 | // encodings.h
23 |
24 | template struct UTF8;
25 | template struct UTF16;
26 | template struct UTF16BE;
27 | template struct UTF16LE;
28 | template struct UTF32;
29 | template struct UTF32BE;
30 | template struct UTF32LE;
31 | template struct ASCII;
32 | template struct AutoUTF;
33 |
34 | template
35 | struct Transcoder;
36 |
37 | // allocators.h
38 |
39 | class CrtAllocator;
40 |
41 | template
42 | class MemoryPoolAllocator;
43 |
44 | // stream.h
45 |
46 | template
47 | struct GenericStringStream;
48 |
49 | typedef GenericStringStream > StringStream;
50 |
51 | template
52 | struct GenericInsituStringStream;
53 |
54 | typedef GenericInsituStringStream > InsituStringStream;
55 |
56 | // stringbuffer.h
57 |
58 | template
59 | class GenericStringBuffer;
60 |
61 | typedef GenericStringBuffer, CrtAllocator> StringBuffer;
62 |
63 | // filereadstream.h
64 |
65 | class FileReadStream;
66 |
67 | // filewritestream.h
68 |
69 | class FileWriteStream;
70 |
71 | // memorybuffer.h
72 |
73 | template
74 | struct GenericMemoryBuffer;
75 |
76 | typedef GenericMemoryBuffer