Skip to content

Commit

Permalink
Merge pull request #79 from tontechio/develop
Browse files Browse the repository at this point in the history
average speed fix
  • Loading branch information
tontechio authored Nov 19, 2021
2 parents 9734fcc + 10660f4 commit e624a4b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ if(MINERCUDA)
target_link_libraries(pow-miner-cuda-lib PUBLIC ton_crypto ton_block ${CUDA_LIBRARIES})

add_executable(pow-miner-cuda util/pow-miner.cpp)
target_compile_definitions(pow-miner-cuda PRIVATE MINERCUDA=${MINERCUDA} $<$<COMPILE_LANGUAGE:CUDA>:-gencode arch=compute_11,code=sm_11>)
target_compile_definitions(pow-miner-cuda PRIVATE MINERCUDA=${MINERCUDA})
target_link_libraries(pow-miner-cuda PRIVATE ton_crypto ton_block pow-miner-cuda-lib git)
endif()

Expand Down
2 changes: 2 additions & 0 deletions crypto/util/Miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ td::optional<std::string> build_mine_result(int cpu_id, ton::HDataEnv H, const t
if (memcmp(hash.data(), options.complexity.data(), 32) < 0) {
LOG(ERROR) << "FOUND! GPU ID: " << options.gpu_id << ", nonce=" << nonce << ", expired=" << expired;
return H.body.as_slice().str();
} else {
LOG(ERROR) << "OVERCLOCK DETECTED! GPU ID: " << options.gpu_id;
}
return {};
}
Expand Down
4 changes: 2 additions & 2 deletions crypto/util/cuda/credits.cu
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern "C" int scanhash_credits(int gpu_id, int cpu_id, ton::HDataEnv H, const t
expired = (uint32_t)td::Clocks::system() + 900;
td::Timestamp instant_start_at = td::Timestamp::now();
HashResult foundNonce = bitcredit_cpu_hash(gpu_id, cpu_id, options.gpu_threads, throughput, i, expired);
*options.instant_passed = td::Timestamp::now().at() - instant_start_at.at();
if (foundNonce.nonce != UINT64_MAX && foundNonce.vcpu != UINT64_MAX) {
pdata[0] = foundNonce.nonce;
pdata[1] = foundNonce.vcpu;
Expand All @@ -57,11 +58,10 @@ extern "C" int scanhash_credits(int gpu_id, int cpu_id, ton::HDataEnv H, const t
*options.hashes_computed += foundNonce.nonce * foundNonce.vcpu;
}
if (options.instant_hashes_computed) {
*options.instant_hashes_computed += foundNonce.nonce * foundNonce.vcpu;
*options.instant_hashes_computed = foundNonce.nonce * foundNonce.vcpu;
}
return 1;
}
*options.instant_passed = td::Timestamp::now().at() - instant_start_at.at();
i += throughput;
if (options.hashes_computed) {
*options.hashes_computed += throughput;
Expand Down
2 changes: 1 addition & 1 deletion crypto/util/opencl/sha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ td::optional<std::string> SHA256::run(ton::HDataEnv H, unsigned char *rdata, con
expired = (uint32_t)td::Clocks::system() + 900;
td::Timestamp instant_start_at = td::Timestamp::now();
HashResult foundNonce = opencl.scan_hash(cpu_id, options.gpu_threads, throughput, i, expired);
*options.instant_passed = td::Timestamp::now().at() - instant_start_at.at();
if (foundNonce.nonce != UINT64_MAX && foundNonce.vcpu != UINT64_MAX) {
if (options.hashes_computed) {
*options.hashes_computed += foundNonce.nonce * foundNonce.vcpu;
Expand All @@ -57,7 +58,6 @@ td::optional<std::string> SHA256::run(ton::HDataEnv H, unsigned char *rdata, con
return result;
}
}
*options.instant_passed = td::Timestamp::now().at() - instant_start_at.at();
i += throughput;
if (options.hashes_computed) {
*options.hashes_computed += throughput;
Expand Down
3 changes: 1 addition & 2 deletions tonlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ if(MINERCUDA)
include_directories("${CUDA_INCLUDE_DIRS}")

add_executable(tonlib-cuda-cli tonlib/tonlib-cli.cpp)
target_compile_definitions(tonlib-cuda-cli PRIVATE MINERCUDA=${MINERCUDA} $<$<COMPILE_LANGUAGE:CUDA>:-gencode arch=compute_11,code=sm_11>)

target_compile_definitions(tonlib-cuda-cli PRIVATE MINERCUDA=${MINERCUDA})
target_link_libraries(tonlib-cuda-cli tonlib tdactor tdutils terminal pow-miner-cuda-lib git ${CUDA_LIBRARIES})
endif()

Expand Down
1 change: 1 addition & 0 deletions tonlib/tonlib/tonlib-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ class TonlibCli : public td::actor::Actor {

if (miner_options_ && threads_.empty() && need_run_miners_) {
LOG(INFO) << "pminer: start workers";
hashes_computed_.store(0);
need_run_miners_ = false;
miner_options_copy_ = miner_options_.value();
miner_options_copy_.hashes_computed = &hashes_computed_;
Expand Down

0 comments on commit e624a4b

Please sign in to comment.