-
Notifications
You must be signed in to change notification settings - Fork 26
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
Initial integration of new xrd-transforms package #509
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Attached below are my results from the analysis on the monolithic ruby example. new_grains.txt old_grains.txt You can see the difference in values in the two |
psavery
force-pushed
the
new-xrd-transforms
branch
from
April 4, 2023 21:15
664a608
to
df4aad0
Compare
This will help us keep track of what is being used and what has been migrated over. Signed-off-by: Patrick Avery <[email protected]>
This copies over files exactly as they are from this repository: https://github.com/ovillellas/xrd-transforms At commit: b94f8b2d7839d883829d00a2adc5bec9c80e0116
We don't support older versions of python anymore, so we don't need these. This also removes any trailing white space. Signed-off-by: Patrick Avery <[email protected]>
Signed-off-by: Patrick Avery <[email protected]>
Now we compile both the old CAPI extension module and the new one. Compiling them do not take much time, and this will help us migrate the functions over more easily. Signed-off-by: Patrick Avery <[email protected]>
I unfortunately did not see a hugely noticeable speedup when I tried this. Signed-off-by: Patrick Avery <[email protected]>
Migrate these to their new API functions. Still need some testing to verify. Signed-off-by: Patrick Avery <[email protected]>
If there's only one task or one worker in the thread pool, just execute it serially. This removes the overhead of making the thread pool, and it is better for profiling when running serially. Signed-off-by: Patrick Avery <[email protected]>
make_sample_rmat is the new function that is used for both make_oscill_rot_mat and make_oscill_rot_mat_array. I ran fit-grains with these changes and got the same answer. Signed-off-by: Patrick Avery <[email protected]>
Newer gcc versions compile code that runs faster. And we want to allow c99 for loops by default (this will fix a current error). gcc 10 is what is used by manylinux2014, so it has a good basis for being used. Signed-off-by: Patrick Avery <[email protected]>
Signed-off-by: Patrick Avery <[email protected]>
psavery
force-pushed
the
new-xrd-transforms
branch
from
April 13, 2023 17:21
df4aad0
to
3d630f5
Compare
@donald-e-boyce tried this out on various examples and approved of the changes. |
psavery
added a commit
that referenced
this pull request
Apr 27, 2023
This issue arose from #509, due to somewhat complex details. In short, the old `gvecToDetectorXY()` would filter out g-vectors going the wrong way (they would result in `nan`), but `gvecToDetectorXYArray()` would not. The new `gvec_to_xy()` has behavior matching `gvecToDetectorXYArray()`. But that means that places where `gvecToDetectorXY()` used to be used, we need to verify that the function does not receive g-vectors going the wrong way. Looking through the code, however, I only found one place where `gvecToDetectorXY()` used to receive g-vectors going the wrong way. It was the Laue overlay simulator, which would compute g-vectors from symmetrical HKLs (which is why it would have duplicate g-vectors going the wrong way). All other cases where `gvecToDetectorXY()` was called would be after the g-vectors were computed from `anglesToGvec()`, which I believe should always produce g-vectors going in the correct direction. As such, we only need to filter out wrong-direction g-vectors in the Laue simulator. Fixes: HEXRD/hexrdgui#1412 Signed-off-by: Patrick Avery <[email protected]>
psavery
added a commit
that referenced
this pull request
Apr 27, 2023
This issue arose from #509, due to somewhat complex details. In short, the old `gvecToDetectorXY()` would filter out g-vectors going the wrong way (they would result in `nan`), but `gvecToDetectorXYArray()` would not. The new `gvec_to_xy()` has behavior matching `gvecToDetectorXYArray()`. But that means that places where `gvecToDetectorXY()` used to be used, we need to verify that the function does not receive g-vectors going the wrong way. Looking through the code, however, I only found one place where `gvecToDetectorXY()` used to receive g-vectors going the wrong way. It was the Laue overlay simulator, which would compute g-vectors from symmetrical HKLs (which is why it would have duplicate g-vectors going the wrong way). All other cases where `gvecToDetectorXY()` was called would be after the g-vectors were computed from `anglesToGvec()`, which I believe should always produce g-vectors going in the correct direction. As such, we only need to filter out wrong-direction g-vectors in the Laue simulator. Fixes: HEXRD/hexrdgui#1412 Signed-off-by: Patrick Avery <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This takes @ovillellas's xrd-transforms package and integrates it into hexrd.
hexrd is now building and using functions from both the old transforms package and the new transforms package. I think this is okay to do for some time for a couple of reasons:
We can keep migrating some functions and testing them until we have all of them in. Once we do, and once it has been tested thoroughly, we can eliminate the old xfcapi code. But until then, we should proceed carefully.
That said, the first few functions that were migrated over were the ones found to be most important through profiling fit-grains here. The functions migrated over were:
anglesToGVec
,makeOscillRotMat
,makeOscillRotMatArray
,gvecToDetectorXY
, andgvecToDetectorXYArray
. Here are the changes:anglesToGVec
->angles_to_gvec
(arguments are all snake_case now)makeOscillRotMat
->make_sample_rmat
(also changed - keepchi
andome
as separate arrays rather than concatenating them into the first argument)makeOscillRotMatArray
->make_sample_rmat
gvecToDetectorXY
->gvec_to_xy
(arguments are all snake_case now)gvecToDetectorXYArray
->gvec_to_xy
(arguments are all snake_case now)You can see that
makeOscillRotMat
andmakeOscillRotMatArray
were combined into a singlemake_sample_rmat
. This automatically figures out which underlying c function should be called based upon the arguments it was provided. Similarly,gvecToDetectorXY
andgvecToDetectorXYArray
are combined intogvec_to_xy
, and the underlying c function is also chosen based upon the arguments provided.The convention here is to keep the older function names in the camelCase syntax, and make the new function names be in the more Pythonic snake_case syntax. This helps us keep track of what has been migrated and what has not.
For fit-grains, these changes resulted in a 23% speed increase for running the the monolithic ruby example serially.
However, there is one important thing to note: the output from
gvecToDetectorXY*
is now slightly different. The max difference I saw was~8e-13
. But this difference accumulated/propagated over several calls so that the fit-grains output (grains.out
) saw a difference in its tvec around1e-5
. All of the other values were different as well (except for completeness - which was an exact match), and the other differences were between1e-6
to1e-8
.I contacted @ovillellas about this, since any change in numbers is concerning. And here is what he told me:
So he claims that the difference in numbers is likely because the precision is better now than it was before. But this needs to be verified. The speed improvement is great, and the difference in numbers is small, but we should still verify them.
He also mentioned that
gvec_to_xy
is the function with the most extensive changes. Indeed, for the other functions, I did not see any difference in the numbers (even down to floating point precision differences). Sogvec_to_xy
is the main function of difference (and it alone accounted for about half of the 23% speed improvement seen in fit-grains).