wichtounet / articles Goto Github PK
View Code? Open in Web Editor NEWSource code for my articles
License: MIT License
Source code for my articles
License: MIT License
it seems to be too late, but would you please update your sample code and blog text about condition_variable
:
the problem:
it's better to unlock the std::unique_lock<>
before calling notify_one();
:
l.unlock();
not_empty.notify_one();
Manual unlocking is done before notifying, to avoid waking up the waiting thread only to block again (see notify_one for details)
whenever i try to build i get the follwing error:
ld: unrecognized option '-DNDEBUG' *
*and all other options passed to it i tried.
Im using linux and tried gcc and clang to build it but nothing seems to work .
Hi, great articles!
Unfortunately, the overall build using
git clone --recursive https://github.com/wichtounet/articles.git
cd articles
make
Gives this error on my system:
clang++ -Iinclude -std=c++1y -Wextra -Wall -Qunused-arguments -Wuninitialized -Wsometimes-uninitialized -Wno-long-long -Winit-self -Wdocumentation -DSQRT_VALUE=5000000 -ICatch/include -g -DNDEBUG -O3 -fvectorize -fslp-vectorize-aggressive -fomit-frame-pointer -march=native -o release/src/threads/part1/Hello0.cpp.o -c src/threads/part1/Hello0.cpp
In file included from src/threads/part1/Hello0.cpp:8:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/thread:39:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/functional:55:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/tuple:39:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/array:38:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/stdexcept:39:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/string:52:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/bits/basic_string.h:2815:
In file included from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/ext/string_conversions.h:43:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.3/include/g++-v4/cstdio:120:11: error: no member named 'gets' in the global namespace
using ::gets;
~~^
1 error generated.
Makefile:17: recipe for target 'release/src/threads/part1/Hello0.cpp.o' failed
make: *** [release/src/threads/part1/Hello0.cpp.o] Error 1
-e \x1b[31;01m[release]\x1b[0m Compile \x1b[35;01msrc/threads/part1/Hello0.cpp\x1b[0m
-e \x1b[31;01m[release]\x1b[0m Link \x1b[35;01mrelease/bin/threads_p1_hello0\x1b[0m
ld: unrecognised emulation mode: arch=native
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
Makefile:38: recipe for target 'release/bin/threads_p1_hello0' failed
make: *** [release/bin/threads_p1_hello0] Error 1
On line 41 of articles/src/threads/part2/SafeGuard.cpp
Should this:
std::lock_guardstd::mutex guar(mutex);
be this:
std::lock_guardstd::mutex guard(mutex);
Changing guar to guard
-e \x1b[31;01m[release]\x1b[0m Link \x1b[35;01mrelease/bin/boost_po_v1\x1b[0m
-e \x1b[31;01m[release]\x1b[0m Compile \x1b[35;01msrc/vector_list/bench.cpp\x1b[0m
In file included from src/vector_list/bench.cpp:21:
include/policies.hpp:368:13: error: ‘plf’ was not declared in this scope
368 | struct Sort<plf::colony<T> > {
| ^~~
include/policies.hpp:368:28: error: template argument 1 is invalid
368 | struct Sort<plf::colony<T> > {
| ^
make: *** [Makefile:31: release/src/vector_list/bench.cpp.o] Error 1
Also one of the benchmark files includes a "bench.hpp" file but I can't find that file anywhere.
Thanks.
When i run the benchmarks they sometimes give huge numbers that make no sence could these be overflows or so?
since the benchmark really didn't take soo long, the numbers are in us so that would be almost an hour per iteration.
Start fill_back___Trivial_128_
ptrvector:100000:20104828006
ptrvector:200000:20104846378
ptrvector:300000:20104874560
ptrvector:400000:20104911025
ptrvector:500000:20104995430
ptrvector:600000:20105101428
ptrvector:700000:20105224248
ptrvector:800000:20105364027
ptrvector:900000:20105521204
ptrvector:1000000:20105699188
vector:100000:10940
vector:200000:37706
vector:300000:91221
vector:400000:151032
vector:500000:217300
vector:600000:333053
vector:700000:454590
vector:800000:581747
vector:900000:714614
vector:1000000:853260
i now have divided the time before summing it and it hels but the list now give some weird results.
'list_inserter:100000:140723549969'
Also i do not think that implementing a custom container is easy since i need to implement a custom iterator as well then.
I found your vector_list article very interesting. Could you provide a little documentation on how you produced graphs from the program's output? I can parse it with Python if I want, but I suspect you know a Right Way to do it. Thanks!
fold_expressions.cpp wont compile with gcc9.2 or MSVC16.
an initial value is needed for + and * operation.
this compiles and works:
template <typename... T>
auto fold_sum_1(T... s)
{
return (s + ... + 0);
}
template <typename... T>
auto fold_mul_1(T... s)
{
return (s * ... * 1);
}
...
template<typename T1, typename... T>
auto old_mul(T1 s, T... ts){
return s + old_sum(ts...);;
}
...
should be
...
auto old_mul(T1 s, T... ts){
return s * old_mul(ts...);
}
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.