fastlib / fCWT

The fast Continuous Wavelet Transform (fCWT) is a library for fast calculation of CWT.
Apache License 2.0
263 stars 53 forks source link

fCWT matlab crash on Mac #17

Open keigoyoshida7 opened 1 year ago

keigoyoshida7 commented 1 year ago

Dear fastlib

Hi, I try to do fCWT on matlab, but it crashed at line 55 in the following picture sentence.

Mac PC spec is here, processor: 2.3 GHz 8core Intel Core i9 memory: 32 GB 2667 MHz DDR4 macOS 13.1(22C65)

Are there any solution ? I would be happy if you could solve it by adding some code.

Thank you.

problem
fastlib commented 1 year ago

Thank you for pointing this out. We will release a fix soon.

keigoyoshida7 commented 1 year ago

Thank you for answer me. Also, I'm trying MEX file in matlab on windows (intel CORE i7) but, there is a error with omp file may be... Are there any wrong code in this picture or other problem?

(please teach us how can We use fCWT in matlab on windows...)

best regards,

a
fastlib commented 1 year ago

It seems no easy fix. If you want to use fCWT without C++, your best option would be to use the Python package. We will be looking into fixing the Matlab wrapper but that could take some time. Our apologies for the inconvenience.

keigoyoshida7 commented 1 year ago

Thank you! please let us know when it is fixed. best regards,

felixdollack commented 1 year ago

@fastlib I am wondering about O1 in this line of fcwt.cpp: https://github.com/fastlib/fCWT/blob/e6e6c15303a4ade9a882bcd2cf2190d4f738bda0/src/fcwt/fcwt.cpp#L474

It is initialized to 0 https://github.com/fastlib/fCWT/blob/e6e6c15303a4ade9a882bcd2cf2190d4f738bda0/src/fcwt/fcwt.cpp#L443 but not filled with any data or used as output variable.

I can compile fcwtmex (on macOS) after adjusting for the new path of fcwt, but Matlab crashes randomly when calling fcwt.

That seems to work. See next comment...

felixdollack commented 1 year ago

fCWT_plan is redefining PI (comment it out) from fctw.h and it is missing mwSize c0 = mxGetScalar(prhs[1]); before using it in Morl(c0); After those modifications it compiles. But still does not run.

If I remove omp_set_num_threads(threads); from create_FFT_optimization_plan, I can run it.

%%%%%% Edit: Nevermind, I missed another comment I made.

All calls to OMP and fftwf_plan_with_nthreads need to be commented out:

//omp_set_num_threads(threads);
//std::cout << "Threads:" << omp_get_max_threads() << std::endl;

fftwf_init_threads();
// fftwf_plan_with_nthreads(omp_get_max_threads());

%%%%%%

The same does work for cwt.

If fftw is run with a single thread there are no issues (except that it might be slower than intended? ^^)

fastlib commented 1 year ago

What a coincidence! I was discovering exactly the same pragmatic solution as you did yesterday evening. After a few hours of tedious commenting and uncommenting and restarting Matlab 120+ times, I discovered that Matlab doesn't like OpenMP anymore. I'm not sure what the problem is, but for now a good solution is to use fCWT singlethreaded like you did in your pull-request.

Eventually, I merged your pull-request with mine and created a build time variable which I only use when building the mex-files via CMake. Additionally, I added some warnings for Matlab-users to make clear that their fCWT implementation does not support threads at the moment.

For now, the Matlab-wrapper should work again, but be it only single-threaded. I will leave this issue open as this is only a temporary solution.

liu7645 commented 1 year ago

Hi I want to run the code in matlab. My gcc could find openmp_c, but not find openmp_cxx. Could you please give me some advice? Oh, it's on windows.

whip123 commented 1 year ago

Hi @fastlib, Is there any way to run the full potential of fCWT in MATLAB such as using an older version of MATLAB? Thanks