-
Notifications
You must be signed in to change notification settings - Fork 9
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
Re-enable C API, depletion, and many tests #33
Conversation
Thanks so much for fixing all these tests -- these are super useful fixes! Would be awesome to have most of the python tests working again. At first glance the fixes in the PR generally look good, though all the HPC systems at ANL are down this week, so I won't be able to do any testing with this until next week. I did have a few questions though on the new
|
Yes. std::string causes segfaults when its destructor runs if we have expanded an array of objects which contain std::string's has their destructors run. I'm not opposed to leaving pointers to names rather than statically sized names, but simply removing std::string and not having to worry about running its copy constructor when resizing arrays is pretty nice. |
Firstly, its nice to have getters and setters that protect us in copying to a static array, so that we can either warn about truncation or change the underlying implementation of how names are stored, e.g. switch off to pointers to elsewhere. To answer the first question, elements and isotopes can be expected to have at most 8 bytes of data, which keeps alignment of the struct as if we're adding one double precision number. It's nice to minimize how much extra space we take, so it's templated. On the other hand, thermal scattering data names are a bit longer so it makes sense to allow 16 characters. Lastly, cells and lattices are given longer names sometimes in the test suite, hence the choice of 32 characters. Another reason that inheritance solves this problem cleanly is that we often require std::string to be used as our interchange format for character data, e.g. in the HDF5 interface. This way, if we switch off to a char array, the calls to HDF5 stuff, and std::string::operator+ still work as expected, since the Lastly, inheritance in this case is nothing more than adding a data member. It's just more semantically meaningful. |
Now that std::string is removed from them, they are trivially copyable. This is why std::realloc now works with the various classes that inherit from |
As for accessing the names on device, no, it's definitely not necessary. Just a plus for debugging down the road. We could replace these with a vector and call it a day just as easily. |
Ah, when I say trivially copyable, I was thinking of host -> device copying, rather than host -> host copying. In host -> device copying, we still have to manually copy the vector data individually, so most objects are not trivially copyable in that context. At some point, we should switch over to using OpenMP custom mappers so that the host -> device copying becomes trivial, but we do not utilize that feature yet. To your last point -- why not just make the |
Yeah, I agree with you on that. It's a nice micro optimization to have. I'll revise this PR to use that technique instead! Still, vector isn't compatible with std::string out of the box, so it might make sense to have it wrapped in a class that makes it straightforward to interface with. |
Sounds good! Yeah, I can see the utility of defining a |
So you definitely want to remove the inheritance approach? If we're going to refactor it like this, I'll probably name it TriviallyCopyableString or something like that. |
Hey John, stuff should be good-to-go now! I've left it as a mixin class though, since we already were using member functions like set_name, it makes sense to do this. Otherwise I'll just be copying and pasting repeated code in various places. Inheritance in this case is nothing more than adding a data member and adding some methods. |
Sounds reasonable -- I'll take another look and will do some testing on this branch. Thanks again for putting these fixes together! |
I tried compiling with LLVM with A100 as a target, I'm getting compile time error:
When I remove this argument from the CMakeLists.txt and try again, I get a link-time error:
|
Oh yeah, fext-numeric-literals is a gcc thing. Lets you write complex literals very easily, but we should move to the more portable approach of On the linking, looks like gcc transitively is including a system header that LLVM is not. Thanks for pointing this out, will also test with LLVM. Or maybe it's trying to generate device code containing |
I re-ran without the unity build to perhaps narrow down the problem, it gives:
|
Just want to say: I have not forgotten about this but have just had trouble debugging what's going on, will hopefully get to this soon. |
Many, but not all, of the tests work now. I've also marked a few of the tests as things we should skip for now. I'm submitting this as intermediate work on the way to getting pytest usable here again.
Also, we can now run depletion here, which is nice. Previously stuff would crash and burn on depletion problems.
Closes #26 and #32