KomputeProject / kompute

General purpose GPU compute framework built on Vulkan to support 1000s of cross vendor graphics cards (AMD, Qualcomm, NVIDIA & friends). Blazing fast, mobile-enabled, asynchronous and optimized for advanced GPU data processing usecases. Backed by the Linux Foundation.
http://kompute.cc/
Apache License 2.0
1.94k stars 146 forks source link

Refactor build system #287

Closed COM8 closed 1 year ago

COM8 commented 2 years ago

Why this PR?

I have a couple of problems with the current way Kompute handles dependencies:

  1. git-Submodules are a rather outdated concept in my eyes and should be replaced since they are always a pain to use and are not flexible in any way.
  2. When including Kompute in a project that also uses Spdlog, it beaks a lot of stuff, e.g. Log-Macros stay in code, but we do not link Kompute against Spdlog.
  3. On my System (Fedora) Vulkan-Headers >= 1.3.0 are available, but my driver (mesa/intel) supports only >= 1.2.131. Well I need to link against a different version Vulkan-Headers without downgrading my System Vulkan-Headers since other applications depend on those. If I don't change the Vulkan-Header version, I always run into the following assertion: VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION );

Proposed Solutions

What is left to do?

Things that need to be done once the PR has been merged

Let me know what you think about this.

axsaucedo commented 2 years ago

Hey @COM8 - thank you for this PR, this all sounds great. Here's a couple of comments on the proposed actions:

I also cleaned up all CMake options related to dependencies and fixed a few bugs here and there to solve 2.

Sounds good, would be good to explicitly list them in the PR description.

My main suggestion would be to do this in iterative chunks, as opposed to a massive PR, mainyl to avoid potentially a situation where there's too much at once. Only mentioning this as I've started to see some changes in the git jobs, which I actually do like, but mainly to break down into different PRs so it's simpler/smoother to merge.

COM8 commented 2 years ago

Agree with all of your points, Then I will keep this PR open as "current" stat and as soon as I'm happy with the result, I will create smaller PRs.

COM8 commented 2 years ago

When I tried splitting up my changes into multiple smaller PRs I noticed a lot of other stuff needing to be fixed. So basically I'm planing to do a rewrite of the complete build system over at my fork: https://github.com/COM8/kompute

This will roughly take me one month and since especially the Makefile stuff is not really portable I plan to integrate what ever possible directly into CMake e.g. compiling shaders: https://github.com/COM8/movement-sim/blob/main/cmake/vulkan_shader_compiler.cmake

I will the try to outline every breaking change I did and why it was necessary in a clear manner and try to get in touch with you in case I need to change anything large.

axsaucedo commented 2 years ago

Ok interesting @COM8 - I would still be keen to look towards merging the initial improvements in an iterative way where possible, as I like already some of the ideas on moving away from git modules as that would already make it much better. Certianly if you do need a hand let me know - happy to help here, or you can also join the discord and I am active there for any questions

COM8 commented 2 years ago

This PR is now ready for its first review. Things that need to be done:

axsaucedo commented 2 years ago

I'm currently testing locally and I'm getting

Cannot create Vulkan instance.
This problem is often caused by a faulty installation of the Vulkan driver or attempting to use a GPU that does not support Vulkan.
ERROR at /build/vulkan-tools-1.2.148.0-1ubuntu18.04/vulkaninfo/vulkaninfo.h:641:vkCreateInstance failed with ERROR_INCOMPATIBLE_DRIVER
CMake Error at cmake/check_vulkan_version.cmake:61 (string):
  string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
  command.
Call Stack (most recent call first):
  CMakeLists.txt:116 (check_vulkan_version)

Have you seen this before? Would it be due to the version of my vulkan setup?

COM8 commented 2 years ago

I'm currently testing locally and I'm getting

Cannot create Vulkan instance.
This problem is often caused by a faulty installation of the Vulkan driver or attempting to use a GPU that does not support Vulkan.
ERROR at /build/vulkan-tools-1.2.148.0-1ubuntu18.04/vulkaninfo/vulkaninfo.h:641:vkCreateInstance failed with ERROR_INCOMPATIBLE_DRIVER
CMake Error at cmake/check_vulkan_version.cmake:61 (string):
  string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
  command.
Call Stack (most recent call first):
  CMakeLists.txt:116 (check_vulkan_version)

Have you seen this before? Would it be due to the version of my vulkan setup?

Hmmm, I have never seen such an error before. But I see a potential error in cmake/check_vulkan_version.cmake:61 resulting from this "crash".

axsaucedo commented 2 years ago

Just tried from the latest to build but it seems it gets frozen iwth infinite loop on:

...etc
--   KOMPUTE_OPT_BUILD_SHADERS: 1
--   KOMPUTE_OPT_USE_BUILD_IN_SPDLOG: ON
--   KOMPUTE_OPT_USE_BUILD_IN_FMT: ON
--   KOMPUTE_OPT_USE_BUILD_IN_GOOGLE_TEST: ON
--   KOMPUTE_OPT_USE_BUILD_IN_PYBIND11: ON
--   KOMPUTE_OPT_USE_BUILD_IN_VULKAN_HEADER: ON
--   KOMPUTE_OPT_BUILD_IN_VULKAN_HEADER_TAG: v1.2.203
-- =======================================================
-- Ensuring the currently installed driver supports the Vulkan version requested by the Vulkan Header.
-- Found Vulkan Header version 1.2.203.

Wondering if the trailing . could be causing an issue?

COM8 commented 2 years ago

@axsaucedo Is there anything else I can do on this PR?

axsaucedo commented 2 years ago

@COM8 thank you for following up - just pinged on Discord, I will be keen to merge soon, planning to do a pass asap in the next / following week

axsaucedo commented 1 year ago

@COM8 I am thinking of merging this quite soon to make sure we can get the ball rolling on the rest of the PRs, however I can't seem to get the Android examples working unfortunately - are you able to run these example successfully on your end?

COM8 commented 1 year ago

Nope, never have tried compiling them for android since I have no toolchain set up for this. But I can try to set up one if this helps.

axsaucedo commented 1 year ago

That would be great if you get a chance @COM8 - I will be diving into it during the weekend as well to get this and the rest of the examples working correctly, I want then to move towards merging so any further changes can be done from master as there's already also some other interesting PRs to explore (Such as upgrading to vulkan 1.3)

COM8 commented 1 year ago

ACK, will try to work on it during the next week.

COM8 commented 1 year ago

Quick update: I got it almost up and running. Just some minor things like fixing the Vulkan function templates still left to do. Sadly I won't have too much time over the next three weeks while I'm finishing my thesis. So this one might get delayed a bit. Sorry...

axsaucedo commented 1 year ago

@COM8 that's fantastic news! It would be really helpful if you do manage to get it through as for some reason I'm still having issues in my set up - no worries at all tho, great to hear you're looking to finish/wrap your theses, hopefully I am able to finalise it before then but otherwise we can have a look once you get a chance again

COM8 commented 1 year ago

@axsaucedo it is done! The android example builds again. But when clicking on the button and when creating a kp::Manager it crashes with a segfault...

I'm looking into this one right now.

Could you please confirm quickly it's also building on your system?

COM8 commented 1 year ago

Done. Now everything works. Ready for a final review.

axsaucedo commented 1 year ago

That's fantastic @COM8 ! I am just back from a conference this week so I will be able to review and rerun all the examples.

PS Hope everything went smooth with the thesis

COM8 commented 1 year ago

Great to hear. Yes, from my side everything worked perfectly!