Skip to content

Commit

Permalink
build logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyFFM committed Oct 2, 2018
1 parent 538e3af commit 7d6ca2e
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 183 deletions.
21 changes: 0 additions & 21 deletions .vscode/c_cpp_properties.json

This file was deleted.

19 changes: 0 additions & 19 deletions .vscode/launch.json

This file was deleted.

7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ readme = "README.md"
[features]
opencl = ["ocl-core"]
neon = []
arm = []
simd = []

[dependencies]
hyper = "0.12"
Expand Down
108 changes: 51 additions & 57 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,81 +25,75 @@ fn main() {
.compile("shabal");

cfg_if! {
if #[cfg(feature = "arm")] {
if #[cfg(feature = "neon")] {
fn build(shared_config: cc::Build){
let mut config = shared_config.clone();

#[cfg(not(feature = "neon"))]
drop(shared_config);
#[cfg(not(target_env = "msvc"))]
config.flag("-mfpu=neon");

#[cfg(feature = "neon")]
let mut config = shared_config.clone();

#[cfg(all(not(target_env = "msvc"), feature = "neon"))]
config.flag("-mfpu=neon");

#[cfg(feature = "neon")]
config
.file("src/c/mshabal_128_neon.c")
.file("src/c/shabal_neon.c")
.compile("shabal_neon");
config
.file("src/c/mshabal_128_neon.c")
.file("src/c/shabal_neon.c")
.compile("shabal_neon");
}
}
}

cfg_if! {
if #[cfg(feature = "simd")] {
fn build(shared_config: cc::Build){
let mut config = shared_config.clone();

#[cfg(not(target_env = "msvc"))]
config.flag("-msse2");

config
.file("src/c/mshabal_128_sse2.c")
.file("src/c/shabal_sse2.c")
.compile("shabal_sse2");

} else {

//start x64
fn build(shared_config: cc::Build){
let mut config = shared_config.clone();

#[cfg(not(target_env = "msvc"))]
config.flag("-msse2");

config
.file("src/c/mshabal_128_sse2.c")
.file("src/c/shabal_sse2.c")
.compile("shabal_sse2");

let mut config = shared_config.clone();
let mut config = shared_config.clone();

#[cfg(target_env = "msvc")]
config.flag("/arch:AVX");
#[cfg(target_env = "msvc")]
config.flag("/arch:AVX");

#[cfg(not(target_env = "msvc"))]
config.flag("-mavx");
#[cfg(not(target_env = "msvc"))]
config.flag("-mavx");

config
.file("src/c/mshabal_128_avx.c")
.file("src/c/shabal_avx.c")
.compile("shabal_avx");
config
.file("src/c/mshabal_128_avx.c")
.file("src/c/shabal_avx.c")
.compile("shabal_avx");

let mut config = shared_config.clone();
let mut config = shared_config.clone();

#[cfg(target_env = "msvc")]
config.flag("/arch:AVX2");
#[cfg(target_env = "msvc")]
config.flag("/arch:AVX2");

#[cfg(not(target_env = "msvc"))]
config.flag("-mavx2");
#[cfg(not(target_env = "msvc"))]
config.flag("-mavx2");

config
.file("src/c/mshabal_256_avx2.c")
.file("src/c/shabal_avx2.c")
.compile("shabal_avx2");
config
.file("src/c/mshabal_256_avx2.c")
.file("src/c/shabal_avx2.c")
.compile("shabal_avx2");

let mut config = shared_config.clone();
let mut config = shared_config.clone();

#[cfg(target_env = "msvc")]
config.flag("/arch:AVX512F");
#[cfg(target_env = "msvc")]
config.flag("/arch:AVX512F");

#[cfg(not(target_env = "msvc"))]
config.flag("-mavx512f");
#[cfg(not(target_env = "msvc"))]
config.flag("-mavx512f");

config
.file("src/c/mshabal_512_avx512f.c")
.file("src/c/shabal_avx512f.c")
.compile("shabal_avx512f");
}}
}
config
.file("src/c/mshabal_512_avx512f.c")
.file("src/c/shabal_avx512f.c")
.compile("shabal_avx512f");
}
}
}
#[cfg(any(feature = "simd", feature = "neon"))]
build(shared_config);
}
8 changes: 2 additions & 6 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ account_id_to_secret_phrase: # define accounts and passphrases

plot_dirs:
- 'test_data'
- 'd:\plot'

# - 'C:\second\windows\plot\dir'
# - '/first/linux/plot/dir'
# - '/second/linux/plot/dir'

# url: 'http://pool.dev.burst-test.net:8124' # testnet pool
# url: 'http://wallet.dev.burst-test.net:6876' # testnet wallet
url: 'https://wallet.burst.cryptoguru.org:8125' # cg wallet

url: 'http://wallet.dev.burst-test.net:6876' # testnet wallet
# url: 'http://dummypool.megash.it' # dummypool with constant scoop number for benchmarking

hdd_reader_thread_count: 0 # default 0 (=number of disks)
Expand Down Expand Up @@ -51,4 +47,4 @@ logfile_log_pattern: "{({d(%Y-%m-%d %H:%M:%S)} [{l}]):26.26} {m}{n}"

# More detailed log patterns
#console_log_pattern: "{d(%H:%M:%S.%3f%z)} [{h({l}):<5}] [{T}] [{t}] - {M}:{m}{n}"
#logfile_log_pattern: "{d(%Y-%m-%dT%H:%M:%S.%3f%z)} [{h({l}):<5}] [{T}]-[{t}] [{f}:{L}] - {M}:{m}{n}"
#logfile_log_pattern: "{d(%Y-%m-%dT%H:%M:%S.%3f%z)} [{h({l}):<5}] [{T}]-[{t}] [{f}:{L}] - {M}:{m}{n}"
87 changes: 52 additions & 35 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,59 @@ use config::load_cfg;
use miner::Miner;
use std::process;

extern "C" {
#[cfg(not(feature = "arm"))]
pub fn init_shabal_avx512f() -> ();
#[cfg(not(feature = "arm"))]
pub fn init_shabal_avx2() -> ();
#[cfg(not(feature = "arm"))]
pub fn init_shabal_avx() -> ();
#[cfg(not(feature = "arm"))]
pub fn init_shabal_sse2() -> ();
}

fn init_simd_extensions() {
if is_x86_feature_detected!("avx512f") {
info!("SIMD extensions: AVX512F");
#[cfg(not(feature = "arm"))]
unsafe {
init_shabal_avx512f();
cfg_if! {
if #[cfg(feature = "simd")] {
extern "C" {
pub fn init_shabal_avx512f() -> ();
pub fn init_shabal_avx2() -> ();
pub fn init_shabal_avx() -> ();
pub fn init_shabal_sse2() -> ();
}
} else if is_x86_feature_detected!("avx2") {
info!("SIMD extensions: AVX2");
#[cfg(not(feature = "arm"))]
unsafe {
init_shabal_avx2();

fn init_cpu_extensions() {
if is_x86_feature_detected!("avx512f") {
info!("SIMD extensions: AVX512F");
unsafe {
init_shabal_avx512f();
}
} else if is_x86_feature_detected!("avx2") {
info!("SIMD extensions: AVX2");
unsafe {
init_shabal_avx2();
}
} else if is_x86_feature_detected!("avx") {
info!("SIMD extensions: AVX");
unsafe {
init_shabal_avx();
}
} else if is_x86_feature_detected!("sse2") {
info!("SIMD extensions: SSE2");
unsafe {
init_shabal_sse2();
}
} else {
info!("SIMD extensions: none");
}
}
} else if is_x86_feature_detected!("avx") {
info!("SIMD extensions: AVX");
#[cfg(not(feature = "arm"))]
unsafe {
init_shabal_avx();
}
}

cfg_if! {
if #[cfg(feature = "neon")] {
extern "C" {
pub fn init_shabal_neon() -> ();
}
} else if is_x86_feature_detected!("sse2") {
info!("SIMD extensions: SSE2");
#[cfg(not(feature = "arm"))]
unsafe {
init_shabal_sse2();

fn init_cpu_extensions() {
if is_x86_feature_detected!("neon") {
info!("SIMD extensions: NEON");
unsafe {
init_shabal_neon();
}
} else {
info!("SIMD extensions: none");
}
}
} else {
info!("SIMD extensions: none");
}
}

Expand Down Expand Up @@ -122,7 +137,9 @@ fn main() {
ocl::platform_info();
process::exit(0);
}
init_simd_extensions();

#[cfg(any(feature = "simd", feature = "neon"))]
init_cpu_extensions();
#[cfg(feature = "opencl")]
ocl::gpu_info(&cfg_loaded);

Expand Down
Loading

0 comments on commit 7d6ca2e

Please sign in to comment.