Skip to content

CMake build issues on Linux. #6

Closed

Description

@denis0x0D

Hello everyone, I was trying to build IREE by CMake on Linux and here some minor issues:

  1. The SRCS path to file_io and file_mapping libs
    https://github.com/google/iree/blob/master/iree/base/CMakeLists.txt#L64
    Should the path be "internal/file_io_posix.cc" instead "file_io_posix.cc" and so on?
  2. executable_cache needs iree::base::wait_handle which is commented out in https://github.com/google/iree/blob/master/iree/base/CMakeLists.txt#L349
  3. Tensorflow path, should it be changed from
    build_tools/third_party/tensorflow
    to
    third_party/tensorlow ?

By the way, as far as I understood you have own internal build system, do you have any plans to support stable build under Linux?
Thanks.

Activity

  1. changed the title [-]CMale build issues on Linux.[/-] [+]CMake build issues on Linux.[/+] on Oct 1, 2019
  2. benvanik commented on Oct 1, 2019

    @benvanik
    Collaborator

    Hi! Good catches! We are still working to get the public build working (mostly stalled on figuring out a good way to build Tensorflow via cmake, as it currently only has bazel files), and once we have it working we'll be setting up a CI to ensure it remains buildable on Windows, Linux, and MacOS.

    We use bazel internally and will be adding the build files to the public repo, but wanted to force ourselves to get cmake working first so that it's easier to consume the project (at least the runtime parts) from a non-bazel world. Worst case if we can't get Tensorflow building from cmake we'll have the compiler build with bazel but the runtime parts linked into applications will not need bazel at all.

    We hope to have the compiler figured out in the next week or so (unless you or someone who has done things like this knows of any solutions!), and we'll update this issue as we make progress.

  3. self-assigned this
    on Oct 1, 2019
  4. added
    infrastructure
    on Oct 1, 2019
  5. denis0x0D commented on Oct 1, 2019

    @denis0x0D
    Author

    @benvanik thanks for the quick reply! This is good to know!

  6. benvanik commented on Oct 3, 2019

    @benvanik
    Collaborator

    Update: much closer to building now - the iree-translate binary should build (at least on Windows) but there are still a few missing pieces:

    • SPIR-V translation (needs glslang CMake build/rules for handwritten kernels)
    • Flatbuffer writing/embedding rules to run the samples (invoke iree-translate and then embed the resulting binary in a header)
    • Non-TODO'ed ALWAYSLINK to prevent the need to pass all libs everywhere (for static registration)
    • lit test wrapper that makes proper ctests for CMake testing

    I'll try to get these in this weekend at which point we should have the full end-to-end going. @ScottTodd is working on getting Swiftshader setup so that we can have the full Vulkan + SPIR-V path tested on CI's without GPUs, at which point we'll setup github actions (probably) for all platforms that perform the builds and run all tests.

  7. denis0x0D commented on Oct 4, 2019

    @denis0x0D
    Author

    @benvanik can you please clarify on "handwritten" kernels, sorry if it's a not right thread.
    As far as I understood, plese fix me if I'm wrong, in general, loweing pipeline is:
    TF Dialect (legalize, full convertion) -> XLA Dialect (legalize, partial convertion) -> IREE High level (legalize, full) -> IREE Low level.
    I've skipped some passes which are described here https://github.com/google/iree/blob/master/iree/compiler/Translation/Sequencer/SequencerModuleTranslation.cpp#L217

    The result module is splitted on regions and for example some region could have math operation like "dot"

     %0 = iree.load_input(%arg0 : memref<1x128xf32>) : tensor<1x128xf32>
     %1 = iree.load_input(%arg1 : memref<128x10xf32>) : tensor<128x10xf32>
     %2 = "xla_hlo.dot"(%0, %1) {name = "dot.13", precision_config = ["DEFAULT", "DEFAULT"]} : (tensor<1x128xf32>, tensor<128x10xf32>) -> tensor<1x10xf32>
     iree.store_output(%2 : tensor<1x10xf32>, %arg2 : memref<1x10xf32>)
     iree.return
    

    So, on the next stage of lowering it could be possible to lower "dot" into MLIR SPIR-V or instead specify to use "handwritten" kernel?
    Thanks.

  8. benvanik commented on Oct 4, 2019

    @benvanik
    Collaborator

    You're correct about the flow - we lower through XLA HLO and then allow the backends to do what they want with that. So for the dot in your example above we lower that to an interpreter matmul_f op when we are running on the CPU (which then uses Ruy to perform the GEMM) but in SPIR-V land we (today) lower it to a handwritten kernel (https://github.com/google/iree/blob/master/iree/compiler/Translation/SPIRV/Kernels/matmul.comp). xla_hlo.dot is special, though, and currently the only op we have a handwritten kernel for. All other ops are automatically generated into SPIR-V.

    This is because GEMMs are the most performance heavy op we have and it's not clear that the automatic lowering will be able to achieve matching performance for awhile (if ever). There's also a lot of vendor-specific magic that we want to take advantage of such as Nvidia's cooperative matrix extension (which would be even more difficult to generate code for).

    So the idea is that we can optionally have handwritten implementations but default to generating automatically. An improvement that will be added soon is fusing into the handwritten kernels so that we can merge generated and handwritten IR. Over time we could hopefully remove all handwritten kernels (which, again today is just xla_hlo.dot).

  9. denis0x0D commented on Oct 4, 2019

    @denis0x0D
    Author

    @benvanik thanks for detailed explanation!

  10. denis0x0D commented on Oct 19, 2019

    @denis0x0D
    Author

    @benvanik I'm not sure is ok to report some build issue or not, since it still under development, please let me know if it's not needed.

    1. It seems like those flags https://github.com/google/iree/blob/master/build_tools/cmake/iree_copts.cmake#L31 are "unrecognized" at least by gcc,
    cc1plus: warning: command line option ‘-Wno-strict-prototypes’ is valid for C/ObjC but not for C++
    cc1plus: warning: unrecognized command line option ‘-Wno-documentation-unknown-command’
    cc1plus: warning: unrecognized command line option ‘-Wno-documentation’
    cc1plus: warning: unrecognized command line option ‘-Wno-gnu-label-as-value’
    cc1plus: warning: unrecognized command line option ‘-Wno-missing-variable-declarations’
    cc1plus: warning: unrecognized command line option ‘-Wno-unused-private-field’
    cc1plus: warning: unrecognized command line option ‘-Wno-unreachable-code-return’
    cc1plus: warning: unrecognized command line option ‘-Wno-shadow-field-in-constructor’
    cc1plus: warning: unrecognized command line option ‘-Wno-gnu-zero-variadic-macro-arguments’
    cc1plus: warning: unrecognized command line option ‘-Wno-shadow-uncaptured-local’
    cc1plus: warning: unrecognized command line option ‘-Wno-unused-local-typedef’
    

    the problem accurs when some third party package has "Werror" flag, in this case the build fails.
    My workaround was to add "-Wno-error" to the end of the CMAKE_CXX_FLAGS.

  11. ScottTodd commented on Oct 22, 2019

    @ScottTodd
    Member

    Build issues are still useful to track, thanks for trying what exists so far!

    Yes, the flags aren't compatible with gcc. We've primarily been using clang.

  12. denis0x0D commented on Oct 22, 2019

    @denis0x0D
    Author

    @ScottTodd got it, thanks!

  13. marbre commented on Nov 15, 2019

    @marbre
    Member

    @benvanik The iree-translate binary also builds under Linux (using clang). Anyway, the CMakeLists.txt files need some tweaking to get the build running. If there is interested, I can submit PRs within the next week for the patches I have written so far.

  14. GMNGeoffrey commented on Nov 15, 2019

    @GMNGeoffrey
    Member

    If you've got tweaks to the cmake configs to make things build with clang, we'd happily accept PRs. I'm working on getting us some proper CI on the OSS side so that we can stay on top of these.

  15. GMNGeoffrey commented on Nov 21, 2019

    @GMNGeoffrey
    Member

    FYI we now have a cmake CI, although it excludes the compiler portion of IREE (and therefore the MLIR dependencies). When we do get them working, I can change the option to add these to the CI.

  16. added a commit that references this issue on Dec 10, 2019
  17. ScottTodd commented on Mar 24, 2020

    @ScottTodd
    Member

    Let's close this issue, as most of the problems in the initial report have been resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

infrastructure

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions