mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 19:57:48 +02:00
add force usage of cpu instructions, update GH actions
This commit is contained in:
parent
faf04def31
commit
ee8d5e9a0c
10 changed files with 51 additions and 37 deletions
20
.github/workflows/build-qt.yml
vendored
20
.github/workflows/build-qt.yml
vendored
|
@ -1,20 +0,0 @@
|
||||||
name: Build on Ubuntu
|
|
||||||
|
|
||||||
on: [push, pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: With QT GUI
|
|
||||||
runs-on: ubuntu-16.04
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: install packages
|
|
||||||
run: |
|
|
||||||
sudo add-apt-repository ppa:mhier/libboost-latest
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install build-essential qt5-default libqt5gui5 libboost1.74-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
|
||||||
- name: build application
|
|
||||||
run: |
|
|
||||||
cd qt/i2pd_qt
|
|
||||||
qmake I2PDMAKE+="USE_AESNI=no"
|
|
||||||
make -j3
|
|
21
.github/workflows/build.yml
vendored
21
.github/workflows/build.yml
vendored
|
@ -2,10 +2,12 @@ name: Build on Ubuntu
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
runs-on: ubuntu-16.04
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: With USE_UPNP=${{ matrix.with_upnp }}
|
name: With USE_UPNP=${{ matrix.with_upnp }}
|
||||||
runs-on: ubuntu-16.04
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
|
@ -18,4 +20,19 @@ jobs:
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install build-essential libboost1.74-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
sudo apt-get install build-essential libboost1.74-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
||||||
- name: build application
|
- name: build application
|
||||||
run: make USE_AESNI=no USE_UPNP=${{ matrix.with_upnp }} -j3
|
run: make USE_UPNP=${{ matrix.with_upnp }} -j3
|
||||||
|
|
||||||
|
build_qt:
|
||||||
|
name: With QT GUI
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: install packages
|
||||||
|
run: |
|
||||||
|
sudo add-apt-repository ppa:mhier/libboost-latest
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install build-essential qt5-default libqt5gui5 libboost1.74-dev libminiupnpc-dev libssl-dev zlib1g-dev
|
||||||
|
- name: build application
|
||||||
|
run: |
|
||||||
|
cd qt/i2pd_qt
|
||||||
|
qmake
|
||||||
|
make -j3
|
|
@ -229,3 +229,12 @@ verify = true
|
||||||
[persist]
|
[persist]
|
||||||
## Save peer profiles on disk (default: true)
|
## Save peer profiles on disk (default: true)
|
||||||
# profiles = true
|
# profiles = true
|
||||||
|
|
||||||
|
[cpuext]
|
||||||
|
## Use CPU AES-NI instructions set when work with cryptography when available (default: true)
|
||||||
|
# aesni = true
|
||||||
|
## Use CPU AVX instructions set when work with cryptography when available (default: true)
|
||||||
|
# avx = true
|
||||||
|
## Force usage of CPU instructions set, even if they not found
|
||||||
|
## DO NOT TOUCH that option if you really don't know what are you doing!
|
||||||
|
# force = false
|
|
@ -128,9 +128,10 @@ namespace i2p
|
||||||
LogPrint(eLogDebug, "FS: data directory: ", datadir);
|
LogPrint(eLogDebug, "FS: data directory: ", datadir);
|
||||||
|
|
||||||
bool precomputation; i2p::config::GetOption("precomputation.elgamal", precomputation);
|
bool precomputation; i2p::config::GetOption("precomputation.elgamal", precomputation);
|
||||||
bool aesni; i2p::config::GetOption("aesni", aesni);
|
bool aesni; i2p::config::GetOption("cpuext.aesni", aesni);
|
||||||
bool avx; i2p::config::GetOption("avx", avx);
|
bool avx; i2p::config::GetOption("cpuext.avx", avx);
|
||||||
i2p::crypto::InitCrypto (precomputation, aesni, avx);
|
bool forceCpuExt; i2p::config::GetOption("cpuext.force", forceCpuExt);
|
||||||
|
i2p::crypto::InitCrypto (precomputation, aesni, avx, forceCpuExt);
|
||||||
|
|
||||||
int netID; i2p::config::GetOption("netid", netID);
|
int netID; i2p::config::GetOption("netid", netID);
|
||||||
i2p::context.SetNetID (netID);
|
i2p::context.SetNetID (netID);
|
||||||
|
|
|
@ -27,17 +27,17 @@ namespace cpu
|
||||||
bool aesni = false;
|
bool aesni = false;
|
||||||
bool avx = false;
|
bool avx = false;
|
||||||
|
|
||||||
void Detect(bool AesSwitch, bool AvxSwitch)
|
void Detect(bool AesSwitch, bool AvxSwitch, bool force)
|
||||||
{
|
{
|
||||||
#if defined(__x86_64__) || defined(__i386__)
|
#if defined(__x86_64__) || defined(__i386__)
|
||||||
int info[4];
|
int info[4];
|
||||||
__cpuid(0, info[0], info[1], info[2], info[3]);
|
__cpuid(0, info[0], info[1], info[2], info[3]);
|
||||||
if (info[0] >= 0x00000001) {
|
if (info[0] >= 0x00000001) {
|
||||||
__cpuid(0x00000001, info[0], info[1], info[2], info[3]);
|
__cpuid(0x00000001, info[0], info[1], info[2], info[3]);
|
||||||
if (info[2] & bit_AES && AesSwitch) {
|
if ((info[2] & bit_AES && AesSwitch) || (AesSwitch && force)) {
|
||||||
aesni = true;
|
aesni = true;
|
||||||
}
|
}
|
||||||
if (info[2] & bit_AVX && AvxSwitch) {
|
if ((info[2] & bit_AVX && AvxSwitch) || (AvxSwitch && force)) {
|
||||||
avx = true;
|
avx = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace cpu
|
||||||
extern bool aesni;
|
extern bool aesni;
|
||||||
extern bool avx;
|
extern bool avx;
|
||||||
|
|
||||||
void Detect(bool AesSwitch, bool AvxSwitch);
|
void Detect(bool AesSwitch, bool AvxSwitch, bool force);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,6 @@ namespace config {
|
||||||
("ntcp", bool_switch()->default_value(false), "Ignored. Always false")
|
("ntcp", bool_switch()->default_value(false), "Ignored. Always false")
|
||||||
("ssu", bool_switch()->default_value(true), "Enable SSU transport (default: enabled)")
|
("ssu", bool_switch()->default_value(true), "Enable SSU transport (default: enabled)")
|
||||||
("ntcpproxy", value<std::string>()->default_value(""), "Ignored")
|
("ntcpproxy", value<std::string>()->default_value(""), "Ignored")
|
||||||
("aesni", bool_switch()->default_value(true), "Use auto detection for AESNI CPU extensions. If false, AESNI will be not used")
|
|
||||||
("avx", bool_switch()->default_value(true), "Use auto detection for AVX CPU extensions. If false, AVX will be not used")
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
("svcctl", value<std::string>()->default_value(""), "Windows service management ('install' or 'remove')")
|
("svcctl", value<std::string>()->default_value(""), "Windows service management ('install' or 'remove')")
|
||||||
("insomnia", bool_switch()->default_value(false), "Prevent system from sleeping (default: disabled)")
|
("insomnia", bool_switch()->default_value(false), "Prevent system from sleeping (default: disabled)")
|
||||||
|
@ -268,6 +266,13 @@ namespace config {
|
||||||
("persist.addressbook", value<bool>()->default_value(true), "Persist full addresses (default: true)")
|
("persist.addressbook", value<bool>()->default_value(true), "Persist full addresses (default: true)")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
options_description cpuext("CPU encryption extensions options");
|
||||||
|
cpuext.add_options()
|
||||||
|
("cpuext.aesni", bool_switch()->default_value(true), "Use auto detection for AESNI CPU extensions. If false, AESNI will be not used")
|
||||||
|
("cpuext.avx", bool_switch()->default_value(true), "Use auto detection for AVX CPU extensions. If false, AVX will be not used")
|
||||||
|
("cpuext.force", bool_switch()->default_value(false), "Force usage of CPU extensions. Useful when cpuinfo is not available on virtual machines")
|
||||||
|
;
|
||||||
|
|
||||||
m_OptionsDesc
|
m_OptionsDesc
|
||||||
.add(general)
|
.add(general)
|
||||||
.add(limits)
|
.add(limits)
|
||||||
|
@ -288,6 +293,7 @@ namespace config {
|
||||||
.add(ntcp2)
|
.add(ntcp2)
|
||||||
.add(nettime)
|
.add(nettime)
|
||||||
.add(persist)
|
.add(persist)
|
||||||
|
.add(cpuext)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1345,9 +1345,9 @@ namespace crypto
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void InitCrypto (bool precomputation, bool aesni, bool avx)
|
void InitCrypto (bool precomputation, bool aesni, bool avx, bool force)
|
||||||
{
|
{
|
||||||
i2p::cpu::Detect (aesni, avx);
|
i2p::cpu::Detect (aesni, avx, force);
|
||||||
#if LEGACY_OPENSSL
|
#if LEGACY_OPENSSL
|
||||||
SSL_library_init ();
|
SSL_library_init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -319,7 +319,7 @@ namespace crypto
|
||||||
};
|
};
|
||||||
|
|
||||||
// init and terminate
|
// init and terminate
|
||||||
void InitCrypto (bool precomputation, bool aesni, bool avx);
|
void InitCrypto (bool precomputation, bool aesni, bool avx, bool force);
|
||||||
void TerminateCrypto ();
|
void TerminateCrypto ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,10 @@ namespace api
|
||||||
i2p::fs::Init();
|
i2p::fs::Init();
|
||||||
|
|
||||||
bool precomputation; i2p::config::GetOption("precomputation.elgamal", precomputation);
|
bool precomputation; i2p::config::GetOption("precomputation.elgamal", precomputation);
|
||||||
bool aesni; i2p::config::GetOption("aesni", aesni);
|
bool aesni; i2p::config::GetOption("cpuext.aesni", aesni);
|
||||||
bool avx; i2p::config::GetOption("avx", avx);
|
bool avx; i2p::config::GetOption("cpuext.avx", avx);
|
||||||
i2p::crypto::InitCrypto (precomputation, aesni, avx);
|
bool forceCpuExt; i2p::config::GetOption("cpuext.force", forceCpuExt);
|
||||||
|
i2p::crypto::InitCrypto (precomputation, aesni, avx, forceCpuExt);
|
||||||
|
|
||||||
int netID; i2p::config::GetOption("netid", netID);
|
int netID; i2p::config::GetOption("netid", netID);
|
||||||
i2p::context.SetNetID (netID);
|
i2p::context.SetNetID (netID);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue