Skip to content
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

Fixing the queue LCO and add example demonstrating its use #1627

Merged
merged 2 commits into from Jun 28, 2015

Conversation

hkaiser
Copy link
Member

@hkaiser hkaiser commented Jun 23, 2015

Also this removes the stubs/queue.hpp

@TheConstructor
Copy link

Works for me (albeit it is slower than I hoped it would be)

@hkaiser
Copy link
Member Author

hkaiser commented Jun 25, 2015

@TheConstructor Can you show us your code and your numbers, please? Let's see what we can do to improve things.

@TheConstructor
Copy link

So, my application currently looks like this: https://gist.github.com/TheConstructor/5a29ecba757b308b690d
I tried a few things myself and it seems if you set EXA_2015_INTERACT_REDUCE_MODE to 1 in interact_reduce.hpp (thereby deactivating hpx::queue-usage) you gain a lot of speed.

On my computer (Mac OS X 10.10.3, 4 HT-Cores at 2.5GHz, 16MB RAM) EXA_2015_INTERACT_REDUCE_MODE=1 takes 6 Seconds to complete and EXA_2015_INTERACT_REDUCE_MODE=3 takes 30s+

This is terminal-ouput for EXA_2015_INTERACT_REDUCE_MODE=3:

$ ./nbody_test3 --runs=10
initialization...done!
executing...
run 0: 38328 ms
run 1: 37591 ms
run 2: 36841 ms
run 3: 37794 ms
run 4: 37332 ms
run 5: 36413 ms
run 6: 36492 ms
run 7: 38079 ms
run 8: 37288 ms
run 9: 36504 ms
...done!

timings:
min: 36413 ms - max: 38328 ms - avg: 37266.2 ms
$ ~/Documents/Uni/hpx_build/bin/hpxrun.py ./nbody_test3 -l 2 -t 1 -- --runs=10
initialization...done!
executing...
run 0: 36195 ms
run 1: 36003 ms
run 2: 37339 ms
run 3: 38324 ms
run 4: 37046 ms
run 5: 36783 ms
run 6: 36467 ms
run 7: 36010 ms
run 8: 35792 ms
run 9: 36547 ms
...done!

timings:
min: 35792 ms - max: 38324 ms - avg: 36650.6 ms

And then there is seemingly an error in the queue-implementation I missed at first:

 ~/Documents/Uni/hpx_build/bin/hpxrun.py ./nbody_test3 -l 2 -t 2 -- --runs=10
initialization...done!
executing...
Assertion failed: (!queue_.empty()), function get_value, file /Users/matthias/Documents/Uni/hpx/hpx/lcos/server/queue.hpp, line 108.
Process 0 failed with an unexpected error code of -6 (expected 0)

- Fly-by changes to detail::condition_variable:
  - fix return value for notify_one
  - Remove entries from queue before checking for errors
@hkaiser
Copy link
Member Author

hkaiser commented Jun 26, 2015

@TheConstructor The queue should be fine now, I fixed a possible race condition.

For your code, I'm surprised it compiled at all (it did not for me). You're still serializing lambda functions, which does not work. Just because you wrap the lambda into a boost::function does not mean that it will be serializable. Even if you wrapped it in hpx::util::function it wouldn't work.

Also, why are your function objects derived from boost::function? This is not necessary.

@TheConstructor
Copy link

I don't remember right now why I derive the classes from boost::function. I vaguely remember that there was a problem otherwise, which might have also been solved by adding const to operator().

I am still a bit confused that lambdas are so much less than a function object. Last thing I remembered was that you need explicit types on them and they should behave just fine.

An lastly: what kind of compiler errors did my code generate? I used LLVM 6.1.0/clang-602.0.53 and it compiled fine. Care to share what you needed to change?

Will try with the new commit soon.

@TheConstructor
Copy link

Ok, seems to work now:

$ hpxrun.py ./nbody_test3 -l 1 -t 2 -- --runs=3
initialization...done!
executing...
run 0: 20796 ms
run 1: 20820 ms
run 2: 20884 ms
...done!

timings:
min: 20796 ms - max: 20884 ms - avg: 20833.3 ms

@hkaiser
Copy link
Member Author

hkaiser commented Jun 26, 2015

I am still a bit confused that lambdas are so much less than a function object. Last thing I remembered was that you need explicit types on them and they should behave just fine.

Lambdas have no (observable) type, thus they can't be re-constructed (de-serialized).

An lastly: what kind of compiler errors did my code generate? I used LLVM 6.1.0/clang-602.0.53 and it compiled fine. Care to share what you needed to change?

The compilation error happened only after I changed your use of boost::function to hpx::util::function (as this is serialzable, the Boost version is not)

hkaiser added a commit that referenced this pull request Jun 28, 2015
Fixing the queue LCO and add example demonstrating its use
@hkaiser hkaiser merged commit 5ca63f4 into master Jun 28, 2015
@hkaiser hkaiser deleted the fixing_queue branch June 28, 2015 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants