Boost logo

Boost :

Subject: Re: [boost] GSOC 2015 : Project on Concurrent Hash Tables
From: Amarnath V A (me_at_[hidden])
Date: 2015-03-05 19:43:07


On Thu, Mar 5, 2015 at 9:34 PM, Niall Douglas <s_sourceforge_at_[hidden]> wrote:
> On 5 Mar 2015 at 19:34, Amarnath V A wrote:
>
>> I have spent last few days trying to implement the move and copy
>> constructors. But all my trials have ended up in failures.
>
> The fact of failure isn't anything like as important as how you
> failed. Can you tell us some more about exactly what failed and your
> best guesses as to why?

When making changes to move constructor after Rob's and Niall's
review, I ended up several issues. I am not sure if these are due to
my misunderstanding of the data structure or if it's because of my
incorrect implementation. Nevertheless, I am sharing those here.

1. After the discussion with Niall and Rob on the piece of code I have
shared here before, what I understood is that I was not marking the
old map to be reloaded by the threads which are making use of it. Say,
I performed a move construction of old_map and it was being used by
few threads, shouldn't I mark it for reloading by those threads. From
the explanation Niall had provided here, I came to the conclusion that
I have to mark the newly created buckets of old_map as lock state 2.
But this did not work out as expected. I ended up in a infinite loop I
guess when I ran a simple unit test testing the move construction.
Niall, after marking the buckets to be reloaded, how is the actual
reload of the buckets performed? Do I have to some how let the threads
know that you have to do a reload of the buckets? How is this
achieved? I see that the lock stays in state 2 after I set it and is
not switching back to 0 value.

2. For copy construction, should I do similar logic as in _rehash()
method or can I just perform an atomic load and store from the
old_map's buckets? I believe this is not the right way and should do
something similar to the _rehash().

3. How do I handle exceptions in move construction? On an exception,
what is the move construction expected to do? Just abort whatever it
was doing and restore the old_map?

4. And how about copy constructor? Are copy constructors allowed to
throw exceptions?

5. Niall, one more question. I see that the thread_sanitizer unit
test is not building. Please see the build #228's console output.
https://ci.nedprod.com/view/Boost%20Thread-Expected-Permit/job/Boost.Spinlock%20Test%20Linux%20GCC%204.8/lastCompletedBuild/console

I see that there is an unrecognized flag "-fsanitize=undefined" and
compiler is throwing the following error.

g++: error: unrecognized command line option '-fsanitize=undefined'

I removed the particular flag from the build script and compiled. This
time it worked out and but when I ran, I see so many warnings thrown.
Is this expected or is it that something needs to be fixed?

>
> The only introductory resource I am aware of - and please, if anyone
> else reading can help here please chime in - is Anthony William's
> book "C++ Concurrency in Action: Practical Multithreading". I've
> never read it, but Anthony was one of the main designers of
> Boost.Thread, so I am taking it entirely on trust that his book is
> solid.

Yes, I have already come across this book. I will try to find time and read it.

>
> I had been thinking this topic would be a standard course in Computer
> Science by now, but a quick search of google shows it is an optional
> final year module if present at all in most courses. This is a good
> example of how universities produce students not useful to the
> workplace. That said, MIT appear to have an electable web course on
> shared memory concurrency at
> http://web.mit.edu/6.005/www/fa14/classes/17-concurrency/, this might
> be useful.

I will go through this and see if I am able to do better. Yes, like
you rightly commented, none of the universities have this as even an
elective. What I know about concurrency is just what I have read
online and some from my basic experience writing multi threaded
applications. So, I am at an amateur level.

And I will post any other problems faced from now on. I was under the
impression that as this is part of competency test, the students are
supposed to figure out how to do themselves. Thanks for helping out.

Thanks,
Amarnath


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk