-
Notifications
You must be signed in to change notification settings - Fork 33
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
gfortran and libSystemB.dylib issue when a large array is in play #88
Comments
did you as yet figure out the critical size for your array that leads to link failure (just drop a few zeros until it works)? |
No, I'll do some tests... |
Ok, I've found a program ready for use among those prepared by one of my former colleagues:
The execution outcome is this:
No error about libSystem.B.dylib, possibly because of the dynamic allocation. So I'll explore more with the static (and possibly use 'allocate' in the original troubled program...) |
Indeed, I think the static allocation of the large array is exactly the issue that leads to running out of link address room, but I’m too dumb to really know for sure and we await the guru. |
your colleague’s program is something completely different, I believe… you’re just running out of memory there. |
At this time, we do not support ... the right course of action (as you have determined later in this thread) is to use dynamic allocation - that should only be limited by the memory on your system. We will look into implementing the large model at some point (but there are higher priorities for the main port correctness at present). |
So, I've set up a shell script test.sh
where origin is
The outcome is:
The error does not occur at the allocate statement, but at
|
OK, so now you know the maximum size that can be allocated in the static way, and that it will not be made any larger any time soon so you will need to rewrite it as dynamic allocation if you need larger! All done! Check back in three to five years and perhaps the static allocation will be made larger by then, if anyone cares about that by that point... |
That's a bit unfortunate - one might have hoped that the linker would have complained about this (rather than a run-time crash) I would imagine that as you reduce the size of the complex array you'd reach a point that it works .. |
for static allocation(s) - I would guess that the critical size is hard to determine for a general Fortran source - since the limitation could well be on the sum of the various static objects in the program (plus, quite probably the program code itself - all would need to fit into the address space reachable with the 'medium' (default) mcmodel. .. which is a long-winded way of saying that if you determine that 2Gb is the largest array you can allocate statically, that does not mean you can have two of them :) .. you have to share the available space ... |
Understanding why the static allocation works on Intel with 16 GB RAM and not on arm64 with 64 GB is beyond my capabilities. I just understand that this porting to arm64 must be an incredibly huge task, and I'm so happy that you went already so far... I'm just curious to know if finding the equivalent of /usr/lib/libSystem.B.dylib on arm64/Monterey would magically solve the issue... Now I'll start looking inside the original program that presented the error and try to go the dynamic way... |
not finding It doesn't load because it can't do the relocations because it's out of memory. But dyld never thought of that possibility, so it says it can't find the library instead, as that is the error the dyld programmer DID expect. So it's the wrong error, for the wrong issue, for something completely different. :> |
The way in which the system libraries is delivered is different on arm64 (iOS and macOS) from x86 (and even powerpc if one goes back that far) - the underlying issue as @kencu says is running out of usable heap (not running out of available RAM)
Nope, I do not think it is actually even possible - libSystem is part of the system fixed cache.
sorry, that's the best course of action right now. |
Happy to report that after converting to dynamic allocation the largest arrays of the original program, execution proceeds smoothly till the end. Tested on arm64 Mac (10.12.1, 64GB RAM), Intel Mac (10.6.8 96 GB RAM; 10.14.6 16 GB RAM), CentOS 6 VM hosted on Intel Mac (VirtualBox, 8GB RAM assigned). Thanks to all who contributed! |
I am going to close this, but we now have issue #100 which is asking for support for the large code model; perhaps that would also be useful in this case. |
I've installed gcc-mp-devel with MacPorts
GNU Fortran (MacPorts gcc-devel 12-20220320_0+enable_stdlib_flag) 12.0.1 20220319 (experimental)
on a M1 Mac 64 GB RAM running macOS 12.2.1. Could compile and execute all the FORTRAN programs I'm working with but one, that has some large array definition.
Actually I've reproduced the issue with a very simple program:
I can compile/run this on an Intel Mac with 16 GB RAM (running Mojave, and an old gfortran (v. 7.5, but I succeeded with several versions from 4.x to 10.x on Intel Macs with OS ranging from 10.6.8 to 10.14.6), and I've no issues also an a Linux VM (CentOS 6 with gfortran 4.4.7 and just 8 GB of RAM assigned).
What I get on the arm64 Mac is:
The original program (full version) that fails to execute on my new arm64 Mac fails on the Linux VM 8 GB RAM Linux VM as well, but can be compiled/executed there provided that I add the option
-mcmodel=large
at compile time. Unfortunately that option leads to errors at compile time on any Mac (Intel or Apple Silicon) I've tried it on.
I made some more (blind...) experiments on the arm64 Mac, and described the outcome here
(https://trac.macports.org/ticket/64896#comment:5)
Not sure if they could be of any help, but thanks for your very appreciated efforts on this whole project!
Franco
The text was updated successfully, but these errors were encountered: