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

Update quickinstall instructions for macOS #3130

Merged

Conversation

sohhae
Copy link
Contributor

@sohhae sohhae commented Sep 8, 2024

Description

Please include a summary of the change and which issue is fixed if applicable. Please also include relevant motivation and context.

The path for clang++ compiler doesn't seem to be correct. Per Stack Overflow, this seemed to work for my M2 MacBook Pro.

Fixes # (issue)
N/A

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 15) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

The path specified for clang++ was incorrect. The result was cmake command fails. Per this stack overflow answer (https://stackoverflow.com/a/53889826) these are the correct flags.
@gridley
Copy link
Contributor

gridley commented Sep 8, 2024

Did this end up working with multithreading? The homebrew version is there because if you install clang via homebrew, it will come with OpenMP support. The system clang compiler does not have openmp support.

@sohhae
Copy link
Contributor Author

sohhae commented Sep 10, 2024

Did this end up working with multithreading?

Yes, it works for me!

@gridley
Copy link
Contributor

gridley commented Sep 10, 2024

Well if so, I think you should feel free to add a note that this is how you use the system's clang. However, the previous instructions show how to install clang via homebrew, so if the user followed the instructions above they end up not using the compiler that it used.

What do you think is the best way to describe this? I think if you were to just not set the CC and CXX variables, the path you set is what gets found.

Ah. And I think this relates to whether sudo was used when running homebrew, maybe. Did you use sudo? That would explain the difference if so.

@jtramm
Copy link
Contributor

jtramm commented Sep 10, 2024

@sohhae -- can you double check that you were able to run on multiple threads with apple clang, and not just that the code ran cleanly? You can double check that you are seeing something like:

                   | The OpenMC Monte Carlo Code
         Copyright | 2011-2021 MIT and OpenMC contributors
           License | https://docs.openmc.org/en/latest/license.html
           Version | 0.13.0-dev
          Git SHA1 | 333137dbae939cbfc06eef6237ae756a1d8083e7
         Date/Time | 2024-09-10 15:17:25
    OpenMP Threads | 10

at the top when OpenMC is run (note the OpenMP Threads line). Is it reporting more than 1? If the OpenMP Threads line is not showing up, then this means OpenMC was not compiled with threading support. If you are getting multiple threads, did you use any other homebrew install commands and/or sudo? The system default apple llvm/clang does not have OpenMP support, as @gridley said.

@sohhae
Copy link
Contributor Author

sohhae commented Sep 10, 2024

@gridley This is the clang installed by homebrew. I have confirmed this by uninstalling llvm, and verifying that the clang executable is no longer present, then reinstalling and confirming that the executable is present again. The current path specified in the documentation seems to be incorrect, export CXX=/opt/homebrew/opt/llvm/bin/clang++ does not exist on my system even after installing llvm with homebrew. It is possible this comes down to configuration differences, or homebrew/MacOS versions, so it might be worth some other people verifying, but the paths I've given worked on my M2 Mac Pro, running macOS Sonoma 14.6.1 with brew version 4.3.19.

@jtramm thanks for the explanation. Please see below.

                 | The OpenMC Monte Carlo Code
       Copyright | 2011-2024 MIT, UChicago Argonne LLC, and contributors
         License | https://docs.openmc.org/en/latest/license.html
         Version | 0.15.1-dev
        Git SHA1 | 57816e6b8cf23ed0e9b020b72752ed6aeb9501dd
       Date/Time | 2024-09-10 10:27:34
  OpenMP Threads | 12

 Reading settings XML file...
 Reading materials XML file...
 Reading geometry XML file...
 Reading tallies XML file...

@gridley
Copy link
Contributor

gridley commented Sep 11, 2024

Wow, I wonder what the difference is! Have you seen what happens if you just don't set the CC and CXX files?

@jtramm
Copy link
Contributor

jtramm commented Sep 11, 2024

Thanks for clarifying @sohhae! On my system, homebrew installs llvm to /opt/homebrew/opt/llvm/bin/clang++ similar to @gridley. One option for the docs might be to have the discussion tell the user to ensure they add clang++ to their path, and that probable locations if installed via homebrew are at:

/opt/homebrew/opt/llvm/bin/clang++

OR

/usr/local/opt/llvm/bin/clang++

From what I can tell in some of the secondary comments on this stack overflow post, the paths that homebrew makes binary simlinks is different depending on M1 vs. M2 or newer (for reasons unknown!). To future proof things, we might also advise the user to double check where homebrew is installing things via:

brew info llvm

@gridley
Copy link
Contributor

gridley commented Sep 11, 2024

Thank you for getting to the bottom of this John! Yes, we should definitely just note that it may be one or the other. Hopefully we can eventually write a more detailed install guide (not on this page) noting that homebrew isn't necessarily the only route as you've noted before John.

@sohhae
Copy link
Contributor Author

sohhae commented Sep 11, 2024

Thank you both @gridley and @jtramm. This was my first ever openmc pull request, so I'm still learning the ropes on how all this works. I will try to be more descriptive in the future! :)

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtramm @gridley @sohhae What do you think of the updated instructions I just pushed to this branch?

@paulromano paulromano changed the title Sohhae/update quickinstall for mac Update quickinstall instructions for macOS Oct 3, 2024
@paulromano paulromano merged commit 8263f05 into openmc-dev:develop Oct 12, 2024
16 checks passed
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

Successfully merging this pull request may close these issues.

4 participants