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

symbol not found in flat namespace '_ompi_mpi_byte' #91

Open
Jamie790 opened this issue Sep 14, 2023 · 10 comments
Open

symbol not found in flat namespace '_ompi_mpi_byte' #91

Jamie790 opened this issue Sep 14, 2023 · 10 comments

Comments

@Jamie790
Copy link

Hi,

I have successfully build Openfoam-5.x in M2, but when i try to run simplefoam or blockmesh i get this message:

%simpleFoam
dyld[1343]: symbol not found in flat namespace '_ompi_mpi_byte'
zsh: abort simpleFoam

%blockMesh
dyld[1654]: symbol not found in flat namespace '_ompi_mpi_byte'
zsh: abort blockMesh

Can you help me to solve this problem. Many thanks.

@mrklein
Copy link
Owner

mrklein commented Sep 16, 2023

Hi,

It looks like architecture mix. By make rules were made for x86_64 (ex. wmake/rules/darwin64Clang/c++):

CC          = xcrun c++ -arch x86_64 -std=c++14

While Homebrew-installed openmpi is compiled for arm64. So, you need to either simply remove -arch x86_64 flag in wmake/rules/darwin64Clang/c++ and wmake/rules/darwin64Clang/c, or put there arm64 instead of x86_64. And then recompile the software.

@Jamie790
Copy link
Author

Jamie790 commented Sep 17, 2023

Hi,

Thanks for you reply. I tired to put arm64 instead of x86_64 in wmake/rules/darwin64Clang/c++ and wmake/rules/darwin64Clang/c and then recomplied.

But i get some error message during ./Allwmake

``` /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/word.HIn file included from :/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.H42::
error: In file included from /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.H51:51:
reference to unresolved using declarationIn file included from :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string
In file included from :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string527::
527:
    _VSTD::memcpy(&__r, __p, sizeof(__r));/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h::37           ^37:
:1212::  error: error: reference to unresolved using declarationreference to unresolved using declaration

In file included from 99/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/wchar.h:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwd:In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h:29:
:99/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/wchar.h:
:62In file included from :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h4262:::29 42:
: /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/wchar.herror: :error: no type named 'wstring' in namespace 'std'62:42:no type named 'wstring' in namespace 'std' 

error: no type named 'wstring' in namespace 'std'
Ostream& operator<<(Ostream&, const std::wstring&);
Ostream& operator<<(Ostream&, const std::wstring&);                                    ~~~~~^

Ostream& operator<<(Ostream&, const std::wstring&);                                    ~~~~~^
                                    ~~~~~^
/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.HIn file included from :/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/int32.H51:error: :
43In file included from :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stringIn file included from reference to unresolved using declaration:/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/word.H529:
:
42In file included from :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__ios/fpos.hIn file included from :/Users/liqiaoqiao/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/string.H:typedef fpos<mbstate_t>    streampos;51
14             ^: 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwdIn file included from :230/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/string/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h:::4414:529:1:
 :In file included from  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__ios/fpos.h:error: 14note: :
using declaration annotated with 'using_if_exists' here/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iosfwdreference to unresolved using declaration:

230:14: using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
typedef fpos<mbstate_t>    streampos;error: 
^
             ^reference to unresolved using declaration

In file included from UPstream.C:26/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.h:
:typedef fpos<mbstate_t>    streampos;44
:1             ^:
In file included from /Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/UPstream.H :/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__mbstate_t.hnote: 42:
In file included from :/Users/OpenFOAM/OpenFOAM-5.x/src/OpenFOAM/lnInclude/labelList.H44using declaration annotated with 'using_if_exists' here
::471:

I am try to compile OpenFOAM-5.x-7f7d351b7.patch, i am not sure where i did wrong. Should i try other patches to see if there is same error? Many thanks.

@mrklein
Copy link
Owner

mrklein commented Sep 17, 2023

Well, it seems, we need more information. Could you post output of:

  1. uname -m
  2. file /opt/homebrew/Cellar/open-mpi/*/lib/libmpi.dylib
  3. Compilation command from log-file. To see what flags are really passed to compiler.

@Jamie790
Copy link
Author

Hi,

  1. uname -m - i got arm64
  2. file /opt/homebrew/Cellar/open-mpi/*/lib/libmpi.dylib - i got /opt/homebrew/Cellar/open-mpi/4.1.5/lib/libmpi.dylib: Mach-O 64-bit dynamically linked shared library arm64
  3. see file attached
    Allwmake.docx

Many thank for your reply.

Regards,
mz

@mrklein
Copy link
Owner

mrklein commented Sep 18, 2023

Things are a bit complicated, cause I do not have access to Apple's ARM platform, and I have never tried to compile 5.x with current compiler. So, I would propose:

  • Try to remove -arch flag from compilation rules.
  • Post output of brew doctor command. If there is a problem with clang installation, the command will shown them. Though, you have successfully compiled the code for x86_64, I doubt, there is a problem with the installation.

@nolankucd
Copy link

You should be able to fix this by installing Xcode and the Command line Tools before building OpenFOAM. Then wmake/rules/darwin64Clang/c++ and wmake/rules/darwin64Clang/c will reference -m64 and not x86-64

@philipcardiff
Copy link

FYI, I also have this issue on my M3 Mac. I am not sure of the cause of the problem, but I suspect it is related to linking to libPstream or libmpi.

I will post here if I progress, but I am happy to hear about others' experiences.

@philipcardiff
Copy link

The _ompi_mpi_byte should be given in libmpi.dylib, e.g. we can see this with nm:

>> nm -g $(mpicc --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/')/libmpi.dylib | c++filt | grep "_ompi_mpi_byte"
3233:00000000001e4808 D _ompi_mpi_byte

I am not sure why this symbol is not found, if mpi is being linked correctly, which it seems to be...

@philipcardiff
Copy link

Problem solved: your solution here works.

That is, in $WM_DIR/rules/darwin64Clang/c++ and $WM_DIR/rules/darwin64Clang/c, replace x86_64 with arm64. Then, clean (wcleanPlatform) and re-build OpenFOAM.

However, this leads to an error when compiling $FOAM_SRC/OSspecific related to #include <xmmintrin.h>. A hack fix is to comment line 41 in $FOAM_SRC/OSspecific/POSIX/signals/sigFpe.C:

//#include <xmmintrin.h>   

and comment lines 215 and 216

        // _mm_setcsr(_MM_MASK_MASK &~                                                                                    
        //            (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO));  

Everything now works correctly, including in parallel.

Creating a dedicated darwinArm64Clang seems like a reasonable solution for the rules. I am not sure about the implication of the sigFpe.C hack. I see that OpenFOAM.com has solved this issue, so maybe something can be copied from there. Let me know if you like me to test or propose an updated patch.

@mrklein
Copy link
Owner

mrklein commented Mar 13, 2024

Thank you for the feedback. Yes, commented-out parts are Intel-specific.

OpenFOAM.com solved problem of sigFPE on ARM-based Macs. I will try to add the solution to OpenFOAM.org patches, though I won't be able to test them. As soon as I update the patches, I will create an issue for testing.

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