-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asiotest: working multi-thread crypto bench; with start barier #454
Conversation
…ze: 64 has Gbit/s: 2.85008 (CompDragon-v1)
asiotest: cryptotest moving to lambda for multi-thread crypto [bad] asiotest: crypto bench MT starts to work; also debug changes [fix] average tool - rouding by mistake (though old results are fine since it was operating on large numers) asiotest: crypto bench MT giving correct results asiotest: crypto bench MT giving correct results - removed test 0.001 ! asiotest: crypto bench iterates via threads, on thr=-2 argument netmodel: debug segfault in bench asiotest: cosmetic aisotest: [bad] showing the bug: after all lambda param buf was NOT duplicated since var was already a reference asiotest: [bad] testing lambda memory [fix] this is the other bug causing crash asiotest: [ok] crypto multithread fixes membug; using cv as start barier
} | ||
|
||
// poly auth | ||
unsigned char key[crypto_onetimeauth_KEYBYTES]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗
auto thread_lambda = [&init_buffer_lambda, &thread_results, &iterations, this, &thread_cv, &thread_mutex, &threads_started, &trigger_cv, &thread_ready_flag] | ||
(size_t buff_size, size_t return_array_index) { | ||
try { | ||
stdplus::affinity::set_current_thread_affinity(return_array_index % 8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗
trigger_cv.wait(lg, [&threads_started]{return threads_started;}); // wait for start | ||
|
||
auto start_point = std::chrono::steady_clock::now(); | ||
for (size_t j=0; j<iterations; j++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be iterations/number _of all threads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗
std::vector<unsigned char> outbuff(buff_size); | ||
init_buffer_lambda(inbuff.data(), outbuff.data(), buff_size, buff_size); | ||
|
||
std::unique_lock<std::mutex> lg(thread_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unlock this after trigger_cv.wait()
thread_ready_flag.fill(false); // all threads are not ready | ||
for (size_t j=0; j<=threads_count; j++) // iterate through threads count | ||
{ | ||
threads.at(j) = std::move(std::thread(thread_lambda, i, j)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🆗
src-tools/netmodel/netmodel.cpp
Outdated
} | ||
|
||
void t_crypt_opt::calculate() { | ||
if (threads == -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not in constructor?
src-tools/netmodel/netmodel.cpp
Outdated
auto my_speed = my_this->time_finish( msg_buf_size * (test_repeat - test_repeat_point1) , local_time_started ); | ||
_dbg2("work#"<<worker_nr<<" done, speed=" << my_speed); | ||
worker_result.at(worker_nr) = my_speed; | ||
} catch(const std::exception & ex) { _erro("Worker thread error: " << ex.what()); throw ; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::terminate for any exception
src-tools/netmodel/netmodel.cpp
Outdated
c_crypto_benchloop<F, allow_mt, max_threads_count> | ||
::time_finish(size_t bytes_transferred, std::chrono::time_point<std::chrono::steady_clock> time_started) { | ||
auto end_point = std::chrono::steady_clock::now(); // [timer] | ||
auto ellapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end_point - time_started).count() / (1000.*1000.*1000.f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 1000.f ?
src-tools/netmodel/netmodel.cpp
Outdated
c_crypto_benchloop<decltype(crypto_func_veri_and_auth),false,1> benchloop(crypto_func_veri_and_auth); | ||
speed_gbps = benchloop.run_test_4buf(bench_opt, msg_buf, two_buf, key_buf, keyB_buf); | ||
} break; | ||
default: throw runtime_error("Unknown crypto_op (enum)"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw std::invalid_argument
src-tools/tools_helper.hpp
Outdated
} | ||
|
||
template<typename TFloat> | ||
TFloat average(std::vector<TFloat> tab) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe std::is_floating_point for TFloat?
…h invalida address of buf_nonce that is shared, and that was 0 because lambda was created too soon
…arier 7ed66fe asiotest: [fix] deb9 clang; and cryptobench format crypto_op as number too (Rafal Crypto Tigusoft) 80170fb asiotest: crypto bench debt - explain memleak at end sometimes (ASAN) (Rafal Crypto Tigusoft) e477ae7 gnuplot scrypt for poly auth (Rysiek) 466a1c6 review fixes (Rysiek) d84a98a asiotest: crypto bench after review PR#454 (Rafal Crypto Tigusoft) beb2088 add chacha20 bench, use e_crypto_test enum (Robert Oleksy) 7d5990e create enum for crypto tests (Robert Oleksy) af4d9b2 asiotest: crypto: start -100 all crypto; AND [fix] really the bug with invalida address of buf_nonce that is shared, and that was 0 because lambda was created too soon (Rafal Crypto Tigusoft) 9b672a5 asiotest: style fixes, removed older example barier (Rafal Crypto Tigusoft) e9a774a (rfree commiting for rob) - threads/cv example (copy) (Uviner) 03c8bb8 asiotest: crypto box operations, and verify+auth2 (Rafal Crypto Tigusoft) 0619c8a asiotest: cryptobench decrypt/encrypt (Rafal Crypto Tigusoft) 98f027d asiotest: cryptobench using samples/mediana; other ranges (Rafal Crypto Tigusoft) c56478b asiotest: crypto bench some reaftoring, 3buf; mved modify buf to function (Rafal Crypto Tigusoft) 7ff3a6d asiotest: crypto bench lambda; speed same? Speed auth_poly1305 msg_size: 64 has Gbit/s: 2.85008 (CompDragon-v1) (Rafal Crypto Tigusoft) 5346e8d asiotest: crypto auth depending on msg size (ranges) (Rafal Crypto Tigusoft) 6c238be asiotest: crypto for auth, 3% stability in restults. 1 thread (Rafal Crypto Tigusoft) 408bf80 asiotest: moving crypto bench tests (by Rob/Mikurys) to hpp (Rafal Crypto Tigusoft) c8b036a Draft cryptobench netmodel, gnuplot (Mikurys,Robert) (Rysiek) 292dee0 Cryptobench stub (Rafal Crypto Tigusoft) 50b41e6 crypto_bench (KrystianTigusoft)
multi thread should work well
start barier (countdown, cv)