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

MATLAB code crashes with larger number of densities #15

Open
bobbielf2 opened this issue Nov 14, 2020 · 7 comments
Open

MATLAB code crashes with larger number of densities #15

bobbielf2 opened this issue Nov 14, 2020 · 7 comments

Comments

@bobbielf2
Copy link

Hi,

I run the code below in MATLAB and it crashes. The crash happens reliably whenever the number of densities nd is big enough. Also, it only happens if I compile the code with OpenMP, the single-threaded version works fine.

OS: macOS Catalina 10.15.6
MATLAB version: R2019b or R2020b
FMM3D library compiled with the default make.inc.macos.gnu options

Additionally, I also tried similar things on a Ubuntu system and modified the OMP_STACKSIZE variable as described here. This somewhat alleviates the issue, but still crashes when nd is big enough. (However, I am not too familiar with Linux, so I could have done something wrong here.)

ns = 4000;

nd = 200;
srcinfo.nd = nd;

pg = 1;

srcinfo.sources = rand(3,ns);
srcinfo.charges = rand(nd,ns);

eps = 1e-5;

U = lfmm3d(eps,srcinfo,pg);
@ahbarnett
Copy link
Collaborator

Just some more data.
I find the same on MATLAB R2017a on ubuntu 16.04, i7, gcc9. omp, 8 threads.
It's not the total data size since ns=1e5; nd=10; doesn't crash, neither does ns=1e5; nd=65; even though it uses 16 GB or so.
ns=1e4; nd=1e2 crashes.
It's not a strict limit on nd either, since ns=1e2; nd=1e4; is crashless.

maxNumCompThreads(1)
prevents all such crashes.

@zgimbutas
Copy link
Collaborator

zgimbutas commented Nov 15, 2020 via email

@ahbarnett
Copy link
Collaborator

Hi Zydrunas - good to hear from you!

Ok, but how come FMM3D puts much on the stack? Surely any variable-sized arrays go on the heap, via malloc etc?

FWIW matlab (libiomp5) doesn't like env var changing stacksize:

OMP: Warning #181: OMP_STACKSIZE: ignored because KMP_STACKSIZE has been defined

ulimit -s unlimited
didn't stop the matlab segfault.

Ok, off to bed now, Alex

@zgimbutas
Copy link
Collaborator

zgimbutas commented Nov 15, 2020 via email

@zgimbutas
Copy link
Collaborator

zgimbutas commented Nov 15, 2020 via email

@mrachh
Copy link
Member

mrachh commented Nov 15, 2020

Thanks for bringing this to our notice. Thanks Alex and Zydrunas for the additional data and suggestions too.

I think I know the cause of the issue. It is in local memory allocation in list4 processing where the arrays are allocated inside an openmp loop rather than outside. This might also explain some issues we are having with compiling with intel compilers on windows.

Hopefully that should fix the bug..

@ahbarnett
Copy link
Collaborator

@mrachh is this fixed - can it be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants