- Jesus Christ in His proper place - 1 Update
- Efficient C++ Bounded Thread-Safe FIFO Queue and LIFO Stack for real-time systems version 1.08 - 10 Updates
- I'm the best c coder here. - 4 Updates
- "Extra" pair of braces sometimes required when brace-initializing std::array - 3 Updates
- "Packaging" class member functions as closures - 3 Updates
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Sep 05 03:28PM -0700 ... out front of all of our endeavors. Leading the way in light, in truth, in righteousness, in holiness, in full guidance in all things. Steve Lawson on a restorat (2 minutes): https://www.youtube.com/watch?v=eUmBtUWXxa4 Jesus first. Other things second. It is the natural way of things because He is the Creator, and the advisor ... but who will listen? Will you listen? Will you hear Him out about your sin? Will you answer His call to be with Him in paradise? Streets of gold. The river of life. God Himself and you ... face to face. You'll never get a better offer. Be wise. Receive His free offer of eternity, His free offer of a new body, His free offer of a mansion in Heaven, His free offer to forgive you of every hurtful, sinful, hateful thing you've ever done. You need to be saved. You need Jesus to save you. Thank you, Rick C. Hodgin |
rami18 <coco@coco.com>: Sep 05 02:40PM -0400 Hello.. Efficient C++ Bounded Thread-Safe FIFO Queue and LIFO Stack for real-time systems version 1.08 Now the Thread-Safe LIFO Stack that is LIFO fair and starvation-free is working correctly. Author: Amine Moulay Ramdane Description: Efficient C++ Bounded Thread-Safe FIFO Queue and LIFO Stack for real-time systems, they are efficient and they eliminate false-sharing and the Thread-Safe FIFO Queue is FIFO fair and starvation-free, and the Thread-Safe LIFO Stack is LIFO fair and starvation-free. You can download it from: https://sites.google.com/site/aminer68/efficient-c-bounded-thread-safe-fifo-queue-and-lifo-stack-for-real-time-systems Thank you, Amine Moulay Ramdane. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Sep 05 08:19PM +0100 On 05/09/2017 19:40, rami18 wrote: > the Thread-Safe LIFO Stack is LIFO fair and starvation-free. > You can download it from: > https://sites.google.com/site/aminer68/efficient-c-bounded-thread-safe-fifo-queue-and-lifo-stack-for-real-time-systems As usual the code you post here is egregious. You do realize that you cacheline "padding" isn't padding at all because you aren't using unions or C++11 alignment features so every time you put a scalar member variable in-between the "pads" you offset subsequent "pads"? Also it is beneficial to put multiple variables WITHIN the same cacheline which is the opposite of what you are doing with your "padding"? union { int i; char padding[CACHE_LINE_SIZE]; } i; int this_one_is_aligned[56]; Try harder mate. /Flibble |
rami18 <coco@coco.com>: Sep 05 03:29PM -0400 On 9/5/2017 3:19 PM, Mr Flibble wrote: > int this_one_is_aligned[56]; > Try harder mate. > /Flibble I don't think you are correct, because i am using the same cacheline padding as here: http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue This guy called Dmitry Vyukov that wrote this is a an expert. Thank you, Amine Moulay Ramdane. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Sep 05 08:43PM +0100 On 05/09/2017 20:29, rami18 wrote: > padding as here: > http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue > This guy called Dmitry Vyukov that wrote this is a an expert. If what you are trying to do is eliminate false sharing then your code is still incorrect as you are still needlessly offsetting subsequent pads; you need to use a union or a C++11 aligned storage. This is what you want: template<typename T> struct cache_line_storage { alignas(CACHE_LINE_SIZE) T data; char pad[CACHE_LINE_SIZE > sizeof(T) ? CACHE_LINE_SIZE - sizeof(T) : 1]; }; /Flibble |
rami18 <coco@coco.com>: Sep 05 04:31PM -0400 On 9/5/2017 3:43 PM, Mr Flibble wrote: > : 1]; > }; > /Flibble What you are trying to do Fibble is optimizing the memory, my way of doing as i have explained is working correctly for false-sharing, your way is an optimization of memory, but it is good to optimize for memory for very tight constrains on memory on real-time systems.. Thank you, Amine Moulay Ramdane. |
"Chris M. Thomasson" <invalid@invalid.invalid>: Sep 05 01:53PM -0700 On 9/5/2017 12:19 PM, Mr Flibble wrote: > union { int i; char padding[CACHE_LINE_SIZE]; } i; > int this_one_is_aligned[56]; > Try harder mate. Strange padding stuff aside, the code does not make sense to me. He is using Pthread emulation, locks mutexs, and waits on semaphores. How can this even be remotely starvation free unless the underlying primitives provide those guarantees? Also, he has this sequential consistency membar in there, that does not make sense. He also has this strange: while (count()>=size) {sched_yield();} WTF is that shit! |
"Chris M. Thomasson" <invalid@invalid.invalid>: Sep 05 02:01PM -0700 On 9/5/2017 1:31 PM, rami18 wrote: > of doing as i have explained is working correctly for false-sharing, > your way is an optimization of memory, but it is good to optimize for > memory for very tight constrains on memory on real-time systems.. Personally, I would want the head and tail to be aligned and padded on different cache lines, but you funnel all through individual mutexes for head and tail. This means that the mutex state for the head and tail needs to be accounted for as well. Padding is one aspect, proper alignment is another. Without both, well, you basically have nothing. Take a look at: http://en.cppreference.com/w/cpp/memory/c/aligned_alloc http://en.cppreference.com/w/cpp/types/aligned_storage http://en.cppreference.com/w/cpp/language/alignas Also, how can you claim starvation-free when you use pthread mutexs and semaphores? Then you throw in a C++11 seq_cst membar, and do a strange spin wait using sched_yield, it seems to be waiting for a "full" condition. What is that all about? |
rami18 <coco@coco.com>: Sep 05 05:14PM -0400 On 9/5/2017 5:01 PM, Chris M. Thomasson wrote: > semaphores? Then you throw in a C++11 seq_cst membar, and do a strange > spin wait using sched_yield, it seems to be waiting for a "full" > condition. What is that all about? You are asking for me to do padding and alignement, but i don't think you are correct, because why Dmitry Vyukov is using only padding on the following: http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue This guy called Dmitry Vyukov that wrote this is a an expert. >Also, how can you claim starvation-free when you use pthread mutexs and > semaphores? Because i think Mutex and Semaphore of pthread for VxWorks real-time system and for QNX real-time system are real-time and starvation-free. Thank you, Amine Moulay Ramdane. |
"Chris M. Thomasson" <invalid@invalid.invalid>: Sep 05 03:06PM -0700 On 9/5/2017 2:14 PM, rami18 wrote: > think you are correct, because why Dmitry Vyukov is using only > padding on the following: > http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue His padding does not mean correct alignment. For instance, I want head and tail to start on actual cache line boundaries. Dmitry's example code does not do that. Keep in mind that its example code, not really meant for production. Btw, I know Dmitry. > > semaphores? > Because i think Mutex and Semaphore of pthread for VxWorks real-time > system and for QNX real-time system are real-time and starvation-free. VxWorks has absolutely nothing to do with it. Afaict, you seem to have copied binaries from a PThread emulation lib: https://sourceware.org/pthreads-win32/index.html You should mention the license it has in copying.lib? ;^/ |
rami18 <coco@coco.com>: Sep 05 06:21PM -0400 On 9/5/2017 6:06 PM, Chris M. Thomasson wrote: > copied binaries from a PThread emulation lib: > https://sourceware.org/pthreads-win32/index.html > You should mention the license it has in copying.lib? ;^/ I have just included the copying.lib file inside the zip. Thank you, Amine Moulay Ramdane. |
Jeff-Relf.Me @.: Sep 05 10:59AM -0700 |
Snit <usenet@gallopinginsanity.com>: Sep 05 11:07AM -0700 On 9/5/17, 10:59 AM, in article Jeff-Relf.Me@Sep.5--10.59am.Seattle.2017, > "BuzGoz", "FizBuzGoz", "Kaz", "FizKaz", "BuzKaz", "FizBuzKaz", > "GozKaz", "FizGozKaz", "BuzGozKaz", "FizBuzGozKaz" }; int x = 0 ; > while ( x++ A count of lines is hardly a good sign of quality... heck, I noted that when speaking to Marek and noting how my solution was only 17 lines (or whatever). It was noted to speak to how simple the program is (few lines and nothing "clever" to keep it short -- could have made it shorter) but not a sign that it is better than, say, a 50 line solution. -- Personal attacks from those who troll show their own insecurity. They cannot use reason to show the message to be wrong so they try to feel somehow superior by attacking the messenger. They cling to their attacks and ignore the message time and time again. <https://youtu.be/H4NW-Cqh308> |
Jeff-Relf.Me @.: Sep 05 11:28AM -0700 |
Snit <usenet@gallopinginsanity.com>: Sep 05 11:43AM -0700 On 9/5/17, 11:28 AM, in article Jeff-Relf.Me@Sep.5--11.28am.Seattle.2017, > From 9/8 to 9/11 last year, 2016, you posted 589 times in 4 days. > That's almost 150 per day, for 4 straight days, leading up to 9/11. > "insane", "Galloping", in a "Snit". You just said nothing with a lot of words. Oh, and my Usenet provider caps me at 100 posts per day... not possible for me to post what you claimed. -- Personal attacks from those who troll show their own insecurity. They cannot use reason to show the message to be wrong so they try to feel somehow superior by attacking the messenger. They cling to their attacks and ignore the message time and time again. <https://youtu.be/H4NW-Cqh308> |
"K. Frank" <kfrank29.c@gmail.com>: Sep 04 04:42PM -0700 Hello Group! The following code illustrates my question: === entire compilation unit === #include <array> #include <vector> std::vector<unsigned> vu0 { 1, 2, 3 }; std::vector<unsigned> vu1 { 4, 5 }; std::array<unsigned, 2> au { 1, 2 }; std::array<std::vector<unsigned>, 2> avux { vu0, vu1 }; std::array<std::vector<unsigned>, 2> avuy {{ { 1, 2, 3 }, { 4, 5 } }}; std::array<std::vector<unsigned>, 2> avuz { { 1, 2, 3 }, { 4, 5 } }; === end === Everything compiles except for the last line -- the definition and initialization of avuz. That is, when initializing the elements of std::array with numeric literals or already-defined variables, only a single pair of braces is needed. But when initializing the array elements with their own brace initializers, as in the avuy line, an "extra' pair of braces is needed. That is, the avuz line without the "extra" braces (line 18) fails, giving (with g++ 4.9.2) the following error: g++ -std=c++11 -c av_init.cpp av_init.cpp:18:67: error: too many initializers for 'std::__array_traits<std::vector<unsigned int>, 2ull>::_Type {aka std::vector<unsigned int> [2]}' std::array<std::vector<unsigned>, 2> avuz { { 1, 2, 3 }, { 4, 5 } }; ^ av_init.cpp:18:67: error: too many initializers for 'std::array<std::vector<unsigned int>, 2ull>' av_init.cpp:18:67: error: could not convert '1' from 'int' to 'std::vector<unsigned int>' av_init.cpp:18:67: error: could not convert '2' from 'int' to 'std::vector<unsigned int>' I have seen in various places the explanation that std::array is basically just a class with a single member variable that is a C-style built-in array. Thus, it requires a brace initializer that contains just a single entry to match its single member variable. This make sense (even if a bit ugly). But why then do the initializations of au and avux succeed, where we have brace initializers with a single pair of braces so we would appear also to have more initializer values than the single (array-valued) member variable of the std::array? Is there some special-case rule in the standard that makes this work? (And, if so, why doesn't it extend to the case of the nested brace initializers?) Thanks for any wisdom. K. Frank |
Ian Collins <ian-news@hotmail.com>: Sep 05 03:01PM +1200 On 09/ 5/17 11:42 AM, K. Frank wrote: > Hello Group! > The following code illustrates my question: <big snip> > g++ -std=c++11 -c av_init.cpp This was tidied up in C++14, so try -std=c++14. -- Ian |
"K. Frank" <kfrank29.c@gmail.com>: Sep 05 06:29AM -0700 Hi Ian! Thanks for your reply. On Monday, September 4, 2017 at 11:02:15 PM UTC-4, Ian Collins wrote: > <big snip> > > g++ -std=c++11 -c av_init.cpp > This was tidied up in C++14, so try -std=c++14. The g++ version I currently have installed is too old to support c++14, so I tried it with a random online compiler that claims to have a c++14 mode: https://www.onlinegdb.com/online_c++_compiler I get the same behavior / error with its c++14. (Perhaps someone could test my example with both c++11 and c++14.) But more to the point, tidied up in c++14 or not, I would like to understand what's going on -- why you can get away without the "extra" pair of braces when you don't have nested brace initializers. > Ian Best. K. Frank |
bitrex <bitrex@de.lete.earthlink.net>: Sep 04 10:36PM -0400 On 09/04/2017 02:59 PM, Chris M. Thomasson wrote: > This might be of interest to you: > https://software.intel.com/sites/default/files/Designing_a_Parallel_Game_Engine.pdf Hey cool! |
bitrex <bitrex@de.lete.earthlink.net>: Sep 04 10:48PM -0400 On 09/04/2017 02:59 PM, Chris M. Thomasson wrote: > This might be of interest to you: > https://software.intel.com/sites/default/files/Designing_a_Parallel_Game_Engine.pdf But while it is cool, it's very abstract and seems more or less a guideline as to how to re-implement a framework like Unity. Which unfortunately I don't really have time to do. :-( |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Sep 05 12:53PM +0100 On Mon, 4 Sep 2017 14:45:59 -0400 > super-familiar with lambdas and the stuff that's now possible with > std::function post C+11, wondering if anyone could give a reference > or example as to how something like this would be done? "Closures" in the abstract sense are just functions which have previously declared variables accessible to them lexically which are not passed to the functions as arguments. These so-called "free" variables are said to be closed over by the function. Unlike some languages, C++ does not have closures built in, and they have to be synthesized. They are synthesized as objects with a operator() method (function objects) which keep the "closed over" variables as data members. You have probably written hundreds of them without labelling them as closures in your mind - they are pretty basic. Most function objects of class type are closures. As suggested, because such "closures" (ie function objects) comprise a "package" containing the data members plus a function to operate on them, they can be useful for passing to other functions for those other functions to do something with them: you could think of such function objects as self-contained callbacks. This can be done opaquely, because any function object can be stored polymorphically in a std::function object. They are also commonly passed statically as types of a template function - this occurs throughout the standard library. C++11 lambdas are just a syntactic convenience to construct anonymous function objects "on the fly". The closed-over free variables to be incorporated in the function object are specified in the lambda's capture list. std::bind also constructs anonymous function objects. So far as reading is concerned, although VS orientated this is quite a good introduction: https://docs.microsoft.com/en-us/cpp/cpp/lambda-expressions-in-cpp Chris |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment