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

Adding missing features of CMakeLists.txt & Refactoring #131

Merged
merged 7 commits into from
Mar 21, 2023
Merged

Adding missing features of CMakeLists.txt & Refactoring #131

merged 7 commits into from
Mar 21, 2023

Conversation

nusu-github
Copy link
Contributor

We have come up with several changes to CMakeLists.txt that are expected to improve performance, compatibility, and maintainability, and we have drafted them.

Change list :

  1. remove NO from option names that have NO in the option name.
    Change LLAMA_NO_ACCELERATE to LLAMA_ACCELERATE to avoid "NOT NO" in if statements.
  2. make it possible to enable/disable SIMD extension instructions for non-Apple.
    I see no reason to make it Apple-only. It should be possible to enable/disable on all platforms.
  3. give priority to CMake functions.
    Use "add_compile_options" instead of writing directly to CMAKE_C_FLAGS to avoid double flags and compile errors due to typos.
  4. Add new options.
    LLAMA_STATIC_LINK, LLAMA_NATIVE, and LLAMA_LTO were added.
    LLAMA_STATIC_LINK is an option to enable static linking. This will be useful when compiling for Windows with MinGW and for future distribution.
    Also, LLAMA_NATIVE to add -march=native and LLAMA_LTO for link-time optimization will both be useful options for this project for speed.
  5. other changes.
    cmake_minimum_required was changed to 3.9 for LTO support.
    CMAKE_CXX_STANDARD was changed to c++11, the same as in the Makefile.
    I made utils build using add_library and link to it.
    Added Threads link since it was missing.
    Added option LLAMA_OPENBLAS. (Not tested).

We have confirmed that it works on MSVC, MSVC Clang GUN like (not clang-cl), MinGW, and Cygwin on Windows, but have not confirmed that it works on other platforms.
Also, prioritizing CMake's features may sometimes sacrifice simplicity.

P.S. Sorry if there is any strange English. This is using automatic translation.

Refactoring:
1. Simplify more options that are negation of negation.
LLAMA_NO_ACCELERATE -> LLAMA_ACCELERATE
2. Changed to an optional expression instead of forcing to enable AVX2 in MSVC.
3. Make CMAKE_CXX_STANDARD, which is different from Makefile, the same.
4. Use add_compile_options instead of adding options to CMAKE_C_FLAGS.
5. Make utils use target_link_libraries instead of directly referencing code.

Added features:
1. Added some options.
LLAMA_STATIC_LINK,LLAMA_NATIVE,LLAMA_LTO,LLAMA_GPROF,LLAMA_OPENBLAS
@ggerganov ggerganov marked this pull request as ready for review March 19, 2023 17:52
@ggerganov
Copy link
Member

Someone figure out with the Windows build is failing and merge

@nusu-github
Copy link
Contributor Author

LLAMA_LTO was changed so that it can be used outside of Release so that it can be built on Windows.

Copy link
Collaborator

@Green-Sky Green-Sky left a comment

Choose a reason for hiding this comment

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

@ggerganov should we upgrade form cmake 3.9 to 3.12 ?

@gjmulder gjmulder added enhancement New feature or request build Compilation issues labels Mar 20, 2023
@Green-Sky Green-Sky self-requested a review March 21, 2023 00:14
@Green-Sky Green-Sky merged commit 8cf9f34 into ggml-org:master Mar 21, 2023
@anzz1
Copy link
Contributor

anzz1 commented Mar 21, 2023

What is the reasoning for changing C++11 standard to C++17 since the project does not use any of C++17 extensions? To my knowledge all compiler versions which support C++17 also support C++11, but not vice-versa.

@Green-Sky
Copy link
Collaborator

@anzz1 we have been using c++17 features (string_view) since 074bea2

@nusu-github nusu-github deleted the patch-1 branch March 21, 2023 16:14
rooprob pushed a commit to rooprob/llama.cpp that referenced this pull request Aug 2, 2023
readme: Include reference to go port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Compilation issues enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants