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

[Do not merge] Initial support for auto updating and building dependent third party projects #211

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

silee2
Copy link
Contributor

@silee2 silee2 commented Apr 27, 2022

Current build setup requires all dependent third party components like LLVM/MLIR and level zero loader to be built/installed separately.
This has two issues

  1. complex building steps
  2. need manual update of third party components

This PR addresses those issues by

  1. Single CMake configuration clones and build git based third party components
  2. Third party source version is auto updated if _sha.txt is updated.

The change does not break existing usage cases since the old method of building third party components separately and passing path as CMake config arguments is still supported.
CMake checks if third party components provides a path and only builds components missing path.

@silee2 silee2 mentioned this pull request Apr 27, 2022
@diptorupd diptorupd marked this pull request as draft April 27, 2022 16:56
@diptorupd
Copy link
Contributor

@silee2 Please add a description, I want to understand what you are attempting. I too am making some changes to build system, so we should make sure our changes do not collide.

Since you had a Do not merge in the title, I converted it to draft.

@diptorupd diptorupd self-requested a review April 27, 2022 16:57
@silee2
Copy link
Contributor Author

silee2 commented Apr 27, 2022

@diptorupd Added description.

@diptorupd
Copy link
Contributor

@SiLee I am unable to leave any review comments, maybe my access is not setup correctly.

add_subdirectory(third-party)

if(NOT MLIR_EXT_USE_LLVM_INSTALL_TREE)
set(LLVM_DIR ${PROJECT_BINARY_DIR}/third-party/mlir/llvm-project/llvm/lib/cmake/llvm)
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not like checking out third party repos in IMEX repo. The problem is if you use git clean -dfx the folder will be wiped out. In my Python build_locally.py, I allow users to set a WORKING_DIR or use system temp directory. Let us at least have the option of providing a -DCMAKE_THIRD_PARTY_LIB_PATH` or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The PR does not remove the option of providing -DCMAKE_THIRD_PARTY_LIB_PATH. It only checks out third party repo if -DCMAKE_THIRD_PARTY_LIB_PATH is not provided.

if(GPU_ENABLE)
# Check if using external level-zero
if(DEFINED LEVEL_ZERO_DIR)
set(MLIR_EXT_USE_EXT_LEVEL_ZERO ON)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let us move to IMEX as the prefix of all our CMake flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@@ -0,0 +1 @@
bb7fff05b801e26c3d7858e03e509d1089914d59
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps bind to a released tag for L0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. That was the intention but did not have time to update tag parsing routine. I already had a SHA parse code so just used a SHA instead of tag for now. The SHA points to tag v1.5.0

@@ -70,6 +72,43 @@ macro(apply_llvm_compile_flags target)
target_compile_definitions(${target} PRIVATE ${LLVM_DEFINITIONS})
endmacro()

# Check if using external LLVM/MLIR install tree
if (DEFINED MLIR_DIR)
Copy link
Contributor

Choose a reason for hiding this comment

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

We should really not need two flags. If someone is using an LLVM build without building MLIR project, CMake will throw an error and we should at that point inform user what to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps I am not understanding it right. What does MLIR_DIR point to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MLIR_DIR is defined to guide "find_package(MLIR)" work correctly in CMake.
LLVM_DIR is for "find_package(LLVM)"
Both were already used in the code base. Not introduced by this PR.
Actually find_package(MLIR) will call find_package(LLVM) internally. So we can clean it up but that requires more changes.

Copy link
Contributor

@diptorupd diptorupd left a comment

Choose a reason for hiding this comment

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

I had considered using ExternalProject too. What I did not like was that I needed to first to a make llvm and then make imex.

But, I like the overall direction of the changes. They will not break my Python build script and direct usage of CMake will work as well.

@silee2
Copy link
Contributor Author

silee2 commented Apr 28, 2022

LLVM is not built separately.
LLVM source tree is added to the project by "add_subdirectory()" so it is single make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants