certik / fastGPT

Fast GPT-2 inference written in Fortran
MIT License
180 stars 16 forks source link

CMake improvements #27

Closed scivision closed 1 year ago

scivision commented 1 year ago
certik commented 1 year ago

I tested benchmarks, they seem to be unchanged. I found one issue:

$ FC=gfortran cmake -DFASTGPT_BLAS=OpenBLAS .
-- The C compiler identification is AppleClang 13.0.0.13000029
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is GNU 11.3.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /Users/ondrej/bin/gfortran - skipped
-- Found OPENBLAS: /Users/ondrej/mambaforge/envs/fastgpt/include  
-- Found OpenMP_Fortran: -fopenmp (found version "4.5") 
-- Found OpenMP: TRUE (found version "4.5") found components: Fortran 

Configuration results
---------------------
Fortran compiler: /Users/ondrej/bin/gfortran
Build type: Release
Fortran compiler flags: -Wall -Wextra -Wimplicit-interface -fPIC -O3 -march=native -ffast-math -funroll-loops
Installation prefix: /usr/local
FASTGPT_BLAS: OpenBLAS
-- Configuring done
CMake Warning at CMakeLists.txt:67 (add_executable):
  Cannot generate a safe runtime search path for target gpt2 because files in
  some directories may conflict with libraries in implicit directories:

    runtime library [libgomp.dylib] in /Users/ondrej/repos/spack/opt/spack/darwin-monterey-m1/apple-clang-13.0.0/gcc-11.3.0-wiug7nsdvmtmlzc5whzmrv6enfmxhjt4/lib may be hidden by files in:
      /Users/ondrej/mambaforge/envs/fastgpt/lib

  Some of these libraries may not be found correctly.

-- Generating done
-- Build files have been written to: /Users/ondrej/repos/fastGPT

I am getting a warning now. I use gfortran installed using spack, and I guess it collides with Conda installed OpenMP (that OpenBLAS installs I believe). Do you know how to fix the warning?

scivision commented 1 year ago

either give CMake command line option

cmake -DOpenMP_ROOT=<path to desired OpenMP> -Bbuild

or set environment variable OpenMP_ROOT similarly

Or, make your FindOMP first, and if not found, fall back to factory find_package(OpenMP)

certik commented 1 year ago

I tried this:

FC=gfortran cmake -DFASTGPT_BLAS=OpenBLAS -DOpenMP_ROOT=$CONDA_PREFIX  .

But still the same warning. $CONDA_PREFIX points to /Users/ondrej/mambaforge/envs/fastGPT.

scivision commented 1 year ago

OK I force-pushed to have CMakeLists.txt try your FIndOMP first, then fallback to factory FindOpenMP

certik commented 1 year ago

This works for me now, thanks!