Merge 5579440640
into 410084384e
This commit is contained in:
commit
40c6d1f970
110 changed files with 13816 additions and 5900 deletions
208
.github/workflows/deploy.yml
vendored
Normal file
208
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,208 @@
|
|||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
name: Create release and build artifacts
|
||||
|
||||
jobs:
|
||||
build_win:
|
||||
name: Build Windows artifacts
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: Checkout deps
|
||||
run: git clone https://github.com/xmrig/xmrig-deps.git
|
||||
- name: Build project on Windows
|
||||
run: |
|
||||
cmake . -G "MinGW Makefiles" -DXMRIG_DEPS=xmrig-deps\gcc\x64
|
||||
make -j2
|
||||
copy src\config.json .
|
||||
copy bin\WinRing0\WinRing0x64.sys .
|
||||
7z a -tzip -mx windows_build.zip xmrig.exe config.json WinRing0x64.sys
|
||||
- name: Upload Windows build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: windows_build
|
||||
path: windows_build.zip
|
||||
|
||||
build_lin:
|
||||
name: Build Ubuntu artifacts
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Prepare Ubuntu tools
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: Build project on Ubuntu
|
||||
run: |
|
||||
cmake .
|
||||
make -j$(nproc)
|
||||
cp src/config.json .
|
||||
tar cfz ubuntu_build.tar.gz xmrig config.json
|
||||
- name: Upload Ubuntu build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: ubuntu_build
|
||||
path: ubuntu_build.tar.gz
|
||||
|
||||
build_macos:
|
||||
name: Build MacOS artifacts
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Prepare MacOS tools
|
||||
run: |
|
||||
brew install cmake libuv openssl hwloc
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: Build hwloc on MacOS
|
||||
run: |
|
||||
curl -O https://download.open-mpi.org/release/hwloc/v2.1/hwloc-2.1.0.tar.bz2
|
||||
tar xjf hwloc-2.1.0.tar.bz2
|
||||
cd hwloc-2.1.0
|
||||
./configure --disable-shared --enable-static --disable-io --disable-libxml2
|
||||
make -j$(sysctl -n hw.logicalcpu)
|
||||
cd ..
|
||||
- name: Build project on MacOS
|
||||
run: |
|
||||
cmake . -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DHWLOC_INCLUDE_DIR=hwloc-2.1.0/include -DHWLOC_LIBRARY=hwloc-2.1.0/hwloc/.libs/libhwloc.a
|
||||
make -j$(sysctl -n hw.logicalcpu)
|
||||
cp src/config.json .
|
||||
tar cfz macos_build.tar.gz xmrig config.json
|
||||
- name: Upload MacOS build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: macos_build
|
||||
path: macos_build.tar.gz
|
||||
|
||||
build_lin_rh7:
|
||||
name: Build CentOS 7 artifacts
|
||||
runs-on: ubuntu-latest
|
||||
container: centos:7
|
||||
steps:
|
||||
- name: Prepare CentOS 7 tools
|
||||
run: |
|
||||
yum install -y centos-release-scl epel-release
|
||||
yum install -y devtoolset-9
|
||||
yum install -y wget git cmake3 automake libtool autoconf libstdc++-static glibc-static
|
||||
- name: Checkout code
|
||||
run: |
|
||||
git clone https://github.com/MoneroOcean/xmrig.git .
|
||||
git checkout ${GITHUB_REF:10}
|
||||
- name: Build project on CentOS 7
|
||||
run: |
|
||||
source /opt/rh/devtoolset-9/enable
|
||||
cd scripts
|
||||
./build_deps.sh
|
||||
cd ..
|
||||
cmake3 . -DXMRIG_DEPS=scripts/deps
|
||||
make -j$(nproc)
|
||||
cp src/config.json .
|
||||
tar cfz centos7_build.tar.gz xmrig config.json
|
||||
- name: Upload CentOS 7 build artifacts
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: centos7_build
|
||||
path: centos7_build.tar.gz
|
||||
|
||||
deploy:
|
||||
needs: [build_win, build_lin, build_macos, build_lin_rh7]
|
||||
name: Create release and upload artifacts
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1.0.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Set version
|
||||
id: version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF:10}
|
||||
- name: Download Windows build artifacts
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: windows_build
|
||||
- name: Download Ubuntu build artifacts
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: ubuntu_build
|
||||
- name: Download MacOS build artifacts
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: macos_build
|
||||
- name: Download CentOS 7 build artifacts
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: centos7_build
|
||||
- name: Upload Windows build release asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: windows_build/windows_build.zip
|
||||
asset_name: xmrig-${{steps.version.outputs.VERSION}}-win64.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Upload Ubuntu build release asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ubuntu_build/ubuntu_build.tar.gz
|
||||
asset_name: xmrig-${{steps.version.outputs.VERSION}}-lin64.tar.gz
|
||||
asset_content_type: application/zip
|
||||
- name: Upload MacOS build release asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: macos_build/macos_build.tar.gz
|
||||
asset_name: xmrig-${{steps.version.outputs.VERSION}}-mac64.tar.gz
|
||||
asset_content_type: application/zip
|
||||
- name: Upload CentOS 7 build release asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: centos7_build/centos7_build.tar.gz
|
||||
asset_name: xmrig-${{steps.version.outputs.VERSION}}-lin64-compat.tar.gz
|
||||
asset_content_type: application/zip
|
||||
- name: Update xmrig_setup repo
|
||||
run: |
|
||||
git clone https://$GITHUB_ACTOR:${{secrets.xmrig_setup_key}}@github.com/MoneroOcean/xmrig_setup.git
|
||||
cd xmrig_setup
|
||||
git config user.name MoneroOcean
|
||||
git config user.email support@moneroocean.stream
|
||||
cp ../centos7_build/centos7_build.tar.gz xmrig.tar.gz
|
||||
cp ../windows_build/windows_build.zip xmrig.zip
|
||||
unzip xmrig.zip
|
||||
zip -u offline_miner_setup.zip xmrig.exe config.json WinRing0x64.sys
|
||||
git commit -m "xmrig "${GITHUB_REF:10}" based release" xmrig.tar.gz xmrig.zip offline_miner_setup.zip
|
||||
git push
|
||||
cd ..
|
||||
- name: Update hiveos repo
|
||||
run: |
|
||||
git clone https://$GITHUB_ACTOR:${{secrets.xmrig_setup_key}}@github.com/MoneroOcean/hiveos.git
|
||||
cd hiveos
|
||||
git config user.name MoneroOcean
|
||||
git config user.email support@moneroocean.stream
|
||||
tar xf ../centos7_build/centos7_build.tar.gz
|
||||
mv xmrig mo_xmrig/xmrig
|
||||
mv config.json mo_xmrig/config_global.json
|
||||
export VER=${GITHUB_REF:10}
|
||||
export VER=${VER//-/_}
|
||||
tar -zcvf mo_xmrig-$VER.tar.gz mo_xmrig
|
||||
git add mo_xmrig-$VER.tar.gz mo_xmrig/xmrig mo_xmrig/config_global.json
|
||||
git commit -m "xmrig "${GITHUB_REF:10}" based release" mo_xmrig-$VER.tar.gz
|
||||
git push
|
32
.github/workflows/test.yml
vendored
Normal file
32
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
on: push
|
||||
|
||||
name: Test builds
|
||||
|
||||
jobs:
|
||||
build_win:
|
||||
name: Windows build
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: Checkout deps
|
||||
run: git clone https://github.com/xmrig/xmrig-deps.git
|
||||
- name: Build project on Windows
|
||||
run: |
|
||||
cmake . -G "MinGW Makefiles" -DXMRIG_DEPS=xmrig-deps\gcc\x64
|
||||
make -j2
|
||||
|
||||
build_lin:
|
||||
name: Ubuntu build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Prepare Ubuntu tools
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y git build-essential cmake libuv1-dev libssl-dev libhwloc-dev
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@master
|
||||
- name: Build project on Ubuntu
|
||||
run: |
|
||||
cmake .
|
||||
make -j$(nproc)
|
|
@ -5,6 +5,7 @@ option(WITH_HWLOC "Enable hwloc support" ON)
|
|||
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
|
||||
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON)
|
||||
option(WITH_CN_PICO "Enable CryptoNight-Pico algorithm" ON)
|
||||
option(WITH_CN_GPU "Enable CryptoNight-GPU algorithm" ON)
|
||||
option(WITH_CN_FEMTO "Enable CryptoNight-UPX2 algorithm" ON)
|
||||
option(WITH_RANDOMX "Enable RandomX algorithms family" ON)
|
||||
option(WITH_ARGON2 "Enable Argon2 algorithms family" ON)
|
||||
|
@ -23,6 +24,7 @@ option(WITH_NVML "Enable NVML (NVIDIA Management Library) support (on
|
|||
option(WITH_ADL "Enable ADL (AMD Display Library) or sysfs support (only if OpenCL backend enabled)" ON)
|
||||
option(WITH_STRICT_CACHE "Enable strict checks for OpenCL cache" ON)
|
||||
option(WITH_INTERLEAVE_DEBUG_LOG "Enable debug log for threads interleave" OFF)
|
||||
option(WITH_MO_BENCHMARK "Enable Benchmark module and algo-perf feature (for MoneroOcean)" ON)
|
||||
option(WITH_PROFILING "Enable profiling for developers" OFF)
|
||||
option(WITH_SSE4_1 "Enable SSE 4.1 for Blake2" ON)
|
||||
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
|
||||
|
@ -124,6 +126,13 @@ set(SOURCES_CRYPTO
|
|||
src/crypto/common/VirtualMemory.cpp
|
||||
)
|
||||
|
||||
if (WITH_MO_BENCHMARK)
|
||||
list(APPEND SOURCES
|
||||
src/core/MoBenchmark.cpp
|
||||
)
|
||||
add_definitions(/DXMRIG_FEATURE_MO_BENCHMARK)
|
||||
endif()
|
||||
|
||||
if (WITH_HWLOC)
|
||||
list(APPEND HEADERS_CRYPTO
|
||||
src/crypto/common/NUMAMemoryPool.h
|
||||
|
@ -184,6 +193,7 @@ include(cmake/astrobwt.cmake)
|
|||
include(cmake/kawpow.cmake)
|
||||
include(cmake/OpenSSL.cmake)
|
||||
include(cmake/asm.cmake)
|
||||
include(cmake/cn-gpu.cmake)
|
||||
|
||||
if (WITH_CN_LITE)
|
||||
add_definitions(/DXMRIG_ALGO_CN_LITE)
|
||||
|
|
16
README.md
16
README.md
|
@ -1,21 +1,21 @@
|
|||
# XMRig
|
||||
|
||||
[](https://github.com/xmrig/xmrig/releases)
|
||||
[](https://github.com/xmrig/xmrig/releases)
|
||||
[](https://github.com/xmrig/xmrig/releases)
|
||||
[](https://github.com/xmrig/xmrig/blob/master/LICENSE)
|
||||
[](https://github.com/xmrig/xmrig/stargazers)
|
||||
[](https://github.com/xmrig/xmrig/network)
|
||||
[](https://github.com/MoneroOcean/xmrig/releases)
|
||||
[](https://github.com/MoneroOcean/xmrig/releases)
|
||||
[](https://github.com/MoneroOcean/xmrig/releases)
|
||||
[](https://github.com/MoneroOcean/xmrig/blob/master/LICENSE)
|
||||
[](https://github.com/MoneroOcean/xmrig/stargazers)
|
||||
[](https://github.com/MoneroOcean/xmrig/network)
|
||||
|
||||
XMRig is a high performance, open source, cross platform RandomX, KawPow, CryptoNight and AstroBWT unified CPU/GPU miner and [RandomX benchmark](https://xmrig.com/benchmark). Official binaries are available for Windows, Linux, macOS and FreeBSD.
|
||||
|
||||
## Mining backends
|
||||
- **CPU** (x64/ARMv8)
|
||||
- **OpenCL** for AMD GPUs.
|
||||
- **CUDA** for NVIDIA GPUs via external [CUDA plugin](https://github.com/xmrig/xmrig-cuda).
|
||||
- **CUDA** for NVIDIA GPUs via external [CUDA plugin](https://github.com/MoneroOcean/xmrig-cuda).
|
||||
|
||||
## Download
|
||||
* **[Binary releases](https://github.com/xmrig/xmrig/releases)**
|
||||
* **[Binary releases](https://github.com/MoneroOcean/xmrig/releases)**
|
||||
* **[Build from source](https://xmrig.com/docs/miner/build)**
|
||||
|
||||
## Usage
|
||||
|
|
31
cmake/cn-gpu.cmake
Normal file
31
cmake/cn-gpu.cmake
Normal file
|
@ -0,0 +1,31 @@
|
|||
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(/DXMRIG_ALGO_CN_GPU)
|
||||
|
||||
if (XMRIG_ARM)
|
||||
list(APPEND SOURCES_CRYPTO
|
||||
src/crypto/cn/gpu/cn_gpu_arm.cpp
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
set_source_files_properties(src/crypto/cn/gpu/cn_gpu_arm.cpp PROPERTIES COMPILE_FLAGS "-O3")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND SOURCES_CRYPTO
|
||||
src/crypto/cn/gpu/cn_gpu_avx.cpp
|
||||
src/crypto/cn/gpu/cn_gpu_ssse3.cpp
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
||||
set_source_files_properties(src/crypto/cn/gpu/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "-O3 -mavx2")
|
||||
set_source_files_properties(src/crypto/cn/gpu/cn_gpu_ssse3.cpp PROPERTIES COMPILE_FLAGS "-O3")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||
set_source_files_properties(src/crypto/cn/gpu/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "-O3 -mavx2")
|
||||
set_source_files_properties(src/crypto/cn/gpu/cn_gpu_ssse3.cpp PROPERTIES COMPILE_FLAGS "-O1")
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES MSVC)
|
||||
set_source_files_properties(src/crypto/cn/gpu/cn_gpu_avx.cpp PROPERTIES COMPILE_FLAGS "/arch:AVX")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
else()
|
||||
remove_definitions(/DXMRIG_ALGO_CN_GPU)
|
||||
endif()
|
|
@ -40,6 +40,13 @@ if (WITH_RANDOMX)
|
|||
src/crypto/rx/RxDataset.cpp
|
||||
src/crypto/rx/RxQueue.cpp
|
||||
src/crypto/rx/RxVm.cpp
|
||||
|
||||
### Removed useless includes
|
||||
src/crypto/randomx/panthera/sha256.c
|
||||
src/crypto/randomx/panthera/KangarooTwelve.c
|
||||
src/crypto/randomx/panthera/KeccakP-1600-reference.c
|
||||
src/crypto/randomx/panthera/KeccakSpongeWidth1600.c
|
||||
src/crypto/randomx/panthera/yespower-opt.c
|
||||
)
|
||||
|
||||
if (WITH_ASM AND CMAKE_C_COMPILER_ID MATCHES MSVC)
|
||||
|
|
|
@ -28,6 +28,7 @@ Option `coin` useful for pools without [algorithm negotiation](https://xmrig.com
|
|||
| `cn/zls` | 2 MB | 2.14.0+ | CryptoNight variant 2 with 3/4 iterations. | |
|
||||
| `cn/double` | 2 MB | 2.14.0+ | CryptoNight variant 2 with double iterations. | |
|
||||
| `cn/r` | 2 MB | 2.13.0+ | CryptoNightR (Monero's variant 4). | |
|
||||
| `cn/gpu` | 2 MB | 2.11.0+ | CryptoNight-GPU. | |
|
||||
| `cn-pico` | 256 KB | 2.10.0+ | CryptoNight-Pico. | |
|
||||
| `cn/half` | 2 MB | 2.9.0+ | CryptoNight variant 2 with half iterations. | |
|
||||
| `cn/2` | 2 MB | 2.8.0+ | CryptoNight variant 2. | |
|
||||
|
|
1
doc/build/CMAKE_OPTIONS.md
vendored
1
doc/build/CMAKE_OPTIONS.md
vendored
|
@ -6,6 +6,7 @@
|
|||
* **`-DWITH_CN_LITE=OFF`** disable all CryptoNight-Lite algorithms (`cn-lite/0`, `cn-lite/1`).
|
||||
* **`-DWITH_CN_HEAVY=OFF`** disable all CryptoNight-Heavy algorithms (`cn-heavy/0`, `cn-heavy/xhv`, `cn-heavy/tube`).
|
||||
* **`-DWITH_CN_PICO=OFF`** disable CryptoNight-Pico algorithm (`cn-pico`).
|
||||
* **`-DWITH_CN_GPU=OFF`** disable CryptoNight-GPU algorithm (`cn/gpu`).
|
||||
* **`-DWITH_RANDOMX=OFF`** disable RandomX algorithms (`rx/loki`, `rx/wow`).
|
||||
* **`-DWITH_ARGON2=OFF`** disable Argon2 algorithms (`argon2/chukwa`, `argon2/wrkz`).
|
||||
|
||||
|
|
|
@ -86,10 +86,20 @@ function kawpow()
|
|||
}
|
||||
|
||||
|
||||
function cn_gpu()
|
||||
{
|
||||
const cn_gpu = opencl_minify(addIncludes('cryptonight_gpu.cl', [ 'wolf-aes.cl', 'keccak.cl' ]));
|
||||
|
||||
// fs.writeFileSync('cryptonight_gpu_gen.cl', cn_gpu);
|
||||
fs.writeFileSync('cryptonight_gpu_cl.h', text2h(cn_gpu, 'xmrig', 'cryptonight_gpu_cl'));
|
||||
}
|
||||
|
||||
|
||||
process.chdir(path.resolve('src/backend/opencl/cl/cn'));
|
||||
|
||||
cn();
|
||||
cn_r();
|
||||
cn_gpu();
|
||||
|
||||
process.chdir(cwd);
|
||||
process.chdir(path.resolve('src/backend/opencl/cl/rx'));
|
||||
|
|
14
src/App.cpp
14
src/App.cpp
|
@ -85,7 +85,21 @@ int xmrig::App::exec()
|
|||
return 0;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
m_controller->pre_start();
|
||||
m_controller->config()->benchmark().set_controller(m_controller);
|
||||
|
||||
if (m_controller->config()->benchmark().isNewBenchRun() || m_controller->config()->isRebenchAlgo()) {
|
||||
if (m_controller->config()->isShouldSave()) {
|
||||
m_controller->config()->save();
|
||||
}
|
||||
m_controller->config()->benchmark().start();
|
||||
} else {
|
||||
m_controller->start();
|
||||
}
|
||||
# else
|
||||
m_controller->start();
|
||||
# endif
|
||||
|
||||
rc = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
uv_loop_close(uv_default_loop());
|
||||
|
|
|
@ -46,6 +46,10 @@ const char *ocl_tag();
|
|||
const char *cuda_tag();
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
const char *bm_tag();
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "backend/common/Threads.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "backend/cpu/CpuThreads.h"
|
||||
|
@ -136,6 +138,8 @@ xmrig::String xmrig::Threads<T>::profileName(const Algorithm &algorithm, bool st
|
|||
}
|
||||
}
|
||||
|
||||
if (std::is_same<T, CpuThreads>::value && (name == "defyx" || name == "panthera") && has("rx")) return "rx";
|
||||
|
||||
if (has(kAsterisk)) {
|
||||
return kAsterisk;
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ bool xmrig::CpuBackend::isEnabled() const
|
|||
|
||||
bool xmrig::CpuBackend::isEnabled(const Algorithm &algorithm) const
|
||||
{
|
||||
return !d_ptr->controller->config()->cpu().threads().get(algorithm).isEmpty();
|
||||
return algorithm.isValid() && !d_ptr->controller->config()->cpu().threads().get(algorithm).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,6 +60,10 @@ size_t inline generate<Algorithm::CN>(Threads<CpuThreads> &threads, uint32_t lim
|
|||
++count;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
count += generate("cn/gpu", threads, Algorithm::CN_GPU, limit);
|
||||
# endif
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
@ -143,6 +147,10 @@ size_t inline generate<Algorithm::RANDOM_X>(Threads<CpuThreads> &threads, uint32
|
|||
count += threads.move("rx/wow", std::move(wow));
|
||||
}
|
||||
|
||||
if (!threads.isExist(Algorithm::RX_XLA)) {
|
||||
count += generate("panthera", threads, Algorithm::RX_XLA, limit);
|
||||
}
|
||||
|
||||
count += generate("rx", threads, Algorithm::RX_0, limit);
|
||||
|
||||
return count;
|
||||
|
|
|
@ -166,11 +166,22 @@ bool xmrig::CpuWorker<N>::selfTest()
|
|||
verify(Algorithm::CN_RWZ, test_output_rwz) &&
|
||||
verify(Algorithm::CN_ZLS, test_output_zls) &&
|
||||
verify(Algorithm::CN_CCX, test_output_ccx) &&
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
verify(Algorithm::CN_GPU, test_output_gpu) &&
|
||||
# endif
|
||||
verify(Algorithm::CN_DOUBLE, test_output_double);
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (!rc || N > 1) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
return verify(Algorithm::CN_GPU, test_output_gpu);
|
||||
# else
|
||||
return rc;
|
||||
# endif
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
if (m_algorithm.family() == Algorithm::CN_LITE) {
|
||||
return verify(Algorithm::CN_LITE_0, test_output_v0_lite) &&
|
||||
|
@ -279,12 +290,13 @@ void xmrig::CpuWorker<N>::start()
|
|||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (job.algorithm().family() == Algorithm::RANDOM_X) {
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
if (job.hasMinerSignature()) {
|
||||
job.generateMinerSignature(m_job.blob(), job.size(), miner_signature_ptr);
|
||||
}
|
||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size());
|
||||
randomx_calculate_hash_first(m_vm, tempHash, m_job.blob(), job.size(), job.algorithm());
|
||||
}
|
||||
|
||||
if (!nextRound()) {
|
||||
|
@ -295,7 +307,7 @@ void xmrig::CpuWorker<N>::start()
|
|||
memcpy(miner_signature_saved, miner_signature_ptr, sizeof(miner_signature_saved));
|
||||
job.generateMinerSignature(m_job.blob(), job.size(), miner_signature_ptr);
|
||||
}
|
||||
randomx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash);
|
||||
randomx_calculate_hash_next(m_vm, tempHash, m_job.blob(), job.size(), m_hash, job.algorithm());
|
||||
}
|
||||
else
|
||||
# endif
|
||||
|
|
|
@ -301,9 +301,12 @@ const char *xmrig::BasicCpuInfo::backend() const
|
|||
}
|
||||
|
||||
|
||||
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint32_t) const
|
||||
xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint32_t limit) const
|
||||
{
|
||||
const size_t count = std::thread::hardware_concurrency();
|
||||
const uint32_t count = std::thread::hardware_concurrency();
|
||||
const uint32_t count_limit = std::max(static_cast<uint32_t>(count * (limit / 100.0f)), 1U);
|
||||
const uint32_t count_limit2 = std::max(static_cast<uint32_t>(count / 2), count_limit);
|
||||
const uint32_t count_limit4 = std::max(static_cast<uint32_t>(count / 4), count_limit);
|
||||
|
||||
if (count == 1) {
|
||||
return 1;
|
||||
|
@ -313,13 +316,13 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
|
|||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
if (f == Algorithm::CN_LITE) {
|
||||
return CpuThreads(count, 1);
|
||||
return CpuThreads(count_limit, 1);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_PICO
|
||||
if (f == Algorithm::CN_PICO) {
|
||||
return CpuThreads(count, 2);
|
||||
return CpuThreads(count_limit, 2);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -331,37 +334,51 @@ xmrig::CpuThreads xmrig::BasicCpuInfo::threads(const Algorithm &algorithm, uint3
|
|||
|
||||
# ifdef XMRIG_ALGO_CN_HEAVY
|
||||
if (f == Algorithm::CN_HEAVY) {
|
||||
return CpuThreads(std::max<size_t>(count / 4, 1), 1);
|
||||
return CpuThreads(count_limit4, 1);
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (f == Algorithm::RANDOM_X) {
|
||||
if (algorithm == Algorithm::RX_WOW) {
|
||||
return count;
|
||||
return count_limit;
|
||||
}
|
||||
|
||||
return std::max<size_t>(count / 2, 1);
|
||||
if (algorithm == Algorithm::RX_XLA) {
|
||||
CpuThreads threads;
|
||||
for (size_t i = 0; i < count_limit2; ++i) {
|
||||
threads.add(i, 0);
|
||||
}
|
||||
return threads;
|
||||
}
|
||||
|
||||
return count_limit2;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
if (f == Algorithm::ARGON2) {
|
||||
return count;
|
||||
return count_limit;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_ASTROBWT
|
||||
if (f == Algorithm::ASTROBWT) {
|
||||
CpuThreads threads;
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
for (size_t i = 0; i < count_limit; ++i) {
|
||||
threads.add(i, 0);
|
||||
}
|
||||
return threads;
|
||||
}
|
||||
# endif
|
||||
|
||||
return CpuThreads(std::max<size_t>(count / 2, 1), 1);
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (algorithm == Algorithm::CN_GPU) {
|
||||
return count_limit;
|
||||
}
|
||||
# endif
|
||||
|
||||
return CpuThreads(count_limit2, 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -341,10 +341,18 @@ void xmrig::HwlocCpuInfo::processTopLevelCache(hwloc_obj_t cache, const Algorith
|
|||
intensity = 2;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (algorithm == Algorithm::CN_GPU) {
|
||||
cacheHashes = PUs;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
if (extra == 0 && algorithm.l2() > 0) {
|
||||
cacheHashes = std::min<size_t>(std::max<size_t>(L2 / algorithm.l2(), cores.size()), cacheHashes);
|
||||
}
|
||||
if (algorithm == Algorithm::RX_XLA) cacheHashes = cores.size();
|
||||
|
||||
# endif
|
||||
|
||||
if (limit > 0) {
|
||||
|
|
|
@ -64,6 +64,10 @@ size_t inline generate<Algorithm::CN>(Threads<CudaThreads> &threads, const std::
|
|||
count++;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
count += generate("cn/gpu", threads, Algorithm::CN_GPU, devices);
|
||||
# endif
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,10 @@ size_t inline generate<Algorithm::CN>(Threads<OclThreads> &threads, const std::v
|
|||
count++;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
count += generate("cn/gpu", threads, Algorithm::CN_GPU, devices);
|
||||
# endif
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,20 @@ public:
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
OclThread(uint32_t index, uint32_t intensity, uint32_t worksize, uint32_t threads, uint32_t unrollFactor) :
|
||||
m_fields(0),
|
||||
m_threads(threads, -1),
|
||||
m_index(index),
|
||||
m_memChunk(0),
|
||||
m_stridedIndex(0),
|
||||
m_unrollFactor(unrollFactor),
|
||||
m_worksize(worksize)
|
||||
{
|
||||
setIntensity(intensity);
|
||||
}
|
||||
# endif
|
||||
|
||||
OclThread(const rapidjson::Value &value);
|
||||
|
||||
inline bool isAsm() const { return m_gcnAsm; }
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
# include "backend/opencl/runners/OclKawPowRunner.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
# include "backend/opencl/runners/OclRyoRunner.h"
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <thread>
|
||||
|
||||
|
@ -102,6 +106,12 @@ xmrig::OclWorker::OclWorker(size_t id, const OclLaunchData &data) :
|
|||
break;
|
||||
|
||||
default:
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (m_algorithm == Algorithm::CN_GPU) {
|
||||
m_runner = new OclRyoRunner(id, data);
|
||||
}
|
||||
else
|
||||
# endif
|
||||
m_runner = new OclCnRunner(id, data);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,10 @@
|
|||
# include "backend/opencl/cl/kawpow/kawpow_dag_cl.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
# include "backend/opencl/cl/cn/cryptonight_gpu_cl.h"
|
||||
#endif
|
||||
|
||||
|
||||
const char *xmrig::OclSource::get(const Algorithm &algorithm)
|
||||
{
|
||||
|
@ -62,5 +66,11 @@ const char *xmrig::OclSource::get(const Algorithm &algorithm)
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (algorithm == Algorithm::CN_GPU) {
|
||||
return cryptonight_gpu_cl;
|
||||
}
|
||||
# endif
|
||||
|
||||
return cryptonight_cl;
|
||||
}
|
||||
|
|
|
@ -17,17 +17,19 @@
|
|||
#define ALGO_CN_PICO_0 16
|
||||
#define ALGO_CN_PICO_TLO 17
|
||||
#define ALGO_CN_CCX 18
|
||||
#define ALGO_CN_UPX2 19
|
||||
#define ALGO_RX_0 20
|
||||
#define ALGO_RX_WOW 21
|
||||
#define ALGO_RX_ARQMA 22
|
||||
#define ALGO_RX_SFX 23
|
||||
#define ALGO_RX_KEVA 24
|
||||
#define ALGO_AR2_CHUKWA 25
|
||||
#define ALGO_AR2_CHUKWA_V2 26
|
||||
#define ALGO_AR2_WRKZ 27
|
||||
#define ALGO_ASTROBWT_DERO 28
|
||||
#define ALGO_KAWPOW_RVN 29
|
||||
#define ALGO_CN_GPU 19
|
||||
#define ALGO_CN_UPX2 20
|
||||
#define ALGO_RX_0 21
|
||||
#define ALGO_RX_WOW 22
|
||||
#define ALGO_RX_ARQ 23
|
||||
#define ALGO_RX_SFX 24
|
||||
#define ALGO_RX_KEVA 25
|
||||
#define ALGO_AR2_CHUKWA 26
|
||||
#define ALGO_AR2_CHUKWA_V2 27
|
||||
#define ALGO_AR2_WRKZ 28
|
||||
#define ALGO_ASTROBWT_DERO 29
|
||||
#define ALGO_KAWPOW_RVN 30
|
||||
#define ALGO_RX_XLA 31
|
||||
|
||||
#define FAMILY_UNKNOWN 0
|
||||
#define FAMILY_CN 1
|
||||
|
|
File diff suppressed because it is too large
Load diff
520
src/backend/opencl/cl/cn/cryptonight_gpu.cl
Normal file
520
src/backend/opencl/cl/cn/cryptonight_gpu.cl
Normal file
|
@ -0,0 +1,520 @@
|
|||
#include "wolf-aes.cl"
|
||||
#include "keccak.cl"
|
||||
|
||||
|
||||
inline uint getIdx()
|
||||
{
|
||||
return get_global_id(0) - get_global_offset(0);
|
||||
}
|
||||
|
||||
|
||||
#define IDX(x) (x)
|
||||
|
||||
|
||||
inline float4 _mm_add_ps(float4 a, float4 b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_sub_ps(float4 a, float4 b)
|
||||
{
|
||||
return a - b;
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_mul_ps(float4 a, float4 b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_div_ps(float4 a, float4 b)
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_and_ps(float4 a, int b)
|
||||
{
|
||||
return as_float4(as_int4(a) & (int4)(b));
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_or_ps(float4 a, int b)
|
||||
{
|
||||
return as_float4(as_int4(a) | (int4)(b));
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_fmod_ps(float4 v, float dc)
|
||||
{
|
||||
float4 d = (float4)(dc);
|
||||
float4 c = _mm_div_ps(v, d);
|
||||
c = trunc(c);
|
||||
c = _mm_mul_ps(c, d);
|
||||
return _mm_sub_ps(v, c);
|
||||
}
|
||||
|
||||
|
||||
inline int4 _mm_xor_si128(int4 a, int4 b)
|
||||
{
|
||||
return a ^ b;
|
||||
}
|
||||
|
||||
|
||||
inline float4 _mm_xor_ps(float4 a, int b)
|
||||
{
|
||||
return as_float4(as_int4(a) ^ (int4)(b));
|
||||
}
|
||||
|
||||
|
||||
inline int4 _mm_alignr_epi8(int4 a, const uint rot)
|
||||
{
|
||||
const uint right = 8 * rot;
|
||||
const uint left = (32 - 8 * rot);
|
||||
return (int4)(
|
||||
((uint)a.x >> right) | ( a.y << left ),
|
||||
((uint)a.y >> right) | ( a.z << left ),
|
||||
((uint)a.z >> right) | ( a.w << left ),
|
||||
((uint)a.w >> right) | ( a.x << left )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline global int4* scratchpad_ptr(uint idx, uint n, __global int *lpad) { return (__global int4*)((__global char*)lpad + (idx & MASK) + n * 16); }
|
||||
|
||||
|
||||
inline float4 fma_break(float4 x)
|
||||
{
|
||||
// Break the dependency chain by setting the exp to ?????01
|
||||
x = _mm_and_ps(x, 0xFEFFFFFF);
|
||||
return _mm_or_ps(x, 0x00800000);
|
||||
}
|
||||
|
||||
|
||||
inline void sub_round(float4 n0, float4 n1, float4 n2, float4 n3, float4 rnd_c, float4* n, float4* d, float4* c)
|
||||
{
|
||||
n1 = _mm_add_ps(n1, *c);
|
||||
float4 nn = _mm_mul_ps(n0, *c);
|
||||
nn = _mm_mul_ps(n1, _mm_mul_ps(nn,nn));
|
||||
nn = fma_break(nn);
|
||||
*n = _mm_add_ps(*n, nn);
|
||||
|
||||
n3 = _mm_sub_ps(n3, *c);
|
||||
float4 dd = _mm_mul_ps(n2, *c);
|
||||
dd = _mm_mul_ps(n3, _mm_mul_ps(dd,dd));
|
||||
dd = fma_break(dd);
|
||||
*d = _mm_add_ps(*d, dd);
|
||||
|
||||
//Constant feedback
|
||||
*c = _mm_add_ps(*c, rnd_c);
|
||||
*c = _mm_add_ps(*c, (float4)(0.734375f));
|
||||
float4 r = _mm_add_ps(nn, dd);
|
||||
r = _mm_and_ps(r, 0x807FFFFF);
|
||||
r = _mm_or_ps(r, 0x40000000);
|
||||
*c = _mm_add_ps(*c, r);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 9*8 + 2 = 74
|
||||
inline void round_compute(float4 n0, float4 n1, float4 n2, float4 n3, float4 rnd_c, float4* c, float4* r)
|
||||
{
|
||||
float4 n = (float4)(0.0f);
|
||||
float4 d = (float4)(0.0f);
|
||||
|
||||
sub_round(n0, n1, n2, n3, rnd_c, &n, &d, c);
|
||||
sub_round(n1, n2, n3, n0, rnd_c, &n, &d, c);
|
||||
sub_round(n2, n3, n0, n1, rnd_c, &n, &d, c);
|
||||
sub_round(n3, n0, n1, n2, rnd_c, &n, &d, c);
|
||||
sub_round(n3, n2, n1, n0, rnd_c, &n, &d, c);
|
||||
sub_round(n2, n1, n0, n3, rnd_c, &n, &d, c);
|
||||
sub_round(n1, n0, n3, n2, rnd_c, &n, &d, c);
|
||||
sub_round(n0, n3, n2, n1, rnd_c, &n, &d, c);
|
||||
|
||||
// Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0
|
||||
d = _mm_and_ps(d, 0xFF7FFFFF);
|
||||
d = _mm_or_ps(d, 0x40000000);
|
||||
*r =_mm_add_ps(*r, _mm_div_ps(n,d));
|
||||
}
|
||||
|
||||
|
||||
inline int4 single_compute(float4 n0, float4 n1, float4 n2, float4 n3, float cnt, float4 rnd_c, __local float4* sum)
|
||||
{
|
||||
float4 c= (float4)(cnt);
|
||||
// 35 maths calls follow (140 FLOPS)
|
||||
float4 r = (float4)(0.0f);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
round_compute(n0, n1, n2, n3, rnd_c, &c, &r);
|
||||
}
|
||||
|
||||
// do a quick fmod by setting exp to 2
|
||||
r = _mm_and_ps(r, 0x807FFFFF);
|
||||
r = _mm_or_ps(r, 0x40000000);
|
||||
*sum = r; // 34
|
||||
float4 x = (float4)(536870880.0f);
|
||||
r = _mm_mul_ps(r, x); // 35
|
||||
return convert_int4_rte(r);
|
||||
}
|
||||
|
||||
|
||||
inline void single_compute_wrap(const uint rot, int4 v0, int4 v1, int4 v2, int4 v3, float cnt, float4 rnd_c, __local float4* sum, __local int4* out)
|
||||
{
|
||||
float4 n0 = convert_float4_rte(v0);
|
||||
float4 n1 = convert_float4_rte(v1);
|
||||
float4 n2 = convert_float4_rte(v2);
|
||||
float4 n3 = convert_float4_rte(v3);
|
||||
|
||||
int4 r = single_compute(n0, n1, n2, n3, cnt, rnd_c, sum);
|
||||
*out = rot == 0 ? r : _mm_alignr_epi8(r, rot);
|
||||
}
|
||||
|
||||
|
||||
static const __constant uint look[16][4] = {
|
||||
{0, 1, 2, 3},
|
||||
{0, 2, 3, 1},
|
||||
{0, 3, 1, 2},
|
||||
{0, 3, 2, 1},
|
||||
|
||||
{1, 0, 2, 3},
|
||||
{1, 2, 3, 0},
|
||||
{1, 3, 0, 2},
|
||||
{1, 3, 2, 0},
|
||||
|
||||
{2, 1, 0, 3},
|
||||
{2, 0, 3, 1},
|
||||
{2, 3, 1, 0},
|
||||
{2, 3, 0, 1},
|
||||
|
||||
{3, 1, 2, 0},
|
||||
{3, 2, 0, 1},
|
||||
{3, 0, 1, 2},
|
||||
{3, 0, 2, 1}
|
||||
};
|
||||
|
||||
|
||||
static const __constant float ccnt[16] = {
|
||||
1.34375f,
|
||||
1.28125f,
|
||||
1.359375f,
|
||||
1.3671875f,
|
||||
|
||||
1.4296875f,
|
||||
1.3984375f,
|
||||
1.3828125f,
|
||||
1.3046875f,
|
||||
|
||||
1.4140625f,
|
||||
1.2734375f,
|
||||
1.2578125f,
|
||||
1.2890625f,
|
||||
|
||||
1.3203125f,
|
||||
1.3515625f,
|
||||
1.3359375f,
|
||||
1.4609375f
|
||||
};
|
||||
|
||||
|
||||
struct SharedMemChunk
|
||||
{
|
||||
int4 out[16];
|
||||
float4 va[16];
|
||||
};
|
||||
|
||||
|
||||
__attribute__((reqd_work_group_size(WORKSIZE * 16, 1, 1)))
|
||||
__kernel void cn1(__global int *lpad_in, __global int *spad, uint numThreads)
|
||||
{
|
||||
const uint gIdx = getIdx();
|
||||
uint chunk = get_local_id(0) / 16;
|
||||
|
||||
__global int* lpad = (__global int*)((__global char*)lpad_in + MEMORY * (gIdx/16));
|
||||
|
||||
__local struct SharedMemChunk smem_in[WORKSIZE];
|
||||
__local struct SharedMemChunk* smem = smem_in + chunk;
|
||||
|
||||
uint tid = get_local_id(0) % 16;
|
||||
|
||||
uint idxHash = gIdx/16;
|
||||
uint s = ((__global uint*)spad)[idxHash * 50] >> 8;
|
||||
float4 vs = (float4)(0);
|
||||
|
||||
// tid divided
|
||||
const uint tidd = tid / 4;
|
||||
// tid modulo
|
||||
const uint tidm = tid % 4;
|
||||
const uint block = tidd * 16 + tidm;
|
||||
|
||||
#pragma unroll CN_UNROLL
|
||||
for (uint i = 0; i < ITERATIONS; i++) {
|
||||
mem_fence(CLK_LOCAL_MEM_FENCE);
|
||||
int tmp = ((__global int*)scratchpad_ptr(s, tidd, lpad))[tidm];
|
||||
((__local int*)(smem->out))[tid] = tmp;
|
||||
mem_fence(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
{
|
||||
single_compute_wrap(
|
||||
tidm,
|
||||
*(smem->out + look[tid][0]),
|
||||
*(smem->out + look[tid][1]),
|
||||
*(smem->out + look[tid][2]),
|
||||
*(smem->out + look[tid][3]),
|
||||
ccnt[tid], vs, smem->va + tid,
|
||||
smem->out + tid
|
||||
);
|
||||
}
|
||||
mem_fence(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
int outXor = ((__local int*)smem->out)[block];
|
||||
for (uint dd = block + 4; dd < (tidd + 1) * 16; dd += 4) {
|
||||
outXor ^= ((__local int*)smem->out)[dd];
|
||||
}
|
||||
|
||||
((__global int*)scratchpad_ptr(s, tidd, lpad))[tidm] = outXor ^ tmp;
|
||||
((__local int*)smem->out)[tid] = outXor;
|
||||
|
||||
float va_tmp1 = ((__local float*)smem->va)[block] + ((__local float*)smem->va)[block + 4];
|
||||
float va_tmp2 = ((__local float*)smem->va)[block+ 8] + ((__local float*)smem->va)[block + 12];
|
||||
((__local float*)smem->va)[tid] = va_tmp1 + va_tmp2;
|
||||
|
||||
mem_fence(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
int out2 = ((__local int*)smem->out)[tid] ^ ((__local int*)smem->out)[tid + 4 ] ^ ((__local int*)smem->out)[tid + 8] ^ ((__local int*)smem->out)[tid + 12];
|
||||
va_tmp1 = ((__local float*)smem->va)[block] + ((__local float*)smem->va)[block + 4];
|
||||
va_tmp2 = ((__local float*)smem->va)[block + 8] + ((__local float*)smem->va)[block + 12];
|
||||
va_tmp1 = va_tmp1 + va_tmp2;
|
||||
va_tmp1 = fabs(va_tmp1);
|
||||
|
||||
float xx = va_tmp1 * 16777216.0f;
|
||||
int xx_int = (int)xx;
|
||||
((__local int*)smem->out)[tid] = out2 ^ xx_int;
|
||||
((__local float*)smem->va)[tid] = va_tmp1 / 64.0f;
|
||||
|
||||
mem_fence(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
vs = smem->va[0];
|
||||
s = smem->out[0].x ^ smem->out[0].y ^ smem->out[0].z ^ smem->out[0].w;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static const __constant uint skip[3] = {
|
||||
20,22,22
|
||||
};
|
||||
|
||||
|
||||
inline void generate_512(uint idx, __local ulong* in, __global ulong* out)
|
||||
{
|
||||
ulong hash[25];
|
||||
|
||||
hash[0] = in[0] ^ idx;
|
||||
for (int i = 1; i < 25; ++i) {
|
||||
hash[i] = in[i];
|
||||
}
|
||||
|
||||
for (int a = 0; a < 3; ++a) {
|
||||
keccakf1600_1(hash);
|
||||
for (int i = 0; i < skip[a]; ++i) {
|
||||
out[i] = hash[i];
|
||||
}
|
||||
|
||||
out += skip[a];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__attribute__((reqd_work_group_size(8, 8, 1)))
|
||||
__kernel void cn0(__global ulong *input, int inlen, __global int *Scratchpad, __global ulong *states, uint Threads)
|
||||
{
|
||||
const uint gIdx = getIdx();
|
||||
__local ulong State_buf[8 * 25];
|
||||
__local ulong* State = State_buf + get_local_id(0) * 25;
|
||||
|
||||
{
|
||||
states += 25 * gIdx;
|
||||
|
||||
Scratchpad = (__global int*)((__global char*)Scratchpad + MEMORY * gIdx);
|
||||
|
||||
if (get_local_id(1) == 0) {
|
||||
|
||||
# ifdef __NV_CL_C_VERSION
|
||||
for(uint i = 0; i < 8; ++i)
|
||||
State[i] = input[i];
|
||||
# else
|
||||
((__local ulong8 *)State)[0] = vload8(0, input);
|
||||
# endif
|
||||
|
||||
State[8] = input[8];
|
||||
State[9] = input[9];
|
||||
State[10] = input[10];
|
||||
|
||||
((__local uint *)State)[9] &= 0x00FFFFFFU;
|
||||
((__local uint *)State)[9] |= (((uint)get_global_id(0)) & 0xFF) << 24;
|
||||
((__local uint *)State)[10] &= 0xFF000000U;
|
||||
/* explicit cast to `uint` is required because some OpenCL implementations (e.g. NVIDIA)
|
||||
* handle get_global_id and get_global_offset as signed long long int and add
|
||||
* 0xFFFFFFFF... to `get_global_id` if we set on host side a 32bit offset where the first bit is `1`
|
||||
* (even if it is correct casted to unsigned on the host)
|
||||
*/
|
||||
((__local uint *)State)[10] |= (((uint)get_global_id(0) >> 8));
|
||||
|
||||
for (int i = 11; i < 25; ++i) {
|
||||
State[i] = 0x00UL;
|
||||
}
|
||||
|
||||
// Last bit of padding
|
||||
State[16] = 0x8000000000000000UL;
|
||||
|
||||
keccakf1600_2(State);
|
||||
|
||||
#pragma unroll
|
||||
for (int i = 0; i < 25; ++i) {
|
||||
states[i] = State[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__attribute__((reqd_work_group_size(64, 1, 1)))
|
||||
__kernel void cn00(__global int *Scratchpad, __global ulong *states)
|
||||
{
|
||||
const uint gIdx = getIdx() / 64;
|
||||
__local ulong State[25];
|
||||
|
||||
states += 25 * gIdx;
|
||||
|
||||
Scratchpad = (__global int*)((__global char*)Scratchpad + MEMORY * gIdx);
|
||||
|
||||
for (int i = get_local_id(0); i < 25; i += get_local_size(0)) {
|
||||
State[i] = states[i];
|
||||
}
|
||||
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
for (uint i = get_local_id(0); i < MEMORY / 512; i += get_local_size(0)) {
|
||||
generate_512(i, State, (__global ulong*)((__global uchar*)Scratchpad + i * 512));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__attribute__((reqd_work_group_size(8, 8, 1)))
|
||||
__kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global uint *output, ulong Target, uint Threads)
|
||||
{
|
||||
__local uint AES0[256], AES1[256], AES2[256], AES3[256];
|
||||
uint ExpandedKey2[40];
|
||||
uint4 text;
|
||||
|
||||
const uint gIdx = getIdx();
|
||||
|
||||
for (int i = get_local_id(1) * 8 + get_local_id(0); i < 256; i += 8 * 8) {
|
||||
const uint tmp = AES0_C[i];
|
||||
AES0[i] = tmp;
|
||||
AES1[i] = rotate(tmp, 8U);
|
||||
AES2[i] = rotate(tmp, 16U);
|
||||
AES3[i] = rotate(tmp, 24U);
|
||||
}
|
||||
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
__local uint4 xin1[8][8];
|
||||
__local uint4 xin2[8][8];
|
||||
|
||||
{
|
||||
states += 25 * gIdx;
|
||||
Scratchpad += gIdx * (MEMORY >> 4);
|
||||
|
||||
#if defined(__Tahiti__) || defined(__Pitcairn__)
|
||||
for(int i = 0; i < 4; ++i) ((ulong *)ExpandedKey2)[i] = states[i + 4];
|
||||
text = vload4(get_local_id(1) + 4, (__global uint *)states);
|
||||
#else
|
||||
text = vload4(get_local_id(1) + 4, (__global uint *)states);
|
||||
((uint8 *)ExpandedKey2)[0] = vload8(1, (__global uint *)states);
|
||||
#endif
|
||||
|
||||
AESExpandKey256(ExpandedKey2);
|
||||
}
|
||||
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
__local uint4* xin1_store = &xin1[get_local_id(1)][get_local_id(0)];
|
||||
__local uint4* xin1_load = &xin1[(get_local_id(1) + 1) % 8][get_local_id(0)];
|
||||
__local uint4* xin2_store = &xin2[get_local_id(1)][get_local_id(0)];
|
||||
__local uint4* xin2_load = &xin2[(get_local_id(1) + 1) % 8][get_local_id(0)];
|
||||
*xin2_store = (uint4)(0, 0, 0, 0);
|
||||
|
||||
{
|
||||
|
||||
#pragma unroll 2
|
||||
for (int i = 0, i1 = get_local_id(1); i < (MEMORY >> 7); ++i, i1 = (i1 + 16) % (MEMORY >> 4)) {
|
||||
text ^= Scratchpad[(uint)i1];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
text ^= *xin2_load;
|
||||
|
||||
#pragma unroll 10
|
||||
for(int j = 0; j < 10; ++j)
|
||||
text = AES_Round(AES0, AES1, AES2, AES3, text, ((uint4 *)ExpandedKey2)[j]);
|
||||
|
||||
*xin1_store = text;
|
||||
|
||||
text ^= Scratchpad[(uint)i1 + 8u];
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
text ^= *xin1_load;
|
||||
|
||||
#pragma unroll 10
|
||||
for(int j = 0; j < 10; ++j)
|
||||
text = AES_Round(AES0, AES1, AES2, AES3, text, ((uint4 *)ExpandedKey2)[j]);
|
||||
|
||||
*xin2_store = text;
|
||||
}
|
||||
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
text ^= *xin2_load;
|
||||
}
|
||||
|
||||
/* Also left over threads performe this loop.
|
||||
* The left over thread results will be ignored
|
||||
*/
|
||||
#pragma unroll 16
|
||||
for(size_t i = 0; i < 16; i++)
|
||||
{
|
||||
#pragma unroll 10
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
text = AES_Round(AES0, AES1, AES2, AES3, text, ((uint4 *)ExpandedKey2)[j]);
|
||||
}
|
||||
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
*xin1_store = text;
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
text ^= *xin1_load;
|
||||
}
|
||||
|
||||
__local ulong State_buf[8 * 25];
|
||||
{
|
||||
vstore2(as_ulong2(text), get_local_id(1) + 4, states);
|
||||
}
|
||||
|
||||
barrier(CLK_GLOBAL_MEM_FENCE);
|
||||
|
||||
{
|
||||
if(!get_local_id(1))
|
||||
{
|
||||
__local ulong* State = State_buf + get_local_id(0) * 25;
|
||||
|
||||
for(int i = 0; i < 25; ++i) State[i] = states[i];
|
||||
|
||||
keccakf1600_2(State);
|
||||
|
||||
if(State[3] <= Target)
|
||||
{
|
||||
ulong outIdx = atomic_inc(output + 0xFF);
|
||||
if(outIdx < 0xFF)
|
||||
output[outIdx] = get_global_id(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
mem_fence(CLK_GLOBAL_MEM_FENCE);
|
||||
}
|
639
src/backend/opencl/cl/cn/cryptonight_gpu_cl.h
Normal file
639
src/backend/opencl/cl/cn/cryptonight_gpu_cl.h
Normal file
|
@ -0,0 +1,639 @@
|
|||
#pragma once
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
static const char cryptonight_gpu_cl[20176] = {
|
||||
0x23,0x69,0x66,0x6e,0x64,0x65,0x66,0x20,0x57,0x4f,0x4c,0x46,0x5f,0x41,0x45,0x53,0x5f,0x43,0x4c,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x57,0x4f,0x4c,0x46,
|
||||
0x5f,0x41,0x45,0x53,0x5f,0x43,0x4c,0x0a,0x23,0x69,0x66,0x64,0x65,0x66,0x20,0x63,0x6c,0x5f,0x61,0x6d,0x64,0x5f,0x6d,0x65,0x64,0x69,0x61,0x5f,0x6f,0x70,0x73,0x32,
|
||||
0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x4f,0x50,0x45,0x4e,0x43,0x4c,0x20,0x45,0x58,0x54,0x45,0x4e,0x53,0x49,0x4f,0x4e,0x20,0x63,0x6c,0x5f,0x61,0x6d,0x64,
|
||||
0x5f,0x6d,0x65,0x64,0x69,0x61,0x5f,0x6f,0x70,0x73,0x32,0x20,0x3a,0x20,0x65,0x6e,0x61,0x62,0x6c,0x65,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x78,0x6d,0x72,
|
||||
0x69,0x67,0x5f,0x61,0x6d,0x64,0x5f,0x62,0x66,0x65,0x28,0x73,0x72,0x63,0x30,0x2c,0x20,0x73,0x72,0x63,0x31,0x2c,0x20,0x73,0x72,0x63,0x32,0x29,0x20,0x61,0x6d,0x64,
|
||||
0x5f,0x62,0x66,0x65,0x28,0x73,0x72,0x63,0x30,0x2c,0x20,0x73,0x72,0x63,0x31,0x2c,0x20,0x73,0x72,0x63,0x32,0x29,0x0a,0x23,0x65,0x6c,0x73,0x65,0x0a,0x69,0x6e,0x6c,
|
||||
0x69,0x6e,0x65,0x20,0x69,0x6e,0x74,0x20,0x78,0x6d,0x72,0x69,0x67,0x5f,0x61,0x6d,0x64,0x5f,0x62,0x66,0x65,0x28,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,
|
||||
0x20,0x73,0x72,0x63,0x30,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x6f,0x66,0x66,0x73,0x65,0x74,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,
|
||||
0x6e,0x74,0x20,0x77,0x69,0x64,0x74,0x68,0x29,0x0a,0x7b,0x0a,0x69,0x66,0x28,0x28,0x6f,0x66,0x66,0x73,0x65,0x74,0x2b,0x77,0x69,0x64,0x74,0x68,0x29,0x3c,0x33,0x32,
|
||||
0x75,0x29,0x20,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x28,0x73,0x72,0x63,0x30,0x3c,0x3c,0x28,0x33,0x32,0x75,0x2d,0x6f,0x66,0x66,0x73,0x65,0x74,0x2d,0x77,
|
||||
0x69,0x64,0x74,0x68,0x29,0x29,0x3e,0x3e,0x28,0x33,0x32,0x75,0x2d,0x77,0x69,0x64,0x74,0x68,0x29,0x3b,0x0a,0x7d,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x72,
|
||||
0x63,0x30,0x3e,0x3e,0x6f,0x66,0x66,0x73,0x65,0x74,0x3b,0x0a,0x7d,0x0a,0x23,0x65,0x6e,0x64,0x69,0x66,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x41,0x45,0x53,0x30,0x5f,0x43,0x5b,0x32,0x35,0x36,0x5d,0x20,0x3d,0x0a,
|
||||
0x7b,0x0a,0x30,0x78,0x41,0x35,0x36,0x33,0x36,0x33,0x43,0x36,0x55,0x2c,0x30,0x78,0x38,0x34,0x37,0x43,0x37,0x43,0x46,0x38,0x55,0x2c,0x30,0x78,0x39,0x39,0x37,0x37,
|
||||
0x37,0x37,0x45,0x45,0x55,0x2c,0x30,0x78,0x38,0x44,0x37,0x42,0x37,0x42,0x46,0x36,0x55,0x2c,0x0a,0x30,0x78,0x30,0x44,0x46,0x32,0x46,0x32,0x46,0x46,0x55,0x2c,0x30,
|
||||
0x78,0x42,0x44,0x36,0x42,0x36,0x42,0x44,0x36,0x55,0x2c,0x30,0x78,0x42,0x31,0x36,0x46,0x36,0x46,0x44,0x45,0x55,0x2c,0x30,0x78,0x35,0x34,0x43,0x35,0x43,0x35,0x39,
|
||||
0x31,0x55,0x2c,0x0a,0x30,0x78,0x35,0x30,0x33,0x30,0x33,0x30,0x36,0x30,0x55,0x2c,0x30,0x78,0x30,0x33,0x30,0x31,0x30,0x31,0x30,0x32,0x55,0x2c,0x30,0x78,0x41,0x39,
|
||||
0x36,0x37,0x36,0x37,0x43,0x45,0x55,0x2c,0x30,0x78,0x37,0x44,0x32,0x42,0x32,0x42,0x35,0x36,0x55,0x2c,0x0a,0x30,0x78,0x31,0x39,0x46,0x45,0x46,0x45,0x45,0x37,0x55,
|
||||
0x2c,0x30,0x78,0x36,0x32,0x44,0x37,0x44,0x37,0x42,0x35,0x55,0x2c,0x30,0x78,0x45,0x36,0x41,0x42,0x41,0x42,0x34,0x44,0x55,0x2c,0x30,0x78,0x39,0x41,0x37,0x36,0x37,
|
||||
0x36,0x45,0x43,0x55,0x2c,0x0a,0x30,0x78,0x34,0x35,0x43,0x41,0x43,0x41,0x38,0x46,0x55,0x2c,0x30,0x78,0x39,0x44,0x38,0x32,0x38,0x32,0x31,0x46,0x55,0x2c,0x30,0x78,
|
||||
0x34,0x30,0x43,0x39,0x43,0x39,0x38,0x39,0x55,0x2c,0x30,0x78,0x38,0x37,0x37,0x44,0x37,0x44,0x46,0x41,0x55,0x2c,0x0a,0x30,0x78,0x31,0x35,0x46,0x41,0x46,0x41,0x45,
|
||||
0x46,0x55,0x2c,0x30,0x78,0x45,0x42,0x35,0x39,0x35,0x39,0x42,0x32,0x55,0x2c,0x30,0x78,0x43,0x39,0x34,0x37,0x34,0x37,0x38,0x45,0x55,0x2c,0x30,0x78,0x30,0x42,0x46,
|
||||
0x30,0x46,0x30,0x46,0x42,0x55,0x2c,0x0a,0x30,0x78,0x45,0x43,0x41,0x44,0x41,0x44,0x34,0x31,0x55,0x2c,0x30,0x78,0x36,0x37,0x44,0x34,0x44,0x34,0x42,0x33,0x55,0x2c,
|
||||
0x30,0x78,0x46,0x44,0x41,0x32,0x41,0x32,0x35,0x46,0x55,0x2c,0x30,0x78,0x45,0x41,0x41,0x46,0x41,0x46,0x34,0x35,0x55,0x2c,0x0a,0x30,0x78,0x42,0x46,0x39,0x43,0x39,
|
||||
0x43,0x32,0x33,0x55,0x2c,0x30,0x78,0x46,0x37,0x41,0x34,0x41,0x34,0x35,0x33,0x55,0x2c,0x30,0x78,0x39,0x36,0x37,0x32,0x37,0x32,0x45,0x34,0x55,0x2c,0x30,0x78,0x35,
|
||||
0x42,0x43,0x30,0x43,0x30,0x39,0x42,0x55,0x2c,0x0a,0x30,0x78,0x43,0x32,0x42,0x37,0x42,0x37,0x37,0x35,0x55,0x2c,0x30,0x78,0x31,0x43,0x46,0x44,0x46,0x44,0x45,0x31,
|
||||
0x55,0x2c,0x30,0x78,0x41,0x45,0x39,0x33,0x39,0x33,0x33,0x44,0x55,0x2c,0x30,0x78,0x36,0x41,0x32,0x36,0x32,0x36,0x34,0x43,0x55,0x2c,0x0a,0x30,0x78,0x35,0x41,0x33,
|
||||
0x36,0x33,0x36,0x36,0x43,0x55,0x2c,0x30,0x78,0x34,0x31,0x33,0x46,0x33,0x46,0x37,0x45,0x55,0x2c,0x30,0x78,0x30,0x32,0x46,0x37,0x46,0x37,0x46,0x35,0x55,0x2c,0x30,
|
||||
0x78,0x34,0x46,0x43,0x43,0x43,0x43,0x38,0x33,0x55,0x2c,0x0a,0x30,0x78,0x35,0x43,0x33,0x34,0x33,0x34,0x36,0x38,0x55,0x2c,0x30,0x78,0x46,0x34,0x41,0x35,0x41,0x35,
|
||||
0x35,0x31,0x55,0x2c,0x30,0x78,0x33,0x34,0x45,0x35,0x45,0x35,0x44,0x31,0x55,0x2c,0x30,0x78,0x30,0x38,0x46,0x31,0x46,0x31,0x46,0x39,0x55,0x2c,0x0a,0x30,0x78,0x39,
|
||||
0x33,0x37,0x31,0x37,0x31,0x45,0x32,0x55,0x2c,0x30,0x78,0x37,0x33,0x44,0x38,0x44,0x38,0x41,0x42,0x55,0x2c,0x30,0x78,0x35,0x33,0x33,0x31,0x33,0x31,0x36,0x32,0x55,
|
||||
0x2c,0x30,0x78,0x33,0x46,0x31,0x35,0x31,0x35,0x32,0x41,0x55,0x2c,0x0a,0x30,0x78,0x30,0x43,0x30,0x34,0x30,0x34,0x30,0x38,0x55,0x2c,0x30,0x78,0x35,0x32,0x43,0x37,
|
||||
0x43,0x37,0x39,0x35,0x55,0x2c,0x30,0x78,0x36,0x35,0x32,0x33,0x32,0x33,0x34,0x36,0x55,0x2c,0x30,0x78,0x35,0x45,0x43,0x33,0x43,0x33,0x39,0x44,0x55,0x2c,0x0a,0x30,
|
||||
0x78,0x32,0x38,0x31,0x38,0x31,0x38,0x33,0x30,0x55,0x2c,0x30,0x78,0x41,0x31,0x39,0x36,0x39,0x36,0x33,0x37,0x55,0x2c,0x30,0x78,0x30,0x46,0x30,0x35,0x30,0x35,0x30,
|
||||
0x41,0x55,0x2c,0x30,0x78,0x42,0x35,0x39,0x41,0x39,0x41,0x32,0x46,0x55,0x2c,0x0a,0x30,0x78,0x30,0x39,0x30,0x37,0x30,0x37,0x30,0x45,0x55,0x2c,0x30,0x78,0x33,0x36,
|
||||
0x31,0x32,0x31,0x32,0x32,0x34,0x55,0x2c,0x30,0x78,0x39,0x42,0x38,0x30,0x38,0x30,0x31,0x42,0x55,0x2c,0x30,0x78,0x33,0x44,0x45,0x32,0x45,0x32,0x44,0x46,0x55,0x2c,
|
||||
0x0a,0x30,0x78,0x32,0x36,0x45,0x42,0x45,0x42,0x43,0x44,0x55,0x2c,0x30,0x78,0x36,0x39,0x32,0x37,0x32,0x37,0x34,0x45,0x55,0x2c,0x30,0x78,0x43,0x44,0x42,0x32,0x42,
|
||||
0x32,0x37,0x46,0x55,0x2c,0x30,0x78,0x39,0x46,0x37,0x35,0x37,0x35,0x45,0x41,0x55,0x2c,0x0a,0x30,0x78,0x31,0x42,0x30,0x39,0x30,0x39,0x31,0x32,0x55,0x2c,0x30,0x78,
|
||||
0x39,0x45,0x38,0x33,0x38,0x33,0x31,0x44,0x55,0x2c,0x30,0x78,0x37,0x34,0x32,0x43,0x32,0x43,0x35,0x38,0x55,0x2c,0x30,0x78,0x32,0x45,0x31,0x41,0x31,0x41,0x33,0x34,
|
||||
0x55,0x2c,0x0a,0x30,0x78,0x32,0x44,0x31,0x42,0x31,0x42,0x33,0x36,0x55,0x2c,0x30,0x78,0x42,0x32,0x36,0x45,0x36,0x45,0x44,0x43,0x55,0x2c,0x30,0x78,0x45,0x45,0x35,
|
||||
0x41,0x35,0x41,0x42,0x34,0x55,0x2c,0x30,0x78,0x46,0x42,0x41,0x30,0x41,0x30,0x35,0x42,0x55,0x2c,0x0a,0x30,0x78,0x46,0x36,0x35,0x32,0x35,0x32,0x41,0x34,0x55,0x2c,
|
||||
0x30,0x78,0x34,0x44,0x33,0x42,0x33,0x42,0x37,0x36,0x55,0x2c,0x30,0x78,0x36,0x31,0x44,0x36,0x44,0x36,0x42,0x37,0x55,0x2c,0x30,0x78,0x43,0x45,0x42,0x33,0x42,0x33,
|
||||
0x37,0x44,0x55,0x2c,0x0a,0x30,0x78,0x37,0x42,0x32,0x39,0x32,0x39,0x35,0x32,0x55,0x2c,0x30,0x78,0x33,0x45,0x45,0x33,0x45,0x33,0x44,0x44,0x55,0x2c,0x30,0x78,0x37,
|
||||
0x31,0x32,0x46,0x32,0x46,0x35,0x45,0x55,0x2c,0x30,0x78,0x39,0x37,0x38,0x34,0x38,0x34,0x31,0x33,0x55,0x2c,0x0a,0x30,0x78,0x46,0x35,0x35,0x33,0x35,0x33,0x41,0x36,
|
||||
0x55,0x2c,0x30,0x78,0x36,0x38,0x44,0x31,0x44,0x31,0x42,0x39,0x55,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x55,0x2c,0x30,0x78,0x32,0x43,0x45,0x44,
|
||||
0x45,0x44,0x43,0x31,0x55,0x2c,0x0a,0x30,0x78,0x36,0x30,0x32,0x30,0x32,0x30,0x34,0x30,0x55,0x2c,0x30,0x78,0x31,0x46,0x46,0x43,0x46,0x43,0x45,0x33,0x55,0x2c,0x30,
|
||||
0x78,0x43,0x38,0x42,0x31,0x42,0x31,0x37,0x39,0x55,0x2c,0x30,0x78,0x45,0x44,0x35,0x42,0x35,0x42,0x42,0x36,0x55,0x2c,0x0a,0x30,0x78,0x42,0x45,0x36,0x41,0x36,0x41,
|
||||
0x44,0x34,0x55,0x2c,0x30,0x78,0x34,0x36,0x43,0x42,0x43,0x42,0x38,0x44,0x55,0x2c,0x30,0x78,0x44,0x39,0x42,0x45,0x42,0x45,0x36,0x37,0x55,0x2c,0x30,0x78,0x34,0x42,
|
||||
0x33,0x39,0x33,0x39,0x37,0x32,0x55,0x2c,0x0a,0x30,0x78,0x44,0x45,0x34,0x41,0x34,0x41,0x39,0x34,0x55,0x2c,0x30,0x78,0x44,0x34,0x34,0x43,0x34,0x43,0x39,0x38,0x55,
|
||||
0x2c,0x30,0x78,0x45,0x38,0x35,0x38,0x35,0x38,0x42,0x30,0x55,0x2c,0x30,0x78,0x34,0x41,0x43,0x46,0x43,0x46,0x38,0x35,0x55,0x2c,0x0a,0x30,0x78,0x36,0x42,0x44,0x30,
|
||||
0x44,0x30,0x42,0x42,0x55,0x2c,0x30,0x78,0x32,0x41,0x45,0x46,0x45,0x46,0x43,0x35,0x55,0x2c,0x30,0x78,0x45,0x35,0x41,0x41,0x41,0x41,0x34,0x46,0x55,0x2c,0x30,0x78,
|
||||
0x31,0x36,0x46,0x42,0x46,0x42,0x45,0x44,0x55,0x2c,0x0a,0x30,0x78,0x43,0x35,0x34,0x33,0x34,0x33,0x38,0x36,0x55,0x2c,0x30,0x78,0x44,0x37,0x34,0x44,0x34,0x44,0x39,
|
||||
0x41,0x55,0x2c,0x30,0x78,0x35,0x35,0x33,0x33,0x33,0x33,0x36,0x36,0x55,0x2c,0x30,0x78,0x39,0x34,0x38,0x35,0x38,0x35,0x31,0x31,0x55,0x2c,0x0a,0x30,0x78,0x43,0x46,
|
||||
0x34,0x35,0x34,0x35,0x38,0x41,0x55,0x2c,0x30,0x78,0x31,0x30,0x46,0x39,0x46,0x39,0x45,0x39,0x55,0x2c,0x30,0x78,0x30,0x36,0x30,0x32,0x30,0x32,0x30,0x34,0x55,0x2c,
|
||||
0x30,0x78,0x38,0x31,0x37,0x46,0x37,0x46,0x46,0x45,0x55,0x2c,0x0a,0x30,0x78,0x46,0x30,0x35,0x30,0x35,0x30,0x41,0x30,0x55,0x2c,0x30,0x78,0x34,0x34,0x33,0x43,0x33,
|
||||
0x43,0x37,0x38,0x55,0x2c,0x30,0x78,0x42,0x41,0x39,0x46,0x39,0x46,0x32,0x35,0x55,0x2c,0x30,0x78,0x45,0x33,0x41,0x38,0x41,0x38,0x34,0x42,0x55,0x2c,0x0a,0x30,0x78,
|
||||
0x46,0x33,0x35,0x31,0x35,0x31,0x41,0x32,0x55,0x2c,0x30,0x78,0x46,0x45,0x41,0x33,0x41,0x33,0x35,0x44,0x55,0x2c,0x30,0x78,0x43,0x30,0x34,0x30,0x34,0x30,0x38,0x30,
|
||||
0x55,0x2c,0x30,0x78,0x38,0x41,0x38,0x46,0x38,0x46,0x30,0x35,0x55,0x2c,0x0a,0x30,0x78,0x41,0x44,0x39,0x32,0x39,0x32,0x33,0x46,0x55,0x2c,0x30,0x78,0x42,0x43,0x39,
|
||||
0x44,0x39,0x44,0x32,0x31,0x55,0x2c,0x30,0x78,0x34,0x38,0x33,0x38,0x33,0x38,0x37,0x30,0x55,0x2c,0x30,0x78,0x30,0x34,0x46,0x35,0x46,0x35,0x46,0x31,0x55,0x2c,0x0a,
|
||||
0x30,0x78,0x44,0x46,0x42,0x43,0x42,0x43,0x36,0x33,0x55,0x2c,0x30,0x78,0x43,0x31,0x42,0x36,0x42,0x36,0x37,0x37,0x55,0x2c,0x30,0x78,0x37,0x35,0x44,0x41,0x44,0x41,
|
||||
0x41,0x46,0x55,0x2c,0x30,0x78,0x36,0x33,0x32,0x31,0x32,0x31,0x34,0x32,0x55,0x2c,0x0a,0x30,0x78,0x33,0x30,0x31,0x30,0x31,0x30,0x32,0x30,0x55,0x2c,0x30,0x78,0x31,
|
||||
0x41,0x46,0x46,0x46,0x46,0x45,0x35,0x55,0x2c,0x30,0x78,0x30,0x45,0x46,0x33,0x46,0x33,0x46,0x44,0x55,0x2c,0x30,0x78,0x36,0x44,0x44,0x32,0x44,0x32,0x42,0x46,0x55,
|
||||
0x2c,0x0a,0x30,0x78,0x34,0x43,0x43,0x44,0x43,0x44,0x38,0x31,0x55,0x2c,0x30,0x78,0x31,0x34,0x30,0x43,0x30,0x43,0x31,0x38,0x55,0x2c,0x30,0x78,0x33,0x35,0x31,0x33,
|
||||
0x31,0x33,0x32,0x36,0x55,0x2c,0x30,0x78,0x32,0x46,0x45,0x43,0x45,0x43,0x43,0x33,0x55,0x2c,0x0a,0x30,0x78,0x45,0x31,0x35,0x46,0x35,0x46,0x42,0x45,0x55,0x2c,0x30,
|
||||
0x78,0x41,0x32,0x39,0x37,0x39,0x37,0x33,0x35,0x55,0x2c,0x30,0x78,0x43,0x43,0x34,0x34,0x34,0x34,0x38,0x38,0x55,0x2c,0x30,0x78,0x33,0x39,0x31,0x37,0x31,0x37,0x32,
|
||||
0x45,0x55,0x2c,0x0a,0x30,0x78,0x35,0x37,0x43,0x34,0x43,0x34,0x39,0x33,0x55,0x2c,0x30,0x78,0x46,0x32,0x41,0x37,0x41,0x37,0x35,0x35,0x55,0x2c,0x30,0x78,0x38,0x32,
|
||||
0x37,0x45,0x37,0x45,0x46,0x43,0x55,0x2c,0x30,0x78,0x34,0x37,0x33,0x44,0x33,0x44,0x37,0x41,0x55,0x2c,0x0a,0x30,0x78,0x41,0x43,0x36,0x34,0x36,0x34,0x43,0x38,0x55,
|
||||
0x2c,0x30,0x78,0x45,0x37,0x35,0x44,0x35,0x44,0x42,0x41,0x55,0x2c,0x30,0x78,0x32,0x42,0x31,0x39,0x31,0x39,0x33,0x32,0x55,0x2c,0x30,0x78,0x39,0x35,0x37,0x33,0x37,
|
||||
0x33,0x45,0x36,0x55,0x2c,0x0a,0x30,0x78,0x41,0x30,0x36,0x30,0x36,0x30,0x43,0x30,0x55,0x2c,0x30,0x78,0x39,0x38,0x38,0x31,0x38,0x31,0x31,0x39,0x55,0x2c,0x30,0x78,
|
||||
0x44,0x31,0x34,0x46,0x34,0x46,0x39,0x45,0x55,0x2c,0x30,0x78,0x37,0x46,0x44,0x43,0x44,0x43,0x41,0x33,0x55,0x2c,0x0a,0x30,0x78,0x36,0x36,0x32,0x32,0x32,0x32,0x34,
|
||||
0x34,0x55,0x2c,0x30,0x78,0x37,0x45,0x32,0x41,0x32,0x41,0x35,0x34,0x55,0x2c,0x30,0x78,0x41,0x42,0x39,0x30,0x39,0x30,0x33,0x42,0x55,0x2c,0x30,0x78,0x38,0x33,0x38,
|
||||
0x38,0x38,0x38,0x30,0x42,0x55,0x2c,0x0a,0x30,0x78,0x43,0x41,0x34,0x36,0x34,0x36,0x38,0x43,0x55,0x2c,0x30,0x78,0x32,0x39,0x45,0x45,0x45,0x45,0x43,0x37,0x55,0x2c,
|
||||
0x30,0x78,0x44,0x33,0x42,0x38,0x42,0x38,0x36,0x42,0x55,0x2c,0x30,0x78,0x33,0x43,0x31,0x34,0x31,0x34,0x32,0x38,0x55,0x2c,0x0a,0x30,0x78,0x37,0x39,0x44,0x45,0x44,
|
||||
0x45,0x41,0x37,0x55,0x2c,0x30,0x78,0x45,0x32,0x35,0x45,0x35,0x45,0x42,0x43,0x55,0x2c,0x30,0x78,0x31,0x44,0x30,0x42,0x30,0x42,0x31,0x36,0x55,0x2c,0x30,0x78,0x37,
|
||||
0x36,0x44,0x42,0x44,0x42,0x41,0x44,0x55,0x2c,0x0a,0x30,0x78,0x33,0x42,0x45,0x30,0x45,0x30,0x44,0x42,0x55,0x2c,0x30,0x78,0x35,0x36,0x33,0x32,0x33,0x32,0x36,0x34,
|
||||
0x55,0x2c,0x30,0x78,0x34,0x45,0x33,0x41,0x33,0x41,0x37,0x34,0x55,0x2c,0x30,0x78,0x31,0x45,0x30,0x41,0x30,0x41,0x31,0x34,0x55,0x2c,0x0a,0x30,0x78,0x44,0x42,0x34,
|
||||
0x39,0x34,0x39,0x39,0x32,0x55,0x2c,0x30,0x78,0x30,0x41,0x30,0x36,0x30,0x36,0x30,0x43,0x55,0x2c,0x30,0x78,0x36,0x43,0x32,0x34,0x32,0x34,0x34,0x38,0x55,0x2c,0x30,
|
||||
0x78,0x45,0x34,0x35,0x43,0x35,0x43,0x42,0x38,0x55,0x2c,0x0a,0x30,0x78,0x35,0x44,0x43,0x32,0x43,0x32,0x39,0x46,0x55,0x2c,0x30,0x78,0x36,0x45,0x44,0x33,0x44,0x33,
|
||||
0x42,0x44,0x55,0x2c,0x30,0x78,0x45,0x46,0x41,0x43,0x41,0x43,0x34,0x33,0x55,0x2c,0x30,0x78,0x41,0x36,0x36,0x32,0x36,0x32,0x43,0x34,0x55,0x2c,0x0a,0x30,0x78,0x41,
|
||||
0x38,0x39,0x31,0x39,0x31,0x33,0x39,0x55,0x2c,0x30,0x78,0x41,0x34,0x39,0x35,0x39,0x35,0x33,0x31,0x55,0x2c,0x30,0x78,0x33,0x37,0x45,0x34,0x45,0x34,0x44,0x33,0x55,
|
||||
0x2c,0x30,0x78,0x38,0x42,0x37,0x39,0x37,0x39,0x46,0x32,0x55,0x2c,0x0a,0x30,0x78,0x33,0x32,0x45,0x37,0x45,0x37,0x44,0x35,0x55,0x2c,0x30,0x78,0x34,0x33,0x43,0x38,
|
||||
0x43,0x38,0x38,0x42,0x55,0x2c,0x30,0x78,0x35,0x39,0x33,0x37,0x33,0x37,0x36,0x45,0x55,0x2c,0x30,0x78,0x42,0x37,0x36,0x44,0x36,0x44,0x44,0x41,0x55,0x2c,0x0a,0x30,
|
||||
0x78,0x38,0x43,0x38,0x44,0x38,0x44,0x30,0x31,0x55,0x2c,0x30,0x78,0x36,0x34,0x44,0x35,0x44,0x35,0x42,0x31,0x55,0x2c,0x30,0x78,0x44,0x32,0x34,0x45,0x34,0x45,0x39,
|
||||
0x43,0x55,0x2c,0x30,0x78,0x45,0x30,0x41,0x39,0x41,0x39,0x34,0x39,0x55,0x2c,0x0a,0x30,0x78,0x42,0x34,0x36,0x43,0x36,0x43,0x44,0x38,0x55,0x2c,0x30,0x78,0x46,0x41,
|
||||
0x35,0x36,0x35,0x36,0x41,0x43,0x55,0x2c,0x30,0x78,0x30,0x37,0x46,0x34,0x46,0x34,0x46,0x33,0x55,0x2c,0x30,0x78,0x32,0x35,0x45,0x41,0x45,0x41,0x43,0x46,0x55,0x2c,
|
||||
0x0a,0x30,0x78,0x41,0x46,0x36,0x35,0x36,0x35,0x43,0x41,0x55,0x2c,0x30,0x78,0x38,0x45,0x37,0x41,0x37,0x41,0x46,0x34,0x55,0x2c,0x30,0x78,0x45,0x39,0x41,0x45,0x41,
|
||||
0x45,0x34,0x37,0x55,0x2c,0x30,0x78,0x31,0x38,0x30,0x38,0x30,0x38,0x31,0x30,0x55,0x2c,0x0a,0x30,0x78,0x44,0x35,0x42,0x41,0x42,0x41,0x36,0x46,0x55,0x2c,0x30,0x78,
|
||||
0x38,0x38,0x37,0x38,0x37,0x38,0x46,0x30,0x55,0x2c,0x30,0x78,0x36,0x46,0x32,0x35,0x32,0x35,0x34,0x41,0x55,0x2c,0x30,0x78,0x37,0x32,0x32,0x45,0x32,0x45,0x35,0x43,
|
||||
0x55,0x2c,0x0a,0x30,0x78,0x32,0x34,0x31,0x43,0x31,0x43,0x33,0x38,0x55,0x2c,0x30,0x78,0x46,0x31,0x41,0x36,0x41,0x36,0x35,0x37,0x55,0x2c,0x30,0x78,0x43,0x37,0x42,
|
||||
0x34,0x42,0x34,0x37,0x33,0x55,0x2c,0x30,0x78,0x35,0x31,0x43,0x36,0x43,0x36,0x39,0x37,0x55,0x2c,0x0a,0x30,0x78,0x32,0x33,0x45,0x38,0x45,0x38,0x43,0x42,0x55,0x2c,
|
||||
0x30,0x78,0x37,0x43,0x44,0x44,0x44,0x44,0x41,0x31,0x55,0x2c,0x30,0x78,0x39,0x43,0x37,0x34,0x37,0x34,0x45,0x38,0x55,0x2c,0x30,0x78,0x32,0x31,0x31,0x46,0x31,0x46,
|
||||
0x33,0x45,0x55,0x2c,0x0a,0x30,0x78,0x44,0x44,0x34,0x42,0x34,0x42,0x39,0x36,0x55,0x2c,0x30,0x78,0x44,0x43,0x42,0x44,0x42,0x44,0x36,0x31,0x55,0x2c,0x30,0x78,0x38,
|
||||
0x36,0x38,0x42,0x38,0x42,0x30,0x44,0x55,0x2c,0x30,0x78,0x38,0x35,0x38,0x41,0x38,0x41,0x30,0x46,0x55,0x2c,0x0a,0x30,0x78,0x39,0x30,0x37,0x30,0x37,0x30,0x45,0x30,
|
||||
0x55,0x2c,0x30,0x78,0x34,0x32,0x33,0x45,0x33,0x45,0x37,0x43,0x55,0x2c,0x30,0x78,0x43,0x34,0x42,0x35,0x42,0x35,0x37,0x31,0x55,0x2c,0x30,0x78,0x41,0x41,0x36,0x36,
|
||||
0x36,0x36,0x43,0x43,0x55,0x2c,0x0a,0x30,0x78,0x44,0x38,0x34,0x38,0x34,0x38,0x39,0x30,0x55,0x2c,0x30,0x78,0x30,0x35,0x30,0x33,0x30,0x33,0x30,0x36,0x55,0x2c,0x30,
|
||||
0x78,0x30,0x31,0x46,0x36,0x46,0x36,0x46,0x37,0x55,0x2c,0x30,0x78,0x31,0x32,0x30,0x45,0x30,0x45,0x31,0x43,0x55,0x2c,0x0a,0x30,0x78,0x41,0x33,0x36,0x31,0x36,0x31,
|
||||
0x43,0x32,0x55,0x2c,0x30,0x78,0x35,0x46,0x33,0x35,0x33,0x35,0x36,0x41,0x55,0x2c,0x30,0x78,0x46,0x39,0x35,0x37,0x35,0x37,0x41,0x45,0x55,0x2c,0x30,0x78,0x44,0x30,
|
||||
0x42,0x39,0x42,0x39,0x36,0x39,0x55,0x2c,0x0a,0x30,0x78,0x39,0x31,0x38,0x36,0x38,0x36,0x31,0x37,0x55,0x2c,0x30,0x78,0x35,0x38,0x43,0x31,0x43,0x31,0x39,0x39,0x55,
|
||||
0x2c,0x30,0x78,0x32,0x37,0x31,0x44,0x31,0x44,0x33,0x41,0x55,0x2c,0x30,0x78,0x42,0x39,0x39,0x45,0x39,0x45,0x32,0x37,0x55,0x2c,0x0a,0x30,0x78,0x33,0x38,0x45,0x31,
|
||||
0x45,0x31,0x44,0x39,0x55,0x2c,0x30,0x78,0x31,0x33,0x46,0x38,0x46,0x38,0x45,0x42,0x55,0x2c,0x30,0x78,0x42,0x33,0x39,0x38,0x39,0x38,0x32,0x42,0x55,0x2c,0x30,0x78,
|
||||
0x33,0x33,0x31,0x31,0x31,0x31,0x32,0x32,0x55,0x2c,0x0a,0x30,0x78,0x42,0x42,0x36,0x39,0x36,0x39,0x44,0x32,0x55,0x2c,0x30,0x78,0x37,0x30,0x44,0x39,0x44,0x39,0x41,
|
||||
0x39,0x55,0x2c,0x30,0x78,0x38,0x39,0x38,0x45,0x38,0x45,0x30,0x37,0x55,0x2c,0x30,0x78,0x41,0x37,0x39,0x34,0x39,0x34,0x33,0x33,0x55,0x2c,0x0a,0x30,0x78,0x42,0x36,
|
||||
0x39,0x42,0x39,0x42,0x32,0x44,0x55,0x2c,0x30,0x78,0x32,0x32,0x31,0x45,0x31,0x45,0x33,0x43,0x55,0x2c,0x30,0x78,0x39,0x32,0x38,0x37,0x38,0x37,0x31,0x35,0x55,0x2c,
|
||||
0x30,0x78,0x32,0x30,0x45,0x39,0x45,0x39,0x43,0x39,0x55,0x2c,0x0a,0x30,0x78,0x34,0x39,0x43,0x45,0x43,0x45,0x38,0x37,0x55,0x2c,0x30,0x78,0x46,0x46,0x35,0x35,0x35,
|
||||
0x35,0x41,0x41,0x55,0x2c,0x30,0x78,0x37,0x38,0x32,0x38,0x32,0x38,0x35,0x30,0x55,0x2c,0x30,0x78,0x37,0x41,0x44,0x46,0x44,0x46,0x41,0x35,0x55,0x2c,0x0a,0x30,0x78,
|
||||
0x38,0x46,0x38,0x43,0x38,0x43,0x30,0x33,0x55,0x2c,0x30,0x78,0x46,0x38,0x41,0x31,0x41,0x31,0x35,0x39,0x55,0x2c,0x30,0x78,0x38,0x30,0x38,0x39,0x38,0x39,0x30,0x39,
|
||||
0x55,0x2c,0x30,0x78,0x31,0x37,0x30,0x44,0x30,0x44,0x31,0x41,0x55,0x2c,0x0a,0x30,0x78,0x44,0x41,0x42,0x46,0x42,0x46,0x36,0x35,0x55,0x2c,0x30,0x78,0x33,0x31,0x45,
|
||||
0x36,0x45,0x36,0x44,0x37,0x55,0x2c,0x30,0x78,0x43,0x36,0x34,0x32,0x34,0x32,0x38,0x34,0x55,0x2c,0x30,0x78,0x42,0x38,0x36,0x38,0x36,0x38,0x44,0x30,0x55,0x2c,0x0a,
|
||||
0x30,0x78,0x43,0x33,0x34,0x31,0x34,0x31,0x38,0x32,0x55,0x2c,0x30,0x78,0x42,0x30,0x39,0x39,0x39,0x39,0x32,0x39,0x55,0x2c,0x30,0x78,0x37,0x37,0x32,0x44,0x32,0x44,
|
||||
0x35,0x41,0x55,0x2c,0x30,0x78,0x31,0x31,0x30,0x46,0x30,0x46,0x31,0x45,0x55,0x2c,0x0a,0x30,0x78,0x43,0x42,0x42,0x30,0x42,0x30,0x37,0x42,0x55,0x2c,0x30,0x78,0x46,
|
||||
0x43,0x35,0x34,0x35,0x34,0x41,0x38,0x55,0x2c,0x30,0x78,0x44,0x36,0x42,0x42,0x42,0x42,0x36,0x44,0x55,0x2c,0x30,0x78,0x33,0x41,0x31,0x36,0x31,0x36,0x32,0x43,0x55,
|
||||
0x0a,0x7d,0x3b,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x42,0x59,0x54,0x45,0x28,0x78,0x2c,0x20,0x79,0x29,0x20,0x28,0x78,0x6d,0x72,0x69,0x67,0x5f,0x61,0x6d,
|
||||
0x64,0x5f,0x62,0x66,0x65,0x28,0x28,0x78,0x29,0x2c,0x20,0x28,0x79,0x29,0x20,0x3c,0x3c,0x20,0x33,0x55,0x2c,0x20,0x38,0x55,0x29,0x29,0x0a,0x23,0x69,0x66,0x20,0x28,
|
||||
0x41,0x4c,0x47,0x4f,0x20,0x3d,0x3d,0x20,0x41,0x4c,0x47,0x4f,0x5f,0x43,0x4e,0x5f,0x48,0x45,0x41,0x56,0x59,0x5f,0x54,0x55,0x42,0x45,0x29,0x0a,0x69,0x6e,0x6c,0x69,
|
||||
0x6e,0x65,0x20,0x75,0x69,0x6e,0x74,0x34,0x20,0x41,0x45,0x53,0x5f,0x52,0x6f,0x75,0x6e,0x64,0x5f,0x62,0x69,0x74,0x74,0x75,0x62,0x65,0x32,0x28,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x30,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,
|
||||
0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x31,0x2c,0x75,0x69,0x6e,0x74,0x34,0x20,0x78,0x2c,0x75,0x69,0x6e,0x74,0x34,0x20,0x6b,0x29,0x0a,0x7b,
|
||||
0x0a,0x78,0x3d,0x7e,0x78,0x3b,0x0a,0x6b,0x2e,0x73,0x30,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x30,0x2c,0x30,0x29,
|
||||
0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x31,0x2c,0x31,0x29,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x41,0x45,0x53,0x30,
|
||||
0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x32,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x33,0x2c,0x33,0x29,
|
||||
0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x78,0x2e,0x73,0x30,0x20,0x5e,0x3d,0x20,0x6b,0x2e,0x73,0x30,0x3b,0x0a,0x6b,0x2e,0x73,0x31,0x20,0x5e,0x3d,0x20,0x41,0x45,
|
||||
0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x31,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x32,0x2c,
|
||||
0x31,0x29,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x33,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,
|
||||
0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x30,0x2c,0x33,0x29,0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x78,0x2e,0x73,0x31,0x20,0x5e,0x3d,0x20,0x6b,
|
||||
0x2e,0x73,0x31,0x3b,0x0a,0x6b,0x2e,0x73,0x32,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x32,0x2c,0x30,0x29,0x5d,0x5e,
|
||||
0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x33,0x2c,0x31,0x29,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x41,0x45,0x53,0x30,0x5b,0x42,
|
||||
0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x30,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x31,0x2c,0x33,0x29,0x5d,0x2c,
|
||||
0x31,0x36,0x55,0x29,0x3b,0x0a,0x78,0x2e,0x73,0x32,0x20,0x5e,0x3d,0x20,0x6b,0x2e,0x73,0x32,0x3b,0x0a,0x6b,0x2e,0x73,0x33,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,
|
||||
0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x33,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x30,0x2c,0x31,0x29,
|
||||
0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x31,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,
|
||||
0x5b,0x42,0x59,0x54,0x45,0x28,0x78,0x2e,0x73,0x32,0x2c,0x33,0x29,0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6b,0x3b,0x0a,0x7d,
|
||||
0x0a,0x23,0x65,0x6e,0x64,0x69,0x66,0x0a,0x75,0x69,0x6e,0x74,0x34,0x20,0x41,0x45,0x53,0x5f,0x52,0x6f,0x75,0x6e,0x64,0x28,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,
|
||||
0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x30,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x31,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,
|
||||
0x53,0x32,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x33,0x2c,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x75,0x69,0x6e,0x74,0x34,0x20,0x58,0x2c,0x75,0x69,0x6e,0x74,0x34,0x20,0x6b,0x65,0x79,0x29,0x0a,0x7b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x30,0x20,0x5e,0x3d,
|
||||
0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x30,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,
|
||||
0x73,0x31,0x2c,0x31,0x29,0x5d,0x5e,0x41,0x45,0x53,0x32,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x33,0x5b,0x42,
|
||||
0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x33,0x29,0x5d,0x3b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x31,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,
|
||||
0x45,0x28,0x58,0x2e,0x73,0x31,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x31,0x29,0x5d,0x5e,0x41,0x45,
|
||||
0x53,0x32,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x33,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x30,0x2c,
|
||||
0x33,0x29,0x5d,0x3b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x32,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x30,0x29,
|
||||
0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x31,0x29,0x5d,0x5e,0x41,0x45,0x53,0x32,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,
|
||||
0x2e,0x73,0x30,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x33,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x31,0x2c,0x33,0x29,0x5d,0x3b,0x0a,0x6b,0x65,0x79,0x2e,
|
||||
0x73,0x33,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,
|
||||
0x54,0x45,0x28,0x58,0x2e,0x73,0x30,0x2c,0x31,0x29,0x5d,0x5e,0x41,0x45,0x53,0x32,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x31,0x2c,0x32,0x29,0x5d,0x5e,0x41,
|
||||
0x45,0x53,0x33,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x33,0x29,0x5d,0x3b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6b,0x65,0x79,0x3b,0x0a,0x7d,
|
||||
0x0a,0x75,0x69,0x6e,0x74,0x34,0x20,0x41,0x45,0x53,0x5f,0x52,0x6f,0x75,0x6e,0x64,0x5f,0x54,0x77,0x6f,0x5f,0x54,0x61,0x62,0x6c,0x65,0x73,0x28,0x63,0x6f,0x6e,0x73,
|
||||
0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x30,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x6c,0x6f,0x63,
|
||||
0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x41,0x45,0x53,0x31,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x34,0x20,0x58,0x2c,0x75,0x69,0x6e,0x74,
|
||||
0x34,0x20,0x6b,0x65,0x79,0x29,0x0a,0x7b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x30,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,
|
||||
0x30,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x31,0x2c,0x31,0x29,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,
|
||||
0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,
|
||||
0x33,0x2c,0x33,0x29,0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x31,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,
|
||||
0x58,0x2e,0x73,0x31,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x31,0x29,0x5d,0x5e,0x72,0x6f,0x74,0x61,
|
||||
0x74,0x65,0x28,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,
|
||||
0x58,0x2e,0x73,0x30,0x2c,0x33,0x29,0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x32,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,
|
||||
0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x31,0x29,0x5d,0x5e,0x72,
|
||||
0x6f,0x74,0x61,0x74,0x65,0x28,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x30,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,
|
||||
0x54,0x45,0x28,0x58,0x2e,0x73,0x31,0x2c,0x33,0x29,0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x6b,0x65,0x79,0x2e,0x73,0x33,0x20,0x5e,0x3d,0x20,0x41,0x45,0x53,0x30,
|
||||
0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x33,0x2c,0x30,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x30,0x2c,0x31,0x29,
|
||||
0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x41,0x45,0x53,0x30,0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x31,0x2c,0x32,0x29,0x5d,0x5e,0x41,0x45,0x53,0x31,
|
||||
0x5b,0x42,0x59,0x54,0x45,0x28,0x58,0x2e,0x73,0x32,0x2c,0x33,0x29,0x5d,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6b,0x65,0x79,0x3b,
|
||||
0x0a,0x7d,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x63,0x68,0x61,0x72,
|
||||
0x20,0x72,0x63,0x6f,0x6e,0x5b,0x38,0x5d,0x3d,0x7b,0x20,0x30,0x78,0x38,0x64,0x2c,0x30,0x78,0x30,0x31,0x2c,0x30,0x78,0x30,0x32,0x2c,0x30,0x78,0x30,0x34,0x2c,0x30,
|
||||
0x78,0x30,0x38,0x2c,0x30,0x78,0x31,0x30,0x2c,0x30,0x78,0x32,0x30,0x2c,0x30,0x78,0x34,0x30,0x20,0x7d,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,
|
||||
0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x63,0x68,0x61,0x72,0x20,0x73,0x62,0x6f,0x78,0x5b,0x32,0x35,0x36,0x5d,0x20,0x3d,0x0a,
|
||||
0x7b,0x0a,0x30,0x78,0x36,0x33,0x2c,0x30,0x78,0x37,0x43,0x2c,0x30,0x78,0x37,0x37,0x2c,0x30,0x78,0x37,0x42,0x2c,0x30,0x78,0x46,0x32,0x2c,0x30,0x78,0x36,0x42,0x2c,
|
||||
0x30,0x78,0x36,0x46,0x2c,0x30,0x78,0x43,0x35,0x2c,0x30,0x78,0x33,0x30,0x2c,0x30,0x78,0x30,0x31,0x2c,0x30,0x78,0x36,0x37,0x2c,0x30,0x78,0x32,0x42,0x2c,0x30,0x78,
|
||||
0x46,0x45,0x2c,0x30,0x78,0x44,0x37,0x2c,0x30,0x78,0x41,0x42,0x2c,0x30,0x78,0x37,0x36,0x2c,0x0a,0x30,0x78,0x43,0x41,0x2c,0x30,0x78,0x38,0x32,0x2c,0x30,0x78,0x43,
|
||||
0x39,0x2c,0x30,0x78,0x37,0x44,0x2c,0x30,0x78,0x46,0x41,0x2c,0x30,0x78,0x35,0x39,0x2c,0x30,0x78,0x34,0x37,0x2c,0x30,0x78,0x46,0x30,0x2c,0x30,0x78,0x41,0x44,0x2c,
|
||||
0x30,0x78,0x44,0x34,0x2c,0x30,0x78,0x41,0x32,0x2c,0x30,0x78,0x41,0x46,0x2c,0x30,0x78,0x39,0x43,0x2c,0x30,0x78,0x41,0x34,0x2c,0x30,0x78,0x37,0x32,0x2c,0x30,0x78,
|
||||
0x43,0x30,0x2c,0x0a,0x30,0x78,0x42,0x37,0x2c,0x30,0x78,0x46,0x44,0x2c,0x30,0x78,0x39,0x33,0x2c,0x30,0x78,0x32,0x36,0x2c,0x30,0x78,0x33,0x36,0x2c,0x30,0x78,0x33,
|
||||
0x46,0x2c,0x30,0x78,0x46,0x37,0x2c,0x30,0x78,0x43,0x43,0x2c,0x30,0x78,0x33,0x34,0x2c,0x30,0x78,0x41,0x35,0x2c,0x30,0x78,0x45,0x35,0x2c,0x30,0x78,0x46,0x31,0x2c,
|
||||
0x30,0x78,0x37,0x31,0x2c,0x30,0x78,0x44,0x38,0x2c,0x30,0x78,0x33,0x31,0x2c,0x30,0x78,0x31,0x35,0x2c,0x0a,0x30,0x78,0x30,0x34,0x2c,0x30,0x78,0x43,0x37,0x2c,0x30,
|
||||
0x78,0x32,0x33,0x2c,0x30,0x78,0x43,0x33,0x2c,0x30,0x78,0x31,0x38,0x2c,0x30,0x78,0x39,0x36,0x2c,0x30,0x78,0x30,0x35,0x2c,0x30,0x78,0x39,0x41,0x2c,0x30,0x78,0x30,
|
||||
0x37,0x2c,0x30,0x78,0x31,0x32,0x2c,0x30,0x78,0x38,0x30,0x2c,0x30,0x78,0x45,0x32,0x2c,0x30,0x78,0x45,0x42,0x2c,0x30,0x78,0x32,0x37,0x2c,0x30,0x78,0x42,0x32,0x2c,
|
||||
0x30,0x78,0x37,0x35,0x2c,0x0a,0x30,0x78,0x30,0x39,0x2c,0x30,0x78,0x38,0x33,0x2c,0x30,0x78,0x32,0x43,0x2c,0x30,0x78,0x31,0x41,0x2c,0x30,0x78,0x31,0x42,0x2c,0x30,
|
||||
0x78,0x36,0x45,0x2c,0x30,0x78,0x35,0x41,0x2c,0x30,0x78,0x41,0x30,0x2c,0x30,0x78,0x35,0x32,0x2c,0x30,0x78,0x33,0x42,0x2c,0x30,0x78,0x44,0x36,0x2c,0x30,0x78,0x42,
|
||||
0x33,0x2c,0x30,0x78,0x32,0x39,0x2c,0x30,0x78,0x45,0x33,0x2c,0x30,0x78,0x32,0x46,0x2c,0x30,0x78,0x38,0x34,0x2c,0x0a,0x30,0x78,0x35,0x33,0x2c,0x30,0x78,0x44,0x31,
|
||||
0x2c,0x30,0x78,0x30,0x30,0x2c,0x30,0x78,0x45,0x44,0x2c,0x30,0x78,0x32,0x30,0x2c,0x30,0x78,0x46,0x43,0x2c,0x30,0x78,0x42,0x31,0x2c,0x30,0x78,0x35,0x42,0x2c,0x30,
|
||||
0x78,0x36,0x41,0x2c,0x30,0x78,0x43,0x42,0x2c,0x30,0x78,0x42,0x45,0x2c,0x30,0x78,0x33,0x39,0x2c,0x30,0x78,0x34,0x41,0x2c,0x30,0x78,0x34,0x43,0x2c,0x30,0x78,0x35,
|
||||
0x38,0x2c,0x30,0x78,0x43,0x46,0x2c,0x0a,0x30,0x78,0x44,0x30,0x2c,0x30,0x78,0x45,0x46,0x2c,0x30,0x78,0x41,0x41,0x2c,0x30,0x78,0x46,0x42,0x2c,0x30,0x78,0x34,0x33,
|
||||
0x2c,0x30,0x78,0x34,0x44,0x2c,0x30,0x78,0x33,0x33,0x2c,0x30,0x78,0x38,0x35,0x2c,0x30,0x78,0x34,0x35,0x2c,0x30,0x78,0x46,0x39,0x2c,0x30,0x78,0x30,0x32,0x2c,0x30,
|
||||
0x78,0x37,0x46,0x2c,0x30,0x78,0x35,0x30,0x2c,0x30,0x78,0x33,0x43,0x2c,0x30,0x78,0x39,0x46,0x2c,0x30,0x78,0x41,0x38,0x2c,0x0a,0x30,0x78,0x35,0x31,0x2c,0x30,0x78,
|
||||
0x41,0x33,0x2c,0x30,0x78,0x34,0x30,0x2c,0x30,0x78,0x38,0x46,0x2c,0x30,0x78,0x39,0x32,0x2c,0x30,0x78,0x39,0x44,0x2c,0x30,0x78,0x33,0x38,0x2c,0x30,0x78,0x46,0x35,
|
||||
0x2c,0x30,0x78,0x42,0x43,0x2c,0x30,0x78,0x42,0x36,0x2c,0x30,0x78,0x44,0x41,0x2c,0x30,0x78,0x32,0x31,0x2c,0x30,0x78,0x31,0x30,0x2c,0x30,0x78,0x46,0x46,0x2c,0x30,
|
||||
0x78,0x46,0x33,0x2c,0x30,0x78,0x44,0x32,0x2c,0x0a,0x30,0x78,0x43,0x44,0x2c,0x30,0x78,0x30,0x43,0x2c,0x30,0x78,0x31,0x33,0x2c,0x30,0x78,0x45,0x43,0x2c,0x30,0x78,
|
||||
0x35,0x46,0x2c,0x30,0x78,0x39,0x37,0x2c,0x30,0x78,0x34,0x34,0x2c,0x30,0x78,0x31,0x37,0x2c,0x30,0x78,0x43,0x34,0x2c,0x30,0x78,0x41,0x37,0x2c,0x30,0x78,0x37,0x45,
|
||||
0x2c,0x30,0x78,0x33,0x44,0x2c,0x30,0x78,0x36,0x34,0x2c,0x30,0x78,0x35,0x44,0x2c,0x30,0x78,0x31,0x39,0x2c,0x30,0x78,0x37,0x33,0x2c,0x0a,0x30,0x78,0x36,0x30,0x2c,
|
||||
0x30,0x78,0x38,0x31,0x2c,0x30,0x78,0x34,0x46,0x2c,0x30,0x78,0x44,0x43,0x2c,0x30,0x78,0x32,0x32,0x2c,0x30,0x78,0x32,0x41,0x2c,0x30,0x78,0x39,0x30,0x2c,0x30,0x78,
|
||||
0x38,0x38,0x2c,0x30,0x78,0x34,0x36,0x2c,0x30,0x78,0x45,0x45,0x2c,0x30,0x78,0x42,0x38,0x2c,0x30,0x78,0x31,0x34,0x2c,0x30,0x78,0x44,0x45,0x2c,0x30,0x78,0x35,0x45,
|
||||
0x2c,0x30,0x78,0x30,0x42,0x2c,0x30,0x78,0x44,0x42,0x2c,0x0a,0x30,0x78,0x45,0x30,0x2c,0x30,0x78,0x33,0x32,0x2c,0x30,0x78,0x33,0x41,0x2c,0x30,0x78,0x30,0x41,0x2c,
|
||||
0x30,0x78,0x34,0x39,0x2c,0x30,0x78,0x30,0x36,0x2c,0x30,0x78,0x32,0x34,0x2c,0x30,0x78,0x35,0x43,0x2c,0x30,0x78,0x43,0x32,0x2c,0x30,0x78,0x44,0x33,0x2c,0x30,0x78,
|
||||
0x41,0x43,0x2c,0x30,0x78,0x36,0x32,0x2c,0x30,0x78,0x39,0x31,0x2c,0x30,0x78,0x39,0x35,0x2c,0x30,0x78,0x45,0x34,0x2c,0x30,0x78,0x37,0x39,0x2c,0x0a,0x30,0x78,0x45,
|
||||
0x37,0x2c,0x30,0x78,0x43,0x38,0x2c,0x30,0x78,0x33,0x37,0x2c,0x30,0x78,0x36,0x44,0x2c,0x30,0x78,0x38,0x44,0x2c,0x30,0x78,0x44,0x35,0x2c,0x30,0x78,0x34,0x45,0x2c,
|
||||
0x30,0x78,0x41,0x39,0x2c,0x30,0x78,0x36,0x43,0x2c,0x30,0x78,0x35,0x36,0x2c,0x30,0x78,0x46,0x34,0x2c,0x30,0x78,0x45,0x41,0x2c,0x30,0x78,0x36,0x35,0x2c,0x30,0x78,
|
||||
0x37,0x41,0x2c,0x30,0x78,0x41,0x45,0x2c,0x30,0x78,0x30,0x38,0x2c,0x0a,0x30,0x78,0x42,0x41,0x2c,0x30,0x78,0x37,0x38,0x2c,0x30,0x78,0x32,0x35,0x2c,0x30,0x78,0x32,
|
||||
0x45,0x2c,0x30,0x78,0x31,0x43,0x2c,0x30,0x78,0x41,0x36,0x2c,0x30,0x78,0x42,0x34,0x2c,0x30,0x78,0x43,0x36,0x2c,0x30,0x78,0x45,0x38,0x2c,0x30,0x78,0x44,0x44,0x2c,
|
||||
0x30,0x78,0x37,0x34,0x2c,0x30,0x78,0x31,0x46,0x2c,0x30,0x78,0x34,0x42,0x2c,0x30,0x78,0x42,0x44,0x2c,0x30,0x78,0x38,0x42,0x2c,0x30,0x78,0x38,0x41,0x2c,0x0a,0x30,
|
||||
0x78,0x37,0x30,0x2c,0x30,0x78,0x33,0x45,0x2c,0x30,0x78,0x42,0x35,0x2c,0x30,0x78,0x36,0x36,0x2c,0x30,0x78,0x34,0x38,0x2c,0x30,0x78,0x30,0x33,0x2c,0x30,0x78,0x46,
|
||||
0x36,0x2c,0x30,0x78,0x30,0x45,0x2c,0x30,0x78,0x36,0x31,0x2c,0x30,0x78,0x33,0x35,0x2c,0x30,0x78,0x35,0x37,0x2c,0x30,0x78,0x42,0x39,0x2c,0x30,0x78,0x38,0x36,0x2c,
|
||||
0x30,0x78,0x43,0x31,0x2c,0x30,0x78,0x31,0x44,0x2c,0x30,0x78,0x39,0x45,0x2c,0x0a,0x30,0x78,0x45,0x31,0x2c,0x30,0x78,0x46,0x38,0x2c,0x30,0x78,0x39,0x38,0x2c,0x30,
|
||||
0x78,0x31,0x31,0x2c,0x30,0x78,0x36,0x39,0x2c,0x30,0x78,0x44,0x39,0x2c,0x30,0x78,0x38,0x45,0x2c,0x30,0x78,0x39,0x34,0x2c,0x30,0x78,0x39,0x42,0x2c,0x30,0x78,0x31,
|
||||
0x45,0x2c,0x30,0x78,0x38,0x37,0x2c,0x30,0x78,0x45,0x39,0x2c,0x30,0x78,0x43,0x45,0x2c,0x30,0x78,0x35,0x35,0x2c,0x30,0x78,0x32,0x38,0x2c,0x30,0x78,0x44,0x46,0x2c,
|
||||
0x0a,0x30,0x78,0x38,0x43,0x2c,0x30,0x78,0x41,0x31,0x2c,0x30,0x78,0x38,0x39,0x2c,0x30,0x78,0x30,0x44,0x2c,0x30,0x78,0x42,0x46,0x2c,0x30,0x78,0x45,0x36,0x2c,0x30,
|
||||
0x78,0x34,0x32,0x2c,0x30,0x78,0x36,0x38,0x2c,0x30,0x78,0x34,0x31,0x2c,0x30,0x78,0x39,0x39,0x2c,0x30,0x78,0x32,0x44,0x2c,0x30,0x78,0x30,0x46,0x2c,0x30,0x78,0x42,
|
||||
0x30,0x2c,0x30,0x78,0x35,0x34,0x2c,0x30,0x78,0x42,0x42,0x2c,0x30,0x78,0x31,0x36,0x0a,0x7d,0x3b,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x53,0x75,0x62,0x57,
|
||||
0x6f,0x72,0x64,0x28,0x69,0x6e,0x77,0x29,0x20,0x28,0x28,0x73,0x62,0x6f,0x78,0x5b,0x42,0x59,0x54,0x45,0x28,0x69,0x6e,0x77,0x2c,0x20,0x33,0x29,0x5d,0x20,0x3c,0x3c,
|
||||
0x20,0x32,0x34,0x29,0x20,0x7c,0x20,0x28,0x73,0x62,0x6f,0x78,0x5b,0x42,0x59,0x54,0x45,0x28,0x69,0x6e,0x77,0x2c,0x20,0x32,0x29,0x5d,0x20,0x3c,0x3c,0x20,0x31,0x36,
|
||||
0x29,0x20,0x7c,0x20,0x28,0x73,0x62,0x6f,0x78,0x5b,0x42,0x59,0x54,0x45,0x28,0x69,0x6e,0x77,0x2c,0x20,0x31,0x29,0x5d,0x20,0x3c,0x3c,0x20,0x38,0x29,0x20,0x7c,0x20,
|
||||
0x73,0x62,0x6f,0x78,0x5b,0x42,0x59,0x54,0x45,0x28,0x69,0x6e,0x77,0x2c,0x20,0x30,0x29,0x5d,0x29,0x0a,0x76,0x6f,0x69,0x64,0x20,0x41,0x45,0x53,0x45,0x78,0x70,0x61,
|
||||
0x6e,0x64,0x4b,0x65,0x79,0x32,0x35,0x36,0x28,0x75,0x69,0x6e,0x74,0x20,0x2a,0x6b,0x65,0x79,0x62,0x75,0x66,0x29,0x0a,0x7b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,
|
||||
0x6e,0x74,0x20,0x63,0x3d,0x38,0x2c,0x69,0x3d,0x31,0x3b,0x20,0x63,0x3c,0x34,0x30,0x3b,0x20,0x2b,0x2b,0x63,0x29,0x20,0x7b,0x0a,0x75,0x69,0x6e,0x74,0x20,0x74,0x3d,
|
||||
0x28,0x28,0x21,0x28,0x63,0x26,0x37,0x29,0x29,0x7c,0x7c,0x28,0x28,0x63,0x26,0x37,0x29,0x3d,0x3d,0x34,0x29,0x29,0x3f,0x53,0x75,0x62,0x57,0x6f,0x72,0x64,0x28,0x6b,
|
||||
0x65,0x79,0x62,0x75,0x66,0x5b,0x63,0x2d,0x31,0x5d,0x29,0x3a,0x6b,0x65,0x79,0x62,0x75,0x66,0x5b,0x63,0x2d,0x31,0x5d,0x3b,0x0a,0x6b,0x65,0x79,0x62,0x75,0x66,0x5b,
|
||||
0x63,0x5d,0x3d,0x6b,0x65,0x79,0x62,0x75,0x66,0x5b,0x63,0x2d,0x38,0x5d,0x5e,0x28,0x28,0x21,0x28,0x63,0x26,0x37,0x29,0x29,0x3f,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,
|
||||
0x74,0x2c,0x32,0x34,0x55,0x29,0x5e,0x61,0x73,0x5f,0x75,0x69,0x6e,0x74,0x28,0x28,0x75,0x63,0x68,0x61,0x72,0x34,0x29,0x28,0x72,0x63,0x6f,0x6e,0x5b,0x69,0x2b,0x2b,
|
||||
0x5d,0x2c,0x30,0x55,0x2c,0x30,0x55,0x2c,0x30,0x55,0x29,0x29,0x3a,0x74,0x29,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x23,0x65,0x6e,0x64,0x69,0x66,0x0a,0x23,0x69,0x66,0x6e,
|
||||
0x64,0x65,0x66,0x20,0x58,0x4d,0x52,0x49,0x47,0x5f,0x4b,0x45,0x43,0x43,0x41,0x4b,0x5f,0x43,0x4c,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x58,0x4d,0x52,0x49,
|
||||
0x47,0x5f,0x4b,0x45,0x43,0x43,0x41,0x4b,0x5f,0x43,0x4c,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,
|
||||
0x61,0x6e,0x74,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x72,0x6e,0x64,0x63,0x5b,0x32,0x34,0x5d,0x20,0x3d,0x0a,0x7b,0x0a,0x30,
|
||||
0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||
0x38,0x30,0x38,0x32,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x38,0x61,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x38,0x62,0x2c,0x30,
|
||||
0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,
|
||||
0x30,0x38,0x30,0x38,0x31,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x39,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x61,0x2c,0x0a,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x38,0x2c,
|
||||
0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x30,0x39,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x61,0x2c,0x0a,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x38,0x62,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x62,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x38,0x39,0x2c,
|
||||
0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x33,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x38,0x30,0x30,0x32,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x2c,0x0a,0x30,0x78,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x61,0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x61,
|
||||
0x2c,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x38,0x31,0x2c,0x0a,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x30,0x38,0x30,0x38,0x30,0x2c,0x30,0x78,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x31,0x2c,0x30,0x78,0x38,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x38,0x30,0x30,0x30,0x38,0x30,0x30,0x38,0x0a,0x7d,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,
|
||||
0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x72,0x6f,0x74,0x63,0x5b,0x32,0x34,0x5d,0x20,0x3d,
|
||||
0x0a,0x7b,0x0a,0x31,0x2c,0x33,0x2c,0x36,0x2c,0x31,0x30,0x2c,0x31,0x35,0x2c,0x32,0x31,0x2c,0x32,0x38,0x2c,0x33,0x36,0x2c,0x34,0x35,0x2c,0x35,0x35,0x2c,0x32,0x2c,
|
||||
0x31,0x34,0x2c,0x0a,0x32,0x37,0x2c,0x34,0x31,0x2c,0x35,0x36,0x2c,0x38,0x2c,0x32,0x35,0x2c,0x34,0x33,0x2c,0x36,0x32,0x2c,0x31,0x38,0x2c,0x33,0x39,0x2c,0x36,0x31,
|
||||
0x2c,0x32,0x30,0x2c,0x34,0x34,0x0a,0x7d,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,
|
||||
0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x70,0x69,0x6c,0x6e,0x5b,0x32,0x34,0x5d,0x20,0x3d,0x0a,0x7b,0x0a,0x31,0x30,0x2c,0x37,
|
||||
0x2c,0x31,0x31,0x2c,0x31,0x37,0x2c,0x31,0x38,0x2c,0x33,0x2c,0x35,0x2c,0x31,0x36,0x2c,0x38,0x2c,0x32,0x31,0x2c,0x32,0x34,0x2c,0x34,0x2c,0x0a,0x31,0x35,0x2c,0x32,
|
||||
0x33,0x2c,0x31,0x39,0x2c,0x31,0x33,0x2c,0x31,0x32,0x2c,0x32,0x2c,0x32,0x30,0x2c,0x31,0x34,0x2c,0x32,0x32,0x2c,0x39,0x2c,0x36,0x2c,0x31,0x0a,0x7d,0x3b,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x31,0x36,0x30,0x30,0x5f,0x31,0x28,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x73,0x74,0x29,0x0a,0x7b,0x0a,0x69,
|
||||
0x6e,0x74,0x20,0x69,0x2c,0x72,0x6f,0x75,0x6e,0x64,0x3b,0x0a,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x74,0x2c,0x62,0x63,0x5b,0x35,0x5d,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,
|
||||
0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x72,0x6f,0x75,0x6e,0x64,0x3d,0x30,0x3b,0x20,0x72,0x6f,0x75,0x6e,0x64,0x3c,
|
||||
0x32,0x34,0x3b,0x20,0x2b,0x2b,0x72,0x6f,0x75,0x6e,0x64,0x29,0x20,0x7b,0x0a,0x62,0x63,0x5b,0x30,0x5d,0x3d,0x73,0x74,0x5b,0x30,0x5d,0x5e,0x73,0x74,0x5b,0x35,0x5d,
|
||||
0x5e,0x73,0x74,0x5b,0x31,0x30,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x35,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x30,0x5d,0x3b,0x0a,0x62,0x63,0x5b,0x31,0x5d,0x3d,0x73,0x74,0x5b,
|
||||
0x31,0x5d,0x5e,0x73,0x74,0x5b,0x36,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x31,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x36,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x31,0x5d,0x3b,0x0a,0x62,
|
||||
0x63,0x5b,0x32,0x5d,0x3d,0x73,0x74,0x5b,0x32,0x5d,0x5e,0x73,0x74,0x5b,0x37,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x32,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x37,0x5d,0x5e,0x73,
|
||||
0x74,0x5b,0x32,0x32,0x5d,0x3b,0x0a,0x62,0x63,0x5b,0x33,0x5d,0x3d,0x73,0x74,0x5b,0x33,0x5d,0x5e,0x73,0x74,0x5b,0x38,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x33,0x5d,0x5e,
|
||||
0x73,0x74,0x5b,0x31,0x38,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x33,0x5d,0x3b,0x0a,0x62,0x63,0x5b,0x34,0x5d,0x3d,0x73,0x74,0x5b,0x34,0x5d,0x5e,0x73,0x74,0x5b,0x39,0x5d,
|
||||
0x5e,0x73,0x74,0x5b,0x31,0x34,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x39,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x34,0x5d,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,
|
||||
0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x35,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x7b,0x0a,0x74,0x3d,
|
||||
0x62,0x63,0x5b,0x28,0x69,0x2b,0x34,0x29,0x20,0x25,0x20,0x35,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x62,0x63,0x5b,0x28,0x69,0x2b,0x31,0x29,0x20,0x25,0x20,
|
||||
0x35,0x5d,0x2c,0x31,0x55,0x4c,0x29,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x20,0x5d,0x20,0x5e,0x3d,0x20,0x74,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x35,0x5d,0x20,0x5e,0x3d,
|
||||
0x20,0x74,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x31,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x74,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x31,0x35,0x5d,0x20,0x5e,0x3d,0x20,0x74,
|
||||
0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x32,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x74,0x3b,0x0a,0x7d,0x0a,0x74,0x3d,0x73,0x74,0x5b,0x31,0x5d,0x3b,0x0a,0x23,0x70,0x72,0x61,
|
||||
0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x32,0x34,0x3b,0x20,0x2b,0x2b,0x69,
|
||||
0x29,0x20,0x7b,0x0a,0x62,0x63,0x5b,0x30,0x5d,0x3d,0x73,0x74,0x5b,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x70,0x69,0x6c,0x6e,0x5b,0x69,0x5d,0x5d,0x3b,0x0a,0x73,
|
||||
0x74,0x5b,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x70,0x69,0x6c,0x6e,0x5b,0x69,0x5d,0x5d,0x3d,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x74,0x2c,0x28,0x75,0x6c,0x6f,
|
||||
0x6e,0x67,0x29,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x72,0x6f,0x74,0x63,0x5b,0x69,0x5d,0x29,0x3b,0x0a,0x74,0x3d,0x62,0x63,0x5b,0x30,0x5d,0x3b,0x0a,0x7d,0x0a,
|
||||
0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,
|
||||
0x3c,0x32,0x35,0x3b,0x20,0x69,0x2b,0x3d,0x35,0x29,0x20,0x7b,0x0a,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x74,0x6d,0x70,0x5b,0x35,0x5d,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,
|
||||
0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x3d,0x30,0x3b,0x20,0x78,0x3c,0x35,0x3b,0x20,0x2b,
|
||||
0x2b,0x78,0x29,0x20,0x7b,0x0a,0x74,0x6d,0x70,0x5b,0x78,0x5d,0x3d,0x62,0x69,0x74,0x73,0x65,0x6c,0x65,0x63,0x74,0x28,0x73,0x74,0x5b,0x69,0x2b,0x78,0x5d,0x5e,0x73,
|
||||
0x74,0x5b,0x69,0x2b,0x28,0x28,0x78,0x2b,0x32,0x29,0x20,0x25,0x20,0x35,0x29,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x78,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x28,0x28,
|
||||
0x78,0x2b,0x31,0x29,0x20,0x25,0x20,0x35,0x29,0x5d,0x29,0x3b,0x0a,0x7d,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,
|
||||
0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x78,0x3d,0x30,0x3b,0x20,0x78,0x3c,0x35,0x3b,0x20,0x2b,0x2b,0x78,0x29,0x20,0x7b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x78,
|
||||
0x5d,0x3d,0x74,0x6d,0x70,0x5b,0x78,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x73,0x74,0x5b,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x72,
|
||||
0x6e,0x64,0x63,0x5b,0x72,0x6f,0x75,0x6e,0x64,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x31,0x36,0x30,0x30,
|
||||
0x5f,0x32,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x73,0x74,0x29,0x0a,0x7b,0x0a,0x69,0x6e,0x74,0x20,0x69,0x2c,0x72,0x6f,
|
||||
0x75,0x6e,0x64,0x3b,0x0a,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x74,0x2c,0x62,0x63,0x5b,0x35,0x5d,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,
|
||||
0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x72,0x6f,0x75,0x6e,0x64,0x3d,0x30,0x3b,0x20,0x72,0x6f,0x75,0x6e,0x64,0x3c,0x32,0x34,0x3b,0x20,0x2b,0x2b,0x72,
|
||||
0x6f,0x75,0x6e,0x64,0x29,0x20,0x7b,0x0a,0x62,0x63,0x5b,0x30,0x5d,0x3d,0x73,0x74,0x5b,0x30,0x5d,0x5e,0x73,0x74,0x5b,0x35,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x30,0x5d,
|
||||
0x5e,0x73,0x74,0x5b,0x31,0x35,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x30,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x73,0x74,0x5b,0x32,0x5d,0x5e,0x73,0x74,0x5b,0x37,
|
||||
0x5d,0x5e,0x73,0x74,0x5b,0x31,0x32,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x37,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x32,0x5d,0x2c,0x31,0x55,0x4c,0x29,0x3b,0x0a,0x62,0x63,0x5b,
|
||||
0x31,0x5d,0x3d,0x73,0x74,0x5b,0x31,0x5d,0x5e,0x73,0x74,0x5b,0x36,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x31,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x36,0x5d,0x5e,0x73,0x74,0x5b,
|
||||
0x32,0x31,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x73,0x74,0x5b,0x33,0x5d,0x5e,0x73,0x74,0x5b,0x38,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x33,0x5d,0x5e,0x73,0x74,
|
||||
0x5b,0x31,0x38,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x33,0x5d,0x2c,0x31,0x55,0x4c,0x29,0x3b,0x0a,0x62,0x63,0x5b,0x32,0x5d,0x3d,0x73,0x74,0x5b,0x32,0x5d,0x5e,0x73,0x74,
|
||||
0x5b,0x37,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x32,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x37,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x32,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,
|
||||
0x73,0x74,0x5b,0x34,0x5d,0x5e,0x73,0x74,0x5b,0x39,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x34,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x39,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x34,0x5d,
|
||||
0x2c,0x31,0x55,0x4c,0x29,0x3b,0x0a,0x62,0x63,0x5b,0x33,0x5d,0x3d,0x73,0x74,0x5b,0x33,0x5d,0x5e,0x73,0x74,0x5b,0x38,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x33,0x5d,0x5e,
|
||||
0x73,0x74,0x5b,0x31,0x38,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x33,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x73,0x74,0x5b,0x30,0x5d,0x5e,0x73,0x74,0x5b,0x35,0x5d,
|
||||
0x5e,0x73,0x74,0x5b,0x31,0x30,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x35,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x30,0x5d,0x2c,0x31,0x55,0x4c,0x29,0x3b,0x0a,0x62,0x63,0x5b,0x34,
|
||||
0x5d,0x3d,0x73,0x74,0x5b,0x34,0x5d,0x5e,0x73,0x74,0x5b,0x39,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x34,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x39,0x5d,0x5e,0x73,0x74,0x5b,0x32,
|
||||
0x34,0x5d,0x5e,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x73,0x74,0x5b,0x31,0x5d,0x5e,0x73,0x74,0x5b,0x36,0x5d,0x5e,0x73,0x74,0x5b,0x31,0x31,0x5d,0x5e,0x73,0x74,0x5b,
|
||||
0x31,0x36,0x5d,0x5e,0x73,0x74,0x5b,0x32,0x31,0x5d,0x2c,0x31,0x55,0x4c,0x29,0x3b,0x0a,0x73,0x74,0x5b,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x34,0x5d,0x3b,
|
||||
0x0a,0x73,0x74,0x5b,0x35,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x34,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x34,0x5d,
|
||||
0x3b,0x0a,0x73,0x74,0x5b,0x31,0x35,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x34,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x32,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,
|
||||
0x34,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x30,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x36,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,
|
||||
0x30,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x31,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x30,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x36,0x5d,0x20,0x5e,0x3d,0x20,0x62,
|
||||
0x63,0x5b,0x30,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x32,0x31,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x30,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x32,0x5d,0x20,0x5e,0x3d,0x20,
|
||||
0x62,0x63,0x5b,0x31,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x37,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x31,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x32,0x5d,0x20,0x5e,0x3d,
|
||||
0x20,0x62,0x63,0x5b,0x31,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x37,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x31,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x32,0x32,0x5d,0x20,
|
||||
0x5e,0x3d,0x20,0x62,0x63,0x5b,0x31,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x33,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x32,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x38,0x5d,0x20,
|
||||
0x5e,0x3d,0x20,0x62,0x63,0x5b,0x32,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x33,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x32,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x38,
|
||||
0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x32,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x32,0x33,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x32,0x5d,0x3b,0x0a,0x73,0x74,0x5b,
|
||||
0x34,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x33,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x39,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x33,0x5d,0x3b,0x0a,0x73,0x74,0x5b,
|
||||
0x31,0x34,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x33,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x31,0x39,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x33,0x5d,0x3b,0x0a,0x73,
|
||||
0x74,0x5b,0x32,0x34,0x5d,0x20,0x5e,0x3d,0x20,0x62,0x63,0x5b,0x33,0x5d,0x3b,0x0a,0x74,0x3d,0x73,0x74,0x5b,0x31,0x5d,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,
|
||||
0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x32,0x34,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x7b,
|
||||
0x0a,0x62,0x63,0x5b,0x30,0x5d,0x3d,0x73,0x74,0x5b,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x70,0x69,0x6c,0x6e,0x5b,0x69,0x5d,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x6b,
|
||||
0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x70,0x69,0x6c,0x6e,0x5b,0x69,0x5d,0x5d,0x3d,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x74,0x2c,0x28,0x75,0x6c,0x6f,0x6e,0x67,0x29,
|
||||
0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x72,0x6f,0x74,0x63,0x5b,0x69,0x5d,0x29,0x3b,0x0a,0x74,0x3d,0x62,0x63,0x5b,0x30,0x5d,0x3b,0x0a,0x7d,0x0a,0x23,0x70,0x72,
|
||||
0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x32,0x35,
|
||||
0x3b,0x20,0x69,0x2b,0x3d,0x35,0x29,0x20,0x7b,0x0a,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x74,0x6d,0x70,0x31,0x3d,0x73,0x74,0x5b,0x69,0x5d,0x2c,0x74,0x6d,0x70,0x32,0x3d,
|
||||
0x73,0x74,0x5b,0x69,0x2b,0x31,0x5d,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x5d,0x3d,0x62,0x69,0x74,0x73,0x65,0x6c,0x65,0x63,0x74,0x28,0x73,0x74,0x5b,0x69,0x5d,0x5e,0x73,
|
||||
0x74,0x5b,0x69,0x2b,0x32,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x31,0x5d,0x29,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x31,0x5d,0x3d,0x62,
|
||||
0x69,0x74,0x73,0x65,0x6c,0x65,0x63,0x74,0x28,0x73,0x74,0x5b,0x69,0x2b,0x31,0x5d,0x5e,0x73,0x74,0x5b,0x69,0x2b,0x33,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x31,0x5d,
|
||||
0x2c,0x73,0x74,0x5b,0x69,0x2b,0x32,0x5d,0x29,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x32,0x5d,0x3d,0x62,0x69,0x74,0x73,0x65,0x6c,0x65,0x63,0x74,0x28,0x73,0x74,0x5b,
|
||||
0x69,0x2b,0x32,0x5d,0x5e,0x73,0x74,0x5b,0x69,0x2b,0x34,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x32,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x33,0x5d,0x29,0x3b,0x0a,0x73,
|
||||
0x74,0x5b,0x69,0x2b,0x33,0x5d,0x3d,0x62,0x69,0x74,0x73,0x65,0x6c,0x65,0x63,0x74,0x28,0x73,0x74,0x5b,0x69,0x2b,0x33,0x5d,0x5e,0x74,0x6d,0x70,0x31,0x2c,0x73,0x74,
|
||||
0x5b,0x69,0x2b,0x33,0x5d,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x34,0x5d,0x29,0x3b,0x0a,0x73,0x74,0x5b,0x69,0x2b,0x34,0x5d,0x3d,0x62,0x69,0x74,0x73,0x65,0x6c,0x65,0x63,
|
||||
0x74,0x28,0x73,0x74,0x5b,0x69,0x2b,0x34,0x5d,0x5e,0x74,0x6d,0x70,0x32,0x2c,0x73,0x74,0x5b,0x69,0x2b,0x34,0x5d,0x2c,0x74,0x6d,0x70,0x31,0x29,0x3b,0x0a,0x7d,0x0a,
|
||||
0x73,0x74,0x5b,0x30,0x5d,0x20,0x5e,0x3d,0x20,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x5f,0x72,0x6e,0x64,0x63,0x5b,0x72,0x6f,0x75,0x6e,0x64,0x5d,0x3b,0x0a,0x7d,0x0a,
|
||||
0x7d,0x0a,0x23,0x65,0x6e,0x64,0x69,0x66,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x65,0x74,0x49,0x64,0x78,0x28,0x29,0x0a,0x7b,0x0a,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x2d,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,
|
||||
0x61,0x6c,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x23,0x64,0x65,0x66,0x69,0x6e,0x65,0x20,0x49,0x44,0x58,0x28,0x78,0x29,0x20,0x28,
|
||||
0x78,0x29,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x34,0x20,0x61,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x2b,0x62,0x3b,0x0a,0x7d,0x0a,0x69,
|
||||
0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x73,0x75,0x62,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,
|
||||
0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x2d,0x62,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,
|
||||
0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,0x2c,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x2a,0x62,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x64,0x69,0x76,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x2f,0x62,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||
0x20,0x5f,0x6d,0x6d,0x5f,0x61,0x6e,0x64,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,0x2c,0x69,0x6e,0x74,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,
|
||||
0x74,0x75,0x72,0x6e,0x20,0x61,0x73,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x61,0x73,0x5f,0x69,0x6e,0x74,0x34,0x28,0x61,0x29,0x26,0x28,0x69,0x6e,0x74,0x34,0x29,
|
||||
0x28,0x62,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x6f,0x72,0x5f,0x70,0x73,0x28,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,0x2c,0x69,0x6e,0x74,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x73,0x5f,0x66,0x6c,0x6f,0x61,
|
||||
0x74,0x34,0x28,0x61,0x73,0x5f,0x69,0x6e,0x74,0x34,0x28,0x61,0x29,0x7c,0x28,0x69,0x6e,0x74,0x34,0x29,0x28,0x62,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,
|
||||
0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x66,0x6d,0x6f,0x64,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x76,0x2c,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x20,0x64,0x63,0x29,0x0a,0x7b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x64,0x3d,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x64,0x63,0x29,
|
||||
0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x3d,0x5f,0x6d,0x6d,0x5f,0x64,0x69,0x76,0x5f,0x70,0x73,0x28,0x76,0x2c,0x64,0x29,0x3b,0x0a,0x63,0x3d,0x74,0x72,
|
||||
0x75,0x6e,0x63,0x28,0x63,0x29,0x3b,0x0a,0x63,0x3d,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,0x63,0x2c,0x64,0x29,0x3b,0x0a,0x72,0x65,0x74,0x75,0x72,
|
||||
0x6e,0x20,0x5f,0x6d,0x6d,0x5f,0x73,0x75,0x62,0x5f,0x70,0x73,0x28,0x76,0x2c,0x63,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x69,0x6e,0x74,0x34,
|
||||
0x20,0x5f,0x6d,0x6d,0x5f,0x78,0x6f,0x72,0x5f,0x73,0x69,0x31,0x32,0x38,0x28,0x69,0x6e,0x74,0x34,0x20,0x61,0x2c,0x69,0x6e,0x74,0x34,0x20,0x62,0x29,0x0a,0x7b,0x0a,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x61,0x5e,0x62,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,
|
||||
0x78,0x6f,0x72,0x5f,0x70,0x73,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x61,0x2c,0x69,0x6e,0x74,0x20,0x62,0x29,0x0a,0x7b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
|
||||
0x61,0x73,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x34,0x28,0x61,0x73,0x5f,0x69,0x6e,0x74,0x34,0x28,0x61,0x29,0x5e,0x28,0x69,0x6e,0x74,0x34,0x29,0x28,0x62,0x29,0x29,0x3b,
|
||||
0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x69,0x6e,0x74,0x34,0x20,0x5f,0x6d,0x6d,0x5f,0x61,0x6c,0x69,0x67,0x6e,0x72,0x5f,0x65,0x70,0x69,0x38,0x28,0x69,
|
||||
0x6e,0x74,0x34,0x20,0x61,0x2c,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x72,0x6f,0x74,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,
|
||||
0x6e,0x74,0x20,0x72,0x69,0x67,0x68,0x74,0x3d,0x38,0x2a,0x72,0x6f,0x74,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x6c,0x65,0x66,0x74,0x3d,
|
||||
0x28,0x33,0x32,0x2d,0x38,0x2a,0x72,0x6f,0x74,0x29,0x3b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x28,0x69,0x6e,0x74,0x34,0x29,0x28,0x0a,0x28,0x28,0x75,0x69,0x6e,
|
||||
0x74,0x29,0x61,0x2e,0x78,0x3e,0x3e,0x72,0x69,0x67,0x68,0x74,0x29,0x7c,0x28,0x20,0x61,0x2e,0x79,0x3c,0x3c,0x6c,0x65,0x66,0x74,0x20,0x29,0x2c,0x0a,0x28,0x28,0x75,
|
||||
0x69,0x6e,0x74,0x29,0x61,0x2e,0x79,0x3e,0x3e,0x72,0x69,0x67,0x68,0x74,0x29,0x7c,0x28,0x20,0x61,0x2e,0x7a,0x3c,0x3c,0x6c,0x65,0x66,0x74,0x20,0x29,0x2c,0x0a,0x28,
|
||||
0x28,0x75,0x69,0x6e,0x74,0x29,0x61,0x2e,0x7a,0x3e,0x3e,0x72,0x69,0x67,0x68,0x74,0x29,0x7c,0x28,0x20,0x61,0x2e,0x77,0x3c,0x3c,0x6c,0x65,0x66,0x74,0x20,0x29,0x2c,
|
||||
0x0a,0x28,0x28,0x75,0x69,0x6e,0x74,0x29,0x61,0x2e,0x77,0x3e,0x3e,0x72,0x69,0x67,0x68,0x74,0x29,0x7c,0x28,0x20,0x61,0x2e,0x78,0x3c,0x3c,0x6c,0x65,0x66,0x74,0x20,
|
||||
0x29,0x0a,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x34,0x2a,0x20,0x73,0x63,0x72,0x61,0x74,
|
||||
0x63,0x68,0x70,0x61,0x64,0x5f,0x70,0x74,0x72,0x28,0x75,0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x2c,0x75,0x69,0x6e,0x74,0x20,0x6e,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,
|
||||
0x61,0x6c,0x20,0x69,0x6e,0x74,0x20,0x2a,0x6c,0x70,0x61,0x64,0x29,0x20,0x7b,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,
|
||||
0x20,0x69,0x6e,0x74,0x34,0x2a,0x29,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x68,0x61,0x72,0x2a,0x29,0x6c,0x70,0x61,0x64,0x2b,0x28,0x69,0x64,
|
||||
0x78,0x26,0x4d,0x41,0x53,0x4b,0x29,0x2b,0x6e,0x2a,0x31,0x36,0x29,0x3b,0x20,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,
|
||||
0x6d,0x61,0x5f,0x62,0x72,0x65,0x61,0x6b,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x29,0x0a,0x7b,0x0a,0x78,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x6e,0x64,0x5f,0x70,
|
||||
0x73,0x28,0x78,0x2c,0x30,0x78,0x46,0x45,0x46,0x46,0x46,0x46,0x46,0x46,0x29,0x3b,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x6d,0x6d,0x5f,0x6f,0x72,0x5f,0x70,
|
||||
0x73,0x28,0x78,0x2c,0x30,0x78,0x30,0x30,0x38,0x30,0x30,0x30,0x30,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x76,0x6f,0x69,0x64,0x20,0x73,
|
||||
0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x30,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x31,0x2c,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x20,0x6e,0x32,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x33,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x34,0x2a,0x20,0x6e,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x2a,0x20,0x64,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x2a,0x20,0x63,0x29,0x0a,0x7b,0x0a,0x6e,
|
||||
0x31,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x6e,0x31,0x2c,0x2a,0x63,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x6e,0x3d,0x5f,
|
||||
0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,0x6e,0x30,0x2c,0x2a,0x63,0x29,0x3b,0x0a,0x6e,0x6e,0x3d,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,
|
||||
0x6e,0x31,0x2c,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,0x6e,0x6e,0x2c,0x6e,0x6e,0x29,0x29,0x3b,0x0a,0x6e,0x6e,0x3d,0x66,0x6d,0x61,0x5f,0x62,0x72,
|
||||
0x65,0x61,0x6b,0x28,0x6e,0x6e,0x29,0x3b,0x0a,0x2a,0x6e,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x2a,0x6e,0x2c,0x6e,0x6e,0x29,0x3b,0x0a,0x6e,
|
||||
0x33,0x3d,0x5f,0x6d,0x6d,0x5f,0x73,0x75,0x62,0x5f,0x70,0x73,0x28,0x6e,0x33,0x2c,0x2a,0x63,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x64,0x64,0x3d,0x5f,
|
||||
0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,0x6e,0x32,0x2c,0x2a,0x63,0x29,0x3b,0x0a,0x64,0x64,0x3d,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,
|
||||
0x6e,0x33,0x2c,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,0x70,0x73,0x28,0x64,0x64,0x2c,0x64,0x64,0x29,0x29,0x3b,0x0a,0x64,0x64,0x3d,0x66,0x6d,0x61,0x5f,0x62,0x72,
|
||||
0x65,0x61,0x6b,0x28,0x64,0x64,0x29,0x3b,0x0a,0x2a,0x64,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x2a,0x64,0x2c,0x64,0x64,0x29,0x3b,0x0a,0x2a,
|
||||
0x63,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x2a,0x63,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x29,0x3b,0x0a,0x2a,0x63,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,
|
||||
0x64,0x64,0x5f,0x70,0x73,0x28,0x2a,0x63,0x2c,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x30,0x2e,0x37,0x33,0x34,0x33,0x37,0x35,0x66,0x29,0x29,0x3b,0x0a,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x72,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x6e,0x6e,0x2c,0x64,0x64,0x29,0x3b,0x0a,0x72,0x3d,0x5f,0x6d,0x6d,
|
||||
0x5f,0x61,0x6e,0x64,0x5f,0x70,0x73,0x28,0x72,0x2c,0x30,0x78,0x38,0x30,0x37,0x46,0x46,0x46,0x46,0x46,0x29,0x3b,0x0a,0x72,0x3d,0x5f,0x6d,0x6d,0x5f,0x6f,0x72,0x5f,
|
||||
0x70,0x73,0x28,0x72,0x2c,0x30,0x78,0x34,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x29,0x3b,0x0a,0x2a,0x63,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,
|
||||
0x2a,0x63,0x2c,0x72,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x76,0x6f,0x69,0x64,0x20,0x72,0x6f,0x75,0x6e,0x64,0x5f,0x63,0x6f,0x6d,0x70,0x75,
|
||||
0x74,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x30,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x31,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x32,
|
||||
0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x33,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x2a,0x20,
|
||||
0x63,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x2a,0x20,0x72,0x29,0x0a,0x7b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x3d,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,
|
||||
0x28,0x30,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x64,0x3d,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x30,0x2e,0x30,0x66,0x29,0x3b,
|
||||
0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x30,0x2c,0x6e,0x31,0x2c,0x6e,0x32,0x2c,0x6e,0x33,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x6e,0x2c,
|
||||
0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x31,0x2c,0x6e,0x32,0x2c,0x6e,0x33,0x2c,0x6e,0x30,0x2c,0x72,0x6e,0x64,
|
||||
0x5f,0x63,0x2c,0x26,0x6e,0x2c,0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x32,0x2c,0x6e,0x33,0x2c,0x6e,0x30,0x2c,
|
||||
0x6e,0x31,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x6e,0x2c,0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x33,0x2c,
|
||||
0x6e,0x30,0x2c,0x6e,0x31,0x2c,0x6e,0x32,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x6e,0x2c,0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,
|
||||
0x6e,0x64,0x28,0x6e,0x33,0x2c,0x6e,0x32,0x2c,0x6e,0x31,0x2c,0x6e,0x30,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x6e,0x2c,0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x73,
|
||||
0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x32,0x2c,0x6e,0x31,0x2c,0x6e,0x30,0x2c,0x6e,0x33,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x6e,0x2c,0x26,0x64,
|
||||
0x2c,0x63,0x29,0x3b,0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x31,0x2c,0x6e,0x30,0x2c,0x6e,0x33,0x2c,0x6e,0x32,0x2c,0x72,0x6e,0x64,0x5f,0x63,
|
||||
0x2c,0x26,0x6e,0x2c,0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x73,0x75,0x62,0x5f,0x72,0x6f,0x75,0x6e,0x64,0x28,0x6e,0x30,0x2c,0x6e,0x33,0x2c,0x6e,0x32,0x2c,0x6e,0x31,
|
||||
0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x6e,0x2c,0x26,0x64,0x2c,0x63,0x29,0x3b,0x0a,0x64,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x6e,0x64,0x5f,0x70,0x73,0x28,0x64,0x2c,
|
||||
0x30,0x78,0x46,0x46,0x37,0x46,0x46,0x46,0x46,0x46,0x29,0x3b,0x0a,0x64,0x3d,0x5f,0x6d,0x6d,0x5f,0x6f,0x72,0x5f,0x70,0x73,0x28,0x64,0x2c,0x30,0x78,0x34,0x30,0x30,
|
||||
0x30,0x30,0x30,0x30,0x30,0x29,0x3b,0x0a,0x2a,0x72,0x20,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x64,0x64,0x5f,0x70,0x73,0x28,0x2a,0x72,0x2c,0x5f,0x6d,0x6d,0x5f,0x64,0x69,
|
||||
0x76,0x5f,0x70,0x73,0x28,0x6e,0x2c,0x64,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x69,0x6e,0x74,0x34,0x20,0x73,0x69,0x6e,0x67,0x6c,0x65,
|
||||
0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x30,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x31,0x2c,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x20,0x6e,0x32,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x33,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x20,0x63,0x6e,0x74,0x2c,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x2a,0x20,0x73,0x75,0x6d,0x29,0x0a,0x7b,0x0a,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x3d,0x20,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x63,0x6e,0x74,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x72,
|
||||
0x3d,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x30,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,
|
||||
0x3c,0x34,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x7b,0x0a,0x72,0x6f,0x75,0x6e,0x64,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x28,0x6e,0x30,0x2c,0x6e,0x31,0x2c,0x6e,
|
||||
0x32,0x2c,0x6e,0x33,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x26,0x63,0x2c,0x26,0x72,0x29,0x3b,0x0a,0x7d,0x0a,0x72,0x3d,0x5f,0x6d,0x6d,0x5f,0x61,0x6e,0x64,0x5f,0x70,
|
||||
0x73,0x28,0x72,0x2c,0x30,0x78,0x38,0x30,0x37,0x46,0x46,0x46,0x46,0x46,0x29,0x3b,0x0a,0x72,0x3d,0x5f,0x6d,0x6d,0x5f,0x6f,0x72,0x5f,0x70,0x73,0x28,0x72,0x2c,0x30,
|
||||
0x78,0x34,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x29,0x3b,0x0a,0x2a,0x73,0x75,0x6d,0x3d,0x72,0x3b,0x20,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x78,0x3d,0x28,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x35,0x33,0x36,0x38,0x37,0x30,0x38,0x38,0x30,0x2e,0x30,0x66,0x29,0x3b,0x0a,0x72,0x3d,0x5f,0x6d,0x6d,0x5f,0x6d,0x75,0x6c,0x5f,
|
||||
0x70,0x73,0x28,0x72,0x2c,0x78,0x29,0x3b,0x20,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x63,0x6f,0x6e,0x76,0x65,0x72,0x74,0x5f,0x69,0x6e,0x74,0x34,0x5f,0x72,0x74,
|
||||
0x65,0x28,0x72,0x29,0x3b,0x0a,0x7d,0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x76,0x6f,0x69,0x64,0x20,0x73,0x69,0x6e,0x67,0x6c,0x65,0x5f,0x63,0x6f,0x6d,0x70,0x75,
|
||||
0x74,0x65,0x5f,0x77,0x72,0x61,0x70,0x28,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x72,0x6f,0x74,0x2c,0x69,0x6e,0x74,0x34,0x20,0x76,0x30,0x2c,0x69,
|
||||
0x6e,0x74,0x34,0x20,0x76,0x31,0x2c,0x69,0x6e,0x74,0x34,0x20,0x76,0x32,0x2c,0x69,0x6e,0x74,0x34,0x20,0x76,0x33,0x2c,0x66,0x6c,0x6f,0x61,0x74,0x20,0x63,0x6e,0x74,
|
||||
0x2c,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x2a,0x20,0x73,0x75,
|
||||
0x6d,0x2c,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x34,0x2a,0x20,0x6f,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x6e,0x30,
|
||||
0x3d,0x63,0x6f,0x6e,0x76,0x65,0x72,0x74,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x34,0x5f,0x72,0x74,0x65,0x28,0x76,0x30,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x6e,0x31,0x3d,0x63,0x6f,0x6e,0x76,0x65,0x72,0x74,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x34,0x5f,0x72,0x74,0x65,0x28,0x76,0x31,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,
|
||||
0x34,0x20,0x6e,0x32,0x3d,0x63,0x6f,0x6e,0x76,0x65,0x72,0x74,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x34,0x5f,0x72,0x74,0x65,0x28,0x76,0x32,0x29,0x3b,0x0a,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x34,0x20,0x6e,0x33,0x3d,0x63,0x6f,0x6e,0x76,0x65,0x72,0x74,0x5f,0x66,0x6c,0x6f,0x61,0x74,0x34,0x5f,0x72,0x74,0x65,0x28,0x76,0x33,0x29,0x3b,0x0a,0x69,
|
||||
0x6e,0x74,0x34,0x20,0x72,0x3d,0x73,0x69,0x6e,0x67,0x6c,0x65,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x28,0x6e,0x30,0x2c,0x6e,0x31,0x2c,0x6e,0x32,0x2c,0x6e,0x33,
|
||||
0x2c,0x63,0x6e,0x74,0x2c,0x72,0x6e,0x64,0x5f,0x63,0x2c,0x73,0x75,0x6d,0x29,0x3b,0x0a,0x2a,0x6f,0x75,0x74,0x3d,0x72,0x6f,0x74,0x3d,0x3d,0x30,0x3f,0x72,0x3a,0x5f,
|
||||
0x6d,0x6d,0x5f,0x61,0x6c,0x69,0x67,0x6e,0x72,0x5f,0x65,0x70,0x69,0x38,0x28,0x72,0x2c,0x72,0x6f,0x74,0x29,0x3b,0x0a,0x7d,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,
|
||||
0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x6c,0x6f,0x6f,0x6b,0x5b,0x31,0x36,0x5d,0x5b,0x34,
|
||||
0x5d,0x3d,0x7b,0x0a,0x7b,0x30,0x2c,0x31,0x2c,0x32,0x2c,0x33,0x7d,0x2c,0x0a,0x7b,0x30,0x2c,0x32,0x2c,0x33,0x2c,0x31,0x7d,0x2c,0x0a,0x7b,0x30,0x2c,0x33,0x2c,0x31,
|
||||
0x2c,0x32,0x7d,0x2c,0x0a,0x7b,0x30,0x2c,0x33,0x2c,0x32,0x2c,0x31,0x7d,0x2c,0x0a,0x7b,0x31,0x2c,0x30,0x2c,0x32,0x2c,0x33,0x7d,0x2c,0x0a,0x7b,0x31,0x2c,0x32,0x2c,
|
||||
0x33,0x2c,0x30,0x7d,0x2c,0x0a,0x7b,0x31,0x2c,0x33,0x2c,0x30,0x2c,0x32,0x7d,0x2c,0x0a,0x7b,0x31,0x2c,0x33,0x2c,0x32,0x2c,0x30,0x7d,0x2c,0x0a,0x7b,0x32,0x2c,0x31,
|
||||
0x2c,0x30,0x2c,0x33,0x7d,0x2c,0x0a,0x7b,0x32,0x2c,0x30,0x2c,0x33,0x2c,0x31,0x7d,0x2c,0x0a,0x7b,0x32,0x2c,0x33,0x2c,0x31,0x2c,0x30,0x7d,0x2c,0x0a,0x7b,0x32,0x2c,
|
||||
0x33,0x2c,0x30,0x2c,0x31,0x7d,0x2c,0x0a,0x7b,0x33,0x2c,0x31,0x2c,0x32,0x2c,0x30,0x7d,0x2c,0x0a,0x7b,0x33,0x2c,0x32,0x2c,0x30,0x2c,0x31,0x7d,0x2c,0x0a,0x7b,0x33,
|
||||
0x2c,0x30,0x2c,0x31,0x2c,0x32,0x7d,0x2c,0x0a,0x7b,0x33,0x2c,0x30,0x2c,0x32,0x2c,0x31,0x7d,0x0a,0x7d,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,
|
||||
0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x63,0x63,0x6e,0x74,0x5b,0x31,0x36,0x5d,0x3d,0x7b,0x0a,0x31,
|
||||
0x2e,0x33,0x34,0x33,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x32,0x38,0x31,0x32,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x33,0x35,0x39,0x33,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,
|
||||
0x33,0x36,0x37,0x31,0x38,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x34,0x32,0x39,0x36,0x38,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x33,0x39,0x38,0x34,0x33,0x37,0x35,0x66,
|
||||
0x2c,0x0a,0x31,0x2e,0x33,0x38,0x32,0x38,0x31,0x32,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x33,0x30,0x34,0x36,0x38,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x34,0x31,0x34,0x30,
|
||||
0x36,0x32,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x32,0x37,0x33,0x34,0x33,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x32,0x35,0x37,0x38,0x31,0x32,0x35,0x66,0x2c,0x0a,0x31,0x2e,
|
||||
0x32,0x38,0x39,0x30,0x36,0x32,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x33,0x32,0x30,0x33,0x31,0x32,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x33,0x35,0x31,0x35,0x36,0x32,0x35,0x66,
|
||||
0x2c,0x0a,0x31,0x2e,0x33,0x33,0x35,0x39,0x33,0x37,0x35,0x66,0x2c,0x0a,0x31,0x2e,0x34,0x36,0x30,0x39,0x33,0x37,0x35,0x66,0x0a,0x7d,0x3b,0x0a,0x73,0x74,0x72,0x75,
|
||||
0x63,0x74,0x20,0x53,0x68,0x61,0x72,0x65,0x64,0x4d,0x65,0x6d,0x43,0x68,0x75,0x6e,0x6b,0x0a,0x7b,0x0a,0x69,0x6e,0x74,0x34,0x20,0x6f,0x75,0x74,0x5b,0x31,0x36,0x5d,
|
||||
0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x76,0x61,0x5b,0x31,0x36,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,
|
||||
0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x73,0x69,0x7a,0x65,0x28,0x57,0x4f,0x52,0x4b,0x53,0x49,0x5a,0x45,
|
||||
0x2a,0x31,0x36,0x2c,0x31,0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x63,0x6e,0x31,0x28,0x5f,0x5f,0x67,
|
||||
0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x20,0x2a,0x6c,0x70,0x61,0x64,0x5f,0x69,0x6e,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x20,
|
||||
0x2a,0x73,0x70,0x61,0x64,0x2c,0x75,0x69,0x6e,0x74,0x20,0x6e,0x75,0x6d,0x54,0x68,0x72,0x65,0x61,0x64,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,
|
||||
0x69,0x6e,0x74,0x20,0x67,0x49,0x64,0x78,0x3d,0x67,0x65,0x74,0x49,0x64,0x78,0x28,0x29,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x20,0x63,0x68,0x75,0x6e,0x6b,0x3d,0x67,0x65,
|
||||
0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x2f,0x31,0x36,0x3b,0x0a,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x20,
|
||||
0x6c,0x70,0x61,0x64,0x3d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,
|
||||
0x68,0x61,0x72,0x2a,0x29,0x6c,0x70,0x61,0x64,0x5f,0x69,0x6e,0x2b,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x2a,0x28,0x67,0x49,0x64,0x78,0x2f,0x31,0x36,0x29,0x29,0x3b,0x0a,
|
||||
0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x68,0x61,0x72,0x65,0x64,0x4d,0x65,0x6d,0x43,0x68,0x75,0x6e,0x6b,0x20,0x73,0x6d,
|
||||
0x65,0x6d,0x5f,0x69,0x6e,0x5b,0x57,0x4f,0x52,0x4b,0x53,0x49,0x5a,0x45,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||
0x53,0x68,0x61,0x72,0x65,0x64,0x4d,0x65,0x6d,0x43,0x68,0x75,0x6e,0x6b,0x2a,0x20,0x73,0x6d,0x65,0x6d,0x3d,0x73,0x6d,0x65,0x6d,0x5f,0x69,0x6e,0x2b,0x63,0x68,0x75,
|
||||
0x6e,0x6b,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x20,0x74,0x69,0x64,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x20,0x25,0x20,0x31,
|
||||
0x36,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x20,0x69,0x64,0x78,0x48,0x61,0x73,0x68,0x3d,0x67,0x49,0x64,0x78,0x2f,0x31,0x36,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x20,0x73,0x3d,
|
||||
0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x2a,0x29,0x73,0x70,0x61,0x64,0x29,0x5b,0x69,0x64,0x78,0x48,0x61,0x73,0x68,0x2a,0x35,
|
||||
0x30,0x5d,0x3e,0x3e,0x38,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x76,0x73,0x3d,0x28,0x66,0x6c,0x6f,0x61,0x74,0x34,0x29,0x28,0x30,0x29,0x3b,0x0a,0x63,0x6f,
|
||||
0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x74,0x69,0x64,0x64,0x3d,0x74,0x69,0x64,0x2f,0x34,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,
|
||||
0x74,0x69,0x64,0x6d,0x3d,0x74,0x69,0x64,0x20,0x25,0x20,0x34,0x3b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x62,0x6c,0x6f,0x63,0x6b,0x3d,0x74,
|
||||
0x69,0x64,0x64,0x2a,0x31,0x36,0x2b,0x74,0x69,0x64,0x6d,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x43,0x4e,0x5f,0x55,
|
||||
0x4e,0x52,0x4f,0x4c,0x4c,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x49,0x54,0x45,0x52,0x41,0x54,0x49,0x4f,0x4e,
|
||||
0x53,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x20,0x7b,0x0a,0x6d,0x65,0x6d,0x5f,0x66,0x65,0x6e,0x63,0x65,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,
|
||||
0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x69,0x6e,0x74,0x20,0x74,0x6d,0x70,0x3d,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,
|
||||
0x2a,0x29,0x73,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x5f,0x70,0x74,0x72,0x28,0x73,0x2c,0x74,0x69,0x64,0x64,0x2c,0x6c,0x70,0x61,0x64,0x29,0x29,0x5b,0x74,
|
||||
0x69,0x64,0x6d,0x5d,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,
|
||||
0x29,0x5b,0x74,0x69,0x64,0x5d,0x3d,0x74,0x6d,0x70,0x3b,0x0a,0x6d,0x65,0x6d,0x5f,0x66,0x65,0x6e,0x63,0x65,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,
|
||||
0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x7b,0x0a,0x73,0x69,0x6e,0x67,0x6c,0x65,0x5f,0x63,0x6f,0x6d,0x70,0x75,0x74,0x65,0x5f,0x77,0x72,0x61,
|
||||
0x70,0x28,0x0a,0x74,0x69,0x64,0x6d,0x2c,0x0a,0x2a,0x28,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x2b,0x6c,0x6f,0x6f,0x6b,0x5b,0x74,0x69,0x64,0x5d,0x5b,0x30,
|
||||
0x5d,0x29,0x2c,0x0a,0x2a,0x28,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x2b,0x6c,0x6f,0x6f,0x6b,0x5b,0x74,0x69,0x64,0x5d,0x5b,0x31,0x5d,0x29,0x2c,0x0a,0x2a,
|
||||
0x28,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x2b,0x6c,0x6f,0x6f,0x6b,0x5b,0x74,0x69,0x64,0x5d,0x5b,0x32,0x5d,0x29,0x2c,0x0a,0x2a,0x28,0x73,0x6d,0x65,0x6d,
|
||||
0x2d,0x3e,0x6f,0x75,0x74,0x2b,0x6c,0x6f,0x6f,0x6b,0x5b,0x74,0x69,0x64,0x5d,0x5b,0x33,0x5d,0x29,0x2c,0x0a,0x63,0x63,0x6e,0x74,0x5b,0x74,0x69,0x64,0x5d,0x2c,0x76,
|
||||
0x73,0x2c,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x2b,0x74,0x69,0x64,0x2c,0x0a,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x2b,0x74,0x69,0x64,0x0a,0x29,0x3b,
|
||||
0x0a,0x7d,0x0a,0x6d,0x65,0x6d,0x5f,0x66,0x65,0x6e,0x63,0x65,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,
|
||||
0x29,0x3b,0x0a,0x69,0x6e,0x74,0x20,0x6f,0x75,0x74,0x58,0x6f,0x72,0x3d,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,
|
||||
0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x5d,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x20,0x64,0x64,0x3d,0x62,0x6c,0x6f,
|
||||
0x63,0x6b,0x2b,0x34,0x3b,0x20,0x64,0x64,0x3c,0x28,0x74,0x69,0x64,0x64,0x2b,0x31,0x29,0x2a,0x31,0x36,0x3b,0x20,0x64,0x64,0x2b,0x3d,0x34,0x29,0x20,0x7b,0x0a,0x6f,
|
||||
0x75,0x74,0x58,0x6f,0x72,0x20,0x5e,0x3d,0x20,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,
|
||||
0x74,0x29,0x5b,0x64,0x64,0x5d,0x3b,0x0a,0x7d,0x0a,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x63,0x72,0x61,0x74,0x63,
|
||||
0x68,0x70,0x61,0x64,0x5f,0x70,0x74,0x72,0x28,0x73,0x2c,0x74,0x69,0x64,0x64,0x2c,0x6c,0x70,0x61,0x64,0x29,0x29,0x5b,0x74,0x69,0x64,0x6d,0x5d,0x3d,0x6f,0x75,0x74,
|
||||
0x58,0x6f,0x72,0x5e,0x74,0x6d,0x70,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,
|
||||
0x74,0x29,0x5b,0x74,0x69,0x64,0x5d,0x3d,0x6f,0x75,0x74,0x58,0x6f,0x72,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x61,0x5f,0x74,0x6d,0x70,0x31,0x3d,0x28,0x28,
|
||||
0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x5d,0x2b,
|
||||
0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,
|
||||
0x2b,0x34,0x5d,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x76,0x61,0x5f,0x74,0x6d,0x70,0x32,0x3d,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,
|
||||
0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x2b,0x20,0x38,0x5d,0x2b,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,
|
||||
0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x2b,0x31,0x32,0x5d,0x3b,0x0a,0x28,0x28,
|
||||
0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x74,0x69,0x64,0x5d,0x3d,0x76,0x61,
|
||||
0x5f,0x74,0x6d,0x70,0x31,0x2b,0x76,0x61,0x5f,0x74,0x6d,0x70,0x32,0x3b,0x0a,0x6d,0x65,0x6d,0x5f,0x66,0x65,0x6e,0x63,0x65,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,
|
||||
0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x69,0x6e,0x74,0x20,0x6f,0x75,0x74,0x32,0x3d,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,
|
||||
0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,0x5b,0x74,0x69,0x64,0x5d,0x5e,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,
|
||||
0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,0x5b,0x74,0x69,0x64,0x2b,0x34,0x20,0x5d,0x5e,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,
|
||||
0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,0x5b,0x74,0x69,0x64,0x2b,0x38,0x5d,0x5e,0x28,0x28,0x5f,0x5f,0x6c,0x6f,
|
||||
0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,0x5b,0x74,0x69,0x64,0x2b,0x31,0x32,0x5d,0x3b,0x0a,0x76,0x61,0x5f,
|
||||
0x74,0x6d,0x70,0x31,0x3d,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,
|
||||
0x62,0x6c,0x6f,0x63,0x6b,0x5d,0x2b,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,
|
||||
0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x2b,0x34,0x5d,0x3b,0x0a,0x76,0x61,0x5f,0x74,0x6d,0x70,0x32,0x3d,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,
|
||||
0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x2b,0x38,0x5d,0x2b,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,
|
||||
0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x62,0x6c,0x6f,0x63,0x6b,0x2b,0x31,0x32,0x5d,0x3b,0x0a,0x76,0x61,
|
||||
0x5f,0x74,0x6d,0x70,0x31,0x3d,0x76,0x61,0x5f,0x74,0x6d,0x70,0x31,0x2b,0x76,0x61,0x5f,0x74,0x6d,0x70,0x32,0x3b,0x0a,0x76,0x61,0x5f,0x74,0x6d,0x70,0x31,0x3d,0x66,
|
||||
0x61,0x62,0x73,0x28,0x76,0x61,0x5f,0x74,0x6d,0x70,0x31,0x29,0x3b,0x0a,0x66,0x6c,0x6f,0x61,0x74,0x20,0x78,0x78,0x3d,0x76,0x61,0x5f,0x74,0x6d,0x70,0x31,0x2a,0x31,
|
||||
0x36,0x37,0x37,0x37,0x32,0x31,0x36,0x2e,0x30,0x66,0x3b,0x0a,0x69,0x6e,0x74,0x20,0x78,0x78,0x5f,0x69,0x6e,0x74,0x3d,0x28,0x69,0x6e,0x74,0x29,0x78,0x78,0x3b,0x0a,
|
||||
0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x29,0x5b,0x74,0x69,0x64,0x5d,0x3d,0x6f,
|
||||
0x75,0x74,0x32,0x5e,0x78,0x78,0x5f,0x69,0x6e,0x74,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x66,0x6c,0x6f,0x61,0x74,0x2a,0x29,0x73,0x6d,0x65,
|
||||
0x6d,0x2d,0x3e,0x76,0x61,0x29,0x5b,0x74,0x69,0x64,0x5d,0x3d,0x76,0x61,0x5f,0x74,0x6d,0x70,0x31,0x2f,0x36,0x34,0x2e,0x30,0x66,0x3b,0x0a,0x6d,0x65,0x6d,0x5f,0x66,
|
||||
0x65,0x6e,0x63,0x65,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x76,0x73,0x3d,0x73,0x6d,
|
||||
0x65,0x6d,0x2d,0x3e,0x76,0x61,0x5b,0x30,0x5d,0x3b,0x0a,0x73,0x3d,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x5b,0x30,0x5d,0x2e,0x78,0x5e,0x73,0x6d,0x65,0x6d,
|
||||
0x2d,0x3e,0x6f,0x75,0x74,0x5b,0x30,0x5d,0x2e,0x79,0x5e,0x73,0x6d,0x65,0x6d,0x2d,0x3e,0x6f,0x75,0x74,0x5b,0x30,0x5d,0x2e,0x7a,0x5e,0x73,0x6d,0x65,0x6d,0x2d,0x3e,
|
||||
0x6f,0x75,0x74,0x5b,0x30,0x5d,0x2e,0x77,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x63,0x6f,0x6e,0x73,0x74,0x20,0x5f,0x5f,0x63,0x6f,0x6e,
|
||||
0x73,0x74,0x61,0x6e,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x73,0x6b,0x69,0x70,0x5b,0x33,0x5d,0x3d,0x7b,0x0a,0x32,0x30,0x2c,0x32,0x32,0x2c,0x32,0x32,0x0a,0x7d,0x3b,
|
||||
0x0a,0x69,0x6e,0x6c,0x69,0x6e,0x65,0x20,0x76,0x6f,0x69,0x64,0x20,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x5f,0x35,0x31,0x32,0x28,0x75,0x69,0x6e,0x74,0x20,0x69,
|
||||
0x64,0x78,0x2c,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x2a,0x20,0x69,0x6e,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x6c,
|
||||
0x6f,0x6e,0x67,0x2a,0x20,0x6f,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x68,0x61,0x73,0x68,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x68,0x61,0x73,0x68,
|
||||
0x5b,0x30,0x5d,0x3d,0x69,0x6e,0x5b,0x30,0x5d,0x5e,0x69,0x64,0x78,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x31,0x3b,0x20,0x69,0x3c,0x32,
|
||||
0x35,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x7b,0x0a,0x68,0x61,0x73,0x68,0x5b,0x69,0x5d,0x3d,0x69,0x6e,0x5b,0x69,0x5d,0x3b,0x0a,0x7d,0x0a,0x66,0x6f,0x72,0x20,0x28,
|
||||
0x69,0x6e,0x74,0x20,0x61,0x3d,0x30,0x3b,0x20,0x61,0x3c,0x33,0x3b,0x20,0x2b,0x2b,0x61,0x29,0x20,0x7b,0x0a,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x31,0x36,0x30,0x30,
|
||||
0x5f,0x31,0x28,0x68,0x61,0x73,0x68,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x73,0x6b,0x69,0x70,0x5b,0x61,
|
||||
0x5d,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x7b,0x0a,0x6f,0x75,0x74,0x5b,0x69,0x5d,0x3d,0x68,0x61,0x73,0x68,0x5b,0x69,0x5d,0x3b,0x0a,0x7d,0x0a,0x6f,0x75,0x74,0x2b,
|
||||
0x3d,0x73,0x6b,0x69,0x70,0x5b,0x61,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,
|
||||
0x64,0x5f,0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,0x5f,0x73,0x69,0x7a,0x65,0x28,0x38,0x2c,0x38,0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,
|
||||
0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x63,0x6e,0x30,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x69,0x6e,0x70,
|
||||
0x75,0x74,0x2c,0x69,0x6e,0x74,0x20,0x69,0x6e,0x6c,0x65,0x6e,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x20,0x2a,0x53,0x63,0x72,0x61,0x74,
|
||||
0x63,0x68,0x70,0x61,0x64,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x73,0x74,0x61,0x74,0x65,0x73,0x2c,0x75,0x69,0x6e,
|
||||
0x74,0x20,0x54,0x68,0x72,0x65,0x61,0x64,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x49,0x64,0x78,0x3d,0x67,0x65,0x74,
|
||||
0x49,0x64,0x78,0x28,0x29,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x53,0x74,0x61,0x74,0x65,0x5f,0x62,0x75,0x66,0x5b,0x38,
|
||||
0x2a,0x32,0x35,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x2a,0x20,0x53,0x74,0x61,0x74,0x65,0x3d,0x53,0x74,0x61,0x74,0x65,
|
||||
0x5f,0x62,0x75,0x66,0x2b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x2a,0x32,0x35,0x3b,0x0a,0x7b,0x0a,0x73,0x74,0x61,0x74,0x65,
|
||||
0x73,0x2b,0x3d,0x32,0x35,0x2a,0x67,0x49,0x64,0x78,0x3b,0x0a,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x3d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,
|
||||
0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x63,0x68,0x61,0x72,0x2a,0x29,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,
|
||||
0x64,0x2b,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x2a,0x67,0x49,0x64,0x78,0x29,0x3b,0x0a,0x69,0x66,0x28,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,
|
||||
0x31,0x29,0x3d,0x3d,0x30,0x29,0x20,0x7b,0x0a,0x23,0x69,0x66,0x64,0x65,0x66,0x20,0x5f,0x5f,0x4e,0x56,0x5f,0x43,0x4c,0x5f,0x43,0x5f,0x56,0x45,0x52,0x53,0x49,0x4f,
|
||||
0x4e,0x0a,0x66,0x6f,0x72,0x28,0x75,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x38,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x0a,0x53,0x74,0x61,0x74,0x65,0x5b,
|
||||
0x69,0x5d,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5b,0x69,0x5d,0x3b,0x0a,0x23,0x65,0x6c,0x73,0x65,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,
|
||||
0x6e,0x67,0x38,0x20,0x2a,0x29,0x53,0x74,0x61,0x74,0x65,0x29,0x5b,0x30,0x5d,0x3d,0x76,0x6c,0x6f,0x61,0x64,0x38,0x28,0x30,0x2c,0x69,0x6e,0x70,0x75,0x74,0x29,0x3b,
|
||||
0x0a,0x23,0x65,0x6e,0x64,0x69,0x66,0x0a,0x53,0x74,0x61,0x74,0x65,0x5b,0x38,0x5d,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5b,0x38,0x5d,0x3b,0x0a,0x53,0x74,0x61,0x74,0x65,
|
||||
0x5b,0x39,0x5d,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5b,0x39,0x5d,0x3b,0x0a,0x53,0x74,0x61,0x74,0x65,0x5b,0x31,0x30,0x5d,0x3d,0x69,0x6e,0x70,0x75,0x74,0x5b,0x31,0x30,
|
||||
0x5d,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,0x53,0x74,0x61,0x74,0x65,0x29,0x5b,0x39,0x5d,0x20,0x26,0x3d,
|
||||
0x20,0x30,0x78,0x30,0x30,0x46,0x46,0x46,0x46,0x46,0x46,0x55,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,0x53,
|
||||
0x74,0x61,0x74,0x65,0x29,0x5b,0x39,0x5d,0x7c,0x3d,0x28,0x28,0x28,0x75,0x69,0x6e,0x74,0x29,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x28,
|
||||
0x30,0x29,0x29,0x26,0x30,0x78,0x46,0x46,0x29,0x3c,0x3c,0x32,0x34,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,
|
||||
0x53,0x74,0x61,0x74,0x65,0x29,0x5b,0x31,0x30,0x5d,0x20,0x26,0x3d,0x20,0x30,0x78,0x46,0x46,0x30,0x30,0x30,0x30,0x30,0x30,0x55,0x3b,0x0a,0x28,0x28,0x5f,0x5f,0x6c,
|
||||
0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,0x53,0x74,0x61,0x74,0x65,0x29,0x5b,0x31,0x30,0x5d,0x7c,0x3d,0x28,0x28,0x28,0x75,0x69,0x6e,0x74,0x29,
|
||||
0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3e,0x3e,0x38,0x29,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,
|
||||
0x69,0x3d,0x31,0x31,0x3b,0x20,0x69,0x3c,0x32,0x35,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x7b,0x0a,0x53,0x74,0x61,0x74,0x65,0x5b,0x69,0x5d,0x3d,0x30,0x78,0x30,0x30,
|
||||
0x55,0x4c,0x3b,0x0a,0x7d,0x0a,0x53,0x74,0x61,0x74,0x65,0x5b,0x31,0x36,0x5d,0x3d,0x30,0x78,0x38,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,
|
||||
0x30,0x30,0x55,0x4c,0x3b,0x0a,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x31,0x36,0x30,0x30,0x5f,0x32,0x28,0x53,0x74,0x61,0x74,0x65,0x29,0x3b,0x0a,0x23,0x70,0x72,0x61,
|
||||
0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x32,0x35,0x3b,0x20,0x2b,
|
||||
0x2b,0x69,0x29,0x20,0x7b,0x0a,0x73,0x74,0x61,0x74,0x65,0x73,0x5b,0x69,0x5d,0x3d,0x53,0x74,0x61,0x74,0x65,0x5b,0x69,0x5d,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x7d,0x0a,
|
||||
0x7d,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,
|
||||
0x5f,0x73,0x69,0x7a,0x65,0x28,0x36,0x34,0x2c,0x31,0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x63,0x6e,
|
||||
0x30,0x30,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x20,0x2a,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x2c,0x5f,0x5f,0x67,0x6c,
|
||||
0x6f,0x62,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x73,0x74,0x61,0x74,0x65,0x73,0x29,0x0a,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,
|
||||
0x20,0x67,0x49,0x64,0x78,0x3d,0x67,0x65,0x74,0x49,0x64,0x78,0x28,0x29,0x2f,0x36,0x34,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,
|
||||
0x20,0x53,0x74,0x61,0x74,0x65,0x5b,0x32,0x35,0x5d,0x3b,0x0a,0x73,0x74,0x61,0x74,0x65,0x73,0x2b,0x3d,0x32,0x35,0x2a,0x67,0x49,0x64,0x78,0x3b,0x0a,0x53,0x63,0x72,
|
||||
0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x3d,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x69,0x6e,0x74,0x2a,0x29,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,
|
||||
0x6c,0x20,0x63,0x68,0x61,0x72,0x2a,0x29,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x2b,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x2a,0x67,0x49,0x64,0x78,0x29,0x3b,
|
||||
0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x20,0x69,0x3c,0x32,
|
||||
0x35,0x3b,0x20,0x69,0x2b,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x28,0x30,0x29,0x29,0x20,0x7b,0x0a,0x53,0x74,0x61,0x74,0x65,
|
||||
0x5b,0x69,0x5d,0x3d,0x73,0x74,0x61,0x74,0x65,0x73,0x5b,0x69,0x5d,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,
|
||||
0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x75,0x69,0x6e,0x74,0x20,0x69,0x3d,0x67,0x65,0x74,0x5f,0x6c,
|
||||
0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x3b,0x20,0x69,0x3c,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x2f,0x35,0x31,0x32,0x3b,0x20,0x69,0x2b,0x3d,0x67,0x65,0x74,
|
||||
0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x73,0x69,0x7a,0x65,0x28,0x30,0x29,0x29,0x20,0x7b,0x0a,0x67,0x65,0x6e,0x65,0x72,0x61,0x74,0x65,0x5f,0x35,0x31,0x32,0x28,0x69,
|
||||
0x2c,0x53,0x74,0x61,0x74,0x65,0x2c,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x2a,0x29,0x28,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,
|
||||
0x61,0x6c,0x20,0x75,0x63,0x68,0x61,0x72,0x2a,0x29,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x2b,0x69,0x2a,0x35,0x31,0x32,0x29,0x29,0x3b,0x0a,0x7d,0x0a,
|
||||
0x7d,0x0a,0x5f,0x5f,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x5f,0x5f,0x28,0x28,0x72,0x65,0x71,0x64,0x5f,0x77,0x6f,0x72,0x6b,0x5f,0x67,0x72,0x6f,0x75,0x70,
|
||||
0x5f,0x73,0x69,0x7a,0x65,0x28,0x38,0x2c,0x38,0x2c,0x31,0x29,0x29,0x29,0x0a,0x5f,0x5f,0x6b,0x65,0x72,0x6e,0x65,0x6c,0x20,0x76,0x6f,0x69,0x64,0x20,0x63,0x6e,0x32,
|
||||
0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x34,0x20,0x2a,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x2c,0x5f,0x5f,0x67,0x6c,
|
||||
0x6f,0x62,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x73,0x74,0x61,0x74,0x65,0x73,0x2c,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,
|
||||
0x20,0x2a,0x6f,0x75,0x74,0x70,0x75,0x74,0x2c,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x54,0x61,0x72,0x67,0x65,0x74,0x2c,0x75,0x69,0x6e,0x74,0x20,0x54,0x68,0x72,0x65,0x61,
|
||||
0x64,0x73,0x29,0x0a,0x7b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x41,0x45,0x53,0x30,0x5b,0x32,0x35,0x36,0x5d,0x2c,0x41,0x45,0x53,
|
||||
0x31,0x5b,0x32,0x35,0x36,0x5d,0x2c,0x41,0x45,0x53,0x32,0x5b,0x32,0x35,0x36,0x5d,0x2c,0x41,0x45,0x53,0x33,0x5b,0x32,0x35,0x36,0x5d,0x3b,0x0a,0x75,0x69,0x6e,0x74,
|
||||
0x20,0x45,0x78,0x70,0x61,0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x5b,0x34,0x30,0x5d,0x3b,0x0a,0x75,0x69,0x6e,0x74,0x34,0x20,0x74,0x65,0x78,0x74,0x3b,0x0a,0x63,
|
||||
0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x49,0x64,0x78,0x3d,0x67,0x65,0x74,0x49,0x64,0x78,0x28,0x29,0x3b,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,
|
||||
0x74,0x20,0x69,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x2a,0x38,0x2b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,
|
||||
0x69,0x64,0x28,0x30,0x29,0x3b,0x20,0x69,0x3c,0x32,0x35,0x36,0x3b,0x20,0x69,0x2b,0x3d,0x38,0x2a,0x38,0x29,0x20,0x7b,0x0a,0x63,0x6f,0x6e,0x73,0x74,0x20,0x75,0x69,
|
||||
0x6e,0x74,0x20,0x74,0x6d,0x70,0x3d,0x41,0x45,0x53,0x30,0x5f,0x43,0x5b,0x69,0x5d,0x3b,0x0a,0x41,0x45,0x53,0x30,0x5b,0x69,0x5d,0x3d,0x74,0x6d,0x70,0x3b,0x0a,0x41,
|
||||
0x45,0x53,0x31,0x5b,0x69,0x5d,0x3d,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x74,0x6d,0x70,0x2c,0x38,0x55,0x29,0x3b,0x0a,0x41,0x45,0x53,0x32,0x5b,0x69,0x5d,0x3d,0x72,
|
||||
0x6f,0x74,0x61,0x74,0x65,0x28,0x74,0x6d,0x70,0x2c,0x31,0x36,0x55,0x29,0x3b,0x0a,0x41,0x45,0x53,0x33,0x5b,0x69,0x5d,0x3d,0x72,0x6f,0x74,0x61,0x74,0x65,0x28,0x74,
|
||||
0x6d,0x70,0x2c,0x32,0x34,0x55,0x29,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,
|
||||
0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x34,0x20,0x78,0x69,0x6e,0x31,0x5b,0x38,0x5d,0x5b,0x38,
|
||||
0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x34,0x20,0x78,0x69,0x6e,0x32,0x5b,0x38,0x5d,0x5b,0x38,0x5d,0x3b,0x0a,0x7b,0x0a,0x73,
|
||||
0x74,0x61,0x74,0x65,0x73,0x2b,0x3d,0x32,0x35,0x2a,0x67,0x49,0x64,0x78,0x3b,0x0a,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x2b,0x3d,0x67,0x49,0x64,0x78,
|
||||
0x2a,0x28,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x3e,0x3e,0x34,0x29,0x3b,0x0a,0x23,0x69,0x66,0x20,0x64,0x65,0x66,0x69,0x6e,0x65,0x64,0x28,0x5f,0x5f,0x54,0x61,0x68,0x69,
|
||||
0x74,0x69,0x5f,0x5f,0x29,0x20,0x7c,0x7c,0x20,0x64,0x65,0x66,0x69,0x6e,0x65,0x64,0x28,0x5f,0x5f,0x50,0x69,0x74,0x63,0x61,0x69,0x72,0x6e,0x5f,0x5f,0x29,0x0a,0x66,
|
||||
0x6f,0x72,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x34,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x28,0x28,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x2a,0x29,
|
||||
0x45,0x78,0x70,0x61,0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x29,0x5b,0x69,0x5d,0x3d,0x73,0x74,0x61,0x74,0x65,0x73,0x5b,0x69,0x2b,0x34,0x5d,0x3b,0x0a,0x74,0x65,
|
||||
0x78,0x74,0x3d,0x76,0x6c,0x6f,0x61,0x64,0x34,0x28,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x2b,0x34,0x2c,0x28,0x5f,0x5f,0x67,
|
||||
0x6c,0x6f,0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,0x73,0x74,0x61,0x74,0x65,0x73,0x29,0x3b,0x0a,0x23,0x65,0x6c,0x73,0x65,0x0a,0x74,0x65,0x78,0x74,
|
||||
0x3d,0x76,0x6c,0x6f,0x61,0x64,0x34,0x28,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x2b,0x34,0x2c,0x28,0x5f,0x5f,0x67,0x6c,0x6f,
|
||||
0x62,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,0x73,0x74,0x61,0x74,0x65,0x73,0x29,0x3b,0x0a,0x28,0x28,0x75,0x69,0x6e,0x74,0x38,0x20,0x2a,0x29,0x45,0x78,
|
||||
0x70,0x61,0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x29,0x5b,0x30,0x5d,0x3d,0x76,0x6c,0x6f,0x61,0x64,0x38,0x28,0x31,0x2c,0x28,0x5f,0x5f,0x67,0x6c,0x6f,0x62,0x61,
|
||||
0x6c,0x20,0x75,0x69,0x6e,0x74,0x20,0x2a,0x29,0x73,0x74,0x61,0x74,0x65,0x73,0x29,0x3b,0x0a,0x23,0x65,0x6e,0x64,0x69,0x66,0x0a,0x41,0x45,0x53,0x45,0x78,0x70,0x61,
|
||||
0x6e,0x64,0x4b,0x65,0x79,0x32,0x35,0x36,0x28,0x45,0x78,0x70,0x61,0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x29,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,
|
||||
0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,
|
||||
0x75,0x69,0x6e,0x74,0x34,0x2a,0x20,0x78,0x69,0x6e,0x31,0x5f,0x73,0x74,0x6f,0x72,0x65,0x3d,0x26,0x78,0x69,0x6e,0x31,0x5b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,
|
||||
0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x5d,0x5b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,
|
||||
0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x34,0x2a,0x20,0x78,0x69,0x6e,0x31,0x5f,0x6c,0x6f,0x61,0x64,0x3d,0x26,0x78,0x69,0x6e,0x31,0x5b,0x28,0x67,0x65,0x74,0x5f,0x6c,
|
||||
0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x2b,0x31,0x29,0x20,0x25,0x20,0x38,0x5d,0x5b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,
|
||||
0x30,0x29,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x34,0x2a,0x20,0x78,0x69,0x6e,0x32,0x5f,0x73,0x74,0x6f,0x72,0x65,0x3d,0x26,
|
||||
0x78,0x69,0x6e,0x32,0x5b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x5d,0x5b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,
|
||||
0x69,0x64,0x28,0x30,0x29,0x5d,0x3b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x69,0x6e,0x74,0x34,0x2a,0x20,0x78,0x69,0x6e,0x32,0x5f,0x6c,0x6f,0x61,0x64,
|
||||
0x3d,0x26,0x78,0x69,0x6e,0x32,0x5b,0x28,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x2b,0x31,0x29,0x20,0x25,0x20,0x38,0x5d,0x5b,
|
||||
0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x5d,0x3b,0x0a,0x2a,0x78,0x69,0x6e,0x32,0x5f,0x73,0x74,0x6f,0x72,0x65,0x3d,0x28,0x75,
|
||||
0x69,0x6e,0x74,0x34,0x29,0x28,0x30,0x2c,0x30,0x2c,0x30,0x2c,0x30,0x29,0x3b,0x0a,0x7b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,
|
||||
0x20,0x32,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,0x30,0x2c,0x69,0x31,0x3d,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,
|
||||
0x31,0x29,0x3b,0x20,0x69,0x3c,0x28,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x3e,0x3e,0x37,0x29,0x3b,0x20,0x2b,0x2b,0x69,0x2c,0x69,0x31,0x3d,0x28,0x69,0x31,0x2b,0x31,0x36,
|
||||
0x29,0x20,0x25,0x20,0x28,0x4d,0x45,0x4d,0x4f,0x52,0x59,0x3e,0x3e,0x34,0x29,0x29,0x20,0x7b,0x0a,0x74,0x65,0x78,0x74,0x20,0x5e,0x3d,0x20,0x53,0x63,0x72,0x61,0x74,
|
||||
0x63,0x68,0x70,0x61,0x64,0x5b,0x28,0x75,0x69,0x6e,0x74,0x29,0x69,0x31,0x5d,0x3b,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,
|
||||
0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x74,0x65,0x78,0x74,0x20,0x5e,0x3d,0x20,0x2a,0x78,0x69,0x6e,0x32,0x5f,0x6c,0x6f,0x61,
|
||||
0x64,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x30,0x0a,0x66,0x6f,0x72,0x28,0x69,0x6e,0x74,0x20,0x6a,0x3d,0x30,
|
||||
0x3b,0x20,0x6a,0x3c,0x31,0x30,0x3b,0x20,0x2b,0x2b,0x6a,0x29,0x0a,0x74,0x65,0x78,0x74,0x3d,0x41,0x45,0x53,0x5f,0x52,0x6f,0x75,0x6e,0x64,0x28,0x41,0x45,0x53,0x30,
|
||||
0x2c,0x41,0x45,0x53,0x31,0x2c,0x41,0x45,0x53,0x32,0x2c,0x41,0x45,0x53,0x33,0x2c,0x74,0x65,0x78,0x74,0x2c,0x28,0x28,0x75,0x69,0x6e,0x74,0x34,0x20,0x2a,0x29,0x45,
|
||||
0x78,0x70,0x61,0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x29,0x5b,0x6a,0x5d,0x29,0x3b,0x0a,0x2a,0x78,0x69,0x6e,0x31,0x5f,0x73,0x74,0x6f,0x72,0x65,0x3d,0x74,0x65,
|
||||
0x78,0x74,0x3b,0x0a,0x74,0x65,0x78,0x74,0x20,0x5e,0x3d,0x20,0x53,0x63,0x72,0x61,0x74,0x63,0x68,0x70,0x61,0x64,0x5b,0x28,0x75,0x69,0x6e,0x74,0x29,0x69,0x31,0x2b,
|
||||
0x38,0x75,0x5d,0x3b,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,
|
||||
0x29,0x3b,0x0a,0x74,0x65,0x78,0x74,0x20,0x5e,0x3d,0x20,0x2a,0x78,0x69,0x6e,0x31,0x5f,0x6c,0x6f,0x61,0x64,0x3b,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,
|
||||
0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x30,0x0a,0x66,0x6f,0x72,0x28,0x69,0x6e,0x74,0x20,0x6a,0x3d,0x30,0x3b,0x20,0x6a,0x3c,0x31,0x30,0x3b,0x20,0x2b,0x2b,0x6a,0x29,
|
||||
0x0a,0x74,0x65,0x78,0x74,0x3d,0x41,0x45,0x53,0x5f,0x52,0x6f,0x75,0x6e,0x64,0x28,0x41,0x45,0x53,0x30,0x2c,0x41,0x45,0x53,0x31,0x2c,0x41,0x45,0x53,0x32,0x2c,0x41,
|
||||
0x45,0x53,0x33,0x2c,0x74,0x65,0x78,0x74,0x2c,0x28,0x28,0x75,0x69,0x6e,0x74,0x34,0x20,0x2a,0x29,0x45,0x78,0x70,0x61,0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x29,
|
||||
0x5b,0x6a,0x5d,0x29,0x3b,0x0a,0x2a,0x78,0x69,0x6e,0x32,0x5f,0x73,0x74,0x6f,0x72,0x65,0x3d,0x74,0x65,0x78,0x74,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,
|
||||
0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x74,0x65,0x78,0x74,0x20,0x5e,0x3d,0x20,
|
||||
0x2a,0x78,0x69,0x6e,0x32,0x5f,0x6c,0x6f,0x61,0x64,0x3b,0x0a,0x7d,0x0a,0x23,0x70,0x72,0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x36,0x0a,
|
||||
0x66,0x6f,0x72,0x28,0x73,0x69,0x7a,0x65,0x5f,0x74,0x20,0x69,0x3d,0x30,0x3b,0x20,0x69,0x3c,0x31,0x36,0x3b,0x20,0x69,0x2b,0x2b,0x29,0x0a,0x7b,0x0a,0x23,0x70,0x72,
|
||||
0x61,0x67,0x6d,0x61,0x20,0x75,0x6e,0x72,0x6f,0x6c,0x6c,0x20,0x31,0x30,0x0a,0x66,0x6f,0x72,0x20,0x28,0x69,0x6e,0x74,0x20,0x6a,0x3d,0x30,0x3b,0x20,0x6a,0x3c,0x31,
|
||||
0x30,0x3b,0x20,0x2b,0x2b,0x6a,0x29,0x20,0x7b,0x0a,0x74,0x65,0x78,0x74,0x3d,0x41,0x45,0x53,0x5f,0x52,0x6f,0x75,0x6e,0x64,0x28,0x41,0x45,0x53,0x30,0x2c,0x41,0x45,
|
||||
0x53,0x31,0x2c,0x41,0x45,0x53,0x32,0x2c,0x41,0x45,0x53,0x33,0x2c,0x74,0x65,0x78,0x74,0x2c,0x28,0x28,0x75,0x69,0x6e,0x74,0x34,0x20,0x2a,0x29,0x45,0x78,0x70,0x61,
|
||||
0x6e,0x64,0x65,0x64,0x4b,0x65,0x79,0x32,0x29,0x5b,0x6a,0x5d,0x29,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,
|
||||
0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x2a,0x78,0x69,0x6e,0x31,0x5f,0x73,0x74,0x6f,0x72,0x65,0x3d,0x74,0x65,0x78,0x74,0x3b,
|
||||
0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x4c,0x4f,0x43,0x41,0x4c,0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x74,
|
||||
0x65,0x78,0x74,0x20,0x5e,0x3d,0x20,0x2a,0x78,0x69,0x6e,0x31,0x5f,0x6c,0x6f,0x61,0x64,0x3b,0x0a,0x7d,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,
|
||||
0x6e,0x67,0x20,0x53,0x74,0x61,0x74,0x65,0x5f,0x62,0x75,0x66,0x5b,0x38,0x2a,0x32,0x35,0x5d,0x3b,0x0a,0x7b,0x0a,0x76,0x73,0x74,0x6f,0x72,0x65,0x32,0x28,0x61,0x73,
|
||||
0x5f,0x75,0x6c,0x6f,0x6e,0x67,0x32,0x28,0x74,0x65,0x78,0x74,0x29,0x2c,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x2b,0x34,0x2c,
|
||||
0x73,0x74,0x61,0x74,0x65,0x73,0x29,0x3b,0x0a,0x7d,0x0a,0x62,0x61,0x72,0x72,0x69,0x65,0x72,0x28,0x43,0x4c,0x4b,0x5f,0x47,0x4c,0x4f,0x42,0x41,0x4c,0x5f,0x4d,0x45,
|
||||
0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x7b,0x0a,0x69,0x66,0x28,0x21,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x31,0x29,0x29,
|
||||
0x0a,0x7b,0x0a,0x5f,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x20,0x75,0x6c,0x6f,0x6e,0x67,0x2a,0x20,0x53,0x74,0x61,0x74,0x65,0x3d,0x53,0x74,0x61,0x74,0x65,0x5f,0x62,0x75,
|
||||
0x66,0x2b,0x67,0x65,0x74,0x5f,0x6c,0x6f,0x63,0x61,0x6c,0x5f,0x69,0x64,0x28,0x30,0x29,0x2a,0x32,0x35,0x3b,0x0a,0x66,0x6f,0x72,0x28,0x69,0x6e,0x74,0x20,0x69,0x3d,
|
||||
0x30,0x3b,0x20,0x69,0x3c,0x32,0x35,0x3b,0x20,0x2b,0x2b,0x69,0x29,0x20,0x53,0x74,0x61,0x74,0x65,0x5b,0x69,0x5d,0x3d,0x73,0x74,0x61,0x74,0x65,0x73,0x5b,0x69,0x5d,
|
||||
0x3b,0x0a,0x6b,0x65,0x63,0x63,0x61,0x6b,0x66,0x31,0x36,0x30,0x30,0x5f,0x32,0x28,0x53,0x74,0x61,0x74,0x65,0x29,0x3b,0x0a,0x69,0x66,0x28,0x53,0x74,0x61,0x74,0x65,
|
||||
0x5b,0x33,0x5d,0x3c,0x3d,0x54,0x61,0x72,0x67,0x65,0x74,0x29,0x0a,0x7b,0x0a,0x75,0x6c,0x6f,0x6e,0x67,0x20,0x6f,0x75,0x74,0x49,0x64,0x78,0x3d,0x61,0x74,0x6f,0x6d,
|
||||
0x69,0x63,0x5f,0x69,0x6e,0x63,0x28,0x6f,0x75,0x74,0x70,0x75,0x74,0x2b,0x30,0x78,0x46,0x46,0x29,0x3b,0x0a,0x69,0x66,0x28,0x6f,0x75,0x74,0x49,0x64,0x78,0x3c,0x30,
|
||||
0x78,0x46,0x46,0x29,0x0a,0x6f,0x75,0x74,0x70,0x75,0x74,0x5b,0x6f,0x75,0x74,0x49,0x64,0x78,0x5d,0x3d,0x67,0x65,0x74,0x5f,0x67,0x6c,0x6f,0x62,0x61,0x6c,0x5f,0x69,
|
||||
0x64,0x28,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x7d,0x0a,0x7d,0x0a,0x6d,0x65,0x6d,0x5f,0x66,0x65,0x6e,0x63,0x65,0x28,0x43,0x4c,0x4b,0x5f,0x47,0x4c,0x4f,0x42,0x41,0x4c,
|
||||
0x5f,0x4d,0x45,0x4d,0x5f,0x46,0x45,0x4e,0x43,0x45,0x29,0x3b,0x0a,0x7d,0x0a,0x00
|
||||
};
|
||||
|
||||
} // namespace xmrig
|
|
@ -4,7 +4,7 @@
|
|||
#include "randomx_constants_monero.h"
|
||||
#elif (ALGO == ALGO_RX_WOW)
|
||||
#include "randomx_constants_wow.h"
|
||||
#elif (ALGO == ALGO_RX_ARQMA)
|
||||
#elif (ALGO == ALGO_RX_ARQ)
|
||||
#include "randomx_constants_arqma.h"
|
||||
#elif (ALGO == ALGO_RX_KEVA)
|
||||
#include "randomx_constants_keva.h"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,87 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/OclThreads.h"
|
||||
#include "backend/opencl/wrappers/OclDevice.h"
|
||||
#include "base/crypto/Algorithm.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
constexpr const size_t oneMiB = 1024u * 1024u;
|
||||
|
||||
|
||||
|
||||
bool ocl_generic_cn_gpu_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads)
|
||||
{
|
||||
if (algorithm != Algorithm::CN_GPU) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t worksize = 8;
|
||||
uint32_t numThreads = 1u;
|
||||
size_t minFreeMem = 128u * oneMiB;
|
||||
|
||||
if (device.type() == OclDevice::Vega_10 || device.type() == OclDevice::Vega_20) {
|
||||
minFreeMem = oneMiB;
|
||||
worksize = 16;
|
||||
}
|
||||
else if (device.type() == OclDevice::Navi_10) {
|
||||
numThreads = 2u;
|
||||
}
|
||||
else if (device.name() == "Fiji") {
|
||||
worksize = 16;
|
||||
}
|
||||
|
||||
size_t maxThreads = device.computeUnits() * 6 * 8;
|
||||
|
||||
const size_t maxAvailableFreeMem = device.freeMemSize() - minFreeMem;
|
||||
const size_t memPerThread = std::min(device.maxMemAllocSize(), maxAvailableFreeMem);
|
||||
|
||||
size_t memPerHash = algorithm.l3() + 240u;
|
||||
size_t maxIntensity = memPerThread / memPerHash;
|
||||
size_t possibleIntensity = std::min(maxThreads, maxIntensity);
|
||||
size_t intensity = 0;
|
||||
size_t cuUtilization = ((possibleIntensity * 100) / (worksize * device.computeUnits())) % 100;
|
||||
|
||||
if (cuUtilization >= 75) {
|
||||
intensity = (possibleIntensity / worksize) * worksize;
|
||||
}
|
||||
else {
|
||||
intensity = (possibleIntensity / (worksize * device.computeUnits())) * device.computeUnits() * worksize;
|
||||
}
|
||||
|
||||
threads.add(OclThread(device.index(), intensity, worksize, numThreads, 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
44
src/backend/opencl/kernels/Cn00RyoKernel.cpp
Normal file
44
src/backend/opencl/kernels/Cn00RyoKernel.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/Cn00RyoKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::Cn00RyoKernel::enqueue(cl_command_queue queue, size_t threads)
|
||||
{
|
||||
const size_t gthreads = threads * 64;
|
||||
const size_t lthreads = 64;
|
||||
|
||||
enqueueNDRange(queue, 1, nullptr, >hreads, <hreads);
|
||||
}
|
||||
|
||||
|
||||
// __kernel void cn00(__global int *Scratchpad, __global ulong *states)
|
||||
void xmrig::Cn00RyoKernel::setArgs(cl_mem scratchpads, cl_mem states)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||
setArg(1, sizeof(cl_mem), &states);
|
||||
}
|
48
src/backend/opencl/kernels/Cn00RyoKernel.h
Normal file
48
src/backend/opencl/kernels/Cn00RyoKernel.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CN00RYOKERNEL_H
|
||||
#define XMRIG_CN00RYOKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Cn00RyoKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline Cn00RyoKernel(cl_program program) : OclKernel(program, "cn00") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads);
|
||||
void setArgs(cl_mem scratchpads, cl_mem states);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_CN00RYOKERNEL_H */
|
48
src/backend/opencl/kernels/Cn1RyoKernel.cpp
Normal file
48
src/backend/opencl/kernels/Cn1RyoKernel.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/Cn1RyoKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::Cn1RyoKernel::enqueue(cl_command_queue queue, size_t threads, size_t worksize)
|
||||
{
|
||||
const size_t gthreads = threads * 16;
|
||||
const size_t lthreads = worksize * 16;
|
||||
|
||||
enqueueNDRange(queue, 1, nullptr, >hreads, <hreads);
|
||||
}
|
||||
|
||||
|
||||
// __kernel void cn1(__global int *lpad_in, __global int *spad, uint numThreads)
|
||||
void xmrig::Cn1RyoKernel::setArgs(cl_mem scratchpads, cl_mem states, uint32_t threads)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||
setArg(1, sizeof(cl_mem), &states);
|
||||
setArg(2, sizeof(uint32_t), &threads);
|
||||
}
|
48
src/backend/opencl/kernels/Cn1RyoKernel.h
Normal file
48
src/backend/opencl/kernels/Cn1RyoKernel.h
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CN1RYOKERNEL_H
|
||||
#define XMRIG_CN1RYOKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Cn1RyoKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline Cn1RyoKernel(cl_program program) : OclKernel(program, "cn1") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, size_t threads, size_t worksize);
|
||||
void setArgs(cl_mem scratchpads, cl_mem states, uint32_t threads);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_CN1RYOKERNEL_H */
|
53
src/backend/opencl/kernels/Cn2RyoKernel.cpp
Normal file
53
src/backend/opencl/kernels/Cn2RyoKernel.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/kernels/Cn2RyoKernel.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
|
||||
|
||||
void xmrig::Cn2RyoKernel::enqueue(cl_command_queue queue, uint32_t nonce, size_t threads)
|
||||
{
|
||||
const size_t offset[2] = { nonce, 1 };
|
||||
const size_t gthreads[2] = { threads, 8 };
|
||||
static const size_t lthreads[2] = { 8, 8 };
|
||||
|
||||
enqueueNDRange(queue, 2, offset, gthreads, lthreads);
|
||||
}
|
||||
|
||||
|
||||
// __kernel void cn2(__global uint4 *Scratchpad, __global ulong *states, __global uint *output, ulong Target, uint Threads)
|
||||
void xmrig::Cn2RyoKernel::setArgs(cl_mem scratchpads, cl_mem states, cl_mem output, uint32_t threads)
|
||||
{
|
||||
setArg(0, sizeof(cl_mem), &scratchpads);
|
||||
setArg(1, sizeof(cl_mem), &states);
|
||||
setArg(2, sizeof(cl_mem), &output);
|
||||
setArg(4, sizeof(uint32_t), &threads);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Cn2RyoKernel::setTarget(uint64_t target)
|
||||
{
|
||||
setArg(3, sizeof(cl_ulong), &target);
|
||||
}
|
49
src/backend/opencl/kernels/Cn2RyoKernel.h
Normal file
49
src/backend/opencl/kernels/Cn2RyoKernel.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_CN2RYOKERNEL_H
|
||||
#define XMRIG_CN2RYOKERNEL_H
|
||||
|
||||
|
||||
#include "backend/opencl/wrappers/OclKernel.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Cn2RyoKernel : public OclKernel
|
||||
{
|
||||
public:
|
||||
inline Cn2RyoKernel(cl_program program) : OclKernel(program, "cn2") {}
|
||||
|
||||
void enqueue(cl_command_queue queue, uint32_t nonce, size_t threads);
|
||||
void setArgs(cl_mem scratchpads, cl_mem states, cl_mem output, uint32_t threads);
|
||||
void setTarget(uint64_t target);
|
||||
};
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
#endif /* XMRIG_CN2RYOKERNEL_H */
|
|
@ -146,6 +146,23 @@ if (WITH_OPENCL)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (WITH_CN_GPU AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND HEADERS_BACKEND_OPENCL
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.h
|
||||
src/backend/opencl/kernels/Cn1RyoKernel.h
|
||||
src/backend/opencl/kernels/Cn2RyoKernel.h
|
||||
src/backend/opencl/runners/OclRyoRunner.h
|
||||
)
|
||||
|
||||
list(APPEND SOURCES_BACKEND_OPENCL
|
||||
src/backend/opencl/generators/ocl_generic_cn_gpu_generator.cpp
|
||||
src/backend/opencl/kernels/Cn00RyoKernel.cpp
|
||||
src/backend/opencl/kernels/Cn1RyoKernel.cpp
|
||||
src/backend/opencl/kernels/Cn2RyoKernel.cpp
|
||||
src/backend/opencl/runners/OclRyoRunner.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_STRICT_CACHE)
|
||||
add_definitions(/DXMRIG_STRICT_OPENCL_CACHE)
|
||||
else()
|
||||
|
|
128
src/backend/opencl/runners/OclRyoRunner.cpp
Normal file
128
src/backend/opencl/runners/OclRyoRunner.cpp
Normal file
|
@ -0,0 +1,128 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "backend/opencl/runners/OclRyoRunner.h"
|
||||
#include "backend/opencl/kernels/Cn00RyoKernel.h"
|
||||
#include "backend/opencl/kernels/Cn0Kernel.h"
|
||||
#include "backend/opencl/kernels/Cn1RyoKernel.h"
|
||||
#include "backend/opencl/kernels/Cn2RyoKernel.h"
|
||||
#include "backend/opencl/kernels/CnBranchKernel.h"
|
||||
#include "backend/opencl/OclLaunchData.h"
|
||||
#include "backend/opencl/wrappers/OclLib.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "crypto/cn/CnAlgo.h"
|
||||
|
||||
|
||||
xmrig::OclRyoRunner::OclRyoRunner(size_t index, const OclLaunchData &data) : OclBaseRunner(index, data)
|
||||
{
|
||||
m_options += " -DITERATIONS=" + std::to_string(CnAlgo<>::iterations(m_algorithm)) + "U";
|
||||
m_options += " -DMASK=" + std::to_string(CnAlgo<>::mask(m_algorithm)) + "U";
|
||||
m_options += " -DWORKSIZE=" + std::to_string(data.thread.worksize()) + "U";
|
||||
m_options += " -DMEMORY=" + std::to_string(m_algorithm.l3()) + "LU";
|
||||
m_options += " -DCN_UNROLL=" + std::to_string(data.thread.unrollFactor());
|
||||
|
||||
m_options += " -cl-fp32-correctly-rounded-divide-sqrt";
|
||||
}
|
||||
|
||||
|
||||
xmrig::OclRyoRunner::~OclRyoRunner()
|
||||
{
|
||||
delete m_cn00;
|
||||
delete m_cn0;
|
||||
delete m_cn1;
|
||||
delete m_cn2;
|
||||
|
||||
OclLib::release(m_scratchpads);
|
||||
OclLib::release(m_states);
|
||||
}
|
||||
|
||||
|
||||
size_t xmrig::OclRyoRunner::bufferSize() const
|
||||
{
|
||||
return OclBaseRunner::bufferSize() + align(data().algorithm.l3() * m_intensity) + align(200 * m_intensity);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclRyoRunner::run(uint32_t nonce, uint32_t *hashOutput)
|
||||
{
|
||||
static const cl_uint zero = 0;
|
||||
|
||||
const size_t w_size = data().thread.worksize();
|
||||
const size_t g_thd = ((m_intensity + w_size - 1u) / w_size) * w_size;
|
||||
|
||||
assert(g_thd % w_size == 0);
|
||||
|
||||
enqueueWriteBuffer(m_output, CL_FALSE, sizeof(cl_uint) * 0xFF, sizeof(cl_uint), &zero);
|
||||
|
||||
m_cn0->enqueue(m_queue, nonce, g_thd);
|
||||
m_cn00->enqueue(m_queue, g_thd);
|
||||
m_cn1->enqueue(m_queue, g_thd, w_size);
|
||||
m_cn2->enqueue(m_queue, nonce, g_thd);
|
||||
|
||||
finalize(hashOutput);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclRyoRunner::set(const Job &job, uint8_t *blob)
|
||||
{
|
||||
if (job.size() > (Job::kMaxBlobSize - 4)) {
|
||||
throw std::length_error("job size too big");
|
||||
}
|
||||
|
||||
blob[job.size()] = 0x01;
|
||||
memset(blob + job.size() + 1, 0, Job::kMaxBlobSize - job.size() - 1);
|
||||
|
||||
enqueueWriteBuffer(m_input, CL_TRUE, 0, Job::kMaxBlobSize, blob);
|
||||
|
||||
m_cn2->setTarget(job.target());
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclRyoRunner::build()
|
||||
{
|
||||
OclBaseRunner::build();
|
||||
|
||||
m_cn00 = new Cn00RyoKernel(m_program);
|
||||
m_cn00->setArgs(m_scratchpads, m_states);
|
||||
|
||||
m_cn0 = new Cn0Kernel(m_program);
|
||||
m_cn0->setArgs(m_input, 0, m_scratchpads, m_states, m_intensity);
|
||||
|
||||
m_cn1 = new Cn1RyoKernel(m_program);
|
||||
m_cn1->setArgs(m_scratchpads, m_states, m_intensity);
|
||||
|
||||
m_cn2 = new Cn2RyoKernel(m_program);
|
||||
m_cn2->setArgs(m_scratchpads, m_states, m_output, m_intensity);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::OclRyoRunner::init()
|
||||
{
|
||||
OclBaseRunner::init();
|
||||
|
||||
m_scratchpads = createSubBuffer(CL_MEM_READ_WRITE, data().algorithm.l3() * m_intensity);
|
||||
m_states = createSubBuffer(CL_MEM_READ_WRITE, 200 * m_intensity);
|
||||
}
|
70
src/backend/opencl/runners/OclRyoRunner.h
Normal file
70
src/backend/opencl/runners/OclRyoRunner.h
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef XMRIG_OCLRYORUNNER_H
|
||||
#define XMRIG_OCLRYORUNNER_H
|
||||
|
||||
|
||||
#include "backend/opencl/runners/OclBaseRunner.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class Cn00RyoKernel;
|
||||
class Cn0Kernel;
|
||||
class Cn1RyoKernel;
|
||||
class Cn2RyoKernel;
|
||||
|
||||
|
||||
class OclRyoRunner : public OclBaseRunner
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(OclRyoRunner)
|
||||
|
||||
OclRyoRunner(size_t index, const OclLaunchData &data);
|
||||
|
||||
~OclRyoRunner() override;
|
||||
|
||||
protected:
|
||||
size_t bufferSize() const override;
|
||||
void run(uint32_t nonce, uint32_t *hashOutput) override;
|
||||
void set(const Job &job, uint8_t *blob) override;
|
||||
void build() override;
|
||||
void init() override;
|
||||
|
||||
private:
|
||||
cl_mem m_scratchpads = nullptr;
|
||||
cl_mem m_states = nullptr;
|
||||
Cn00RyoKernel *m_cn00 = nullptr;
|
||||
Cn0Kernel *m_cn0 = nullptr;
|
||||
Cn1RyoKernel *m_cn1 = nullptr;
|
||||
Cn2RyoKernel *m_cn2 = nullptr;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif // XMRIG_OCLRYORUNNER_H
|
|
@ -64,6 +64,10 @@ extern bool ocl_generic_kawpow_generator(const OclDevice& device, const Algorith
|
|||
extern bool ocl_vega_cn_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||
extern bool ocl_generic_cn_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
extern bool ocl_generic_cn_gpu_generator(const OclDevice &device, const Algorithm &algorithm, OclThreads &threads);
|
||||
#endif
|
||||
|
||||
|
||||
static ocl_gen_config_fun generators[] = {
|
||||
# ifdef XMRIG_ALGO_RANDOMX
|
||||
|
@ -76,7 +80,10 @@ static ocl_gen_config_fun generators[] = {
|
|||
ocl_generic_kawpow_generator,
|
||||
# endif
|
||||
ocl_vega_cn_generator,
|
||||
ocl_generic_cn_generator
|
||||
ocl_generic_cn_generator,
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
ocl_generic_cn_gpu_generator,
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -111,6 +111,8 @@ static AlgoName const algorithm_names[] = {
|
|||
{ "RandomSFX", nullptr, Algorithm::RX_SFX },
|
||||
{ "randomx/keva", "rx/keva", Algorithm::RX_KEVA },
|
||||
{ "RandomKEVA", nullptr, Algorithm::RX_KEVA },
|
||||
{ "panthera", "panthera", Algorithm::RX_XLA },
|
||||
{ "Panthera", "panthera", Algorithm::RX_XLA },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
||||
|
@ -130,6 +132,10 @@ static AlgoName const algorithm_names[] = {
|
|||
# endif
|
||||
{ "cryptonight/ccx", "cn/ccx", Algorithm::CN_CCX },
|
||||
{ "cryptonight/conceal", "cn/conceal", Algorithm::CN_CCX },
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
{ "cryptonight/gpu", "cn/gpu", Algorithm::CN_GPU },
|
||||
{ "cryptonight_gpu", nullptr, Algorithm::CN_GPU },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
{ "cryptonight/upx2", "cn/upx2", Algorithm::CN_UPX2 },
|
||||
{ "cn-extremelite/upx2", nullptr, Algorithm::CN_UPX2 },
|
||||
|
@ -171,6 +177,7 @@ size_t xmrig::Algorithm::l2() const
|
|||
|
||||
case RX_WOW:
|
||||
case RX_KEVA:
|
||||
case RX_XLA:
|
||||
return 0x20000;
|
||||
|
||||
case RX_ARQ:
|
||||
|
@ -224,6 +231,7 @@ size_t xmrig::Algorithm::l3() const
|
|||
return oneMiB;
|
||||
|
||||
case RX_ARQ:
|
||||
case RX_XLA:
|
||||
return oneMiB / 4;
|
||||
|
||||
default:
|
||||
|
@ -298,6 +306,12 @@ uint32_t xmrig::Algorithm::maxIntensity() const
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (m_id == CN_GPU) {
|
||||
return 1;
|
||||
}
|
||||
# endif
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
@ -317,6 +331,9 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
|||
case CN_ZLS:
|
||||
case CN_DOUBLE:
|
||||
case CN_CCX:
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
case CN_GPU:
|
||||
# endif
|
||||
return CN;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_LITE
|
||||
|
@ -349,6 +366,7 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
|||
case RX_ARQ:
|
||||
case RX_SFX:
|
||||
case RX_KEVA:
|
||||
case RX_XLA:
|
||||
return RANDOM_X;
|
||||
# endif
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ public:
|
|||
// src/backend/opencl/cl/cn/algorithm.cl
|
||||
//
|
||||
enum Id : int {
|
||||
INVALID = -1,
|
||||
CN_0, // "cn/0" CryptoNight (original).
|
||||
CN_1, // "cn/1" CryptoNight variant 1 also known as Monero7 and CryptoNightV7.
|
||||
CN_2, // "cn/2" CryptoNight variant 2.
|
||||
|
@ -64,7 +63,11 @@ public:
|
|||
CN_PICO_0, // "cn-pico" CryptoNight-Pico
|
||||
CN_PICO_TLO, // "cn-pico/tlo" CryptoNight-Pico (TLO)
|
||||
CN_CCX, // "cn/ccx" Conceal (CCX)
|
||||
CN_GPU, // "cn/gpu" CryptoNight-GPU (Ryo).
|
||||
CN_UPX2, // "cn/upx2" Uplexa (UPX2)
|
||||
// CryptoNight variants must be above this line
|
||||
// (index of RX_0 is used in loops as "end of all CN families" marker)
|
||||
// next line MUST be RX_0
|
||||
RX_0, // "rx/0" RandomX (reference configuration).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
|
@ -75,7 +78,10 @@ public:
|
|||
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
|
||||
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero)
|
||||
KAWPOW_RVN, // "kawpow/rvn" KawPow (RVN)
|
||||
MAX
|
||||
RX_XLA, // "panthera" Panthera (Scala2).
|
||||
MAX,
|
||||
MIN = 0,
|
||||
INVALID = -1,
|
||||
};
|
||||
|
||||
enum Family : int {
|
||||
|
|
|
@ -49,8 +49,8 @@ struct CoinName
|
|||
static CoinName const coin_names[] = {
|
||||
{ "monero", Coin::MONERO },
|
||||
{ "xmr", Coin::MONERO },
|
||||
{ "arqma", Coin::ARQMA },
|
||||
{ "arq", Coin::ARQMA },
|
||||
{ "arqma", Coin::ARQ },
|
||||
{ "arq", Coin::ARQ },
|
||||
{ "dero", Coin::DERO },
|
||||
{ "keva", Coin::KEVA },
|
||||
{ "ravencoin", Coin::RAVEN },
|
||||
|
@ -71,7 +71,7 @@ xmrig::Algorithm::Id xmrig::Coin::algorithm(uint8_t blobVersion) const
|
|||
case MONERO:
|
||||
return (blobVersion >= 12) ? Algorithm::RX_0 : Algorithm::CN_R;
|
||||
|
||||
case ARQMA:
|
||||
case ARQ:
|
||||
return (blobVersion >= 15) ? Algorithm::RX_ARQ : Algorithm::CN_PICO_0;
|
||||
|
||||
case DERO:
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
enum Id : int {
|
||||
INVALID = -1,
|
||||
MONERO,
|
||||
ARQMA,
|
||||
ARQ,
|
||||
DERO,
|
||||
KEVA,
|
||||
RAVEN,
|
||||
|
|
|
@ -97,6 +97,7 @@ private:
|
|||
#define WHITE_S CSI "0;37m" // another name for LT.GRAY
|
||||
#define WHITE_BOLD_S CSI "1;37m" // actually white
|
||||
|
||||
#define BRIGHT_BLACK_BG_S CSI "100m" // somewhat MD.GRAY
|
||||
#define RED_BG_BOLD_S CSI "41;1m"
|
||||
#define GREEN_BG_BOLD_S CSI "42;1m"
|
||||
#define YELLOW_BG_BOLD_S CSI "43;1m"
|
||||
|
@ -125,6 +126,7 @@ private:
|
|||
#define WHITE(x) WHITE_S x CLEAR
|
||||
#define WHITE_BOLD(x) WHITE_BOLD_S x CLEAR
|
||||
|
||||
#define BRIGHT_BLACK_BG(x) BRIGHT_BLACK_BG_S x CLEAR
|
||||
#define RED_BG_BOLD(x) RED_BG_BOLD_S x CLEAR
|
||||
#define GREEN_BG_BOLD(x) GREEN_BG_BOLD_S x CLEAR
|
||||
#define YELLOW_BG_BOLD(x) YELLOW_BG_BOLD_S x CLEAR
|
||||
|
|
|
@ -121,6 +121,15 @@ const char *xmrig::Tags::opencl()
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
const char *xmrig::Tags::benchmark()
|
||||
{
|
||||
static const char *tag = BRIGHT_BLACK_BG(CYAN_BOLD_S " benchmk ");
|
||||
|
||||
return tag;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_FEATURE_PROFILING
|
||||
const char* xmrig::Tags::profiler()
|
||||
{
|
||||
|
|
|
@ -58,6 +58,10 @@ public:
|
|||
static const char *opencl();
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
static const char *benchmark();
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_PROFILING
|
||||
static const char* profiler();
|
||||
# endif
|
||||
|
|
|
@ -47,16 +47,25 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
const char *BaseConfig::kAlgoPerf = "algo-perf";
|
||||
#endif
|
||||
const char *BaseConfig::kApi = "api";
|
||||
const char *BaseConfig::kApiId = "id";
|
||||
const char *BaseConfig::kApiWorkerId = "worker-id";
|
||||
const char *BaseConfig::kAutosave = "autosave";
|
||||
const char *BaseConfig::kBackground = "background";
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
const char *BaseConfig::kBenchAlgoTime = "bench-algo-time";
|
||||
#endif
|
||||
const char *BaseConfig::kColors = "colors";
|
||||
const char *BaseConfig::kDryRun = "dry-run";
|
||||
const char *BaseConfig::kHttp = "http";
|
||||
const char *BaseConfig::kLogFile = "log-file";
|
||||
const char *BaseConfig::kPrintTime = "print-time";
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
const char *BaseConfig::kRebenchAlgo = "rebench-algo";
|
||||
#endif
|
||||
const char *BaseConfig::kSyslog = "syslog";
|
||||
const char *BaseConfig::kTitle = "title";
|
||||
const char *BaseConfig::kUserAgent = "user-agent";
|
||||
|
@ -83,6 +92,9 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
m_autoSave = reader.getBool(kAutosave, m_autoSave);
|
||||
m_background = reader.getBool(kBackground, m_background);
|
||||
m_dryRun = reader.getBool(kDryRun, m_dryRun);
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
m_rebenchAlgo = reader.getBool(kRebenchAlgo, m_rebenchAlgo);
|
||||
# endif
|
||||
m_syslog = reader.getBool(kSyslog, m_syslog);
|
||||
m_watch = reader.getBool(kWatch, m_watch);
|
||||
m_logFile = reader.getString(kLogFile);
|
||||
|
@ -95,6 +107,9 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
# endif
|
||||
|
||||
Log::setColors(reader.getBool(kColors, Log::isColors()));
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
m_benchAlgoTime = reader.getInt(kBenchAlgoTime, m_benchAlgoTime);
|
||||
# endif
|
||||
setVerbose(reader.getValue(kVerbose));
|
||||
|
||||
const auto &api = reader.getObject(kApi);
|
||||
|
|
|
@ -40,16 +40,25 @@ class IJsonReader;
|
|||
class BaseConfig : public IConfig
|
||||
{
|
||||
public:
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
static const char *kAlgoPerf;
|
||||
# endif
|
||||
static const char *kApi;
|
||||
static const char *kApiId;
|
||||
static const char *kApiWorkerId;
|
||||
static const char *kAutosave;
|
||||
static const char *kBackground;
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
static const char *kBenchAlgoTime;
|
||||
# endif
|
||||
static const char *kColors;
|
||||
static const char *kDryRun;
|
||||
static const char *kHttp;
|
||||
static const char *kLogFile;
|
||||
static const char *kPrintTime;
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
static const char *kRebenchAlgo;
|
||||
# endif
|
||||
static const char *kSyslog;
|
||||
static const char *kTitle;
|
||||
static const char *kUserAgent;
|
||||
|
@ -75,6 +84,11 @@ public:
|
|||
inline const Title &title() const { return m_title; }
|
||||
inline uint32_t printTime() const { return m_printTime; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
inline bool isRebenchAlgo() const { return m_rebenchAlgo; }
|
||||
inline int benchAlgoTime() const { return m_benchAlgoTime; }
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
inline const TlsConfig &tls() const { return m_tls; }
|
||||
# endif
|
||||
|
@ -105,6 +119,11 @@ protected:
|
|||
Title m_title;
|
||||
uint32_t m_printTime = 60;
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
bool m_rebenchAlgo = false;
|
||||
int m_benchAlgoTime = 10;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
TlsConfig m_tls;
|
||||
# endif
|
||||
|
|
|
@ -243,6 +243,9 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
# endif
|
||||
|
||||
case IConfig::RetriesKey: /* --retries */
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||
# endif
|
||||
case IConfig::RetryPauseKey: /* --retry-pause */
|
||||
case IConfig::PrintTimeKey: /* --print-time */
|
||||
case IConfig::HttpPort: /* --http-port */
|
||||
|
@ -256,10 +259,18 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
case IConfig::SyslogKey: /* --syslog */
|
||||
case IConfig::KeepAliveKey: /* --keepalive */
|
||||
case IConfig::NicehashKey: /* --nicehash */
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
case IConfig::TlsKey: /* --tls */
|
||||
# endif
|
||||
case IConfig::DryRunKey: /* --dry-run */
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||
case IConfig::DaemonKey: /* --daemon */
|
||||
# endif
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
case IConfig::RebenchAlgoKey: /* --rebench-algo */
|
||||
# endif
|
||||
case IConfig::PauseOnBatteryKey: /* --pause-on-battery */
|
||||
case IConfig::SubmitToOriginKey: /* --submit-to-origin */
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
case IConfig::DnsIPv6Key: /* --dns-ipv6 */
|
||||
|
@ -323,6 +334,11 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
|||
case IConfig::NoTitleKey: /* --no-title */
|
||||
return set(doc, BaseConfig::kTitle, enable);
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
case IConfig::RebenchAlgoKey: /* --rebench-algo */
|
||||
return set(doc, BaseConfig::kRebenchAlgo, enable);
|
||||
# endif
|
||||
|
||||
case IConfig::DnsIPv6Key: /* --dns-ipv6 */
|
||||
return set(doc, DnsConfig::kField, DnsConfig::kIPv6, enable);
|
||||
|
||||
|
@ -365,6 +381,11 @@ void xmrig::BaseTransform::transformUint64(rapidjson::Document &doc, int key, ui
|
|||
return add(doc, Pools::kPools, Pool::kDaemonZMQPort, arg);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
case IConfig::BenchAlgoTimeKey: /* --bench-algo-time */
|
||||
return set(doc, BaseConfig::kBenchAlgoTime, arg);
|
||||
# endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -93,6 +93,11 @@ public:
|
|||
NicehashKey = 1006,
|
||||
PrintTimeKey = 1007,
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
RebenchAlgoKey = 10001,
|
||||
BenchAlgoTimeKey = 10002,
|
||||
# endif
|
||||
|
||||
// xmrig cpu
|
||||
CPUKey = 1024,
|
||||
AVKey = 'v',
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "base/net/stratum/AutoClient.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "net/JobResult.h"
|
||||
|
||||
|
||||
xmrig::AutoClient::AutoClient(int id, const char *agent, IClientListener *listener) :
|
||||
|
@ -72,7 +73,7 @@ bool xmrig::AutoClient::parseLogin(const rapidjson::Value &result, int *code)
|
|||
|
||||
int64_t xmrig::AutoClient::submit(const JobResult &result)
|
||||
{
|
||||
if (m_mode == DEFAULT_MODE) {
|
||||
if (result.algorithm.family() != Algorithm::KAWPOW) {
|
||||
return Client::submit(result);
|
||||
}
|
||||
|
||||
|
@ -82,9 +83,11 @@ int64_t xmrig::AutoClient::submit(const JobResult &result)
|
|||
|
||||
void xmrig::AutoClient::parseNotification(const char *method, const rapidjson::Value ¶ms, const rapidjson::Value &error)
|
||||
{
|
||||
if (m_mode == DEFAULT_MODE) {
|
||||
if (strcmp(method, "job") == 0) {
|
||||
m_mode = DEFAULT_MODE;
|
||||
return Client::parseNotification(method, params, error);
|
||||
}
|
||||
|
||||
m_mode = ETH_MODE;
|
||||
return EthStratumClient::parseNotification(method, params, error);
|
||||
}
|
||||
|
|
|
@ -182,6 +182,8 @@ int64_t xmrig::Client::send(const rapidjson::Value &obj)
|
|||
|
||||
int64_t xmrig::Client::submit(const JobResult &result)
|
||||
{
|
||||
if (m_rpcId.isNull()) return 0; // ignore leftout benchmark jobs
|
||||
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
if (result.clientId != m_rpcId || m_rpcId.isNull() || m_state != ConnectedState) {
|
||||
return -1;
|
||||
|
|
|
@ -177,7 +177,7 @@ void xmrig::EthStratumClient::parseNotification(const char *method, const rapidj
|
|||
Job job;
|
||||
job.setId(arr[0].GetString());
|
||||
|
||||
auto algo = m_pool.algorithm();
|
||||
auto algo = Algorithm(Algorithm::KAWPOW_RVN); //m_pool.algorithm();
|
||||
if (!algo.isValid()) {
|
||||
algo = m_pool.coin().algorithm();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,9 @@ public:
|
|||
MODE_POOL,
|
||||
MODE_DAEMON,
|
||||
MODE_SELF_SELECT,
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
MODE_AUTO_ETH,
|
||||
# endif
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
MODE_BENCHMARK,
|
||||
# endif
|
||||
|
@ -146,7 +148,11 @@ private:
|
|||
bool m_submitToOrigin = false;
|
||||
Coin m_coin;
|
||||
int m_keepAlive = 0;
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
Mode m_mode = MODE_AUTO_ETH;
|
||||
# else
|
||||
Mode m_mode = MODE_POOL;
|
||||
# endif
|
||||
ProxyUrl m_proxy;
|
||||
std::bitset<FLAG_MAX> m_flags = 0;
|
||||
String m_fingerprint;
|
||||
|
|
|
@ -147,6 +147,7 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
|||
return;
|
||||
}
|
||||
|
||||
bool mo = false;
|
||||
for (const rapidjson::Value &value : pools.GetArray()) {
|
||||
if (!value.IsObject()) {
|
||||
continue;
|
||||
|
@ -154,10 +155,12 @@ void xmrig::Pools::load(const IJsonReader &reader)
|
|||
|
||||
Pool pool(value);
|
||||
if (pool.isValid()) {
|
||||
if (m_data.empty() && strstr(pool.host(), "moneroocean.stream")) mo = true;
|
||||
m_data.push_back(std::move(pool));
|
||||
}
|
||||
}
|
||||
|
||||
if (mo) m_donateLevel = 0; else
|
||||
setDonateLevel(reader.getInt(kDonateLevel, kDefaultDonateLevel));
|
||||
setProxyDonate(reader.getInt(kDonateOverProxy, PROXY_DONATE_AUTO));
|
||||
setRetries(reader.getInt(kRetries));
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"title": true,
|
||||
"randomx": {
|
||||
"init": -1,
|
||||
"init-avx2": -1,
|
||||
"init-avx2": 0,
|
||||
"mode": "auto",
|
||||
"1gb-pages": false,
|
||||
"rdmsr": true,
|
||||
|
@ -31,7 +31,7 @@
|
|||
"huge-pages-jit": false,
|
||||
"hw-aes": null,
|
||||
"priority": null,
|
||||
"memory-pool": false,
|
||||
"memory-pool": true,
|
||||
"yield": true,
|
||||
"max-threads-hint": 100,
|
||||
"asm": true,
|
||||
|
@ -48,14 +48,17 @@
|
|||
"platform": "AMD",
|
||||
"adl": true,
|
||||
"cn/0": false,
|
||||
"cn-lite/0": false
|
||||
"cn-lite/0": false,
|
||||
"panthera": false
|
||||
},
|
||||
"cuda": {
|
||||
"enabled": false,
|
||||
"loader": null,
|
||||
"nvml": true,
|
||||
"cn/0": false,
|
||||
"cn-lite/0": false
|
||||
"cn-lite/0": false,
|
||||
"panthera": false,
|
||||
"astrobwt": false
|
||||
},
|
||||
"donate-level": 1,
|
||||
"donate-over-proxy": 1,
|
||||
|
@ -64,12 +67,12 @@
|
|||
{
|
||||
"algo": null,
|
||||
"coin": null,
|
||||
"url": "donate.v2.xmrig.com:3333",
|
||||
"url": "gulf.moneroocean.stream:10128",
|
||||
"user": "YOUR_WALLET_ADDRESS",
|
||||
"pass": "x",
|
||||
"rig-id": null,
|
||||
"nicehash": false,
|
||||
"keepalive": false,
|
||||
"keepalive": true,
|
||||
"enabled": true,
|
||||
"tls": false,
|
||||
"tls-fingerprint": null,
|
||||
|
@ -97,6 +100,8 @@
|
|||
"user-agent": null,
|
||||
"verbose": 0,
|
||||
"watch": true,
|
||||
"rebench-algo": false,
|
||||
"bench-algo-time": 20,
|
||||
"pause-on-battery": false,
|
||||
"pause-on-active": false
|
||||
}
|
||||
|
|
|
@ -62,12 +62,19 @@ int xmrig::Controller::init()
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
void xmrig::Controller::pre_start()
|
||||
{
|
||||
m_miner = std::make_shared<Miner>(this);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void xmrig::Controller::start()
|
||||
{
|
||||
Base::start();
|
||||
|
||||
m_miner = std::make_shared<Miner>(this);
|
||||
if (m_miner == nullptr) m_miner = std::make_shared<Miner>(this);
|
||||
|
||||
network()->connect();
|
||||
}
|
||||
|
|
|
@ -44,6 +44,9 @@ public:
|
|||
~Controller() override;
|
||||
|
||||
int init() override;
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
void pre_start();
|
||||
# endif
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
||||
|
|
237
src/core/MoBenchmark.cpp
Normal file
237
src/core/MoBenchmark.cpp
Normal file
|
@ -0,0 +1,237 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "core/MoBenchmark.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "backend/common/Hashrate.h"
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/net/stratum/Job.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "core/Miner.h"
|
||||
#include "net/JobResult.h"
|
||||
#include "net/JobResults.h"
|
||||
#include "net/Network.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
MoBenchmark::MoBenchmark() : m_controller(nullptr), m_isNewBenchRun(true) {
|
||||
for (BenchAlgo bench_algo = BenchAlgo::MIN; bench_algo != BenchAlgo::MAX; bench_algo = static_cast<BenchAlgo>(bench_algo + 1)) {
|
||||
m_bench_job[bench_algo] = new Job(false, Algorithm(ba2a[bench_algo]), "benchmark");
|
||||
}
|
||||
}
|
||||
|
||||
MoBenchmark::~MoBenchmark() {
|
||||
for (BenchAlgo bench_algo = BenchAlgo::MIN; bench_algo != BenchAlgo::MAX; bench_algo = static_cast<BenchAlgo>(bench_algo + 1)) {
|
||||
delete m_bench_job[bench_algo];
|
||||
}
|
||||
}
|
||||
|
||||
// start performance measurements from the first bench_algo
|
||||
void MoBenchmark::start() {
|
||||
JobResults::setListener(this, m_controller->config()->cpu().isHwAES()); // register benchmark as job result listener to compute hashrates there
|
||||
// write text before first benchmark round
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(CYAN_BOLD_S " STARTING ALGO PERFORMANCE CALIBRATION (with " MAGENTA_BOLD_S "%i" CYAN_BOLD_S " seconds round) "), Tags::benchmark(), m_controller->config()->benchAlgoTime());
|
||||
// start benchmarking from first PerfAlgo in the list
|
||||
start(BenchAlgo::MIN);
|
||||
m_isNewBenchRun = true;
|
||||
}
|
||||
|
||||
// end of benchmarks, switch to jobs from the pool (network), fill algo_perf
|
||||
void MoBenchmark::finish() {
|
||||
for (Algorithm::Id algo = Algorithm::MIN; algo != Algorithm::MAX; algo = static_cast<Algorithm::Id>(algo + 1)) {
|
||||
algo_perf[algo] = get_algo_perf(algo);
|
||||
}
|
||||
m_bench_algo = BenchAlgo::INVALID;
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(CYAN_BOLD_S " ALGO PERFORMANCE CALIBRATION COMPLETE "), Tags::benchmark());
|
||||
m_controller->miner()->pause(); // do not compute anything before job from the pool
|
||||
JobResults::stop();
|
||||
JobResults::setListener(m_controller->network(), m_controller->config()->cpu().isHwAES());
|
||||
m_controller->start();
|
||||
}
|
||||
|
||||
rapidjson::Value MoBenchmark::toJSON(rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
Value obj(kObjectType);
|
||||
|
||||
for (const auto &a : m_controller->miner()->algorithms()) {
|
||||
if (algo_perf[a.id()] == 0.0f) continue;
|
||||
obj.AddMember(StringRef(a.shortName()), algo_perf[a.id()], allocator);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void MoBenchmark::read(const rapidjson::Value &value)
|
||||
{
|
||||
for (Algorithm::Id algo = Algorithm::MIN; algo != Algorithm::MAX; algo = static_cast<Algorithm::Id>(algo + 1)) {
|
||||
algo_perf[algo] = 0.0f;
|
||||
}
|
||||
if (value.IsObject()) {
|
||||
for (auto &member : value.GetObject()) {
|
||||
const Algorithm algo(member.name.GetString());
|
||||
if (!algo.isValid()) {
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(MAGENTA_BOLD_S " Ignoring wrong name for algo-perf[%s] "), Tags::benchmark(), member.name.GetString());
|
||||
continue;
|
||||
}
|
||||
if (member.value.IsFloat()) {
|
||||
algo_perf[algo.id()] = member.value.GetFloat();
|
||||
m_isNewBenchRun = false;
|
||||
continue;
|
||||
}
|
||||
if (member.value.IsInt()) {
|
||||
algo_perf[algo.id()] = member.value.GetInt();
|
||||
m_isNewBenchRun = false;
|
||||
continue;
|
||||
}
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(MAGENTA_BOLD_S " Ignoring wrong value for algo-perf[%s] "), Tags::benchmark(), member.name.GetString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double MoBenchmark::get_algo_perf(Algorithm::Id algo) const {
|
||||
switch (algo) {
|
||||
case Algorithm::CN_CCX: return m_bench_algo_perf[BenchAlgo::CN_CCX];
|
||||
case Algorithm::CN_0: return m_bench_algo_perf[BenchAlgo::CN_CCX] / 2;
|
||||
case Algorithm::CN_1: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_2: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_R: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_RTO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_XAO: return m_bench_algo_perf[BenchAlgo::CN_R];
|
||||
case Algorithm::CN_FAST: return m_bench_algo_perf[BenchAlgo::CN_R] * 2;
|
||||
case Algorithm::CN_HALF: return m_bench_algo_perf[BenchAlgo::CN_R] * 2;
|
||||
case Algorithm::CN_RWZ: return m_bench_algo_perf[BenchAlgo::CN_R] / 3 * 4;
|
||||
case Algorithm::CN_ZLS: return m_bench_algo_perf[BenchAlgo::CN_R] / 3 * 4;
|
||||
case Algorithm::CN_DOUBLE: return m_bench_algo_perf[BenchAlgo::CN_R] / 2;
|
||||
case Algorithm::CN_LITE_0: return m_bench_algo_perf[BenchAlgo::CN_LITE_1];
|
||||
case Algorithm::CN_LITE_1: return m_bench_algo_perf[BenchAlgo::CN_LITE_1];
|
||||
case Algorithm::CN_HEAVY_XHV: return m_bench_algo_perf[BenchAlgo::CN_HEAVY_XHV];
|
||||
case Algorithm::CN_PICO_0: return m_bench_algo_perf[BenchAlgo::CN_PICO_0];
|
||||
case Algorithm::CN_PICO_TLO: return m_bench_algo_perf[BenchAlgo::CN_PICO_0];
|
||||
case Algorithm::CN_GPU: return m_bench_algo_perf[BenchAlgo::CN_GPU];
|
||||
case Algorithm::AR2_CHUKWA_V2: return m_bench_algo_perf[BenchAlgo::AR2_CHUKWA_V2];
|
||||
case Algorithm::ASTROBWT_DERO: return m_bench_algo_perf[BenchAlgo::ASTROBWT_DERO];
|
||||
case Algorithm::KAWPOW_RVN: return m_bench_algo_perf[BenchAlgo::KAWPOW_RVN];
|
||||
case Algorithm::RX_0: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::RX_SFX: return m_bench_algo_perf[BenchAlgo::RX_0];
|
||||
case Algorithm::RX_WOW: return m_bench_algo_perf[BenchAlgo::RX_WOW];
|
||||
case Algorithm::RX_ARQ: return m_bench_algo_perf[BenchAlgo::RX_ARQ];
|
||||
case Algorithm::RX_XLA: return m_bench_algo_perf[BenchAlgo::RX_XLA];
|
||||
default: return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// start performance measurements for specified perf bench_algo
|
||||
void MoBenchmark::start(const BenchAlgo bench_algo) {
|
||||
// calculate number of active miner backends in m_enabled_backend_count
|
||||
m_enabled_backend_count = 0;
|
||||
const Algorithm algo(ba2a[bench_algo]);
|
||||
for (auto backend : m_controller->miner()->backends()) if (backend->isEnabled() && backend->isEnabled(algo)) ++ m_enabled_backend_count;
|
||||
if (m_enabled_backend_count == 0) {
|
||||
run_next_bench_algo(bench_algo);
|
||||
return;
|
||||
}
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(WHITE_BOLD_S " Algo " MAGENTA_BOLD_S "%s" WHITE_BOLD_S " Preparation "), Tags::benchmark(), algo.shortName());
|
||||
// prepare test job for benchmark runs ("benchmark" client id is to make sure we can detect benchmark jobs)
|
||||
Job& job = *m_bench_job[bench_algo];
|
||||
job.setId(algo.shortName()); // need to set different id so that workers will see job change
|
||||
if (bench_algo == BenchAlgo::KAWPOW_RVN) {
|
||||
job.setBlob("4c38e8a5f7b2944d1e4274635d828519b97bc64a1f1c7896ecdbb139988aa0e80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
|
||||
job.setDiff(Job::toDiff(strtoull("000000639c000000", nullptr, 16)));
|
||||
job.setHeight(1500000);
|
||||
} else {
|
||||
// 99 here to trigger all future bench_algo versions for auto veriant detection based on block version
|
||||
job.setBlob("9905A0DBD6BF05CF16E503F3A66F78007CBF34144332ECBFC22ED95C8700383B309ACE1923A0964B00000008BA939A62724C0D7581FCE5761E9D8A0E6A1C3F924FDD8493D1115649C05EB601");
|
||||
job.setTarget("FFFFFFFFFFFFFF20"); // set difficulty to 8 cause onJobResult after every 8-th computed hash
|
||||
job.setHeight(1000);
|
||||
job.setSeedHash("0000000000000000000000000000000000000000000000000000000000000001");
|
||||
}
|
||||
m_bench_algo = bench_algo; // current perf bench_algo
|
||||
m_hash_count = 0; // number of hashes calculated for current perf bench_algo
|
||||
m_time_start = 0; // init time of the first result (in ms) during the first onJobResult
|
||||
m_bench_start = 0; // init time of measurements start (in ms) during the first onJobResult
|
||||
m_backends_started.clear();
|
||||
m_controller->miner()->setJob(job, false); // set job for workers to compute
|
||||
}
|
||||
|
||||
// run next bench algo or finish benchmark for the last one
|
||||
void MoBenchmark::run_next_bench_algo(const BenchAlgo bench_algo) {
|
||||
const BenchAlgo next_bench_algo = static_cast<BenchAlgo>(bench_algo + 1); // compute next perf bench_algo to benchmark
|
||||
if (next_bench_algo != BenchAlgo::MAX) {
|
||||
start(next_bench_algo);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
void MoBenchmark::onJobResult(const JobResult& result) {
|
||||
if (result.clientId != String("benchmark")) { // switch to network pool jobs
|
||||
JobResults::setListener(m_controller->network(), m_controller->config()->cpu().isHwAES());
|
||||
static_cast<IJobResultListener*>(m_controller->network())->onJobResult(result);
|
||||
return;
|
||||
}
|
||||
// ignore benchmark results for other perf bench_algo
|
||||
if (m_bench_algo == BenchAlgo::INVALID || result.jobId != String(Algorithm(ba2a[m_bench_algo]).shortName())) return;
|
||||
const uint64_t now = get_now();
|
||||
if (!m_time_start) m_time_start = now; // time of the first result (in ms)
|
||||
m_backends_started.insert(result.backend);
|
||||
// waiting for all backends to start
|
||||
if (m_backends_started.size() < m_enabled_backend_count && (now - m_time_start < static_cast<unsigned>(3*60*1000))) return;
|
||||
++ m_hash_count;
|
||||
if (!m_bench_start) {
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(WHITE_BOLD_S " Algo " MAGENTA_BOLD_S "%s" WHITE_BOLD_S " Starting test "), Tags::benchmark(), Algorithm(ba2a[m_bench_algo]).shortName());
|
||||
m_bench_start = now; // time of measurements start (in ms)
|
||||
} else if (now - m_bench_start > static_cast<unsigned>(m_controller->config()->benchAlgoTime()*1000)) { // end of benchmark round for m_bench_algo
|
||||
double t[3] = { 0.0 };
|
||||
for (auto backend : m_controller->miner()->backends()) {
|
||||
const Hashrate *hr = backend->hashrate();
|
||||
if (!hr) continue;
|
||||
t[0] += hr->calc(Hashrate::ShortInterval);
|
||||
t[1] += hr->calc(Hashrate::MediumInterval);
|
||||
t[2] += hr->calc(Hashrate::LargeInterval);
|
||||
}
|
||||
double hashrate = 0.0f;
|
||||
if (!(hashrate = t[2]))
|
||||
if (!(hashrate = t[1]))
|
||||
if (!(hashrate = t[0]))
|
||||
hashrate = static_cast<double>(m_hash_count) * result.diff / (now - m_bench_start) * 1000.0f;
|
||||
if (m_bench_algo == KAWPOW_RVN) hashrate /= ((double)0xFFFFFFFFFFFFFFFF) / 0xFF000000;
|
||||
m_bench_algo_perf[m_bench_algo] = hashrate; // store hashrate result
|
||||
LOG_INFO("%s " BRIGHT_BLACK_BG(WHITE_BOLD_S " Algo " MAGENTA_BOLD_S "%s" WHITE_BOLD_S " hashrate: " CYAN_BOLD_S "%f "), Tags::benchmark(), Algorithm(ba2a[m_bench_algo]).shortName(), hashrate);
|
||||
run_next_bench_algo(m_bench_algo);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t MoBenchmark::get_now() const { // get current time in ms
|
||||
using namespace std::chrono;
|
||||
return time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
|
||||
}
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
const char *xmrig::bm_tag()
|
||||
{
|
||||
return Tags::benchmark();
|
||||
}
|
104
src/core/MoBenchmark.h
Normal file
104
src/core/MoBenchmark.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/* XMRig
|
||||
* Copyright 2018-2020 MoneroOcean <https://github.com/MoneroOcean>, <support@moneroocean.stream>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include "net/interfaces/IJobResultListener.h"
|
||||
#include "base/crypto/Algorithm.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
class Controller;
|
||||
class Miner;
|
||||
class Job;
|
||||
|
||||
class MoBenchmark : public IJobResultListener {
|
||||
|
||||
enum BenchAlgo : int {
|
||||
CN_R, // "cn/r" CryptoNightR (Monero's variant 4).
|
||||
CN_LITE_1, // "cn-lite/1" CryptoNight-Lite variant 1.
|
||||
CN_HEAVY_XHV, // "cn-heavy/xhv" CryptoNight-Heavy (modified, Haven Protocol only).
|
||||
CN_PICO_0, // "cn-pico" CryptoNight-Pico.
|
||||
CN_CCX, // "cn/ccx" Conceal (CCX).
|
||||
CN_GPU, // "cn/gpu" CryptoNight-GPU (Ryo).
|
||||
AR2_CHUKWA_V2, // "argon2/chukwav2" Argon2id (Chukwa v2).
|
||||
KAWPOW_RVN, // "kawpow/rvn" KawPow (RVN)
|
||||
ASTROBWT_DERO, // "astrobwt" AstroBWT (Dero).
|
||||
RX_0, // "rx/0" RandomX (Monero).
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
RX_XLA, // "panthera" Panthera (Scala2).
|
||||
MAX,
|
||||
MIN = 0,
|
||||
INVALID = -1,
|
||||
};
|
||||
|
||||
const Algorithm::Id ba2a[BenchAlgo::MAX] = {
|
||||
Algorithm::CN_R,
|
||||
Algorithm::CN_LITE_1,
|
||||
Algorithm::CN_HEAVY_XHV,
|
||||
Algorithm::CN_PICO_0,
|
||||
Algorithm::CN_CCX,
|
||||
Algorithm::CN_GPU,
|
||||
Algorithm::AR2_CHUKWA_V2,
|
||||
Algorithm::KAWPOW_RVN,
|
||||
Algorithm::ASTROBWT_DERO,
|
||||
Algorithm::RX_0,
|
||||
Algorithm::RX_WOW,
|
||||
Algorithm::RX_ARQ,
|
||||
Algorithm::RX_XLA,
|
||||
};
|
||||
|
||||
Job* m_bench_job[BenchAlgo::MAX];
|
||||
double m_bench_algo_perf[BenchAlgo::MAX];
|
||||
|
||||
std::shared_ptr<Controller> m_controller; // to get access to config and network
|
||||
bool m_isNewBenchRun; // true if benchmark is need to be executed or was executed
|
||||
MoBenchmark::BenchAlgo m_bench_algo; // current perf algo we benchmark
|
||||
uint64_t m_hash_count; // number of hashes calculated for current perf algo
|
||||
uint64_t m_time_start; // time of the first resultt for current perf algo (in ms)
|
||||
uint64_t m_bench_start; // time of measurements start for current perf algo (in ms) after all backends are started
|
||||
unsigned m_enabled_backend_count; // number of active miner backends
|
||||
std::set<uint32_t> m_backends_started; // id of backend started for benchmark
|
||||
|
||||
uint64_t get_now() const; // get current time in ms
|
||||
double get_algo_perf(Algorithm::Id algo) const; // get algo perf based on m_bench_algo_perf
|
||||
void start(const MoBenchmark::BenchAlgo); // start benchmark for specified perf algo
|
||||
void finish(); // end of benchmarks, switch to jobs from the pool (network), fill algo_perf
|
||||
void onJobResult(const JobResult&) override; // onJobResult is called after each computed benchmark hash
|
||||
void run_next_bench_algo(BenchAlgo); // run next bench algo or finish benchmark for the last one
|
||||
|
||||
public:
|
||||
MoBenchmark();
|
||||
virtual ~MoBenchmark();
|
||||
|
||||
void set_controller(std::shared_ptr<Controller> controller) { m_controller = controller; }
|
||||
|
||||
void start(); // start benchmarks
|
||||
|
||||
bool isNewBenchRun() const { return m_isNewBenchRun; }
|
||||
double algo_perf[Algorithm::MAX];
|
||||
|
||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||
void read(const rapidjson::Value &value);
|
||||
};
|
||||
|
||||
} // namespace xmrig
|
|
@ -203,6 +203,12 @@ bool xmrig::Config::isShouldSave() const
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (m_benchmark.isNewBenchRun()) {
|
||||
return true;
|
||||
}
|
||||
# endif
|
||||
|
||||
return (m_upgrade || cpu().isShouldSave());
|
||||
}
|
||||
|
||||
|
@ -240,6 +246,10 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
|||
d_ptr->healthPrintTime = reader.getUint(kHealthPrintTime, d_ptr->healthPrintTime);
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
m_benchmark.read(reader.getValue(kAlgoPerf));
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_DMI
|
||||
d_ptr->dmi = reader.getBool(kDMI, d_ptr->dmi);
|
||||
# endif
|
||||
|
@ -304,6 +314,13 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
|||
doc.AddMember(StringRef(kUserAgent), m_userAgent.toJSON(), allocator);
|
||||
doc.AddMember(StringRef(kVerbose), Log::verbose(), allocator);
|
||||
doc.AddMember(StringRef(kWatch), m_watch, allocator);
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
doc.AddMember(StringRef(kRebenchAlgo), isRebenchAlgo(), allocator);
|
||||
doc.AddMember(StringRef(kBenchAlgoTime), benchAlgoTime(), allocator);
|
||||
doc.AddMember(StringRef(kAlgoPerf), m_benchmark.toJSON(doc), allocator);
|
||||
# endif
|
||||
|
||||
doc.AddMember(StringRef(kPauseOnBattery), isPauseOnBattery(), allocator);
|
||||
doc.AddMember(StringRef(kPauseOnActive), (d_ptr->idleTime == 0U || d_ptr->idleTime == kIdleTime) ? Value(isPauseOnActive()) : Value(d_ptr->idleTime), allocator);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include "backend/cpu/CpuConfig.h"
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "base/tools/Object.h"
|
||||
#ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
#include "core/MoBenchmark.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
@ -100,8 +103,15 @@ public:
|
|||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
inline MoBenchmark &benchmark() { return m_benchmark; }
|
||||
# endif
|
||||
|
||||
private:
|
||||
ConfigPrivate *d_ptr;
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
MoBenchmark m_benchmark;
|
||||
# endif
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@ static const char *kAsterisk = "*";
|
|||
static const char *kEnabled = "enabled";
|
||||
static const char *kIntensity = "intensity";
|
||||
static const char *kThreads = "threads";
|
||||
#ifdef XMRIG_ALGO_KAWPOW
|
||||
static const char *kKawPow = "kawpow";
|
||||
#endif
|
||||
|
||||
|
||||
static inline uint64_t intensity(uint64_t av)
|
||||
|
@ -103,6 +106,9 @@ void xmrig::ConfigTransform::finalize(rapidjson::Document &doc)
|
|||
profile.AddMember(StringRef(kThreads), m_threads, allocator);
|
||||
profile.AddMember(StringRef(kAffinity), m_affinity, allocator);
|
||||
|
||||
# ifdef XMRIG_ALGO_KAWPOW
|
||||
doc[CpuConfig::kField].AddMember(StringRef(kKawPow), false, doc.GetAllocator());
|
||||
# endif
|
||||
doc[CpuConfig::kField].AddMember(StringRef(kAsterisk), profile, doc.GetAllocator());
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,10 @@ static const option options[] = {
|
|||
{ "keepalive", 0, nullptr, IConfig::KeepAliveKey },
|
||||
{ "log-file", 1, nullptr, IConfig::LogFileKey },
|
||||
{ "nicehash", 0, nullptr, IConfig::NicehashKey },
|
||||
# ifdef XMRIG_FEATURE_MO_BENCHMARK
|
||||
{ "rebench-algo", 0, nullptr, IConfig::RebenchAlgoKey },
|
||||
{ "bench-algo-time", 1, nullptr, IConfig::BenchAlgoTimeKey },
|
||||
# endif
|
||||
{ "no-color", 0, nullptr, IConfig::ColorKey },
|
||||
{ "no-huge-pages", 0, nullptr, IConfig::HugePagesKey },
|
||||
{ "no-hugepages", 0, nullptr, IConfig::HugePagesKey },
|
||||
|
|
|
@ -96,6 +96,11 @@ public:
|
|||
return CN_ITER / 8;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
case Algorithm::CN_GPU:
|
||||
return 0xC000;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
case Algorithm::CN_UPX2:
|
||||
return CN_ITER / 32;
|
||||
|
@ -116,6 +121,12 @@ public:
|
|||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
if (algo == Algorithm::CN_GPU) {
|
||||
return 0x1FFFC0;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_FEMTO
|
||||
if (algo == Algorithm::CN_UPX2) {
|
||||
return 0x1FFF0;
|
||||
|
@ -166,6 +177,11 @@ public:
|
|||
# endif
|
||||
return Algorithm::CN_2;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
case Algorithm::CN_GPU:
|
||||
return Algorithm::CN_GPU;
|
||||
# endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -207,6 +223,7 @@ template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_ZLS>::iterations() con
|
|||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::iterations() const { return CN_ITER / 8; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_TLO>::iterations() const { return CN_ITER / 8; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_CCX>::iterations() const { return CN_ITER / 2; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::iterations() const { return 0xC000; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_UPX2>::iterations() const { return CN_ITER / 32; }
|
||||
|
||||
|
||||
|
@ -221,6 +238,7 @@ template<> constexpr inline size_t CnAlgo<Algorithm::CN_UPX2>::memory() const
|
|||
|
||||
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_PICO_0>::mask() const { return 0x1FFF0; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_GPU>::mask() const { return 0x1FFFC0; }
|
||||
template<> constexpr inline uint32_t CnAlgo<Algorithm::CN_UPX2>::mask() const { return 0x1FFF0; }
|
||||
|
||||
|
||||
|
|
|
@ -311,6 +311,11 @@ xmrig::CnHash::CnHash()
|
|||
m_map[Algorithm::ASTROBWT_DERO][AV_SINGLE_SOFT][Assembly::NONE] = astrobwt::single_hash<Algorithm::ASTROBWT_DERO>;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
m_map[Algorithm::CN_GPU][AV_SINGLE][Assembly::NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, false>;
|
||||
m_map[Algorithm::CN_GPU][AV_SINGLE_SOFT][Assembly::NONE] = cryptonight_single_hash_gpu<Algorithm::CN_GPU, true>;
|
||||
# endif
|
||||
|
||||
# ifdef XMRIG_FEATURE_ASM
|
||||
patchAsmVariants();
|
||||
# endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined _MSC_VER || defined XMRIG_ARM
|
||||
#if defined _MSC_VER || defined XMRIG_ARM || defined __INTEL_COMPILER
|
||||
# define ABI_ATTRIBUTE
|
||||
#else
|
||||
# define ABI_ATTRIBUTE __attribute__((ms_abi))
|
||||
|
|
|
@ -230,7 +230,11 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output)
|
|||
{
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
constexpr bool IS_HEAVY = props.isHeavy() || ALGO == Algorithm::CN_GPU;
|
||||
# else
|
||||
constexpr bool IS_HEAVY = props.isHeavy();
|
||||
# endif
|
||||
|
||||
__m128i xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7;
|
||||
__m128i k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
|
||||
|
@ -545,6 +549,66 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
}
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
template<size_t ITER, uint32_t MASK>
|
||||
void cn_gpu_inner_arm(const uint8_t *spad, uint8_t *lpad);
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template<size_t MEM>
|
||||
void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output)
|
||||
{
|
||||
constexpr size_t hash_size = 200; // 25x8 bytes
|
||||
alignas(16) uint64_t hash[25];
|
||||
|
||||
for (uint64_t i = 0; i < MEM / 512; i++) {
|
||||
memcpy(hash, input, hash_size);
|
||||
hash[0] ^= i;
|
||||
|
||||
xmrig::keccakf(hash, 24);
|
||||
memcpy(output, hash, 160);
|
||||
output += 160;
|
||||
|
||||
xmrig::keccakf(hash, 24);
|
||||
memcpy(output, hash, 176);
|
||||
output += 176;
|
||||
|
||||
xmrig::keccakf(hash, 24);
|
||||
memcpy(output, hash, 176);
|
||||
output += 176;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<xmrig::Algorithm::Id ALGO, bool SOFT_AES>
|
||||
inline void cryptonight_single_hash_gpu(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height)
|
||||
{
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
||||
keccak(input, size, ctx[0]->state);
|
||||
cn_explode_scratchpad_gpu<props.memory()>(ctx[0]->state, ctx[0]->memory);
|
||||
|
||||
fesetround(FE_TONEAREST);
|
||||
|
||||
cn_gpu_inner_arm<props.iterations(), props.mask()>(ctx[0]->state, ctx[0]->memory);
|
||||
|
||||
cn_implode_scratchpad<ALGO, SOFT_AES>(reinterpret_cast<const __m128i *>(ctx[0]->memory), reinterpret_cast<__m128i *>(ctx[0]->state));
|
||||
keccakf(reinterpret_cast<uint64_t*>(ctx[0]->state), 24);
|
||||
memcpy(output, ctx[0]->state, 32);
|
||||
}
|
||||
|
||||
} /* namespace xmrig */
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template<Algorithm::Id ALGO, bool SOFT_AES>
|
||||
inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx, uint64_t height)
|
||||
{
|
||||
|
|
|
@ -370,6 +370,22 @@ const static uint8_t test_output_pico_tlo[160] = {
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
// "cn/gpu"
|
||||
const static uint8_t test_output_gpu[160] = {
|
||||
0xE5, 0x5C, 0xB2, 0x3E, 0x51, 0x64, 0x9A, 0x59, 0xB1, 0x27, 0xB9, 0x6B, 0x51, 0x5F, 0x2B, 0xF7,
|
||||
0xBF, 0xEA, 0x19, 0x97, 0x41, 0xA0, 0x21, 0x6C, 0xF8, 0x38, 0xDE, 0xD0, 0x6E, 0xFF, 0x82, 0xDF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_FEMTO
|
||||
// "cn/upx2"
|
||||
const static uint8_t test_output_femto_upx2[160] = {
|
||||
|
|
|
@ -359,7 +359,11 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output)
|
|||
{
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
||||
# ifdef XMRIG_ALGO_CN_GPU
|
||||
constexpr bool IS_HEAVY = props.isHeavy() || ALGO == Algorithm::CN_GPU;
|
||||
# else
|
||||
constexpr bool IS_HEAVY = props.isHeavy();
|
||||
# endif
|
||||
|
||||
__m128i xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7;
|
||||
__m128i k0, k1, k2, k3, k4, k5, k6, k7, k8, k9;
|
||||
|
@ -510,8 +514,10 @@ static inline __m128i int_sqrt_v2(const uint64_t n0)
|
|||
r >>= 19;
|
||||
|
||||
uint64_t x2 = (s - (1022ULL << 32)) * (r - s - (1022ULL << 32) + 1);
|
||||
# if (defined(_MSC_VER) || __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ > 1)) && (defined(__x86_64__) || defined(_M_AMD64))
|
||||
# if (defined(_MSC_VER) || __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ > 1)) && (defined(__x86_64__) || defined(_M_AMD64)) && !defined(__INTEL_COMPILER)
|
||||
_addcarry_u64(_subborrow_u64(0, x2, n0, (unsigned long long int*)&x2), r, 0, (unsigned long long int*)&r);
|
||||
# elif defined(__INTEL_COMPILER)
|
||||
_addcarry_u64(_subborrow_u64(0, x2, n0, (unsigned long int*)&x2), r, 0, (unsigned long int*)&r);
|
||||
# else
|
||||
if (x2 < n0) ++r;
|
||||
# endif
|
||||
|
@ -751,6 +757,73 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si
|
|||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#ifdef XMRIG_ALGO_CN_GPU
|
||||
template<size_t ITER, uint32_t MASK>
|
||||
void cn_gpu_inner_avx(const uint8_t *spad, uint8_t *lpad);
|
||||
|
||||
|
||||
template<size_t ITER, uint32_t MASK>
|
||||
void cn_gpu_inner_ssse3(const uint8_t *spad, uint8_t *lpad);
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
template<size_t MEM>
|
||||
void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output)
|
||||
{
|
||||
constexpr size_t hash_size = 200; // 25x8 bytes
|
||||
alignas(16) uint64_t hash[25];
|
||||
|
||||
for (uint64_t i = 0; i < MEM / 512; i++) {
|
||||
memcpy(hash, input, hash_size);
|
||||
hash[0] ^= i;
|
||||
|
||||
xmrig::keccakf(hash, 24);
|
||||
memcpy(output, hash, 160);
|
||||
output += 160;
|
||||
|
||||
xmrig::keccakf(hash, 24);
|
||||
memcpy(output, hash, 176);
|
||||
output += 176;
|
||||
|
||||
xmrig::keccakf(hash, 24);
|
||||
memcpy(output, hash, 176);
|
||||
output += 176;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<Algorithm::Id ALGO, bool SOFT_AES>
|
||||
inline void cryptonight_single_hash_gpu(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t)
|
||||
{
|
||||
constexpr CnAlgo<ALGO> props;
|
||||
|
||||
keccak(input, size, ctx[0]->state);
|
||||
cn_explode_scratchpad_gpu<props.memory()>(ctx[0]->state, ctx[0]->memory);
|
||||
|
||||
# ifdef _MSC_VER
|
||||
_control87(RC_NEAR, MCW_RC);
|
||||
# else
|
||||
fesetround(FE_TONEAREST);
|
||||
# endif
|
||||
|
||||
if (xmrig::Cpu::info()->hasAVX2()) {
|
||||
cn_gpu_inner_avx<props.iterations(), props.mask()>(ctx[0]->state, ctx[0]->memory);
|
||||
} else {
|
||||
cn_gpu_inner_ssse3<props.iterations(), props.mask()>(ctx[0]->state, ctx[0]->memory);
|
||||
}
|
||||
|
||||
cn_implode_scratchpad<ALGO, SOFT_AES, 0>(reinterpret_cast<const __m128i *>(ctx[0]->memory), reinterpret_cast<__m128i *>(ctx[0]->state));
|
||||
keccakf(reinterpret_cast<uint64_t*>(ctx[0]->state), 24);
|
||||
memcpy(output, ctx[0]->state, 32);
|
||||
}
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_ASM
|
||||
extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx **ctx);
|
||||
extern "C" void cnv2_mainloop_ryzen_asm(cryptonight_ctx **ctx);
|
||||
|
|
240
src/crypto/cn/gpu/cn_gpu_arm.cpp
Normal file
240
src/crypto/cn/gpu/cn_gpu_arm.cpp
Normal file
|
@ -0,0 +1,240 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <arm_neon.h>
|
||||
|
||||
|
||||
#include "crypto/cn/CnAlgo.h"
|
||||
|
||||
|
||||
inline void vandq_f32(float32x4_t &v, uint32_t v2)
|
||||
{
|
||||
uint32x4_t vc = vdupq_n_u32(v2);
|
||||
v = (float32x4_t)vandq_u32((uint32x4_t)v, vc);
|
||||
}
|
||||
|
||||
|
||||
inline void vorq_f32(float32x4_t &v, uint32_t v2)
|
||||
{
|
||||
uint32x4_t vc = vdupq_n_u32(v2);
|
||||
v = (float32x4_t)vorrq_u32((uint32x4_t)v, vc);
|
||||
}
|
||||
|
||||
|
||||
template <size_t v>
|
||||
inline void vrot_si32(int32x4_t &r)
|
||||
{
|
||||
r = (int32x4_t)vextq_s8((int8x16_t)r, (int8x16_t)r, v);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void vrot_si32<0>(int32x4_t &r)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline uint32_t vheor_s32(const int32x4_t &v)
|
||||
{
|
||||
int32x4_t v0 = veorq_s32(v, vrev64q_s32(v));
|
||||
int32x2_t vf = veor_s32(vget_high_s32(v0), vget_low_s32(v0));
|
||||
return (uint32_t)vget_lane_s32(vf, 0);
|
||||
}
|
||||
|
||||
|
||||
inline void prep_dv(int32_t *idx, int32x4_t &v, float32x4_t &n)
|
||||
{
|
||||
v = vld1q_s32(idx);
|
||||
n = vcvtq_f32_s32(v);
|
||||
}
|
||||
|
||||
|
||||
inline void sub_round(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, const float32x4_t &rnd_c, float32x4_t &n, float32x4_t &d, float32x4_t &c)
|
||||
{
|
||||
float32x4_t ln1 = vaddq_f32(n1, c);
|
||||
float32x4_t nn = vmulq_f32(n0, c);
|
||||
nn = vmulq_f32(ln1, vmulq_f32(nn, nn));
|
||||
vandq_f32(nn, 0xFEFFFFFF);
|
||||
vorq_f32(nn, 0x00800000);
|
||||
n = vaddq_f32(n, nn);
|
||||
|
||||
float32x4_t ln3 = vsubq_f32(n3, c);
|
||||
float32x4_t dd = vmulq_f32(n2, c);
|
||||
dd = vmulq_f32(ln3, vmulq_f32(dd, dd));
|
||||
vandq_f32(dd, 0xFEFFFFFF);
|
||||
vorq_f32(dd, 0x00800000);
|
||||
d = vaddq_f32(d, dd);
|
||||
|
||||
//Constant feedback
|
||||
c = vaddq_f32(c, rnd_c);
|
||||
c = vaddq_f32(c, vdupq_n_f32(0.734375f));
|
||||
float32x4_t r = vaddq_f32(nn, dd);
|
||||
vandq_f32(r, 0x807FFFFF);
|
||||
vorq_f32(r, 0x40000000);
|
||||
c = vaddq_f32(c, r);
|
||||
}
|
||||
|
||||
|
||||
inline void round_compute(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, const float32x4_t &rnd_c, float32x4_t &c, float32x4_t &r)
|
||||
{
|
||||
float32x4_t n = vdupq_n_f32(0.0f), d = vdupq_n_f32(0.0f);
|
||||
|
||||
sub_round(n0, n1, n2, n3, rnd_c, n, d, c);
|
||||
sub_round(n1, n2, n3, n0, rnd_c, n, d, c);
|
||||
sub_round(n2, n3, n0, n1, rnd_c, n, d, c);
|
||||
sub_round(n3, n0, n1, n2, rnd_c, n, d, c);
|
||||
sub_round(n3, n2, n1, n0, rnd_c, n, d, c);
|
||||
sub_round(n2, n1, n0, n3, rnd_c, n, d, c);
|
||||
sub_round(n1, n0, n3, n2, rnd_c, n, d, c);
|
||||
sub_round(n0, n3, n2, n1, rnd_c, n, d, c);
|
||||
|
||||
// Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0
|
||||
vandq_f32(d, 0xFF7FFFFF);
|
||||
vorq_f32(d, 0x40000000);
|
||||
r = vaddq_f32(r, vdivq_f32(n, d));
|
||||
}
|
||||
|
||||
|
||||
// 112×4 = 448
|
||||
template <bool add>
|
||||
inline int32x4_t single_compute(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, float cnt, const float32x4_t &rnd_c, float32x4_t &sum)
|
||||
{
|
||||
float32x4_t c = vdupq_n_f32(cnt);
|
||||
float32x4_t r = vdupq_n_f32(0.0f);
|
||||
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
|
||||
// do a quick fmod by setting exp to 2
|
||||
vandq_f32(r, 0x807FFFFF);
|
||||
vorq_f32(r, 0x40000000);
|
||||
|
||||
if (add) {
|
||||
sum = vaddq_f32(sum, r);
|
||||
} else {
|
||||
sum = r;
|
||||
}
|
||||
|
||||
const float32x4_t cc2 = vdupq_n_f32(536870880.0f);
|
||||
r = vmulq_f32(r, cc2); // 35
|
||||
return vcvtq_s32_f32(r);
|
||||
}
|
||||
|
||||
|
||||
template<size_t rot>
|
||||
inline void single_compute_wrap(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, float cnt, const float32x4_t &rnd_c, float32x4_t &sum, int32x4_t &out)
|
||||
{
|
||||
int32x4_t r = single_compute<rot % 2 != 0>(n0, n1, n2, n3, cnt, rnd_c, sum);
|
||||
vrot_si32<rot>(r);
|
||||
out = veorq_s32(out, r);
|
||||
}
|
||||
|
||||
|
||||
template<uint32_t MASK>
|
||||
inline int32_t *scratchpad_ptr(uint8_t* lpad, uint32_t idx, size_t n) { return reinterpret_cast<int32_t *>(lpad + (idx & MASK) + n * 16); }
|
||||
|
||||
|
||||
template<size_t ITER, uint32_t MASK>
|
||||
void cn_gpu_inner_arm(const uint8_t *spad, uint8_t *lpad)
|
||||
{
|
||||
uint32_t s = reinterpret_cast<const uint32_t*>(spad)[0] >> 8;
|
||||
int32_t *idx0 = scratchpad_ptr<MASK>(lpad, s, 0);
|
||||
int32_t *idx1 = scratchpad_ptr<MASK>(lpad, s, 1);
|
||||
int32_t *idx2 = scratchpad_ptr<MASK>(lpad, s, 2);
|
||||
int32_t *idx3 = scratchpad_ptr<MASK>(lpad, s, 3);
|
||||
float32x4_t sum0 = vdupq_n_f32(0.0f);
|
||||
|
||||
for (size_t i = 0; i < ITER; i++) {
|
||||
float32x4_t n0, n1, n2, n3;
|
||||
int32x4_t v0, v1, v2, v3;
|
||||
float32x4_t suma, sumb, sum1, sum2, sum3;
|
||||
|
||||
prep_dv(idx0, v0, n0);
|
||||
prep_dv(idx1, v1, n1);
|
||||
prep_dv(idx2, v2, n2);
|
||||
prep_dv(idx3, v3, n3);
|
||||
float32x4_t rc = sum0;
|
||||
|
||||
int32x4_t out, out2;
|
||||
out = vdupq_n_s32(0);
|
||||
single_compute_wrap<0>(n0, n1, n2, n3, 1.3437500f, rc, suma, out);
|
||||
single_compute_wrap<1>(n0, n2, n3, n1, 1.2812500f, rc, suma, out);
|
||||
single_compute_wrap<2>(n0, n3, n1, n2, 1.3593750f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n0, n3, n2, n1, 1.3671875f, rc, sumb, out);
|
||||
sum0 = vaddq_f32(suma, sumb);
|
||||
vst1q_s32(idx0, veorq_s32(v0, out));
|
||||
out2 = out;
|
||||
|
||||
out = vdupq_n_s32(0);
|
||||
single_compute_wrap<0>(n1, n0, n2, n3, 1.4296875f, rc, suma, out);
|
||||
single_compute_wrap<1>(n1, n2, n3, n0, 1.3984375f, rc, suma, out);
|
||||
single_compute_wrap<2>(n1, n3, n0, n2, 1.3828125f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n1, n3, n2, n0, 1.3046875f, rc, sumb, out);
|
||||
sum1 = vaddq_f32(suma, sumb);
|
||||
vst1q_s32(idx1, veorq_s32(v1, out));
|
||||
out2 = veorq_s32(out2, out);
|
||||
|
||||
out = vdupq_n_s32(0);
|
||||
single_compute_wrap<0>(n2, n1, n0, n3, 1.4140625f, rc, suma, out);
|
||||
single_compute_wrap<1>(n2, n0, n3, n1, 1.2734375f, rc, suma, out);
|
||||
single_compute_wrap<2>(n2, n3, n1, n0, 1.2578125f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n2, n3, n0, n1, 1.2890625f, rc, sumb, out);
|
||||
sum2 = vaddq_f32(suma, sumb);
|
||||
vst1q_s32(idx2, veorq_s32(v2, out));
|
||||
out2 = veorq_s32(out2, out);
|
||||
|
||||
out = vdupq_n_s32(0);
|
||||
single_compute_wrap<0>(n3, n1, n2, n0, 1.3203125f, rc, suma, out);
|
||||
single_compute_wrap<1>(n3, n2, n0, n1, 1.3515625f, rc, suma, out);
|
||||
single_compute_wrap<2>(n3, n0, n1, n2, 1.3359375f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n3, n0, n2, n1, 1.4609375f, rc, sumb, out);
|
||||
sum3 = vaddq_f32(suma, sumb);
|
||||
vst1q_s32(idx3, veorq_s32(v3, out));
|
||||
out2 = veorq_s32(out2, out);
|
||||
|
||||
sum0 = vaddq_f32(sum0, sum1);
|
||||
sum2 = vaddq_f32(sum2, sum3);
|
||||
sum0 = vaddq_f32(sum0, sum2);
|
||||
|
||||
const float32x4_t cc1 = vdupq_n_f32(16777216.0f);
|
||||
const float32x4_t cc2 = vdupq_n_f32(64.0f);
|
||||
vandq_f32(sum0, 0x7fffffff); // take abs(va) by masking the float sign bit
|
||||
// vs range 0 - 64
|
||||
n0 = vmulq_f32(sum0, cc1);
|
||||
v0 = vcvtq_s32_f32(n0);
|
||||
v0 = veorq_s32(v0, out2);
|
||||
uint32_t n = vheor_s32(v0);
|
||||
|
||||
// vs is now between 0 and 1
|
||||
sum0 = vdivq_f32(sum0, cc2);
|
||||
idx0 = scratchpad_ptr<MASK>(lpad, n, 0);
|
||||
idx1 = scratchpad_ptr<MASK>(lpad, n, 1);
|
||||
idx2 = scratchpad_ptr<MASK>(lpad, n, 2);
|
||||
idx3 = scratchpad_ptr<MASK>(lpad, n, 3);
|
||||
}
|
||||
}
|
||||
|
||||
template void cn_gpu_inner_arm<xmrig::CnAlgo<xmrig::Algorithm::CN_GPU>().iterations(), xmrig::CnAlgo<xmrig::Algorithm::CN_GPU>().mask()>(const uint8_t* spad, uint8_t* lpad);
|
211
src/crypto/cn/gpu/cn_gpu_avx.cpp
Normal file
211
src/crypto/cn/gpu/cn_gpu_avx.cpp
Normal file
|
@ -0,0 +1,211 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "crypto/cn/CnAlgo.h"
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
# include <x86intrin.h>
|
||||
#else
|
||||
# include <intrin.h>
|
||||
# define __restrict__ __restrict
|
||||
#endif
|
||||
#ifndef _mm256_bslli_epi128
|
||||
#define _mm256_bslli_epi128(a, count) _mm256_slli_si256((a), (count))
|
||||
#endif
|
||||
#ifndef _mm256_bsrli_epi128
|
||||
#define _mm256_bsrli_epi128(a, count) _mm256_srli_si256((a), (count))
|
||||
#endif
|
||||
|
||||
inline void prep_dv_avx(__m256i* idx, __m256i& v, __m256& n01)
|
||||
{
|
||||
v = _mm256_load_si256(idx);
|
||||
n01 = _mm256_cvtepi32_ps(v);
|
||||
}
|
||||
|
||||
inline __m256 fma_break(const __m256& x)
|
||||
{
|
||||
// Break the dependency chain by setting the exp to ?????01
|
||||
__m256 xx = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0xFEFFFFFF)), x);
|
||||
return _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x00800000)), xx);
|
||||
}
|
||||
|
||||
// 14
|
||||
inline void sub_round(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3, const __m256& rnd_c, __m256& n, __m256& d, __m256& c)
|
||||
{
|
||||
__m256 nn = _mm256_mul_ps(n0, c);
|
||||
nn = _mm256_mul_ps(_mm256_add_ps(n1, c), _mm256_mul_ps(nn, nn));
|
||||
nn = fma_break(nn);
|
||||
n = _mm256_add_ps(n, nn);
|
||||
|
||||
__m256 dd = _mm256_mul_ps(n2, c);
|
||||
dd = _mm256_mul_ps(_mm256_sub_ps(n3, c), _mm256_mul_ps(dd, dd));
|
||||
dd = fma_break(dd);
|
||||
d = _mm256_add_ps(d, dd);
|
||||
|
||||
//Constant feedback
|
||||
c = _mm256_add_ps(c, rnd_c);
|
||||
c = _mm256_add_ps(c, _mm256_set1_ps(0.734375f));
|
||||
__m256 r = _mm256_add_ps(nn, dd);
|
||||
r = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x807FFFFF)), r);
|
||||
r = _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)), r);
|
||||
c = _mm256_add_ps(c, r);
|
||||
}
|
||||
|
||||
// 14*8 + 2 = 112
|
||||
inline void round_compute(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3, const __m256& rnd_c, __m256& c, __m256& r)
|
||||
{
|
||||
__m256 n = _mm256_setzero_ps(), d = _mm256_setzero_ps();
|
||||
|
||||
sub_round(n0, n1, n2, n3, rnd_c, n, d, c);
|
||||
sub_round(n1, n2, n3, n0, rnd_c, n, d, c);
|
||||
sub_round(n2, n3, n0, n1, rnd_c, n, d, c);
|
||||
sub_round(n3, n0, n1, n2, rnd_c, n, d, c);
|
||||
sub_round(n3, n2, n1, n0, rnd_c, n, d, c);
|
||||
sub_round(n2, n1, n0, n3, rnd_c, n, d, c);
|
||||
sub_round(n1, n0, n3, n2, rnd_c, n, d, c);
|
||||
sub_round(n0, n3, n2, n1, rnd_c, n, d, c);
|
||||
|
||||
// Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0
|
||||
d = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0xFF7FFFFF)), d);
|
||||
d = _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)), d);
|
||||
r = _mm256_add_ps(r, _mm256_div_ps(n, d));
|
||||
}
|
||||
|
||||
// 112×4 = 448
|
||||
template <bool add>
|
||||
inline __m256i double_compute(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3,
|
||||
float lcnt, float hcnt, const __m256& rnd_c, __m256& sum)
|
||||
{
|
||||
__m256 c = _mm256_insertf128_ps(_mm256_castps128_ps256(_mm_set1_ps(lcnt)), _mm_set1_ps(hcnt), 1);
|
||||
__m256 r = _mm256_setzero_ps();
|
||||
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
|
||||
// do a quick fmod by setting exp to 2
|
||||
r = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x807FFFFF)), r);
|
||||
r = _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)), r);
|
||||
|
||||
if(add)
|
||||
sum = _mm256_add_ps(sum, r);
|
||||
else
|
||||
sum = r;
|
||||
|
||||
r = _mm256_mul_ps(r, _mm256_set1_ps(536870880.0f)); // 35
|
||||
return _mm256_cvttps_epi32(r);
|
||||
}
|
||||
|
||||
template <size_t rot>
|
||||
inline void double_compute_wrap(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3,
|
||||
float lcnt, float hcnt, const __m256& rnd_c, __m256& sum, __m256i& out)
|
||||
{
|
||||
__m256i r = double_compute<rot % 2 != 0>(n0, n1, n2, n3, lcnt, hcnt, rnd_c, sum);
|
||||
if(rot != 0)
|
||||
r = _mm256_or_si256(_mm256_bslli_epi128(r, 16 - rot), _mm256_bsrli_epi128(r, rot));
|
||||
|
||||
out = _mm256_xor_si256(out, r);
|
||||
}
|
||||
|
||||
template<uint32_t MASK>
|
||||
inline __m256i* scratchpad_ptr(uint8_t* lpad, uint32_t idx, size_t n) { return reinterpret_cast<__m256i*>(lpad + (idx & MASK) + n*16); }
|
||||
|
||||
template<size_t ITER, uint32_t MASK>
|
||||
void cn_gpu_inner_avx(const uint8_t* spad, uint8_t* lpad)
|
||||
{
|
||||
uint32_t s = reinterpret_cast<const uint32_t*>(spad)[0] >> 8;
|
||||
__m256i* idx0 = scratchpad_ptr<MASK>(lpad, s, 0);
|
||||
__m256i* idx2 = scratchpad_ptr<MASK>(lpad, s, 2);
|
||||
__m256 sum0 = _mm256_setzero_ps();
|
||||
|
||||
for(size_t i = 0; i < ITER; i++)
|
||||
{
|
||||
__m256i v01, v23;
|
||||
__m256 suma, sumb, sum1;
|
||||
__m256 rc = sum0;
|
||||
|
||||
__m256 n01, n23;
|
||||
prep_dv_avx(idx0, v01, n01);
|
||||
prep_dv_avx(idx2, v23, n23);
|
||||
|
||||
__m256i out, out2;
|
||||
__m256 n10, n22, n33;
|
||||
n10 = _mm256_permute2f128_ps(n01, n01, 0x01);
|
||||
n22 = _mm256_permute2f128_ps(n23, n23, 0x00);
|
||||
n33 = _mm256_permute2f128_ps(n23, n23, 0x11);
|
||||
|
||||
out = _mm256_setzero_si256();
|
||||
double_compute_wrap<0>(n01, n10, n22, n33, 1.3437500f, 1.4296875f, rc, suma, out);
|
||||
double_compute_wrap<1>(n01, n22, n33, n10, 1.2812500f, 1.3984375f, rc, suma, out);
|
||||
double_compute_wrap<2>(n01, n33, n10, n22, 1.3593750f, 1.3828125f, rc, sumb, out);
|
||||
double_compute_wrap<3>(n01, n33, n22, n10, 1.3671875f, 1.3046875f, rc, sumb, out);
|
||||
_mm256_store_si256(idx0, _mm256_xor_si256(v01, out));
|
||||
sum0 = _mm256_add_ps(suma, sumb);
|
||||
out2 = out;
|
||||
|
||||
__m256 n11, n02, n30;
|
||||
n11 = _mm256_permute2f128_ps(n01, n01, 0x11);
|
||||
n02 = _mm256_permute2f128_ps(n01, n23, 0x20);
|
||||
n30 = _mm256_permute2f128_ps(n01, n23, 0x03);
|
||||
|
||||
out = _mm256_setzero_si256();
|
||||
double_compute_wrap<0>(n23, n11, n02, n30, 1.4140625f, 1.3203125f, rc, suma, out);
|
||||
double_compute_wrap<1>(n23, n02, n30, n11, 1.2734375f, 1.3515625f, rc, suma, out);
|
||||
double_compute_wrap<2>(n23, n30, n11, n02, 1.2578125f, 1.3359375f, rc, sumb, out);
|
||||
double_compute_wrap<3>(n23, n30, n02, n11, 1.2890625f, 1.4609375f, rc, sumb, out);
|
||||
_mm256_store_si256(idx2, _mm256_xor_si256(v23, out));
|
||||
sum1 = _mm256_add_ps(suma, sumb);
|
||||
|
||||
out2 = _mm256_xor_si256(out2, out);
|
||||
out2 = _mm256_xor_si256(_mm256_permute2x128_si256(out2,out2,0x41), out2);
|
||||
suma = _mm256_permute2f128_ps(sum0, sum1, 0x30);
|
||||
sumb = _mm256_permute2f128_ps(sum0, sum1, 0x21);
|
||||
sum0 = _mm256_add_ps(suma, sumb);
|
||||
sum0 = _mm256_add_ps(sum0, _mm256_permute2f128_ps(sum0, sum0, 0x41));
|
||||
|
||||
// Clear the high 128 bits
|
||||
__m128 sum = _mm256_castps256_ps128(sum0);
|
||||
|
||||
sum = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)), sum); // take abs(va) by masking the float sign bit
|
||||
// vs range 0 - 64
|
||||
__m128i v0 = _mm_cvttps_epi32(_mm_mul_ps(sum, _mm_set1_ps(16777216.0f)));
|
||||
v0 = _mm_xor_si128(v0, _mm256_castsi256_si128(out2));
|
||||
__m128i v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 2, 3));
|
||||
v0 = _mm_xor_si128(v0, v1);
|
||||
v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 0, 1));
|
||||
v0 = _mm_xor_si128(v0, v1);
|
||||
|
||||
// vs is now between 0 and 1
|
||||
sum = _mm_div_ps(sum, _mm_set1_ps(64.0f));
|
||||
sum0 = _mm256_insertf128_ps(_mm256_castps128_ps256(sum), sum, 1);
|
||||
uint32_t n = _mm_cvtsi128_si32(v0);
|
||||
idx0 = scratchpad_ptr<MASK>(lpad, n, 0);
|
||||
idx2 = scratchpad_ptr<MASK>(lpad, n, 2);
|
||||
}
|
||||
}
|
||||
|
||||
template void cn_gpu_inner_avx<xmrig::CnAlgo<xmrig::Algorithm::CN_GPU>().iterations(), xmrig::CnAlgo<xmrig::Algorithm::CN_GPU>().mask()>(const uint8_t* spad, uint8_t* lpad);
|
212
src/crypto/cn/gpu/cn_gpu_ssse3.cpp
Normal file
212
src/crypto/cn/gpu/cn_gpu_ssse3.cpp
Normal file
|
@ -0,0 +1,212 @@
|
|||
/* XMRig
|
||||
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
|
||||
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
|
||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include "crypto/cn/CnAlgo.h"
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
# include <x86intrin.h>
|
||||
#else
|
||||
# include <intrin.h>
|
||||
# define __restrict__ __restrict
|
||||
#endif
|
||||
|
||||
inline void prep_dv(__m128i* idx, __m128i& v, __m128& n)
|
||||
{
|
||||
v = _mm_load_si128(idx);
|
||||
n = _mm_cvtepi32_ps(v);
|
||||
}
|
||||
|
||||
inline __m128 fma_break(__m128 x)
|
||||
{
|
||||
// Break the dependency chain by setting the exp to ?????01
|
||||
x = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0xFEFFFFFF)), x);
|
||||
return _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x00800000)), x);
|
||||
}
|
||||
|
||||
// 14
|
||||
inline void sub_round(__m128 n0, __m128 n1, __m128 n2, __m128 n3, __m128 rnd_c, __m128& n, __m128& d, __m128& c)
|
||||
{
|
||||
n1 = _mm_add_ps(n1, c);
|
||||
__m128 nn = _mm_mul_ps(n0, c);
|
||||
nn = _mm_mul_ps(n1, _mm_mul_ps(nn,nn));
|
||||
nn = fma_break(nn);
|
||||
n = _mm_add_ps(n, nn);
|
||||
|
||||
n3 = _mm_sub_ps(n3, c);
|
||||
__m128 dd = _mm_mul_ps(n2, c);
|
||||
dd = _mm_mul_ps(n3, _mm_mul_ps(dd,dd));
|
||||
dd = fma_break(dd);
|
||||
d = _mm_add_ps(d, dd);
|
||||
|
||||
//Constant feedback
|
||||
c = _mm_add_ps(c, rnd_c);
|
||||
c = _mm_add_ps(c, _mm_set1_ps(0.734375f));
|
||||
__m128 r = _mm_add_ps(nn, dd);
|
||||
r = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF)), r);
|
||||
r = _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x40000000)), r);
|
||||
c = _mm_add_ps(c, r);
|
||||
}
|
||||
|
||||
// 14*8 + 2 = 112
|
||||
inline void round_compute(__m128 n0, __m128 n1, __m128 n2, __m128 n3, __m128 rnd_c, __m128& c, __m128& r)
|
||||
{
|
||||
__m128 n = _mm_setzero_ps(), d = _mm_setzero_ps();
|
||||
|
||||
sub_round(n0, n1, n2, n3, rnd_c, n, d, c);
|
||||
sub_round(n1, n2, n3, n0, rnd_c, n, d, c);
|
||||
sub_round(n2, n3, n0, n1, rnd_c, n, d, c);
|
||||
sub_round(n3, n0, n1, n2, rnd_c, n, d, c);
|
||||
sub_round(n3, n2, n1, n0, rnd_c, n, d, c);
|
||||
sub_round(n2, n1, n0, n3, rnd_c, n, d, c);
|
||||
sub_round(n1, n0, n3, n2, rnd_c, n, d, c);
|
||||
sub_round(n0, n3, n2, n1, rnd_c, n, d, c);
|
||||
|
||||
// Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0
|
||||
d = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0xFF7FFFFF)), d);
|
||||
d = _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x40000000)), d);
|
||||
r =_mm_add_ps(r, _mm_div_ps(n,d));
|
||||
}
|
||||
|
||||
// 112×4 = 448
|
||||
template<bool add>
|
||||
inline __m128i single_compute(__m128 n0, __m128 n1, __m128 n2, __m128 n3, float cnt, __m128 rnd_c, __m128& sum)
|
||||
{
|
||||
__m128 c = _mm_set1_ps(cnt);
|
||||
__m128 r = _mm_setzero_ps();
|
||||
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
round_compute(n0, n1, n2, n3, rnd_c, c, r);
|
||||
|
||||
// do a quick fmod by setting exp to 2
|
||||
r = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF)), r);
|
||||
r = _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x40000000)), r);
|
||||
|
||||
if(add)
|
||||
sum = _mm_add_ps(sum, r);
|
||||
else
|
||||
sum = r;
|
||||
|
||||
r = _mm_mul_ps(r, _mm_set1_ps(536870880.0f)); // 35
|
||||
return _mm_cvttps_epi32(r);
|
||||
}
|
||||
|
||||
template<size_t rot>
|
||||
inline void single_compute_wrap(__m128 n0, __m128 n1, __m128 n2, __m128 n3, float cnt, __m128 rnd_c, __m128& sum, __m128i& out)
|
||||
{
|
||||
__m128i r = single_compute<rot % 2 != 0>(n0, n1, n2, n3, cnt, rnd_c, sum);
|
||||
if(rot != 0)
|
||||
r = _mm_or_si128(_mm_slli_si128(r, 16 - rot), _mm_srli_si128(r, rot));
|
||||
out = _mm_xor_si128(out, r);
|
||||
}
|
||||
|
||||
template<uint32_t MASK>
|
||||
inline __m128i* scratchpad_ptr(uint8_t* lpad, uint32_t idx, size_t n) { return reinterpret_cast<__m128i*>(lpad + (idx & MASK) + n*16); }
|
||||
|
||||
template<size_t ITER, uint32_t MASK>
|
||||
void cn_gpu_inner_ssse3(const uint8_t* spad, uint8_t* lpad)
|
||||
{
|
||||
uint32_t s = reinterpret_cast<const uint32_t*>(spad)[0] >> 8;
|
||||
__m128i* idx0 = scratchpad_ptr<MASK>(lpad, s, 0);
|
||||
__m128i* idx1 = scratchpad_ptr<MASK>(lpad, s, 1);
|
||||
__m128i* idx2 = scratchpad_ptr<MASK>(lpad, s, 2);
|
||||
__m128i* idx3 = scratchpad_ptr<MASK>(lpad, s, 3);
|
||||
__m128 sum0 = _mm_setzero_ps();
|
||||
|
||||
for(size_t i = 0; i < ITER; i++)
|
||||
{
|
||||
__m128 n0, n1, n2, n3;
|
||||
__m128i v0, v1, v2, v3;
|
||||
__m128 suma, sumb, sum1, sum2, sum3;
|
||||
|
||||
prep_dv(idx0, v0, n0);
|
||||
prep_dv(idx1, v1, n1);
|
||||
prep_dv(idx2, v2, n2);
|
||||
prep_dv(idx3, v3, n3);
|
||||
__m128 rc = sum0;
|
||||
|
||||
__m128i out, out2;
|
||||
out = _mm_setzero_si128();
|
||||
single_compute_wrap<0>(n0, n1, n2, n3, 1.3437500f, rc, suma, out);
|
||||
single_compute_wrap<1>(n0, n2, n3, n1, 1.2812500f, rc, suma, out);
|
||||
single_compute_wrap<2>(n0, n3, n1, n2, 1.3593750f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n0, n3, n2, n1, 1.3671875f, rc, sumb, out);
|
||||
sum0 = _mm_add_ps(suma, sumb);
|
||||
_mm_store_si128(idx0, _mm_xor_si128(v0, out));
|
||||
out2 = out;
|
||||
|
||||
out = _mm_setzero_si128();
|
||||
single_compute_wrap<0>(n1, n0, n2, n3, 1.4296875f, rc, suma, out);
|
||||
single_compute_wrap<1>(n1, n2, n3, n0, 1.3984375f, rc, suma, out);
|
||||
single_compute_wrap<2>(n1, n3, n0, n2, 1.3828125f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n1, n3, n2, n0, 1.3046875f, rc, sumb, out);
|
||||
sum1 = _mm_add_ps(suma, sumb);
|
||||
_mm_store_si128(idx1, _mm_xor_si128(v1, out));
|
||||
out2 = _mm_xor_si128(out2, out);
|
||||
|
||||
out = _mm_setzero_si128();
|
||||
single_compute_wrap<0>(n2, n1, n0, n3, 1.4140625f, rc, suma, out);
|
||||
single_compute_wrap<1>(n2, n0, n3, n1, 1.2734375f, rc, suma, out);
|
||||
single_compute_wrap<2>(n2, n3, n1, n0, 1.2578125f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n2, n3, n0, n1, 1.2890625f, rc, sumb, out);
|
||||
sum2 = _mm_add_ps(suma, sumb);
|
||||
_mm_store_si128(idx2, _mm_xor_si128(v2, out));
|
||||
out2 = _mm_xor_si128(out2, out);
|
||||
|
||||
out = _mm_setzero_si128();
|
||||
single_compute_wrap<0>(n3, n1, n2, n0, 1.3203125f, rc, suma, out);
|
||||
single_compute_wrap<1>(n3, n2, n0, n1, 1.3515625f, rc, suma, out);
|
||||
single_compute_wrap<2>(n3, n0, n1, n2, 1.3359375f, rc, sumb, out);
|
||||
single_compute_wrap<3>(n3, n0, n2, n1, 1.4609375f, rc, sumb, out);
|
||||
sum3 = _mm_add_ps(suma, sumb);
|
||||
_mm_store_si128(idx3, _mm_xor_si128(v3, out));
|
||||
out2 = _mm_xor_si128(out2, out);
|
||||
sum0 = _mm_add_ps(sum0, sum1);
|
||||
sum2 = _mm_add_ps(sum2, sum3);
|
||||
sum0 = _mm_add_ps(sum0, sum2);
|
||||
|
||||
sum0 = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)), sum0); // take abs(va) by masking the float sign bit
|
||||
// vs range 0 - 64
|
||||
n0 = _mm_mul_ps(sum0, _mm_set1_ps(16777216.0f));
|
||||
v0 = _mm_cvttps_epi32(n0);
|
||||
v0 = _mm_xor_si128(v0, out2);
|
||||
v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 2, 3));
|
||||
v0 = _mm_xor_si128(v0, v1);
|
||||
v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 0, 1));
|
||||
v0 = _mm_xor_si128(v0, v1);
|
||||
|
||||
// vs is now between 0 and 1
|
||||
sum0 = _mm_div_ps(sum0, _mm_set1_ps(64.0f));
|
||||
uint32_t n = _mm_cvtsi128_si32(v0);
|
||||
idx0 = scratchpad_ptr<MASK>(lpad, n, 0);
|
||||
idx1 = scratchpad_ptr<MASK>(lpad, n, 1);
|
||||
idx2 = scratchpad_ptr<MASK>(lpad, n, 2);
|
||||
idx3 = scratchpad_ptr<MASK>(lpad, n, 3);
|
||||
}
|
||||
}
|
||||
|
||||
template void cn_gpu_inner_ssse3<xmrig::CnAlgo<xmrig::Algorithm::CN_GPU>().iterations(), xmrig::CnAlgo<xmrig::Algorithm::CN_GPU>().mask()>(const uint8_t* spad, uint8_t* lpad);
|
|
@ -47,11 +47,11 @@ xmrig::MemoryPool::MemoryPool(size_t size, bool hugePages, uint32_t node)
|
|||
return;
|
||||
}
|
||||
|
||||
constexpr size_t alignment = 1 << 24;
|
||||
constexpr size_t alignment = 0; //1 << 24;
|
||||
|
||||
m_memory = new VirtualMemory(size * pageSize + alignment, hugePages, false, false, node);
|
||||
|
||||
m_alignOffset = (alignment - (((size_t)m_memory->scratchpad()) % alignment)) % alignment;
|
||||
//m_alignOffset = (alignment - (((size_t)m_memory->scratchpad()) % alignment)) % alignment;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
mov rsi, rdx ;# uint8_t* scratchpad
|
||||
|
||||
mov rax, rbp
|
||||
ror rbp, 32
|
||||
|
||||
;# zero integer registers
|
||||
xor r8, r8
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
mov rbx, r9 ;# loop counter
|
||||
|
||||
mov rax, rbp
|
||||
ror rbp, 32
|
||||
|
||||
;# zero integer registers
|
||||
xor r8, r8
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
mov ecx, ebp ;# ecx = ma
|
||||
and ecx, RANDOMX_DATASET_BASE_MASK
|
||||
xor r8, qword ptr [rdi+rcx]
|
||||
ror rbp, 32 ;# swap "ma" and "mx"
|
||||
xor rbp, rax ;# modify "mx"
|
||||
mov edx, ebp ;# edx = mx
|
||||
and edx, RANDOMX_DATASET_BASE_MASK
|
||||
prefetchnta byte ptr [rdi+rdx]
|
||||
xor r9, qword ptr [rdi+rcx+8]
|
||||
xor r10, qword ptr [rdi+rcx+16]
|
||||
xor r11, qword ptr [rdi+rcx+24]
|
||||
xor r12, qword ptr [rdi+rcx+32]
|
||||
xor r13, qword ptr [rdi+rcx+40]
|
||||
xor r14, qword ptr [rdi+rcx+48]
|
||||
xor r15, qword ptr [rdi+rcx+56]
|
||||
ror rbp, 32 ;# swap "ma" and "mx"
|
||||
mov edx, ebp ;# edx = ma
|
||||
and edx, RANDOMX_DATASET_BASE_MASK
|
||||
lea rcx, [rdi+rdx] ;# dataset cache line
|
||||
xor r8, qword ptr [rcx+0]
|
||||
xor r9, qword ptr [rcx+8]
|
||||
xor r10, qword ptr [rcx+16]
|
||||
xor r11, qword ptr [rcx+24]
|
||||
xor r12, qword ptr [rcx+32]
|
||||
xor r13, qword ptr [rcx+40]
|
||||
xor r14, qword ptr [rcx+48]
|
||||
xor r15, qword ptr [rcx+56]
|
||||
|
17
src/crypto/randomx/asm/program_read_dataset_ryzen.inc
Normal file
17
src/crypto/randomx/asm/program_read_dataset_ryzen.inc
Normal file
|
@ -0,0 +1,17 @@
|
|||
mov rcx, rbp ;# ecx = ma
|
||||
shr rcx, 32
|
||||
and ecx, RANDOMX_DATASET_BASE_MASK
|
||||
xor r8, qword ptr [rdi+rcx]
|
||||
xor rbp, rax ;# modify "mx"
|
||||
mov edx, ebp ;# edx = mx
|
||||
and edx, RANDOMX_DATASET_BASE_MASK
|
||||
prefetchnta byte ptr [rdi+rdx]
|
||||
ror rbp, 32 ;# swap "ma" and "mx"
|
||||
xor r9, qword ptr [rdi+rcx+8]
|
||||
xor r10, qword ptr [rdi+rcx+16]
|
||||
xor r11, qword ptr [rdi+rcx+24]
|
||||
xor r12, qword ptr [rdi+rcx+32]
|
||||
xor r13, qword ptr [rdi+rcx+40]
|
||||
xor r14, qword ptr [rdi+rcx+48]
|
||||
xor r15, qword ptr [rdi+rcx+56]
|
||||
|
|
@ -74,7 +74,7 @@ namespace randomx {
|
|||
constexpr int SuperscalarMaxSize = 3 * RANDOMX_SUPERSCALAR_MAX_LATENCY + 2;
|
||||
constexpr size_t CacheLineSize = RANDOMX_DATASET_ITEM_SIZE;
|
||||
#define ScratchpadSize RandomX_CurrentConfig.ScratchpadL3_Size
|
||||
#define CacheLineAlignMask RandomX_ConfigurationBase::CacheLineAlignMask_Calculated
|
||||
#define CacheLineAlignMask RandomX_CurrentConfig.CacheLineAlignMask_Calculated
|
||||
#define DatasetExtraItems RandomX_ConfigurationBase::DatasetExtraItems_Calculated
|
||||
constexpr int StoreL3Condition = 14;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ static size_t CalcDatasetItemSize()
|
|||
// Prologue
|
||||
((uint8_t*)randomx_calc_dataset_item_aarch64_prefetch - (uint8_t*)randomx_calc_dataset_item_aarch64) +
|
||||
// Main loop
|
||||
RandomX_ConfigurationBase::CacheAccesses * (
|
||||
RandomX_CurrentConfig.CacheAccesses * (
|
||||
// Main loop prologue
|
||||
((uint8_t*)randomx_calc_dataset_item_aarch64_mix - ((uint8_t*)randomx_calc_dataset_item_aarch64_prefetch)) + 4 +
|
||||
// Inner main loop (instructions)
|
||||
|
@ -263,7 +263,7 @@ void JitCompilerA64::generateSuperscalarHash(SuperscalarProgram(&programs)[N])
|
|||
num32bitLiterals = 64;
|
||||
constexpr uint32_t tmp_reg = 12;
|
||||
|
||||
for (size_t i = 0; i < RandomX_ConfigurationBase::CacheAccesses; ++i)
|
||||
for (size_t i = 0; i < RandomX_CurrentConfig.CacheAccesses; ++i)
|
||||
{
|
||||
// and x11, x10, CacheSize / CacheLineSize - 1
|
||||
emit32(0x92400000 | 11 | (10 << 5) | ((RandomX_CurrentConfig.Log2_CacheSize - 1) << 10), code, codePos);
|
||||
|
|
|
@ -115,7 +115,6 @@ namespace randomx {
|
|||
#define codeLoopLoad ADDR(randomx_program_loop_load)
|
||||
#define codeLoopLoadXOP ADDR(randomx_program_loop_load_xop)
|
||||
#define codeProgamStart ADDR(randomx_program_start)
|
||||
#define codeReadDataset ADDR(randomx_program_read_dataset)
|
||||
#define codeReadDatasetLightSshInit ADDR(randomx_program_read_dataset_sshash_init)
|
||||
#define codeReadDatasetLightSshFin ADDR(randomx_program_read_dataset_sshash_fin)
|
||||
#define codeDatasetInit ADDR(randomx_dataset_init)
|
||||
|
@ -136,7 +135,6 @@ namespace randomx {
|
|||
#define prologueSize (codeLoopBegin - codePrologue)
|
||||
#define loopLoadSize (codeLoopLoadXOP - codeLoopLoad)
|
||||
#define loopLoadXOPSize (codeProgamStart - codeLoopLoadXOP)
|
||||
#define readDatasetSize (codeReadDatasetLightSshInit - codeReadDataset)
|
||||
#define readDatasetLightInitSize (codeReadDatasetLightSshFin - codeReadDatasetLightSshInit)
|
||||
#define readDatasetLightFinSize (codeLoopStore - codeReadDatasetLightSshFin)
|
||||
#define loopStoreSize (codeLoopEnd - codeLoopStore)
|
||||
|
@ -320,7 +318,20 @@ namespace randomx {
|
|||
vm_flags = flags;
|
||||
|
||||
generateProgramPrologue(prog, pcfg);
|
||||
emit(codeReadDataset, readDatasetSize, code, codePos);
|
||||
|
||||
uint8_t* p;
|
||||
uint32_t n;
|
||||
if (flags & RANDOMX_FLAG_AMD) {
|
||||
p = RandomX_CurrentConfig.codeReadDatasetRyzenTweaked;
|
||||
n = RandomX_CurrentConfig.codeReadDatasetRyzenTweakedSize;
|
||||
}
|
||||
else {
|
||||
p = RandomX_CurrentConfig.codeReadDatasetTweaked;
|
||||
n = RandomX_CurrentConfig.codeReadDatasetTweakedSize;
|
||||
}
|
||||
memcpy(code + codePos, p, n);
|
||||
codePos += n;
|
||||
|
||||
generateProgramEpilogue(prog, pcfg);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
.global DECL(randomx_program_loop_load_xop)
|
||||
.global DECL(randomx_program_start)
|
||||
.global DECL(randomx_program_read_dataset)
|
||||
.global DECL(randomx_program_read_dataset_ryzen)
|
||||
.global DECL(randomx_program_read_dataset_sshash_init)
|
||||
.global DECL(randomx_program_read_dataset_sshash_fin)
|
||||
.global DECL(randomx_program_loop_store)
|
||||
|
@ -139,6 +140,9 @@ DECL(randomx_program_start):
|
|||
DECL(randomx_program_read_dataset):
|
||||
#include "asm/program_read_dataset.inc"
|
||||
|
||||
DECL(randomx_program_read_dataset_ryzen):
|
||||
#include "asm/program_read_dataset_ryzen.inc"
|
||||
|
||||
DECL(randomx_program_read_dataset_sshash_init):
|
||||
#include "asm/program_read_dataset_sshash_init.inc"
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ PUBLIC randomx_program_loop_load
|
|||
PUBLIC randomx_program_loop_load_xop
|
||||
PUBLIC randomx_program_start
|
||||
PUBLIC randomx_program_read_dataset
|
||||
PUBLIC randomx_program_read_dataset_ryzen
|
||||
PUBLIC randomx_program_read_dataset_sshash_init
|
||||
PUBLIC randomx_program_read_dataset_sshash_fin
|
||||
PUBLIC randomx_dataset_init
|
||||
|
@ -135,6 +136,10 @@ randomx_program_read_dataset PROC
|
|||
include asm/program_read_dataset.inc
|
||||
randomx_program_read_dataset ENDP
|
||||
|
||||
randomx_program_read_dataset_ryzen PROC
|
||||
include asm/program_read_dataset_ryzen.inc
|
||||
randomx_program_read_dataset_ryzen ENDP
|
||||
|
||||
randomx_program_read_dataset_sshash_init PROC
|
||||
include asm/program_read_dataset_sshash_init.inc
|
||||
randomx_program_read_dataset_sshash_init ENDP
|
||||
|
|
|
@ -40,6 +40,7 @@ extern "C" {
|
|||
void randomx_program_loop_load_xop();
|
||||
void randomx_program_start();
|
||||
void randomx_program_read_dataset();
|
||||
void randomx_program_read_dataset_ryzen();
|
||||
void randomx_program_read_dataset_sshash_init();
|
||||
void randomx_program_read_dataset_sshash_fin();
|
||||
void randomx_program_loop_store();
|
||||
|
|
271
src/crypto/randomx/panthera/KangarooTwelve.c
Normal file
271
src/crypto/randomx/panthera/KangarooTwelve.c
Normal file
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "KangarooTwelve.h"
|
||||
#ifndef KeccakP1600timesN_excluded
|
||||
// #include "KeccakP-1600-times2-SnP.h"
|
||||
// #include "KeccakP-1600-times4-SnP.h"
|
||||
// #include "KeccakP-1600-times8-SnP.h"
|
||||
#endif
|
||||
|
||||
#define chunkSize 8192
|
||||
#define laneSize 8
|
||||
#define suffixLeaf 0x0B /* '110': message hop, simple padding, inner node */
|
||||
|
||||
#define security 128
|
||||
#define capacity (2*security)
|
||||
#define capacityInBytes (capacity/8)
|
||||
#define capacityInLanes (capacityInBytes/laneSize)
|
||||
#define rate (1600-capacity)
|
||||
#define rateInBytes (rate/8)
|
||||
#define rateInLanes (rateInBytes/laneSize)
|
||||
|
||||
#define ParallelSpongeFastLoop( Parallellism ) \
|
||||
while ( inLen >= Parallellism * chunkSize ) { \
|
||||
ALIGN(KeccakP1600times##Parallellism##_statesAlignment) unsigned char states[KeccakP1600times##Parallellism##_statesSizeInBytes]; \
|
||||
unsigned char intermediate[Parallellism*capacityInBytes]; \
|
||||
unsigned int localBlockLen = chunkSize; \
|
||||
const unsigned char * localInput = input; \
|
||||
unsigned int i; \
|
||||
unsigned int fastLoopOffset; \
|
||||
\
|
||||
KeccakP1600times##Parallellism##_StaticInitialize(); \
|
||||
KeccakP1600times##Parallellism##_InitializeAll(states); \
|
||||
fastLoopOffset = KeccakP1600times##Parallellism##_12rounds_FastLoop_Absorb(states, rateInLanes, chunkSize / laneSize, rateInLanes, localInput, Parallellism * chunkSize); \
|
||||
localBlockLen -= fastLoopOffset; \
|
||||
localInput += fastLoopOffset; \
|
||||
for ( i = 0; i < Parallellism; ++i, localInput += chunkSize ) { \
|
||||
KeccakP1600times##Parallellism##_AddBytes(states, i, localInput, 0, localBlockLen); \
|
||||
KeccakP1600times##Parallellism##_AddByte(states, i, suffixLeaf, localBlockLen); \
|
||||
KeccakP1600times##Parallellism##_AddByte(states, i, 0x80, rateInBytes-1); \
|
||||
} \
|
||||
KeccakP1600times##Parallellism##_PermuteAll_12rounds(states); \
|
||||
input += Parallellism * chunkSize; \
|
||||
inLen -= Parallellism * chunkSize; \
|
||||
ktInstance->blockNumber += Parallellism; \
|
||||
KeccakP1600times##Parallellism##_ExtractLanesAll(states, intermediate, capacityInLanes, capacityInLanes ); \
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
|
||||
}
|
||||
|
||||
#define ParallelSpongeLoop( Parallellism ) \
|
||||
while ( inLen >= Parallellism * chunkSize ) { \
|
||||
ALIGN(KeccakP1600times##Parallellism##_statesAlignment) unsigned char states[KeccakP1600times##Parallellism##_statesSizeInBytes]; \
|
||||
unsigned char intermediate[Parallellism*capacityInBytes]; \
|
||||
unsigned int localBlockLen = chunkSize; \
|
||||
const unsigned char * localInput = input; \
|
||||
unsigned int i; \
|
||||
\
|
||||
KeccakP1600times##Parallellism##_StaticInitialize(); \
|
||||
KeccakP1600times##Parallellism##_InitializeAll(states); \
|
||||
while(localBlockLen >= rateInBytes) { \
|
||||
KeccakP1600times##Parallellism##_AddLanesAll(states, localInput, rateInLanes, chunkSize / laneSize); \
|
||||
KeccakP1600times##Parallellism##_PermuteAll_12rounds(states); \
|
||||
localBlockLen -= rateInBytes; \
|
||||
localInput += rateInBytes; \
|
||||
} \
|
||||
for ( i = 0; i < Parallellism; ++i, localInput += chunkSize ) { \
|
||||
KeccakP1600times##Parallellism##_AddBytes(states, i, localInput, 0, localBlockLen); \
|
||||
KeccakP1600times##Parallellism##_AddByte(states, i, suffixLeaf, localBlockLen); \
|
||||
KeccakP1600times##Parallellism##_AddByte(states, i, 0x80, rateInBytes-1); \
|
||||
} \
|
||||
KeccakP1600times##Parallellism##_PermuteAll_12rounds(states); \
|
||||
input += Parallellism * chunkSize; \
|
||||
inLen -= Parallellism * chunkSize; \
|
||||
ktInstance->blockNumber += Parallellism; \
|
||||
KeccakP1600times##Parallellism##_ExtractLanesAll(states, intermediate, capacityInLanes, capacityInLanes ); \
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, Parallellism * capacityInBytes) != 0) return 1; \
|
||||
}
|
||||
|
||||
static unsigned int right_encode( unsigned char * encbuf, size_t value )
|
||||
{
|
||||
unsigned int n, i;
|
||||
size_t v;
|
||||
|
||||
for ( v = value, n = 0; v && (n < sizeof(size_t)); ++n, v >>= 8 )
|
||||
; /* empty */
|
||||
for ( i = 1; i <= n; ++i )
|
||||
encbuf[i-1] = (unsigned char)(value >> (8 * (n-i)));
|
||||
encbuf[n] = (unsigned char)n;
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
int KangarooTwelve_Initialize(KangarooTwelve_Instance *ktInstance, size_t outputLen)
|
||||
{
|
||||
ktInstance->fixedOutputLength = outputLen;
|
||||
ktInstance->queueAbsorbedLen = 0;
|
||||
ktInstance->blockNumber = 0;
|
||||
ktInstance->phase = ABSORBING;
|
||||
return KeccakWidth1600_12rounds_SpongeInitialize(&ktInstance->finalNode, rate, capacity);
|
||||
}
|
||||
|
||||
int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned char *input, size_t inLen)
|
||||
{
|
||||
if (ktInstance->phase != ABSORBING)
|
||||
return 1;
|
||||
|
||||
if ( ktInstance->blockNumber == 0 ) {
|
||||
/* First block, absorb in final node */
|
||||
unsigned int len = (inLen < (chunkSize - ktInstance->queueAbsorbedLen)) ? inLen : (chunkSize - ktInstance->queueAbsorbedLen);
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, input, len) != 0)
|
||||
return 1;
|
||||
input += len;
|
||||
inLen -= len;
|
||||
ktInstance->queueAbsorbedLen += len;
|
||||
if ( (ktInstance->queueAbsorbedLen == chunkSize) && (inLen != 0) ) {
|
||||
/* First block complete and more input data available, finalize it */
|
||||
const unsigned char padding = 0x03; /* '110^6': message hop, simple padding */
|
||||
ktInstance->queueAbsorbedLen = 0;
|
||||
ktInstance->blockNumber = 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, &padding, 1) != 0)
|
||||
return 1;
|
||||
ktInstance->finalNode.byteIOIndex = (ktInstance->finalNode.byteIOIndex + 7) & ~7; /* Zero padding up to 64 bits */
|
||||
}
|
||||
}
|
||||
else if ( ktInstance->queueAbsorbedLen != 0 ) {
|
||||
/* There is data in the queue, absorb further in queue until block complete */
|
||||
unsigned int len = (inLen < (chunkSize - ktInstance->queueAbsorbedLen)) ? inLen : (chunkSize - ktInstance->queueAbsorbedLen);
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->queueNode, input, len) != 0)
|
||||
return 1;
|
||||
input += len;
|
||||
inLen -= len;
|
||||
ktInstance->queueAbsorbedLen += len;
|
||||
if ( ktInstance->queueAbsorbedLen == chunkSize ) {
|
||||
unsigned char intermediate[capacityInBytes];
|
||||
ktInstance->queueAbsorbedLen = 0;
|
||||
++ktInstance->blockNumber;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(KeccakP1600times8_implementation) && !defined(KeccakP1600times8_isFallback)
|
||||
#if defined(KeccakP1600times8_12rounds_FastLoop_supported)
|
||||
ParallelSpongeFastLoop( 8 )
|
||||
#else
|
||||
ParallelSpongeLoop( 8 )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(KeccakP1600times4_implementation) && !defined(KeccakP1600times4_isFallback)
|
||||
#if defined(KeccakP1600times4_12rounds_FastLoop_supported)
|
||||
ParallelSpongeFastLoop( 4 )
|
||||
#else
|
||||
ParallelSpongeLoop( 4 )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(KeccakP1600times2_implementation) && !defined(KeccakP1600times2_isFallback)
|
||||
#if defined(KeccakP1600times2_12rounds_FastLoop_supported)
|
||||
ParallelSpongeFastLoop( 2 )
|
||||
#else
|
||||
ParallelSpongeLoop( 2 )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
while ( inLen > 0 ) {
|
||||
unsigned int len = (inLen < chunkSize) ? inLen : chunkSize;
|
||||
if (KeccakWidth1600_12rounds_SpongeInitialize(&ktInstance->queueNode, rate, capacity) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->queueNode, input, len) != 0)
|
||||
return 1;
|
||||
input += len;
|
||||
inLen -= len;
|
||||
if ( len == chunkSize ) {
|
||||
unsigned char intermediate[capacityInBytes];
|
||||
++ktInstance->blockNumber;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
ktInstance->queueAbsorbedLen = len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int KangarooTwelve_Final(KangarooTwelve_Instance *ktInstance, unsigned char * output, const unsigned char * customization, size_t customLen)
|
||||
{
|
||||
unsigned char encbuf[sizeof(size_t)+1+2];
|
||||
unsigned char padding;
|
||||
|
||||
if (ktInstance->phase != ABSORBING)
|
||||
return 1;
|
||||
|
||||
/* Absorb customization | right_encode(customLen) */
|
||||
if ((customLen != 0) && (KangarooTwelve_Update(ktInstance, customization, customLen) != 0))
|
||||
return 1;
|
||||
if (KangarooTwelve_Update(ktInstance, encbuf, right_encode(encbuf, customLen)) != 0)
|
||||
return 1;
|
||||
|
||||
if ( ktInstance->blockNumber == 0 ) {
|
||||
/* Non complete first block in final node, pad it */
|
||||
padding = 0x07; /* '11': message hop, final node */
|
||||
}
|
||||
else {
|
||||
unsigned int n;
|
||||
|
||||
if ( ktInstance->queueAbsorbedLen != 0 ) {
|
||||
/* There is data in the queue node */
|
||||
unsigned char intermediate[capacityInBytes];
|
||||
++ktInstance->blockNumber;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->queueNode, suffixLeaf) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->queueNode, intermediate, capacityInBytes) != 0)
|
||||
return 1;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, intermediate, capacityInBytes) != 0)
|
||||
return 1;
|
||||
}
|
||||
--ktInstance->blockNumber; /* Absorb right_encode(number of Chaining Values) || 0xFF || 0xFF */
|
||||
n = right_encode(encbuf, ktInstance->blockNumber);
|
||||
encbuf[n++] = 0xFF;
|
||||
encbuf[n++] = 0xFF;
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorb(&ktInstance->finalNode, encbuf, n) != 0)
|
||||
return 1;
|
||||
padding = 0x06; /* '01': chaining hop, final node */
|
||||
}
|
||||
if (KeccakWidth1600_12rounds_SpongeAbsorbLastFewBits(&ktInstance->finalNode, padding) != 0)
|
||||
return 1;
|
||||
if ( ktInstance->fixedOutputLength != 0 ) {
|
||||
ktInstance->phase = FINAL;
|
||||
return KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->finalNode, output, ktInstance->fixedOutputLength);
|
||||
}
|
||||
ktInstance->phase = SQUEEZING;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int KangarooTwelve_Squeeze(KangarooTwelve_Instance *ktInstance, unsigned char * output, size_t outputLen)
|
||||
{
|
||||
if (ktInstance->phase != SQUEEZING)
|
||||
return 1;
|
||||
return KeccakWidth1600_12rounds_SpongeSqueeze(&ktInstance->finalNode, output, outputLen);
|
||||
}
|
||||
|
||||
int KangarooTwelve( const unsigned char * input, size_t inLen, unsigned char * output, size_t outLen, const unsigned char * customization, size_t customLen )
|
||||
{
|
||||
KangarooTwelve_Instance ktInstance;
|
||||
|
||||
if (outLen == 0)
|
||||
return 1;
|
||||
if (KangarooTwelve_Initialize(&ktInstance, outLen) != 0)
|
||||
return 1;
|
||||
if (KangarooTwelve_Update(&ktInstance, input, inLen) != 0)
|
||||
return 1;
|
||||
return KangarooTwelve_Final(&ktInstance, output, customization, customLen);
|
||||
}
|
89
src/crypto/randomx/panthera/KangarooTwelve.h
Normal file
89
src/crypto/randomx/panthera/KangarooTwelve.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#ifndef _KangarooTwelve_h_
|
||||
#define _KangarooTwelve_h_
|
||||
|
||||
#ifndef KeccakP1600_excluded
|
||||
|
||||
#include <stddef.h>
|
||||
#include "align.h"
|
||||
#include "KeccakSpongeWidth1600.h"
|
||||
#include "Phases.h"
|
||||
|
||||
typedef KCP_Phases KangarooTwelve_Phases;
|
||||
|
||||
typedef struct {
|
||||
KeccakWidth1600_12rounds_SpongeInstance queueNode;
|
||||
KeccakWidth1600_12rounds_SpongeInstance finalNode;
|
||||
size_t fixedOutputLength;
|
||||
size_t blockNumber;
|
||||
unsigned int queueAbsorbedLen;
|
||||
KangarooTwelve_Phases phase;
|
||||
} KangarooTwelve_Instance;
|
||||
|
||||
/** Extendable ouput function KangarooTwelve.
|
||||
* @param input Pointer to the input message (M).
|
||||
* @param inputByteLen The length of the input message in bytes.
|
||||
* @param output Pointer to the output buffer.
|
||||
* @param outputByteLen The desired number of output bytes.
|
||||
* @param customization Pointer to the customization string (C).
|
||||
* @param customByteLen The length of the customization string in bytes.
|
||||
* @return 0 if successful, 1 otherwise.
|
||||
*/
|
||||
int KangarooTwelve(const unsigned char *input, size_t inputByteLen, unsigned char *output, size_t outputByteLen, const unsigned char *customization, size_t customByteLen );
|
||||
|
||||
/**
|
||||
* Function to initialize a KangarooTwelve instance.
|
||||
* @param ktInstance Pointer to the instance to be initialized.
|
||||
* @param outputByteLen The desired number of output bytes,
|
||||
* or 0 for an arbitrarily-long output.
|
||||
* @return 0 if successful, 1 otherwise.
|
||||
*/
|
||||
int KangarooTwelve_Initialize(KangarooTwelve_Instance *ktInstance, size_t outputByteLen);
|
||||
|
||||
/**
|
||||
* Function to give input data to be absorbed.
|
||||
* @param ktInstance Pointer to the instance initialized by KangarooTwelve_Initialize().
|
||||
* @param input Pointer to the input message data (M).
|
||||
* @param inputByteLen The number of bytes provided in the input message data.
|
||||
* @return 0 if successful, 1 otherwise.
|
||||
*/
|
||||
int KangarooTwelve_Update(KangarooTwelve_Instance *ktInstance, const unsigned char *input, size_t inputByteLen);
|
||||
|
||||
/**
|
||||
* Function to call after all the input message has been input, and to get
|
||||
* output bytes if the length was specified when calling KangarooTwelve_Initialize().
|
||||
* @param ktInstance Pointer to the hash instance initialized by KangarooTwelve_Initialize().
|
||||
* If @a outputByteLen was not 0 in the call to KangarooTwelve_Initialize(), the number of
|
||||
* output bytes is equal to @a outputByteLen.
|
||||
* If @a outputByteLen was 0 in the call to KangarooTwelve_Initialize(), the output bytes
|
||||
* must be extracted using the KangarooTwelve_Squeeze() function.
|
||||
* @param output Pointer to the buffer where to store the output data.
|
||||
* @param customization Pointer to the customization string (C).
|
||||
* @param customByteLen The length of the customization string in bytes.
|
||||
* @return 0 if successful, 1 otherwise.
|
||||
*/
|
||||
int KangarooTwelve_Final(KangarooTwelve_Instance *ktInstance, unsigned char *output, const unsigned char *customization, size_t customByteLen);
|
||||
|
||||
/**
|
||||
* Function to squeeze output data.
|
||||
* @param ktInstance Pointer to the hash instance initialized by KangarooTwelve_Initialize().
|
||||
* @param data Pointer to the buffer where to store the output data.
|
||||
* @param outputByteLen The number of output bytes desired.
|
||||
* @pre KangarooTwelve_Final() must have been already called.
|
||||
* @return 0 if successful, 1 otherwise.
|
||||
*/
|
||||
int KangarooTwelve_Squeeze(KangarooTwelve_Instance *ktInstance, unsigned char *output, size_t outputByteLen);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
41
src/crypto/randomx/panthera/KeccakP-1600-SnP.h
Normal file
41
src/crypto/randomx/panthera/KeccakP-1600-SnP.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
---
|
||||
|
||||
Please refer to SnP-documentation.h for more details.
|
||||
*/
|
||||
|
||||
#ifndef _KeccakP_1600_SnP_h_
|
||||
#define _KeccakP_1600_SnP_h_
|
||||
|
||||
#define KeccakP1600_implementation "64-bit reference implementation"
|
||||
#define KeccakP1600_stateSizeInBytes 200
|
||||
#define KeccakP1600_stateAlignment 8
|
||||
|
||||
#ifdef KeccakReference
|
||||
void KeccakP1600_StaticInitialize( void );
|
||||
#else
|
||||
#define KeccakP1600_StaticInitialize()
|
||||
#endif
|
||||
void KeccakP1600_Initialize(void *state);
|
||||
void KeccakP1600_AddByte(void *state, unsigned char data, unsigned int offset);
|
||||
void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
|
||||
void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length);
|
||||
void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount);
|
||||
void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds);
|
||||
void KeccakP1600_Permute_12rounds(void *state);
|
||||
void KeccakP1600_Permute_24rounds(void *state);
|
||||
void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length);
|
||||
void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length);
|
||||
|
||||
#endif
|
402
src/crypto/randomx/panthera/KeccakP-1600-reference.c
Normal file
402
src/crypto/randomx/panthera/KeccakP-1600-reference.c
Normal file
|
@ -0,0 +1,402 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
---
|
||||
|
||||
This file implements Keccak-p[1600] in a SnP-compatible way.
|
||||
Please refer to SnP-documentation.h for more details.
|
||||
|
||||
This implementation comes with KeccakP-1600-SnP.h in the same folder.
|
||||
Please refer to LowLevel.build for the exact list of other files it must be combined with.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "brg_endian.h"
|
||||
#ifdef KeccakReference
|
||||
#include "displayIntermediateValues.h"
|
||||
#endif
|
||||
|
||||
typedef unsigned char UINT8;
|
||||
typedef unsigned long long UINT64;
|
||||
typedef UINT64 tKeccakLane;
|
||||
|
||||
#define maxNrRounds 24
|
||||
#define nrLanes 25
|
||||
#define index(x, y) (((x)%5)+5*((y)%5))
|
||||
|
||||
#ifdef KeccakReference
|
||||
|
||||
static tKeccakLane KeccakRoundConstants[maxNrRounds];
|
||||
static unsigned int KeccakRhoOffsets[nrLanes];
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_InitializeRoundConstants(void);
|
||||
void KeccakP1600_InitializeRhoOffsets(void);
|
||||
static int LFSR86540(UINT8 *LFSR);
|
||||
|
||||
void KeccakP1600_StaticInitialize(void)
|
||||
{
|
||||
if (sizeof(tKeccakLane) != 8) {
|
||||
printf("tKeccakLane should be 64-bit wide\n");
|
||||
abort();
|
||||
}
|
||||
KeccakP1600_InitializeRoundConstants();
|
||||
KeccakP1600_InitializeRhoOffsets();
|
||||
}
|
||||
|
||||
void KeccakP1600_InitializeRoundConstants(void)
|
||||
{
|
||||
UINT8 LFSRstate = 0x01;
|
||||
unsigned int i, j, bitPosition;
|
||||
|
||||
for(i=0; i<maxNrRounds; i++) {
|
||||
KeccakRoundConstants[i] = 0;
|
||||
for(j=0; j<7; j++) {
|
||||
bitPosition = (1<<j)-1; /* 2^j-1 */
|
||||
if (LFSR86540(&LFSRstate))
|
||||
KeccakRoundConstants[i] ^= (tKeccakLane)1<<bitPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KeccakP1600_InitializeRhoOffsets(void)
|
||||
{
|
||||
unsigned int x, y, t, newX, newY;
|
||||
|
||||
KeccakRhoOffsets[index(0, 0)] = 0;
|
||||
x = 1;
|
||||
y = 0;
|
||||
for(t=0; t<24; t++) {
|
||||
KeccakRhoOffsets[index(x, y)] = ((t+1)*(t+2)/2) % 64;
|
||||
newX = (0*x+1*y) % 5;
|
||||
newY = (2*x+3*y) % 5;
|
||||
x = newX;
|
||||
y = newY;
|
||||
}
|
||||
}
|
||||
|
||||
static int LFSR86540(UINT8 *LFSR)
|
||||
{
|
||||
int result = ((*LFSR) & 0x01) != 0;
|
||||
if (((*LFSR) & 0x80) != 0)
|
||||
/* Primitive polynomial over GF(2): x^8+x^6+x^5+x^4+1 */
|
||||
(*LFSR) = ((*LFSR) << 1) ^ 0x71;
|
||||
else
|
||||
(*LFSR) <<= 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static const tKeccakLane KeccakRoundConstants[maxNrRounds] =
|
||||
{
|
||||
0x0000000000000001,
|
||||
0x0000000000008082,
|
||||
0x800000000000808a,
|
||||
0x8000000080008000,
|
||||
0x000000000000808b,
|
||||
0x0000000080000001,
|
||||
0x8000000080008081,
|
||||
0x8000000000008009,
|
||||
0x000000000000008a,
|
||||
0x0000000000000088,
|
||||
0x0000000080008009,
|
||||
0x000000008000000a,
|
||||
0x000000008000808b,
|
||||
0x800000000000008b,
|
||||
0x8000000000008089,
|
||||
0x8000000000008003,
|
||||
0x8000000000008002,
|
||||
0x8000000000000080,
|
||||
0x000000000000800a,
|
||||
0x800000008000000a,
|
||||
0x8000000080008081,
|
||||
0x8000000000008080,
|
||||
0x0000000080000001,
|
||||
0x8000000080008008,
|
||||
};
|
||||
|
||||
static const unsigned int KeccakRhoOffsets[nrLanes] =
|
||||
{
|
||||
0, 1, 62, 28, 27, 36, 44, 6, 55, 20, 3, 10, 43, 25, 39, 41, 45, 15, 21, 8, 18, 2, 61, 56, 14
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_Initialize(void *state)
|
||||
{
|
||||
memset(state, 0, 1600/8);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_AddByte(void *state, unsigned char byte, unsigned int offset)
|
||||
{
|
||||
assert(offset < 200);
|
||||
((unsigned char *)state)[offset] ^= byte;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_AddBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
assert(offset < 200);
|
||||
assert(offset+length <= 200);
|
||||
for(i=0; i<length; i++)
|
||||
((unsigned char *)state)[offset+i] ^= data[i];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_OverwriteBytes(void *state, const unsigned char *data, unsigned int offset, unsigned int length)
|
||||
{
|
||||
assert(offset < 200);
|
||||
assert(offset+length <= 200);
|
||||
memcpy((unsigned char*)state+offset, data, length);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_OverwriteWithZeroes(void *state, unsigned int byteCount)
|
||||
{
|
||||
assert(byteCount <= 200);
|
||||
memset(state, 0, byteCount);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600OnWords(tKeccakLane *state, unsigned int nrRounds);
|
||||
void KeccakP1600Round(tKeccakLane *state, unsigned int indexRound);
|
||||
static void theta(tKeccakLane *A);
|
||||
static void rho(tKeccakLane *A);
|
||||
static void pi(tKeccakLane *A);
|
||||
static void chi(tKeccakLane *A);
|
||||
static void iota(tKeccakLane *A, unsigned int indexRound);
|
||||
|
||||
void KeccakP1600_Permute_Nrounds(void *state, unsigned int nrounds)
|
||||
{
|
||||
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
||||
tKeccakLane stateAsWords[1600/64];
|
||||
#endif
|
||||
|
||||
#ifdef KeccakReference
|
||||
displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state, 1600);
|
||||
#endif
|
||||
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
||||
KeccakP1600OnWords((tKeccakLane*)state, nrounds);
|
||||
#else
|
||||
fromBytesToWords(stateAsWords, (const unsigned char *)state);
|
||||
KeccakP1600OnWords(stateAsWords, nrounds);
|
||||
fromWordsToBytes((unsigned char *)state, stateAsWords);
|
||||
#endif
|
||||
#ifdef KeccakReference
|
||||
displayStateAsBytes(1, "State after permutation", (const unsigned char *)state, 1600);
|
||||
#endif
|
||||
}
|
||||
|
||||
void KeccakP1600_Permute_12rounds(void *state)
|
||||
{
|
||||
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
||||
tKeccakLane stateAsWords[1600/64];
|
||||
#endif
|
||||
|
||||
#ifdef KeccakReference
|
||||
displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state, 1600);
|
||||
#endif
|
||||
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
||||
KeccakP1600OnWords((tKeccakLane*)state, 12);
|
||||
#else
|
||||
fromBytesToWords(stateAsWords, (const unsigned char *)state);
|
||||
KeccakP1600OnWords(stateAsWords, 12);
|
||||
fromWordsToBytes((unsigned char *)state, stateAsWords);
|
||||
#endif
|
||||
#ifdef KeccakReference
|
||||
displayStateAsBytes(1, "State after permutation", (const unsigned char *)state, 1600);
|
||||
#endif
|
||||
}
|
||||
|
||||
void KeccakP1600_Permute_24rounds(void *state)
|
||||
{
|
||||
#if (PLATFORM_BYTE_ORDER != IS_LITTLE_ENDIAN)
|
||||
tKeccakLane stateAsWords[1600/64];
|
||||
#endif
|
||||
|
||||
#ifdef KeccakReference
|
||||
displayStateAsBytes(1, "Input of permutation", (const unsigned char *)state, 1600);
|
||||
#endif
|
||||
#if (PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN)
|
||||
KeccakP1600OnWords((tKeccakLane*)state, 24);
|
||||
#else
|
||||
fromBytesToWords(stateAsWords, (const unsigned char *)state);
|
||||
KeccakP1600OnWords(stateAsWords, 24);
|
||||
fromWordsToBytes((unsigned char *)state, stateAsWords);
|
||||
#endif
|
||||
#ifdef KeccakReference
|
||||
displayStateAsBytes(1, "State after permutation", (const unsigned char *)state, 1600);
|
||||
#endif
|
||||
}
|
||||
|
||||
void KeccakP1600OnWords(tKeccakLane *state, unsigned int nrRounds)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
#ifdef KeccakReference
|
||||
displayStateAsLanes(3, "Same, with lanes as 64-bit words", state, 1600);
|
||||
#endif
|
||||
|
||||
for(i=(maxNrRounds-nrRounds); i<maxNrRounds; i++)
|
||||
KeccakP1600Round(state, i);
|
||||
}
|
||||
|
||||
void KeccakP1600Round(tKeccakLane *state, unsigned int indexRound)
|
||||
{
|
||||
#ifdef KeccakReference
|
||||
displayRoundNumber(3, indexRound);
|
||||
#endif
|
||||
|
||||
theta(state);
|
||||
#ifdef KeccakReference
|
||||
displayStateAsLanes(3, "After theta", state, 1600);
|
||||
#endif
|
||||
|
||||
rho(state);
|
||||
#ifdef KeccakReference
|
||||
displayStateAsLanes(3, "After rho", state, 1600);
|
||||
#endif
|
||||
|
||||
pi(state);
|
||||
#ifdef KeccakReference
|
||||
displayStateAsLanes(3, "After pi", state, 1600);
|
||||
#endif
|
||||
|
||||
chi(state);
|
||||
#ifdef KeccakReference
|
||||
displayStateAsLanes(3, "After chi", state, 1600);
|
||||
#endif
|
||||
|
||||
iota(state, indexRound);
|
||||
#ifdef KeccakReference
|
||||
displayStateAsLanes(3, "After iota", state, 1600);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define ROL64(a, offset) ((offset != 0) ? ((((tKeccakLane)a) << offset) ^ (((tKeccakLane)a) >> (64-offset))) : a)
|
||||
|
||||
static void theta(tKeccakLane *A)
|
||||
{
|
||||
unsigned int x, y;
|
||||
tKeccakLane C[5], D[5];
|
||||
|
||||
for(x=0; x<5; x++) {
|
||||
C[x] = 0;
|
||||
for(y=0; y<5; y++)
|
||||
C[x] ^= A[index(x, y)];
|
||||
}
|
||||
for(x=0; x<5; x++)
|
||||
D[x] = ROL64(C[(x+1)%5], 1) ^ C[(x+4)%5];
|
||||
for(x=0; x<5; x++)
|
||||
for(y=0; y<5; y++)
|
||||
A[index(x, y)] ^= D[x];
|
||||
}
|
||||
|
||||
static void rho(tKeccakLane *A)
|
||||
{
|
||||
unsigned int x, y;
|
||||
|
||||
for(x=0; x<5; x++) for(y=0; y<5; y++)
|
||||
A[index(x, y)] = ROL64(A[index(x, y)], KeccakRhoOffsets[index(x, y)]);
|
||||
}
|
||||
|
||||
static void pi(tKeccakLane *A)
|
||||
{
|
||||
unsigned int x, y;
|
||||
tKeccakLane tempA[25];
|
||||
|
||||
for(x=0; x<5; x++) for(y=0; y<5; y++)
|
||||
tempA[index(x, y)] = A[index(x, y)];
|
||||
for(x=0; x<5; x++) for(y=0; y<5; y++)
|
||||
A[index(0*x+1*y, 2*x+3*y)] = tempA[index(x, y)];
|
||||
}
|
||||
|
||||
static void chi(tKeccakLane *A)
|
||||
{
|
||||
unsigned int x, y;
|
||||
tKeccakLane C[5];
|
||||
|
||||
for(y=0; y<5; y++) {
|
||||
for(x=0; x<5; x++)
|
||||
C[x] = A[index(x, y)] ^ ((~A[index(x+1, y)]) & A[index(x+2, y)]);
|
||||
for(x=0; x<5; x++)
|
||||
A[index(x, y)] = C[x];
|
||||
}
|
||||
}
|
||||
|
||||
static void iota(tKeccakLane *A, unsigned int indexRound)
|
||||
{
|
||||
A[index(0, 0)] ^= KeccakRoundConstants[indexRound];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_ExtractBytes(const void *state, unsigned char *data, unsigned int offset, unsigned int length)
|
||||
{
|
||||
assert(offset < 200);
|
||||
assert(offset+length <= 200);
|
||||
memcpy(data, (unsigned char*)state+offset, length);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_ExtractAndAddBytes(const void *state, const unsigned char *input, unsigned char *output, unsigned int offset, unsigned int length)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
assert(offset < 200);
|
||||
assert(offset+length <= 200);
|
||||
for(i=0; i<length; i++)
|
||||
output[i] = input[i] ^ ((unsigned char *)state)[offset+i];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
void KeccakP1600_DisplayRoundConstants(FILE *f)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for(i=0; i<maxNrRounds; i++) {
|
||||
fprintf(f, "RC[%02i][0][0] = ", i);
|
||||
fprintf(f, "%08X", (unsigned int)(KeccakRoundConstants[i] >> 32));
|
||||
fprintf(f, "%08X", (unsigned int)(KeccakRoundConstants[i] & 0xFFFFFFFFULL));
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
void KeccakP1600_DisplayRhoOffsets(FILE *f)
|
||||
{
|
||||
unsigned int x, y;
|
||||
|
||||
for(y=0; y<5; y++) for(x=0; x<5; x++) {
|
||||
fprintf(f, "RhoOffset[%i][%i] = ", x, y);
|
||||
fprintf(f, "%2i", KeccakRhoOffsets[index(x, y)]);
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
35
src/crypto/randomx/panthera/KeccakSponge-common.h
Normal file
35
src/crypto/randomx/panthera/KeccakSponge-common.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#ifndef _KeccakSpongeCommon_h_
|
||||
#define _KeccakSpongeCommon_h_
|
||||
|
||||
#include <string.h>
|
||||
#include "align.h"
|
||||
|
||||
#define KCP_DeclareSpongeStructure(prefix, size, alignment) \
|
||||
ALIGN(alignment) typedef struct prefix##_SpongeInstanceStruct { \
|
||||
unsigned char state[size]; \
|
||||
unsigned int rate; \
|
||||
unsigned int byteIOIndex; \
|
||||
int squeezing; \
|
||||
} prefix##_SpongeInstance;
|
||||
|
||||
#define KCP_DeclareSpongeFunctions(prefix) \
|
||||
int prefix##_Sponge(unsigned int rate, unsigned int capacity, const unsigned char *input, size_t inputByteLen, unsigned char suffix, unsigned char *output, size_t outputByteLen); \
|
||||
int prefix##_SpongeInitialize(prefix##_SpongeInstance *spongeInstance, unsigned int rate, unsigned int capacity); \
|
||||
int prefix##_SpongeAbsorb(prefix##_SpongeInstance *spongeInstance, const unsigned char *data, size_t dataByteLen); \
|
||||
int prefix##_SpongeAbsorbLastFewBits(prefix##_SpongeInstance *spongeInstance, unsigned char delimitedData); \
|
||||
int prefix##_SpongeSqueeze(prefix##_SpongeInstance *spongeInstance, unsigned char *data, size_t dataByteLen);
|
||||
|
||||
#endif
|
311
src/crypto/randomx/panthera/KeccakSponge.inc
Normal file
311
src/crypto/randomx/panthera/KeccakSponge.inc
Normal file
|
@ -0,0 +1,311 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#define JOIN0(a, b) a ## b
|
||||
#define JOIN(a, b) JOIN0(a, b)
|
||||
|
||||
#define Sponge JOIN(prefix, _Sponge)
|
||||
#define SpongeInstance JOIN(prefix, _SpongeInstance)
|
||||
#define SpongeInitialize JOIN(prefix, _SpongeInitialize)
|
||||
#define SpongeAbsorb JOIN(prefix, _SpongeAbsorb)
|
||||
#define SpongeAbsorbLastFewBits JOIN(prefix, _SpongeAbsorbLastFewBits)
|
||||
#define SpongeSqueeze JOIN(prefix, _SpongeSqueeze)
|
||||
|
||||
#define SnP_stateSizeInBytes JOIN(SnP, _stateSizeInBytes)
|
||||
#define SnP_stateAlignment JOIN(SnP, _stateAlignment)
|
||||
#define SnP_StaticInitialize JOIN(SnP, _StaticInitialize)
|
||||
#define SnP_Initialize JOIN(SnP, _Initialize)
|
||||
#define SnP_AddByte JOIN(SnP, _AddByte)
|
||||
#define SnP_AddBytes JOIN(SnP, _AddBytes)
|
||||
#define SnP_ExtractBytes JOIN(SnP, _ExtractBytes)
|
||||
|
||||
int Sponge(unsigned int rate, unsigned int capacity, const unsigned char *input, size_t inputByteLen, unsigned char suffix, unsigned char *output, size_t outputByteLen)
|
||||
{
|
||||
ALIGN(SnP_stateAlignment) unsigned char state[SnP_stateSizeInBytes];
|
||||
unsigned int partialBlock;
|
||||
const unsigned char *curInput = input;
|
||||
unsigned char *curOutput = output;
|
||||
unsigned int rateInBytes = rate/8;
|
||||
|
||||
if (rate+capacity != SnP_width)
|
||||
return 1;
|
||||
if ((rate <= 0) || (rate > SnP_width) || ((rate % 8) != 0))
|
||||
return 1;
|
||||
if (suffix == 0)
|
||||
return 1;
|
||||
|
||||
/* Initialize the state */
|
||||
SnP_StaticInitialize();
|
||||
SnP_Initialize(state);
|
||||
|
||||
/* First, absorb whole blocks */
|
||||
#ifdef SnP_FastLoop_Absorb
|
||||
if (((rateInBytes % (SnP_width/200)) == 0) && (inputByteLen >= rateInBytes)) {
|
||||
/* fast lane: whole lane rate */
|
||||
size_t j;
|
||||
j = SnP_FastLoop_Absorb(state, rateInBytes/(SnP_width/200), curInput, inputByteLen);
|
||||
curInput += j;
|
||||
inputByteLen -= j;
|
||||
}
|
||||
#endif
|
||||
while(inputByteLen >= (size_t)rateInBytes) {
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Block to be absorbed", curInput, rateInBytes);
|
||||
#endif
|
||||
SnP_AddBytes(state, curInput, 0, rateInBytes);
|
||||
SnP_Permute(state);
|
||||
curInput += rateInBytes;
|
||||
inputByteLen -= rateInBytes;
|
||||
}
|
||||
|
||||
/* Then, absorb what remains */
|
||||
partialBlock = (unsigned int)inputByteLen;
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Block to be absorbed (part)", curInput, partialBlock);
|
||||
#endif
|
||||
SnP_AddBytes(state, curInput, 0, partialBlock);
|
||||
|
||||
/* Finally, absorb the suffix */
|
||||
#ifdef KeccakReference
|
||||
{
|
||||
unsigned char delimitedData1[1];
|
||||
delimitedData1[0] = suffix;
|
||||
displayBytes(1, "Block to be absorbed (last few bits + first bit of padding)", delimitedData1, 1);
|
||||
}
|
||||
#endif
|
||||
/* Last few bits, whose delimiter coincides with first bit of padding */
|
||||
SnP_AddByte(state, suffix, partialBlock);
|
||||
/* If the first bit of padding is at position rate-1, we need a whole new block for the second bit of padding */
|
||||
if ((suffix >= 0x80) && (partialBlock == (rateInBytes-1)))
|
||||
SnP_Permute(state);
|
||||
/* Second bit of padding */
|
||||
SnP_AddByte(state, 0x80, rateInBytes-1);
|
||||
#ifdef KeccakReference
|
||||
{
|
||||
unsigned char block[SnP_width/8];
|
||||
memset(block, 0, SnP_width/8);
|
||||
block[rateInBytes-1] = 0x80;
|
||||
displayBytes(1, "Second bit of padding", block, rateInBytes);
|
||||
}
|
||||
#endif
|
||||
SnP_Permute(state);
|
||||
#ifdef KeccakReference
|
||||
displayText(1, "--- Switching to squeezing phase ---");
|
||||
#endif
|
||||
|
||||
/* First, output whole blocks */
|
||||
while(outputByteLen > (size_t)rateInBytes) {
|
||||
SnP_ExtractBytes(state, curOutput, 0, rateInBytes);
|
||||
SnP_Permute(state);
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Squeezed block", curOutput, rateInBytes);
|
||||
#endif
|
||||
curOutput += rateInBytes;
|
||||
outputByteLen -= rateInBytes;
|
||||
}
|
||||
|
||||
/* Finally, output what remains */
|
||||
partialBlock = (unsigned int)outputByteLen;
|
||||
SnP_ExtractBytes(state, curOutput, 0, partialBlock);
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Squeezed block (part)", curOutput, partialBlock);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
int SpongeInitialize(SpongeInstance *instance, unsigned int rate, unsigned int capacity)
|
||||
{
|
||||
if (rate+capacity != SnP_width)
|
||||
return 1;
|
||||
if ((rate <= 0) || (rate > SnP_width) || ((rate % 8) != 0))
|
||||
return 1;
|
||||
SnP_StaticInitialize();
|
||||
SnP_Initialize(instance->state);
|
||||
instance->rate = rate;
|
||||
instance->byteIOIndex = 0;
|
||||
instance->squeezing = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
int SpongeAbsorb(SpongeInstance *instance, const unsigned char *data, size_t dataByteLen)
|
||||
{
|
||||
size_t i, j;
|
||||
unsigned int partialBlock;
|
||||
const unsigned char *curData;
|
||||
unsigned int rateInBytes = instance->rate/8;
|
||||
|
||||
if (instance->squeezing)
|
||||
return 1; /* Too late for additional input */
|
||||
|
||||
i = 0;
|
||||
curData = data;
|
||||
while(i < dataByteLen) {
|
||||
if ((instance->byteIOIndex == 0) && (dataByteLen >= (i + rateInBytes))) {
|
||||
#ifdef SnP_FastLoop_Absorb
|
||||
/* processing full blocks first */
|
||||
if ((rateInBytes % (SnP_width/200)) == 0) {
|
||||
/* fast lane: whole lane rate */
|
||||
j = SnP_FastLoop_Absorb(instance->state, rateInBytes/(SnP_width/200), curData, dataByteLen - i);
|
||||
i += j;
|
||||
curData += j;
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
for(j=dataByteLen-i; j>=rateInBytes; j-=rateInBytes) {
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Block to be absorbed", curData, rateInBytes);
|
||||
#endif
|
||||
SnP_AddBytes(instance->state, curData, 0, rateInBytes);
|
||||
SnP_Permute(instance->state);
|
||||
curData+=rateInBytes;
|
||||
}
|
||||
i = dataByteLen - j;
|
||||
#ifdef SnP_FastLoop_Absorb
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
/* normal lane: using the message queue */
|
||||
partialBlock = (unsigned int)(dataByteLen - i);
|
||||
if (partialBlock+instance->byteIOIndex > rateInBytes)
|
||||
partialBlock = rateInBytes-instance->byteIOIndex;
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Block to be absorbed (part)", curData, partialBlock);
|
||||
#endif
|
||||
i += partialBlock;
|
||||
|
||||
SnP_AddBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
|
||||
curData += partialBlock;
|
||||
instance->byteIOIndex += partialBlock;
|
||||
if (instance->byteIOIndex == rateInBytes) {
|
||||
SnP_Permute(instance->state);
|
||||
instance->byteIOIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
int SpongeAbsorbLastFewBits(SpongeInstance *instance, unsigned char delimitedData)
|
||||
{
|
||||
unsigned int rateInBytes = instance->rate/8;
|
||||
|
||||
if (delimitedData == 0)
|
||||
return 1;
|
||||
if (instance->squeezing)
|
||||
return 1; /* Too late for additional input */
|
||||
|
||||
#ifdef KeccakReference
|
||||
{
|
||||
unsigned char delimitedData1[1];
|
||||
delimitedData1[0] = delimitedData;
|
||||
displayBytes(1, "Block to be absorbed (last few bits + first bit of padding)", delimitedData1, 1);
|
||||
}
|
||||
#endif
|
||||
/* Last few bits, whose delimiter coincides with first bit of padding */
|
||||
SnP_AddByte(instance->state, delimitedData, instance->byteIOIndex);
|
||||
/* If the first bit of padding is at position rate-1, we need a whole new block for the second bit of padding */
|
||||
if ((delimitedData >= 0x80) && (instance->byteIOIndex == (rateInBytes-1)))
|
||||
SnP_Permute(instance->state);
|
||||
/* Second bit of padding */
|
||||
SnP_AddByte(instance->state, 0x80, rateInBytes-1);
|
||||
#ifdef KeccakReference
|
||||
{
|
||||
unsigned char block[SnP_width/8];
|
||||
memset(block, 0, SnP_width/8);
|
||||
block[rateInBytes-1] = 0x80;
|
||||
displayBytes(1, "Second bit of padding", block, rateInBytes);
|
||||
}
|
||||
#endif
|
||||
SnP_Permute(instance->state);
|
||||
instance->byteIOIndex = 0;
|
||||
instance->squeezing = 1;
|
||||
#ifdef KeccakReference
|
||||
displayText(1, "--- Switching to squeezing phase ---");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
int SpongeSqueeze(SpongeInstance *instance, unsigned char *data, size_t dataByteLen)
|
||||
{
|
||||
size_t i, j;
|
||||
unsigned int partialBlock;
|
||||
unsigned int rateInBytes = instance->rate/8;
|
||||
unsigned char *curData;
|
||||
|
||||
if (!instance->squeezing)
|
||||
SpongeAbsorbLastFewBits(instance, 0x01);
|
||||
|
||||
i = 0;
|
||||
curData = data;
|
||||
while(i < dataByteLen) {
|
||||
if ((instance->byteIOIndex == rateInBytes) && (dataByteLen >= (i + rateInBytes))) {
|
||||
for(j=dataByteLen-i; j>=rateInBytes; j-=rateInBytes) {
|
||||
SnP_Permute(instance->state);
|
||||
SnP_ExtractBytes(instance->state, curData, 0, rateInBytes);
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Squeezed block", curData, rateInBytes);
|
||||
#endif
|
||||
curData+=rateInBytes;
|
||||
}
|
||||
i = dataByteLen - j;
|
||||
}
|
||||
else {
|
||||
/* normal lane: using the message queue */
|
||||
if (instance->byteIOIndex == rateInBytes) {
|
||||
SnP_Permute(instance->state);
|
||||
instance->byteIOIndex = 0;
|
||||
}
|
||||
partialBlock = (unsigned int)(dataByteLen - i);
|
||||
if (partialBlock+instance->byteIOIndex > rateInBytes)
|
||||
partialBlock = rateInBytes-instance->byteIOIndex;
|
||||
i += partialBlock;
|
||||
|
||||
SnP_ExtractBytes(instance->state, curData, instance->byteIOIndex, partialBlock);
|
||||
#ifdef KeccakReference
|
||||
displayBytes(1, "Squeezed block (part)", curData, partialBlock);
|
||||
#endif
|
||||
curData += partialBlock;
|
||||
instance->byteIOIndex += partialBlock;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
#undef Sponge
|
||||
#undef SpongeInstance
|
||||
#undef SpongeInitialize
|
||||
#undef SpongeAbsorb
|
||||
#undef SpongeAbsorbLastFewBits
|
||||
#undef SpongeSqueeze
|
||||
#undef SnP_stateSizeInBytes
|
||||
#undef SnP_stateAlignment
|
||||
#undef SnP_StaticInitialize
|
||||
#undef SnP_Initialize
|
||||
#undef SnP_AddByte
|
||||
#undef SnP_AddBytes
|
||||
#undef SnP_ExtractBytes
|
54
src/crypto/randomx/panthera/KeccakSpongeWidth1600.c
Normal file
54
src/crypto/randomx/panthera/KeccakSpongeWidth1600.c
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#include "KeccakSpongeWidth1600.h"
|
||||
|
||||
#ifdef KeccakReference
|
||||
#include "displayIntermediateValues.h"
|
||||
#endif
|
||||
|
||||
#ifndef KeccakP1600_excluded
|
||||
#include "KeccakP-1600-SnP.h"
|
||||
|
||||
#define prefix KeccakWidth1600
|
||||
#define SnP KeccakP1600
|
||||
#define SnP_width 1600
|
||||
#define SnP_Permute KeccakP1600_Permute_24rounds
|
||||
#if defined(KeccakF1600_FastLoop_supported)
|
||||
#define SnP_FastLoop_Absorb KeccakF1600_FastLoop_Absorb
|
||||
#endif
|
||||
#include "KeccakSponge.inc"
|
||||
#undef prefix
|
||||
#undef SnP
|
||||
#undef SnP_width
|
||||
#undef SnP_Permute
|
||||
#undef SnP_FastLoop_Absorb
|
||||
#endif
|
||||
|
||||
#ifndef KeccakP1600_excluded
|
||||
#include "KeccakP-1600-SnP.h"
|
||||
|
||||
#define prefix KeccakWidth1600_12rounds
|
||||
#define SnP KeccakP1600
|
||||
#define SnP_width 1600
|
||||
#define SnP_Permute KeccakP1600_Permute_12rounds
|
||||
#if defined(KeccakP1600_12rounds_FastLoop_supported)
|
||||
#define SnP_FastLoop_Absorb KeccakP1600_12rounds_FastLoop_Absorb
|
||||
#endif
|
||||
#include "KeccakSponge.inc"
|
||||
#undef prefix
|
||||
#undef SnP
|
||||
#undef SnP_width
|
||||
#undef SnP_Permute
|
||||
#undef SnP_FastLoop_Absorb
|
||||
#endif
|
31
src/crypto/randomx/panthera/KeccakSpongeWidth1600.h
Normal file
31
src/crypto/randomx/panthera/KeccakSpongeWidth1600.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#ifndef _KeccakSpongeWidth1600_h_
|
||||
#define _KeccakSpongeWidth1600_h_
|
||||
|
||||
#include "KeccakSponge-common.h"
|
||||
|
||||
#ifndef KeccakP1600_excluded
|
||||
#include "KeccakP-1600-SnP.h"
|
||||
KCP_DeclareSpongeStructure(KeccakWidth1600, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment)
|
||||
KCP_DeclareSpongeFunctions(KeccakWidth1600)
|
||||
#endif
|
||||
|
||||
#ifndef KeccakP1600_excluded
|
||||
#include "KeccakP-1600-SnP.h"
|
||||
KCP_DeclareSpongeStructure(KeccakWidth1600_12rounds, KeccakP1600_stateSizeInBytes, KeccakP1600_stateAlignment)
|
||||
KCP_DeclareSpongeFunctions(KeccakWidth1600_12rounds)
|
||||
#endif
|
||||
|
||||
#endif
|
22
src/crypto/randomx/panthera/Phases.h
Normal file
22
src/crypto/randomx/panthera/Phases.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
Implementation by Ronny Van Keer, hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#ifndef _Phases_h_
|
||||
#define _Phases_h_
|
||||
|
||||
typedef enum {
|
||||
NOT_INITIALIZED,
|
||||
ABSORBING,
|
||||
FINAL,
|
||||
SQUEEZING
|
||||
} KCP_Phases;
|
||||
|
||||
#endif
|
32
src/crypto/randomx/panthera/align.h
Normal file
32
src/crypto/randomx/panthera/align.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
Implementation by the Keccak Team, namely, Guido Bertoni, Joan Daemen,
|
||||
Michaël Peeters, Gilles Van Assche and Ronny Van Keer,
|
||||
hereby denoted as "the implementer".
|
||||
|
||||
For more information, feedback or questions, please refer to our website:
|
||||
https://keccak.team/
|
||||
|
||||
To the extent possible under law, the implementer has waived all copyright
|
||||
and related or neighboring rights to the source code in this file.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
#ifndef _align_h_
|
||||
#define _align_h_
|
||||
|
||||
/* on Mac OS-X and possibly others, ALIGN(x) is defined in param.h, and -Werror chokes on the redef. */
|
||||
#ifdef ALIGN
|
||||
#undef ALIGN
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define ALIGN(x) __attribute__ ((aligned(x)))
|
||||
#elif defined(_MSC_VER)
|
||||
#define ALIGN(x) __declspec(align(x))
|
||||
#elif defined(__ARMCC_VERSION)
|
||||
#define ALIGN(x) __align(x)
|
||||
#else
|
||||
#define ALIGN(x)
|
||||
#endif
|
||||
|
||||
#endif
|
143
src/crypto/randomx/panthera/brg_endian.h
Normal file
143
src/crypto/randomx/panthera/brg_endian.h
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
---------------------------------------------------------------------------
|
||||
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
|
||||
|
||||
LICENSE TERMS
|
||||
|
||||
The redistribution and use of this software (with or without changes)
|
||||
is allowed without the payment of fees or royalties provided that:
|
||||
|
||||
1. source code distributions include the above copyright notice, this
|
||||
list of conditions and the following disclaimer;
|
||||
|
||||
2. binary distributions include the above copyright notice, this list
|
||||
of conditions and the following disclaimer in their documentation;
|
||||
|
||||
3. the name of the copyright holder is not used to endorse products
|
||||
built using this software without specific written permission.
|
||||
|
||||
DISCLAIMER
|
||||
|
||||
This software is provided 'as is' with no explicit or implied warranties
|
||||
in respect of its properties, including, but not limited to, correctness
|
||||
and/or fitness for purpose.
|
||||
---------------------------------------------------------------------------
|
||||
Issue Date: 20/12/2007
|
||||
Changes for ARM 9/9/2010
|
||||
*/
|
||||
|
||||
#ifndef _BRG_ENDIAN_H
|
||||
#define _BRG_ENDIAN_H
|
||||
|
||||
#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */
|
||||
#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */
|
||||
|
||||
#if 0
|
||||
/* Include files where endian defines and byteswap functions may reside */
|
||||
#if defined( __sun )
|
||||
# include <sys/isa_defs.h>
|
||||
#elif defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __NetBSD__ )
|
||||
# include <sys/endian.h>
|
||||
#elif defined( BSD ) && ( BSD >= 199103 ) || defined( __APPLE__ ) || \
|
||||
defined( __CYGWIN32__ ) || defined( __DJGPP__ ) || defined( __osf__ )
|
||||
# include <machine/endian.h>
|
||||
#elif defined( __linux__ ) || defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
|
||||
# if !defined( __MINGW32__ ) && !defined( _AIX )
|
||||
# include <endian.h>
|
||||
# if !defined( __BEOS__ )
|
||||
# include <byteswap.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Now attempt to set the define for platform byte order using any */
|
||||
/* of the four forms SYMBOL, _SYMBOL, __SYMBOL & __SYMBOL__, which */
|
||||
/* seem to encompass most endian symbol definitions */
|
||||
|
||||
#if defined( BIG_ENDIAN ) && defined( LITTLE_ENDIAN )
|
||||
# if defined( BYTE_ORDER ) && BYTE_ORDER == BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( BYTE_ORDER ) && BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( BIG_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( LITTLE_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined( _BIG_ENDIAN ) && defined( _LITTLE_ENDIAN )
|
||||
# if defined( _BYTE_ORDER ) && _BYTE_ORDER == _BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( _BYTE_ORDER ) && _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( _BIG_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( _LITTLE_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined( __BIG_ENDIAN ) && defined( __LITTLE_ENDIAN )
|
||||
# if defined( __BYTE_ORDER ) && __BYTE_ORDER == __BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( __BYTE_ORDER ) && __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( __BIG_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( __LITTLE_ENDIAN )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
#if defined( __BIG_ENDIAN__ ) && defined( __LITTLE_ENDIAN__ )
|
||||
# if defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __BIG_ENDIAN__
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# elif defined( __BYTE_ORDER__ ) && __BYTE_ORDER__ == __LITTLE_ENDIAN__
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif defined( __BIG_ENDIAN__ )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#elif defined( __LITTLE_ENDIAN__ )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#endif
|
||||
|
||||
/* if the platform byte order could not be determined, then try to */
|
||||
/* set this define using common machine defines */
|
||||
#if !defined(PLATFORM_BYTE_ORDER)
|
||||
|
||||
#if defined( __alpha__ ) || defined( __alpha ) || defined( i386 ) || \
|
||||
defined( __i386__ ) || defined( _M_I86 ) || defined( _M_IX86 ) || \
|
||||
defined( __OS2__ ) || defined( sun386 ) || defined( __TURBOC__ ) || \
|
||||
defined( vax ) || defined( vms ) || defined( VMS ) || \
|
||||
defined( __VMS ) || defined( _M_X64 )
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
|
||||
#elif defined( AMIGA ) || defined( applec ) || defined( __AS400__ ) || \
|
||||
defined( _CRAY ) || defined( __hppa ) || defined( __hp9000 ) || \
|
||||
defined( ibm370 ) || defined( mc68000 ) || defined( m68k ) || \
|
||||
defined( __MRC__ ) || defined( __MVS__ ) || defined( __MWERKS__ ) || \
|
||||
defined( sparc ) || defined( __sparc) || defined( SYMANTEC_C ) || \
|
||||
defined( __VOS__ ) || defined( __TIGCC__ ) || defined( __TANDEM ) || \
|
||||
defined( THINK_C ) || defined( __VMCMS__ ) || defined( _AIX ) || \
|
||||
defined( __s390__ ) || defined( __s390x__ ) || defined( __zarch__ )
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
|
||||
#elif defined(__arm__)
|
||||
# ifdef __BIG_ENDIAN
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
# else
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
# endif
|
||||
#elif 1 /* **** EDIT HERE IF NECESSARY **** */
|
||||
# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN
|
||||
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
|
||||
# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
|
||||
#else
|
||||
# error Please edit lines 132 or 134 in brg_endian.h to set the platform byte order
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
1
src/crypto/randomx/panthera/insecure_memzero.h
Normal file
1
src/crypto/randomx/panthera/insecure_memzero.h
Normal file
|
@ -0,0 +1 @@
|
|||
#define insecure_memzero(buf, len) /* empty */
|
653
src/crypto/randomx/panthera/sha256.c
Normal file
653
src/crypto/randomx/panthera/sha256.c
Normal file
|
@ -0,0 +1,653 @@
|
|||
/*-
|
||||
* Copyright 2005-2016 Colin Percival
|
||||
* Copyright 2016-2018 Alexander Peslyak
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "insecure_memzero.h"
|
||||
#include "sysendian.h"
|
||||
|
||||
#include "sha256.h"
|
||||
|
||||
#ifdef __ICC
|
||||
/* Miscompile with icc 14.0.0 (at least), so don't use restrict there */
|
||||
#define restrict
|
||||
#define static_restrict static
|
||||
#elif defined(_MSC_VER)
|
||||
#define restrict
|
||||
#define static_restrict
|
||||
#elif __STDC_VERSION__ >= 199901L
|
||||
/* Have restrict */
|
||||
#define static_restrict static restrict
|
||||
#elif defined(__GNUC__)
|
||||
#define restrict __restrict
|
||||
#define static_restrict static __restrict
|
||||
#else
|
||||
#define restrict
|
||||
#define static_restrict
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Encode a length len*2 vector of (uint32_t) into a length len*8 vector of
|
||||
* (uint8_t) in big-endian form.
|
||||
*/
|
||||
static void
|
||||
be32enc_vect(uint8_t * dst, const uint32_t * src, size_t len)
|
||||
{
|
||||
|
||||
/* Encode vector, two words at a time. */
|
||||
do {
|
||||
be32enc(&dst[0], src[0]);
|
||||
be32enc(&dst[4], src[1]);
|
||||
src += 2;
|
||||
dst += 8;
|
||||
} while (--len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode a big-endian length len*8 vector of (uint8_t) into a length
|
||||
* len*2 vector of (uint32_t).
|
||||
*/
|
||||
static void
|
||||
be32dec_vect(uint32_t * dst, const uint8_t * src, size_t len)
|
||||
{
|
||||
|
||||
/* Decode vector, two words at a time. */
|
||||
do {
|
||||
dst[0] = be32dec(&src[0]);
|
||||
dst[1] = be32dec(&src[4]);
|
||||
src += 8;
|
||||
dst += 2;
|
||||
} while (--len);
|
||||
}
|
||||
|
||||
/* SHA256 round constants. */
|
||||
static const uint32_t Krnd[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
||||
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
||||
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
||||
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
||||
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
/* Elementary functions used by SHA256 */
|
||||
#define Ch(x, y, z) ((x & (y ^ z)) ^ z)
|
||||
#define Maj(x, y, z) ((x & (y | z)) | (y & z))
|
||||
#define SHR(x, n) (x >> n)
|
||||
#define ROTR(x, n) ((x >> n) | (x << (32 - n)))
|
||||
#define S0(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
|
||||
#define S1(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
|
||||
#define s0(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHR(x, 3))
|
||||
#define s1(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHR(x, 10))
|
||||
|
||||
/* SHA256 round function */
|
||||
#define RND(a, b, c, d, e, f, g, h, k) \
|
||||
h += S1(e) + Ch(e, f, g) + k; \
|
||||
d += h; \
|
||||
h += S0(a) + Maj(a, b, c);
|
||||
|
||||
/* Adjusted round function for rotating state */
|
||||
#define RNDr(S, W, i, ii) \
|
||||
RND(S[(64 - i) % 8], S[(65 - i) % 8], \
|
||||
S[(66 - i) % 8], S[(67 - i) % 8], \
|
||||
S[(68 - i) % 8], S[(69 - i) % 8], \
|
||||
S[(70 - i) % 8], S[(71 - i) % 8], \
|
||||
W[i + ii] + Krnd[i + ii])
|
||||
|
||||
/* Message schedule computation */
|
||||
#define MSCH(W, ii, i) \
|
||||
W[i + ii + 16] = s1(W[i + ii + 14]) + W[i + ii + 9] + s0(W[i + ii + 1]) + W[i + ii]
|
||||
|
||||
/*
|
||||
* SHA256 block compression function. The 256-bit state is transformed via
|
||||
* the 512-bit input block to produce a new state.
|
||||
*/
|
||||
static void
|
||||
SHA256_Transform(uint32_t state[static_restrict 8],
|
||||
const uint8_t block[static_restrict 64],
|
||||
uint32_t W[static_restrict 64], uint32_t S[static_restrict 8])
|
||||
{
|
||||
int i;
|
||||
|
||||
/* 1. Prepare the first part of the message schedule W. */
|
||||
be32dec_vect(W, block, 8);
|
||||
|
||||
/* 2. Initialize working variables. */
|
||||
memcpy(S, state, 32);
|
||||
|
||||
/* 3. Mix. */
|
||||
for (i = 0; i < 64; i += 16) {
|
||||
RNDr(S, W, 0, i);
|
||||
RNDr(S, W, 1, i);
|
||||
RNDr(S, W, 2, i);
|
||||
RNDr(S, W, 3, i);
|
||||
RNDr(S, W, 4, i);
|
||||
RNDr(S, W, 5, i);
|
||||
RNDr(S, W, 6, i);
|
||||
RNDr(S, W, 7, i);
|
||||
RNDr(S, W, 8, i);
|
||||
RNDr(S, W, 9, i);
|
||||
RNDr(S, W, 10, i);
|
||||
RNDr(S, W, 11, i);
|
||||
RNDr(S, W, 12, i);
|
||||
RNDr(S, W, 13, i);
|
||||
RNDr(S, W, 14, i);
|
||||
RNDr(S, W, 15, i);
|
||||
|
||||
if (i == 48)
|
||||
break;
|
||||
MSCH(W, 0, i);
|
||||
MSCH(W, 1, i);
|
||||
MSCH(W, 2, i);
|
||||
MSCH(W, 3, i);
|
||||
MSCH(W, 4, i);
|
||||
MSCH(W, 5, i);
|
||||
MSCH(W, 6, i);
|
||||
MSCH(W, 7, i);
|
||||
MSCH(W, 8, i);
|
||||
MSCH(W, 9, i);
|
||||
MSCH(W, 10, i);
|
||||
MSCH(W, 11, i);
|
||||
MSCH(W, 12, i);
|
||||
MSCH(W, 13, i);
|
||||
MSCH(W, 14, i);
|
||||
MSCH(W, 15, i);
|
||||
}
|
||||
|
||||
/* 4. Mix local working variables into global state. */
|
||||
state[0] += S[0];
|
||||
state[1] += S[1];
|
||||
state[2] += S[2];
|
||||
state[3] += S[3];
|
||||
state[4] += S[4];
|
||||
state[5] += S[5];
|
||||
state[6] += S[6];
|
||||
state[7] += S[7];
|
||||
}
|
||||
|
||||
static const uint8_t PAD[64] = {
|
||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
/* Add padding and terminating bit-count. */
|
||||
static void
|
||||
SHA256_Pad(SHA256_CTX * ctx, uint32_t tmp32[static_restrict 72])
|
||||
{
|
||||
size_t r;
|
||||
|
||||
/* Figure out how many bytes we have buffered. */
|
||||
r = (ctx->count >> 3) & 0x3f;
|
||||
|
||||
/* Pad to 56 mod 64, transforming if we finish a block en route. */
|
||||
if (r < 56) {
|
||||
/* Pad to 56 mod 64. */
|
||||
memcpy(&ctx->buf[r], PAD, 56 - r);
|
||||
} else {
|
||||
/* Finish the current block and mix. */
|
||||
memcpy(&ctx->buf[r], PAD, 64 - r);
|
||||
SHA256_Transform(ctx->state, ctx->buf, &tmp32[0], &tmp32[64]);
|
||||
|
||||
/* The start of the final block is all zeroes. */
|
||||
memset(&ctx->buf[0], 0, 56);
|
||||
}
|
||||
|
||||
/* Add the terminating bit-count. */
|
||||
be64enc(&ctx->buf[56], ctx->count);
|
||||
|
||||
/* Mix in the final block. */
|
||||
SHA256_Transform(ctx->state, ctx->buf, &tmp32[0], &tmp32[64]);
|
||||
}
|
||||
|
||||
/* Magic initialization constants. */
|
||||
static const uint32_t initial_state[8] = {
|
||||
0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
|
||||
0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19
|
||||
};
|
||||
|
||||
/**
|
||||
* SHA256_Init(ctx):
|
||||
* Initialize the SHA256 context ${ctx}.
|
||||
*/
|
||||
void
|
||||
SHA256_Init(SHA256_CTX * ctx)
|
||||
{
|
||||
|
||||
/* Zero bits processed so far. */
|
||||
ctx->count = 0;
|
||||
|
||||
/* Initialize state. */
|
||||
memcpy(ctx->state, initial_state, sizeof(initial_state));
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA256_Update(ctx, in, len):
|
||||
* Input ${len} bytes from ${in} into the SHA256 context ${ctx}.
|
||||
*/
|
||||
static void
|
||||
_SHA256_Update(SHA256_CTX * ctx, const void * in, size_t len,
|
||||
uint32_t tmp32[static_restrict 72])
|
||||
{
|
||||
uint32_t r;
|
||||
const uint8_t * src = in;
|
||||
|
||||
/* Return immediately if we have nothing to do. */
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
/* Number of bytes left in the buffer from previous updates. */
|
||||
r = (ctx->count >> 3) & 0x3f;
|
||||
|
||||
/* Update number of bits. */
|
||||
ctx->count += (uint64_t)(len) << 3;
|
||||
|
||||
/* Handle the case where we don't need to perform any transforms. */
|
||||
if (len < 64 - r) {
|
||||
memcpy(&ctx->buf[r], src, len);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Finish the current block. */
|
||||
memcpy(&ctx->buf[r], src, 64 - r);
|
||||
SHA256_Transform(ctx->state, ctx->buf, &tmp32[0], &tmp32[64]);
|
||||
src += 64 - r;
|
||||
len -= 64 - r;
|
||||
|
||||
/* Perform complete blocks. */
|
||||
while (len >= 64) {
|
||||
SHA256_Transform(ctx->state, src, &tmp32[0], &tmp32[64]);
|
||||
src += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Copy left over data into buffer. */
|
||||
memcpy(ctx->buf, src, len);
|
||||
}
|
||||
|
||||
/* Wrapper function for intermediate-values sanitization. */
|
||||
void
|
||||
SHA256_Update(SHA256_CTX * ctx, const void * in, size_t len)
|
||||
{
|
||||
uint32_t tmp32[72];
|
||||
|
||||
/* Call the real function. */
|
||||
_SHA256_Update(ctx, in, len, tmp32);
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(tmp32, 288);
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA256_Final(digest, ctx):
|
||||
* Output the SHA256 hash of the data input to the context ${ctx} into the
|
||||
* buffer ${digest}.
|
||||
*/
|
||||
static void
|
||||
_SHA256_Final(uint8_t digest[32], SHA256_CTX * ctx,
|
||||
uint32_t tmp32[static_restrict 72])
|
||||
{
|
||||
|
||||
/* Add padding. */
|
||||
SHA256_Pad(ctx, tmp32);
|
||||
|
||||
/* Write the hash. */
|
||||
be32enc_vect(digest, ctx->state, 4);
|
||||
}
|
||||
|
||||
/* Wrapper function for intermediate-values sanitization. */
|
||||
void
|
||||
SHA256_Final(uint8_t digest[32], SHA256_CTX * ctx)
|
||||
{
|
||||
uint32_t tmp32[72];
|
||||
|
||||
/* Call the real function. */
|
||||
_SHA256_Final(digest, ctx, tmp32);
|
||||
|
||||
/* Clear the context state. */
|
||||
insecure_memzero(ctx, sizeof(SHA256_CTX));
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(tmp32, 288);
|
||||
}
|
||||
|
||||
/**
|
||||
* SHA256_Buf(in, len, digest):
|
||||
* Compute the SHA256 hash of ${len} bytes from ${in} and write it to ${digest}.
|
||||
*/
|
||||
void
|
||||
SHA256_Buf(const void * in, size_t len, uint8_t digest[32])
|
||||
{
|
||||
SHA256_CTX ctx;
|
||||
uint32_t tmp32[72];
|
||||
|
||||
SHA256_Init(&ctx);
|
||||
_SHA256_Update(&ctx, in, len, tmp32);
|
||||
_SHA256_Final(digest, &ctx, tmp32);
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(&ctx, sizeof(SHA256_CTX));
|
||||
insecure_memzero(tmp32, 288);
|
||||
}
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Init(ctx, K, Klen):
|
||||
* Initialize the HMAC-SHA256 context ${ctx} with ${Klen} bytes of key from
|
||||
* ${K}.
|
||||
*/
|
||||
static void
|
||||
_HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen,
|
||||
uint32_t tmp32[static_restrict 72], uint8_t pad[static_restrict 64],
|
||||
uint8_t khash[static_restrict 32])
|
||||
{
|
||||
const uint8_t * K = _K;
|
||||
size_t i;
|
||||
|
||||
/* If Klen > 64, the key is really SHA256(K). */
|
||||
if (Klen > 64) {
|
||||
SHA256_Init(&ctx->ictx);
|
||||
_SHA256_Update(&ctx->ictx, K, Klen, tmp32);
|
||||
_SHA256_Final(khash, &ctx->ictx, tmp32);
|
||||
K = khash;
|
||||
Klen = 32;
|
||||
}
|
||||
|
||||
/* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */
|
||||
SHA256_Init(&ctx->ictx);
|
||||
memset(pad, 0x36, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
_SHA256_Update(&ctx->ictx, pad, 64, tmp32);
|
||||
|
||||
/* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */
|
||||
SHA256_Init(&ctx->octx);
|
||||
memset(pad, 0x5c, 64);
|
||||
for (i = 0; i < Klen; i++)
|
||||
pad[i] ^= K[i];
|
||||
_SHA256_Update(&ctx->octx, pad, 64, tmp32);
|
||||
}
|
||||
|
||||
/* Wrapper function for intermediate-values sanitization. */
|
||||
void
|
||||
HMAC_SHA256_Init(HMAC_SHA256_CTX * ctx, const void * _K, size_t Klen)
|
||||
{
|
||||
uint32_t tmp32[72];
|
||||
uint8_t pad[64];
|
||||
uint8_t khash[32];
|
||||
|
||||
/* Call the real function. */
|
||||
_HMAC_SHA256_Init(ctx, _K, Klen, tmp32, pad, khash);
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(tmp32, 288);
|
||||
insecure_memzero(khash, 32);
|
||||
insecure_memzero(pad, 64);
|
||||
}
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Update(ctx, in, len):
|
||||
* Input ${len} bytes from ${in} into the HMAC-SHA256 context ${ctx}.
|
||||
*/
|
||||
static void
|
||||
_HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void * in, size_t len,
|
||||
uint32_t tmp32[static_restrict 72])
|
||||
{
|
||||
|
||||
/* Feed data to the inner SHA256 operation. */
|
||||
_SHA256_Update(&ctx->ictx, in, len, tmp32);
|
||||
}
|
||||
|
||||
/* Wrapper function for intermediate-values sanitization. */
|
||||
void
|
||||
HMAC_SHA256_Update(HMAC_SHA256_CTX * ctx, const void * in, size_t len)
|
||||
{
|
||||
uint32_t tmp32[72];
|
||||
|
||||
/* Call the real function. */
|
||||
_HMAC_SHA256_Update(ctx, in, len, tmp32);
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(tmp32, 288);
|
||||
}
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Final(digest, ctx):
|
||||
* Output the HMAC-SHA256 of the data input to the context ${ctx} into the
|
||||
* buffer ${digest}.
|
||||
*/
|
||||
static void
|
||||
_HMAC_SHA256_Final(uint8_t digest[32], HMAC_SHA256_CTX * ctx,
|
||||
uint32_t tmp32[static_restrict 72], uint8_t ihash[static_restrict 32])
|
||||
{
|
||||
|
||||
/* Finish the inner SHA256 operation. */
|
||||
_SHA256_Final(ihash, &ctx->ictx, tmp32);
|
||||
|
||||
/* Feed the inner hash to the outer SHA256 operation. */
|
||||
_SHA256_Update(&ctx->octx, ihash, 32, tmp32);
|
||||
|
||||
/* Finish the outer SHA256 operation. */
|
||||
_SHA256_Final(digest, &ctx->octx, tmp32);
|
||||
}
|
||||
|
||||
/* Wrapper function for intermediate-values sanitization. */
|
||||
void
|
||||
HMAC_SHA256_Final(uint8_t digest[32], HMAC_SHA256_CTX * ctx)
|
||||
{
|
||||
uint32_t tmp32[72];
|
||||
uint8_t ihash[32];
|
||||
|
||||
/* Call the real function. */
|
||||
_HMAC_SHA256_Final(digest, ctx, tmp32, ihash);
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(tmp32, 288);
|
||||
insecure_memzero(ihash, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Buf(K, Klen, in, len, digest):
|
||||
* Compute the HMAC-SHA256 of ${len} bytes from ${in} using the key ${K} of
|
||||
* length ${Klen}, and write the result to ${digest}.
|
||||
*/
|
||||
void
|
||||
HMAC_SHA256_Buf(const void * K, size_t Klen, const void * in, size_t len,
|
||||
uint8_t digest[32])
|
||||
{
|
||||
HMAC_SHA256_CTX ctx;
|
||||
uint32_t tmp32[72];
|
||||
uint8_t tmp8[96];
|
||||
|
||||
_HMAC_SHA256_Init(&ctx, K, Klen, tmp32, &tmp8[0], &tmp8[64]);
|
||||
_HMAC_SHA256_Update(&ctx, in, len, tmp32);
|
||||
_HMAC_SHA256_Final(digest, &ctx, tmp32, &tmp8[0]);
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(&ctx, sizeof(HMAC_SHA256_CTX));
|
||||
insecure_memzero(tmp32, 288);
|
||||
insecure_memzero(tmp8, 96);
|
||||
}
|
||||
|
||||
/* Add padding and terminating bit-count, but don't invoke Transform yet. */
|
||||
static int
|
||||
SHA256_Pad_Almost(SHA256_CTX * ctx, uint8_t len[static_restrict 8],
|
||||
uint32_t tmp32[static_restrict 72])
|
||||
{
|
||||
uint32_t r;
|
||||
|
||||
r = (ctx->count >> 3) & 0x3f;
|
||||
if (r >= 56)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* Convert length to a vector of bytes -- we do this now rather
|
||||
* than later because the length will change after we pad.
|
||||
*/
|
||||
be64enc(len, ctx->count);
|
||||
|
||||
/* Add 1--56 bytes so that the resulting length is 56 mod 64. */
|
||||
_SHA256_Update(ctx, PAD, 56 - r, tmp32);
|
||||
|
||||
/* Add the terminating bit-count. */
|
||||
ctx->buf[63] = len[7];
|
||||
_SHA256_Update(ctx, len, 7, tmp32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
||||
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
|
||||
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
|
||||
*/
|
||||
void
|
||||
PBKDF2_SHA256(const uint8_t * passwd, size_t passwdlen, const uint8_t * salt,
|
||||
size_t saltlen, uint64_t c, uint8_t * buf, size_t dkLen)
|
||||
{
|
||||
HMAC_SHA256_CTX Phctx, PShctx, hctx;
|
||||
uint32_t tmp32[72];
|
||||
union {
|
||||
uint8_t tmp8[96];
|
||||
uint32_t state[8];
|
||||
} u;
|
||||
size_t i;
|
||||
uint8_t ivec[4];
|
||||
uint8_t U[32];
|
||||
uint8_t T[32];
|
||||
uint64_t j;
|
||||
int k;
|
||||
size_t clen;
|
||||
|
||||
/* Sanity-check. */
|
||||
assert(dkLen <= 32 * (size_t)(UINT32_MAX));
|
||||
|
||||
if (c == 1 && (dkLen & 31) == 0 && (saltlen & 63) <= 51) {
|
||||
uint32_t oldcount;
|
||||
uint8_t * ivecp;
|
||||
|
||||
/* Compute HMAC state after processing P and S. */
|
||||
_HMAC_SHA256_Init(&hctx, passwd, passwdlen,
|
||||
tmp32, &u.tmp8[0], &u.tmp8[64]);
|
||||
_HMAC_SHA256_Update(&hctx, salt, saltlen, tmp32);
|
||||
|
||||
/* Prepare ictx padding. */
|
||||
oldcount = hctx.ictx.count & (0x3f << 3);
|
||||
_HMAC_SHA256_Update(&hctx, "\0\0\0", 4, tmp32);
|
||||
if ((hctx.ictx.count & (0x3f << 3)) < oldcount ||
|
||||
SHA256_Pad_Almost(&hctx.ictx, u.tmp8, tmp32))
|
||||
goto generic; /* Can't happen due to saltlen check */
|
||||
ivecp = hctx.ictx.buf + (oldcount >> 3);
|
||||
|
||||
/* Prepare octx padding. */
|
||||
hctx.octx.count += 32 << 3;
|
||||
SHA256_Pad_Almost(&hctx.octx, u.tmp8, tmp32);
|
||||
|
||||
/* Iterate through the blocks. */
|
||||
for (i = 0; i * 32 < dkLen; i++) {
|
||||
/* Generate INT(i + 1). */
|
||||
be32enc(ivecp, (uint32_t)(i + 1));
|
||||
|
||||
/* Compute U_1 = PRF(P, S || INT(i)). */
|
||||
memcpy(u.state, hctx.ictx.state, sizeof(u.state));
|
||||
SHA256_Transform(u.state, hctx.ictx.buf,
|
||||
&tmp32[0], &tmp32[64]);
|
||||
be32enc_vect(hctx.octx.buf, u.state, 4);
|
||||
memcpy(u.state, hctx.octx.state, sizeof(u.state));
|
||||
SHA256_Transform(u.state, hctx.octx.buf,
|
||||
&tmp32[0], &tmp32[64]);
|
||||
be32enc_vect(&buf[i * 32], u.state, 4);
|
||||
}
|
||||
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
generic:
|
||||
/* Compute HMAC state after processing P. */
|
||||
_HMAC_SHA256_Init(&Phctx, passwd, passwdlen,
|
||||
tmp32, &u.tmp8[0], &u.tmp8[64]);
|
||||
|
||||
/* Compute HMAC state after processing P and S. */
|
||||
memcpy(&PShctx, &Phctx, sizeof(HMAC_SHA256_CTX));
|
||||
_HMAC_SHA256_Update(&PShctx, salt, saltlen, tmp32);
|
||||
|
||||
/* Iterate through the blocks. */
|
||||
for (i = 0; i * 32 < dkLen; i++) {
|
||||
/* Generate INT(i + 1). */
|
||||
be32enc(ivec, (uint32_t)(i + 1));
|
||||
|
||||
/* Compute U_1 = PRF(P, S || INT(i)). */
|
||||
memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX));
|
||||
_HMAC_SHA256_Update(&hctx, ivec, 4, tmp32);
|
||||
_HMAC_SHA256_Final(T, &hctx, tmp32, u.tmp8);
|
||||
|
||||
if (c > 1) {
|
||||
/* T_i = U_1 ... */
|
||||
memcpy(U, T, 32);
|
||||
|
||||
for (j = 2; j <= c; j++) {
|
||||
/* Compute U_j. */
|
||||
memcpy(&hctx, &Phctx, sizeof(HMAC_SHA256_CTX));
|
||||
_HMAC_SHA256_Update(&hctx, U, 32, tmp32);
|
||||
_HMAC_SHA256_Final(U, &hctx, tmp32, u.tmp8);
|
||||
|
||||
/* ... xor U_j ... */
|
||||
for (k = 0; k < 32; k++)
|
||||
T[k] ^= U[k];
|
||||
}
|
||||
}
|
||||
|
||||
/* Copy as many bytes as necessary into buf. */
|
||||
clen = dkLen - i * 32;
|
||||
if (clen > 32)
|
||||
clen = 32;
|
||||
memcpy(&buf[i * 32], T, clen);
|
||||
}
|
||||
|
||||
/* Clean the stack. */
|
||||
insecure_memzero(&Phctx, sizeof(HMAC_SHA256_CTX));
|
||||
insecure_memzero(&PShctx, sizeof(HMAC_SHA256_CTX));
|
||||
insecure_memzero(U, 32);
|
||||
insecure_memzero(T, 32);
|
||||
|
||||
cleanup:
|
||||
insecure_memzero(&hctx, sizeof(HMAC_SHA256_CTX));
|
||||
insecure_memzero(tmp32, 288);
|
||||
insecure_memzero(&u, sizeof(u));
|
||||
}
|
129
src/crypto/randomx/panthera/sha256.h
Normal file
129
src/crypto/randomx/panthera/sha256.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*-
|
||||
* Copyright 2005-2016 Colin Percival
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SHA256_H_
|
||||
#define _SHA256_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use #defines in order to avoid namespace collisions with anyone else's
|
||||
* SHA256 code (e.g., the code in OpenSSL).
|
||||
*/
|
||||
#define SHA256_Init libcperciva_SHA256_Init
|
||||
#define SHA256_Update libcperciva_SHA256_Update
|
||||
#define SHA256_Final libcperciva_SHA256_Final
|
||||
#define SHA256_Buf libcperciva_SHA256_Buf
|
||||
#define SHA256_CTX libcperciva_SHA256_CTX
|
||||
#define HMAC_SHA256_Init libcperciva_HMAC_SHA256_Init
|
||||
#define HMAC_SHA256_Update libcperciva_HMAC_SHA256_Update
|
||||
#define HMAC_SHA256_Final libcperciva_HMAC_SHA256_Final
|
||||
#define HMAC_SHA256_Buf libcperciva_HMAC_SHA256_Buf
|
||||
#define HMAC_SHA256_CTX libcperciva_HMAC_SHA256_CTX
|
||||
|
||||
/* Context structure for SHA256 operations. */
|
||||
typedef struct {
|
||||
uint32_t state[8];
|
||||
uint64_t count;
|
||||
uint8_t buf[64];
|
||||
} SHA256_CTX;
|
||||
|
||||
/**
|
||||
* SHA256_Init(ctx):
|
||||
* Initialize the SHA256 context ${ctx}.
|
||||
*/
|
||||
void SHA256_Init(SHA256_CTX *);
|
||||
|
||||
/**
|
||||
* SHA256_Update(ctx, in, len):
|
||||
* Input ${len} bytes from ${in} into the SHA256 context ${ctx}.
|
||||
*/
|
||||
void SHA256_Update(SHA256_CTX *, const void *, size_t);
|
||||
|
||||
/**
|
||||
* SHA256_Final(digest, ctx):
|
||||
* Output the SHA256 hash of the data input to the context ${ctx} into the
|
||||
* buffer ${digest}.
|
||||
*/
|
||||
void SHA256_Final(uint8_t[32], SHA256_CTX *);
|
||||
|
||||
/**
|
||||
* SHA256_Buf(in, len, digest):
|
||||
* Compute the SHA256 hash of ${len} bytes from ${in} and write it to ${digest}.
|
||||
*/
|
||||
void SHA256_Buf(const void *, size_t, uint8_t[32]);
|
||||
|
||||
/* Context structure for HMAC-SHA256 operations. */
|
||||
typedef struct {
|
||||
SHA256_CTX ictx;
|
||||
SHA256_CTX octx;
|
||||
} HMAC_SHA256_CTX;
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Init(ctx, K, Klen):
|
||||
* Initialize the HMAC-SHA256 context ${ctx} with ${Klen} bytes of key from
|
||||
* ${K}.
|
||||
*/
|
||||
void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t);
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Update(ctx, in, len):
|
||||
* Input ${len} bytes from ${in} into the HMAC-SHA256 context ${ctx}.
|
||||
*/
|
||||
void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t);
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Final(digest, ctx):
|
||||
* Output the HMAC-SHA256 of the data input to the context ${ctx} into the
|
||||
* buffer ${digest}.
|
||||
*/
|
||||
void HMAC_SHA256_Final(uint8_t[32], HMAC_SHA256_CTX *);
|
||||
|
||||
/**
|
||||
* HMAC_SHA256_Buf(K, Klen, in, len, digest):
|
||||
* Compute the HMAC-SHA256 of ${len} bytes from ${in} using the key ${K} of
|
||||
* length ${Klen}, and write the result to ${digest}.
|
||||
*/
|
||||
void HMAC_SHA256_Buf(const void *, size_t, const void *, size_t, uint8_t[32]);
|
||||
|
||||
/**
|
||||
* PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
|
||||
* Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
|
||||
* write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
|
||||
*/
|
||||
void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t,
|
||||
uint64_t, uint8_t *, size_t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_SHA256_H_ */
|
94
src/crypto/randomx/panthera/sysendian.h
Normal file
94
src/crypto/randomx/panthera/sysendian.h
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*-
|
||||
* Copyright 2007-2014 Colin Percival
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SYSENDIAN_H_
|
||||
#define _SYSENDIAN_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* Avoid namespace collisions with BSD <sys/endian.h>. */
|
||||
#define be32dec libcperciva_be32dec
|
||||
#define be32enc libcperciva_be32enc
|
||||
#define be64enc libcperciva_be64enc
|
||||
#define le32dec libcperciva_le32dec
|
||||
#define le32enc libcperciva_le32enc
|
||||
|
||||
static inline uint32_t
|
||||
be32dec(const void * pp)
|
||||
{
|
||||
const uint8_t * p = (uint8_t const *)pp;
|
||||
|
||||
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
|
||||
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
|
||||
}
|
||||
|
||||
static inline void
|
||||
be32enc(void * pp, uint32_t x)
|
||||
{
|
||||
uint8_t * p = (uint8_t *)pp;
|
||||
|
||||
p[3] = x & 0xff;
|
||||
p[2] = (x >> 8) & 0xff;
|
||||
p[1] = (x >> 16) & 0xff;
|
||||
p[0] = (x >> 24) & 0xff;
|
||||
}
|
||||
|
||||
static inline void
|
||||
be64enc(void * pp, uint64_t x)
|
||||
{
|
||||
uint8_t * p = (uint8_t *)pp;
|
||||
|
||||
p[7] = x & 0xff;
|
||||
p[6] = (x >> 8) & 0xff;
|
||||
p[5] = (x >> 16) & 0xff;
|
||||
p[4] = (x >> 24) & 0xff;
|
||||
p[3] = (x >> 32) & 0xff;
|
||||
p[2] = (x >> 40) & 0xff;
|
||||
p[1] = (x >> 48) & 0xff;
|
||||
p[0] = (x >> 56) & 0xff;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
le32dec(const void * pp)
|
||||
{
|
||||
const uint8_t * p = (uint8_t const *)pp;
|
||||
|
||||
return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) +
|
||||
((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24));
|
||||
}
|
||||
|
||||
static inline void
|
||||
le32enc(void * pp, uint32_t x)
|
||||
{
|
||||
uint8_t * p = (uint8_t *)pp;
|
||||
|
||||
p[0] = x & 0xff;
|
||||
p[1] = (x >> 8) & 0xff;
|
||||
p[2] = (x >> 16) & 0xff;
|
||||
p[3] = (x >> 24) & 0xff;
|
||||
}
|
||||
|
||||
#endif /* !_SYSENDIAN_H_ */
|
1161
src/crypto/randomx/panthera/yespower-opt.c
Normal file
1161
src/crypto/randomx/panthera/yespower-opt.c
Normal file
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue