-
Notifications
You must be signed in to change notification settings - Fork 389
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
cpgfunction cleanup #9307
cpgfunction cleanup #9307
Conversation
@Myoldmopar there's a lot more that could be done in there... let me know how far to take this. |
@mitchute, I don't particularly care either way, but why couldn't you wrap the OpenMP functions with EnergyPlus/src/ConvertInputFormat/main.cpp Lines 598 to 613 in 5e982ed
Then I only link the libraries if they are found EnergyPlus/src/ConvertInputFormat/CMakeLists.txt Lines 12 to 15 in 5e982ed
|
I'm a bit confused: if there is a gain by using openMP (is there?) then why remove it? I'd agree with @mbadams5 and only enable the blocks if openMP was found. The alternative is to actually start requiring OpenMP, which isn't such a big deal really (it's not like it's hard to install on unix, it's preinstalled with MSVC, and the github runners already have it). Then we could do the call to to |
@jmarrec There’s a good summary about openmp in EnergyPlus here from @amirroth. It was introduced in EnergyPlus in one version and then quickly removed. Full disclosure: We (the BEopt dev team) were the ones that complained that “… slowdowns were observed when multiple EnergyPlus simulations were run in parallel”. My recollection is that the slowdowns were quite severe. |
@shorowit The issue you and amir were describing predates the conversion to C++. And yes, I saw the same issues with the old OpenMP implementation in Fortran for the interior radiant heat exchange (it basically always used 100% of all threads requested regardless of the actual work being down within interior radiant heat exchange). I think there was something wrong with the implementation of OpenMP code in EnergyPlus causing this issue. Regardless, I think OpenMP can have uses within EnergyPlus. I know LBNL explored some of them under the EP10X project and I do think it probably provides value within cpgfunction here. @jmarrec The only issue really stopping us from just requiring OpenMP is Apple's clang compiler. It is not built with OpenMP support, even though LLVM and Clang built from source or homebrew does have OpenMP support. GCC and MSVC both support OpenMP currently on Linux and Windows. |
@shorowit thanks for the context. @mbadams5 I don't think there's any problem on mac though, if you use AppleClang and as long as it's v7+ (which is very old) you just https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindOpenMP.cmake#L107 and https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindOpenMP.cmake#L280-287 I just tested again, with https://github.com/jmarrec/CppBenchmarks/blob/main/bench_OpenMP.cpp, and Apple Clang 13.0 on a M1 mac, and it worked fine. |
@jmarrec I should have been more specific. Yes, you can either use |
Ok I see. It would be a packaging issue then: actually installing the libomp with EnergyPlus in the correct location and setting rpaths correctly. |
@mbadams5 so for ConvertInputFormat... currently the code at EnergyPlus/src/ConvertInputFormat/CMakeLists.txt Lines 12 to 15 in 5e982ed
The same is true on Linux, where it's actually found on Github runners, so a clean linux machine will not be able to run it. Here's a test with a clean docker docker run -it ubuntu:focal bash Inside the container: apt update && apt install wget
curl -L -O https://github.com/NREL/EnergyPlus/releases/download/v22.1.0-IOFreeze/EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64.tar.gz
tar xfz EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64.tar.gz
cd EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64/ root@054f2656b7ff:/EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64# ldd energyplus
linux-vdso.so.1 (0x00007ffe127f1000)
libenergyplusapi.so.22.1.0 => /EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64/./libenergyplusapi.so.22.1.0 (0x00007f32fc63f000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f32fc45b000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f32fc440000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f32fc24e000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f32fc22b000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f32fc225000)
- libgomp.so.1 => not found
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f32fc0d4000)
- libX11.so.6 => not found
libpython3.8.so.1.0 => /EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64/./libpython3.8.so.1.0 (0x00007f32fbd39000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3301173000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f32fbd34000)
root@054f2656b7ff:/EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64# ldd ConvertInputFormat
linux-vdso.so.1 (0x00007fffe32ea000)
- libgomp.so.1 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd7c0ea7000)
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd7c0cc5000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd7c0b76000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd7c0b5b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd7c0969000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd7c1429000) root@054f2656b7ff:/EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64# ./energyplus --help
./energyplus: error while loading shared libraries: libgomp.so.1: cannot open shared object file: No such file or directory
root@054f2656b7ff:/EnergyPlus-22.1.0-4fa778ec59-Linux-Ubuntu20.04-x86_64# ./ConvertInputFormat --help
./ConvertInputFormat: error while loading shared libraries: libgomp.so.1: cannot open shared object file: No such file or director |
Note: I made a test bed at https://github.com/jmarrec/test-cxx-OpenMP-installer to see if I could correctly ship the OpenMP libs on mac/Linux (we know windows is fine via InstallRequiredSystemLibraries and |
I'm responding to @mbadams5 from #9307 (comment).
Would there be any way to test if the issues with OpenMP persist, and that
I agree that OpenMP include guards seems to be a good solution. https://stackoverflow.com/a/8447025 I found in my implementation of |
@mitchute @Myoldmopar it has been 28 days since this pull request was last updated. |
OpenMP was tried during the 10X project but with limited gains due to the current code structure of EnergyPlus. Another try in future may be worth it after all code refactoring. |
@hongtz68 I think what you have said is true in general for EnergyPlus, but not for this specific third-party tool. OpenMP could be used here effectively to speed up this part of the simulation. However... there are better algorithms that have since come out that would have meaningful speedups without any sort of parallelization on our end. What Jack said above is still true, though. We do need to find, and/or start using some robust, off-the-shelf LA libraries rather than trying to roll our own solutions every time we need something (how many LU decomp or tri-diagonal solvers do we have littered throughout E+ at this point?). Figuring out that issue would go a long way in helping overcome these problems. |
The new development of the equivalent borehole method (EBM) by Prieto and Cimmino (2021) is likely the better algorithm @mitchute is mentioning. I have considered enhancing In recent months I have considered modifying cpgfunctionEP to be dependent on Eigen for all linear algebra functionality, given that the current hand rolled LU decomposition is significantly slower than Eigen's implementation. Eigen is currently not being utilized by cpgfunctionEP due to an unresolved segmentation fault previously thrown by the Linux CI machine while performing LU decomposition (see #8708 (comment)). I am currently uncertain as to what pure C++ library should be utilized by cpgfunctionEP for use in EnergyPlus. I personally like the API BLAS and LAPACK have to offer, but am unaware of any optimized libraries like openBLAS that do not require a -- Cook, J.C. (2021). Development of computer programs for fast computation of g-functions and automated ground heat exchanger design. M.S. Thesis, Oklahoma State University. https://hdl.handle.net/11244/335489 |
@mitchute @Myoldmopar it has been 28 days since this pull request was last updated. |
This needs to happen but I can't tackle it at this point. There's no sense in keeping this open indefinitely, so I'm closing this one and I'll probably open a different PR later if I get around to it. |
Pull request overview
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.