/* XMRig * Copyright 2010 Jeff Garzik * Copyright 2012-2014 pooler * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , * Copyright 2018 Lee Clagett * Copyright 2016-2018 XMRig , * * 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 . */ #ifndef __CRYPTONIGHT_CONSTANTS_H__ #define __CRYPTONIGHT_CONSTANTS_H__ #include #include "common/xmrig.h" namespace xmrig { constexpr const size_t CRYPTONIGHT_MEMORY = 2 * 1024 * 1024; constexpr const uint32_t CRYPTONIGHT_MASK = 0x1FFFF0; constexpr const uint32_t CRYPTONIGHT_ITER = 0x80000; constexpr const size_t CRYPTONIGHT_LITE_MEMORY = 1 * 1024 * 1024; constexpr const uint32_t CRYPTONIGHT_LITE_MASK = 0xFFFF0; constexpr const uint32_t CRYPTONIGHT_LITE_ITER = 0x40000; constexpr const size_t CRYPTONIGHT_HEAVY_MEMORY = 4 * 1024 * 1024; constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0; constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000; template inline constexpr size_t cn_select_memory() { return 0; } template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_MEMORY; } template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_LITE_MEMORY; } template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_HEAVY_MEMORY; } inline size_t cn_select_memory(Algo algorithm) { switch(algorithm) { case CRYPTONIGHT: return CRYPTONIGHT_MEMORY; case CRYPTONIGHT_LITE: return CRYPTONIGHT_LITE_MEMORY; case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MEMORY; default: break; } return 0; } template inline constexpr uint32_t cn_select_mask() { return 0; } template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_MASK; } template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_LITE_MASK; } template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_HEAVY_MASK; } inline uint32_t cn_select_mask(Algo algorithm) { switch(algorithm) { case CRYPTONIGHT: return CRYPTONIGHT_MASK; case CRYPTONIGHT_LITE: return CRYPTONIGHT_LITE_MASK; case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MASK; default: break; } return 0; } template inline constexpr uint32_t cn_select_iter() { return 0; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } inline uint32_t cn_select_iter(Algo algorithm) { switch(algorithm) { case CRYPTONIGHT: return CRYPTONIGHT_ITER; case CRYPTONIGHT_LITE: return CRYPTONIGHT_LITE_ITER; case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_ITER; default: break; } return 0; } } /* namespace xmrig */ #endif /* __CRYPTONIGHT_CONSTANTS_H__ */