Page 1 of 3 123 LastLast
Results 1 to 10 of 22

Thread: How to enable OpenMP on cmake gcc? (covid-sim)

Hybrid View

  1. #1
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    158

    Default How to enable OpenMP on cmake gcc? (covid-sim)

    Hello,

    I am trying to build covid-sim.
    It need OpenMP to be useful.
    https://build.opensuse.org/package/s...reat/covid-sim
    https://github.com/mrc-ide/covid-sim/issues/349

    OpenMP is a feature in gcc is not it?
    It seems like I have not enable OpenMP properly.

    I add
    Code:
    BuildRequires:  libgomp1
    and build flags
    Code:
    %cmake -DUSE_OPENMP:BOOL=ON \
           -DOpenMP_CXX_FLAGS:STRING=libomp \
           -DOpenMP_C_FLAGS:STRING=libomp \
           -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix}
    But still encounter warning which I believe cause the build to fail.

    Code:
    /home/abuild/rpmbuild/BUILD/covid-sim-0.13.0/src/CovidSim.cpp:2711: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
    2711 | #pragma omp parallel for schedule(static,1) default(none) \
    Thanks you.

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,111
    Blog Entries
    15

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Hi
    That's a runtime library for running programs that have been compiled with openmp?

    Code:
    This is the OpenMP runtime library needed by OpenMP enabled programs 
    that were built with the -fopenmp compiler option and by programs that 
    were auto-parallelized via the -ftree-parallelize-loops compiler 
    option.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    158

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Quote Originally Posted by malcolmlewis View Post
    Hi
    That's a runtime library for running programs that have been compiled with openmp?

    Code:
    This is the OpenMP runtime library needed by OpenMP enabled programs 
    that were built with the -fopenmp compiler option and by programs that 
    were auto-parallelized via the -ftree-parallelize-loops compiler 
    option.
    Hello,
    Did you mean the libgomp1 dependency I included? I am not sure if it is needed, I just found some random recommendation.
    I have change the flags as my old one seems to be wrong.

    I think I use it correctly now. Still, I am uncertain what went wrong from the build log.
    Code:
    %cmake -DUSE_OPENMP:BOOL=ON \
           -DOpenMP_CXX_FLAGS:STRING="%{optflags} -fopenmp" \
           -DOpenMP_C_FLAGS:STRING="%{optflags} -fopenmp" \
           -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix}
    I believe that this is the error isn't it? But it is specific to covid-sim rather than cmake?
    Code:
    #pragma omp parallel for schedule(static,500) default(none) \

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,111
    Blog Entries
    15

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Hi
    The flags are already set and USE_OPENMP is already on?
    https://github.com/mrc-ide/covid-sim...CMakeLists.txt

    I would suggest a first step is to build as per instructions, no using the macros....

    Code:
    mkdir build
    cd build
    cmake ..
    make
    Code:
    git clone https://github.com/mrc-ide/covid-sim.git
    
    Cloning into 'covid-sim'...
    remote: Enumerating objects: 46, done.
    remote: Counting objects: 100% (46/46), done.
    remote: Compressing objects: 100% (34/34), done.
    remote: Total 6871 (delta 23), reused 25 (delta 12), pack-reused 6825
    Receiving objects: 100% (6871/6871), 101.93 MiB | 5.86 MiB/s, done.
    Resolving deltas: 100% (5715/5715), done.
    
    cd covid-sim
    mkdir build
    cd build
    
    cmake ..
    
    -- The C compiler identification is GNU 9.3.1
    -- The CXX compiler identification is GNU 9.3.1
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc - works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ - works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Setting build type to 'RelWithDebInfo' as none was specified.
    -- Found OpenMP_C: -fopenmp (found version "4.5") 
    -- Found OpenMP_CXX: -fopenmp (found version "4.5") 
    -- Found OpenMP: TRUE (found version "4.5")  
    -- Found Python3: /usr/bin/python3.8 (found version "3.8.3") found components: Interpreter 
    -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/repositories/covid-sim/build
    
    /data/repositories/covid-sim/build> make
    
    Scanning dependencies of target CovidSim
    [  6%] Building CXX object src/CMakeFiles/CovidSim.dir/CovidSim.cpp.o
    [ 13%] Building CXX object src/CMakeFiles/CovidSim.dir/BinIO.cpp.o
    [ 20%] Building CXX object src/CMakeFiles/CovidSim.dir/Rand.cpp.o
    [ 26%] Building CXX object src/CMakeFiles/CovidSim.dir/Error.cpp.o
    [ 33%] Building CXX object src/CMakeFiles/CovidSim.dir/Dist.cpp.o
    [ 40%] Building CXX object src/CMakeFiles/CovidSim.dir/Kernels.cpp.o
    [ 46%] Building CXX object src/CMakeFiles/CovidSim.dir/Bitmap.cpp.o
    [ 53%] Building CXX object src/CMakeFiles/CovidSim.dir/SetupModel.cpp.o
    [ 60%] Building CXX object src/CMakeFiles/CovidSim.dir/CalcInfSusc.cpp.o
    [ 66%] Building CXX object src/CMakeFiles/CovidSim.dir/Sweep.cpp.o
    [ 73%] Building CXX object src/CMakeFiles/CovidSim.dir/Update.cpp.o
    [ 80%] Building CXX object src/CMakeFiles/CovidSim.dir/Param.cpp.o
    [ 86%] Building CXX object src/CMakeFiles/CovidSim.dir/MicroCellPosition.cpp.o
    [ 93%] Building CXX object src/CMakeFiles/CovidSim.dir/Direction.cpp.o
    [100%] Linking CXX executable CovidSim
    [100%] Built target CovidSim
    Note gcc 9

    Additional note: add cmake -DCMAKE_VERBOSE_MAKEFILE=ON .. for verbose make output...
    Last edited by malcolmlewis; 31-May-2020 at 19:11.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    158

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Quote Originally Posted by malcolmlewis View Post
    Hi
    The flags are already set and USE_OPENMP is already on?
    https://github.com/mrc-ide/covid-sim...CMakeLists.txt

    I would suggest a first step is to build as per instructions, no using the macros....

    Code:
    mkdir build
    cd build
    cmake ..
    make
    Code:
    git clone https://github.com/mrc-ide/covid-sim.git
    
    Cloning into 'covid-sim'...
    remote: Enumerating objects: 46, done.
    remote: Counting objects: 100% (46/46), done.
    remote: Compressing objects: 100% (34/34), done.
    remote: Total 6871 (delta 23), reused 25 (delta 12), pack-reused 6825
    Receiving objects: 100% (6871/6871), 101.93 MiB | 5.86 MiB/s, done.
    Resolving deltas: 100% (5715/5715), done.
    
    cd covid-sim
    mkdir build
    cd build
    
    cmake ..
    
    -- The C compiler identification is GNU 9.3.1
    -- The CXX compiler identification is GNU 9.3.1
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc - works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ - works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Setting build type to 'RelWithDebInfo' as none was specified.
    -- Found OpenMP_C: -fopenmp (found version "4.5") 
    -- Found OpenMP_CXX: -fopenmp (found version "4.5") 
    -- Found OpenMP: TRUE (found version "4.5")  
    -- Found Python3: /usr/bin/python3.8 (found version "3.8.3") found components: Interpreter 
    -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /data/repositories/covid-sim/build
    
    /data/repositories/covid-sim/build> make
    
    Scanning dependencies of target CovidSim
    [  6%] Building CXX object src/CMakeFiles/CovidSim.dir/CovidSim.cpp.o
    [ 13%] Building CXX object src/CMakeFiles/CovidSim.dir/BinIO.cpp.o
    [ 20%] Building CXX object src/CMakeFiles/CovidSim.dir/Rand.cpp.o
    [ 26%] Building CXX object src/CMakeFiles/CovidSim.dir/Error.cpp.o
    [ 33%] Building CXX object src/CMakeFiles/CovidSim.dir/Dist.cpp.o
    [ 40%] Building CXX object src/CMakeFiles/CovidSim.dir/Kernels.cpp.o
    [ 46%] Building CXX object src/CMakeFiles/CovidSim.dir/Bitmap.cpp.o
    [ 53%] Building CXX object src/CMakeFiles/CovidSim.dir/SetupModel.cpp.o
    [ 60%] Building CXX object src/CMakeFiles/CovidSim.dir/CalcInfSusc.cpp.o
    [ 66%] Building CXX object src/CMakeFiles/CovidSim.dir/Sweep.cpp.o
    [ 73%] Building CXX object src/CMakeFiles/CovidSim.dir/Update.cpp.o
    [ 80%] Building CXX object src/CMakeFiles/CovidSim.dir/Param.cpp.o
    [ 86%] Building CXX object src/CMakeFiles/CovidSim.dir/MicroCellPosition.cpp.o
    [ 93%] Building CXX object src/CMakeFiles/CovidSim.dir/Direction.cpp.o
    [100%] Linking CXX executable CovidSim
    [100%] Built target CovidSim
    Note gcc 9

    Additional note: add cmake -DCMAKE_VERBOSE_MAKEFILE=ON .. for verbose make output...
    Hello,
    I should have tried building on my local machine first as you said.
    But covid-sim would still not found openMP on my TW machine.
    So OpenMP is a feature in gcc. From what I understand C compiler and CXX compiler mustbe the same version for OpenMP to detect properly.

    Code:
    andy@linux:~/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build> cmake ..
    -- The C compiler identification is GNU 9.3.1
    -- The CXX compiler identification is GNU 9.3.1
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc - works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ - works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Setting build type to 'RelWithDebInfo' as none was specified.
    CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
      Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
    Call Stack (most recent call first):
      /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
      /usr/share/cmake/Modules/FindOpenMP.cmake:529 (find_package_handle_standard_args)
      CMakeLists.txt:35 (find_package)
    
    
    -- Configuring incomplete, errors occurred!

    The C compiler identification is GNU and CXX compiler identification is 9.3.1.

    I look inside CMakeError.log, don't look like anything useful.
    Code:
    Detecting C OpenMP failed with the following output:
    Change Dir: /home/kev-test/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake cmTC_052e2/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_052e2.dir/build.make CMakeFiles/cmTC_052e2.dir/build
    gmake[1]: Entering directory '/home/kev-test/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build/CMakeFiles/CMakeTmp'
    CMakeFiles/cmTC_052e2.dir/build.make:84: *** target pattern contains no '%'.  Stop.
    gmake[1]: Leaving directory '/home/kev-test/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:141: cmTC_052e2/fast] Error 2
    
    
    
    Detecting CXX OpenMP failed with the following output:
    Change Dir: /home/kev-test/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake cmTC_4a0e5/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_4a0e5.dir/build.make CMakeFiles/cmTC_4a0e5.dir/build
    gmake[1]: Entering directory '/home/kev-test/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build/CMakeFiles/CMakeTmp'
    CMakeFiles/cmTC_4a0e5.dir/build.make:84: *** target pattern contains no '%'.  Stop.
    gmake[1]: Leaving directory '/home/kev-test/Desktop/Software/OBS Projects/home:andythe_great/covid-sim/covid-sim-0.13.0/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:141: cmTC_4a0e5/fast] Error 2
    I'm a bit lost.

    Thanks.

    Edit: Trying to use "cmake .. -DOpenMP_C_FLAGS=-fopenmp" yields the same error.

  6. #6
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,111
    Blog Entries
    15

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Quote Originally Posted by andythe_great View Post
    I'm a bit lost.
    Hi
    Is glibc-devel installed?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  7. #7
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    158

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Quote Originally Posted by malcolmlewis View Post
    Hi
    Is glibc-devel installed?
    Yes, both glibc and glibc-devel.

  8. #8
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,111
    Blog Entries
    15

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Quote Originally Posted by andythe_great View Post
    Yes, both glibc and glibc-devel.
    Hi
    There is something wrong with your local build environment... I tested here on Leap 15.1 and SLED 15 SP2 beta, both ran cmake fine and detected OpenMP present...
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  9. #9
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,111
    Blog Entries
    15

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  10. #10
    Join Date
    Oct 2018
    Location
    Atlantis
    Posts
    158

    Default Re: How to enable OpenMP on cmake gcc? (covid-sim)

    Quote Originally Posted by malcolmlewis View Post
    Hi
    There is something wrong with your local build environment... I tested here on Leap 15.1 and SLED 15 SP2 beta, both ran cmake fine and detected OpenMP present...
    You are right, I tried running openSUSE TW live ISO and it can compile locally.
    I see you use install -Dm0755 instead of %cmake_install.
    Looking at https://build.opensuse.org/package/v...acros?expand=1

    Code:
    %cmake_install \
        DESTDIR=%{buildroot} %__builder install -C %__builddir
    The difference is just the "-C"? How does that make a difference?

    Thank so much for help.

    ps. Veyon package was submit for review, it now build on TW.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •