View Single Post
Old 2019-12-09, 16:13   #21
kriesel
 
kriesel's Avatar
 
"TF79LL86GIMPS96gpu17"
Mar 2017
US midwest

132478 Posts
Default Compiling gpuowl

First ask yourself, is this compile really necessary? See https://www.mersenneforum.org/showpo...83&postcount=7 or https://download.mersenne.ca/gpuowl which also have older versions precompiled for Windows. These usually have the executable, readme file, and help output bundled into a zip file. And there is occasionally a Linux version available, such as in the Google Colab thread.

Requirements for recent github commits of gpuowl:
  • 64-bit Intel or AMD system
  • OpenCL v2.0 support on system and gpu (very old commits, years old, may only require v1.2)
  • AMD APP SDK 3.0 (see https://community.amd.com/thread/227948 for a source for a legal copy and the license agreement)
  • Linux or Linux-like environment, including gcc and make
git is not required, but it makes the job easier. The alternative is make a subfolder, download the zip file, unpack it in the subfolder, and this may also not get the version string embedded in the executable right without some further manual intervention.
I've taken the conservative approach of using git clone and saving every build in a separate folder, which gets named for the version and commit, so I can run any version at any time. If you only want the latest, substitute git pull. There's a handy basic intro to git at https://www.mersenneforum.org/showpo...postcount=1076

The following procedures are for relatively recent commits, since Preda et al incorporated multiple build targets into the Gpuowl makefile addressing both Linux builds and msys2/mingw Windows builds around v6.7 as I recall.

There are two steps; preparing an adequate build environment, and performing the build.

On a local system
  • Linux
    • build environment setup (draft, unchecked, some steps may be unnecessary if the listed items are already installed and reasonably current)
      1. install gcc
      2. install make
      3. install git
      4. install AMD APP SDK 3.0
      5. modify path
      6. create the folder within which builds will be performed
  • Windows
    • build environment setup (done rarely) borrowing liberally from https://www.mersenneforum.org/showpost.php?p=483209&postcount=356
      1. install msys2/mingw64 (see https://www.msys2.org/)
      2. close your other apps before the next step, because I've seen it do an unannounced unpreventable system shutdown/restart
      3. install the 64-bit AMD APP SDK 3.0
      4. Copy the contents of C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86_64 to C:\msys64\mingw64\lib
      5. Copy the contents of C:\Program Files (x86)\AMD APP SDK\3.0\include to C:\msys64\mingw64\include
      6. run msys2 for the following setup steps (some steps may be unnecessary if the listed items are already installed and reasonably current)
      7. install gcc: pacman -S mingw-w64-x86_64-gcc
      8. install make
      9. install git
      10. modify path
        Code:
        #PATH=$PATH\:/dir/path ; export PATH
         PATH=$PATH\:c/msys64/usr/bin ; export PATH
      11. create the folder within which builds will be performed
    • the compile and link
      1. run msys2 for the following build steps
      2. cd to the build folder
      3. git clone https://github.com/preda/gpuowl
      4. cd to the gpuowl subfolder that git clone just created
      5. make gpuowl-win.exe
See also https://www.mersenneforum.org/showpo...6&postcount=40, https://www.mersenneforum.org/showth...t=msys2&page=4

I generally create a folder for each version and commit, eg gpuowl-v6.11-9-g9ae3189.
After an executable is produced, I can drag the executable and the readme up to that folder and have a relatively empty working folder for test, while all the source and .o files sit in the .\gpuowl subfolder below.

I follow a fresh build with gpuowl-win -help and save that output. A nice feature is it shows which OpenCL GPUs it detected.

On cloud computing, there are at least three approaches
  1. Follow the Linux instructions, creating the build environment and compile for every new session. You'll always have the latest commit, including when there's a serious bug, and it will be less efficient use of the cloud computing time.
  2. Follow the Linux instructions once, creating the build environment and compile. Then save the compiled executable on persistent cloud storage that it can be copied back from for future sessions, such as a Google drive dedicated to your GIMPS use. You'll have a stable version, until you decide to upgrade by repeating the build steps, and can save and choose among multiple versions. See also https://www.mersenneforum.org/showpo...30&postcount=7
  3. Instead of doing a build, get one from someone else. Store it on the Google drive that will be used during runs.
On Windows, check the right build environment was used; it will fail in a Windows command prompt for the same makefile and commit that will succeed in a MSYS2/MINGW64.

If there's a failure to build, use git bisect to determine at which commit the issue began, and include that info in any issue report provided to Preda. https://git-scm.com/docs/git-bisect


Thanks to kracker, Preda, tServo, and others who helped get me started or fix the occasional broken build environment.


Edit 2021 March 09: None of the above should be mistaken for advocacy of blind adherence to "latest rev is always best". When it is necessary or useful to build or revert to an older commit, that is not available precompiled for the OS and version/commit desired from existing locations, for successful build, stability, features no longer available in the latest commit(s), to avoid speed regression, for comparison testing, or other reasons, a review of https://stackoverflow.com/questions/...ote-repository may be useful in determining how to modify the above build processes to build the desired commit of the desired branch.


Top of this reference thread: https://www.mersenneforum.org/showthread.php?t=23391
Top of reference tree: https://www.mersenneforum.org/showpo...22&postcount=1

Last fiddled with by kriesel on 2021-03-09 at 23:05 Reason: added "Edit 2021 March 09 paragraph" re building other than latest commit
kriesel is online now