Detect CUDA

This commit is contained in:
Hanh 2022-08-14 10:56:42 +08:00
parent 9053a4c7c4
commit ef91e9d3a9
6 changed files with 21 additions and 8 deletions

View File

@ -88,8 +88,6 @@ node-bindgen = { version = "4.0", optional = true }
rustacuda = { version = "0.1.3", optional = true }
rustacuda_core = { version = "0.1.2", optional = true }
# ash-warp = { path = "../../../ash-warp", optional = true }
[features]
ledger = ["ledger-apdu", "hmac", "ed25519-bip32", "ledger-transport-hid"]
ledger_sapling = ["ledger"]
@ -97,7 +95,6 @@ dart_ffi = ["allo-isolate", "once_cell", "android_logger"]
rpc = ["rocket", "dotenv"]
nodejs = ["node-bindgen"]
cuda = ["rustacuda", "rustacuda_core"]
# vulkan = ["ash-warp"]
# librustzcash synced to 35023ed8ca2fb1061e78fd740b640d4eefcc5edd

View File

@ -13,8 +13,6 @@ typedef void *DartPostCObjectFnType;
#define QR_DATA_SIZE 256
#define MAX_OUTPUTS_PER_CHUNK 200000
void dummy_export(void);
void dart_post_cobject(DartPostCObjectFnType ptr);
@ -128,3 +126,5 @@ char *derive_zip32(uint8_t coin,
uint32_t external,
bool has_address,
uint32_t address);
bool has_cuda(void);

View File

@ -43,6 +43,7 @@ pub unsafe extern "C" fn deallocate_str(s: *mut c_char) {
}
fn try_init_logger() {
let _ = env_logger::try_init();
android_logger::init_once(
Config::default()
// .format(|buf, record| {
@ -61,7 +62,7 @@ fn try_init_logger() {
fn log_result<T: Default>(result: anyhow::Result<T>) -> T {
match result {
Err(err) => {
log::error!("{}", err);
log::error!("ERROR: {}", err);
let last_error = LAST_ERROR.lock().unwrap();
last_error.replace(err.to_string());
IS_ERROR.store(true, Ordering::Release);
@ -642,3 +643,8 @@ pub unsafe extern "C" fn derive_zip32(
};
to_c_str(log_string(res()))
}
#[no_mangle]
pub unsafe extern "C" fn has_cuda() -> bool {
crate::has_cuda()
}

View File

@ -101,7 +101,7 @@ pub enum ChainError {
fn get_mem_per_output() -> usize {
if cfg!(feature = "cuda") {
1000
250
} else {
5
}

View File

@ -12,7 +12,6 @@ use std::ffi::CString;
use zcash_note_encryption::Domain;
use zcash_primitives::consensus::{BlockHeight, Network};
use zcash_primitives::sapling::note_encryption::SaplingDomain;
use zcash_primitives::zip32::ExtendedFullViewingKey;
use crate::db::AccountViewKey;
const THREADS_PER_BLOCK: usize = 256usize;

View File

@ -97,3 +97,14 @@ pub mod nodejs;
#[cfg(feature = "cuda")]
mod cuda;
#[cfg(feature = "cuda")]
pub fn has_cuda() -> bool {
let cuda = cuda::CUDA_PROCESSOR.lock().unwrap();
return cuda.is_some();
}
#[cfg(not(feature = "cuda"))]
pub fn has_cuda() -> bool {
false
}