-
Notifications
You must be signed in to change notification settings - Fork 87
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
Vectorization for Riemann solvers for the single-layer shallow water equations #291
base: master
Are you sure you want to change the base?
Conversation
…equations (chile2010 example). To use it, define GEOCLAW_VEC=1 before compiling. More info in the chile2010 Makefile.
This looks good to me. @rjleveque do you have any thoughts as to whether this should be a separate example? Do we want to add a test for this version as well? |
Do I understand correctly that the main differences are
Questions:
|
|
I haven't done extensive tests, but this seems to be slower than the original on my laptop. I tried the
Presumably it works better with the Intel compiler? But we may have bigger problems -- these results seemed strange to me since I was running with 4 threads but only about a factor of 2 improvement in wall time. So I ran the same problem with v5.4.1 and got these results:
We need to sort this out first... |
I am not sure whether I performed some experiments for a paper we submitted last month using Haswells (E5-2697v3) and KNLs (7210F) and got overall speedups of 1.6x and 2.3x, respectively). I also used a larger run in these tests, with Also, before submitting this pull request I also made a small test with I think that the fact that the performance depends on the compiler, machine, and simulation size is yet another motivation to keep vectorization as an optional feature, at least for now. |
I just ran the code with
Now with the GNU compiler 5.4.0:
So, apparently, it is not working with the GNU compiler. The |
@chaulio Would it be easy to combine the vectorized source and non-vectorized source and use a compile time flag to compile one way or the other? This would better ensure that the code would be updated and your effort sustainable. We were also a bit concerned that putting this in the Chile example directly might get some users to get confused regarding when they should or should not use the vectorized version. |
@mandli Do you mean using macros like It would not be hard, but I am afraid it would require dozens of such macros in a few different files, so I don't think it would be good for the code organization. The problem is that, while the most important changes are in the Riemann solvers If I understand correctly, these are the two options we are considering right now, and each has its pros and cons (maybe you can think of other pros and cons, or even of other options): - Option 1: Use separate files for the new code and use the Makefile to decide which files to include during compilation. (This is how the code in the pull request is right now). - Option 2: Introduce the new code in the same files as the original code, using macros to switch between implementations (this is your suggestion). Then vectorization could be turned on by simply setting In practice, I don't think Option 2 is easier to maintain. We would still have two different implementations, but now they would be mixed in the same file. It will still be necessary for the programmer to explicitly modify both implementations. As a small example, below I show how
In my opinion, this is only slightly easier to maintain than if we had two different files, with the disadvantage that the code gets messy in some places. Please consider both options and let me know your opinions. Maybe you can even think of other options to do this. If you really think Option 2 is the best option, I can do it. |
Hmm, I think you answered my question as to whether option 2 is a good idea. Perhaps the thing to do is to add a test that would use the vectorized code so that if there is a change that is incompatible it is caught. Another thing that came up I forgot to mention was whether it makes sense to add the vectorization flag to |
I am not sure if it makes sense to add it to I think adding the tests is a good idea. In fact, it is a trivial task, assuming that there already are tests for the original code. All one needs to do is run the same test again but adding the vectorization flag to the compilation. |
Exactly what I was thinking. You may be able to just modify the regression test itself and recompile through a sub-class of the test. For the Makefile business I get what you are saying. @rjleveque do you have an oppinion about whether to leave the |
@chaulio we are going to be getting a bunch of the GeoClaw developers in one spot next week and it would be nice to merge this PR in by then. Do you need help with adding the tests? Also @rjleveque do you have an idea about the above question? |
I added this as a discussion point for the workshop next week. Since it is fairly specialized and the implementation is perhaps not yet finalized I would be inclined to put the example using this in the apps repository for now at least, rather than in the main examples, or maybe add to the example but as a separate |
These changes introduce new vectorized implementations for the single-layer shallow water equations (chile2010 example). The user can easily switch between the serial and the vectorized code: to use vectorization, one needs to define GEOCLAW_VEC=1 before compiling. More info in the chile2010 Makefile.